bool color::PropertyHelper(CJS_Runtime* pRuntime, CJS_PropValue& vp, CPWL_Color* var) { CJS_Array array; if (vp.IsGetting()) { ConvertPWLColorToArray(pRuntime, *var, &array); vp << array; return true; } if (!vp.GetJSValue()->ConvertToArray(pRuntime, array)) return false; ConvertArrayToPWLColor(pRuntime, array, var); return true; }
FX_BOOL JSGlobalAlternate::DoProperty(IJS_Context* cc, const FX_WCHAR* propname, CJS_PropValue& vp, CFX_WideString& sError) { CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); if (vp.IsSetting()) { CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname); switch (vp.GetJSValue()->GetType()) { case CJS_Value::VT_number: { double dData; vp >> dData; return SetGlobalVariables(sPropName, JS_GlobalDataType::NUMBER, dData, false, "", v8::Local<v8::Object>(), FALSE); } case CJS_Value::VT_boolean: { bool bData; vp >> bData; return SetGlobalVariables(sPropName, JS_GlobalDataType::BOOLEAN, 0, bData, "", v8::Local<v8::Object>(), FALSE); } case CJS_Value::VT_string: { CFX_ByteString sData; vp >> sData; return SetGlobalVariables(sPropName, JS_GlobalDataType::STRING, 0, false, sData, v8::Local<v8::Object>(), FALSE); } case CJS_Value::VT_object: { v8::Local<v8::Object> pData; vp >> pData; return SetGlobalVariables(sPropName, JS_GlobalDataType::OBJECT, 0, false, "", pData, FALSE); } case CJS_Value::VT_null: { return SetGlobalVariables(sPropName, JS_GlobalDataType::NULLOBJ, 0, false, "", v8::Local<v8::Object>(), FALSE); } case CJS_Value::VT_undefined: { DelProperty(cc, propname, sError); return TRUE; } default: break; } } else {
bool app::activeDocs(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { if (!vp.IsGetting()) return false; CJS_Context* pContext = (CJS_Context*)cc; CJS_Runtime* pRuntime = pContext->GetJSRuntime(); CJS_Document* pJSDocument = nullptr; v8::Local<v8::Object> pObj = pRuntime->GetThisObj(); if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) { pJSDocument = static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj)); } CJS_Array aDocs; aDocs.SetElement(pRuntime, 0, CJS_Value(pRuntime, pJSDocument)); if (aDocs.GetLength(pRuntime) > 0) vp << aDocs; else vp.GetJSValue()->SetNull(pRuntime); return true; }