mirror of
https://github.com/fluencelabs/marine-rs-sdk-test
synced 2024-12-04 15:20:18 +00:00
Add unsafe wrapper for imports for not wasm target (#52)
This commit is contained in:
parent
6460362f92
commit
84d5c2af66
80
Cargo.lock
generated
80
Cargo.lock
generated
@ -408,7 +408,7 @@ dependencies = [
|
||||
"log",
|
||||
"marine-module-interface",
|
||||
"marine-rs-sdk 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"marine-rs-sdk-main 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"marine-rs-sdk-main 0.6.10",
|
||||
"marine-runtime",
|
||||
"marine-utils",
|
||||
"safe-transmute",
|
||||
@ -706,7 +706,7 @@ dependencies = [
|
||||
"cargo_toml",
|
||||
"it-lilo",
|
||||
"marine-it-parser 0.6.5",
|
||||
"marine-macro-impl 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"marine-macro-impl 0.6.10",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@ -774,30 +774,17 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "marine-macro"
|
||||
version = "0.6.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd64d5febc6b2ed709a4461c510c1429dc6e4cfcbd6ca0d88463911630acd67b"
|
||||
dependencies = [
|
||||
"marine-macro-impl 0.6.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-macro"
|
||||
version = "0.6.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd64d5febc6b2ed709a4461c510c1429dc6e4cfcbd6ca0d88463911630acd67b"
|
||||
version = "0.6.11"
|
||||
dependencies = [
|
||||
"marine-macro-impl 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-macro-impl"
|
||||
version = "0.6.10"
|
||||
dependencies = [
|
||||
"pretty_assertions",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn",
|
||||
"uuid",
|
||||
"marine-macro-impl 0.6.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -814,6 +801,19 @@ dependencies = [
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-macro-impl"
|
||||
version = "0.6.11"
|
||||
dependencies = [
|
||||
"pretty_assertions",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-module-info-parser"
|
||||
version = "0.2.0"
|
||||
@ -822,7 +822,7 @@ checksum = "b4a0951d77c38171d8b2ddcc888d1153a2c4f777b3b7a7dca093a06c69b32d77"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
"marine-rs-sdk-main 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"marine-rs-sdk-main 0.6.10",
|
||||
"semver 0.11.0",
|
||||
"serde",
|
||||
"thiserror",
|
||||
@ -852,9 +852,9 @@ dependencies = [
|
||||
name = "marine-rs-sdk"
|
||||
version = "0.6.11"
|
||||
dependencies = [
|
||||
"marine-macro 0.6.10",
|
||||
"marine-rs-sdk-main 0.6.10",
|
||||
"marine-timestamp-macro 0.6.10",
|
||||
"marine-macro 0.6.11",
|
||||
"marine-rs-sdk-main 0.6.11",
|
||||
"marine-timestamp-macro 0.6.11",
|
||||
"serde",
|
||||
"trybuild",
|
||||
]
|
||||
@ -865,21 +865,10 @@ version = "0.6.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9157bae63a4bbdd7a29984f6ded08f8ed72991b83ca3bdd59d2f889fa8b8ea02"
|
||||
dependencies = [
|
||||
"marine-macro 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"marine-rs-sdk-main 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"marine-timestamp-macro 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-rs-sdk-main"
|
||||
version = "0.6.10"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"marine-macro 0.6.10",
|
||||
"marine-rs-sdk-main 0.6.10",
|
||||
"marine-timestamp-macro 0.6.10",
|
||||
"serde",
|
||||
"simple_logger",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -889,10 +878,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95c49b5893d8689589219e07cf67421cc415dc5f219ad0e9c197a9a050b5dd4f"
|
||||
dependencies = [
|
||||
"log",
|
||||
"marine-macro 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"marine-macro 0.6.10",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-rs-sdk-main"
|
||||
version = "0.6.11"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"marine-macro 0.6.11",
|
||||
"serde",
|
||||
"simple_logger",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-rs-sdk-test"
|
||||
version = "0.1.11"
|
||||
@ -962,6 +962,8 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "marine-timestamp-macro"
|
||||
version = "0.6.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29ae1a5630bd9b652a77405750c3c37a5fdcfcdc679818bf7d970871ae28f7e6"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"quote",
|
||||
@ -969,9 +971,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marine-timestamp-macro"
|
||||
version = "0.6.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29ae1a5630bd9b652a77405750c3c37a5fdcfcdc679818bf7d970871ae28f7e6"
|
||||
version = "0.6.11"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"quote",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "marine-rs-sdk-main"
|
||||
version = "0.6.10" # remember to update html_root_url
|
||||
version = "0.6.11" # remember to update html_root_url
|
||||
edition = "2018"
|
||||
description = "Contains logger, allocators and several other modules for marine-rs-sdk"
|
||||
documentation = "https://docs.rs/marine-rs-sdk-main"
|
||||
@ -19,7 +19,7 @@ crate-type = ["rlib"]
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
marine-macro = { path = "../marine-macro", version = "=0.6.10" }
|
||||
marine-macro = { path = "../marine-macro", version = "=0.6.11" }
|
||||
|
||||
log = { version = "0.4.8", features = ["std"] }
|
||||
serde = "=1.0.118"
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#![allow(clippy::missing_safety_doc)]
|
||||
#![allow(clippy::needless_doctest_main)]
|
||||
#![doc(html_root_url = "https://docs.rs/marine-rs-sdk-main/0.6.10")]
|
||||
#![doc(html_root_url = "https://docs.rs/marine-rs-sdk-main/0.6.11")]
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "marine-macro-impl"
|
||||
version = "0.6.10" # remember to update html_root_url
|
||||
version = "0.6.11" # remember to update html_root_url
|
||||
edition = "2018"
|
||||
description = "Implementation of the `#[marine]` macro"
|
||||
documentation = "https://docs.rs/fluence/marine-macro-impl"
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/marine-macro-impl/0.6.10")]
|
||||
#![doc(html_root_url = "https://docs.rs/marine-macro-impl/0.6.11")]
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
|
@ -92,6 +92,15 @@ pub(crate) fn generate_fn_return_type(ty: &Option<ParsedType>) -> proc_macro2::T
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn generate_fn_original_return_type(
|
||||
ty: &Option<ParsedType>,
|
||||
) -> proc_macro2::TokenStream {
|
||||
match &ty {
|
||||
Some(ty) => quote! {-> #ty},
|
||||
None => <_>::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn generate_return_expression(ty: &Option<ParsedType>) -> proc_macro2::TokenStream {
|
||||
match ty {
|
||||
None => quote! {},
|
||||
|
@ -34,19 +34,23 @@ impl quote::ToTokens for ast_types::AstExternMod {
|
||||
);
|
||||
|
||||
let wasm_import_module_name = &self.namespace;
|
||||
let original = &self.original;
|
||||
let generated_imports = generate_extern_section_items(&self);
|
||||
let wasm_section_items = generate_extern_section_items(&self, wasm_extern_item_generator);
|
||||
let not_wasm_section_items =
|
||||
generate_extern_section_items(&self, not_wasm_extern_item_generator);
|
||||
|
||||
let wrapper_functions = generate_wrapper_functions(&self);
|
||||
|
||||
let glue_code = quote! {
|
||||
#[link(wasm_import_module = #wasm_import_module_name)]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
extern "C" {
|
||||
#(#generated_imports)*
|
||||
#(#wasm_section_items)*
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#original
|
||||
extern "C" {
|
||||
#(#not_wasm_section_items)*
|
||||
}
|
||||
|
||||
#wrapper_functions
|
||||
|
||||
@ -61,30 +65,62 @@ impl quote::ToTokens for ast_types::AstExternMod {
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_extern_section_items(extern_item: &ast_types::AstExternMod) -> Vec<TokenStream> {
|
||||
fn generate_extern_section_items(
|
||||
extern_item: &ast_types::AstExternMod,
|
||||
item_generator: fn(&ast_types::AstExternFn) -> TokenStream,
|
||||
) -> Vec<TokenStream> {
|
||||
let mut section_items = Vec::with_capacity(extern_item.imports.len());
|
||||
|
||||
for import in &extern_item.imports {
|
||||
let signature = &import.signature;
|
||||
let fn_return_type = crate::parsed_type::generate_fn_return_type(&signature.output_type);
|
||||
let link_name = import.link_name.as_ref().unwrap_or(&signature.name);
|
||||
let import_name = generate_import_name(&signature.name);
|
||||
let ExternDescriptor {
|
||||
raw_arg_names,
|
||||
raw_arg_types,
|
||||
} = signature.arguments.generate_extern_prolog();
|
||||
|
||||
let func = quote! {
|
||||
#[link_name = #link_name]
|
||||
fn #import_name(#(#raw_arg_names: #raw_arg_types),*) #fn_return_type;
|
||||
};
|
||||
|
||||
section_items.push(func);
|
||||
section_items.push(item_generator(&import));
|
||||
}
|
||||
|
||||
section_items
|
||||
}
|
||||
|
||||
fn wasm_extern_item_generator(import: &ast_types::AstExternFn) -> TokenStream {
|
||||
let signature = &import.signature;
|
||||
let fn_return_type = crate::parsed_type::generate_fn_return_type(&signature.output_type);
|
||||
let link_name = import.link_name.as_ref().unwrap_or(&signature.name);
|
||||
let import_name = generate_import_name(&signature.name);
|
||||
let ExternDescriptor {
|
||||
raw_arg_names,
|
||||
raw_arg_types,
|
||||
} = signature.arguments.generate_extern_prolog();
|
||||
|
||||
quote! {
|
||||
#[link_name = #link_name]
|
||||
fn #import_name(#(#raw_arg_names: #raw_arg_types),*) #fn_return_type;
|
||||
}
|
||||
}
|
||||
|
||||
fn not_wasm_extern_item_generator(import: &ast_types::AstExternFn) -> TokenStream {
|
||||
let signature = &import.signature;
|
||||
let original_return_type =
|
||||
crate::parsed_type::generate_fn_original_return_type(&signature.output_type);
|
||||
let link_name = import.link_name.as_ref().unwrap_or(&signature.name);
|
||||
let import_name = generate_import_name(&signature.name);
|
||||
let original_arguments = generate_original_arguments(&signature.arguments);
|
||||
|
||||
quote! {
|
||||
#[link_name = #link_name]
|
||||
fn #import_name(#(#original_arguments),*) #original_return_type;
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_original_arguments(
|
||||
arguments: &Vec<ast_types::AstFnArgument>,
|
||||
) -> Vec<proc_macro2::TokenStream> {
|
||||
arguments
|
||||
.iter()
|
||||
.map(|arg| {
|
||||
let name = crate::new_ident!(&arg.name);
|
||||
let ty = &arg.ty;
|
||||
quote! {#name : #ty}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
fn generate_import_name(import_name: &str) -> syn::Ident {
|
||||
crate::new_ident!(format!("{}_{}", super::GENERATED_WRAPPER_FUNC_PREFIX, import_name))
|
||||
@ -135,6 +171,17 @@ fn generate_wrapper_functions(extern_item: &ast_types::AstExternMod) -> TokenStr
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::all)]
|
||||
#visibility fn #func_name(#(#arg_names: #arg_types), *) #return_type {
|
||||
unsafe {
|
||||
// calling the original function with original args
|
||||
#import_func_name(#(#arg_names), *)
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
token_stream.extend(wrapper_func);
|
||||
|
@ -18,7 +18,7 @@
|
||||
/// Crates new syn::Ident with the given string and new call span
|
||||
macro_rules! new_ident {
|
||||
($string: expr) => {
|
||||
syn::Ident::new(&$string, proc_macro2::Span::call_site());
|
||||
syn::Ident::new(&$string, proc_macro2::Span::call_site())
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,150 @@
|
||||
#[link(wasm_import_module = "test")]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
extern "C" {
|
||||
#[link_name = "inner_arrays_1"]
|
||||
fn __m_generated_wrapper_func__inner_arrays_1(arg_0: u32, arg_1: u32);
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
extern "C" {
|
||||
#[link_name = "inner_arrays_1"]
|
||||
fn __m_generated_wrapper_func__inner_arrays_1(
|
||||
arg: Vec<Vec<Vec<Vec<u8>>>>
|
||||
) -> Vec<Vec<Vec<Vec<u8>>>>;
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::all)]
|
||||
pub fn inner_arrays_1(arg_0: Vec<Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
|
||||
unsafe {
|
||||
unsafe fn __m_generated_vec_serializer_arg_0(arg: &Vec<Vec<Vec<Vec<u8>>>>) -> (u32, u32) {
|
||||
unsafe fn __m_generated_vec_serializer_arg_0_Vec_Vec_u8__(
|
||||
arg: &Vec<Vec<Vec<u8>>>
|
||||
) -> (u32, u32) {
|
||||
unsafe fn __m_generated_vec_serializer_arg_0_Vec_Vec_u8___Vec_u8_(
|
||||
arg: &Vec<Vec<u8>>
|
||||
) -> (u32, u32) {
|
||||
unsafe fn __m_generated_vec_serializer_arg_0_Vec_Vec_u8___Vec_u8__u8(
|
||||
arg: &Vec<u8>
|
||||
) -> (u32, u32) {
|
||||
(arg.as_ptr() as _, arg.len() as _)
|
||||
}
|
||||
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
|
||||
for value in arg {
|
||||
let (ptr, size) =
|
||||
__m_generated_vec_serializer_arg_0_Vec_Vec_u8___Vec_u8__u8(&value);
|
||||
result.push(ptr as _);
|
||||
result.push(size as _);
|
||||
}
|
||||
let result_ptr = result.as_ptr();
|
||||
let result_len = result.len() / 2;
|
||||
marine_rs_sdk::internal::add_object_to_release(Box::new(result));
|
||||
(result_ptr as _, result_len as _)
|
||||
}
|
||||
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
|
||||
for value in arg {
|
||||
let (ptr, size) =
|
||||
__m_generated_vec_serializer_arg_0_Vec_Vec_u8___Vec_u8_(&value);
|
||||
result.push(ptr as _);
|
||||
result.push(size as _);
|
||||
}
|
||||
let result_ptr = result.as_ptr();
|
||||
let result_len = result.len() / 2;
|
||||
marine_rs_sdk::internal::add_object_to_release(Box::new(result));
|
||||
(result_ptr as _, result_len as _)
|
||||
}
|
||||
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
|
||||
for value in arg {
|
||||
let (ptr, size) = __m_generated_vec_serializer_arg_0_Vec_Vec_u8__(&value);
|
||||
result.push(ptr as _);
|
||||
result.push(size as _);
|
||||
}
|
||||
let result_ptr = result.as_ptr();
|
||||
let result_len = result.len() / 2;
|
||||
marine_rs_sdk::internal::add_object_to_release(Box::new(result));
|
||||
(result_ptr as _, result_len as _)
|
||||
}
|
||||
let arg_0 = __m_generated_vec_serializer_arg_0(&arg_0);
|
||||
let result = __m_generated_wrapper_func__inner_arrays_1(arg_0.0 as _, arg_0.1 as _);
|
||||
unsafe fn __m_generated_vec_deserializer(offset: u32, size: u32) -> Vec<Vec<Vec<Vec<u8>>>> {
|
||||
unsafe fn __m_generated_vec_deserializer_Vec_Vec_u8__(
|
||||
offset: u32,
|
||||
size: u32
|
||||
) -> Vec<Vec<Vec<u8>>> {
|
||||
unsafe fn __m_generated_vec_deserializer_Vec_Vec_u8___Vec_u8_(
|
||||
offset: u32,
|
||||
size: u32
|
||||
) -> Vec<Vec<u8>> {
|
||||
unsafe fn __m_generated_vec_deserializer_Vec_Vec_u8___Vec_u8__u8(
|
||||
offset: u32,
|
||||
size: u32
|
||||
) -> Vec<u8> {
|
||||
Vec::from_raw_parts(offset as _, size as _, size as _)
|
||||
}
|
||||
let vec_passing_size = 2;
|
||||
let mut arg: Vec<u32> = Vec::from_raw_parts(
|
||||
offset as _,
|
||||
(vec_passing_size * size) as _,
|
||||
(vec_passing_size * size) as _
|
||||
);
|
||||
let mut result = Vec::with_capacity(arg.len());
|
||||
let mut arg = arg.into_iter();
|
||||
while let Some(offset) = arg.next() {
|
||||
let size = arg.next().unwrap();
|
||||
let value = __m_generated_vec_deserializer_Vec_Vec_u8___Vec_u8__u8(
|
||||
offset as _,
|
||||
size as _
|
||||
);
|
||||
result.push(value);
|
||||
}
|
||||
result
|
||||
}
|
||||
let vec_passing_size = 2;
|
||||
let mut arg: Vec<u32> = Vec::from_raw_parts(
|
||||
offset as _,
|
||||
(vec_passing_size * size) as _,
|
||||
(vec_passing_size * size) as _
|
||||
);
|
||||
let mut result = Vec::with_capacity(arg.len());
|
||||
let mut arg = arg.into_iter();
|
||||
while let Some(offset) = arg.next() {
|
||||
let size = arg.next().unwrap();
|
||||
let value =
|
||||
__m_generated_vec_deserializer_Vec_Vec_u8___Vec_u8_(offset as _, size as _);
|
||||
result.push(value);
|
||||
}
|
||||
result
|
||||
}
|
||||
let vec_passing_size = 2;
|
||||
let mut arg: Vec<u32> = Vec::from_raw_parts(
|
||||
offset as _,
|
||||
(vec_passing_size * size) as _,
|
||||
(vec_passing_size * size) as _
|
||||
);
|
||||
let mut result = Vec::with_capacity(arg.len());
|
||||
let mut arg = arg.into_iter();
|
||||
while let Some(offset) = arg.next() {
|
||||
let size = arg.next().unwrap();
|
||||
let value = __m_generated_vec_deserializer_Vec_Vec_u8__(offset as _, size as _);
|
||||
result.push(value);
|
||||
}
|
||||
result
|
||||
}
|
||||
__m_generated_vec_deserializer(
|
||||
marine_rs_sdk::internal::get_result_ptr() as _,
|
||||
marine_rs_sdk::internal::get_result_size() as _,
|
||||
)
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::all)]
|
||||
pub fn inner_arrays_1(arg_0: Vec<Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
|
||||
unsafe { __m_generated_wrapper_func__inner_arrays_1(arg_0) }
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::all)]
|
||||
#[link_section = "__m_generated_section__test"]
|
||||
pub static __m_generated_static_global_test: [u8; 381usize] = {
|
||||
* b"{\"ast_type\":\"ExternMod\",\"namespace\":\"test\",\"imports\":[{\"link_name\":null,\"signature\":{\"name\":\"inner_arrays_1\",\"arguments\":[{\"name\":\"arg\",\"ty\":{\"Vector\":[{\"Vector\":[{\"Vector\":[{\"Vector\":[{\"U8\":\"ByValue\"},\"ByValue\"]},\"ByValue\"]},\"ByValue\"]},\"ByValue\"]}}],\"output_types\":[{\"Vector\":[{\"Vector\":[{\"Vector\":[{\"Vector\":[{\"U8\":\"ByValue\"},\"ByValue\"]},\"ByValue\"]},\"ByValue\"]},\"ByValue\"]}]}}]}"
|
||||
};
|
@ -0,0 +1,4 @@
|
||||
#[link(wasm_import_module = "test")]
|
||||
extern "C" {
|
||||
pub fn inner_arrays_1(arg: Vec<Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>>;
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
#[link(wasm_import_module = "test")]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
extern "C" {
|
||||
#[link_name = "all_types"]
|
||||
fn __m_generated_wrapper_func__all_types(
|
||||
arg_0: i8,
|
||||
arg_1: i16,
|
||||
arg_2: i32,
|
||||
arg_3: i64,
|
||||
arg_4: u8,
|
||||
arg_5: u16,
|
||||
arg_6: u32,
|
||||
arg_7: u64,
|
||||
arg_8: f32,
|
||||
arg_9: f64,
|
||||
arg_10: u32,
|
||||
arg_11: u32,
|
||||
arg_12: u32,
|
||||
arg_13: u32
|
||||
);
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
extern "C" {
|
||||
#[link_name = "all_types"]
|
||||
fn __m_generated_wrapper_func__all_types(
|
||||
arg_0: i8,
|
||||
arg_1: i16,
|
||||
arg_2: i32,
|
||||
arg_3: i64,
|
||||
arg_4: u8,
|
||||
arg_5: u16,
|
||||
arg_6: u32,
|
||||
arg_7: u64,
|
||||
arg_8: f32,
|
||||
arg_9: f64,
|
||||
arg_10: String,
|
||||
arg_11: Vec<u8>
|
||||
) -> Vec<u8>;
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::all)]
|
||||
pub fn all_types(
|
||||
arg_0: i8,
|
||||
arg_1: i16,
|
||||
arg_2: i32,
|
||||
arg_3: i64,
|
||||
arg_4: u8,
|
||||
arg_5: u16,
|
||||
arg_6: u32,
|
||||
arg_7: u64,
|
||||
arg_8: f32,
|
||||
arg_9: f64,
|
||||
arg_10: String,
|
||||
arg_11: Vec<u8>
|
||||
) -> Vec<u8> {
|
||||
unsafe {
|
||||
let mut arg_10 = std::mem::ManuallyDrop::new(arg_10);
|
||||
unsafe fn __m_generated_vec_serializer_arg_11(arg: &Vec<u8>) -> (u32, u32) {
|
||||
(arg.as_ptr() as _, arg.len() as _)
|
||||
}
|
||||
let arg_11 = __m_generated_vec_serializer_arg_11(&arg_11);
|
||||
let result = __m_generated_wrapper_func__all_types(
|
||||
arg_0,
|
||||
arg_1,
|
||||
arg_2,
|
||||
arg_3,
|
||||
arg_4,
|
||||
arg_5,
|
||||
arg_6,
|
||||
arg_7,
|
||||
arg_8,
|
||||
arg_9,
|
||||
arg_10.as_ptr() as _,
|
||||
arg_10.len() as _,
|
||||
arg_11.0 as _,
|
||||
arg_11.1 as _
|
||||
);
|
||||
std::mem::ManuallyDrop::drop(&mut arg_10);
|
||||
unsafe fn __m_generated_vec_deserializer(offset: u32, size: u32) -> Vec<u8> {
|
||||
Vec::from_raw_parts(offset as _, size as _, size as _)
|
||||
}
|
||||
__m_generated_vec_deserializer(
|
||||
marine_rs_sdk::internal::get_result_ptr() as _,
|
||||
marine_rs_sdk::internal::get_result_size() as _,
|
||||
)
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::all)]
|
||||
pub fn all_types(
|
||||
arg_0: i8,
|
||||
arg_1: i16,
|
||||
arg_2: i32,
|
||||
arg_3: i64,
|
||||
arg_4: u8,
|
||||
arg_5: u16,
|
||||
arg_6: u32,
|
||||
arg_7: u64,
|
||||
arg_8: f32,
|
||||
arg_9: f64,
|
||||
arg_10: String,
|
||||
arg_11: Vec<u8>
|
||||
) -> Vec<u8> {
|
||||
unsafe {
|
||||
__m_generated_wrapper_func__all_types(
|
||||
arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7, arg_8, arg_9, arg_10, arg_11
|
||||
)
|
||||
}
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::all)]
|
||||
#[link_section = "__m_generated_section__test"]
|
||||
pub static __m_generated_static_global_test: [u8; 687usize] = {
|
||||
* b"{\"ast_type\":\"ExternMod\",\"namespace\":\"test\",\"imports\":[{\"link_name\":null,\"signature\":{\"name\":\"all_types\",\"arguments\":[{\"name\":\"arg_0\",\"ty\":{\"I8\":\"ByValue\"}},{\"name\":\"arg_1\",\"ty\":{\"I16\":\"ByValue\"}},{\"name\":\"arg_2\",\"ty\":{\"I32\":\"ByValue\"}},{\"name\":\"arg_3\",\"ty\":{\"I64\":\"ByValue\"}},{\"name\":\"arg_4\",\"ty\":{\"U8\":\"ByValue\"}},{\"name\":\"arg_5\",\"ty\":{\"U16\":\"ByValue\"}},{\"name\":\"arg_6\",\"ty\":{\"U32\":\"ByValue\"}},{\"name\":\"arg_7\",\"ty\":{\"U64\":\"ByValue\"}},{\"name\":\"arg_8\",\"ty\":{\"F32\":\"ByValue\"}},{\"name\":\"arg_9\",\"ty\":{\"F64\":\"ByValue\"}},{\"name\":\"arg_10\",\"ty\":{\"Utf8String\":\"ByValue\"}},{\"name\":\"arg_11\",\"ty\":{\"Vector\":[{\"U8\":\"ByValue\"},\"ByValue\"]}}],\"output_types\":[{\"Vector\":[{\"U8\":\"ByValue\"},\"ByValue\"]}]}}]}"
|
||||
};
|
@ -0,0 +1,17 @@
|
||||
#[link(wasm_import_module = "test")]
|
||||
extern "C" {
|
||||
pub fn all_types(
|
||||
arg_0: i8,
|
||||
arg_1: i16,
|
||||
arg_2: i32,
|
||||
arg_3: i64,
|
||||
arg_4: u8,
|
||||
arg_5: u16,
|
||||
arg_6: u32,
|
||||
arg_7: u64,
|
||||
arg_8: f32,
|
||||
arg_9: f64,
|
||||
arg_10: String,
|
||||
arg_11: Vec<u8>,
|
||||
) -> Vec<u8>;
|
||||
}
|
@ -41,3 +41,19 @@ fn records_use_as_type() {
|
||||
"tests/generation_tests/records/use_as_type/expanded.rs",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn imports_arrays() {
|
||||
assert!(test_marine_token_streams(
|
||||
"tests/generation_tests/imports/arrays/marine.rs",
|
||||
"tests/generation_tests/imports/arrays/expanded.rs",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn imports_basic_types() {
|
||||
assert!(test_marine_token_streams(
|
||||
"tests/generation_tests/imports/basic_types/marine.rs",
|
||||
"tests/generation_tests/imports/basic_types/expanded.rs",
|
||||
));
|
||||
}
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
use marine_macro_impl::marine;
|
||||
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
|
||||
@ -34,8 +32,6 @@ where
|
||||
let expanded_item = items_from_file(expanded_path);
|
||||
let marine_item = to_syn_item(marine_token_streams);
|
||||
|
||||
assert_eq!(expanded_item, marine_item);
|
||||
|
||||
marine_item == expanded_item
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "marine-macro"
|
||||
version = "0.6.10" # remember to update html_root_url
|
||||
version = "0.6.11" # remember to update html_root_url
|
||||
edition = "2018"
|
||||
description = "Definition of the `#[marine]` macro"
|
||||
documentation = "https://docs.rs/fluence/marine-macro"
|
||||
@ -18,4 +18,4 @@ proc-macro = true
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
marine-macro-impl = { path = "../marine-macro-impl", version = "=0.6.10" }
|
||||
marine-macro-impl = { path = "../marine-macro-impl", version = "=0.6.11" }
|
||||
|
@ -50,7 +50,7 @@
|
||||
//!
|
||||
//! ```
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/marine-macro/0.6.10")]
|
||||
#![doc(html_root_url = "https://docs.rs/marine-macro/0.6.11")]
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "marine-timestamp-macro"
|
||||
version = "0.6.10" # remember to update html_root_url
|
||||
version = "0.6.11" # remember to update html_root_url
|
||||
edition = "2018"
|
||||
description = "Definition of the `#[build_timestamp]` macro"
|
||||
documentation = "https://docs.rs/fluence/marine-timestamp-macro"
|
||||
|
@ -18,9 +18,9 @@ path = "src/lib.rs"
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
marine-macro = { path = "../crates/marine-macro", version = "=0.6.10" }
|
||||
marine-rs-sdk-main = { path = "../crates/main", version = "=0.6.10" }
|
||||
marine-timestamp-macro = { path = "../crates/timestamp-macro", version = "=0.6.10" }
|
||||
marine-macro = { path = "../crates/marine-macro", version = "=0.6.11" }
|
||||
marine-rs-sdk-main = { path = "../crates/main", version = "=0.6.11" }
|
||||
marine-timestamp-macro = { path = "../crates/timestamp-macro", version = "=0.6.11" }
|
||||
|
||||
serde = { version = "1.0.118", features = ["derive"]}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user