Skip to content

Commit

Permalink
add source interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
catornot committed Jan 7, 2024
1 parent 20eb5a0 commit 6d1c626
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 169 deletions.
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rrplug"
version = "3.0.0"
version = "4.0.0"
authors = ["catornot"]
description = "wrappers and functions for R2Northstar plugins"
repository = "https://github.com/catornot/rrplug"
Expand All @@ -23,6 +23,5 @@ default-target = "x86_64-pc-windows-msvc"
targets = ["x86_64-pc-windows-msvc"]

[features]
default = ["default_features"]
default_features = [ ]
full = [ ]
default = []
async_engine = []
74 changes: 0 additions & 74 deletions rrplug_proc/Cargo.lock

This file was deleted.

28 changes: 14 additions & 14 deletions rrplug_proc/src/impl_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn get_from_sqvm_impl_struct(input: DeriveInput) -> TokenStream {
stack_pos: i32,
) -> Self {
use rrplug::{high::squirrel_traits::GetFromSQObject,bindings::squirreldatatypes::SQObject};
let sqstruct = unsafe {
let sqstruct = unsafe {
let sqvm = sqvm.as_ref().expect("sqvm has to be valid");
((*sqvm._stackOfCurrentFunction.add(stack_pos as usize))
._VAL
Expand Down Expand Up @@ -129,9 +129,9 @@ pub fn get_from_sqvm_impl_enum(input: DeriveInput) -> TokenStream {
sqvm: *mut HSquirrelVM,
sqfunctions: &SquirrelFunctionsUnwraped,
stack_pos: i32,
) -> Self {
) -> Self {
const _ :#ident<#generics> = unsafe { std::mem::transmute::<i32,#ident<#generics>>(0) };

let value = unsafe { rrplug::mid::squirrel::get_sq_int(sqvm, sqfunctions, stack_pos) };

if value >= #ident::#varient_first as i32 && value <= #ident::#varient_last as i32 {
Expand Down Expand Up @@ -197,7 +197,7 @@ pub fn get_from_sqobject_impl_enum(input: DeriveInput) -> TokenStream {
#[allow(clippy::not_unsafe_ptr_arg_deref)]
fn get_from_sqobject(obj: &rrplug::bindings::squirreldatatypes::SQObject) -> Self {
const _: #ident<#generics> = unsafe { std::mem::transmute::<i32,#ident<#generics>>(0) };

let value = unsafe { obj._VAL.asInteger };

if value >= #ident::#varient_first as i32 && value <= #ident::#varient_last as i32 {
Expand All @@ -214,13 +214,14 @@ pub fn get_from_sqobject_impl_enum(input: DeriveInput) -> TokenStream {
// TODO: refactor this to use what I have in the other implemantion of this
// whar, past self?
pub fn get_from_sqobject_impl_struct(input: DeriveInput) -> TokenStream {
let DeriveInput { // copying this from system clipboard destroyed this, but I won't fix this today
attrs: _,
vis: _,
ident,
generics,
data,
} = input;
let DeriveInput {
// copying this from system clipboard destroyed this, but I won't fix this today
attrs: _,
vis: _,
ident,
generics,
data,
} = input;
let fields = get_struct_fields(data);
let field_idents: Vec<Ident> = fields.iter().cloned().filter_map(|f| f.ident).collect();
let field_amount = field_idents.len() as u32;
Expand All @@ -229,8 +230,8 @@ pub fn get_from_sqobject_impl_struct(input: DeriveInput) -> TokenStream {
#[allow(clippy::not_unsafe_ptr_arg_deref)] // smth should be done about this
#[inline]
fn get_from_sqobject(obj: &rrplug::bindings::squirreldatatypes::SQObject) -> Self {
use rrplug::{high::squirrel_traits::GetFromSQObject,bindings::squirreldatatypes::SQObject};
let sqstruct = unsafe {
use rrplug::{high::squirrel_traits::getfromsqobject,bindings::squirreldatatypes::sqobject};
let sqstruct = unsafe {
obj
._VAL
.asStructInstance
Expand All @@ -253,7 +254,6 @@ pub fn get_from_sqobject_impl_struct(input: DeriveInput) -> TokenStream {
.into()
}


pub fn sqvm_name_impl(input: DeriveInput) -> TokenStream {
let DeriveInput {
attrs: _,
Expand Down
Loading

0 comments on commit 6d1c626

Please sign in to comment.