// CJS_Value::operator CJS_Array() FX_BOOL CJS_Value::ConvertToArray(CJS_Array& array) const { if (IsArrayObject()) { array.Attach(JS_ToArray(m_isolate, m_pValue)); return TRUE; } return FALSE; }
// CJS_Value::operator CJS_Array() FX_BOOL CJS_Value::ConvertToArray(CJS_Array& array) const { if (IsArrayObject()) { array.Attach(FXJS_ToArray(m_pJSRuntime->GetIsolate(), m_pValue)); return TRUE; } return FALSE; }
void color::ConvertArrayToPWLColor(CJS_Array& array, CPWL_Color& color) { int nArrayLen = array.GetLength(); if (nArrayLen < 1) return; CJS_Value value(array.GetIsolate()); array.GetElement(0, value); CFX_ByteString sSpace = value.ToCFXByteString(); double d1 = 0; double d2 = 0; double d3 = 0; double d4 = 0; if (nArrayLen > 1) { array.GetElement(1, value); d1 = value.ToDouble(); } if (nArrayLen > 2) { array.GetElement(2, value); d2 = value.ToDouble(); } if (nArrayLen > 3) { array.GetElement(3, value); d3 = value.ToDouble(); } if (nArrayLen > 4) { array.GetElement(4, value); d4 = value.ToDouble(); } if (sSpace == "T") { color = CPWL_Color(COLORTYPE_TRANSPARENT); } else if (sSpace == "G") { color = CPWL_Color(COLORTYPE_GRAY, (FX_FLOAT)d1); } else if (sSpace == "RGB") { color = CPWL_Color(COLORTYPE_RGB, (FX_FLOAT)d1, (FX_FLOAT)d2, (FX_FLOAT)d3); } else if (sSpace == "CMYK") { color = CPWL_Color(COLORTYPE_CMYK, (FX_FLOAT)d1, (FX_FLOAT)d2, (FX_FLOAT)d3, (FX_FLOAT)d4); } }
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; }
void color::ConvertPWLColorToArray(const CPWL_Color& color, CJS_Array& array) { switch (color.nColorType) { case COLORTYPE_TRANSPARENT: array.SetElement(0, CJS_Value(array.GetIsolate(), "T")); break; case COLORTYPE_GRAY: array.SetElement(0, CJS_Value(array.GetIsolate(),"G")); array.SetElement(1, CJS_Value(array.GetIsolate(),color.fColor1)); break; case COLORTYPE_RGB: array.SetElement(0, CJS_Value(array.GetIsolate(),"RGB")); array.SetElement(1, CJS_Value(array.GetIsolate(),color.fColor1)); array.SetElement(2, CJS_Value(array.GetIsolate(),color.fColor2)); array.SetElement(3, CJS_Value(array.GetIsolate(),color.fColor3)); break; case COLORTYPE_CMYK: array.SetElement(0, CJS_Value(array.GetIsolate(),"CMYK")); array.SetElement(1, CJS_Value(array.GetIsolate(),color.fColor1)); array.SetElement(2, CJS_Value(array.GetIsolate(),color.fColor2)); array.SetElement(3, CJS_Value(array.GetIsolate(),color.fColor3)); array.SetElement(4, CJS_Value(array.GetIsolate(),color.fColor4)); break; } }
CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const CJS_Array& array) : m_pValue(array.ToV8Array(pRuntime)) {}
bool CJS_Value::ConvertToArray(CJS_Runtime* pRuntime, CJS_Array& array) const { if (!IsArrayObject()) return false; array.Attach(pRuntime->ToArray(m_pValue)); return true; }