Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b508933

Browse files
Fix issue #29 by returning primitive types in binding functions rather than struct types (e.g. int32_t instead of System::Int32).
1 parent 74d7d4a commit b508933

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

‎Unity/Assets/CppSource/NativeScript/Bindings.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,33 @@ namespace Plugin
6464
int32_t (*SystemExceptionConstructorSystemString)(int32_t messageHandle);
6565
int32_t (*BoxPrimitiveType)(UnityEngine::PrimitiveType val);
6666
UnityEngine::PrimitiveType (*UnboxPrimitiveType)(int32_t valHandle);
67-
System::Single (*UnityEngineTimePropertyGetDeltaTime)();
67+
float (*UnityEngineTimePropertyGetDeltaTime)();
6868
void (*ReleaseBaseBallScript)(int32_t handle);
6969
void (*BaseBallScriptConstructor)(int32_t cppHandle, int32_t* handle);
7070
int32_t (*BoxBoolean)(uint32_t val);
7171
int32_t (*UnboxBoolean)(int32_t valHandle);
7272
int32_t (*BoxSByte)(int8_t val);
73-
System::SByte (*UnboxSByte)(int32_t valHandle);
73+
int8_t (*UnboxSByte)(int32_t valHandle);
7474
int32_t (*BoxByte)(uint8_t val);
75-
System::Byte (*UnboxByte)(int32_t valHandle);
75+
uint8_t (*UnboxByte)(int32_t valHandle);
7676
int32_t (*BoxInt16)(int16_t val);
77-
System::Int16 (*UnboxInt16)(int32_t valHandle);
77+
int16_t (*UnboxInt16)(int32_t valHandle);
7878
int32_t (*BoxUInt16)(uint16_t val);
79-
System::UInt16 (*UnboxUInt16)(int32_t valHandle);
79+
uint16_t (*UnboxUInt16)(int32_t valHandle);
8080
int32_t (*BoxInt32)(int32_t val);
81-
System::Int32 (*UnboxInt32)(int32_t valHandle);
81+
int32_t (*UnboxInt32)(int32_t valHandle);
8282
int32_t (*BoxUInt32)(uint32_t val);
83-
System::UInt32 (*UnboxUInt32)(int32_t valHandle);
83+
uint32_t (*UnboxUInt32)(int32_t valHandle);
8484
int32_t (*BoxInt64)(int64_t val);
85-
System::Int64 (*UnboxInt64)(int32_t valHandle);
85+
int64_t (*UnboxInt64)(int32_t valHandle);
8686
int32_t (*BoxUInt64)(uint64_t val);
87-
System::UInt64 (*UnboxUInt64)(int32_t valHandle);
87+
uint64_t (*UnboxUInt64)(int32_t valHandle);
8888
int32_t (*BoxChar)(uint16_t val);
8989
int16_t (*UnboxChar)(int32_t valHandle);
9090
int32_t (*BoxSingle)(float val);
91-
System::Single (*UnboxSingle)(int32_t valHandle);
91+
float (*UnboxSingle)(int32_t valHandle);
9292
int32_t (*BoxDouble)(double val);
93-
System::Double (*UnboxDouble)(int32_t valHandle);
93+
double (*UnboxDouble)(int32_t valHandle);
9494
/*END FUNCTION POINTERS*/
9595
}
9696

@@ -6209,7 +6209,7 @@ DLLEXPORT void Init(
62096209
curMemory += sizeof(Plugin::BoxPrimitiveType);
62106210
Plugin::UnboxPrimitiveType = *(UnityEngine::PrimitiveType (**)(int32_t valHandle))curMemory;
62116211
curMemory += sizeof(Plugin::UnboxPrimitiveType);
6212-
Plugin::UnityEngineTimePropertyGetDeltaTime = *(System::Single (**)())curMemory;
6212+
Plugin::UnityEngineTimePropertyGetDeltaTime = *(float (**)())curMemory;
62136213
curMemory += sizeof(Plugin::UnityEngineTimePropertyGetDeltaTime);
62146214
Plugin::ReleaseBaseBallScript = *(void (**)(int32_t handle))curMemory;
62156215
curMemory += sizeof(Plugin::ReleaseBaseBallScript);
@@ -6221,47 +6221,47 @@ DLLEXPORT void Init(
62216221
curMemory += sizeof(Plugin::UnboxBoolean);
62226222
Plugin::BoxSByte = *(int32_t (**)(int8_t val))curMemory;
62236223
curMemory += sizeof(Plugin::BoxSByte);
6224-
Plugin::UnboxSByte = *(System::SByte (**)(int32_t valHandle))curMemory;
6224+
Plugin::UnboxSByte = *(int8_t (**)(int32_t valHandle))curMemory;
62256225
curMemory += sizeof(Plugin::UnboxSByte);
62266226
Plugin::BoxByte = *(int32_t (**)(uint8_t val))curMemory;
62276227
curMemory += sizeof(Plugin::BoxByte);
6228-
Plugin::UnboxByte = *(System::Byte (**)(int32_t valHandle))curMemory;
6228+
Plugin::UnboxByte = *(uint8_t (**)(int32_t valHandle))curMemory;
62296229
curMemory += sizeof(Plugin::UnboxByte);
62306230
Plugin::BoxInt16 = *(int32_t (**)(int16_t val))curMemory;
62316231
curMemory += sizeof(Plugin::BoxInt16);
6232-
Plugin::UnboxInt16 = *(System::Int16 (**)(int32_t valHandle))curMemory;
6232+
Plugin::UnboxInt16 = *(int16_t (**)(int32_t valHandle))curMemory;
62336233
curMemory += sizeof(Plugin::UnboxInt16);
62346234
Plugin::BoxUInt16 = *(int32_t (**)(uint16_t val))curMemory;
62356235
curMemory += sizeof(Plugin::BoxUInt16);
6236-
Plugin::UnboxUInt16 = *(System::UInt16 (**)(int32_t valHandle))curMemory;
6236+
Plugin::UnboxUInt16 = *(uint16_t (**)(int32_t valHandle))curMemory;
62376237
curMemory += sizeof(Plugin::UnboxUInt16);
62386238
Plugin::BoxInt32 = *(int32_t (**)(int32_t val))curMemory;
62396239
curMemory += sizeof(Plugin::BoxInt32);
6240-
Plugin::UnboxInt32 = *(System::Int32 (**)(int32_t valHandle))curMemory;
6240+
Plugin::UnboxInt32 = *(int32_t (**)(int32_t valHandle))curMemory;
62416241
curMemory += sizeof(Plugin::UnboxInt32);
62426242
Plugin::BoxUInt32 = *(int32_t (**)(uint32_t val))curMemory;
62436243
curMemory += sizeof(Plugin::BoxUInt32);
6244-
Plugin::UnboxUInt32 = *(System::UInt32 (**)(int32_t valHandle))curMemory;
6244+
Plugin::UnboxUInt32 = *(uint32_t (**)(int32_t valHandle))curMemory;
62456245
curMemory += sizeof(Plugin::UnboxUInt32);
62466246
Plugin::BoxInt64 = *(int32_t (**)(int64_t val))curMemory;
62476247
curMemory += sizeof(Plugin::BoxInt64);
6248-
Plugin::UnboxInt64 = *(System::Int64 (**)(int32_t valHandle))curMemory;
6248+
Plugin::UnboxInt64 = *(int64_t (**)(int32_t valHandle))curMemory;
62496249
curMemory += sizeof(Plugin::UnboxInt64);
62506250
Plugin::BoxUInt64 = *(int32_t (**)(uint64_t val))curMemory;
62516251
curMemory += sizeof(Plugin::BoxUInt64);
6252-
Plugin::UnboxUInt64 = *(System::UInt64 (**)(int32_t valHandle))curMemory;
6252+
Plugin::UnboxUInt64 = *(uint64_t (**)(int32_t valHandle))curMemory;
62536253
curMemory += sizeof(Plugin::UnboxUInt64);
62546254
Plugin::BoxChar = *(int32_t (**)(uint16_t val))curMemory;
62556255
curMemory += sizeof(Plugin::BoxChar);
62566256
Plugin::UnboxChar = *(int16_t (**)(int32_t valHandle))curMemory;
62576257
curMemory += sizeof(Plugin::UnboxChar);
62586258
Plugin::BoxSingle = *(int32_t (**)(float val))curMemory;
62596259
curMemory += sizeof(Plugin::BoxSingle);
6260-
Plugin::UnboxSingle = *(System::Single (**)(int32_t valHandle))curMemory;
6260+
Plugin::UnboxSingle = *(float (**)(int32_t valHandle))curMemory;
62616261
curMemory += sizeof(Plugin::UnboxSingle);
62626262
Plugin::BoxDouble = *(int32_t (**)(double val))curMemory;
62636263
curMemory += sizeof(Plugin::BoxDouble);
6264-
Plugin::UnboxDouble = *(System::Double (**)(int32_t valHandle))curMemory;
6264+
Plugin::UnboxDouble = *(double (**)(int32_t valHandle))curMemory;
62656265
curMemory += sizeof(Plugin::UnboxDouble);
62666266
/*END INIT BODY PARAMETER READS*/
62676267

‎Unity/Assets/NativeScript/Editor/GenerateBindings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12918,6 +12918,10 @@ static void AppendCppFunctionPointer(
1291812918
// C linkage requires us to use primitive types
1291912919
output.Append("int16_t");
1292012920
}
12921+
else if (returnType.IsPrimitive)
12922+
{
12923+
AppendCppPrimitiveTypeName(returnType, output);
12924+
}
1292112925
else if (IsFullValueType(returnType))
1292212926
{
1292312927
AppendCppTypeFullName(returnType, output);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /