本文整理汇总了C++中v8::Handle::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::IsEmpty方法的具体用法?C++ Handle::IsEmpty怎么用?C++ Handle::IsEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v8::Handle
的用法示例。
在下文中一共展示了Handle::IsEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: then
ScriptPromise ScriptPromise::then(v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected)
{
if (m_promise.isEmpty())
return ScriptPromise();
v8::Local<v8::Object> promise = m_promise.v8Value().As<v8::Object>();
ASSERT(promise->IsPromise());
// Return this Promise if no handlers are given.
// In fact it is not the exact bahavior of Promise.prototype.then
// but that is not a problem in this case.
v8::Local<v8::Promise> resultPromise = promise.As<v8::Promise>();
if (!onFulfilled.IsEmpty()) {
resultPromise = resultPromise->Then(onFulfilled);
if (resultPromise.IsEmpty()) {
// v8::Promise::Then may return an empty value, for example when
// the stack is exhausted.
return ScriptPromise();
}
}
if (!onRejected.IsEmpty())
resultPromise = resultPromise->Catch(onRejected);
return ScriptPromise(m_scriptState.get(), resultPromise);
}
示例2: addToDerived
// Add a tuple (|derivedPromise|, |onFulfilled|, |onRejected|) to
// |internal|'s derived array.
// |internal| must be a Promise internal object.
// |derivedPromise| must be a Promise instance.
// |onFulfilled| and |onRejected| can be an empty value respectively.
void addToDerived(v8::Handle<v8::Object> internal, v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Isolate* isolate)
{
v8::Local<v8::Array> fulfillCallbacks = internal->GetInternalField(V8PromiseCustom::InternalFulfillCallbackIndex).As<v8::Array>();
v8::Local<v8::Array> rejectCallbacks = internal->GetInternalField(V8PromiseCustom::InternalRejectCallbackIndex).As<v8::Array>();
v8::Local<v8::Array> derivedPromises = internal->GetInternalField(V8PromiseCustom::InternalDerivedPromiseIndex).As<v8::Array>();
if (onFulfilled.IsEmpty()) {
fulfillCallbacks->Set(fulfillCallbacks->Length(), v8::Undefined(isolate));
} else {
fulfillCallbacks->Set(fulfillCallbacks->Length(), onFulfilled);
}
if (onRejected.IsEmpty()) {
rejectCallbacks->Set(rejectCallbacks->Length(), v8::Undefined(isolate));
} else {
rejectCallbacks->Set(rejectCallbacks->Length(), onRejected);
}
ASSERT(!derivedPromise.IsEmpty());
derivedPromises->Set(derivedPromises->Length(), derivedPromise);
// Since they are treated as a tuple,
// we need to guaranteed that the length of these arrays are same.
ASSERT(fulfillCallbacks->Length() == rejectCallbacks->Length() && rejectCallbacks->Length() == derivedPromises->Length());
}
示例3: RangeError
v8::Local<v8::Value> WorkerContextExecutionProxy::runScript(v8::Handle<v8::Script> script)
{
if (script.IsEmpty())
return v8::Local<v8::Value>();
// Compute the source string and prevent against infinite recursion.
if (m_recursion >= kMaxRecursionDepth) {
v8::Local<v8::String> code = v8ExternalString("throw RangeError('Recursion too deep')");
script = V8Proxy::compileScript(code, "", 0);
}
if (V8Proxy::handleOutOfMemory())
ASSERT(script.IsEmpty());
if (script.IsEmpty())
return v8::Local<v8::Value>();
// Run the script and keep track of the current recursion depth.
v8::Local<v8::Value> result;
{
m_recursion++;
result = script->Run();
m_recursion--;
}
// Handle V8 internal error situation (Out-of-memory).
if (result.IsEmpty())
return v8::Local<v8::Value>();
return result;
}
示例4: notHandledByInterceptor
v8::Local<v8::Value> V8Proxy::runScriptInternal(v8::Handle<v8::Script> script, bool isInlineCode)
#endif
{
if (script.IsEmpty())
return notHandledByInterceptor();
V8GCController::checkMemoryUsage();
// Compute the source string and prevent against infinite recursion.
if (m_recursion >= kMaxRecursionDepth) {
v8::Local<v8::String> code = v8ExternalString("throw RangeError('Recursion too deep')");
// FIXME: Ideally, we should be able to re-use the origin of the
// script passed to us as the argument instead of using an empty string
// and 0 baseLine.
script = compileScript(code, "", 0);
}
if (handleOutOfMemory())
ASSERT(script.IsEmpty());
if (script.IsEmpty())
return notHandledByInterceptor();
// Save the previous value of the inlineCode flag and update the flag for
// the duration of the script invocation.
bool previousInlineCode = inlineCode();
setInlineCode(isInlineCode);
// Run the script and keep track of the current recursion depth.
v8::Local<v8::Value> result;
{
V8ConsoleMessage::Scope scope;
// See comment in V8Proxy::callFunction.
m_frame->keepAlive();
m_recursion++;
result = script->Run();
m_recursion--;
}
// Release the storage mutex if applicable.
releaseStorageMutex();
if (handleOutOfMemory())
ASSERT(result.IsEmpty());
// Handle V8 internal error situation (Out-of-memory).
if (result.IsEmpty())
return notHandledByInterceptor();
// Restore inlineCode flag.
setInlineCode(previousInlineCode);
if (v8::V8::IsDead())
handleFatalErrorInV8();
return result;
}
示例5: dialogCreated
inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame)
{
m_dialogContext = V8Proxy::context(dialogFrame->frame());
if (m_dialogContext.IsEmpty())
return;
if (m_dialogArguments.IsEmpty())
return;
v8::Context::Scope scope(m_dialogContext);
m_dialogContext->Global()->Set(v8::String::New("dialogArguments"), m_dialogArguments);
}
示例6: dialogCreated
inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame)
{
m_dialogContext = dialogFrame->frame() ? dialogFrame->frame()->script()->currentWorldContext() : v8::Local<v8::Context>();
if (m_dialogContext.IsEmpty())
return;
if (m_dialogArguments.IsEmpty())
return;
v8::Context::Scope scope(m_dialogContext);
m_dialogContext->Global()->Set(v8::String::NewSymbol("dialogArguments"), m_dialogArguments);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:10,代码来源:V8WindowCustom.cpp
示例7: dialogCreated
inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame, v8::Isolate* isolate)
{
// FIXME: It's wrong to use the current world. Instead we should use the world
// from which the modal dialog was requested.
m_dialogContext = dialogFrame->frame() ? toV8Context(isolate, dialogFrame->frame(), DOMWrapperWorld::current(isolate)) : v8::Local<v8::Context>();
if (m_dialogContext.IsEmpty())
return;
if (m_dialogArguments.IsEmpty())
return;
v8::Context::Scope scope(m_dialogContext);
m_dialogContext->Global()->Set(v8AtomicString(isolate, "dialogArguments"), m_dialogArguments);
}
示例8: executeUtilityFunction
String DebuggerAgentImpl::executeUtilityFunction(
v8::Handle<v8::Context> context,
int callId,
const char* object,
const String &functionName,
const String& jsonArgs,
bool async,
String* exception)
{
v8::HandleScope scope;
ASSERT(!context.IsEmpty());
if (context.IsEmpty()) {
*exception = "No window context.";
return "";
}
v8::Context::Scope contextScope(context);
DebuggerAgentManager::UtilityContextScope utilityScope;
v8::Handle<v8::Object> dispatchObject = v8::Handle<v8::Object>::Cast(
context->Global()->Get(v8::String::New(object)));
v8::Handle<v8::Value> dispatchFunction = dispatchObject->Get(v8::String::New("dispatch"));
ASSERT(dispatchFunction->IsFunction());
v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(dispatchFunction);
v8::Handle<v8::String> functionNameWrapper = v8::Handle<v8::String>(
v8::String::New(functionName.utf8().data()));
v8::Handle<v8::String> jsonArgsWrapper = v8::Handle<v8::String>(
v8::String::New(jsonArgs.utf8().data()));
v8::Handle<v8::Number> callIdWrapper = v8::Handle<v8::Number>(
v8::Number::New(async ? callId : 0));
v8::Handle<v8::Value> args[] = {
functionNameWrapper,
jsonArgsWrapper,
callIdWrapper
};
v8::TryCatch tryCatch;
v8::Handle<v8::Value> resObj = function->Call(context->Global(), 3, args);
if (tryCatch.HasCaught()) {
v8::Local<v8::Message> message = tryCatch.Message();
if (message.IsEmpty())
*exception = "Unknown exception";
else
*exception = WebCore::toWebCoreString(message->Get());
return "";
}
return WebCore::toWebCoreStringWithNullCheck(resObj);
}
示例9: handleMaxRecursionDepthExceeded
v8::Local<v8::Value> ScriptRunner::runCompiledScript(v8::Handle<v8::Script> script, ScriptExecutionContext* context)
{
if (script.IsEmpty())
return v8::Local<v8::Value>();
V8GCController::checkMemoryUsage();
if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
return handleMaxRecursionDepthExceeded();
if (handleOutOfMemory())
return v8::Local<v8::Value>();
// Run the script and keep track of the current recursion depth.
v8::Local<v8::Value> result;
{
V8RecursionScope recursionScope(context);
result = script->Run();
}
if (handleOutOfMemory())
ASSERT(result.IsEmpty());
if (result.IsEmpty())
return v8::Local<v8::Value>();
crashIfV8IsDead();
return result;
}
示例10: createUpgradeCandidateWrapper
v8::Handle<v8::Object> CustomElementWrapper<ElementType, WrapperType>::wrap(PassRefPtrWillBeRawPtr<ElementType> element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, v8::Handle<v8::Object> (*createSpecificWrapper)(ElementType* element, v8::Handle<v8::Object> creationContext, v8::Isolate*))
{
ASSERT(DOMDataStore::getWrapper<V8Element>(element.get(), isolate).IsEmpty());
// FIXME: creationContext.IsEmpty() should never happen. Remove
// this when callers (like InspectorController::inspect) are fixed
// to never pass an empty creation context.
v8::Handle<v8::Context> context = creationContext.IsEmpty() ? isolate->GetCurrentContext() : creationContext->CreationContext();
if (!element->isUpgradedCustomElement() || DOMWrapperWorld::world(context).isIsolatedWorld())
return createUpgradeCandidateWrapper(element.get(), creationContext, isolate, createSpecificWrapper);
V8PerContextData* perContextData = V8PerContextData::from(context);
if (!perContextData)
return v8::Handle<v8::Object>();
CustomElementBinding* binding = perContextData->customElementBinding(element->customElementDefinition());
v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, binding->wrapperType(), element.get(), isolate);
if (wrapper.IsEmpty())
return v8::Handle<v8::Object>();
wrapper->SetPrototype(binding->prototype());
V8DOMWrapper::associateObjectWithWrapper<WrapperType>(element, binding->wrapperType(), wrapper, isolate, WrapperConfiguration::Dependent);
return wrapper;
}
示例11: CallbackType
static CustomElementLifecycleCallbacks::CallbackType flagSet(v8::Handle<v8::Function> attached, v8::Handle<v8::Function> detached, v8::Handle<v8::Function> attributeChanged)
{
// V8 Custom Elements always run created to swizzle prototypes.
int flags = CustomElementLifecycleCallbacks::Created;
if (!attached.IsEmpty())
flags |= CustomElementLifecycleCallbacks::Attached;
if (!detached.IsEmpty())
flags |= CustomElementLifecycleCallbacks::Detached;
if (!attributeChanged.IsEmpty())
flags |= CustomElementLifecycleCallbacks::AttributeChanged;
return CustomElementLifecycleCallbacks::CallbackType(flags);
}
示例12: handleMaxRecursionDepthExceeded
v8::Local<v8::Value> V8ScriptRunner::runCompiledScript(v8::Handle<v8::Script> script, ExecutionContext* context, v8::Isolate* isolate)
{
TRACE_EVENT0("v8", "v8.run");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution");
if (script.IsEmpty())
return v8::Local<v8::Value>();
if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth)
return handleMaxRecursionDepthExceeded(isolate);
RELEASE_ASSERT(!context->isIteratingOverObservers());
// Run the script and keep track of the current recursion depth.
v8::Local<v8::Value> result;
{
V8RecursionScope recursionScope(isolate, context);
result = script->Run();
}
if (result.IsEmpty())
return v8::Local<v8::Value>();
crashIfV8IsDead();
return result;
}
示例13: CallbackType
static CustomElementLifecycleCallbacks::CallbackType flagSet(v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged)
{
// V8 Custom Elements always run created to swizzle prototypes.
int flags = CustomElementLifecycleCallbacks::Created;
if (!enteredView.IsEmpty())
flags |= CustomElementLifecycleCallbacks::EnteredView;
if (!leftView.IsEmpty())
flags |= CustomElementLifecycleCallbacks::LeftView;
if (!attributeChanged.IsEmpty())
flags |= CustomElementLifecycleCallbacks::AttributeChanged;
return CustomElementLifecycleCallbacks::CallbackType(flags);
}
示例14: JS_SetPrivate
void JS_SetPrivate(IJS_Runtime* pJSRuntime, v8::Handle<v8::Object> pObj, void* p)
{
if(pObj.IsEmpty() || !pObj->InternalFieldCount()) return;
CJS_PrivateData* pPrivateData = (CJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0);
if(!pPrivateData) return;
pPrivateData->pPrivate = p;
}
示例15: installAttributes
v8::Local<v8::Signature> V8DOMConfiguration::installDOMClassTemplate(v8::Handle<v8::FunctionTemplate> functionDescriptor, const char* interfaceName, v8::Handle<v8::FunctionTemplate> parentClass, size_t fieldCount,
const AttributeConfiguration* attributes, size_t attributeCount,
const AccessorConfiguration* accessors, size_t accessorCount,
const MethodConfiguration* callbacks, size_t callbackCount,
v8::Isolate* isolate)
{
functionDescriptor->SetClassName(v8AtomicString(isolate, interfaceName));
v8::Local<v8::ObjectTemplate> instanceTemplate = functionDescriptor->InstanceTemplate();
instanceTemplate->SetInternalFieldCount(fieldCount);
if (!parentClass.IsEmpty()) {
functionDescriptor->Inherit(parentClass);
// Marks the prototype object as one of native-backed objects.
// This is needed since bug 110436 asks WebKit to tell native-initiated prototypes from pure-JS ones.
// This doesn't mark kinds "root" classes like Node, where setting this changes prototype chain structure.
v8::Local<v8::ObjectTemplate> prototype = functionDescriptor->PrototypeTemplate();
prototype->SetInternalFieldCount(v8PrototypeInternalFieldcount);
}
v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, functionDescriptor);
if (attributeCount)
installAttributes(instanceTemplate, functionDescriptor->PrototypeTemplate(), attributes, attributeCount, isolate);
if (accessorCount)
installAccessors(functionDescriptor->PrototypeTemplate(), defaultSignature, accessors, accessorCount, isolate);
if (callbackCount)
installCallbacks(functionDescriptor->PrototypeTemplate(), defaultSignature, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callbackCount, isolate);
return defaultSignature;
}