当前位置: 首页>>代码示例>>C++>>正文


C++ Persistent::Get方法代码示例

本文整理汇总了C++中v8::Persistent::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ Persistent::Get方法的具体用法?C++ Persistent::Get怎么用?C++ Persistent::Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在v8::Persistent的用法示例。


在下文中一共展示了Persistent::Get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: invokeCallback

bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext)
{
    v8::TryCatch exceptionCatcher;
    exceptionCatcher.SetVerbose(true);

    v8::Local<v8::Function> callbackFunction;
    if (callback->IsFunction()) {
        callbackFunction = v8::Local<v8::Function>::New(v8::Persistent<v8::Function>::Cast(callback));
    } else if (callback->IsObject()) {
        v8::Local<v8::Value> handleEventFunction = callback->Get(v8::String::NewSymbol("handleEvent"));
        if (handleEventFunction->IsFunction())
            callbackFunction = v8::Local<v8::Function>::Cast(handleEventFunction);
    } else
        return false;

    if (callbackFunction.IsEmpty())
        return false;

    v8::Handle<v8::Object> thisObject = v8::Context::GetCurrent()->Global();

    Frame* frame = scriptExecutionContext && scriptExecutionContext->isDocument() ? static_cast<Document*>(scriptExecutionContext)->frame() : 0;
    v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction(frame, callbackFunction, thisObject, argc, argv);

    callbackReturnValue = !result.IsEmpty() && result->BooleanValue();
    return exceptionCatcher.HasCaught();
}
开发者ID:paul99,项目名称:third_party,代码行数:26,代码来源:V8CustomVoidCallback.cpp

示例2: invokeCallback

bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue)
{
    // FIXME: If an exception was thrown by the callback, we should report it
    v8::TryCatch exceptionCatcher;

    v8::Local<v8::Function> callbackFunction;
    if (callback->IsFunction()) {
        callbackFunction = v8::Local<v8::Function>::New(v8::Persistent<v8::Function>::Cast(callback));
    } else if (callback->IsObject()) {
        v8::Local<v8::Value> handleEventFunction = callback->Get(v8::String::NewSymbol("handleEvent"));
        if (handleEventFunction->IsFunction()) {
            callbackFunction = v8::Local<v8::Function>::Cast(handleEventFunction);
        }
    } else
        return false;

    if (callbackFunction.IsEmpty())
        return false;

    v8::Handle<v8::Object> thisObject = v8::Context::GetCurrent()->Global();

    V8Proxy* proxy = V8Proxy::retrieve();
    ASSERT(proxy);

    v8::Handle<v8::Value> result = proxy->CallFunction(callbackFunction, thisObject, argc, argv);

    callbackReturnValue = result.IsEmpty() && result->IsBoolean() && result->BooleanValue();

    return exceptionCatcher.HasCaught();
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:30,代码来源:V8CustomVoidCallback.cpp

示例3: invokeCallback

bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext)
{
    v8::TryCatch exceptionCatcher;

    v8::Local<v8::Function> callbackFunction;
    if (callback->IsFunction()) {
        callbackFunction = v8::Local<v8::Function>::New(v8::Persistent<v8::Function>::Cast(callback));
    } else if (callback->IsObject()) {
        v8::Local<v8::Value> handleEventFunction = callback->Get(v8::String::NewSymbol("handleEvent"));
        if (handleEventFunction->IsFunction())
            callbackFunction = v8::Local<v8::Function>::Cast(handleEventFunction);
    } else
        return false;

    if (callbackFunction.IsEmpty())
        return false;

    v8::Handle<v8::Object> thisObject = v8::Context::GetCurrent()->Global();

    v8::Handle<v8::Value> result = callbackFunction->Call(thisObject, argc, argv);
    callbackReturnValue = !result.IsEmpty() && result->BooleanValue();

    if (exceptionCatcher.HasCaught()) {
        v8::Local<v8::Message> message = exceptionCatcher.Message();
        scriptExecutionContext->reportException(toWebCoreString(message->Get()), message->GetLineNumber(), toWebCoreString(message->GetScriptResourceName()));
        return true;
    }

    return false;
}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:30,代码来源:V8CustomVoidCallback.cpp

示例4: assert

    v8::Handle<v8::Value> create_js_box(const osmium::Box& box) {
        v8::HandleScope scope;

        if (!box.valid()) {
            return scope.Close(v8::Undefined());
        }

        auto cf = module->Get(symbol_Coordinates);
        assert(cf->IsFunction());
        auto bf = module->Get(symbol_Box);
        assert(bf->IsFunction());

        v8::Local<v8::Value> argv_bl[2] = { v8::Number::New(box.bottom_left().lon()), v8::Number::New(box.bottom_left().lat()) };
        auto bottom_left = v8::Local<v8::Function>::Cast(cf)->NewInstance(2, argv_bl);

        v8::Local<v8::Value> argv_tr[2] = { v8::Number::New(box.top_right().lon()), v8::Number::New(box.top_right().lat()) };
        auto top_right = v8::Local<v8::Function>::Cast(cf)->NewInstance(2, argv_tr);

        v8::Local<v8::Value> argv_box[2] = { bottom_left, top_right };
        return scope.Close(v8::Local<v8::Function>::Cast(bf)->NewInstance(2, argv_box));
    }
开发者ID:aaronpdennis,项目名称:node-osmium,代码行数:21,代码来源:utils.cpp

示例5: assert

    v8::Handle<v8::Value> OSMNodeWrap::get_coordinates(v8::Local<v8::String> /* property */, const v8::AccessorInfo& info) {
        v8::HandleScope scope;

        auto cf = module->Get(v8::String::NewSymbol("Coordinates"));
        assert(cf->IsFunction());

        const osmium::Location& location = wrapped(info.This()).location();
        if (!location) {
            return scope.Close(v8::Local<v8::Function>::Cast(cf)->NewInstance());
        }

        v8::Local<v8::Value> lon = v8::Number::New(location.lon_without_check());
        v8::Local<v8::Value> lat = v8::Number::New(location.lat_without_check());
        v8::Local<v8::Value> argv[2] = { lon, lat };
        return scope.Close(v8::Local<v8::Function>::Cast(cf)->NewInstance(2, argv));
    }
开发者ID:morganherlocker,项目名称:node-osmium,代码行数:16,代码来源:osm_node_wrap.cpp


注:本文中的v8::Persistent::Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。