| 51 | } |
| 52 | |
| 53 | static v8::Local<v8::Value> ToV8(v8::Isolate* Isolate, v8::Local<v8::Context> Context, const FValue &Value) |
| 54 | { |
| 55 | JSEngine *JsEngine = nullptr; |
| 56 | switch (Value.Type) |
| 57 | { |
| 58 | case NullOrUndefined: |
| 59 | return v8::Null(Isolate); |
| 60 | case BigInt: |
| 61 | return v8::BigInt::New(Isolate, Value.BigInt); |
| 62 | case Number: |
| 63 | return v8::Number::New(Isolate, Value.Number); |
| 64 | case Date: |
| 65 | return v8::Date::New(Context, Value.Number).ToLocalChecked(); |
| 66 | case String: |
| 67 | return FV8Utils::V8String(Isolate, Value.Str.c_str()); |
| 68 | case NativeObject: |
| 69 | JsEngine = FV8Utils::IsolateData<JSEngine>(Isolate); |
| 70 | return JsEngine->FindOrAddObject(Isolate, Context, Value.ObjectInfo.ClassID, Value.ObjectInfo.ObjectPtr); |
| 71 | case Function: |
| 72 | return Value.FunctionPtr->GFunction.Get(Isolate); |
| 73 | case JsObject: |
| 74 | return Value.JSObjectPtr->GObject.Get(Isolate); |
| 75 | case Boolean: |
| 76 | return v8::Boolean::New(Isolate, Value.Boolean); |
| 77 | case ArrayBuffer: |
| 78 | return Value.ArrayBuffer.Get(Isolate); |
| 79 | default: |
| 80 | return v8::Undefined(Isolate); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /*void JSFunction::SetResult(v8::MaybeLocal<v8::Value> maybeValue) |
| 85 | { |
no test coverage detected