File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Plugins/UnrealJS/Source/V8/Private Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -1473,13 +1473,36 @@ class FJavascriptIsolateImplementation : public FJavascriptIsolate
14731473 FIsolateHelper I (isolate_);
14741474
14751475 auto fn = [](const FunctionCallbackInfo<Value>& info) {
1476- auto ClassToExport = reinterpret_cast <UClass *>((Local<External>::Cast (info.Data ()))->Value ());
1476+ auto StructToExport = reinterpret_cast <UStruct *>((Local<External>::Cast (info.Data ()))->Value ());
14771477
14781478 auto isolate = info.GetIsolate ();
14791479
14801480 if (info.Length () == 1 )
14811481 {
1482- info.GetReturnValue ().Set (info[0 ]);
1482+ auto Value = info[0 ];
1483+
1484+ auto Instance = FStructMemoryInstance::FromV8 (Value);
1485+
1486+ // If given value is an instance
1487+ if (Instance)
1488+ {
1489+ auto GivenStruct = Instance->Struct ;
1490+ if (Instance->Struct ->IsChildOf (StructToExport))
1491+ {
1492+ info.GetReturnValue ().Set (info[0 ]);
1493+ }
1494+ }
1495+ else if (auto ScriptStruct = Cast<UScriptStruct>(StructToExport))
1496+ {
1497+ if (Value->IsObject ())
1498+ {
1499+ auto v = Value->ToObject ();
1500+ auto Target = (uint8*)(FMemory_Alloca (ScriptStruct->GetStructureSize ()));
1501+ GetSelf (isolate)->ReadOffStruct (v, ScriptStruct, Target);
1502+ auto out = GetSelf (isolate)->ExportStructInstance (ScriptStruct, Target, FNoPropertyOwner ());
1503+ info.GetReturnValue ().Set (out);
1504+ }
1505+ }
14831506 }
14841507 };
14851508
You can’t perform that action at this time.
0 commit comments