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


C++ Isolate::ThrowException方法代码示例

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


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

示例1: Serialize

void ABPFilterParserWrap::Serialize(const FunctionCallbackInfo<Value>& args) {
  Isolate* isolate = args.GetIsolate();
  ABPFilterParserWrap* obj =
    ObjectWrap::Unwrap<ABPFilterParserWrap>(args.Holder());

  int totalSize = 0;
  // Serialize data
  char* data = obj->serialize(&totalSize);
  if (nullptr == data) {
    isolate->ThrowException(Exception::TypeError(
      String::NewFromUtf8(isolate, "Could not serialize")));
    return;
  }

  MaybeLocal<Object> buffer = node::Buffer::New(isolate, totalSize);
  Local<Object> localBuffer;
  if (!buffer.ToLocal(&localBuffer)) {
    isolate->ThrowException(Exception::TypeError(
      String::NewFromUtf8(isolate, "Could not convert MaybeLocal to Local")));
    return;
  }
  memcpy(node::Buffer::Data(localBuffer), data, totalSize);
  delete[] data;
  args.GetReturnValue().Set(localBuffer);
}
开发者ID:garvankeeley,项目名称:abp-filter-parser-cpp,代码行数:25,代码来源:ABPFilterParserWrap.cpp

示例2: Lookup

void BookWrap::Lookup(const v8::FunctionCallbackInfo<v8::Value>& args) {
    Isolate* isolate = args.GetIsolate();
    HandleScope scope(isolate);
    
    if (args.Length() == 1) {
        if (args[0]->IsString()) {
            const String::Utf8Value s(args[0]->ToString());
            Book* b = ObjectWrap::Unwrap<BookWrap>(args.This())->m_book;
            try {
                Person* p = b->lookup(*s);
                Local<Object> obj = PersonWrap::NewInstance();
                PersonWrap* pw = ObjectWrap::Unwrap<PersonWrap>(obj);
                pw->m_person = p;
                args.GetReturnValue().Set(obj);
            }
            catch (...) {
                isolate->ThrowException(Exception::RangeError(String::NewFromUtf8(isolate, "Not found")));
                args.GetReturnValue().SetUndefined();
            }
        }
        else {
            isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "String expected")));
            args.GetReturnValue().SetUndefined();
        }
    }
    else {
        isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "One argument expected")));
        args.GetReturnValue().SetUndefined();
    }
}
开发者ID:kneth,项目名称:DemoNodeExtension,代码行数:30,代码来源:book_wrap.cpp

示例3: ParseAsync

void ParseAsync(const Nan::FunctionCallbackInfo<Value> &args) {
  Isolate *isolate = args.GetIsolate();
  int args_length = args.Length();

  if (args_length < 2) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Wrong number of arguments")));
    return;
  }

  Local<Value> input = args[0];
  if (!ValidateInput(input, isolate)) {
    return;
  }
  if (!args[1]->IsFunction()) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Second parameter must be a callback")));
    return;
  }

  Nan::Callback *callback = new Nan::Callback(args[1].As<Function>());
  anitomyJs::Worker *worker = new anitomyJs::Worker(callback);

  if (args_length >= 3) {
    Local<Value> options = args[2];
    if (!ValidateOptions(options, isolate) ||
        !worker->GetAnitomy()->SetOptions(options->ToObject(isolate->GetCurrentContext()).ToLocalChecked(), isolate)) {
      return;
    }
  }

  worker->GetAnitomy()->SetInput(input, isolate);
  Nan::AsyncQueueWorker(worker);
  args.GetReturnValue().Set(Nan::Undefined());
}
开发者ID:nevermnd,项目名称:anitomy-js,代码行数:33,代码来源:addon.cpp

示例4: Each

void BookWrap::Each(const FunctionCallbackInfo<Value>& args) {
    Isolate* isolate = args.GetIsolate();
    HandleScope scope(isolate);

    Book* book = ObjectWrap::Unwrap<BookWrap>(args.This())->m_book;

    if (args.Length() == 1) {
        if (args[0]->IsFunction()) {
            Local<Function> fun = Local<Function>::Cast(args[0]);
            for(uint32_t i = 0; i < book->size(); ++i) {
                Local<Object> pw = PersonWrap::New(isolate, book, i);
                Local<Value> argv[1] = { pw };
                fun->Call(Null(isolate), 1, argv);
            }
            args.GetReturnValue().SetUndefined();
            return;
        }
        else {
            isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Function expected")));
            args.GetReturnValue().SetUndefined();
            return;
        }
    }
    else {
        isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "One argument expected")));
        args.GetReturnValue().SetUndefined();
        return;
            
    }
}
开发者ID:kneth,项目名称:DemoNodeExtension,代码行数:30,代码来源:book_wrap.cpp

示例5:

/*
 * Prototype:
 * Module.enumerateImports(name, callback)
 *
 * Docs:
 * TBW
 *
 * Example:
 * TBW
 */
static void
gum_v8_module_on_enumerate_imports (
    const FunctionCallbackInfo<Value> & info)
{
  GumV8Module * self = static_cast<GumV8Module *> (
      info.Data ().As<External> ()->Value ());
  Isolate * isolate = info.GetIsolate ();
  GumV8ImportsContext ctx;

  ctx.self = self;
  ctx.isolate = isolate;

  Local<Value> name_val = info[0];
  if (!name_val->IsString ())
  {
    isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (
        isolate, "Module.enumerateImports: first argument must be "
        "a string specifying a module name whose imports to enumerate")));
    return;
  }
  String::Utf8Value name_str (name_val);

  Local<Value> callbacks_value = info[1];
  if (!callbacks_value->IsObject ())
  {
    isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (
        isolate, "Module.enumerateImports: second argument must be "
        "a callback object")));
    return;
  }

  Local<Object> callbacks = Local<Object>::Cast (callbacks_value);
  if (!_gum_v8_callbacks_get (callbacks, "onMatch", &ctx.on_match,
      ctx.self->core))
  {
    return;
  }
  if (!_gum_v8_callbacks_get (callbacks, "onComplete", &ctx.on_complete,
      ctx.self->core))
  {
    return;
  }

  ctx.receiver = info.This ();

  ctx.imp = eternal_imp.Get (isolate);
  ctx.type = eternal_type.Get (isolate);
  ctx.name = eternal_name.Get (isolate);
  ctx.module = eternal_module.Get (isolate);
  ctx.address = eternal_address.Get (isolate);
  ctx.variable = eternal_variable.Get (isolate);

  gum_module_enumerate_imports (*name_str,
      gum_v8_module_handle_import_match, &ctx);

  ctx.on_complete->Call (ctx.receiver, 0, 0);
}
开发者ID:terry2012,项目名称:frida-gum,代码行数:67,代码来源:gumv8module.cpp

示例6: Setter

void BookWrap::Setter(uint32_t index, Local<Value> value, const PropertyCallbackInfo<Value>& info) {
    Isolate* isolate = info.GetIsolate();
    HandleScope scope(isolate);
    
    BookWrap* bw = ObjectWrap::Unwrap<BookWrap>(info.This());
    Book*     b  = bw->m_book;

    if (value->IsArray()) {
        if (index < b->size()) {
            Local<v8::Array> arr = Local<v8::Array>::Cast(value);
            if (arr->Length() == 3) {
                const String::Utf8Value firstname(arr->Get(0)->ToString());
                const String::Utf8Value lastname(arr->Get(1)->ToString());
                const time_t birthday = time_t(0.001*(*arr->Get(2))->NumberValue());
                Person *p = (*b)[index];
                p->firstname(*firstname);
                p->lastname(*lastname);
                p->birthday(birthday);
            }
            else {
                isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Three elements expected"))); 
                info.GetReturnValue().SetUndefined();
                return;               
            }
        }
        if (index == b->size()) {
            Local<v8::Array> arr = Local<v8::Array>::Cast(value);
            if (arr->Length() == 3) {
                const String::Utf8Value firstname(arr->Get(0)->ToString());
                const String::Utf8Value lastname(arr->Get(1)->ToString());
                const time_t birthday = time_t(0.001*(*arr->Get(2))->NumberValue());
                Person *p = new Person();
                p->firstname(*firstname);
                p->lastname(*lastname);
                p->birthday(birthday);
                b->add(p);
            }
            else {
                isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Three elements expected")));
                info.GetReturnValue().SetUndefined();
                return;              
            }
        }
        else {
            isolate->ThrowException(Exception::RangeError(String::NewFromUtf8(isolate, "Invalid index")));
            info.GetReturnValue().SetUndefined();
            return;
        }
    }
    else {
        isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Object expected")));
        info.GetReturnValue().SetUndefined();
        return;
    }
    info.GetReturnValue().SetUndefined();
}
开发者ID:kneth,项目名称:DemoNodeExtension,代码行数:56,代码来源:book_wrap.cpp

示例7: if

/*
 * Prototype:
 * Module.findExportByName(module_name, symbol_name)
 *
 * Docs:
 * TBW
 *
 * Example:
 * TBW
 */
static void
gum_v8_module_on_find_export_by_name (
    const FunctionCallbackInfo<Value> & info)
{
  GumV8Module * self = static_cast<GumV8Module *> (
      info.Data ().As<External> ()->Value ());
  Isolate * isolate = info.GetIsolate ();

  Local<Value> module_name_val = info[0];
  gchar * module_name;
  if (module_name_val->IsString ())
  {
    String::Utf8Value module_name_utf8 (module_name_val);
    module_name = g_strdup (*module_name_utf8);
  }
  else if (module_name_val->IsNull ())
  {
    module_name = NULL;
  }
  else
  {
    isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (isolate, 
        "Module.findExportByName: first argument must be a string "
        "specifying module name, or null")));
    return;
  }

  Local<Value> symbol_name_val = info[1];
  if (!symbol_name_val->IsString ())
  {
    g_free (module_name);
    isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (isolate, 
        "Module.findExportByName: second argument must be a string "
        "specifying name of exported symbol")));
    return;
  }
  String::Utf8Value symbol_name (symbol_name_val);

  GumAddress raw_address =
      gum_module_find_export_by_name (module_name, *symbol_name);
  if (raw_address != 0)
  {
    info.GetReturnValue ().Set (
        _gum_v8_native_pointer_new (GSIZE_TO_POINTER (raw_address), self->core));
  }
  else
  {
    info.GetReturnValue ().SetNull ();
  }

  g_free (module_name);
}
开发者ID:terry2012,项目名称:frida-gum,代码行数:62,代码来源:gumv8module.cpp

示例8: Read

void GeoJSONReader::Read(const FunctionCallbackInfo<Value>& args) {
    Isolate* isolate = Isolate::GetCurrent();

    GeoJSONReader* reader = ObjectWrap::Unwrap<GeoJSONReader>(args.This());
    try {
        geos::geom::Geometry* g = reader->read(args[0]);
        args.GetReturnValue().Set(Geometry::New(g));
    }
    catch (const char* e) {
        isolate->ThrowException(Exception::Error(String::NewFromUtf8(isolate, e)));
    }
    catch (geos::util::GEOSException e) {
        isolate->ThrowException(Exception::Error(String::NewFromUtf8(isolate, e.what())));
    }
}
开发者ID:kashif,项目名称:node-geos,代码行数:15,代码来源:geojsonreader.cpp

示例9: scope

Handle<Value>
VException(const char *msg) {
    Isolate *isolate = Isolate::GetCurrent();

    HandleScope scope(isolate);
    return isolate->ThrowException(ErrorException(msg));
}
开发者ID:dl00,项目名称:node-png,代码行数:7,代码来源:common.cpp

示例10: s

Handle<Value> ManagedRef::SetPropertyValue(Local<String> name, Local<Value> value)
{
    Handle<Value> res;
    
    String::Value s(name);

#ifdef DEBUG_TRACE_API
		std::cout << "SetPropertyValue" << std::endl;
#endif
		Isolate* isolate = Isolate::GetCurrent();
    jsvalue v = engine_->AnyFromV8(value);
    jsvalue r = engine_->CallSetPropertyValue(contextId_, id_, *s, v);
    if (r.type == JSVALUE_TYPE_MANAGED_ERROR)
		isolate->ThrowException(engine_->AnyToV8(r, contextId_));//0.12.x
        //res = ThrowException(engine_->AnyToV8(r, contextId_));//0.10.x
    else
        res = engine_->AnyToV8(r, contextId_);
    
#ifdef DEBUG_TRACE_API
		std::cout << "cleaning up result from setproperty value" << std::endl;
#endif
    // We don't need the jsvalues anymore and the CLR side never reuse them.
    jsvalue_dispose(v);
    jsvalue_dispose(r);
    
    return res;
}
开发者ID:Nanonid,项目名称:Espresso,代码行数:27,代码来源:managedref.cpp

示例11: Move

void UiWindow::Move(const FunctionCallbackInfo<Value>& args) {
    Isolate *isolate = Isolate::GetCurrent();
    HandleScope scope(isolate);

    if (args.Length() != 2 && args.Length() != 4) {
        isolate->ThrowException(String::NewFromUtf8(isolate, "arg"));
        return;
    }

    UiWindow* _this = Unwrap<UiWindow>(args.This());
    WindowRect rect = _this->GetWindowRect();

    if (args[0]->IsNumber()) {
        rect.Left = args[0]->Int32Value();
    }
    if (args[1]->IsNumber()) {
        rect.Top = args[1]->Int32Value();
    }
    if (args.Length() == 4) {
        if (args[2]->IsNumber()) {
            rect.Width = args[2]->Int32Value();
        }
        if (args[3]->IsNumber()) {
            rect.Height = args[3]->Int32Value();
        }
    }

    _this->SetWindowRect(rect);
}
开发者ID:NextGenIntelligence,项目名称:io-ui,代码行数:29,代码来源:ui-window.cpp

示例12: ParseSync

void ParseSync(const Nan::FunctionCallbackInfo<Value> &args) {
  Isolate *isolate = args.GetIsolate();
  int args_length = args.Length();

  if (args_length < 1) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Wrong number of arguments")));
    return;
  }

  Local<Value> input = args[0];
  if (!ValidateInput(input, isolate)) {
    return;
  }

  anitomyJs::AnitomyJs anitomy;
  if (args_length >= 2) {
    Local<Value> options = args[1];
    if (!ValidateOptions(options, isolate) ||
        !anitomy.SetOptions(options->ToObject(isolate->GetCurrentContext()).ToLocalChecked(), isolate)) {
      return;
    }
  }

  anitomy.SetInput(input, isolate);
  anitomy.Parse();

  args.GetReturnValue().Set(anitomy.ParsedResult(isolate));
}
开发者ID:nevermnd,项目名称:anitomy-js,代码行数:28,代码来源:addon.cpp

示例13:

/*
 * Prototype:
 * Stalker.addCallProbe(target_address, callback)
 *
 * Docs:
 * TBW
 *
 * Example:
 * TBW
 */
static void
gum_v8_stalker_on_add_call_probe (const FunctionCallbackInfo<Value> & info)
{
  GumV8Stalker * self = static_cast<GumV8Stalker *> (
      info.Data ().As<External> ()->Value ());
  Isolate * isolate = info.GetIsolate ();
  GumV8CallProbe * probe;
  GumProbeId id;

  gpointer target_address;
  if (!_gum_v8_native_pointer_get (info[0], &target_address, self->core))
    return;

  Local<Value> callback_value = info[1];
  if (!callback_value->IsFunction ())
  {
    isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (isolate,
        "Stalker.addCallProbe: second argument must be a function")));
    return;
  }
  Local<Function> callback = Local<Function>::Cast (callback_value);

  probe = g_slice_new (GumV8CallProbe);
  probe->parent = self;
  probe->callback = new GumPersistent<Function>::type (isolate, callback);
  probe->receiver = new GumPersistent<Value>::type (isolate, info.This ());
  id = gum_stalker_add_call_probe (_gum_v8_stalker_get (self),
      target_address, gum_v8_call_probe_fire,
      probe, reinterpret_cast<GDestroyNotify> (gum_v8_call_probe_free));

  info.GetReturnValue ().Set (id);
}
开发者ID:0xItx,项目名称:frida-gum,代码行数:42,代码来源:gumv8stalker.cpp

示例14: New

void CRF::New(const FunctionCallbackInfo<Value>& args) {
    Isolate* isolate = args.GetIsolate();
    
    if (args.IsConstructCall()) {
        // Invoked as constructor: `new CRF(...)`
        
        CRF* obj = new CRF();
        
        CRFPP::Tagger* tag = CRFPP::createTagger(get(args[0]));
        if(!tag){
            
            isolate->ThrowException(Exception::TypeError(
                                                       String::NewFromUtf8(isolate, (const char *) CRFPP::getTaggerError())));
            return;
            
        }
        
        v8::Local<v8::External> handle = v8::External::New(isolate, tag);
        v8::Persistent<v8::External, v8::CopyablePersistentTraits<v8::External> > tagger(isolate, handle);
        
        obj -> tagger = tagger;
        
        obj->Wrap(args.This());
        args.GetReturnValue().Set(args.This());
    } else {
        const int argc = 1;
        Local<Value> argv[argc] = { args[0] };
        Local<Function> cons = Local<Function>::New(isolate, constructor);
        args.GetReturnValue().Set(cons->NewInstance(argc, argv));
    }
}
开发者ID:janez87,项目名称:node-crf,代码行数:31,代码来源:node-crf.cpp

示例15: getIntParameter

int DeviceNode::getIntParameter(const v8::FunctionCallbackInfo<v8::Value>& args) {
  Isolate* isolate = Isolate::GetCurrent();
  if (args.Length() < 1) {
    isolate->ThrowException(Exception::TypeError(
        String::NewFromUtf8(isolate, "Wrong number of arguments")));
    throw "Wrong number of arguments";
  }

  if (!args[0]->IsNumber()) {
    isolate->ThrowException(Exception::TypeError(
        String::NewFromUtf8(isolate, "Wrong arguments")));
    throw "Wrong arguments";
  }

  return args[0]->NumberValue();
}
开发者ID:egeback,项目名称:node-tellstick,代码行数:16,代码来源:device-node.cpp


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