Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support #[frb(proxy)] (part 1) #2050

Merged
merged 143 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
d5c9da0
chore: ir
fzyzcjy Jun 8, 2024
4f48334
feat: more
fzyzcjy Jun 8, 2024
2c27fcf
feat: more
fzyzcjy Jun 8, 2024
ec40297
feat: mark
fzyzcjy Jun 8, 2024
83e81e4
chore: more mark
fzyzcjy Jun 8, 2024
e4dad37
feat: attr
fzyzcjy Jun 8, 2024
e8c4a61
feat: demo
fzyzcjy Jun 8, 2024
dfb492e
chore: codegen
fzyzcjy Jun 8, 2024
0ff0b3a
chore: args
fzyzcjy Jun 8, 2024
48001ca
chore: temp log
fzyzcjy Jun 8, 2024
bf3951c
chore: temp rm
fzyzcjy Jun 8, 2024
c388981
chore: rm
fzyzcjy Jun 8, 2024
4f27024
chore: empty
fzyzcjy Jun 8, 2024
9a0cc40
feat: more
fzyzcjy Jun 8, 2024
4c6ee89
feat: more
fzyzcjy Jun 8, 2024
f2e9a4d
fix: err
fzyzcjy Jun 8, 2024
e6c0f78
chore: codegen
fzyzcjy Jun 8, 2024
8348247
feat: ir
fzyzcjy Jun 8, 2024
c7e7f82
feat: more
fzyzcjy Jun 8, 2024
30b2dd1
refactor: extract
fzyzcjy Jun 8, 2024
4b9c891
feat: parse
fzyzcjy Jun 8, 2024
5d0a3b9
chore: codegen
fzyzcjy Jun 8, 2024
1aaf5a3
feat: more
fzyzcjy Jun 8, 2024
b801232
feat: more
fzyzcjy Jun 8, 2024
be8dfda
feat: more
fzyzcjy Jun 8, 2024
5d3fefa
feat: more
fzyzcjy Jun 8, 2024
b89297b
feat: parser
fzyzcjy Jun 8, 2024
8eb73ce
fix: err
fzyzcjy Jun 8, 2024
ef33d60
chore: empty
fzyzcjy Jun 8, 2024
07870ef
feat: more
fzyzcjy Jun 8, 2024
aef690f
feat: more
fzyzcjy Jun 8, 2024
055a181
feat: ir
fzyzcjy Jun 8, 2024
7def4f1
faet: more
fzyzcjy Jun 8, 2024
dc6de21
chore: pass
fzyzcjy Jun 8, 2024
624930f
feat: more
fzyzcjy Jun 8, 2024
1fff42c
chore: codegen
fzyzcjy Jun 8, 2024
3853f11
fix: err
fzyzcjy Jun 8, 2024
255dcf8
chore: empty
fzyzcjy Jun 8, 2024
40d1bbb
feat: more
fzyzcjy Jun 8, 2024
af50477
chore: more
fzyzcjy Jun 8, 2024
627ccfd
feat: more
fzyzcjy Jun 8, 2024
01c8d65
feat: more
fzyzcjy Jun 8, 2024
39d7487
feat: more
fzyzcjy Jun 8, 2024
8a31c46
refactor: rename
fzyzcjy Jun 8, 2024
e9066ae
feat: more
fzyzcjy Jun 8, 2024
6af02aa
feat: more
fzyzcjy Jun 8, 2024
58133a4
feat: more
fzyzcjy Jun 8, 2024
f2e90e6
feat: more
fzyzcjy Jun 8, 2024
95450ff
fix: rename back
fzyzcjy Jun 8, 2024
30f4330
fix: err
fzyzcjy Jun 8, 2024
943b93d
fix: err
fzyzcjy Jun 8, 2024
151e0a1
chore: codegen
fzyzcjy Jun 8, 2024
3ebf0a2
fix: err
fzyzcjy Jun 8, 2024
9f1dbbf
feat: more
fzyzcjy Jun 8, 2024
1f621bb
feat: func
fzyzcjy Jun 8, 2024
b846b2e
chore: codegen
fzyzcjy Jun 8, 2024
c9ec927
feat: more
fzyzcjy Jun 8, 2024
79277d5
feat: more
fzyzcjy Jun 8, 2024
f3c7827
fix: err
fzyzcjy Jun 8, 2024
a0af78d
feat: log
fzyzcjy Jun 8, 2024
33f3106
chore: more
fzyzcjy Jun 8, 2024
02a2932
chore: lint
fzyzcjy Jun 8, 2024
1c78384
feat: ir
fzyzcjy Jun 8, 2024
a1de18a
refactor: ty
fzyzcjy Jun 8, 2024
cbf97e8
fix: err
fzyzcjy Jun 8, 2024
afb8e47
feat: more
fzyzcjy Jun 8, 2024
dabfadd
feat: empty
fzyzcjy Jun 8, 2024
ba4dfe9
feat: more
fzyzcjy Jun 8, 2024
b6c27e9
chore: more
fzyzcjy Jun 8, 2024
656af81
chore: dump
fzyzcjy Jun 8, 2024
1ded237
feat: more
fzyzcjy Jun 8, 2024
049689d
chore: codegen
fzyzcjy Jun 8, 2024
9257917
feat: more
fzyzcjy Jun 8, 2024
e4fe15b
feat: more
fzyzcjy Jun 8, 2024
155586a
feat: more
fzyzcjy Jun 8, 2024
4cfb8c6
feat: more
fzyzcjy Jun 8, 2024
ba9bb5d
feat: more
fzyzcjy Jun 8, 2024
baf2c65
fix: err
fzyzcjy Jun 8, 2024
7034a30
chore: temp disable
fzyzcjy Jun 8, 2024
d3d5f70
feat: more
fzyzcjy Jun 8, 2024
6ff2f85
chore: rename
fzyzcjy Jun 8, 2024
3202823
feat: more
fzyzcjy Jun 8, 2024
c42b63b
feat: more
fzyzcjy Jun 8, 2024
557879c
chore: more demo
fzyzcjy Jun 8, 2024
f896449
chore: codegen
fzyzcjy Jun 8, 2024
7c10934
feat: impl
fzyzcjy Jun 8, 2024
f287016
feat: more
fzyzcjy Jun 8, 2024
15ee0f6
chore: codegen
fzyzcjy Jun 8, 2024
3dd9192
faet: future
fzyzcjy Jun 8, 2024
92c7a17
feat: more
fzyzcjy Jun 8, 2024
73024f0
feat: more
fzyzcjy Jun 8, 2024
06f43a8
feat: more
fzyzcjy Jun 8, 2024
3554a2c
fix: err
fzyzcjy Jun 8, 2024
ba6c753
chore: codegen
fzyzcjy Jun 8, 2024
efe294e
feat: more
fzyzcjy Jun 8, 2024
3a5c451
chore: codegen
fzyzcjy Jun 8, 2024
aa5b370
refactor: minor
fzyzcjy Jun 8, 2024
4c04d87
feat: field
fzyzcjy Jun 8, 2024
ad190ea
refactor: extract
fzyzcjy Jun 8, 2024
cdef8bc
feat: more
fzyzcjy Jun 8, 2024
16aaef7
fix: err
fzyzcjy Jun 8, 2024
93a254a
chore: simp
fzyzcjy Jun 8, 2024
e767ed4
refactor: rm
fzyzcjy Jun 8, 2024
f60ca47
feat: more
fzyzcjy Jun 8, 2024
8ac50d7
chore: newline
fzyzcjy Jun 8, 2024
9c49571
chore: codegen
fzyzcjy Jun 8, 2024
2d8e030
chore: minor
fzyzcjy Jun 8, 2024
558ba6f
feat: unreach
fzyzcjy Jun 8, 2024
332230a
chore: codegen
fzyzcjy Jun 8, 2024
5d5ec6e
feat: more
fzyzcjy Jun 8, 2024
815f369
feat: more
fzyzcjy Jun 8, 2024
47379f1
chore: codegen
fzyzcjy Jun 8, 2024
8f6c9f4
feat: more
fzyzcjy Jun 8, 2024
ceee65f
feat: more
fzyzcjy Jun 8, 2024
c5b35c4
feat: more
fzyzcjy Jun 8, 2024
0d36b91
feat: more
fzyzcjy Jun 8, 2024
0e5eec5
feat: more
fzyzcjy Jun 8, 2024
9789ec2
feat: more
fzyzcjy Jun 8, 2024
e1fa4b4
feat: more
fzyzcjy Jun 8, 2024
90f7fa1
feat: more
fzyzcjy Jun 8, 2024
a3c5dae
feat: more
fzyzcjy Jun 8, 2024
a6d9bce
feat: more
fzyzcjy Jun 8, 2024
34b2d35
feat: ty
fzyzcjy Jun 8, 2024
3a3d0ff
feat: writer
fzyzcjy Jun 8, 2024
f91d4ea
feat: more
fzyzcjy Jun 8, 2024
a6066d7
feaT: more
fzyzcjy Jun 8, 2024
768e1de
feat: write
fzyzcjy Jun 8, 2024
6e65677
feat: more
fzyzcjy Jun 8, 2024
659af45
feat: more
fzyzcjy Jun 8, 2024
27d437c
chore: arg
fzyzcjy Jun 8, 2024
bd0c9ae
feat: more
fzyzcjy Jun 8, 2024
b564be1
feat: more
fzyzcjy Jun 8, 2024
4010a11
feat: more
fzyzcjy Jun 8, 2024
5e3fbe4
feat: more
fzyzcjy Jun 8, 2024
385a47d
fix: err
fzyzcjy Jun 8, 2024
bca223e
chore: codegen
fzyzcjy Jun 8, 2024
2e22ae1
feat: more
fzyzcjy Jun 8, 2024
67a8120
chore: codegen
fzyzcjy Jun 8, 2024
6924728
feat: more
fzyzcjy Jun 8, 2024
feaa66f
chore: codegen
fzyzcjy Jun 8, 2024
2aa339e
fix: err
fzyzcjy Jun 8, 2024
5c01998
chore: codegen
fzyzcjy Jun 8, 2024
7bcc32f
Merge branch 'master' into feat/12184
fzyzcjy Jun 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
use crate::codegen::generator::api_dart;
use crate::codegen::generator::api_dart::spec_generator::class::proxy_variant;
use crate::codegen::generator::api_dart::spec_generator::function::{
compute_params_str, ApiDartGeneratedFunction, ApiDartGeneratedFunctionParam,
};
use crate::codegen::generator::api_dart::spec_generator::misc::generate_dart_comments;
use crate::codegen::ir::mir::func::{
MirFunc, MirFuncAccessorMode, MirFuncArgMode, MirFuncDefaultConstructorMode, MirFuncOwnerInfo,
MirFuncOwnerInfoMethod, MirFuncOwnerInfoMethodMode,
MirFunc, MirFuncAccessorMode, MirFuncArgMode, MirFuncDefaultConstructorMode, MirFuncImplMode,
MirFuncImplModeDartOnly, MirFuncOwnerInfo, MirFuncOwnerInfoMethod, MirFuncOwnerInfoMethodMode,
};
use crate::codegen::ir::mir::ty::delegate::MirTypeDelegate;
use crate::codegen::ir::mir::ty::MirType;
use crate::if_then_some;
use crate::library::codegen::generator::api_dart::spec_generator::base::*;
use crate::utils::basic_code::dart_header_code::DartHeaderCode;
use crate::utils::namespace::NamespacedName;
use convert_case::{Case, Casing};
use itertools::Itertools;
use lazy_static::lazy_static;
use regex::Regex;

#[derive(Debug, Clone)]
pub(crate) struct GenerateApiMethodConfig {
Expand Down Expand Up @@ -53,23 +58,47 @@
}

pub(crate) fn generate_api_methods(
generalized_class_name: &NamespacedName,
owner_ty: &MirType,
context: ApiDartGeneratorContext,
config: &GenerateApiMethodConfig,
dart_class_name: &str,
) -> GeneratedApiMethods {
let methods =
get_methods_of_enum_or_struct(generalized_class_name, &context.mir_pack.funcs_all)
.iter()
.filter_map(|func| generate_api_method(func, context, config, dart_class_name))
.collect_vec();
let query_class_name = compute_class_name_for_querying_methods(owner_ty);
let methods = get_methods_of_ty(&query_class_name, &context.mir_pack.funcs_all)
.iter()
.filter_map(|func| generate_api_method(func, context, config, dart_class_name))
.collect_vec();
GeneratedApiMethods {
num_methods: methods.len(),
code: methods.iter().map(|x| x.code.clone()).join("\n"),
header: (methods.iter().map(|x| x.header.clone())).fold(Default::default(), |a, b| a + b),
}
}

fn compute_class_name_for_querying_methods(ty: &MirType) -> NamespacedName {
match ty {
MirType::EnumRef(ty) => ty.ident.0.clone(),
MirType::StructRef(ty) => ty.ident.0.clone(),
MirType::TraitDef(ty) => ty.name.clone(),
MirType::Delegate(MirTypeDelegate::ProxyVariant(ty)) => {
compute_class_name_for_querying_methods(&*ty.inner)
}
MirType::RustAutoOpaqueImplicit(ty) => {
compute_class_name_for_querying_methods(&MirType::RustOpaque(ty.inner.clone()))
}
MirType::RustOpaque(ty) => {
lazy_static! {
static ref FILTER: Regex =
Regex::new(r"^flutter_rust_bridge::for_generated::RustAutoOpaqueInner<(.*)>$")
.unwrap();
}
let name = FILTER.replace_all(&ty.inner.0, "$1").to_string();
NamespacedName::new(ty.namespace.clone(), name)
}
_ => panic!("compute_query_class_name see unknown ty={ty:?}"),

Check warning on line 98 in frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/method.rs

View check run for this annotation

Codecov / codecov/patch

frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/method.rs#L98

Added line #L98 was not covered by tests
}
}

// TODO move
pub(crate) fn dart_constructor_postfix(
name: &NamespacedName,
Expand All @@ -83,17 +112,12 @@
}

fn has_default_dart_constructor(name: &NamespacedName, all_funcs: &[MirFunc]) -> bool {
get_methods_of_enum_or_struct(name, all_funcs)
.iter()
.any(|m| {
m.default_constructor_mode() == Some(MirFuncDefaultConstructorMode::DartConstructor)
})
get_methods_of_ty(name, all_funcs).iter().any(|m| {
m.default_constructor_mode() == Some(MirFuncDefaultConstructorMode::DartConstructor)
})
}

fn get_methods_of_enum_or_struct<'a>(
name: &NamespacedName,
all_funcs: &'a [MirFunc],
) -> Vec<&'a MirFunc> {
fn get_methods_of_ty<'a>(name: &NamespacedName, all_funcs: &'a [MirFunc]) -> Vec<&'a MirFunc> {
(all_funcs.iter())
.filter(|f| matches!(&f.owner, MirFuncOwnerInfo::Method(m) if m.owner_ty_name().as_ref() == Some(name)))
.collect_vec()
Expand Down Expand Up @@ -232,20 +256,30 @@
method_info: &MirFuncOwnerInfoMethod,
params: &[ApiDartGeneratedFunctionParam],
) -> String {
let dart_entrypoint_class_name = &context.config.dart_entrypoint_class_name;
let dart_api_instance = format!("{dart_entrypoint_class_name}.instance.api");
match &func.impl_mode {
MirFuncImplMode::Normal => {
let dart_entrypoint_class_name = &context.config.dart_entrypoint_class_name;
let dart_api_instance = format!("{dart_entrypoint_class_name}.instance.api");

let func_name = func.name_dart_wire();
let func_name = func.name_dart_wire();

let arg_names = params
.iter()
.map(|x| format!("{name}: {name}", name = x.name_str))
.join(", ");
let arg_names = params
.iter()
.map(|x| format!("{name}: {name}", name = x.name_str))
.join(", ");

if method_info.mode == MirFuncOwnerInfoMethodMode::Static {
format!("{dart_api_instance}.{func_name}({arg_names})")
} else {
let extra_arg_name = func.inputs[0].inner.name.dart_style();
format!("{dart_api_instance}.{func_name}({extra_arg_name}: this, {arg_names})")
if method_info.mode == MirFuncOwnerInfoMethodMode::Static {
format!("{dart_api_instance}.{func_name}({arg_names})")
} else {
let extra_arg_name = func.inputs[0].inner.name.dart_style();
format!("{dart_api_instance}.{func_name}({extra_arg_name}: this, {arg_names})")
}
}
MirFuncImplMode::NoImpl => "should_not_reach_here".to_owned(),

Check warning on line 278 in frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/method.rs

View check run for this annotation

Codecov / codecov/patch

frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/method.rs#L278

Added line #L278 was not covered by tests
MirFuncImplMode::DartOnly(inner) => match inner {
MirFuncImplModeDartOnly::CreateProxyVariant(inner) => {
proxy_variant::compute_func_implementation(inner, context, func.mode)
}
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use serde::Serialize;
pub(crate) mod field;
pub(crate) mod method;
pub(super) mod misc;
pub(crate) mod proxy_variant;
pub(crate) mod ty;

#[derive(Debug, Serialize)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use crate::codegen::generator::api_dart::spec_generator::base::{
ApiDartGenerator, ApiDartGeneratorContext,
};
use crate::codegen::ir::mir::func::MirFuncMode;
use crate::codegen::ir::mir::ty::delegate::MirTypeDelegateProxyVariant;
use crate::library::codegen::generator::api_dart::spec_generator::info::ApiDartGeneratorInfoTrait;

pub(crate) fn compute_func_implementation(
ir: &MirTypeDelegateProxyVariant,
context: ApiDartGeneratorContext,
func_mode: MirFuncMode,
) -> String {
let mut ans = format!("{}(this)", compute_dart_extra_type(ir, context));
if func_mode == MirFuncMode::Normal {
ans = format!("Future.value({ans})");
}
ans
}

pub(crate) fn compute_dart_extra_type(
ir: &MirTypeDelegateProxyVariant,
context: ApiDartGeneratorContext,
) -> String {
let inner_dart_api_type = ApiDartGenerator::new(ir.inner.clone(), context).dart_api_type();
let upstream_dart_api_type =
ApiDartGenerator::new(ir.upstream.clone(), context).dart_api_type();
format!(
"{}ProxyVariant{}",
inner_dart_api_type, upstream_dart_api_type
)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
use crate::codegen::generator::api_dart::spec_generator::class::method::{
generate_api_methods, GenerateApiMethodConfig, GenerateApiMethodMode,
};
use crate::codegen::generator::api_dart::spec_generator::class::ty::ApiDartGeneratorClassTrait;
use crate::codegen::generator::api_dart::spec_generator::class::ApiDartGeneratedClass;
use crate::codegen::generator::api_dart::spec_generator::class::{
proxy_variant, ApiDartGeneratedClass,
};
use crate::codegen::ir::mir::ty::delegate::{
MirTypeDelegate, MirTypeDelegateArray, MirTypeDelegateArrayMode, MirTypeDelegatePrimitiveEnum,
MirTypeDelegateProxyVariant,
};
use crate::codegen::ir::mir::ty::MirType;
use crate::library::codegen::generator::api_dart::spec_generator::base::*;
use crate::library::codegen::generator::api_dart::spec_generator::info::ApiDartGeneratorInfoTrait;
use crate::utils::basic_code::dart_header_code::DartHeaderCode;
use crate::utils::namespace::NamespacedName;

impl<'a> ApiDartGeneratorClassTrait for DelegateApiDartGenerator<'a> {
fn generate_class(&self) -> Option<ApiDartGeneratedClass> {
Expand All @@ -17,6 +25,13 @@ impl<'a> ApiDartGeneratorClassTrait for DelegateApiDartGenerator<'a> {
_ => None,
}
}

fn generate_extra_impl_code(&self) -> Option<String> {
match &self.mir {
MirTypeDelegate::ProxyVariant(mir) => Some(generate_proxy_variant(mir, self.context)),
_ => None,
}
}
}

fn generate_array(
Expand Down Expand Up @@ -66,3 +81,34 @@ fn generate_array(
needs_freezed: false,
})
}

fn generate_proxy_variant(
mir: &MirTypeDelegateProxyVariant,
context: ApiDartGeneratorContext,
) -> String {
let class_name = proxy_variant::compute_dart_extra_type(mir, context);

let implements_name = ApiDartGenerator::new(mir.inner.clone(), context).dart_api_type();
let upstream_name = ApiDartGenerator::new(mir.upstream.clone(), context).dart_api_type();

let methods = generate_api_methods(
&MirType::Delegate(MirTypeDelegate::ProxyVariant(mir.clone())),
context,
&GenerateApiMethodConfig {
mode_static: GenerateApiMethodMode::Nothing,
mode_non_static: GenerateApiMethodMode::DeclAndImpl,
},
&class_name,
);
let methods_str = methods.code;

format!(
"class {class_name} with SimpleDisposable implements {implements_name} {{
final {upstream_name} _upstream;

{class_name}(this._upstream);

{methods_str}
}}"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ use crate::codegen::generator::api_dart::spec_generator::class::misc::generate_c
use crate::codegen::generator::api_dart::spec_generator::class::ty::ApiDartGeneratorClassTrait;
use crate::codegen::generator::api_dart::spec_generator::class::ApiDartGeneratedClass;
use crate::codegen::ir::mir::ty::enumeration::MirEnumMode;
use crate::codegen::ir::mir::ty::MirType;
use crate::library::codegen::generator::api_dart::spec_generator::base::*;

impl<'a> ApiDartGeneratorClassTrait for EnumRefApiDartGenerator<'a> {
fn generate_class(&self) -> Option<ApiDartGeneratedClass> {
let src = self.mir.get(self.context.mir_pack);

let methods = generate_api_methods(
&src.name,
&MirType::EnumRef(self.mir.clone()),
self.context,
&GenerateApiMethodConfig::COMBINED,
&src.name.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ impl RustOpaqueApiDartGenerator<'_> {
dart_class_name_postfix: &str,
) -> Info {
let dart_api_type = ApiDartGenerator::new(self.mir.clone(), self.context).dart_api_type();
let type_query_name = compute_query_name(&self.mir);

let methods = generate_api_methods(
&NamespacedName::new(self.mir.namespace.clone(), type_query_name.clone()),
&MirType::RustOpaque(self.mir.clone()),
self.context,
config,
&format!("{dart_api_type}{dart_class_name_postfix}"),
Expand All @@ -126,15 +125,6 @@ struct Info {
methods: GeneratedApiMethods,
}

fn compute_query_name(mir: &MirTypeRustOpaque) -> String {
lazy_static! {
static ref FILTER: Regex =
Regex::new(r"^flutter_rust_bridge::for_generated::RustAutoOpaqueInner<(.*)>$").unwrap();
}

FILTER.replace_all(&mir.inner.0, "$1").to_string()
}

fn generate_implements(
all_trait_impls: &[MirTraitImpl],
self_type: &MirTypeRustOpaque,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::codegen::generator::api_dart::spec_generator::class::ApiDartGenerated
use crate::codegen::generator::api_dart::spec_generator::misc::{
generate_dart_comments, generate_dart_metadata,
};
use crate::codegen::ir::mir::ty::MirType;
use crate::library::codegen::generator::api_dart::spec_generator::base::*;

impl<'a> ApiDartGeneratorClassTrait for StructRefApiDartGenerator<'a> {
Expand All @@ -20,7 +21,7 @@ impl<'a> ApiDartGeneratorClassTrait for StructRefApiDartGenerator<'a> {
let class_name = &self.mir.ident.0.name;

let methods = generate_api_methods(
&src.name,
&MirType::StructRef(self.mir.clone()),
self.context,
&GenerateApiMethodConfig::COMBINED,
class_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ use crate::codegen::generator::api_dart::spec_generator::class::method::{
};
use crate::codegen::generator::api_dart::spec_generator::class::ty::ApiDartGeneratorClassTrait;
use crate::codegen::generator::api_dart::spec_generator::class::ApiDartGeneratedClass;
use crate::codegen::ir::mir::ty::MirType;
use crate::library::codegen::generator::api_dart::spec_generator::base::*;

impl<'a> ApiDartGeneratorClassTrait for TraitDefApiDartGenerator<'a> {
fn generate_class(&self) -> Option<ApiDartGeneratedClass> {
let dart_api_type = &self.mir.name.name;
let methods = generate_api_methods(
&self.mir.name,
&MirType::TraitDef(self.mir.clone()),
self.context,
&GenerateApiMethodConfig {
mode_static: GenerateApiMethodMode::Nothing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ impl<'a> ApiDartGeneratorInfoTrait for DelegateApiDartGenerator<'a> {
MirTypeDelegate::RustAutoOpaqueExplicit(mir) => {
ApiDartGenerator::new(mir.inner.clone(), self.context).dart_api_type()
} // MirTypeDelegate::DynTrait(mir) => mir.trait_def_name.name.clone(),
MirTypeDelegate::ProxyVariant(mir) => {
ApiDartGenerator::new(mir.inner.clone(), self.context).dart_api_type()
}
MirTypeDelegate::ProxyEnum(mir) => {
ApiDartGenerator::new(mir.original.clone(), self.context).dart_api_type()
}
}
}

Expand Down
Loading
Loading