Skip to content

Commit b7de99a

Browse files
author
WinterPu
committed
feat: add method decl & impl replaced
1 parent 965cf6e commit b7de99a

File tree

6 files changed

+120
-2
lines changed

6 files changed

+120
-2
lines changed

renders/utility/additional_parsedata.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export class ClazzMethodUserData extends UECommonUserData {
5555
suffix_attribute: string = '';
5656

5757
// bp
58+
bpContextReplacedDecl: boolean = false;
59+
bpContextReplcedMethodDeclaration: string = '';
60+
bpContextReplacedImpl: boolean = false;
61+
bpContextReplcedMethodImplementation: string = '';
62+
5863
bpReturnType: string = '';
5964
bpCallbackDelegateMacroName: string = '';
6065
bpCallbackDelegateTypeName: string = '';

renders/utility/blueprint_special/bp_helper.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ import {
3737
map_method_param_size_count,
3838
map_struct_member_variable_size_count,
3939
} from './bptype_data_conv';
40+
import {
41+
ClazzMethodReplacedContext_,
42+
map_clazz_method_replaced_context,
43+
} from './bptype_data_replaced';
4044
import { UEBPType } from './bptype_helper';
4145

4246
import * as BPTypeHelper from './bptype_helper';
@@ -177,6 +181,20 @@ export function getBPName(node: CXXTerraNode): [CXXTYPE, string] {
177181
return [typeCategory, bpTypeName];
178182
}
179183

184+
export function genContext_BPMethodReplacedDecl(
185+
node_method: MemberFunction
186+
): ClazzMethodReplacedContext_ {
187+
const replaced_data = map_clazz_method_replaced_context[node_method.fullName];
188+
return (
189+
replaced_data ?? {
190+
doReplceDecl: false,
191+
decl: ``,
192+
doReplceImpl: false,
193+
impl: ``,
194+
}
195+
);
196+
}
197+
180198
export function getBPMethodNameFullData(
181199
node_method: MemberFunction,
182200
isCallback: boolean
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
export type ClazzMethodReplacedContext_ = {
2+
doReplceDecl: boolean;
3+
decl: string;
4+
doReplceImpl: boolean;
5+
impl: string;
6+
};
7+
8+
export const map_clazz_method_replaced_context: {
9+
[key: string]: ClazzMethodReplacedContext_;
10+
} = {
11+
'agora::rtc::IMediaPlayer.setPlayerOptionInInt': {
12+
doReplceDecl: false,
13+
decl: ``,
14+
doReplceImpl: true,
15+
impl: `
16+
int UAgoraBPuMediaPlayer::SetPlayerOptionInInt(const FString & key, int value)
17+
{
18+
// Need to be optimized
19+
int FinalReturnResult = AGORA_UE_ERR_CODE(ERROR_NULLPTR);
20+
21+
22+
23+
24+
// Convert UEBP to CppType
25+
std::string Raw_key = TCHAR_TO_UTF8(*key);
26+
int Raw_value = value;
27+
28+
// Call Native Method
29+
30+
// REPLACE_REPLACE!!!
31+
auto ret = _NativePtr->setPlayerOption(Raw_key.c_str(), Raw_value);
32+
33+
// Free Data if neeeded
34+
35+
36+
int ReturnVal = ret;
37+
FinalReturnResult = ReturnVal;
38+
39+
// Need to be optimized
40+
return FinalReturnResult;
41+
42+
}
43+
`,
44+
},
45+
46+
'agora::rtc::IMediaPlayer.setPlayerOptionInString': {
47+
doReplceDecl: false,
48+
decl: ``,
49+
doReplceImpl: true,
50+
impl: `
51+
int UAgoraBPuMediaPlayer::SetPlayerOptionInString(const FString & key, const FString & value)
52+
{
53+
// Need to be optimized
54+
int FinalReturnResult = AGORA_UE_ERR_CODE(ERROR_NULLPTR);
55+
56+
// Convert UEBP to CppType
57+
std::string Raw_key = TCHAR_TO_UTF8(*key);
58+
std::string Raw_value = TCHAR_TO_UTF8(*value);
59+
60+
// Call Native Method
61+
62+
auto ret = _NativePtr->setPlayerOption(Raw_key.c_str(), Raw_value.c_str());
63+
64+
// Free Data if neeeded
65+
66+
67+
int ReturnVal = ret;
68+
FinalReturnResult = ReturnVal;
69+
70+
// Need to be optimized
71+
return FinalReturnResult;
72+
73+
}
74+
`,
75+
},
76+
};

renders/utility/helper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ export function genGeneralTerraData(
133133
bIsCallbackMethod
134134
);
135135
const basedata_clazzmethod = genBaseUECommonUserData(method);
136+
const replaced_context =
137+
BPHelper.genContext_BPMethodReplacedDecl(method);
136138
const clazzMethodUserData: CustomUserData.ClazzMethodUserData = {
137139
...basedata_clazzmethod,
138140
isExcluded: func_exclude_api
@@ -152,6 +154,12 @@ export function genGeneralTerraData(
152154
: 'RtcEngine',
153155

154156
// bp
157+
158+
bpContextReplacedDecl: replaced_context.doReplceDecl,
159+
bpContextReplcedMethodDeclaration: replaced_context.decl,
160+
bpContextReplacedImpl: replaced_context.doReplceImpl,
161+
bpContextReplcedMethodImplementation: replaced_context.impl,
162+
155163
bpReturnType: BPHelper.genBPReturnType(method.return_type),
156164

157165
bpCallbackDelegateMacroName: bpMethodNameFullData.delegateMacroName,

templates/bpplugin/bp_clazz_impl.mustache

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{{#methods}}
2+
{{#user_data.bpContextReplacedImpl}}
3+
// replaced method
4+
{{{user_data.bpContextReplcedMethodImplementation}}}
5+
{{/user_data.bpContextReplacedImpl}}
6+
{{^user_data.bpContextReplacedImpl}}
27
{{{user_data.bpReturnType}}} {{parent.user_data.bpNodeName}}::{{user_data.bpNodeName}}({{#parameters}}{{{user_data.bpParameterType}}} {{name}}{{^user_data.isLast}}, {{/user_data.isLast}}{{/parameters}})
38
{
49
{{#user_data.hasReturnVal}}
@@ -34,7 +39,7 @@
3439
{{{user_data.bpContextReturnValEnd}}}
3540
{{/user_data.hasReturnVal}}
3641
}
37-
42+
{{/user_data.bpContextReplacedImpl}}
3843
{{/methods}}
3944

4045

templates/type/clazz.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ public:
77
{{{user_data.bpContextInitDecl}}}
88

99
{{#methods}}
10+
{{#user_data.bpContextReplacedDecl}}
11+
// replaced method
12+
{{{user_data.bpContextReplcedMethodDeclaration}}}
13+
{{/user_data.bpContextReplacedDecl}}
14+
{{^user_data.bpContextReplacedDecl}}
1015
{{{user_data.commentCppStyle}}}
1116
UFUNCTION(BlueprintCallable,Category = "Agora|{{parent_name}}")
1217
{{{user_data.bpReturnType}}} {{user_data.bpNodeName}}({{#parameters}}{{{user_data.bpParameterType}}} {{name}}{{^user_data.isLast}}, {{/user_data.isLast}}{{/parameters}});
13-
18+
19+
{{/user_data.bpContextReplacedDecl}}
1420
{{/methods}}
1521

1622
private:

0 commit comments

Comments
 (0)