bool JavaScriptObject::setValue(int index, ChromiumDLL::JSObjHandle value) { JavaScriptObject* jso = (JavaScriptObject*)value.get(); if (!jso) return false; return m_pObject->SetValue(index, jso->getCefV8()); }
ChromiumDLL::JSObjHandle JavaScriptObject::executeFunction(ChromiumDLL::JavaScriptFunctionArgs *args) { if (!isFunction()) return GetJSFactory()->CreateException("Not a function!"); if (!args) return GetJSFactory()->CreateException("Args are null for function call"); JavaScriptContext* context = (JavaScriptContext*)args->context; JavaScriptObject* jso = (JavaScriptObject*)args->object.get(); CefV8ValueList argList; for (int x=0; x<args->argc; x++) { JavaScriptObject* jsoa = (JavaScriptObject*)args->argv[x].get(); if (jsoa) argList.push_back(jsoa->getCefV8()); else argList.push_back(NULL); } CefRefPtr<CefV8Value> retval; CefString exception; bool res = m_pObject->ExecuteFunctionWithContext(context->getCefV8(), jso?jso->getCefV8():NULL, argList, retval, exception); if (!res) { if (exception.c_str()) return GetJSFactory()->CreateException(exception.c_str()); return GetJSFactory()->CreateException("failed to run function"); } if (!retval) return NULL; return new JavaScriptObject(retval); }