static v8::Handle<v8::Value> FunctionCallbackImpl(const v8::Arguments& args) { v8::HandleScope handle_scope; JSExtension* handler = static_cast<JSExtension*>(v8::External::Cast(*(args.Data()))->Value()); ChromiumDLL::JSObjHandle* argv = new ChromiumDLL::JSObjHandle[args.Length()]; for(int i = 0; i < args.Length(); i++) argv[i] = new JSObject(args[i]); ChromiumDLL::JSObjHandle obj(new JSObject(args.This())); v8::Handle<v8::Value> value = v8::Null(); v8::Local<v8::Function> funct = args.Callee(); v8::Handle<v8::Value> name = funct->GetName(); v8::String::AsciiValue str(name); try { ChromiumDLL::JavaScriptFunctionArgs jsargs; jsargs.function = *str; jsargs.factory = &g_Factory; jsargs.argc = args.Length(); jsargs.object = obj; jsargs.argv = argv; jsargs.context = nullptr; ChromiumDLL::JSObjHandle ret = handler->m_pExtender->execute(&jsargs); delete [] argv; JSObject *native = dynamic_cast<JSObject*>(ret.get()); if (native) value = native->getNative(); ret->delRef(); } catch (std::exception& e) { delete [] argv; value = v8::ThrowException(v8::String::New(e.what())); } return value; }
bool JavaScriptObject::setValue(int index, ChromiumDLL::JSObjHandle value) { JavaScriptObject* jso = (JavaScriptObject*)value.get(); if (!jso) return false; return m_pObject->SetValue(index, jso->getCefV8()); }