本文整理汇总了C++中v8::Persistent::IsFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ Persistent::IsFunction方法的具体用法?C++ Persistent::IsFunction怎么用?C++ Persistent::IsFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v8::Persistent
的用法示例。
在下文中一共展示了Persistent::IsFunction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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();
}
示例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;
}