mirror of
https://github.com/fluencelabs/marine-rs-sdk
synced 2025-03-15 14:30:48 +00:00
renaming
This commit is contained in:
parent
17115b696a
commit
ba7af66ca8
@ -66,7 +66,7 @@ macro_rules! debug_log {
|
|||||||
let level = log::Level::Info as i32;
|
let level = log::Level::Info as i32;
|
||||||
let target = 0i32;
|
let target = 0i32;
|
||||||
let msg = $msg_generator;
|
let msg = $msg_generator;
|
||||||
logger::log_utf8_string(level, target, msg.as_ptr() as i32, msg.len() as i32);
|
crate::logger::log_utf8_string(level, target, msg.as_ptr() as i32, msg.len() as i32);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ pub(crate) struct AstFnSignature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct AstRecordItem {
|
pub(crate) struct AstRecord {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub fields: AstRecordFields,
|
pub fields: AstRecordFields,
|
||||||
pub original: syn::ItemStruct,
|
pub original: syn::ItemStruct,
|
||||||
@ -60,29 +60,29 @@ pub(crate) struct AstRecordField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct AstExternFnItem {
|
pub(crate) struct AstExternFn {
|
||||||
pub link_name: Option<String>,
|
pub link_name: Option<String>,
|
||||||
// only imports are possible here
|
// only imports are possible here
|
||||||
pub signature: AstFnSignature,
|
pub signature: AstFnSignature,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct AstExternModItem {
|
pub(crate) struct AstExternMod {
|
||||||
pub namespace: String,
|
pub namespace: String,
|
||||||
// only imports are possible here
|
// only imports are possible here
|
||||||
pub imports: Vec<AstExternFnItem>,
|
pub imports: Vec<AstExternFn>,
|
||||||
pub original: syn::ItemForeignMod,
|
pub original: syn::ItemForeignMod,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct AstFnItem {
|
pub(crate) struct AstFn {
|
||||||
pub signature: AstFnSignature,
|
pub signature: AstFnSignature,
|
||||||
pub original: syn::ItemFn,
|
pub original: syn::ItemFn,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) enum FCEAst {
|
pub(crate) enum FCEAst {
|
||||||
Function(AstFnItem),
|
Function(AstFn),
|
||||||
ExternMod(AstExternModItem),
|
ExternMod(AstExternMod),
|
||||||
Record(AstRecordItem),
|
Record(AstRecord),
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ pub struct FnSignature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize)]
|
||||||
pub struct RecordItem {
|
pub struct RecordType {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub fields: RecordFields,
|
pub fields: RecordFields,
|
||||||
}
|
}
|
||||||
@ -55,68 +55,68 @@ pub struct RecordField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize)]
|
||||||
pub struct ExternFnItem {
|
pub struct ExternFnType {
|
||||||
pub link_name: Option<String>,
|
pub link_name: Option<String>,
|
||||||
// only imports are possible here
|
// only imports are possible here
|
||||||
pub signature: FnSignature,
|
pub signature: FnSignature,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize)]
|
||||||
pub struct ExternModItem {
|
pub struct ExternModType {
|
||||||
pub namespace: String,
|
pub namespace: String,
|
||||||
// only imports are possible here
|
// only imports are possible here
|
||||||
pub imports: Vec<ExternFnItem>,
|
pub imports: Vec<ExternFnType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize)]
|
||||||
pub struct FnItem {
|
pub struct FnType {
|
||||||
pub signature: FnSignature,
|
pub signature: FnSignature,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_type")]
|
#[serde(tag = "ast_type")]
|
||||||
pub enum SDKAst {
|
pub enum SDKAst {
|
||||||
Function(FnItem),
|
Function(FnType),
|
||||||
ExternMod(ExternModItem),
|
ExternMod(ExternModType),
|
||||||
Record(RecordItem),
|
Record(RecordType),
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::ast_types::{
|
use crate::ast_types::{
|
||||||
AstFnItem, AstFnSignature, AstFnArgument, AstExternModItem, AstExternFnItem, AstRecordField,
|
AstFn, AstFnSignature, AstFnArgument, AstExternMod, AstExternFn, AstRecordField, AstRecord,
|
||||||
AstRecordItem, AstRecordFields,
|
AstRecordFields,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl From<AstFnItem> for SDKAst {
|
impl From<AstFn> for SDKAst {
|
||||||
fn from(ast_fn_item: AstFnItem) -> Self {
|
fn from(ast_fn_item: AstFn) -> Self {
|
||||||
let fn_item = ast_fn_item.into();
|
let fn_item = ast_fn_item.into();
|
||||||
Self::Function(fn_item)
|
Self::Function(fn_item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AstExternModItem> for SDKAst {
|
impl From<AstExternMod> for SDKAst {
|
||||||
fn from(ast_extern_mod: AstExternModItem) -> Self {
|
fn from(ast_extern_mod: AstExternMod) -> Self {
|
||||||
let extern_mod = ast_extern_mod.into();
|
let extern_mod = ast_extern_mod.into();
|
||||||
Self::ExternMod(extern_mod)
|
Self::ExternMod(extern_mod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AstRecordItem> for SDKAst {
|
impl From<AstRecord> for SDKAst {
|
||||||
fn from(ast_record_item: AstRecordItem) -> Self {
|
fn from(ast_record_item: AstRecord) -> Self {
|
||||||
let record_item = ast_record_item.into();
|
let record_item = ast_record_item.into();
|
||||||
Self::Record(record_item)
|
Self::Record(record_item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AstFnItem> for FnItem {
|
impl From<AstFn> for FnType {
|
||||||
fn from(ast_fn_item: AstFnItem) -> Self {
|
fn from(ast_fn_item: AstFn) -> Self {
|
||||||
let signature = ast_fn_item.signature.into();
|
let signature = ast_fn_item.signature.into();
|
||||||
|
|
||||||
Self { signature }
|
Self { signature }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AstExternModItem> for ExternModItem {
|
impl From<AstExternMod> for ExternModType {
|
||||||
fn from(ast_extern_mod: AstExternModItem) -> Self {
|
fn from(ast_extern_mod: AstExternMod) -> Self {
|
||||||
let imports = ast_extern_mod.imports.into_iter().map(Into::into).collect();
|
let imports = ast_extern_mod.imports.into_iter().map(Into::into).collect();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@ -126,8 +126,8 @@ impl From<AstExternModItem> for ExternModItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AstRecordItem> for RecordItem {
|
impl From<AstRecord> for RecordType {
|
||||||
fn from(ast_record_item: AstRecordItem) -> Self {
|
fn from(ast_record_item: AstRecord) -> Self {
|
||||||
Self {
|
Self {
|
||||||
name: ast_record_item.name,
|
name: ast_record_item.name,
|
||||||
fields: ast_record_item.fields.into(),
|
fields: ast_record_item.fields.into(),
|
||||||
@ -177,8 +177,8 @@ impl From<AstFnArgument> for FnArgument {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AstExternFnItem> for ExternFnItem {
|
impl From<AstExternFn> for ExternFnType {
|
||||||
fn from(ast_extern_item: AstExternFnItem) -> Self {
|
fn from(ast_extern_item: AstExternFn) -> Self {
|
||||||
Self {
|
Self {
|
||||||
link_name: ast_extern_item.link_name,
|
link_name: ast_extern_item.link_name,
|
||||||
signature: ast_extern_item.signature.into(),
|
signature: ast_extern_item.signature.into(),
|
||||||
|
@ -18,7 +18,7 @@ use super::ParseMacroInput;
|
|||||||
use crate::ast_types;
|
use crate::ast_types;
|
||||||
use crate::ParsedType;
|
use crate::ParsedType;
|
||||||
use crate::ast_types::FCEAst;
|
use crate::ast_types::FCEAst;
|
||||||
use crate::ast_types::AstFnItem;
|
use crate::ast_types::AstFn;
|
||||||
use crate::ast_types::AstFnArgument;
|
use crate::ast_types::AstFnArgument;
|
||||||
use crate::syn_error;
|
use crate::syn_error;
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ impl ParseMacroInput for syn::ItemFn {
|
|||||||
check_args(parsed_args)?;
|
check_args(parsed_args)?;
|
||||||
check_output_type(&signature.output_type, self.sig.output.span())?;
|
check_output_type(&signature.output_type, self.sig.output.span())?;
|
||||||
|
|
||||||
let ast_fn = FCEAst::Function(AstFnItem {
|
let ast_fn = FCEAst::Function(AstFn {
|
||||||
signature,
|
signature,
|
||||||
original: self,
|
original: self,
|
||||||
});
|
});
|
||||||
|
@ -36,7 +36,7 @@ impl ParseMacroInput for syn::ItemForeignMod {
|
|||||||
let imports = extract_import_functions(&self)?;
|
let imports = extract_import_functions(&self)?;
|
||||||
check_imports(imports.iter().zip(self.items.iter().map(|i| i.span())))?;
|
check_imports(imports.iter().zip(self.items.iter().map(|i| i.span())))?;
|
||||||
|
|
||||||
let extern_mod_item = ast_types::AstExternModItem {
|
let extern_mod_item = ast_types::AstExternMod {
|
||||||
namespace,
|
namespace,
|
||||||
imports,
|
imports,
|
||||||
original: self,
|
original: self,
|
||||||
@ -99,7 +99,7 @@ fn try_extract_namespace(
|
|||||||
|
|
||||||
fn extract_import_functions(
|
fn extract_import_functions(
|
||||||
foreign_mod: &syn::ItemForeignMod,
|
foreign_mod: &syn::ItemForeignMod,
|
||||||
) -> Result<Vec<ast_types::AstExternFnItem>> {
|
) -> Result<Vec<ast_types::AstExternFn>> {
|
||||||
foreign_mod
|
foreign_mod
|
||||||
.items
|
.items
|
||||||
.iter()
|
.iter()
|
||||||
@ -111,7 +111,7 @@ fn extract_import_functions(
|
|||||||
/// This function checks whether these imports contains inner references. In this case glue
|
/// This function checks whether these imports contains inner references. In this case glue
|
||||||
/// code couldn't be generated.
|
/// code couldn't be generated.
|
||||||
fn check_imports<'i>(
|
fn check_imports<'i>(
|
||||||
extern_fns: impl ExactSizeIterator<Item = (&'i ast_types::AstExternFnItem, proc_macro2::Span)>,
|
extern_fns: impl ExactSizeIterator<Item = (&'i ast_types::AstExternFn, proc_macro2::Span)>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
use super::utils::contain_inner_ref;
|
use super::utils::contain_inner_ref;
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ fn check_imports<'i>(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_raw_foreign_item(raw_item: syn::ForeignItem) -> Result<ast_types::AstExternFnItem> {
|
fn parse_raw_foreign_item(raw_item: syn::ForeignItem) -> Result<ast_types::AstExternFn> {
|
||||||
let function_item = match raw_item {
|
let function_item = match raw_item {
|
||||||
syn::ForeignItem::Fn(function_item) => function_item,
|
syn::ForeignItem::Fn(function_item) => function_item,
|
||||||
_ => {
|
_ => {
|
||||||
@ -158,7 +158,7 @@ fn parse_raw_foreign_item(raw_item: syn::ForeignItem) -> Result<ast_types::AstEx
|
|||||||
};
|
};
|
||||||
|
|
||||||
let signature = super::item_fn::try_to_ast_signature(function_item.sig, function_item.vis)?;
|
let signature = super::item_fn::try_to_ast_signature(function_item.sig, function_item.vis)?;
|
||||||
let ast_extern_fn_item = ast_types::AstExternFnItem {
|
let ast_extern_fn_item = ast_types::AstExternFn {
|
||||||
link_name,
|
link_name,
|
||||||
signature,
|
signature,
|
||||||
};
|
};
|
||||||
|
@ -38,7 +38,7 @@ impl ParseMacroInput for syn::ItemStruct {
|
|||||||
let fields = AstRecordFields::Named(fields);
|
let fields = AstRecordFields::Named(fields);
|
||||||
|
|
||||||
let name = self.ident.to_string();
|
let name = self.ident.to_string();
|
||||||
let ast_record_item = ast_types::AstRecordItem {
|
let ast_record_item = ast_types::AstRecord {
|
||||||
name,
|
name,
|
||||||
fields,
|
fields,
|
||||||
original: self,
|
original: self,
|
||||||
|
@ -25,7 +25,7 @@ use crate::new_ident;
|
|||||||
|
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
|
|
||||||
impl quote::ToTokens for ast_types::AstFnItem {
|
impl quote::ToTokens for ast_types::AstFn {
|
||||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||||
crate::prepare_global_data!(
|
crate::prepare_global_data!(
|
||||||
Function,
|
Function,
|
||||||
|
@ -21,7 +21,7 @@ use crate::parsed_type::*;
|
|||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
|
|
||||||
impl quote::ToTokens for ast_types::AstExternModItem {
|
impl quote::ToTokens for ast_types::AstExternMod {
|
||||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||||
crate::prepare_global_data!(
|
crate::prepare_global_data!(
|
||||||
ExternMod,
|
ExternMod,
|
||||||
@ -61,7 +61,7 @@ impl quote::ToTokens for ast_types::AstExternModItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_extern_section_items(extern_item: &ast_types::AstExternModItem) -> Vec<TokenStream> {
|
fn generate_extern_section_items(extern_item: &ast_types::AstExternMod) -> Vec<TokenStream> {
|
||||||
let mut section_items = Vec::with_capacity(extern_item.imports.len());
|
let mut section_items = Vec::with_capacity(extern_item.imports.len());
|
||||||
|
|
||||||
for import in &extern_item.imports {
|
for import in &extern_item.imports {
|
||||||
@ -90,7 +90,7 @@ fn generate_import_name(import_name: &str) -> syn::Ident {
|
|||||||
crate::new_ident!(format!("{}_{}", super::GENERATED_WRAPPER_FUNC_PREFIX, import_name))
|
crate::new_ident!(format!("{}_{}", super::GENERATED_WRAPPER_FUNC_PREFIX, import_name))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_wrapper_functions(extern_item: &ast_types::AstExternModItem) -> TokenStream {
|
fn generate_wrapper_functions(extern_item: &ast_types::AstExternMod) -> TokenStream {
|
||||||
let mut token_stream = TokenStream::new();
|
let mut token_stream = TokenStream::new();
|
||||||
|
|
||||||
for import in &extern_item.imports {
|
for import in &extern_item.imports {
|
||||||
|
@ -23,10 +23,10 @@ use record_deserializer::*;
|
|||||||
use record_serializer::*;
|
use record_serializer::*;
|
||||||
|
|
||||||
use crate::new_ident;
|
use crate::new_ident;
|
||||||
use crate::ast_types::AstRecordItem;
|
use crate::ast_types::AstRecord;
|
||||||
use crate::ast_types::AstRecordFields;
|
use crate::ast_types::AstRecordFields;
|
||||||
|
|
||||||
impl quote::ToTokens for AstRecordItem {
|
impl quote::ToTokens for AstRecord {
|
||||||
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
|
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
|
||||||
let original = &self.original;
|
let original = &self.original;
|
||||||
crate::prepare_global_data!(
|
crate::prepare_global_data!(
|
||||||
@ -68,7 +68,7 @@ impl quote::ToTokens for AstRecordItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_serializer_fn(record: &AstRecordItem) -> proc_macro2::TokenStream {
|
fn generate_serializer_fn(record: &AstRecord) -> proc_macro2::TokenStream {
|
||||||
let serializer = record.generate_serializer();
|
let serializer = record.generate_serializer();
|
||||||
let fields_count = match &record.fields {
|
let fields_count = match &record.fields {
|
||||||
AstRecordFields::Named(fields) => fields.len(),
|
AstRecordFields::Named(fields) => fields.len(),
|
||||||
@ -91,7 +91,7 @@ fn generate_serializer_fn(record: &AstRecordItem) -> proc_macro2::TokenStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_deserializer_fn(record: &AstRecordItem) -> proc_macro2::TokenStream {
|
fn generate_deserializer_fn(record: &AstRecord) -> proc_macro2::TokenStream {
|
||||||
let RecordDerDescriptor {
|
let RecordDerDescriptor {
|
||||||
fields_der,
|
fields_der,
|
||||||
record_ctor,
|
record_ctor,
|
||||||
|
@ -32,7 +32,7 @@ pub(super) trait RecordDerGlueCodeGenerator {
|
|||||||
fn generate_der(&self) -> RecordDerDescriptor;
|
fn generate_der(&self) -> RecordDerDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RecordDerGlueCodeGenerator for AstRecordItem {
|
impl RecordDerGlueCodeGenerator for AstRecord {
|
||||||
fn generate_der(&self) -> RecordDerDescriptor {
|
fn generate_der(&self) -> RecordDerDescriptor {
|
||||||
match &self.fields {
|
match &self.fields {
|
||||||
AstRecordFields::Named(fields) => record_der_from_named(fields),
|
AstRecordFields::Named(fields) => record_der_from_named(fields),
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
use crate::new_ident;
|
use crate::new_ident;
|
||||||
use crate::parsed_type::ParsedType;
|
use crate::parsed_type::ParsedType;
|
||||||
use crate::ast_types::AstRecordItem;
|
use crate::ast_types::AstRecord;
|
||||||
use crate::ast_types::AstRecordField;
|
use crate::ast_types::AstRecordField;
|
||||||
use crate::ast_types::AstRecordFields;
|
use crate::ast_types::AstRecordFields;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ pub(super) trait RecordSerGlueCodeGenerator {
|
|||||||
fn generate_serializer(&self) -> proc_macro2::TokenStream;
|
fn generate_serializer(&self) -> proc_macro2::TokenStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RecordSerGlueCodeGenerator for AstRecordItem {
|
impl RecordSerGlueCodeGenerator for AstRecord {
|
||||||
fn generate_serializer(&self) -> proc_macro2::TokenStream {
|
fn generate_serializer(&self) -> proc_macro2::TokenStream {
|
||||||
let mut serializer = proc_macro2::TokenStream::new();
|
let mut serializer = proc_macro2::TokenStream::new();
|
||||||
let fields = match &self.fields {
|
let fields = match &self.fields {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user