void VBOModule::create(const v8::FunctionCallbackInfo<v8::Value>& args) { v8::Isolate* isolate = args.GetIsolate(); v8::HandleScope scope(isolate); VboRef vbo; if(args.Length() == 2){ VboRef vbo = Vbo::create( args[1]->ToUint32()->Value() // GLenum target ); } else if(args.Length() == 4){ // TODO: Support other array data types as well if(args[2]->IsNumber()){ vbo = Vbo::create( args[1]->ToUint32()->Value(), args[2]->ToUint32()->Value(), nullptr, args[3]->ToUint32()->Value() ); } else { Local<Float32Array> data = args[2].As<Float32Array>(); // GLenum target, GLsizeiptr allocationSize, const void *data, GLenum usage vbo = Vbo::create( args[1]->ToUint32()->Value(), data->ByteLength(), *data, args[3]->ToUint32()->Value() ); } } StaticFactory::put<Vbo>( isolate, vbo, args[0]->ToObject() ); // TODO: throw isolate error on wrong arguments return; }
void HumixFaceRec::StartCam(const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Integer> devInt = info[0].As<v8::Integer>(); if (mVideoCap != NULL) { //restart the capture by delete the old one delete mVideoCap; } // Get a handle to the Video device: mVideoCap = new VideoCapture(devInt->Value()); mVideoCap->set(CV_CAP_PROP_FRAME_WIDTH, 640); mVideoCap->set(CV_CAP_PROP_FRAME_HEIGHT, 480); // sleep 1 sec, waiting for camera warmup printf("waiting for camera.. %d\n", devInt->Value()); sleep(1); if (!mVideoCap->isOpened()) { return info.GetReturnValue().Set(false); } info.GetReturnValue().Set(true); }
void V8HTMLAllCollection::namedItemMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]); HTMLAllCollection* imp = V8HTMLAllCollection::toNative(info.Holder()); v8::Handle<v8::Value> result = getNamedItems(imp, name, info); if (result.IsEmpty()) { v8SetReturnValueNull(info); return; } v8SetReturnValue(info, result); }
void V8MutationObserver::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ConstructionContext, "MutationObserver", info.Holder(), info.GetIsolate()); if (info.Length() < 1) { exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length())); exceptionState.throwIfNeeded(); return; } v8::Local<v8::Value> arg = info[0]; if (!arg->IsFunction()) { exceptionState.throwTypeError("Callback argument must be a function"); exceptionState.throwIfNeeded(); return; } v8::Local<v8::Object> wrapper = info.Holder(); RawPtr<MutationCallback> callback = V8MutationCallback::create(v8::Local<v8::Function>::Cast(arg), wrapper, ScriptState::current(info.GetIsolate())); RawPtr<MutationObserver> observer = MutationObserver::create(callback.release()); v8SetReturnValue(info, V8DOMWrapper::associateObjectWithWrapper(info.GetIsolate(), observer.get(), &wrapperTypeInfo, wrapper)); }
void UnZip_Wrap::New(const v8::FunctionCallbackInfo<v8::Value>& args) { Isolate* isolate = Isolate::GetCurrent(); HandleScope scope(isolate); if (args.IsConstructCall()) { // Invoked as constructor: `new UnZip_Wrap(...)` UnZip_Wrap* obj = nullptr; if(args.Length()>1) { if(args[0]->IsString() && args[1]->IsString()) { Local<String> fileName = args[0]->ToString(),folder = args[1]->ToString(); obj = new UnZip_Wrap(fileName,folder); } } else { //error goes here } if ( obj != nullptr ) { obj->Wrap(args.This()); args.GetReturnValue().Set(args.This()); } } }
void JsVlcVideo::jsCreate( const v8::FunctionCallbackInfo<v8::Value>& args ) { using namespace v8; Isolate* isolate = Isolate::GetCurrent(); HandleScope scope( isolate ); Local<Object> thisObject = args.Holder(); if( args.IsConstructCall() && thisObject->InternalFieldCount() > 0 ) { JsVlcPlayer* jsPlayer = ObjectWrap::Unwrap<JsVlcPlayer>( Handle<Object>::Cast( args[0] ) ); if( jsPlayer ) { JsVlcVideo* jsPlaylist = new JsVlcVideo( thisObject, jsPlayer ); args.GetReturnValue().Set( thisObject ); } } else { Local<Function> constructor = Local<Function>::New( isolate, _jsConstructor ); Local<Value> argv[] = { args[0] }; args.GetReturnValue().Set( constructor->NewInstance( sizeof( argv ) / sizeof( argv[0] ), argv ) ); } }
void JsVlcPlayer::jsCreate( const v8::FunctionCallbackInfo<v8::Value>& args ) { using namespace v8; Isolate* isolate = Isolate::GetCurrent(); HandleScope scope( isolate ); Local<Object> thisObject = args.Holder(); if( args.IsConstructCall() ) { Local<Array> options; if( args.Length() == 1 && args[0]->IsArray() ) { options = Local<Array>::Cast( args[0] ); } JsVlcPlayer* jsPlayer = new JsVlcPlayer( thisObject, options ); args.GetReturnValue().Set( jsPlayer->handle() ); } else { Local<Value> argv[] = { args[0] }; Local<Function> constructor = Local<Function>::New( isolate, _jsConstructor ); args.GetReturnValue().Set( constructor->NewInstance( sizeof( argv ) / sizeof( argv[0] ), argv ) ); } }
static void typeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); SVGTestInterface* impl = V8SVGTestInterface::toImpl(holder); // Skip on compact node DOMString getters. V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; // Prepare the value to be set. V8StringResource<> cppValue = v8Value; if (!cppValue.prepare()) return; impl->setAttribute(SVGNames::typeAttr, cppValue); }
static void voidMethodDocumentMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodDocument", "TestInterface3", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 2)) { setMinimumArityTypeError(exceptionState, 2, info.Length()); exceptionState.throwIfNeeded(); return; } Document* document; double d; { document = V8Document::toImplWithTypeCheck(info.GetIsolate(), info[0]); if (!document) { exceptionState.throwTypeError("parameter 1 is not of type 'Document'."); exceptionState.throwIfNeeded(); return; } d = toRestrictedDouble(info.GetIsolate(), info[1], exceptionState); if (exceptionState.throwIfNeeded()) return; } TestPartialInterface4::voidMethodDocument(document, d); }
void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "add", "HTMLOptionsCollection", info.Holder(), info.GetIsolate()); if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { exceptionState.throwTypeError("The element provided was not an HTMLOptionElement."); } else { HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()); HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Object>(v8::Handle<v8::Object>::Cast(info[0]))); if (info.Length() < 2) { imp->add(option, exceptionState); } else { bool ok; V8TRYCATCH_VOID(int, index, toInt32(info[1], ok)); if (!ok) exceptionState.throwTypeError("The index provided could not be interpreted as an integer."); else imp->add(option, index, exceptionState); } } exceptionState.throwIfNeeded(); }
result_t path_base::join(const v8::FunctionCallbackInfo<v8::Value> &args, exlib::string &retVal) { exlib::string strBuffer; int32_t argc = args.Length(); int32_t i; for (i = 0; i < argc; i++) { v8::String::Utf8Value s(args[i]); pathAdd(strBuffer, *s); } return normalize(strBuffer, retVal); }
//v8::Handle<v8::Value> Execvp(const v8::Arguments& args) { void Execvp(const v8::FunctionCallbackInfo<v8::Value>& args) { //v8::HandleScope scope; v8::Isolate* isolate = args.GetIsolate(); // check input std::vector<std::string> str_vec = detail::parse_arguments(isolate, args); if(str_vec.size() == 0) { //return scope.Close(v8::Integer::New(-1)); args.GetReturnValue().Set(v8::Integer::New(isolate, -1)); return; } std::vector<char*> argv = detail::to_argv(str_vec); // get ready for the exec int status; detail::unset_cloexec(0); detail::unset_cloexec(1); detail::unset_cloexec(2); detail::handle_error(status = execvp(argv[0], &argv[0]), "execvp"); //return scope.Close(v8::Integer::New(status)); args.GetReturnValue().Set(v8::Integer::New(isolate, status)); }
static void partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "partial2VoidMethod", "TestInterface", info.Holder(), info.GetIsolate()); switch (std::min(1, info.Length())) { case 0: break; case 1: if (V8Node::hasInstance(info[0], info.GetIsolate())) { partial2VoidMethod3Method(info); return; } if (true) { partial2VoidMethod2Method(info); return; } break; default: break; } exceptionState.throwTypeError("No function was found that matched the signature provided."); exceptionState.throwIfNeeded(); return; }
void V8InjectedScriptHost::evalCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); if (info.Length() < 1) { isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "One argument expected."))); return; } v8::Local<v8::String> expression = info[0]->ToString(isolate); if (expression.IsEmpty()) { isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "The argument must be a string."))); return; } ASSERT(isolate->InContext()); v8::TryCatch tryCatch(isolate); v8::Local<v8::Value> result; if (!v8Call(V8ScriptRunner::compileAndRunInternalScript(expression, info.GetIsolate()), result, tryCatch)) { v8SetReturnValue(info, tryCatch.ReThrow()); return; } v8SetReturnValue(info, result); }
static void deleteMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "delete", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 1)) { setMinimumArityTypeError(exceptionState, 1, info.Length()); exceptionState.throwIfNeeded(); return; } TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder()); V8StringResource<> value; { value = info[0]; if (!value.prepare()) return; } ScriptState* scriptState = ScriptState::current(info.GetIsolate()); bool result = impl->deleteForBinding(scriptState, value, exceptionState); if (exceptionState.hadException()) { exceptionState.throwIfNeeded(); return; } v8SetReturnValueBool(info, result); }
static void constructor4(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor", info.Holder(), info.GetIsolate()); V8StringResource<> arg; V8StringResource<> arg2; V8StringResource<> arg3; { TOSTRING_VOID_INTERNAL(arg, info[0]); TOSTRING_VOID_INTERNAL(arg2, info[1]); TOSTRING_VOID_INTERNAL(arg3, info[2]); } ScriptState* scriptState = ScriptState::current(info.GetIsolate()); ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()); Document& document = *toDocument(currentExecutionContext(info.GetIsolate())); RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(scriptState, executionContext, document, arg, arg2, arg3, exceptionState); if (exceptionState.hadException()) { exceptionState.throwIfNeeded(); return; } v8::Local<v8::Object> wrapper = info.Holder(); impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper); v8SetReturnValue(info, wrapper); }
int TNodeJsUtil::GetArgInt32(const v8::FunctionCallbackInfo<v8::Value>& Args, const int& ArgN, const TStr& Property) { v8::Isolate* Isolate = v8::Isolate::GetCurrent(); v8::HandleScope HandleScope(Isolate); EAssertR(Args.Length() > ArgN, "insufficient number of arguments!"); EAssertR(Args[ArgN]->IsObject() && Args[ArgN]->ToObject()->Has(v8::String::NewFromUtf8(Isolate, Property.CStr())), TStr::Fmt("Argument %d, missing property %s", ArgN, Property.CStr()).CStr()); v8::Handle<v8::Value> Val = Args[ArgN]->ToObject()->Get(v8::String::NewFromUtf8(Isolate, Property.CStr())); bool IsInt = Val->IsInt32(); EAssertR(IsInt, TStr::Fmt("Argument %d, property %s expected to be int32", ArgN, Property.CStr()).CStr()); return Val->ToNumber()->Int32Value(); }
void DeviceNode::GetMethods(const v8::FunctionCallbackInfo<v8::Value>& args) { Isolate* isolate = Isolate::GetCurrent(); HandleScope scope(isolate); Device* device = getDeviceBinding(args)->_device; std::vector<std::string> m = device->getMethods(); v8::Handle<v8::Array> methods = Array::New(isolate); int i=0; for (std::vector<std::string>::iterator it = m.begin(); it != m.end(); ++it) { methods->Set(i++, String::NewFromUtf8(isolate, (*it).c_str())); } args.GetReturnValue().Set(methods); }
double TNodeJsUtil::GetArgFlt(const v8::FunctionCallbackInfo<v8::Value>& Args, const int& ArgN, const TStr& Property, const double& DefVal) { v8::Isolate* Isolate = v8::Isolate::GetCurrent(); v8::HandleScope HandleScope(Isolate); if (Args.Length() > ArgN) { if (Args[ArgN]->IsObject() && Args[ArgN]->ToObject()->Has(v8::String::NewFromUtf8(Isolate, Property.CStr()))) { v8::Handle<v8::Value> Val = Args[ArgN]->ToObject()->Get(v8::String::NewFromUtf8(Isolate, Property.CStr())); EAssertR(Val->IsNumber(), TStr::Fmt("Argument %d, property %s expected to be number", ArgN, Property.CStr()).CStr()); return Val->NumberValue(); } } return DefVal; }
void TNodeJsFs::fileInfo(const v8::FunctionCallbackInfo<v8::Value>& Args) { v8::Isolate* Isolate = v8::Isolate::GetCurrent(); v8::HandleScope HandleScope(Isolate); EAssertR(Args.Length() == 1 && Args[0]->IsString(), "Expected a file path as the only argument."); TStr FNm(*v8::String::Utf8Value(Args[0]->ToString())); EAssertR(TFile::Exists(FNm), TStr("File '" + FNm + "' does not exist").CStr()); const uint64 CreateTm = TFile::GetCreateTm(FNm); const uint64 LastAccessTm = TFile::GetLastAccessTm(FNm); const uint64 LastWriteTm = TFile::GetLastWriteTm(FNm); const uint64 Size = TFile::GetSize(FNm); v8::Handle<v8::Object> Obj = v8::Object::New(Isolate); Obj->Set(v8::String::NewFromUtf8(Isolate, "createTime"), v8::String::NewFromUtf8(Isolate, TTm::GetTmFromMSecs(CreateTm).GetWebLogDateTimeStr().CStr())); Obj->Set(v8::String::NewFromUtf8(Isolate, "lastAccessTime"), v8::String::NewFromUtf8(Isolate, TTm::GetTmFromMSecs(LastAccessTm).GetWebLogDateTimeStr().CStr())); Obj->Set(v8::String::NewFromUtf8(Isolate, "lastWriteTime"), v8::String::NewFromUtf8(Isolate, TTm::GetTmFromMSecs(LastWriteTm).GetWebLogDateTimeStr().CStr())); Obj->Set(v8::String::NewFromUtf8(Isolate, "size"), v8::Number::New(Isolate, static_cast<double>(Size))); Args.GetReturnValue().Set(Obj); }
void TNodeJsFs::listFile(const v8::FunctionCallbackInfo<v8::Value>& Args) { v8::Isolate* Isolate = v8::Isolate::GetCurrent(); v8::HandleScope HandleScope(Isolate); EAssertR(Args.Length() >= 1 && Args[0]->IsString(), "Expected directory path as the first argument."); // Read parameters TStr FPath(*v8::String::Utf8Value(Args[0]->ToString())); TStrV FExtV; if (Args.Length() >= 2 && Args[1]->IsString()) { FExtV.Add(TStr(*v8::String::Utf8Value(Args[1]->ToString()))); } const bool RecurseP = Args.Length() >= 3 && Args[2]->IsBoolean() && Args[2]->BooleanValue(); // Get file list TStrV FNmV; TFFile::GetFNmV(FPath, FExtV, RecurseP, FNmV); FNmV.Sort(); v8::Handle<v8::Array> FNmArr = v8::Array::New(Isolate, FNmV.Len()); for(int FldN = 0; FldN < FNmV.Len(); ++FldN) { FNmArr->Set(v8::Integer::New(Isolate, FldN), v8::String::NewFromUtf8(Isolate, FNmV.GetVal(FldN).CStr())); } Args.GetReturnValue().Set(FNmArr); }
void context::run_file(v8::FunctionCallbackInfo<v8::Value> const& args) { v8::Isolate* isolate = args.GetIsolate(); v8::EscapableHandleScope scope(isolate); v8::Local<v8::Value> result; try { std::string const filename = from_v8<std::string>(isolate, args[0], ""); if (filename.empty()) { throw std::runtime_error("run_file: require filename string argument"); } context* ctx = detail::get_external_data<context*>(args.Data()); result = to_v8(isolate, ctx->run_file(filename)); } catch (std::exception const& ex) { result = throw_ex(isolate, ex.what()); } args.GetReturnValue().Set(scope.Escape(result)); }
static void namedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { if (UNLIKELY(info.Length() < 1)) { throwTypeError(ExceptionMessages::failedToExecute("namedItem", "TestInterface", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); return; } TestInterface* impl = V8TestInterface::toNative(info.Holder()); V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]); bool result0Enabled = false; RefPtr<Node> result0; bool result1Enabled = false; RefPtr<NodeList> result1; impl->getItem(name, result0Enabled, result0, result1Enabled, result1); if (result0Enabled) { v8SetReturnValue(info, result0.release()); return; } if (result1Enabled) { v8SetReturnValue(info, result1.release()); return; } v8SetReturnValueNull(info); }
void NativePlatform::AppInitCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { try { auto isolate = Isolate::GetCurrent(); if (args.Length() != 1) { throw NativeScriptException(string("Application should be initialized with single parameter")); } if (!args[0]->IsObject()) { throw NativeScriptException(string("Application should be initialized with single object parameter containing overridden methods")); } // TODO: find another way to get "com/tns/NativeScriptApplication" metadata (move it to more appropriate place) auto node = MetadataNode::GetOrCreate("com/tns/NativeScriptApplication"); auto appInstance = node->CreateJSWrapper(isolate); DEBUG_WRITE("Application object created id: %d", appInstance->GetIdentityHash()); auto implementationObject = args[0]->ToObject(); implementationObject->SetHiddenValue(V8StringConstants::GetClassImplementationObject(), External::New(isolate, node)); DEBUG_WRITE("Application object implementation object is with id: %d", implementationObject->GetIdentityHash()); implementationObject->SetPrototype(appInstance->GetPrototype()); bool appSuccess = appInstance->SetPrototype(implementationObject); if (!appSuccess) { throw NativeScriptException(string("Application could not be initialized correctly")); } jweak applicationObject = g_objectManager->GetJavaObjectByID(AppJavaObjectID); JEnv env; jclass appClass = env.FindClass("com/tns/NativeScriptApplication"); g_objectManager->Link(appInstance, AppJavaObjectID, appClass); JniLocalRef applicationClass(env.GetObjectClass(applicationObject)); jmethodID setNativeScriptOverridesMethodId = env.GetMethodID((jclass)applicationClass, "setNativeScriptOverrides", "([Ljava/lang/String;)V"); jobjectArray methodOverrides = NativeScriptRuntime::GetMethodOverrides(env, implementationObject); env.CallVoidMethod(applicationObject, setNativeScriptOverridesMethodId, methodOverrides); } catch (NativeScriptException& e) { e.ReThrowToV8(); } catch (exception e) { DEBUG_WRITE("Error: c++ exception: %s", e.what()); } catch (...) { DEBUG_WRITE("Error: c++ exception!"); } }
// The callback that is invoked by v8 whenever the JavaScript 'read' // function is called. This function loads the content of the file named in // the argument into a JavaScript string. void Read(const v8::FunctionCallbackInfo<v8::Value>& args) { if (args.Length() != 1) { args.GetIsolate()->ThrowException( v8::String::NewFromUtf8(args.GetIsolate(), "Bad parameters")); return; } v8::String::Utf8Value file(args[0]); if (*file == NULL) { args.GetIsolate()->ThrowException( v8::String::NewFromUtf8(args.GetIsolate(), "Error loading file")); return; } v8::Handle<v8::String> source = ReadFile(args.GetIsolate(), *file); if (source.IsEmpty()) { args.GetIsolate()->ThrowException( v8::String::NewFromUtf8(args.GetIsolate(), "Error loading file")); return; } args.GetReturnValue().Set(source); }
void JSVideoFrameConstructor(const v8::FunctionCallbackInfo<v8::Value> &args) { TRACE("Attempt to construct video frame\n"); if (!args.IsConstructCall()) { TRACE("Ignoring direct call to constructor.\n"); // I'm not sure if this would get called in a "super" constructor if something were // to try and "extend" a video frame. return; } if (args.Length() == 1) { // In this case, the argument must be an external marking this as an // "internal" call to create a video frame. if (args[0]->IsExternal()) { // The external is a ProtoVideoFrame and is used to construct our "real" value. ProtoVideoFrame* proto = UnwrapExternal<ProtoVideoFrame>(args[0]); // I guess you can use "duck" typing in C++! new C(proto->frame, proto->vi, args.GetIsolate(), args.This()); return; } } else if (args.Length() == 3) { // Allowed arguments for this are: } // Eventually, we may allow creating a frame in this fashion. For now: v8::ThrowException(v8::Exception::Error(v8::String::New("Cannot construct video frame directly"))); }
bool TNodeJsUtil::GetArgBool(const v8::FunctionCallbackInfo<v8::Value>& Args, const int& ArgN, const TStr& Property, const bool& DefVal) { v8::Isolate* Isolate = v8::Isolate::GetCurrent(); v8::HandleScope HandleScope(Isolate); if (Args.Length() > ArgN) { if (Args[ArgN]->IsObject() && Args[ArgN]->ToObject()->Has(v8::String::NewFromUtf8(Isolate, Property.CStr()))) { v8::Handle<v8::Value> Val = Args[ArgN]->ToObject()->Get(v8::String::NewFromUtf8(Isolate, Property.CStr())); EAssertR(Val->IsBoolean(), TStr::Fmt("Argument %d, property %s expected to be boolean", ArgN, Property.CStr()).CStr()); v8::Local<v8::BooleanObject> BoolObj = v8::Local<v8::BooleanObject>::Cast(Val->ToObject()); return static_cast<bool>(BoolObj->ValueOf()); } } return DefVal; }
void Profiler::StopCPUProfilerCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { try { auto isolate = args.GetIsolate(); auto extData = args.Data().As<External>(); auto thiz = static_cast<Profiler*>(extData->Value()); thiz->StopCPUProfilerCallbackImpl(args); } catch (NativeScriptException& e) { e.ReThrowToV8(); } catch (std::exception e) { stringstream ss; ss << "Error: c++ exception: " << e.what() << endl; NativeScriptException nsEx(ss.str()); nsEx.ReThrowToV8(); } catch (...) { NativeScriptException nsEx(std::string("Error: c++ exception!")); nsEx.ReThrowToV8(); } }
void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) { DOMWindow* impl = V8Window::toNative(args.Holder()); if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame())) return; // FIXME: Handle exceptions properly. String urlString = toWebCoreStringWithUndefinedOrNullCheck(args[0]); DialogHandler handler(args[1]); String dialogFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(args[2]); impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(), firstDOMWindow(), setUpDialog, &handler); v8SetReturnValue(args, handler.returnValue()); }
// This custom binding is shared by V8WorkerCrypto. As such: // * Do not call V8Crypto::toNative() // * Must be threadsafe void V8Crypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRandomValues", "Crypto", info.Holder(), info.GetIsolate()); if (info.Length() < 1) { exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length())); exceptionState.throwIfNeeded(); return; } v8::Handle<v8::Value> buffer = info[0]; if (!V8ArrayBufferView::hasInstance(buffer, info.GetIsolate())) { exceptionState.throwTypeError("First argument is not an ArrayBufferView"); } else { ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(buffer)); ASSERT(arrayBufferView); Crypto::getRandomValues(arrayBufferView, exceptionState); } if (exceptionState.throwIfNeeded()) return; v8SetReturnValue(info, buffer); }