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
1473
1473
FIsolateHelper I (isolate_);
1474
1474
1475
1475
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 ());
1477
1477
1478
1478
auto isolate = info.GetIsolate ();
1479
1479
1480
1480
if (info.Length () == 1 )
1481
1481
{
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
+ }
1483
1506
}
1484
1507
};
1485
1508
You can’t perform that action at this time.
0 commit comments