void CFXJS_Engine::PutObjectString(v8::Local<v8::Object> pObj, const CFX_WideString& wsPropertyName, const CFX_WideString& wsValue) { if (pObj.IsEmpty()) return; pObj->Set(m_isolate->GetCurrentContext(), WSToJSString(wsPropertyName), WSToJSString(wsValue)) .FromJust(); }
double JS_DateParse(const wchar_t* string) { v8::Isolate* pIsolate = v8::Isolate::GetCurrent(); v8::Isolate::Scope isolate_scope(pIsolate); v8::HandleScope scope(pIsolate); v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); //Use the built-in object method. v8::Local<v8::Value> v = context->Global()->Get(v8::String::NewFromUtf8(pIsolate, "Date")); if(v->IsObject()) { v8::Local<v8::Object> o = v->ToObject(); v = o->Get(v8::String::NewFromUtf8(pIsolate, "parse")); if(v->IsFunction()) { v8::Local<v8::Function> funC = v8::Handle<v8::Function>::Cast(v); const int argc = 1; v8::Local<v8::String> timeStr = WSToJSString(pIsolate, string); v8::Handle<v8::Value> argv[argc] = {timeStr}; v = funC->Call(context->Global(), argc, argv); if(v->IsNumber()) { double date = v->ToNumber()->Value(); if(!_isfinite(date)) return date; return date + _getLocalTZA() + _getDaylightSavingTA(date); } } } return 0; }
void CFXJS_Engine::PutObjectNumber(v8::Local<v8::Object> pObj, const CFX_WideString& wsPropertyName, float fValue) { if (pObj.IsEmpty()) return; pObj->Set(m_isolate->GetCurrentContext(), WSToJSString(wsPropertyName), v8::Number::New(m_isolate, (double)fValue)) .FromJust(); }
v8::Local<v8::Value> CFXJS_Engine::GetObjectProperty( v8::Local<v8::Object> pObj, const CFX_WideString& wsPropertyName) { if (pObj.IsEmpty()) return v8::Local<v8::Value>(); v8::Local<v8::Value> val; if (!pObj->Get(m_isolate->GetCurrentContext(), WSToJSString(wsPropertyName)) .ToLocal(&val)) return v8::Local<v8::Value>(); return val; }
v8::Handle<v8::Value> JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string, unsigned nLen) { return WSToJSString(pJSRuntime, string, nLen); }
v8::Handle<v8::Value> JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string) { return WSToJSString(pJSRuntime, string); }
void JS_PutObjectNull(IJS_Runtime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName) { if(pObj.IsEmpty()) return; pObj->Set(WSToJSString(pJSRuntime,PropertyName),v8::Handle<v8::Object>()); }
void JS_PutObjectBoolean(IJS_Runtime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, bool bValue) { if(pObj.IsEmpty()) return; pObj->Set(WSToJSString(pJSRuntime,PropertyName),v8::Boolean::New(pJSRuntime, bValue)); }
void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, double dValue) { if(pObj.IsEmpty()) return; pObj->Set(WSToJSString(pJSRuntime,PropertyName),v8::Number::New(pJSRuntime, (double)dValue)); }
void JS_PutObjectString(IJS_Runtime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, const wchar_t* sValue) //VT_string { if(pObj.IsEmpty()) return; pObj->Set(WSToJSString(pJSRuntime, PropertyName), WSToJSString(pJSRuntime, sValue)); }
v8::Handle<v8::Value> JS_GetObjectElement(IJS_Runtime* pJSRuntime, v8::Handle<v8::Object> pObj,const wchar_t* PropertyName) { if(pObj.IsEmpty()) return v8::Handle<v8::Value>(); return pObj->Get(WSToJSString(pJSRuntime,PropertyName)); }
v8::Local<v8::Value> CFXJS_Engine::NewString(const wchar_t* str) { return WSToJSString(str); }