Merge pull request #34 from fluencelabs/wit_to_it

Rename fce to marine
This commit is contained in:
Mike Voronov 2021-05-10 15:33:51 +03:00 committed by GitHub
commit 0fa9064a2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
96 changed files with 483 additions and 477 deletions

View File

@ -23,7 +23,7 @@ jobs:
(cd fluence; cargo build -v --target wasm32-wasi --all-features)
(cd fluence; cargo clippy -v --target wasm32-wasi)
(cd fluence-test; cargo build)
(cd crates/wit; cargo test)
(cd crates/marine-macro-impl; cargo test)
TARGET=wasm32-wasi cargo test -v --all-features

View File

@ -1,11 +1,11 @@
[workspace]
members = [
"crates/fce-macro",
"crates/fce-test-macro",
"crates/fce-test-macro-impl",
"crates/main",
"crates/marine-macro",
"crates/marine-macro-impl",
"crates/marine-test-macro",
"crates/marine-test-macro-impl",
"crates/timestamp-macro",
"crates/wit",
"fluence",
"fluence-test"
]

View File

@ -1,9 +1,9 @@
[package]
name = "fluence-sdk-main"
version = "0.6.1" # remember to update html_root_url
version = "0.6.2" # remember to update html_root_url
edition = "2018"
description = "Rust SDK for applications for the Fluence network"
documentation = "https://docs.rs/fluence/fluence-sdk-macro"
documentation = "https://docs.rs/fluence/marine-macro"
repository = "https://github.com/fluencelabs/rust-sdk/crates/main"
authors = ["Fluence Labs"]
keywords = ["fluence", "sdk", "webassembly"]
@ -19,7 +19,7 @@ crate-type = ["rlib"]
doctest = false
[dependencies]
fluence-sdk-macro = { path = "../fce-macro", version = "=0.6.1" }
marine-macro = { path = "../marine-macro", version = "=0.6.2" }
log = { version = "0.4.8", features = ["std"] }
serde = "=1.0.118"

View File

@ -22,25 +22,25 @@ macro_rules! module_manifest {
($authors:expr, $version:expr, $description:expr, $repository:expr) => {
fluence::internal::build_timestamp!();
const __FCE_SDK_AUTHORS_SIZE: usize = $authors.as_bytes().len();
const __FCE_SDK_VERSION_SIZE: usize = $version.as_bytes().len();
const __FCE_SDK_DESCRIPTION_SIZE: usize = $description.as_bytes().len();
const __FCE_SDK_REPOSITORY_SIZE: usize = $repository.as_bytes().len();
const __FCE_SDK_BUILD_TIME_SIZE: usize = __FCE_SDK_BUILD_TIME.as_bytes().len();
const __FCE_SDK_FIELD_PREFIX_SIZE: usize = std::mem::size_of::<u64>();
const __M_SDK_AUTHORS_SIZE: usize = $authors.as_bytes().len();
const __M_SDK_VERSION_SIZE: usize = $version.as_bytes().len();
const __M_SDK_DESCRIPTION_SIZE: usize = $description.as_bytes().len();
const __M_SDK_REPOSITORY_SIZE: usize = $repository.as_bytes().len();
const __M_SDK_BUILD_TIME_SIZE: usize = __M_SDK_BUILD_TIME.as_bytes().len();
const __M_SDK_FIELD_PREFIX_SIZE: usize = std::mem::size_of::<u64>();
const __FCE_MANIFEST_SIZE: usize = __FCE_SDK_AUTHORS_SIZE
+ __FCE_SDK_VERSION_SIZE
+ __FCE_SDK_DESCRIPTION_SIZE
+ __FCE_SDK_REPOSITORY_SIZE
+ __FCE_SDK_BUILD_TIME_SIZE
+ __FCE_SDK_FIELD_PREFIX_SIZE * 5;
const __M_MANIFEST_SIZE: usize = __M_SDK_AUTHORS_SIZE
+ __M_SDK_VERSION_SIZE
+ __M_SDK_DESCRIPTION_SIZE
+ __M_SDK_REPOSITORY_SIZE
+ __M_SDK_BUILD_TIME_SIZE
+ __M_SDK_FIELD_PREFIX_SIZE * 5;
const fn __fce_sdk_append_data(
mut manifest: [u8; __FCE_MANIFEST_SIZE],
const fn __m_sdk_append_data(
mut manifest: [u8; __M_MANIFEST_SIZE],
data: &'static str,
offset: usize,
) -> ([u8; __FCE_MANIFEST_SIZE], usize) {
) -> ([u8; __M_MANIFEST_SIZE], usize) {
let data_as_bytes = data.as_bytes();
let data_len = data_as_bytes.len();
@ -48,7 +48,7 @@ macro_rules! module_manifest {
let data_len_u64 = data_len as u64;
let data_len_le_bytes = data_len_u64.to_le_bytes();
let mut byte_idx = 0;
while byte_idx < __FCE_SDK_FIELD_PREFIX_SIZE {
while byte_idx < __M_SDK_FIELD_PREFIX_SIZE {
manifest[offset + byte_idx] = data_len_le_bytes[byte_idx];
byte_idx += 1;
}
@ -56,22 +56,22 @@ macro_rules! module_manifest {
// write data
let mut byte_idx = 0;
while byte_idx < data_len {
manifest[__FCE_SDK_FIELD_PREFIX_SIZE + offset + byte_idx] = data_as_bytes[byte_idx];
manifest[__M_SDK_FIELD_PREFIX_SIZE + offset + byte_idx] = data_as_bytes[byte_idx];
byte_idx += 1;
}
(manifest, offset + __FCE_SDK_FIELD_PREFIX_SIZE + data_len)
(manifest, offset + __M_SDK_FIELD_PREFIX_SIZE + data_len)
}
const fn generate_manifest() -> [u8; __FCE_MANIFEST_SIZE] {
let manifest: [u8; __FCE_MANIFEST_SIZE] = [0; __FCE_MANIFEST_SIZE];
const fn generate_manifest() -> [u8; __M_MANIFEST_SIZE] {
let manifest: [u8; __M_MANIFEST_SIZE] = [0; __M_MANIFEST_SIZE];
let offset = 0;
let (manifest, offset) = __fce_sdk_append_data(manifest, $authors, offset);
let (manifest, offset) = __fce_sdk_append_data(manifest, $version, offset);
let (manifest, offset) = __fce_sdk_append_data(manifest, $description, offset);
let (manifest, offset) = __fce_sdk_append_data(manifest, $repository, offset);
let (manifest, _) = __fce_sdk_append_data(manifest, __FCE_SDK_BUILD_TIME, offset);
let (manifest, offset) = __m_sdk_append_data(manifest, $authors, offset);
let (manifest, offset) = __m_sdk_append_data(manifest, $version, offset);
let (manifest, offset) = __m_sdk_append_data(manifest, $description, offset);
let (manifest, offset) = __m_sdk_append_data(manifest, $repository, offset);
let (manifest, _) = __m_sdk_append_data(manifest, __M_SDK_BUILD_TIME, offset);
manifest
}
@ -79,7 +79,7 @@ macro_rules! module_manifest {
#[cfg(target_arch = "wasm32")]
#[link_section = "__fluence_wasm_module_manifest"]
#[doc(hidden)]
pub static __FCE_WASM_MODULE_MANIFEST: [u8; __FCE_MANIFEST_SIZE] = generate_manifest();
pub static __M_WASM_MODULE_MANIFEST: [u8; __M_MANIFEST_SIZE] = generate_manifest();
};
() => {

View File

@ -38,4 +38,4 @@ pub const VERSION_SECTION_NAME: &str = "__fluence_sdk_version";
#[cfg(target_arch = "wasm32")]
#[link_section = "__fluence_sdk_version"]
#[doc(hidden)]
pub static __FCE_SDK_VERSION: [u8; VERSION_SIZE] = sdk_version();
pub static __M_SDK_VERSION: [u8; VERSION_SIZE] = sdk_version();

View File

@ -1,12 +1,12 @@
[package]
name = "fluence-sdk-wit"
version = "0.6.1" # remember to update html_root_url
name = "marine-macro-impl"
version = "0.6.2" # remember to update html_root_url
edition = "2018"
description = "Webassembly interface-types generator"
documentation = "https://docs.rs/fluence/fluence-sdk-macro"
description = "Implementation of the `#[marine]` macro"
documentation = "https://docs.rs/fluence/marine-macro"
repository = "https://github.com/fluencelabs/rust-sdk/crates/macro"
authors = ["Fluence Labs"]
keywords = ["fluence", "sdk", "webassembly", "wit", "interface-types"]
keywords = ["fluence", "sdk", "webassembly", "it", "interface-types"]
categories = ["api-bindings", "wasm"]
license = "Apache-2.0"

View File

@ -81,7 +81,7 @@ pub(crate) struct AstFn {
}
#[derive(Clone)]
pub(crate) enum FCEAst {
pub(crate) enum MarineAst {
Function(AstFn),
ExternMod(AstExternMod),
Record(AstRecord),

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
#![doc(html_root_url = "https://docs.rs/wit-support/0.5.0")]
#![doc(html_root_url = "https://docs.rs/marine-macro-impl/0.6.2")]
#![deny(
dead_code,
nonstandard_style,
@ -32,7 +32,7 @@
mod ast_types;
mod export_ast_types;
mod fce_macro_impl;
mod marine_macro_impl;
mod parsed_type;
mod parse_macro_input;
mod token_stream_generator;
@ -40,7 +40,7 @@ mod utils;
mod wasm_type;
pub use export_ast_types::*;
pub use fce_macro_impl::fce;
pub use crate::marine_macro_impl::marine;
pub use parsed_type::ParsedType;
pub use token_stream_generator::GENERATED_WRAPPER_FUNC_PREFIX;
pub use token_stream_generator::GENERATED_SECTION_PREFIX;

View File

@ -20,14 +20,14 @@ use proc_macro2::TokenStream;
use quote::ToTokens;
use syn::Result;
pub fn fce(tokens: TokenStream) -> Result<TokenStream> {
pub fn marine(tokens: TokenStream) -> Result<TokenStream> {
let item = syn::parse2::<syn::Item>(tokens)?;
// convert proc_macro2 token to internal AST type
let fce_ast_item = item.parse_macro_input()?;
let marine_ast_item = item.parse_macro_input()?;
// convert internal AST type to sequence of tokens
let mut tokens = TokenStream::new();
fce_ast_item.to_tokens(&mut tokens);
marine_ast_item.to_tokens(&mut tokens);
Ok(tokens)
}

View File

@ -19,14 +19,14 @@ mod item_foreign_mod;
mod item_record;
mod utils;
use crate::ast_types::FCEAst;
use crate::ast_types::MarineAst;
pub(crate) trait ParseMacroInput {
fn parse_macro_input(self) -> syn::Result<FCEAst>;
fn parse_macro_input(self) -> syn::Result<MarineAst>;
}
impl ParseMacroInput for syn::Item {
fn parse_macro_input(self) -> syn::Result<FCEAst> {
fn parse_macro_input(self) -> syn::Result<MarineAst> {
use syn::spanned::Spanned;
match self {
@ -35,7 +35,7 @@ impl ParseMacroInput for syn::Item {
syn::Item::Struct(item_struct) => item_struct.parse_macro_input(),
_ => Err(syn::Error::new(
self.span(),
"At now, #[fce] could be applied only to a function, extern block or struct",
"At now, #[marine] could be applied only to a function, extern block or struct",
)),
}
}

View File

@ -17,7 +17,7 @@
use super::ParseMacroInput;
use crate::ast_types;
use crate::ParsedType;
use crate::ast_types::FCEAst;
use crate::ast_types::MarineAst;
use crate::ast_types::AstFn;
use crate::ast_types::AstFnArgument;
use crate::syn_error;
@ -26,7 +26,7 @@ use syn::Result;
use syn::spanned::Spanned;
impl ParseMacroInput for syn::ItemFn {
fn parse_macro_input(self) -> Result<FCEAst> {
fn parse_macro_input(self) -> Result<MarineAst> {
let signature = try_to_ast_signature(self.sig.clone(), self.vis.clone())?;
// this check specific only for export functions
@ -38,7 +38,7 @@ impl ParseMacroInput for syn::ItemFn {
check_args(parsed_args)?;
check_output_type(&signature.output_type, self.sig.output.span())?;
let ast_fn = FCEAst::Function(AstFn {
let ast_fn = MarineAst::Function(AstFn {
signature,
original: self,
});
@ -96,7 +96,7 @@ pub(super) fn try_to_ast_signature(
Ok(ast_function_item)
}
/// Check whether the #[fce] macro could be applied to a function.
/// Check whether the #[marine] macro could be applied to a function.
#[rustfmt::skip]
fn check_function(signature: &syn::Signature) -> Result<()> {
let syn::Signature {
@ -109,19 +109,19 @@ fn check_function(signature: &syn::Signature) -> Result<()> {
} = signature;
if let Some(constness) = constness {
return syn_error!(constness.span, "FCE export function shouldn't be constant");
return syn_error!(constness.span, "Marine export function shouldn't be constant");
}
if let Some(unsafety) = unsafety {
return syn_error!(unsafety.span, "FCE export function shouldn't be unsafe");
return syn_error!(unsafety.span, "Marine export function shouldn't be unsafe");
}
if let Some(abi) = abi {
return syn_error!(abi.extern_token.span, "FCE export function shouldn't have any custom linkage");
return syn_error!(abi.extern_token.span, "Marine export function shouldn't have any custom linkage");
}
if generics.where_clause.is_some() {
return syn_error!(signature.span(), "FCE export function shouldn't use template parameters");
return syn_error!(signature.span(), "Marine export function shouldn't use template parameters");
}
if variadic.is_some() {
return syn_error!(variadic.span(), "FCE export function shouldn't use variadic interface");
return syn_error!(variadic.span(), "Marine export function shouldn't use variadic interface");
}
// TODO: check for a lifetime

View File

@ -16,7 +16,7 @@
use super::ParseMacroInput;
use crate::ast_types;
use crate::ast_types::FCEAst;
use crate::ast_types::MarineAst;
use crate::syn_error;
use syn::Result;
@ -27,7 +27,7 @@ const LINK_NAME_DIRECTIVE_NAME: &str = "link_name";
const WASM_IMPORT_MODULE_DIRECTIVE_NAME: &str = "wasm_import_module";
impl ParseMacroInput for syn::ItemForeignMod {
fn parse_macro_input(self) -> Result<FCEAst> {
fn parse_macro_input(self) -> Result<MarineAst> {
check_foreign_section(&self)?;
let wasm_import_module: Option<String> = parse_wasm_import_module(&self);
@ -41,7 +41,7 @@ impl ParseMacroInput for syn::ItemForeignMod {
imports,
original: self,
};
Ok(FCEAst::ExternMod(extern_mod_item))
Ok(MarineAst::ExternMod(extern_mod_item))
}
}
@ -135,7 +135,7 @@ fn parse_raw_foreign_item(raw_item: syn::ForeignItem) -> Result<ast_types::AstEx
_ => {
return syn_error!(
raw_item.span(),
"#[fce] could be applied only to a function, struct ot extern block"
"#[marine] could be applied only to a function, struct ot extern block"
)
}
};

View File

@ -18,7 +18,7 @@ use super::ParseMacroInput;
use crate::ast_types;
use crate::ast_types::AstRecordField;
use crate::ast_types::AstRecordFields;
use crate::ast_types::FCEAst;
use crate::ast_types::MarineAst;
use crate::syn_error;
use crate::parsed_type::ParsedType;
@ -26,7 +26,7 @@ use syn::Result;
use syn::spanned::Spanned;
impl ParseMacroInput for syn::ItemStruct {
fn parse_macro_input(self) -> Result<FCEAst> {
fn parse_macro_input(self) -> Result<MarineAst> {
check_record(&self)?;
let fields = match &self.fields {
@ -44,7 +44,7 @@ impl ParseMacroInput for syn::ItemStruct {
original: self,
};
Ok(FCEAst::Record(ast_record_item))
Ok(MarineAst::Record(ast_record_item))
}
}
@ -55,7 +55,7 @@ fn check_record(record: &syn::ItemStruct) -> Result<()> {
{
return syn_error!(
record.span(),
"#[fce] couldn't be applied to a struct with generics or lifetimes"
"#[marine] couldn't be applied to a struct with generics or lifetimes"
);
}
@ -94,7 +94,7 @@ fn check_field(field: &syn::Field) -> Result<()> {
_ => {
return syn_error!(
field.span(),
"#[fce] could be applied only to struct with all public fields"
"#[marine] could be applied only to struct with all public fields"
)
}
};

View File

@ -106,7 +106,7 @@ fn generate_epilog(ty: &Option<ParsedType>) -> proc_macro2::TokenStream {
None => quote!(),
Some(ParsedType::Record(..)) => {
quote! {
let result_ptr = result.__fce_generated_serialize();
let result_ptr = result.__m_generated_serialize();
fluence::internal::set_result_ptr(result_ptr as _);
}
}
@ -117,7 +117,7 @@ fn generate_epilog(ty: &Option<ParsedType>) -> proc_macro2::TokenStream {
}
}
Some(ParsedType::Vector(ty, _)) => {
let generated_serializer_name = "__fce_generated_vec_serializer";
let generated_serializer_name = "__m_generated_vec_serializer";
let generated_serializer_ident = new_ident!(generated_serializer_name);
let vector_serializer =
super::vector_ser_der::generate_vector_ser(ty, generated_serializer_name);

View File

@ -130,7 +130,7 @@ fn generate_type_lifting_prolog(
},
ParsedType::Vector(ty, _) => {
let generated_der_name =
format!("__fce_generated_vec_deserializer_{}", supplied_arg_start_id);
format!("__m_generated_vec_deserializer_{}", supplied_arg_start_id);
let generated_der_name = crate::utils::prepare_ident(generated_der_name);
let generated_der_ident = new_ident!(generated_der_name);
@ -145,7 +145,7 @@ fn generate_type_lifting_prolog(
ParsedType::Record(record_name, _) => {
let record_ident = new_ident!(record_name);
quote! {
let #type_modifier #converted_arg_ident = #record_ident::__fce_generated_deserialize(#ptr as _);
let #type_modifier #converted_arg_ident = #record_ident::__m_generated_deserialize(#ptr as _);
}
}
_ => panic!(

View File

@ -35,7 +35,7 @@ impl ForeignModArgGlueCodeGenerator for ParsedType {
quote! { #arg.0 as _, #arg.1 as _ }
}
ParsedType::Record(..) => quote! {
#arg.__fce_generated_serialize() as _
#arg.__m_generated_serialize() as _
},
ty @ ParsedType::Boolean(_) => {
let deref_sign = maybe_deref(ty);

View File

@ -57,7 +57,7 @@ impl ForeignModEpilogGlueCodeGenerator for Option<ParsedType> {
)
},
Some(ParsedType::Vector(ty, _)) => {
let generated_der_name = "__fce_generated_vec_deserializer";
let generated_der_name = "__m_generated_vec_deserializer";
let generated_der_ident = new_ident!(generated_der_name);
let vector_deserializer =
super::vector_ser_der::generate_vector_der(ty, generated_der_name);
@ -74,7 +74,7 @@ impl ForeignModEpilogGlueCodeGenerator for Option<ParsedType> {
let record_ident = new_ident!(record_name);
quote! {
#record_ident::__fce_generated_deserialize(fluence::internal::get_result_ptr() as _)
#record_ident::__m_generated_deserialize(fluence::internal::get_result_ptr() as _)
}
}
_ => panic!(

View File

@ -128,7 +128,7 @@ impl ForeignModPrologGlueCodeGenerator for Vec<AstFnArgument> {
}
fn vector_arg_transforms(ty: &ParsedType, arg_name: &str) -> proc_macro2::TokenStream {
let generated_ser_name = format!("__fce_generated_vec_serializer_{}", arg_name);
let generated_ser_name = format!("__m_generated_vec_serializer_{}", arg_name);
let generated_ser_name = crate::utils::prepare_ident(generated_ser_name);
let generated_ser_ident = new_ident!(generated_ser_name);
let arg_ident = new_ident!(arg_name);

View File

@ -69,7 +69,7 @@ pub(super) fn record_der(record_name: &str) -> proc_macro2::TokenStream {
let mut result = Vec::with_capacity(arg.len());
for offset in arg {
let value = #record_name_ident::__fce_generated_deserialize(offset as _);
let value = #record_name_ident::__m_generated_deserialize(offset as _);
result.push(value);
}

View File

@ -65,7 +65,7 @@ pub(super) fn record_ser() -> proc_macro2::TokenStream {
let mut result: Vec<u32> = Vec::with_capacity(arg.len());
for value in arg {
result.push(value.__fce_generated_serialize() as _);
result.push(value.__m_generated_serialize() as _);
}
let result_ptr = result.as_ptr();

View File

@ -18,18 +18,18 @@ mod fn_generator;
mod foreign_mod_generator;
mod record_generator;
use crate::ast_types::FCEAst;
use crate::ast_types::MarineAst;
pub const GENERATED_WRAPPER_FUNC_PREFIX: &str = "__fce_generated_wrapper_func_";
pub const GENERATED_SECTION_PREFIX: &str = "__fce_generated_section__";
pub const GENERATED_GLOBAL_PREFIX: &str = "__fce_generated_static_global_";
pub const GENERATED_WRAPPER_FUNC_PREFIX: &str = "__m_generated_wrapper_func_";
pub const GENERATED_SECTION_PREFIX: &str = "__m_generated_section__";
pub const GENERATED_GLOBAL_PREFIX: &str = "__m_generated_static_global_";
impl quote::ToTokens for FCEAst {
impl quote::ToTokens for MarineAst {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
match self {
FCEAst::Function(ast_function) => ast_function.to_tokens(tokens),
FCEAst::ExternMod(ast_extern) => ast_extern.to_tokens(tokens),
FCEAst::Record(ast_record) => ast_record.to_tokens(tokens),
MarineAst::Function(ast_function) => ast_function.to_tokens(tokens),
MarineAst::ExternMod(ast_extern) => ast_extern.to_tokens(tokens),
MarineAst::Record(ast_record) => ast_record.to_tokens(tokens),
}
}
}

View File

@ -46,8 +46,6 @@ impl quote::ToTokens for AstRecord {
let glue_code = quote::quote! {
#original
// used_id_fce is a special feature that indicates that this struct will be used inside
// FCE for some internal needs
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
#[allow(clippy::all)]
@ -77,7 +75,7 @@ fn generate_serializer_fn(record: &AstRecord) -> proc_macro2::TokenStream {
};
quote::quote! {
pub fn __fce_generated_serialize(&self) -> *const u8 {
pub fn __m_generated_serialize(&self) -> *const u8 {
// 4 is an average size of a possible record field
let mut raw_record: Vec<u8> = Vec::with_capacity(4 * #fields_count);
@ -106,7 +104,7 @@ fn generate_deserializer_fn(record: &AstRecord) -> proc_macro2::TokenStream {
let record_size = crate::utils::get_record_size(fields.iter().map(|ast_field| &ast_field.ty));
quote::quote! {
pub unsafe fn __fce_generated_deserialize(record_ptr: *const u8) -> Self {
pub unsafe fn __m_generated_deserialize(record_ptr: *const u8) -> Self {
let raw_record: Vec<u8> = Vec::from_raw_parts(record_ptr as _, #record_size, #record_size);
#fields_der

View File

@ -263,7 +263,7 @@ impl FieldValuesBuilder {
}
fn vector_der(&mut self, ty: &ParsedType, field: &syn::Ident) -> TokenStream {
let generated_der_name = format!("__fce_generated_vec_deserializer_{}", self.value_id);
let generated_der_name = format!("__m_generated_vec_deserializer_{}", self.value_id);
let generated_der_name = crate::utils::prepare_ident(generated_der_name);
let generated_der_ident = new_ident!(generated_der_name);
@ -308,7 +308,7 @@ impl FieldValuesBuilder {
raw_record[#value_id + 3],
]);
let #field = #record_ident::__fce_generated_deserialize(offset as _);
let #field = #record_ident::__m_generated_deserialize(offset as _);
};
self.value_id += std::mem::size_of::<u32>();

View File

@ -52,7 +52,7 @@ impl RecordSerGlueCodeGenerator for AstRecord {
}
ParsedType::Vector(ty, _) => {
let generated_ser_name = format!(
"__fce_generated_vec_serializer_{}_{}",
"__m_generated_vec_serializer_{}_{}",
field.name.as_ref().unwrap(),
id
);
@ -72,7 +72,7 @@ impl RecordSerGlueCodeGenerator for AstRecord {
}
ParsedType::Record(..) => {
quote! {
let serialized_struct_ptr = #field_ident.__fce_generated_serialize() as usize;
let serialized_struct_ptr = #field_ident.__m_generated_serialize() as usize;
raw_record.extend(&serialized_struct_ptr.to_le_bytes());
}
}

View File

@ -24,10 +24,10 @@ macro_rules! new_ident {
#[macro_export]
macro_rules! prepare_global_data {
($fce_type: ident, $self: ident, $name: expr, $data: ident, $data_size: ident, $global_static_name: ident, $section_name: ident) => {
($mtype: ident, $self: ident, $name: expr, $data: ident, $data_size: ident, $global_static_name: ident, $section_name: ident) => {
// TODO: change serialization protocol
let fce_type = crate::export_ast_types::SDKAst::$fce_type($self.clone().into());
let $data = serde_json::to_vec(&fce_type).unwrap();
let mtype = crate::export_ast_types::SDKAst::$mtype($self.clone().into());
let $data = serde_json::to_vec(&mtype).unwrap();
let $data_size = $data.len();
let $data = syn::LitByteStr::new(&$data, proc_macro2::Span::call_site());

View File

@ -6,17 +6,17 @@ pub fn inner_arrays_1(arg: Vec<Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
#[no_mangle]
#[doc(hidden)]
#[allow(clippy::all)]
pub unsafe fn __fce_generated_wrapper_func_inner_arrays_1(arg_0: u32, arg_1: u32) {
unsafe fn __fce_generated_vec_deserializer_0(offset: u32, size: u32) -> Vec<Vec<Vec<Vec<u8>>>> {
unsafe fn __fce_generated_vec_deserializer_0_Vec_Vec_u8__(
pub unsafe fn __m_generated_wrapper_func_inner_arrays_1(arg_0: u32, arg_1: u32) {
unsafe fn __m_generated_vec_deserializer_0(offset: u32, size: u32) -> Vec<Vec<Vec<Vec<u8>>>> {
unsafe fn __m_generated_vec_deserializer_0_Vec_Vec_u8__(
offset: u32,
size: u32
) -> Vec<Vec<Vec<u8>>> {
unsafe fn __fce_generated_vec_deserializer_0_Vec_Vec_u8___Vec_u8_(
unsafe fn __m_generated_vec_deserializer_0_Vec_Vec_u8___Vec_u8_(
offset: u32,
size: u32
) -> Vec<Vec<u8>> {
unsafe fn __fce_generated_vec_deserializer_0_Vec_Vec_u8___Vec_u8__u8(
unsafe fn __m_generated_vec_deserializer_0_Vec_Vec_u8___Vec_u8__u8(
offset: u32,
size: u32
) -> Vec<u8> {
@ -29,7 +29,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_1(arg_0: u32, arg_1: u32
let mut arg = arg.into_iter();
while let Some(offset) = arg.next() {
let size = arg.next().unwrap();
let value = __fce_generated_vec_deserializer_0_Vec_Vec_u8___Vec_u8__u8(
let value = __m_generated_vec_deserializer_0_Vec_Vec_u8___Vec_u8__u8(
offset as _,
size as _
);
@ -45,7 +45,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_1(arg_0: u32, arg_1: u32
while let Some(offset) = arg.next() {
let size = arg.next().unwrap();
let value =
__fce_generated_vec_deserializer_0_Vec_Vec_u8___Vec_u8_(offset as _, size as _);
__m_generated_vec_deserializer_0_Vec_Vec_u8___Vec_u8_(offset as _, size as _);
result.push(value);
}
result
@ -56,21 +56,21 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_1(arg_0: u32, arg_1: u32
let mut arg = arg.into_iter();
while let Some(offset) = arg.next() {
let size = arg.next().unwrap();
let value = __fce_generated_vec_deserializer_0_Vec_Vec_u8__(offset as _, size as _);
let value = __m_generated_vec_deserializer_0_Vec_Vec_u8__(offset as _, size as _);
result.push(value);
}
result
}
let converted_arg_0 = __fce_generated_vec_deserializer_0(arg_0 as _, arg_1 as _);
let converted_arg_0 = __m_generated_vec_deserializer_0(arg_0 as _, arg_1 as _);
let result = inner_arrays_1(converted_arg_0);
unsafe fn __fce_generated_vec_serializer(arg: &Vec<Vec<Vec<Vec<u8>>>>) -> (u32, u32) {
unsafe fn __fce_generated_vec_serializer_Vec_Vec_u8__(
unsafe fn __m_generated_vec_serializer(arg: &Vec<Vec<Vec<Vec<u8>>>>) -> (u32, u32) {
unsafe fn __m_generated_vec_serializer_Vec_Vec_u8__(
arg: &Vec<Vec<Vec<u8>>>
) -> (u32, u32) {
unsafe fn __fce_generated_vec_serializer_Vec_Vec_u8___Vec_u8_(
unsafe fn __m_generated_vec_serializer_Vec_Vec_u8___Vec_u8_(
arg: &Vec<Vec<u8>>
) -> (u32, u32) {
unsafe fn __fce_generated_vec_serializer_Vec_Vec_u8___Vec_u8__u8(
unsafe fn __m_generated_vec_serializer_Vec_Vec_u8___Vec_u8__u8(
arg: &Vec<u8>
) -> (u32, u32) {
(arg.as_ptr() as _, arg.len() as _)
@ -78,7 +78,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_1(arg_0: u32, arg_1: u32
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
for value in arg {
let (ptr, size) =
__fce_generated_vec_serializer_Vec_Vec_u8___Vec_u8__u8(&value);
__m_generated_vec_serializer_Vec_Vec_u8___Vec_u8__u8(&value);
result.push(ptr as _);
result.push(size as _);
}
@ -89,7 +89,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_1(arg_0: u32, arg_1: u32
}
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
for value in arg {
let (ptr, size) = __fce_generated_vec_serializer_Vec_Vec_u8___Vec_u8_(&value);
let (ptr, size) = __m_generated_vec_serializer_Vec_Vec_u8___Vec_u8_(&value);
result.push(ptr as _);
result.push(size as _);
}
@ -100,7 +100,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_1(arg_0: u32, arg_1: u32
}
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
for value in arg {
let (ptr, size) = __fce_generated_vec_serializer_Vec_Vec_u8__(&value);
let (ptr, size) = __m_generated_vec_serializer_Vec_Vec_u8__(&value);
result.push(ptr as _);
result.push(size as _);
}
@ -110,7 +110,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_1(arg_0: u32, arg_1: u32
(result_ptr as _, result_len as _)
}
{
let (serialized_vec_ptr, serialized_vec_size) = __fce_generated_vec_serializer(&result);
let (serialized_vec_ptr, serialized_vec_size) = __m_generated_vec_serializer(&result);
fluence::internal::set_result_ptr(serialized_vec_ptr as _);
fluence::internal::set_result_size(serialized_vec_size as _);
}
@ -119,7 +119,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_1(arg_0: u32, arg_1: u32
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
#[allow(clippy::all)]
#[link_section = "__fce_generated_section__inner_arrays_1"]
pub static __fce_generated_static_global_inner_arrays_1: [u8; 330usize] = {
#[link_section = "__m_generated_section__inner_arrays_1"]
pub static __m_generated_static_global_inner_arrays_1: [u8; 330usize] = {
* b"{\"ast_type\":\"Function\",\"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\"]}]}}"
};

View File

@ -19,7 +19,7 @@ pub fn all_types(
#[no_mangle]
#[doc(hidden)]
#[allow(clippy::all)]
pub unsafe fn __fce_generated_wrapper_func_all_types(
pub unsafe fn __m_generated_wrapper_func_all_types(
arg_0: i8,
arg_1: i16,
arg_2: i32,
@ -46,10 +46,10 @@ pub unsafe fn __fce_generated_wrapper_func_all_types(
let converted_arg_8 = arg_8 as _;
let converted_arg_9 = arg_9 as _;
let converted_arg_10 = String::from_raw_parts(arg_10 as _, arg_11 as _, arg_11 as _);
unsafe fn __fce_generated_vec_deserializer_12(offset: u32, size: u32) -> Vec<u8> {
unsafe fn __m_generated_vec_deserializer_12(offset: u32, size: u32) -> Vec<u8> {
Vec::from_raw_parts(offset as _, size as _, size as _)
}
let converted_arg_12 = __fce_generated_vec_deserializer_12(arg_12 as _, arg_13 as _);
let converted_arg_12 = __m_generated_vec_deserializer_12(arg_12 as _, arg_13 as _);
let result = all_types(
converted_arg_0,
converted_arg_1,
@ -64,11 +64,11 @@ pub unsafe fn __fce_generated_wrapper_func_all_types(
converted_arg_10,
converted_arg_12
);
unsafe fn __fce_generated_vec_serializer(arg: &Vec<u8>) -> (u32, u32) {
unsafe fn __m_generated_vec_serializer(arg: &Vec<u8>) -> (u32, u32) {
(arg.as_ptr() as _, arg.len() as _)
}
{
let (serialized_vec_ptr, serialized_vec_size) = __fce_generated_vec_serializer(&result);
let (serialized_vec_ptr, serialized_vec_size) = __m_generated_vec_serializer(&result);
fluence::internal::set_result_ptr(serialized_vec_ptr as _);
fluence::internal::set_result_size(serialized_vec_size as _);
}
@ -77,7 +77,7 @@ pub unsafe fn __fce_generated_wrapper_func_all_types(
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
#[allow(clippy::all)]
#[link_section = "__fce_generated_section__all_types"]
pub static __fce_generated_static_global_all_types: [u8; 636usize] = {
#[link_section = "__m_generated_section__all_types"]
pub static __m_generated_static_global_all_types: [u8; 636usize] = {
* b"{\"ast_type\":\"Function\",\"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\"]}]}}"
};

View File

@ -6,9 +6,9 @@ pub fn test_array_refs(arg: &Vec<Vec<String>>) -> &Vec<Vec<Vec<Vec<String>>>> {
#[no_mangle]
#[doc(hidden)]
#[allow(clippy::all)]
pub unsafe fn __fce_generated_wrapper_func_test_array_refs(arg_0: u32, arg_1: u32) {
unsafe fn __fce_generated_vec_deserializer_0(offset: u32, size: u32) -> Vec<Vec<String>> {
unsafe fn __fce_generated_vec_deserializer_0_String(offset: u32, size: u32) -> Vec<String> {
pub unsafe fn __m_generated_wrapper_func_test_array_refs(arg_0: u32, arg_1: u32) {
unsafe fn __m_generated_vec_deserializer_0(offset: u32, size: u32) -> Vec<Vec<String>> {
unsafe fn __m_generated_vec_deserializer_0_String(offset: u32, size: u32) -> Vec<String> {
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 _);
@ -27,21 +27,21 @@ pub unsafe fn __fce_generated_wrapper_func_test_array_refs(arg_0: u32, arg_1: u3
let mut arg = arg.into_iter();
while let Some(offset) = arg.next() {
let size = arg.next().unwrap();
let value = __fce_generated_vec_deserializer_0_String(offset as _, size as _);
let value = __m_generated_vec_deserializer_0_String(offset as _, size as _);
result.push(value);
}
result
}
let converted_arg_0 = __fce_generated_vec_deserializer_0(arg_0 as _, arg_1 as _);
let converted_arg_0 = __m_generated_vec_deserializer_0(arg_0 as _, arg_1 as _);
let result = test_array_refs(&converted_arg_0);
unsafe fn __fce_generated_vec_serializer(arg: &Vec<Vec<Vec<Vec<String>>>>) -> (u32, u32) {
unsafe fn __fce_generated_vec_serializer_Vec_Vec_String__(
unsafe fn __m_generated_vec_serializer(arg: &Vec<Vec<Vec<Vec<String>>>>) -> (u32, u32) {
unsafe fn __m_generated_vec_serializer_Vec_Vec_String__(
arg: &Vec<Vec<Vec<String>>>
) -> (u32, u32) {
unsafe fn __fce_generated_vec_serializer_Vec_Vec_String___Vec_String_(
unsafe fn __m_generated_vec_serializer_Vec_Vec_String___Vec_String_(
arg: &Vec<Vec<String>>
) -> (u32, u32) {
unsafe fn __fce_generated_vec_serializer_Vec_Vec_String___Vec_String__String(
unsafe fn __m_generated_vec_serializer_Vec_Vec_String___Vec_String__String(
arg: &Vec<String>
) -> (u32, u32) {
let mut result: Vec<u32> = Vec::with_capacity(arg.len());
@ -57,7 +57,7 @@ pub unsafe fn __fce_generated_wrapper_func_test_array_refs(arg_0: u32, arg_1: u3
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
for value in arg {
let (ptr, size) =
__fce_generated_vec_serializer_Vec_Vec_String___Vec_String__String(&value);
__m_generated_vec_serializer_Vec_Vec_String___Vec_String__String(&value);
result.push(ptr as _);
result.push(size as _);
}
@ -69,7 +69,7 @@ pub unsafe fn __fce_generated_wrapper_func_test_array_refs(arg_0: u32, arg_1: u3
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
for value in arg {
let (ptr, size) =
__fce_generated_vec_serializer_Vec_Vec_String___Vec_String_(&value);
__m_generated_vec_serializer_Vec_Vec_String___Vec_String_(&value);
result.push(ptr as _);
result.push(size as _);
}
@ -80,7 +80,7 @@ pub unsafe fn __fce_generated_wrapper_func_test_array_refs(arg_0: u32, arg_1: u3
}
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
for value in arg {
let (ptr, size) = __fce_generated_vec_serializer_Vec_Vec_String__(&value);
let (ptr, size) = __m_generated_vec_serializer_Vec_Vec_String__(&value);
result.push(ptr as _);
result.push(size as _);
}
@ -90,7 +90,7 @@ pub unsafe fn __fce_generated_wrapper_func_test_array_refs(arg_0: u32, arg_1: u3
(result_ptr as _, result_len as _)
}
{
let (serialized_vec_ptr, serialized_vec_size) = __fce_generated_vec_serializer(&result);
let (serialized_vec_ptr, serialized_vec_size) = __m_generated_vec_serializer(&result);
fluence::internal::set_result_ptr(serialized_vec_ptr as _);
fluence::internal::set_result_size(serialized_vec_size as _);
}
@ -99,7 +99,7 @@ pub unsafe fn __fce_generated_wrapper_func_test_array_refs(arg_0: u32, arg_1: u3
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
#[allow(clippy::all)]
#[link_section = "__fce_generated_section__test_array_refs"]
pub static __fce_generated_static_global_test_array_refs: [u8; 297usize] = {
#[link_section = "__m_generated_section__test_array_refs"]
pub static __m_generated_static_global_test_array_refs: [u8; 297usize] = {
* b"{\"ast_type\":\"Function\",\"signature\":{\"name\":\"test_array_refs\",\"arguments\":[{\"name\":\"arg\",\"ty\":{\"Vector\":[{\"Vector\":[{\"Utf8String\":\"ByValue\"},\"ByValue\"]},\"ByRef\"]}}],\"output_types\":[{\"Vector\":[{\"Vector\":[{\"Vector\":[{\"Vector\":[{\"Utf8String\":\"ByValue\"},\"ByValue\"]},\"ByValue\"]},\"ByValue\"]},\"ByRef\"]}]}}"
};

View File

@ -16,7 +16,7 @@ pub struct CallParameters {
#[doc(hidden)]
#[allow(clippy::all)]
impl CallParameters {
pub fn __fce_generated_serialize(&self) -> *const u8 {
pub fn __m_generated_serialize(&self) -> *const u8 {
let mut raw_record: Vec<u8> = Vec::with_capacity(4 * 6usize);
let field_ident_ptr = self.init_peer_id.as_ptr() as u32;
raw_record.extend(&field_ident_ptr.to_le_bytes());
@ -33,15 +33,15 @@ impl CallParameters {
let field_ident_ptr = self.particle_id.as_ptr() as u32;
raw_record.extend(&field_ident_ptr.to_le_bytes());
raw_record.extend(&(self.particle_id.len() as u32).to_le_bytes());
unsafe fn __fce_generated_vec_serializer_tetraplets_5(
unsafe fn __m_generated_vec_serializer_tetraplets_5(
arg: &Vec<Vec<SecurityTetraplet>>
) -> (u32, u32) {
unsafe fn __fce_generated_vec_serializer_tetraplets_5_SecurityTetraplet(
unsafe fn __m_generated_vec_serializer_tetraplets_5_SecurityTetraplet(
arg: &Vec<SecurityTetraplet>
) -> (u32, u32) {
let mut result: Vec<u32> = Vec::with_capacity(arg.len());
for value in arg {
result.push(value.__fce_generated_serialize() as _);
result.push(value.__m_generated_serialize() as _);
}
let result_ptr = result.as_ptr();
let result_len = result.len();
@ -51,7 +51,7 @@ impl CallParameters {
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
for value in arg {
let (ptr, size) =
__fce_generated_vec_serializer_tetraplets_5_SecurityTetraplet(&value);
__m_generated_vec_serializer_tetraplets_5_SecurityTetraplet(&value);
result.push(ptr as _);
result.push(size as _);
}
@ -61,14 +61,14 @@ impl CallParameters {
(result_ptr as _, result_len as _)
}
let serialized_arg_5 =
unsafe { __fce_generated_vec_serializer_tetraplets_5(&self.tetraplets) };
unsafe { __m_generated_vec_serializer_tetraplets_5(&self.tetraplets) };
raw_record.extend(&serialized_arg_5.0.to_le_bytes());
raw_record.extend(&serialized_arg_5.1.to_le_bytes());
let raw_record_ptr = raw_record.as_ptr();
fluence::internal::add_object_to_release(Box::new(raw_record));
raw_record_ptr as _
}
pub unsafe fn __fce_generated_deserialize(record_ptr: *const u8) -> Self {
pub unsafe fn __m_generated_deserialize(record_ptr: *const u8) -> Self {
let raw_record: Vec<u8> = Vec::from_raw_parts(record_ptr as _, 48usize, 48usize);
let field_0 = unsafe {
let offset = u32::from_le_bytes([
@ -145,18 +145,18 @@ impl CallParameters {
]);
String::from_raw_parts(offset as _, size as _, size as _)
};
unsafe fn __fce_generated_vec_deserializer_40(
unsafe fn __m_generated_vec_deserializer_40(
offset: u32,
size: u32
) -> Vec<Vec<SecurityTetraplet>> {
unsafe fn __fce_generated_vec_deserializer_40_SecurityTetraplet(
unsafe fn __m_generated_vec_deserializer_40_SecurityTetraplet(
offset: u32,
size: u32
) -> Vec<SecurityTetraplet> {
let mut arg: Vec<u32> = Vec::from_raw_parts(offset as _, size as _, size as _);
let mut result = Vec::with_capacity(arg.len());
for offset in arg {
let value = SecurityTetraplet::__fce_generated_deserialize(offset as _);
let value = SecurityTetraplet::__m_generated_deserialize(offset as _);
result.push(value);
}
result
@ -168,7 +168,7 @@ impl CallParameters {
let mut arg = arg.into_iter();
while let Some(offset) = arg.next() {
let size = arg.next().unwrap();
let value = __fce_generated_vec_deserializer_40_SecurityTetraplet(
let value = __m_generated_vec_deserializer_40_SecurityTetraplet(
offset as _,
size as _
);
@ -188,7 +188,7 @@ impl CallParameters {
raw_record[40usize + 6],
raw_record[40usize + 7],
]);
let field_5 = unsafe { __fce_generated_vec_deserializer_40(offset as _, size as _) };
let field_5 = unsafe { __m_generated_vec_deserializer_40(offset as _, size as _) };
Self {
init_peer_id: field_0,
service_id: field_1,
@ -202,7 +202,7 @@ impl CallParameters {
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
#[allow(clippy::all)]
#[link_section = "__fce_generated_section__CallParameters"]
pub static __fce_generated_static_global_CallParameters: [u8; 455usize] = {
#[link_section = "__m_generated_section__CallParameters"]
pub static __m_generated_static_global_CallParameters: [u8; 455usize] = {
* b"{\"ast_type\":\"Record\",\"name\":\"CallParameters\",\"fields\":{\"Named\":[{\"name\":\"init_peer_id\",\"ty\":{\"Utf8String\":\"ByValue\"}},{\"name\":\"service_id\",\"ty\":{\"Utf8String\":\"ByValue\"}},{\"name\":\"service_creator_peer_id\",\"ty\":{\"Utf8String\":\"ByValue\"}},{\"name\":\"host_id\",\"ty\":{\"Utf8String\":\"ByValue\"}},{\"name\":\"particle_id\",\"ty\":{\"Utf8String\":\"ByValue\"}},{\"name\":\"tetraplets\",\"ty\":{\"Vector\":[{\"Vector\":[{\"Record\":[\"SecurityTetraplet\",\"ByValue\"]},\"ByValue\"]},\"ByValue\"]}}]}}"
};

View File

@ -6,27 +6,27 @@ pub fn inner_arrays_2(arg: Vec<Vec<Vec<Vec<TestRecord>>>>) -> Vec<Vec<Vec<Vec<Te
#[no_mangle]
#[doc(hidden)]
#[allow(clippy::all)]
pub unsafe fn __fce_generated_wrapper_func_inner_arrays_2(arg_0: u32, arg_1: u32) {
unsafe fn __fce_generated_vec_deserializer_0(
pub unsafe fn __m_generated_wrapper_func_inner_arrays_2(arg_0: u32, arg_1: u32) {
unsafe fn __m_generated_vec_deserializer_0(
offset: u32,
size: u32
) -> Vec<Vec<Vec<Vec<TestRecord>>>> {
unsafe fn __fce_generated_vec_deserializer_0_Vec_Vec_TestRecord__(
unsafe fn __m_generated_vec_deserializer_0_Vec_Vec_TestRecord__(
offset: u32,
size: u32
) -> Vec<Vec<Vec<TestRecord>>> {
unsafe fn __fce_generated_vec_deserializer_0_Vec_Vec_TestRecord___Vec_TestRecord_(
unsafe fn __m_generated_vec_deserializer_0_Vec_Vec_TestRecord___Vec_TestRecord_(
offset: u32,
size: u32
) -> Vec<Vec<TestRecord>> {
unsafe fn __fce_generated_vec_deserializer_0_Vec_Vec_TestRecord___Vec_TestRecord__TestRecord(
unsafe fn __m_generated_vec_deserializer_0_Vec_Vec_TestRecord___Vec_TestRecord__TestRecord(
offset: u32,
size: u32
) -> Vec<TestRecord> {
let mut arg: Vec<u32> = Vec::from_raw_parts(offset as _, size as _, size as _);
let mut result = Vec::with_capacity(arg.len());
for offset in arg {
let value = TestRecord::__fce_generated_deserialize(offset as _);
let value = TestRecord::__m_generated_deserialize(offset as _);
result.push(value);
}
result
@ -38,7 +38,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_2(arg_0: u32, arg_1: u32
let mut arg = arg.into_iter();
while let Some(offset) = arg.next() {
let size = arg.next().unwrap();
let value = __fce_generated_vec_deserializer_0_Vec_Vec_TestRecord___Vec_TestRecord__TestRecord ( offset as _ , size as _ ) ;
let value = __m_generated_vec_deserializer_0_Vec_Vec_TestRecord___Vec_TestRecord__TestRecord ( offset as _ , size as _ ) ;
result.push(value);
}
result
@ -50,7 +50,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_2(arg_0: u32, arg_1: u32
let mut arg = arg.into_iter();
while let Some(offset) = arg.next() {
let size = arg.next().unwrap();
let value = __fce_generated_vec_deserializer_0_Vec_Vec_TestRecord___Vec_TestRecord_(
let value = __m_generated_vec_deserializer_0_Vec_Vec_TestRecord___Vec_TestRecord_(
offset as _,
size as _
);
@ -65,26 +65,26 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_2(arg_0: u32, arg_1: u32
while let Some(offset) = arg.next() {
let size = arg.next().unwrap();
let value =
__fce_generated_vec_deserializer_0_Vec_Vec_TestRecord__(offset as _, size as _);
__m_generated_vec_deserializer_0_Vec_Vec_TestRecord__(offset as _, size as _);
result.push(value);
}
result
}
let converted_arg_0 = __fce_generated_vec_deserializer_0(arg_0 as _, arg_1 as _);
let converted_arg_0 = __m_generated_vec_deserializer_0(arg_0 as _, arg_1 as _);
let result = inner_arrays_2(converted_arg_0);
unsafe fn __fce_generated_vec_serializer(arg: &Vec<Vec<Vec<Vec<TestRecord>>>>) -> (u32, u32) {
unsafe fn __fce_generated_vec_serializer_Vec_Vec_TestRecord__(
unsafe fn __m_generated_vec_serializer(arg: &Vec<Vec<Vec<Vec<TestRecord>>>>) -> (u32, u32) {
unsafe fn __m_generated_vec_serializer_Vec_Vec_TestRecord__(
arg: &Vec<Vec<Vec<TestRecord>>>
) -> (u32, u32) {
unsafe fn __fce_generated_vec_serializer_Vec_Vec_TestRecord___Vec_TestRecord_(
unsafe fn __m_generated_vec_serializer_Vec_Vec_TestRecord___Vec_TestRecord_(
arg: &Vec<Vec<TestRecord>>
) -> (u32, u32) {
unsafe fn __fce_generated_vec_serializer_Vec_Vec_TestRecord___Vec_TestRecord__TestRecord(
unsafe fn __m_generated_vec_serializer_Vec_Vec_TestRecord___Vec_TestRecord__TestRecord(
arg: &Vec<TestRecord>
) -> (u32, u32) {
let mut result: Vec<u32> = Vec::with_capacity(arg.len());
for value in arg {
result.push(value.__fce_generated_serialize() as _);
result.push(value.__m_generated_serialize() as _);
}
let result_ptr = result.as_ptr();
let result_len = result.len();
@ -93,7 +93,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_2(arg_0: u32, arg_1: u32
}
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
for value in arg {
let ( ptr , size ) = __fce_generated_vec_serializer_Vec_Vec_TestRecord___Vec_TestRecord__TestRecord ( & value ) ;
let ( ptr , size ) = __m_generated_vec_serializer_Vec_Vec_TestRecord___Vec_TestRecord__TestRecord ( & value ) ;
result.push(ptr as _);
result.push(size as _);
}
@ -105,7 +105,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_2(arg_0: u32, arg_1: u32
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
for value in arg {
let (ptr, size) =
__fce_generated_vec_serializer_Vec_Vec_TestRecord___Vec_TestRecord_(&value);
__m_generated_vec_serializer_Vec_Vec_TestRecord___Vec_TestRecord_(&value);
result.push(ptr as _);
result.push(size as _);
}
@ -116,7 +116,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_2(arg_0: u32, arg_1: u32
}
let mut result: Vec<u32> = Vec::with_capacity(2 * arg.len());
for value in arg {
let (ptr, size) = __fce_generated_vec_serializer_Vec_Vec_TestRecord__(&value);
let (ptr, size) = __m_generated_vec_serializer_Vec_Vec_TestRecord__(&value);
result.push(ptr as _);
result.push(size as _);
}
@ -126,7 +126,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_2(arg_0: u32, arg_1: u32
(result_ptr as _, result_len as _)
}
{
let (serialized_vec_ptr, serialized_vec_size) = __fce_generated_vec_serializer(&result);
let (serialized_vec_ptr, serialized_vec_size) = __m_generated_vec_serializer(&result);
fluence::internal::set_result_ptr(serialized_vec_ptr as _);
fluence::internal::set_result_size(serialized_vec_size as _);
}
@ -135,7 +135,7 @@ pub unsafe fn __fce_generated_wrapper_func_inner_arrays_2(arg_0: u32, arg_1: u32
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
#[allow(clippy::all)]
#[link_section = "__fce_generated_section__inner_arrays_2"]
pub static __fce_generated_static_global_inner_arrays_2: [u8; 368usize] = {
#[link_section = "__m_generated_section__inner_arrays_2"]
pub static __m_generated_static_global_inner_arrays_2: [u8; 368usize] = {
* b"{\"ast_type\":\"Function\",\"signature\":{\"name\":\"inner_arrays_2\",\"arguments\":[{\"name\":\"arg\",\"ty\":{\"Vector\":[{\"Vector\":[{\"Vector\":[{\"Vector\":[{\"Record\":[\"TestRecord\",\"ByValue\"]},\"ByValue\"]},\"ByValue\"]},\"ByValue\"]},\"ByValue\"]}}],\"output_types\":[{\"Vector\":[{\"Vector\":[{\"Vector\":[{\"Vector\":[{\"Record\":[\"TestRecord\",\"ByValue\"]},\"ByValue\"]},\"ByValue\"]},\"ByValue\"]},\"ByValue\"]}]}}"
};

View File

@ -1,43 +1,43 @@
mod utils;
use utils::test_fce_token_streams;
use utils::test_marine_token_streams;
#[test]
fn exports_arrays() {
assert!(test_fce_token_streams(
"tests/generation_tests/exports/arrays/fce.rs",
assert!(test_marine_token_streams(
"tests/generation_tests/exports/arrays/marine.rs",
"tests/generation_tests/exports/arrays/expanded.rs",
));
}
#[test]
fn exports_basic_types() {
assert!(test_fce_token_streams(
"tests/generation_tests/exports/basic_types/fce.rs",
assert!(test_marine_token_streams(
"tests/generation_tests/exports/basic_types/marine.rs",
"tests/generation_tests/exports/basic_types/expanded.rs",
));
}
#[test]
fn exports_refs() {
assert!(test_fce_token_streams(
"tests/generation_tests/exports/refs/fce.rs",
assert!(test_marine_token_streams(
"tests/generation_tests/exports/refs/marine.rs",
"tests/generation_tests/exports/refs/expanded.rs",
));
}
#[test]
fn records_call_parameters() {
assert!(test_fce_token_streams(
"tests/generation_tests/records/call_parameters/fce.rs",
assert!(test_marine_token_streams(
"tests/generation_tests/records/call_parameters/marine.rs",
"tests/generation_tests/records/call_parameters/expanded.rs",
));
}
#[test]
fn records_use_as_type() {
assert!(test_fce_token_streams(
"tests/generation_tests/records/use_as_type/fce.rs",
assert!(test_marine_token_streams(
"tests/generation_tests/records/use_as_type/marine.rs",
"tests/generation_tests/records/use_as_type/expanded.rs",
));
}

View File

@ -14,29 +14,29 @@
* limitations under the License.
*/
use fluence_sdk_wit::fce;
use marine_macro_impl::marine;
use pretty_assertions::assert_eq;
use std::io::Read;
use std::path::Path;
pub fn test_fce_token_streams<FP, EP>(fce_path: FP, expanded_path: EP) -> bool
pub fn test_marine_token_streams<FP, EP>(marine_path: FP, expanded_path: EP) -> bool
where
FP: AsRef<Path>,
EP: AsRef<Path>,
{
let fce_item = stream_from_file(fce_path);
let test_token_stream = quote::quote! { #fce_item };
let fce_token_streams = fce(test_token_stream)
.unwrap_or_else(|e| panic!("failed to apply the fce macro due {}", e));
let marine_item = stream_from_file(marine_path);
let test_token_stream = quote::quote! { #marine_item };
let marine_token_streams = marine(test_token_stream)
.unwrap_or_else(|e| panic!("failed to apply the marine macro due {}", e));
let expanded_item = items_from_file(expanded_path);
let fce_item = to_syn_item(fce_token_streams);
let marine_item = to_syn_item(marine_token_streams);
assert_eq!(expanded_item, fce_item);
assert_eq!(expanded_item, marine_item);
fce_item == expanded_item
marine_item == expanded_item
}
fn stream_from_file<P>(path: P) -> proc_macro2::TokenStream

View File

@ -1,9 +1,9 @@
[package]
name = "fluence-sdk-macro"
version = "0.6.1" # remember to update html_root_url
name = "marine-macro"
version = "0.6.2" # remember to update html_root_url
edition = "2018"
description = "Definition of the `#[fce]` macro"
documentation = "https://docs.rs/fluence/fluence-sdk-macro"
description = "Definition of the `#[marine]` macro"
documentation = "https://docs.rs/fluence/marine-macro"
repository = "https://github.com/fluencelabs/rust-sdk/crates/macro"
authors = ["Fluence Labs"]
keywords = ["fluence", "sdk", "webassembly", "procedural_macros"]
@ -18,4 +18,4 @@ proc-macro = true
doctest = false
[dependencies]
fluence-sdk-wit = { path = "../wit", version = "=0.6.1" }
marine-macro-impl = { path = "../marine-macro-impl", version = "=0.6.2" }

View File

@ -14,17 +14,17 @@
* limitations under the License.
*/
//! Defines the #[fce] macro that should be used with all export functions, extern blocks.
//! Defines the #[marine] macro that should be used with all export functions, extern blocks.
//! At now, It supports the following types that could be used as parameters in export or foreign
//! functions: i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, bool, String, Vec<u8>. Also struct
//! where all fields are public and have aforementioned types could be used as parameters. In this
//! case #[fce] should be also applied to this structs.
//! case #[marine] should be also applied to this structs.
//!
//! # Examples
//!
//! This example shows how a function could be exported:
//! ```ignore
//! #[fce]
//! #[marine]
//! pub fn greeting(name: String) -> String {
//! format!("Hi {}", name)
//! }
@ -36,13 +36,13 @@
//! ```ignore
//! use fluence::MountedBinaryResult;
//!
//! #[fce]
//! #[marine]
//! pub fn read_ipfs_file(file_path: String) -> MountedBinaryResult {
//! let hash = calculate_hash(file_path);
//! ipfs(vec![hash])
//! }
//!
//! #[fce]
//! #[marine]
//! #[link(wasm_import_module = "ipfs_node")]
//! extern "C" {
//! pub fn ipfs(file_hash: Vec<String>) -> MountedBinaryResult;
@ -50,7 +50,7 @@
//!
//! ```
#![doc(html_root_url = "https://docs.rs/fluence-sdk-macro/0.5.0")]
#![doc(html_root_url = "https://docs.rs/marine-macro/0.5.0")]
#![deny(
dead_code,
nonstandard_style,
@ -62,13 +62,27 @@
#![warn(rust_2018_idioms)]
#![recursion_limit = "1024"]
use fluence_sdk_wit::fce as fce_impl;
use marine_macro_impl::marine as marine_impl;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn fce(_attr: TokenStream, input: TokenStream) -> TokenStream {
pub fn marine(_attr: TokenStream, input: TokenStream) -> TokenStream {
// into converts proc_macro::TokenStream to proc_macro2::TokenStream
match fce_impl(input.into()) {
match marine_impl(input.into()) {
Ok(v) => v,
// converts syn:error to proc_macro2::TokenStream
Err(e) => e.to_compile_error(),
}
// converts proc_macro2::TokenStream to proc_macro::TokenStream
.into()
}
// deprecated macro for backwards compatibility
#[deprecated(since = "0.6.2", note = "please use the #[marine] macro instead")]
#[proc_macro_attribute]
pub fn fce(_attr: TokenStream, input: TokenStream) -> TokenStream {
// into converts proc_macro::TokenStream to proc_macro2::TokenStream
match marine_impl(input.into()) {
Ok(v) => v,
// converts syn:error to proc_macro2::TokenStream
Err(e) => e.to_compile_error(),

View File

@ -1,8 +1,8 @@
[package]
name = "fluence-sdk-test-macro-impl"
name = "marine-test-macro-impl"
version = "0.1.5" # remember to update html_root_url
edition = "2018"
description = "Implementation of the `#[fce_test]` macro"
description = "Implementation of the `#[marine_test]` macro"
repository = "https://github.com/fluencelabs/rust-sdk/crates/macro-test"
authors = ["Fluence Labs"]
keywords = ["fluence", "sdk", "webassembly", "procedural_macros"]
@ -14,7 +14,7 @@ all-features = true
[dependencies]
fluence-app-service = { version = "0.7.0", features = ["raw-module-api"] }
fce-wit-parser = "0.5.0"
marine-it-parser = "0.5.0"
darling = "0.12.2"
quote = "1.0.9"

View File

@ -16,9 +16,9 @@
use darling::FromMeta;
/// Describes attributes of `fce_test` macro.
/// Describes attributes of `marine_test` macro.
#[derive(Debug, Default, Clone, FromMeta)]
pub(crate) struct FCETestAttributes {
pub(crate) struct MTestAttributes {
/// Path to a config file of a tested service.
pub(crate) config_path: String,

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
use fce_wit_parser::WITParserError;
use marine_it_parser::ITParserError;
use fluence_app_service::AppServiceError;
use darling::Error as DarlingError;
@ -25,8 +25,8 @@ use std::path::PathBuf;
#[derive(Debug, ThisError)]
pub enum TestGeneratorError {
#[error("Can't load Wasm modules into FCE: {0}")]
WITParserError(#[from] WITParserError),
#[error("Can't load Wasm modules into Marine: {0}")]
ITParserError(#[from] ITParserError),
#[error("{0}")]
CorruptedITSection(#[from] CorruptedITSection),

View File

@ -28,9 +28,9 @@
mod attributes;
mod errors;
mod fce_test;
mod marine_test;
pub use fce_test::fce_test_impl;
pub use marine_test::marine_test_impl;
pub use errors::TestGeneratorError;
pub(crate) type TResult<T> = std::result::Result<T, TestGeneratorError>;

View File

@ -17,19 +17,19 @@
use crate::TResult;
use fluence_app_service::TomlAppServiceConfig;
use fce_wit_parser::module_raw_interface;
use fce_wit_parser::interface::FCEModuleInterface;
use marine_it_parser::module_raw_interface;
use marine_it_parser::interface::MModuleInterface;
use std::path::PathBuf;
#[derive(Debug, Clone, PartialEq, Eq)]
pub(super) struct Module<'m> {
pub name: &'m str,
pub interface: FCEModuleInterface,
pub interface: MModuleInterface,
}
impl<'m> Module<'m> {
fn new(name: &'m str, interface: FCEModuleInterface) -> Self {
fn new(name: &'m str, interface: MModuleInterface) -> Self {
Self { name, interface }
}
}

View File

@ -14,11 +14,11 @@
* limitations under the License.
*/
use crate::attributes::FCETestAttributes;
use crate::attributes::MTestAttributes;
use crate::TResult;
use crate::TestGeneratorError;
use crate::fce_test;
use crate::fce_test::config_utils;
use crate::marine_test;
use crate::marine_test::config_utils;
use fluence_app_service::TomlAppServiceConfig;
use proc_macro2::TokenStream;
@ -30,7 +30,7 @@ use std::path::PathBuf;
/// Generates glue code for tests.
/// F.e. for this test for the greeting service
///```ignore
/// #[fce_test(
/// #[marine_test(
/// config_path = "/path/to/service/config/Config.toml",
/// modules_dir = "/path/to/modules/dir"
/// )]
@ -43,25 +43,25 @@ use std::path::PathBuf;
/// the following glue code would be generated:
///```ignore
/// // (0)
/// pub mod __fce_generated_greeting {
/// struct FCEGeneratedStructgreeting {
/// fce: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>,
/// pub mod __m_generated_greeting {
/// struct MGeneratedStructgreeting {
/// marine: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>,
/// }
///
/// impl FCEGeneratedStructgreeting {
/// pub fn new(fce: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>) -> Self {
/// Self { fce }
/// impl MGeneratedStructgreeting {
/// pub fn new(marine: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>) -> Self {
/// Self { marine }
/// }
///
/// pub fn greeting(&mut self, name: String) -> String {
/// use std::ops::DerefMut;
/// let arguments = fluence_test::internal::serde_json::json!([name]);
/// let result = self
/// .fce
/// .marine
/// .as_ref
/// .borrow_mut()
/// .call_with_module_name("greeting", "greeting", arguments, <_>::default())
/// .expect("call to FCE failed");
/// .expect("call to Marine failed");
/// let result: String = fluence_test::internal::serde_json::from_value(result)
/// .expect("the default deserializer shouldn't fail");
/// result
@ -76,7 +76,7 @@ use std::path::PathBuf;
/// let tmp_dir = tmp_dir.to_string_lossy().to_string();
/// std::fs::create_dir(&tmp_dir).expect("can't create a directory for service in tmp");
///
/// let mut __fce_generated_fce_config = fluence_test::internal::TomlAppServiceConfig::load("/path/to/greeting/Config.toml".to_string())
/// let mut __m_generated_marine_config = fluence_test::internal::TomlAppServiceConfig::load("/path/to/greeting/Config.toml".to_string())
/// .unwrap_or_else(|e| {
/// panic!(
/// "app service located at `{}` config can't be loaded: {}",
@ -84,19 +84,19 @@ use std::path::PathBuf;
/// )
/// });
///
/// __fce_generated_fce_config.service_base_dir = Some("/path/to/tmp".to_string());
/// __m_generated_marine_config.service_base_dir = Some("/path/to/tmp".to_string());
///
/// let fce = fluence_test::internal::AppService::new_with_empty_facade(
/// __fce_generated_fce_config,
/// let marine = fluence_test::internal::AppService::new_with_empty_facade(
/// __m_generated_marine_config,
/// "3640e972-92e3-47cb-b95f-4e3c5bcf0f14",
/// std::collections::HashMap::new(),
/// ).unwrap_or_else(|e| panic!("app service can't be created: {}", e));
///
/// let fce = std::rc::Rc::new(std::cell::RefCell::new(fce));
/// let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
///
/// // (2)
///
/// let mut greeting = __fce_generated_greeting::FCEGeneratedStructgreeting::new(fce);
/// let mut greeting = __m_generated_greeting::MGeneratedStructgreeting::new(marine);
///
/// // (3)
///
@ -113,23 +113,24 @@ use std::path::PathBuf;
/// [(3), (4)] - original_block
pub(super) fn generate_test_glue_code(
func_item: syn::ItemFn,
attrs: FCETestAttributes,
attrs: MTestAttributes,
file_path: PathBuf,
) -> TResult<TokenStream> {
let config_path = file_path.join(&attrs.config_path);
let fce_config = TomlAppServiceConfig::load(&config_path)?;
let modules_dir = match config_utils::resolve_modules_dir(&fce_config, attrs.modules_dir) {
let marine_config = TomlAppServiceConfig::load(&config_path)?;
let modules_dir = match config_utils::resolve_modules_dir(&marine_config, attrs.modules_dir) {
Some(modules_dir) => modules_dir,
None => return Err(TestGeneratorError::ModulesDirUnspecified),
};
let app_service_ctor = generate_app_service_ctor(&attrs.config_path, &modules_dir)?;
let modules_dir = file_path.join(modules_dir);
let module_interfaces = fce_test::config_utils::collect_modules(&fce_config, modules_dir)?;
let module_interfaces =
marine_test::config_utils::collect_modules(&marine_config, modules_dir)?;
let module_definitions =
fce_test::module_generator::generate_module_definitions(module_interfaces.iter())?;
marine_test::module_generator::generate_module_definitions(module_interfaces.iter())?;
let module_iter = module_interfaces.iter().map(|module| module.name);
let module_ctors = generate_module_ctors(module_iter)?;
@ -143,7 +144,7 @@ pub(super) fn generate_test_glue_code(
// definitions for wasm modules specified in config
#(#module_definitions)*
// AppService constructor and instantiation to implicit `fce` variable
// AppService constructor and instantiation to implicit `marine` variable
#app_service_ctor
// constructors of all modules of the tested service
@ -203,15 +204,15 @@ fn generate_app_service_ctor(config_path: &str, modules_dir: &Path) -> TResult<T
let modules_dir = module_path.join(#modules_dir);
let modules_dir = modules_dir.to_str().expect("modules_dir contains invalid UTF8 string");
let mut __fce_generated_fce_config = fluence_test::internal::TomlAppServiceConfig::load(&config_path)
let mut __m_generated_marine_config = fluence_test::internal::TomlAppServiceConfig::load(&config_path)
.unwrap_or_else(|e| panic!("app service config located at `{:?}` can't be loaded: {}", config_path, e));
__fce_generated_fce_config.service_base_dir = Some(tmp_dir);
__fce_generated_fce_config.toml_faas_config.modules_dir = Some(modules_dir.to_string());
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
__m_generated_marine_config.toml_faas_config.modules_dir = Some(modules_dir.to_string());
let fce = fluence_test::internal::AppService::new_with_empty_facade(__fce_generated_fce_config, service_id, std::collections::HashMap::new())
let marine = fluence_test::internal::AppService::new_with_empty_facade(__m_generated_marine_config, service_id, std::collections::HashMap::new())
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
let fce = std::rc::Rc::new(std::cell::RefCell::new(fce));
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
};
Ok(service_ctor)
@ -224,12 +225,12 @@ fn generate_module_ctors<'n>(
.map(|name| -> TResult<_> {
// TODO: optimize these two call because they are called twice for each module name
// and internally allocate memory in format call.
let module_name = fce_test::utils::generate_module_name(&name)?;
let struct_name = fce_test::utils::generate_struct_name(&name)?;
let name_for_user = fce_test::utils::new_ident(&name)?;
let module_name = marine_test::utils::generate_module_name(&name)?;
let struct_name = marine_test::utils::generate_struct_name(&name)?;
let name_for_user = marine_test::utils::new_ident(&name)?;
let module_ctor =
quote! { let mut #name_for_user = #module_name::#struct_name::new(fce.clone()); };
quote! { let mut #name_for_user = #module_name::#struct_name::new(marine.clone()); };
Ok(module_ctor)
})

View File

@ -14,16 +14,16 @@
* limitations under the License.
*/
use crate::attributes::FCETestAttributes;
use crate::attributes::MTestAttributes;
use crate::TResult;
use crate::fce_test::glue_code_generator::generate_test_glue_code;
use crate::marine_test::glue_code_generator::generate_test_glue_code;
use proc_macro2::TokenStream;
use darling::FromMeta;
use syn::parse::Parser;
use std::path::PathBuf;
pub fn fce_test_impl(
pub fn marine_test_impl(
attrs: TokenStream,
input: TokenStream,
file_path: PathBuf,
@ -32,7 +32,7 @@ pub fn fce_test_impl(
let parser = syn::punctuated::Punctuated::<syn::NestedMeta, syn::Token![,]>::parse_terminated;
let attrs = parser.parse2(attrs)?;
let attrs: Vec<syn::NestedMeta> = attrs.into_iter().collect();
let attrs = FCETestAttributes::from_list(&attrs)?;
let attrs = MTestAttributes::from_list(&attrs)?;
let func_item = syn::parse2::<syn::ItemFn>(input)?;

View File

@ -15,9 +15,9 @@
*/
mod config_utils;
mod fce_test_impl;
mod marine_test_impl;
mod glue_code_generator;
mod module_generator;
mod utils;
pub use fce_test_impl::fce_test_impl;
pub use marine_test_impl::marine_test_impl;

View File

@ -18,8 +18,8 @@ mod methods_generator;
mod methods_generator_utils;
mod record_type_generator;
use crate::fce_test::utils;
use crate::fce_test::config_utils::Module;
use crate::marine_test::utils;
use crate::marine_test::config_utils::Module;
use crate::TResult;
use proc_macro2::TokenStream;
@ -28,25 +28,25 @@ use quote::quote;
/// Generates definitions of modules and records of this modules.
/// F.e. for the greeting service the following definitions would be generated:
///```ignore
/// pub mod __fce_generated_greeting {
/// struct FCEGeneratedStructgreeting {
/// fce: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>,
/// pub mod __m_generated_greeting {
/// struct MGeneratedStructgreeting {
/// marine: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>,
/// }
///
/// impl FCEGeneratedStructgreeting {
/// pub fn new(fce: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>) -> Self {
/// Self { fce }
/// impl MGeneratedStructgreeting {
/// pub fn new(marine: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>) -> Self {
/// Self { marine }
/// }
///
/// pub fn greeting(&mut self, name: String) -> String {
/// use std::ops::DerefMut;
/// let arguments = fluence_test::internal::serde_json::json!([name]);
/// let result = self
/// .fce
/// .marine
/// .as_ref
/// .borrow_mut()
/// .call_with_module_name("greeting", "greeting", arguments, <_>::default())
/// .expect("call to FCE failed");
/// .expect("call to Marine failed");
/// let result: String = fluence_test::internal::serde_json::from_value(result)
/// .expect("the default deserializer shouldn't fail");
/// result
@ -81,12 +81,12 @@ fn generate_module_definition(module: &Module<'_>) -> TResult<TokenStream> {
#(#module_records)*
pub struct #struct_name_ident {
fce: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>,
marine: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>,
}
impl #struct_name_ident {
pub fn new(fce: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>) -> Self {
Self { fce }
pub fn new(marine: std::rc::Rc<std::cell::RefCell<fluence_test::internal::AppService>>) -> Self {
Self { marine }
}
}

View File

@ -17,13 +17,13 @@
use super::methods_generator_utils::*;
use crate::TResult;
use fce_wit_parser::interface::FCERecordTypes;
use fce_wit_parser::interface::FCEFunctionSignature;
use marine_it_parser::interface::MRecordTypes;
use marine_it_parser::interface::MFunctionSignature;
pub(super) fn generate_module_methods<'m, 'r>(
module_name: &str,
mut method_signatures: impl ExactSizeIterator<Item = &'m FCEFunctionSignature>,
records: &'r FCERecordTypes,
mut method_signatures: impl ExactSizeIterator<Item = &'m MFunctionSignature>,
records: &'r MRecordTypes,
) -> TResult<Vec<proc_macro2::TokenStream>> {
use CallParametersSettings::*;

View File

@ -14,14 +14,14 @@
* limitations under the License.
*/
use crate::fce_test::utils::new_ident;
use crate::fce_test::utils::itype_to_tokens;
use crate::marine_test::utils::new_ident;
use crate::marine_test::utils::itype_to_tokens;
use crate::TResult;
use fce_wit_parser::interface::it::IType;
use fce_wit_parser::interface::it::IFunctionArg;
use fce_wit_parser::interface::FCERecordTypes;
use fce_wit_parser::interface::FCEFunctionSignature;
use marine_it_parser::interface::it::IType;
use marine_it_parser::interface::it::IFunctionArg;
use marine_it_parser::interface::MRecordTypes;
use marine_it_parser::interface::MFunctionSignature;
use proc_macro2::TokenStream;
use quote::quote;
@ -34,13 +34,13 @@ pub(super) enum CallParametersSettings {
pub(super) fn generate_module_method(
module_name: &str,
signature: &FCEFunctionSignature,
signature: &MFunctionSignature,
cp_setting: CallParametersSettings,
records: &FCERecordTypes,
records: &MRecordTypes,
) -> TResult<TokenStream> {
let arguments = generate_arguments(signature.arguments.iter(), records)?;
let output_type = generate_output_type(&signature.outputs, records)?;
let fce_call = generate_fce_call(module_name, cp_setting, &signature, records)?;
let mcall = generate_marine_call(module_name, cp_setting, &signature, records)?;
let (cp, func_name) = match cp_setting {
CallParametersSettings::Default => {
@ -63,18 +63,18 @@ pub(super) fn generate_module_method(
let module_method = quote! {
pub fn #func_name(&mut self, #(#arguments),* #cp) #output_type {
#fce_call
#mcall
}
};
Ok(module_method)
}
fn generate_fce_call(
fn generate_marine_call(
module_name: &str,
cp_settings: CallParametersSettings,
method_signature: &FCEFunctionSignature,
records: &FCERecordTypes,
method_signature: &MFunctionSignature,
records: &MRecordTypes,
) -> TResult<TokenStream> {
let args = method_signature.arguments.iter().map(|a| a.name.as_str());
let convert_arguments = generate_arguments_converter(args)?;
@ -122,7 +122,7 @@ fn generate_function_call(
CallParametersSettings::UserDefined => quote! { cp },
};
quote! { self.fce.as_ref().borrow_mut().call_module(#module_name, #method_name, arguments, #cp).expect("call to Marine failed"); }
quote! { self.marine.as_ref().borrow_mut().call_module(#module_name, #method_name, arguments, #cp).expect("call to Marine failed"); }
}
fn generate_set_result(output_type: &Option<&IType>) -> TokenStream {
@ -134,7 +134,7 @@ fn generate_set_result(output_type: &Option<&IType>) -> TokenStream {
fn generate_convert_to_output(
output_type: &Option<&IType>,
records: &FCERecordTypes,
records: &MRecordTypes,
) -> TResult<TokenStream> {
let result_stream = match output_type {
Some(ty) => {
@ -158,7 +158,7 @@ fn generate_ret(output_type: &Option<&IType>) -> TokenStream {
fn generate_arguments<'a, 'r>(
arguments: impl ExactSizeIterator<Item = &'a IFunctionArg>,
records: &'r FCERecordTypes,
records: &'r MRecordTypes,
) -> TResult<Vec<TokenStream>> {
arguments
.map(|argument| -> TResult<_> {
@ -171,7 +171,7 @@ fn generate_arguments<'a, 'r>(
.collect::<TResult<Vec<_>>>()
}
fn generate_output_type(output_types: &[IType], records: &FCERecordTypes) -> TResult<TokenStream> {
fn generate_output_type(output_types: &[IType], records: &MRecordTypes) -> TResult<TokenStream> {
let output_type = get_output_type(output_types)?;
match output_type {
None => Ok(TokenStream::new()),

View File

@ -14,16 +14,16 @@
* limitations under the License.
*/
use crate::fce_test::utils;
use crate::marine_test::utils;
use crate::TResult;
use fce_wit_parser::interface::it::IRecordFieldType;
use fce_wit_parser::interface::FCERecordTypes;
use marine_it_parser::interface::it::IRecordFieldType;
use marine_it_parser::interface::MRecordTypes;
use proc_macro2::TokenStream;
use quote::quote;
pub(super) fn generate_records(records: &FCERecordTypes) -> TResult<Vec<TokenStream>> {
pub(super) fn generate_records(records: &MRecordTypes) -> TResult<Vec<TokenStream>> {
use std::ops::Deref;
records.iter().map(|(_, record)| -> TResult<_> {
@ -45,7 +45,7 @@ pub(super) fn generate_records(records: &FCERecordTypes) -> TResult<Vec<TokenStr
fn prepare_field<'f>(
fields: impl ExactSizeIterator<Item = &'f IRecordFieldType>,
records: &FCERecordTypes,
records: &MRecordTypes,
) -> TResult<Vec<TokenStream>> {
fields
.map(|field| -> TResult<_> {

View File

@ -15,14 +15,14 @@
*/
use crate::TResult;
use fce_wit_parser::interface::FCERecordTypes;
use fce_wit_parser::interface::it::IType;
use marine_it_parser::interface::MRecordTypes;
use marine_it_parser::interface::it::IType;
use proc_macro2::TokenStream;
use quote::quote;
pub(super) fn generate_module_name(module_name: &str) -> TResult<syn::Ident> {
let extended_module_name = format!("__fce_generated_{}", module_name);
let extended_module_name = format!("__m_generated_{}", module_name);
new_ident(&extended_module_name)
}
@ -32,7 +32,7 @@ pub(super) fn generate_record_name(record_name: &str) -> TResult<syn::Ident> {
}
pub(super) fn generate_struct_name(struct_name: &str) -> TResult<syn::Ident> {
let extended_struct_name = format!("FCEGeneratedStruct{}", struct_name);
let extended_struct_name = format!("MGeneratedStruct{}", struct_name);
new_ident(&extended_struct_name)
}
@ -41,7 +41,7 @@ pub(super) fn new_ident(ident_str: &str) -> TResult<syn::Ident> {
syn::parse_str::<syn::Ident>(&ident_str).map_err(Into::into)
}
pub(super) fn itype_to_tokens(itype: &IType, records: &FCERecordTypes) -> TResult<TokenStream> {
pub(super) fn itype_to_tokens(itype: &IType, records: &MRecordTypes) -> TResult<TokenStream> {
let token_stream = match itype {
IType::Record(record_id) => {
let record = records

View File

@ -1,8 +1,8 @@
[package]
name = "fluence-sdk-test-macro"
name = "marine-test-macro"
version = "0.1.5" # remember to update html_root_url
edition = "2018"
description = "Definition of the `#[fce_test]` macro"
description = "Definition of the `#[marine_test]` macro"
repository = "https://github.com/fluencelabs/rust-sdk/crates/macro-test"
authors = ["Fluence Labs"]
keywords = ["fluence", "sdk", "webassembly", "procedural_macros"]
@ -17,7 +17,7 @@ proc-macro = true
doctest = false
[dependencies]
fluence-sdk-test-macro-impl = { path = "../fce-test-macro-impl", version = "0.1.5" }
marine-test-macro-impl = { path = "../marine-test-macro-impl", version = "0.1.5" }
quote = "1.0.9"
proc-macro2 = "1.0.24"

View File

@ -28,14 +28,14 @@
#![warn(rust_2018_idioms)]
#![recursion_limit = "1024"]
use fluence_sdk_test_macro_impl::fce_test_impl;
use marine_test_macro_impl::marine_test_impl;
use proc_macro::TokenStream;
use proc_macro_error::proc_macro_error;
use syn::spanned::Spanned;
/// This macro allows user to write tests for services in the following form:
///```rust
/// #[fce_test(config = "/path/to/Config.toml", modules_dir = "path/to/service/modules")]
/// #[marine_test(config = "/path/to/Config.toml", modules_dir = "path/to/service/modules")]
/// fn test() {
/// let service_result = greeting.greeting("John".to_string());
/// assert_eq!(&service_result, "Hi, name!");
@ -43,14 +43,14 @@ use syn::spanned::Spanned;
///```
#[proc_macro_error]
#[proc_macro_attribute]
pub fn fce_test(attrs: TokenStream, input: TokenStream) -> TokenStream {
pub fn marine_test(attrs: TokenStream, input: TokenStream) -> TokenStream {
let attrs: proc_macro2::TokenStream = attrs.into();
let attrs_span = attrs.span();
// here it obtains a path to the current file where macro is applied
let mut file_path = proc_macro::Span::call_site().source_file().path();
let _ = file_path.pop();
match fce_test_impl(attrs, input.into(), file_path) {
match marine_test_impl(attrs, input.into(), file_path) {
Ok(stream) => stream.into(),
Err(e) => proc_macro_error::abort!(attrs_span, format!("{}", e)),
}

View File

@ -1,6 +1,6 @@
[package]
name = "fce-timestamp-macro"
version = "0.6.1" # remember to update html_root_url
name = "marine-timestamp-macro"
version = "0.6.2" # remember to update html_root_url
edition = "2018"
description = "Definition of the `#[build_timestamp]` macro"
repository = "https://github.com/fluencelabs/rust-sdk/crates/timestamp-macro"

View File

@ -33,6 +33,6 @@ pub fn build_timestamp(_: TokenStream) -> TokenStream {
let current_utc_date = chrono::Utc::now();
let current_utc_date = current_utc_date.to_rfc3339();
let glue_code = quote::quote! { const __FCE_SDK_BUILD_TIME: &str = #current_utc_date; };
let glue_code = quote::quote! { const __M_SDK_BUILD_TIME: &str = #current_utc_date; };
glue_code.into()
}

View File

@ -19,7 +19,7 @@ path = "src/lib.rs"
doctest = false
[dependencies]
fluence-sdk-test-macro = { path = "../crates/fce-test-macro", version = "0.1.5" }
marine-test-macro = { path = "../crates/marine-test-macro", version = "0.1.5" }
fluence-app-service = { version = "0.7.0", features = ["raw-module-api"] }
serde = { version = "1.0.118", features = ["derive"] }

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
#![doc(html_root_url = "https://docs.rs/fluence-test/0.5.0")]
#![doc(html_root_url = "https://docs.rs/fluence-test/0.1.5")]
#![deny(
dead_code,
nonstandard_style,
@ -26,7 +26,7 @@
)]
#![warn(rust_2018_idioms)]
pub use fluence_sdk_test_macro::fce_test;
pub use marine_test_macro::marine_test;
pub use fluence_app_service::CallParameters;
pub use fluence_app_service::SecurityTetraplet;

View File

@ -1,6 +1,6 @@
[package]
name = "fluence"
version = "0.6.2" # remember to update html_root_url
version = "0.6.3" # remember to update html_root_url
description = "Fluence backend SDK for developing backend applications for the Fluence network"
documentation = "https://docs.rs/fluence/"
repository = "https://github.com/fluencelabs/rust-sdk"
@ -19,9 +19,9 @@ path = "src/lib.rs"
doctest = false
[dependencies]
fluence-sdk-macro = { path = "../crates/fce-macro", version = "=0.6.1" }
fluence-sdk-main = { path = "../crates/main", version = "=0.6.1" }
fce-timestamp-macro = { path = "../crates/timestamp-macro", version = "=0.6.1" }
marine-macro = { path = "../crates/marine-macro", version = "=0.6.2" }
fluence-sdk-main = { path = "../crates/main", version = "=0.6.2" }
marine-timestamp-macro = { path = "../crates/timestamp-macro", version = "=0.6.2" }
serde = { version = "1.0.118", features = ["derive"]}

View File

@ -14,13 +14,13 @@
* limitations under the License.
*/
use fluence_sdk_macro::fce;
use marine_macro::marine;
use serde::Serialize;
use serde::Deserialize;
/// Describes an origin that set an argument.
#[fce]
#[marine]
#[derive(Clone, PartialEq, Default, Eq, Debug, Serialize, Deserialize)]
pub struct SecurityTetraplet {
pub peer_pk: String,
@ -30,7 +30,7 @@ pub struct SecurityTetraplet {
}
/// This struct contains parameters that would be accessible by Wasm modules.
#[fce]
#[marine]
#[derive(Clone, PartialEq, Default, Eq, Debug, Serialize, Deserialize)]
pub struct CallParameters {
/// Peer id of the AIR script initiator.
@ -60,7 +60,7 @@ pub fn get_call_parameters() -> CallParameters {
unsafe {
get_call_raw_parameters();
let raw_call_parameters = crate::internal::get_result_ptr();
CallParameters::__fce_generated_deserialize(raw_call_parameters as _)
CallParameters::__m_generated_deserialize(raw_call_parameters as _)
}
}

View File

@ -15,28 +15,28 @@
*/
//! Rust backend SDK for applications on the Fluence network. This crate defines the procedure macro
//! `#[fce]` that could be applied to a function, structure or extern block.
//! `#[marine]` that could be applied to a function, structure or extern block.
//!
//! Structures with `#[fce]` (hereinafter they'll be called records) could be used then in function
//! Structures with `#[marine]` (hereinafter they'll be called records) could be used then in function
//! arguments and values. All fields of a record should be public and have one of the
//! following primitive Rust types
//! (`bool, u8, u16, u32, u64, i8, i16, i32, i64, f32, f64, String, Vec<u8>`).
//! ```rust
//! use fluence::fce;
//! use fluence::marine;
//!
//! #[fce]
//! #[marine]
//! struct T {
//! pub field_1: i32,
//! pub field_2: Vec<u8>,
//! }
//! ```
//!
//! Functions with `#[fce]` will be exported from this module:
//! Functions with `#[marine]` will be exported from this module:
//!
//! ```rust
//! use fluence::fce;
//! use fluence::marine;
//!
//! #[fce]
//! #[marine]
//! pub fn get(url: String) {
//! // ...
//! }
@ -46,9 +46,9 @@
//!
//! Finally, to import other wasm modules to your project use similar code:
//! ```rust
//! use fluence::fce;
//! use fluence::marine;
//!
//! #[fce]
//! #[marine]
//! #[link(wasm_import_module = "wasm_curl.wasm")]
//! extern "C" {
//! #[link_name = "get"]
@ -74,7 +74,8 @@ mod mounted_binary;
// fluence is used inside CallParameters and MountedBinaryResult glue code
extern crate self as fluence;
pub use fluence_sdk_macro::fce;
pub use marine_macro::marine;
pub use marine_macro::fce;
pub use call_parameters::CallParameters;
pub use call_parameters::SecurityTetraplet;
@ -99,5 +100,5 @@ pub mod internal {
pub use fluence_sdk_main::set_result_ptr;
pub use fluence_sdk_main::set_result_size;
pub use fluence_sdk_main::add_object_to_release;
pub use fce_timestamp_macro::build_timestamp;
pub use marine_timestamp_macro::build_timestamp;
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
use fluence_sdk_macro::fce;
use marine_macro::marine;
use serde::Serialize;
use serde::Deserialize;
@ -22,7 +22,7 @@ use serde::Deserialize;
pub const SUCCESS_CODE: i32 = 0;
/// Describes result of calling a CLI service.
#[fce]
#[marine]
#[derive(Clone, PartialEq, Default, Eq, Debug, Serialize, Deserialize)]
pub struct MountedBinaryResult {
/// Return process exit code or host execution error code, where SUCCESS_CODE means success.
@ -39,7 +39,7 @@ pub struct MountedBinaryResult {
}
/// The same as the MountedBinaryResult, but stdout and stderr are utf8 strings.
#[fce]
#[marine]
#[derive(Clone, PartialEq, Default, Eq, Debug, Serialize, Deserialize)]
pub struct MountedBinaryStringResult {
/// Return process exit code or host execution error code, where SUCCESS_CODE means success.

View File

@ -1,35 +1,35 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
pub fn main() {}
#[fce]
#[marine]
pub fn byte_type(_arg: Vec<u8>) -> Vec<u8> {
unimplemented!()
}
#[fce]
#[marine]
pub fn inner_arrays_1(_arg: Vec<&Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
unimplemented!()
}
#[fce]
#[marine]
pub fn inner_arrays_2(_arg: Vec<Vec<&Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
unimplemented!()
}
#[fce]
#[marine]
pub fn inner_arrays_3(_arg: Vec<Vec<Vec<&Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
unimplemented!()
}
#[fce]
#[marine]
pub fn inner_arrays_4(_arg: Vec<Vec<Vec<Vec<&u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
unimplemented!()
}
#[fce]
#[marine]
pub fn inner_arrays_5(_arg1: i32, _arg2: Vec<Vec<Vec<&Vec<u8>>>>, _arg3: i32) -> Vec<Vec<Vec<Vec<u8>>>> {
unimplemented!()
}

View File

@ -1,72 +1,72 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
pub fn main() {}
#[fce]
#[marine]
pub fn byte_type(_arg: Vec<u8>) -> Vec<u8> {
unimplemented!()
}
#[fce]
#[marine]
pub fn inner_arrays_1(_arg: Vec<Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
unimplemented!()
}
#[fce]
#[marine]
#[derive(Default)]
pub struct TestRecord {
pub field_0: i32,
pub field_1: Vec<Vec<u8>>,
}
#[fce]
#[marine]
pub fn inner_arrays_2(_arg: Vec<Vec<Vec<Vec<TestRecord>>>>) -> Vec<Vec<Vec<Vec<TestRecord>>>> {
unimplemented!()
}
#[fce]
#[marine]
pub fn string_type(_arg: Vec<String>) -> Vec<String> {
unimplemented!()
}
#[fce]
#[marine]
pub fn bool_type(_arg: Vec<bool>) -> Vec<bool> {
unimplemented!()
}
#[fce]
#[marine]
pub fn f32_type(_arg: Vec<f32>) -> Vec<f32> {
unimplemented!()
}
#[fce]
#[marine]
pub fn f64_type(_arg: Vec<f64>) -> Vec<f64> {
unimplemented!()
}
#[fce]
#[marine]
pub fn u32_type(_arg: Vec<u32>) -> Vec<u32> {
unimplemented!()
}
#[fce]
#[marine]
pub fn u64_type(_arg: Vec<u64>) -> Vec<u64> {
unimplemented!()
}
#[fce]
#[marine]
pub fn i32_type(_arg: Vec<i32>) -> Vec<i32> {
unimplemented!()
}
#[fce]
#[marine]
pub fn i64_type(_arg: Vec<i64>) -> Vec<i64> {
unimplemented!()
}
#[fce]
#[marine]
pub fn empty_type() -> Vec<String> {
unimplemented!()
}

View File

@ -1,10 +1,10 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
pub fn main() {}
#[fce]
#[marine]
pub fn all_types(
_arg_0: i8,
_arg_1: i16,
@ -22,57 +22,57 @@ pub fn all_types(
unimplemented!()
}
#[fce]
#[marine]
pub fn string_type(_arg: String) -> String {
unimplemented!()
}
#[fce]
#[marine]
pub fn str_type(_arg: &str) -> &str {
unimplemented!()
}
#[fce]
#[marine]
pub fn bytearray_type(_arg: Vec<u8>) -> Vec<u8> {
unimplemented!()
}
#[fce]
#[marine]
pub fn bool_type(_arg: bool) -> bool {
unimplemented!()
}
#[fce]
#[marine]
pub fn f32_type(_arg: f32) -> f32 {
unimplemented!()
}
#[fce]
#[marine]
pub fn f64_type(_arg: f64) -> f64 {
unimplemented!()
}
#[fce]
#[marine]
pub fn u32_type(_arg: u32) -> u32 {
unimplemented!()
}
#[fce]
#[marine]
pub fn u64_type(_arg: u64) -> u64 {
unimplemented!()
}
#[fce]
#[marine]
pub fn i32_type(_arg: i32) -> i32 {
unimplemented!()
}
#[fce]
#[marine]
pub fn i64_type(_arg: i64) -> i64 {
unimplemented!()
}
#[fce]
#[marine]
pub fn empty_type() -> String {
unimplemented!()
}

View File

@ -1,24 +1,24 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
pub fn main() {}
#[fce]
#[marine]
fn test(_arg_1: Box<i32>) {}
#[fce]
#[marine]
fn test2(_arg_1: std::rc::Rc<i32>) {}
#[fce]
#[marine]
fn test3(_arg_1: std::collections::HashMap<i32, String>) {}
#[fce]
#[marine]
fn test4(_arg_1: i32) -> (i32, i32) {
unimplemented!()
}
#[fce]
#[marine]
fn test5(_arg_1: i32) -> Box<i32> {
unimplemented!()
}

View File

@ -1,11 +1,15 @@
#![allow(improper_ctypes)]
#[fce]
use fluence::marine;
pub fn main() {}
#[marine]
pub fn inner_arrays_2(_arg: &Vec<Vec<Vec<Vec<u8>>>>) -> &Vec<Vec<&Vec<Vec<u8>>>> {
unimplemented!()
}
#[fce]
#[marine]
pub fn inner_arrays_3(_arg: &Vec<Vec<Vec<Vec<u8>>>>) -> &Vec<&Vec<&Vec<&Vec<&u8>>>> {
unimplemented!()
}

View File

@ -1,23 +1,11 @@
error: cannot find attribute `fce` in this scope
--> $DIR/inner_vec_refs.rs:8:3
error: a vector type in output types of export functions shouldn't contain references
--> $DIR/inner_vec_refs.rs:8:54
|
8 | #[fce]
| ^^^
8 | pub fn inner_arrays_2(_arg: &Vec<Vec<Vec<Vec<u8>>>>) -> &Vec<Vec<&Vec<Vec<u8>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: cannot find attribute `fce` in this scope
--> $DIR/inner_vec_refs.rs:3:3
|
3 | #[fce]
| ^^^
error[E0601]: `main` function not found in crate `$CRATE`
--> $DIR/inner_vec_refs.rs:1:1
error: a vector type in output types of export functions shouldn't contain references
--> $DIR/inner_vec_refs.rs:13:54
|
1 | / #![allow(improper_ctypes)]
2 | |
3 | | #[fce]
4 | | pub fn inner_arrays_2(_arg: &Vec<Vec<Vec<Vec<u8>>>>) -> &Vec<Vec<&Vec<Vec<u8>>>> {
... |
10 | | unimplemented!()
11 | | }
| |_^ consider adding a `main` function to `$DIR/tests/compilation_tests/export_functions/inner_vec_refs.rs`
13 | pub fn inner_arrays_3(_arg: &Vec<Vec<Vec<Vec<u8>>>>) -> &Vec<&Vec<&Vec<&Vec<&u8>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,72 +1,72 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
pub fn main() {}
#[fce]
#[marine]
pub fn byte_type(_arg: &Vec<u8>) -> &Vec<u8> {
unimplemented!()
}
#[fce]
#[marine]
pub fn inner_arrays_1(_arg: &Vec<Vec<Vec<Vec<u8>>>>) -> &Vec<Vec<Vec<Vec<u8>>>> {
unimplemented!()
}
#[fce]
#[marine]
#[derive(Default)]
pub struct TestRecord {
pub field_0: i32,
pub field_1: Vec<Vec<u8>>,
}
#[fce]
#[marine]
pub fn inner_arrays_4(_arg: &Vec<Vec<Vec<Vec<TestRecord>>>>) -> &Vec<Vec<Vec<Vec<TestRecord>>>> {
unimplemented!()
}
#[fce]
#[marine]
pub fn string_type(_arg: &Vec<String>) -> &Vec<String> {
unimplemented!()
}
#[fce]
#[marine]
pub fn bool_type(_arg: &Vec<bool>) -> &Vec<bool> {
unimplemented!()
}
#[fce]
#[marine]
pub fn f32_type(_arg: &Vec<f32>) -> &Vec<f32> {
unimplemented!()
}
#[fce]
#[marine]
pub fn f64_type(_arg: &Vec<f64>) -> &Vec<f64> {
unimplemented!()
}
#[fce]
#[marine]
pub fn u32_type(_arg: &Vec<u32>) -> &Vec<u32> {
unimplemented!()
}
#[fce]
#[marine]
pub fn u64_type(_arg: &Vec<u64>) -> &Vec<u64> {
unimplemented!()
}
#[fce]
#[marine]
pub fn i32_type(_arg: &Vec<i32>) -> &Vec<i32> {
unimplemented!()
}
#[fce]
#[marine]
pub fn i64_type(_arg: &Vec<i64>) -> &Vec<i64> {
unimplemented!()
}
#[fce]
#[marine]
pub fn empty_type() -> &'static Vec<String> {
unimplemented!()
}

View File

@ -1,10 +1,10 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
pub fn main() {}
#[fce]
#[marine]
pub fn all_types<'v>(
_arg_0: &i8,
_arg_1: &i16,
@ -22,52 +22,52 @@ pub fn all_types<'v>(
unimplemented!()
}
#[fce]
#[marine]
pub fn string_type(_arg: &String) -> &String {
unimplemented!()
}
#[fce]
#[marine]
pub fn bytearray_type(_arg: &Vec<u8>) -> &Vec<u8> {
unimplemented!()
}
#[fce]
#[marine]
pub fn bool_type(_arg: &bool) -> &bool {
unimplemented!()
}
#[fce]
#[marine]
pub fn f32_type(_arg: &f32) -> &f32 {
unimplemented!()
}
#[fce]
#[marine]
pub fn f64_type(_arg: &f64) -> &f64 {
unimplemented!()
}
#[fce]
#[marine]
pub fn u32_type(_arg: &u32) -> &u32 {
unimplemented!()
}
#[fce]
#[marine]
pub fn u64_type(_arg: &u64) -> &u64 {
unimplemented!()
}
#[fce]
#[marine]
pub fn i32_type(_arg: &i32) -> &i32 {
unimplemented!()
}
#[fce]
#[marine]
pub fn i64_type(_arg: &i64) -> &i64 {
unimplemented!()
}
#[fce]
#[marine]
pub fn empty_type() -> &'static String {
unimplemented!()
}

View File

@ -1,17 +1,17 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
pub fn main() {}
#[fce]
#[marine]
#[derive(Default)]
pub struct TestRecord {
pub field_0: i32,
pub field_1: Vec<Vec<u8>>,
}
#[fce]
#[marine]
#[link(wasm_import_module = "arrays_passing_effector")]
extern "C" {
pub fn inner_arrays_1(arg: Vec<Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>>;

View File

@ -1,27 +1,27 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
pub fn main() {}
#[fce]
#[marine]
#[link(wasm_import_module = "arrays_passing_effector")]
extern "C" {
#[fce]
#[marine]
pub fn func_1() -> &String;
#[fce]
#[marine]
pub fn func_2() -> &Vec<Vec<Vec<Vec<u8>>>>;
#[fce]
#[marine]
pub fn func_3() -> Vec<&Vec<Vec<Vec<u8>>>>;
#[fce]
#[marine]
pub fn func_4() -> Vec<Vec<&Vec<Vec<u8>>>>;
#[fce]
#[marine]
pub fn func_5() -> Vec<Vec<Vec<&Vec<u8>>>>;
#[fce]
#[marine]
pub fn func_6() -> Vec<Vec<Vec<Vec<&u8>>>>;
}

View File

@ -1,6 +1,6 @@
error: import function can't return a value with references
--> $DIR/arrays_out_inner_refs.rs:10:5
|
10 | / #[fce]
10 | / #[marine]
11 | | pub fn func_1() -> &String;
| |_______________________________^

View File

@ -1,10 +1,10 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
fn main() {}
#[fce]
#[marine]
#[link(wasm_import_module = "arguments_passing_effector")]
extern "C" {
pub fn all_ref_types(

View File

@ -1,10 +1,10 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
fn main() {}
#[fce]
#[marine]
#[link(wasm_import_module = "arguments_passing_effector")]
extern "C" {
pub fn all_types(

View File

@ -1,24 +1,24 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
pub fn main() {}
#[fce]
#[marine]
#[link(wasm_import_module = "arguments_passing_effector")]
extern "C" {
#[fce]
#[marine]
fn test(_arg_1: Box<i32>);
#[fce]
#[marine]
fn test2(_arg_1: std::rc::Rc<i32>);
#[fce]
#[marine]
fn test3(_arg_1: std::collections::HashMap<i32, String>);
#[fce]
#[marine]
fn test4(_arg_1: i32) -> (i32, i32);
#[fce]
#[marine]
fn test5(_arg_1: i32) -> Box<i32>;
}

View File

@ -1,17 +1,17 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
pub fn main() {}
#[fce]
#[marine]
#[derive(Default)]
pub struct TestRecord {
pub field_0: i32,
pub field_1: Vec<Vec<u8>>,
}
#[fce]
#[marine]
#[link(wasm_import_module = "arrays_passing_effector")]
extern "C" {
pub fn inner_arrays_1(arg: &Vec<Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>>;

View File

@ -1,10 +1,10 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
fn main() {}
#[fce]
#[marine]
#[link(wasm_import_module = "arguments_passing_effector")]
extern "C" {
pub fn all_types(

View File

@ -1,8 +1,8 @@
use fluence::fce;
use fluence::marine;
fn main() {}
#[fce]
#[marine]
pub struct TestRecord {
pub field_0: bool,
pub field_1: i8,
@ -19,7 +19,7 @@ pub struct TestRecord {
pub field_12: Vec<u8>,
}
#[fce]
#[marine]
pub struct Tx {
pub block_hash: String,
pub block_number: String,
@ -34,7 +34,7 @@ pub struct Tx {
pub value: String,
}
#[fce]
#[marine]
#[derive(Debug)]
pub struct JsonRpcResult {
pub json_rpc: String,
@ -43,7 +43,7 @@ pub struct JsonRpcResult {
pub id: u64,
}
#[fce]
#[marine]
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
pub struct User {
pub peer_id: String,
@ -52,27 +52,27 @@ pub struct User {
pub name: String,
}
#[fce]
#[marine]
pub struct GetUsersServiceResult {
pub ret_code: i32,
pub err_msg: String,
pub users: Vec<User>,
}
#[fce]
#[marine]
pub struct EmptyServiceResult {
pub ret_code: i32,
pub err_msg: String,
}
#[fce]
#[marine]
pub struct ExistsServiceResult {
pub ret_code: i32,
pub err_msg: String,
pub is_exists: bool,
}
#[fce]
#[marine]
pub struct AuthResult {
pub ret_code: i32,
pub err_msg: String,

View File

@ -1,6 +1,6 @@
use fluence::fce;
use fluence::marine;
fn main() {}
#[fce]
#[marine]
struct A {}

View File

@ -1,18 +1,18 @@
use fluence::fce;
use fluence::marine;
fn main() {}
#[fce]
#[marine]
struct StructWithBox {
pub a: Box<i32>,
}
#[fce]
#[marine]
struct StructWithRc {
pub a: std::rc::Rc<i32>,
}
#[fce]
#[marine]
struct StructWithHashMap {
pub a: std::collections::HashMap<i32, String>,
}

View File

@ -1,10 +1,10 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
fn main() {}
#[fce]
#[marine]
struct StructWithPrivateFields {
a: i32,
b: usize,

View File

@ -1,4 +1,4 @@
error: #[fce] could be applied only to struct with all public fields
error: #[marine] could be applied only to struct with all public fields
--> $DIR/struct_with_private_fields.rs:9:5
|
9 | a: i32,

View File

@ -1,8 +1,8 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::marine;
fn main() {}
#[fce]
#[marine]
struct A(pub i32, pub u32);

View File

@ -1,5 +1,5 @@
#[test]
fn fce_compilation_tests() {
fn marine_compilation_tests() {
let tests = trybuild::TestCases::new();
tests.compile_fail("tests/compilation_tests/export_functions/array_inner_refs.rs");
tests.pass("tests/compilation_tests/export_functions/arrays.rs");