Skip to content

Commit 32fd76d

Browse files
author
WinterPu
committed
bugfix: fix Android Compilation Error
1. some struct has macro scope but USTRUCT cannot be inside the macro scope 2. macro sope problem: in USTRUCT member EUABT_TYPE type = UABT::WrapWithUE(native_enum); use special rule for default value 3. struct default val: int64 a = NULL; change NULL to 0 4. AsyncTask add include files
1 parent 8e6b459 commit 32fd76d

File tree

8 files changed

+75
-2
lines changed

8 files changed

+75
-2
lines changed

docs/src/BlueprintGeneration/BPGen-Struct.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,19 @@ int64 uid = 0;
2525

2626

2727

28+
29+
### USTRUCT 没法包在Macro Scope 内
30+
```
31+
#if PLATFORM_WINDOWS
32+
33+
USTRUCT(BlueprintType)
34+
struct FUABT_Test{
35+
GENERATED_BODY()
36+
public:
37+
38+
}
39+
40+
#endif
41+
42+
Error: USTRUCT must not be inside preprocessor blocks, except for WITH_EDITORONLY_DATA
43+
```

renders/utility/blueprint_special/bp_helper.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
map_method_param_size_count,
3838
map_return_bptype_default_value,
3939
map_return_bptype_fix,
40+
map_return_context_default_value,
4041
map_struct_member_variable_size_count,
4142
} from './bptype_data_conv';
4243
import * as BPContextReplacedHelper from './bptype_data_replaced/helper';
@@ -502,7 +503,8 @@ function genContext_BPMethodReturnValBegin(
502503
// should be default value not a failed value.
503504
let defaultVal =
504505
bpTypeConvData?.defaultBPValue ??
505-
map_return_bptype_default_value[return_type.source] ??
506+
map_return_context_default_value[decl_type] ?? // ref bp
507+
map_return_bptype_default_value[return_type.source] ?? // ref cpp
506508
'';
507509

508510
if (Tools.IsNotEmptyStr(defaultVal)) {

renders/utility/blueprint_special/bptype_data_conv.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,10 @@ export const map_struct_member_variable_default_value: {
10411041
// therefore it shows: EUABT_VIDEO_CONTENT_HINT contentHint = UABTEnum::WrapWithUE(undefined);
10421042
'agora::rtc::ScreenVideoParameters.contentHint':
10431043
'EUABT_VIDEO_CONTENT_HINT::CONTENT_HINT_NONE',
1044+
1045+
// for macro scope problem:
1046+
'agora::rtc::ScreenCaptureSourceInfo.type':
1047+
'EUABT_ScreenCaptureSourceType::ScreenCaptureSourceType_Unknown',
10441048
};
10451049

10461050
// In Struct, the corresponding size count variable to the target member variable
@@ -1129,3 +1133,7 @@ export const map_return_bptype_default_value: Record<string, string> = {
11291133
};
11301134

11311135
export const map_return_bptype_fix: { [key: string]: string } = {};
1136+
1137+
export const map_return_context_default_value: { [key: string]: string } = {
1138+
int64: '0',
1139+
};

renders/utility/blueprint_special/bptype_data_makeup.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,11 @@ export const map_class_initialization: {
545545
Inst: `
546546
static UAgoraBPuScreenCaptureSourceList* InsScreenCaptureSourceList;
547547
548+
#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE)
549+
548550
agora::rtc::IScreenCaptureSourceList* _NativePtr = nullptr;
551+
552+
#endif
549553
`,
550554
InitDecl: `
551555
UFUNCTION(BlueprintCallable,Category = "Agora|IScreenCaptureSourceList")
@@ -581,3 +585,26 @@ export const map_class_initialization: {
581585

582586
// MusicCollection: {},
583587
};
588+
589+
export type MacropScopeMakeup = {
590+
start: string;
591+
end: string;
592+
};
593+
// key : fullName
594+
export const map_macrop_scope_makeup: { [key: string]: MacropScopeMakeup } = {
595+
'agora::rtc::IScreenCaptureSourceList.getCount': {
596+
start:
597+
'#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE)',
598+
end: '#endif',
599+
},
600+
'agora::rtc::IScreenCaptureSourceList.getSourceInfo': {
601+
start:
602+
'#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE)',
603+
end: '#endif',
604+
},
605+
'agora::rtc::IScreenCaptureSourceList.release': {
606+
start:
607+
'#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE)',
608+
end: '#endif',
609+
},
610+
};

renders/utility/blueprint_special/bptype_helper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ export function getBPMemberVariableDefaultValue(
751751

752752
// TBD(WinterPu)
753753
// Special Case: FString
754+
// some fix
754755
if (bpType.declType === 'FString') {
755756
if (
756757
valDefaultVal === '0' ||
@@ -763,6 +764,13 @@ export function getBPMemberVariableDefaultValue(
763764
}
764765
}
765766

767+
if (bpType.declType === 'int64') {
768+
// For Android Compilation
769+
if (valDefaultVal === 'NULL') {
770+
valDefaultVal = '0';
771+
}
772+
}
773+
766774
return [bNeedDefaultValue, valDefaultVal];
767775
}
768776

renders/utility/cpp_helper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from '@agoraio-extensions/terra-core';
1919
import { List, map } from 'lodash';
2020

21+
import { map_macrop_scope_makeup } from './blueprint_special/bptype_data_makeup';
2122
import * as Tools from './tools';
2223
export function formatAsCppComment(input: string): string {
2324
if (input == '' || input == undefined) {
@@ -71,6 +72,13 @@ export function createCompilationDirectivesContent(
7172
node: CXXTerraNode,
7273
isStart: boolean = true
7374
): string {
75+
// TBD(WinterPu)
76+
// should be moved to bp helper.
77+
const data_macrop_scope = map_macrop_scope_makeup[node.fullName];
78+
if (data_macrop_scope) {
79+
return isStart ? data_macrop_scope.start : data_macrop_scope.end;
80+
}
81+
7482
let directives = node.conditional_compilation_directives_infos;
7583
if (directives.length == 0) {
7684
return '';

renders/utility/helper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@ export function genGeneralTerraData(
115115

116116
const basedata_clazz = genBaseUECommonUserData(node);
117117
const clazzUserData: CustomUserData.ClazzUserData = {
118+
...node.user_data,
118119
...basedata_clazz,
119120
bpContextInst: context_clazz?.Inst ?? '',
120121
bpContextInitDecl: context_clazz?.InitDecl ?? '',
121122
bpContextInitImpl: context_clazz?.InitImpl ?? '',
122123
};
123-
node.user_data = { ...node.user_data, ...clazzUserData };
124+
node.user_data = clazzUserData;
124125

125126
// Node - Clazz Method
126127
node.asClazz().methods.map((method, index) => {

templates/type/file_content.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include "UtilityUABTEnumConvertMacro.h"
1616
#include "UtilityUABTTypeHelper.h"
1717

18+
// for AsyncTask
19+
#include "Async/Async.h"
20+
1821
{{#user_data.bpIncludeFiles}}
1922
{{{.}}}
2023
{{/user_data.bpIncludeFiles}}

0 commit comments

Comments
 (0)