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


C++ FunctionCallbackInfo::IsConstructCall方法代码示例

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


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

示例1: New

void SecureCellSeal::New(const Nan::FunctionCallbackInfo<v8::Value>& args)
{
    if (args.IsConstructCall()) {
        if (args.Length() < 1) {
            ThrowParameterError("Secure Cell (Seal) constructor",
                                "not enough arguments, expected master key");
            args.GetReturnValue().SetUndefined();
            return;
        }
        if (!args[0]->IsUint8Array()) {
            ThrowParameterError("Secure Cell (Seal) constructor",
                                "master key is not a byte buffer, use ByteBuffer or Uint8Array");
            args.GetReturnValue().SetUndefined();
            return;
        }
        if (node::Buffer::Length(args[0]) == 0) {
            ThrowParameterError("Secure Cell (Seal) constructor", "master key is empty");
            args.GetReturnValue().SetUndefined();
            return;
        }
        std::vector<uint8_t> key((uint8_t*)(node::Buffer::Data(args[0])),
                                 (uint8_t*)(node::Buffer::Data(args[0]) + node::Buffer::Length(args[0])));
        SecureCellSeal* obj = new SecureCellSeal(key);
        obj->Wrap(args.This());
        args.GetReturnValue().Set(args.This());
    } else {
        const int argc = 1;
        v8::Local<v8::Value> argv[argc] = {args[0]};
        v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
        args.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
    }
}
开发者ID:cossacklabs,项目名称:themis,代码行数:32,代码来源:secure_cell_seal.cpp

示例2: New

 void SecureCellContextImprint::New(const Nan::FunctionCallbackInfo<v8::Value>& args) {
   if (args.IsConstructCall()) {
     std::vector<uint8_t> key((uint8_t*)(node::Buffer::Data(args[0])), (uint8_t*)(node::Buffer::Data(args[0])+node::Buffer::Length(args[0])));
     SecureCellContextImprint* obj = new SecureCellContextImprint(key);
     obj->Wrap(args.This());
     args.GetReturnValue().Set(args.This());
   } else {
     const int argc = 1;
     v8::Local<v8::Value> argv[argc] = { args[0]};
     v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
     args.GetReturnValue().Set(cons->NewInstance(argc, argv));
   }
 }
开发者ID:Lagovas,项目名称:themis,代码行数:13,代码来源:secure_cell_context_imprint.cpp

示例3: New

void MeCab_Tagger::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
  if (info.IsConstructCall()) {
    v8::String::Utf8Value option(info[0]);

    MeCab_Tagger* mecabTagger = new MeCab_Tagger(*option);
    mecabTagger->Wrap(info.This());
    info.GetReturnValue().Set(info.This());
  } else {
    const int argc = 1;
    v8::Local<v8::Value> argv[argc] = { info[0] };
    v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
    info.GetReturnValue().Set(cons->NewInstance(argc, argv));
  }
}
开发者ID:umatoma,项目名称:node-mecab-native,代码行数:14,代码来源:mecab.cpp

示例4: New

void Client::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
	if (info.IsConstructCall()) {
		v8::String::Utf8Value param0(info[0]->ToString());
		std::string* param0String = new std::string(*param0);
		const char* conf = param0String->c_str();

		Client* obj = new Client(conf);
		obj->Wrap(info.This());
		info.GetReturnValue().Set(info.This());
	} else {
		const int argc = 1;
		v8::Local<v8::Value> argv[argc] = { info[0] };
		v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
		info.GetReturnValue().Set(cons->NewInstance(argc, argv));
	}
}
开发者ID:allevo,项目名称:memcached-native,代码行数:16,代码来源:client.cpp


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