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


C++ ErrorEvent::world方法代码示例

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


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

示例1: getListenerObject

v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(v8::Handle<v8::Value> jsEvent, Event* event)
{
    if (!event->hasInterface(EventNames::ErrorEvent))
        return V8EventListener::callListenerFunction(jsEvent, event);

    ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);

    if (errorEvent->world() && errorEvent->world() != &world())
        return v8::Null(isolate());

    v8::Local<v8::Object> listener = getListenerObject(scriptState()->executionContext());
    v8::Local<v8::Value> returnValue;
    if (!listener.IsEmpty() && listener->IsFunction()) {
        v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
        v8::Local<v8::Object> thisValue = scriptState()->context()->Global();

        v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), jsEvent->ToObject(), V8HiddenValue::error(isolate()));
        if (error.IsEmpty())
            error = v8::Null(isolate());

        v8::Handle<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->message()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolate(), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), error };
        v8::TryCatch tryCatch;
        tryCatch.SetVerbose(true);
        returnValue = ScriptController::callFunction(scriptState()->executionContext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate());
    }
    return returnValue;
}
开发者ID:dalecurtis,项目名称:mojo,代码行数:27,代码来源:V8ErrorHandler.cpp

示例2: tryCatch

v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(
    ScriptState* scriptState,
    v8::Local<v8::Value> jsEvent,
    Event* event) {
  ASSERT(!jsEvent.IsEmpty());
  if (!event->hasInterface(EventNames::ErrorEvent))
    return V8EventListener::callListenerFunction(scriptState, jsEvent, event);

  ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
  if (errorEvent->world() && errorEvent->world() != &world())
    return v8::Null(isolate());

  v8::Local<v8::Object> listener =
      getListenerObject(scriptState->getExecutionContext());
  if (listener.IsEmpty() || !listener->IsFunction())
    return v8::Null(isolate());

  v8::Local<v8::Function> callFunction =
      v8::Local<v8::Function>::Cast(listener);
  v8::Local<v8::Object> thisValue = scriptState->context()->Global();

  v8::Local<v8::Object> eventObject;
  if (!jsEvent->ToObject(scriptState->context()).ToLocal(&eventObject))
    return v8::Null(isolate());
  auto privateError = V8PrivateProperty::getErrorEventError(isolate());
  v8::Local<v8::Value> error =
      privateError.getOrUndefined(scriptState->context(), eventObject);
  if (error->IsUndefined())
    error = v8::Null(isolate());

  v8::Local<v8::Value> parameters[5] = {
      v8String(isolate(), errorEvent->message()),
      v8String(isolate(), errorEvent->filename()),
      v8::Integer::New(isolate(), errorEvent->lineno()),
      v8::Integer::New(isolate(), errorEvent->colno()), error};
  v8::TryCatch tryCatch(isolate());
  tryCatch.SetVerbose(true);
  v8::MaybeLocal<v8::Value> result;
  if (scriptState->getExecutionContext()->isWorkerGlobalScope()) {
    result = V8ScriptRunner::callFunction(
        callFunction, scriptState->getExecutionContext(), thisValue,
        WTF_ARRAY_LENGTH(parameters), parameters, isolate());
  } else {
    result = V8ScriptRunner::callFunction(
        callFunction, scriptState->getExecutionContext(), thisValue,
        WTF_ARRAY_LENGTH(parameters), parameters, isolate());
  }
  v8::Local<v8::Value> returnValue;
  if (!result.ToLocal(&returnValue))
    return v8::Null(isolate());

  return returnValue;
}
开发者ID:mirror,项目名称:chromium,代码行数:53,代码来源:V8ErrorHandler.cpp


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