-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2050 from fzyzcjy/feat/12184
Support `#[frb(proxy)]` (part 1)
- Loading branch information
Showing
46 changed files
with
2,259 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/proxy_variant.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.