introduce internal mod to improve sdk API

This commit is contained in:
vms 2020-07-10 10:52:24 +03:00
parent d33872aa5e
commit 5dc680c046
5 changed files with 22 additions and 16 deletions

View File

@ -97,8 +97,8 @@ fn generate_epilog(ty: &Option<ParsedType>) -> proc_macro2::TokenStream {
return result as _;
},
Some(ty) if ty.is_integral_type() => quote! {
fluence::set_result_ptr(result.as_ptr() as _);
fluence::set_result_size(result.len() as _);
fluence::internal::set_result_ptr(result.as_ptr() as _);
fluence::internal::set_result_size(result.len() as _);
std::mem::forget(result);
},
_ => {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2018 Fluence Labs Limited
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2018 Fluence Labs Limited
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,16 +46,16 @@ impl ForeignModEpilogGlueCodeGenerator for Option<ParsedType> {
},
Some(ParsedType::Utf8String) => quote! {
String::from_raw_parts(
fluence::get_result_ptr() as _,
fluence::get_result_size() as _,
fluence::get_result_size() as _
fluence::internal::get_result_ptr() as _,
fluence::internal::get_result_size() as _,
fluence::internal::get_result_size() as _
)
},
Some(ParsedType::ByteVector) => quote! {
Vec::from_raw_parts(
fluence::get_result_ptr() as _,
fluence::get_result_size() as _,
fluence::get_result_size() as _
fluence::internal::get_result_ptr() as _,
fluence::internal::get_result_size() as _,
fluence::internal::get_result_size() as _
)
},
Some(ParsedType::Record(_)) => unimplemented!(),

View File

@ -1,5 +1,5 @@
/*
* Copyright 2018 Fluence Labs Limited
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2018 Fluence Labs Limited
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -35,7 +35,13 @@ extern crate fluence_sdk_macro;
extern crate fluence_sdk_main;
pub use fluence_sdk_macro::fce;
pub use fluence_sdk_main::get_result_ptr;
pub use fluence_sdk_main::get_result_size;
pub use fluence_sdk_main::set_result_ptr;
pub use fluence_sdk_main::set_result_size;
pub use fluence_sdk_main::WasmLogger;
/// These API functions are intended for internal usage in generated code.
/// Normally, you shouldn't use them.
pub mod internal {
pub use fluence_sdk_main::get_result_ptr;
pub use fluence_sdk_main::get_result_size;
pub use fluence_sdk_main::set_result_ptr;
pub use fluence_sdk_main::set_result_size;
}