32 v8::Isolate::Scope isolate_scope(pIsolate);
33 v8::HandleScope scope(pIsolate);
35 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
38 v8::MaybeLocal<v8::Value> maybe_value =
39 context->Global()->Get(context, fxv8::NewStringHelper(pIsolate,
"Date"));
41 v8::Local<v8::Value> value;
42 if (!maybe_value.ToLocal(&value) || !value->IsObject())
45 v8::Local<v8::Object> obj = value.As<v8::Object>();
46 maybe_value = obj->Get(context, fxv8::NewStringHelper(pIsolate,
"parse"));
47 if (!maybe_value.ToLocal(&value) || !value->IsFunction())
50 v8::Local<v8::Function> func = value.As<v8::Function>();
51 static constexpr int argc = 1;
52 v8::Local<v8::Value> argv[argc] = {
53 fxv8::NewStringHelper(pIsolate, str.AsStringView()),
55 maybe_value = func->Call(context, context->Global(), argc, argv);
56 if (!maybe_value.ToLocal(&value) || !value->IsNumber())
59 double date = value.As<v8::Number>()->Value();
64 CJS_Runtime* pRuntime,
70 v8::LocalVector<v8::Value> result(pRuntime->GetIsolate(), nKeywords);
71 size_t size = std::min(originals.size(), nKeywords);
72 for (size_t i = 0; i < size; ++i)
73 result[i] = originals[i];
75 if (originals.size() != 1 || !originals[0]->IsObject() ||
76 originals[0]->IsArray()) {
79 result[0] = v8::Local<v8::Value>();
81 v8::Local<v8::Object> pObj = pRuntime->ToObject(originals[0]);
83 va_start(ap, nKeywords);
84 for (size_t i = 0; i < nKeywords; ++i) {
85 const char* property = va_arg(ap,
const char*);
86 v8::Local<v8::Value> v8Value = pRuntime->GetObjectProperty(pObj, property);
87 if (!v8Value->IsUndefined())