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


C++ nan::FunctionCallbackInfo类代码示例

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


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

示例1: nodeExtractFiles

/* Extract files into directory.
 *
 * Extract an array of files (args[0]) into a directory of choice (args[1]).
 * @param (string) Source directory of CASC archive
 * @param (string) Destination directory to extract files
 * @param (array) Array of files within the CASC archive
 * @return (int) Number of files successfully extracted.
 */
void nodeExtractFiles(const Nan::FunctionCallbackInfo<v8::Value> &args) {
    // Allocate a new scope when we create v8 JavaScript objects.
    v8::Isolate *isolate = args.GetIsolate();
    Nan::HandleScope scope;

    // strSource
    strSource = *v8::String::Utf8Value(args[0]->ToString());
    if ((strSource[strSource.size() - 1] == '/') || (strSource[strSource.size() - 1] == '\\'))
        strSource = strSource.substr(0, strSource.size() - 1);

    // strDestination
    strDestination = *v8::String::Utf8Value(args[1]->ToString());
    if (strDestination.at(strDestination.size() - 1) != '/')
        strDestination += "/";

    // Open CASC archive
    if (!CascOpenStorage(strSource.c_str(), 0, &hStorage)) {
        cerr << "Failed to open the storage '" << strSource << "'" << endl;
        args.GetReturnValue().Set(-1);
        return;
    }

    int filesDone = 0;

    if (args[2]->IsArray()) {
        v8::Handle<v8::Array> files = v8::Handle<v8::Array>::Cast(args[2]);
        for (uint32_t i = 0; i < files->Length(); i++) {
            v8::String::Utf8Value item(files->Get(i)->ToString());
            std::basic_string<char> file = std::string(*item);
            size_t bytesWritten = extractFile(file);
            if (bytesWritten > 0) {
              filesDone++;
            }
        }
    }

    // Clean it up...
    CascCloseStorage(hStorage);
    hStorage = NULL;

    // Ship it out...
    args.GetReturnValue().Set(filesDone);
    return;
}
开发者ID:jnovack,项目名称:storm-extract,代码行数:52,代码来源:storm-extract.cpp

示例2: Stop

void Client::Stop(const Nan::FunctionCallbackInfo<v8::Value>& info) {
	Client* memClient = ObjectWrap::Unwrap<Client>(info.Holder());

	CHECK_ARGUMENT_LENGTH(info, 1, "1")
	CHECK_N_ARGS_IS_A_FUNCTION(info, 0, "0")
	Callback* callback = new Callback(info[0].As<v8::Function>());

	memClient->progressWorker->setCallback(callback);
	memClient->isRunning = false;
}
开发者ID:allevo,项目名称:memcached-native,代码行数:10,代码来源:client.cpp

示例3: nodeListFiles

/* List all files in a CASC archive.
 *
 * @param (string) Source directory of CASC files
 * @return (array) Full paths of files in the archive
 */
void nodeListFiles(const Nan::FunctionCallbackInfo<v8::Value> &args) {
    // Set API variables
    bQuiet = true;
    bVerbose = false;

    // Allocate a new scope when we create v8 JavaScript objects.
    v8::Isolate *isolate = args.GetIsolate();
    Nan::HandleScope scope;

    strSource = *v8::String::Utf8Value(args[0]->ToString());

    if ((strSource[strSource.size() - 1] == '/') || (strSource[strSource.size() - 1] == '\\'))
        strSource = strSource.substr(0, strSource.size() - 1);

    if (!CascOpenStorage(strSource.c_str(), 0, &hStorage)) {
        cerr << "Failed to open the storage '" << strSource << "'" << endl;
        return;
    }

    // Define variables
    CASC_FIND_DATA findData;
    HANDLE handle = CascFindFirstFile(hStorage, "*", &findData, NULL);

    // Let's get this party started..
    vector<string> results = searchArchive();

    // Convert returned vector of *chars to a v8::Array of v8::Strings
    v8::Handle<v8::Array> files = v8::Array::New(isolate);
    for (unsigned int i = 0; i < results.size(); i++ ) {
      v8::Handle<v8::String> result = v8::String::NewFromUtf8(isolate, results[i].c_str());
      files->Set(i, result);
    }

    // Clean it up...
    CascFindClose(handle);
    CascCloseStorage(hStorage);
    handle = NULL;
    hStorage = NULL;

    // Ship it out...
    args.GetReturnValue().Set(files);
    return;
}
开发者ID:jnovack,项目名称:storm-extract,代码行数:48,代码来源:storm-extract.cpp

示例4: CheckPass

void CheckPass(const Nan::FunctionCallbackInfo<v8::Value>& info) {
	Nan::Utf8String recipfile(info[0]->ToString());
	Nan::Utf8String pass(info[1]->ToString());

	//wchar_t* w_recipfile = CharToWchar_New(*recipfile);
	int ret = parse_cert_file(*recipfile, *pass,NULL);
	//delete[] w_recipfile;
	v8::Local<v8::Number> res = Nan::New(ret);
	info.GetReturnValue().Set(res);
}
开发者ID:jishuo1213,项目名称:vcprojects,代码行数:10,代码来源:DecryptMailNode.cpp

示例5: decrypt

 void SecureCellContextImprint::decrypt(const Nan::FunctionCallbackInfo<v8::Value>& args) {
   SecureCellContextImprint* obj = Nan::ObjectWrap::Unwrap<SecureCellContextImprint>(args.This());
   size_t length=0;
   const uint8_t* context=(const uint8_t*)(node::Buffer::Data(args[1]));
   size_t context_length=node::Buffer::Length(args[1]);
   if(themis_secure_cell_decrypt_context_imprint(&(obj->key_)[0], obj->key_.size(), (const uint8_t*)(node::Buffer::Data(args[0])), node::Buffer::Length(args[0]), context, context_length, NULL, &length)!=THEMIS_BUFFER_TOO_SMALL){
     Nan::ThrowError("Secure Cell (Context Imprint) failed  decrypting");
     args.GetReturnValue().SetUndefined();
     return;
   }
   uint8_t* data=(uint8_t*)(malloc(length));
   if(themis_secure_cell_decrypt_context_imprint(&(obj->key_)[0], obj->key_.size(), (const uint8_t*)(node::Buffer::Data(args[0])), node::Buffer::Length(args[0]), context, context_length, data, &length)!=THEMIS_SUCCESS){
     Nan::ThrowError("Secure Cell (Context Imprint) failed  decrypting");
     free(data);
     args.GetReturnValue().SetUndefined();
     return;
   }
   args.GetReturnValue().Set(Nan::NewBuffer((char*)(data), length).ToLocalChecked());
 }
开发者ID:Lagovas,项目名称:themis,代码行数:19,代码来源:secure_cell_context_imprint.cpp

示例6: Inverse

/**
  *  Inverse:
  *  Compute the (multiplicative) inverse of a matrix.
  *   Given a square matrix a, return the matrix ainv satisfying dot(a, ainv) = dot(ainv, a)
  *
  *  arguments:
  *  info[0]: Buffer(object created by smalloc) represent the numjs.Matrix object to be inverted.
  *           Must be square, i.e. M.rows == M.cols.
  *  info[1]: Number represent the number of rows of the matrix.
  *  info[2]: Number represent the number of columns of the matrix.
  *  info[3]: Buffer(object created by smalloc) for return value, inverse of the given matrix.
*/
void Inverse(const Nan::FunctionCallbackInfo<v8::Value>& info){
    using CMd = Eigen::Map <const Eigen::MatrixXd >;
    using Md = Eigen::Map <Eigen::MatrixXd >;

    if (info.Length() < 4) {
        Nan::ThrowTypeError("Wrong number of arguments");
        return;
    }

    if (!info[1]->IsNumber() || !info[2]->IsNumber()) {
        Nan::ThrowTypeError("Wrong arguments");
        return;
    }

    Local<Object> matrixBuffer = info[0].As<Object>();
    if (matrixBuffer->HasIndexedPropertiesInExternalArrayData()) {
        double *refMatrixData = static_cast<double*>(matrixBuffer->GetIndexedPropertiesExternalArrayData());
        size_t rowsMatrix(info[1]->Uint32Value());
        size_t colsMatrix(info[2]->Uint32Value());

        Md inputMat(refMatrixData, rowsMatrix, colsMatrix);

        Local<Object> resBuffer = info[4].As<Object>();
        if (resBuffer->HasIndexedPropertiesInExternalArrayData()) {
            double *refResData = static_cast<double*>(resBuffer->GetIndexedPropertiesExternalArrayData());
            Md res(refResData, rowsMatrix, colsMatrix);
            res = inputMat.inverse();
            Local<Boolean> b = Nan::New(true);
            info.GetReturnValue().Set(b);
        }
        else{
            Nan::ThrowTypeError("Wrong arguments2");
            Local<Boolean> b = Nan::New(false);
            info.GetReturnValue().Set(b);
        }
    }
    else{
        Nan::ThrowTypeError("Wrong arguments3");
        Local<Boolean> b = Nan::New(false);
        info.GetReturnValue().Set(b);
    }
}
开发者ID:RunningWithScissors-,项目名称:numjs.linalg,代码行数:54,代码来源:numjs.linalg.cpp

示例7: sayHello

//#include <string>
void sayHello(const Nan::FunctionCallbackInfo<v8::Value>& info){
//    v8::Local<v8::String> str=info.Data().Cast<v8::String>(info.Data());
    Nan::Utf8String str(info[0]);
//    std::cout<<*str<<std::endl;
//    char* helloStr="hello ";
    std::string hello=std::string("hello ")+std::string(*str);
//    v8::Local<v8::String> helloStr=
//            v8::String::NewFromUtf8(Nan::GetCurrentContext()->GetIsolate(),hello.c_str());
    v8::Local<v8::String> helloStr=Nan::New<v8::String>("hello ").ToLocalChecked();
    info.GetReturnValue().Set(helloStr);
}
开发者ID:CatalystDP,项目名称:node_addon_study,代码行数:12,代码来源:main.cpp

示例8: Replace

void Client::Replace(const Nan::FunctionCallbackInfo<v8::Value>& info) {
	Client* memClient = ObjectWrap::Unwrap<Client>(info.Holder());

	CHECK_ARGUMENT_LENGTH(info, 4, "4")
	CHECK_N_ARGS_IS_A_STRING(info, 0, "0")
	CHECK_N_ARGS_IS_A_STRING(info, 1, "1")
	CHECK_N_ARGS_IS_A_NUMBER(info, 2, "2")
	CHECK_N_ARGS_IS_A_FUNCTION(info, 3, "3")

	const string memcached_key = GET_STRING_FROM_PARAM(info[0]);
	const string memcached_value = GET_STRING_FROM_PARAM(info[1]);
	time_t ttl = (time_t) GET_NUMBER_FROM_PARAM(info[2]);
	Callback* callback = GET_CALLBACK_FROM_PARAM(info[3]);

	JobBase* job = new ReplaceJob(callback, memcached_key, memcached_value, ttl);
	job->setDebug(memClient->debug);
	memClient->jobs.insert(job);

	info.GetReturnValue().Set(Nan::Undefined());
}
开发者ID:allevo,项目名称:memcached-native,代码行数:20,代码来源:client.cpp

示例9: RegisterRemoved

void RegisterRemoved(const Nan::FunctionCallbackInfo<v8::Value>& args) {
	Nan::HandleScope scope;

	v8::Local<v8::Function> callback;

	if (args.Length() == 0) {
		return Nan::ThrowTypeError("First argument must be a function");
	}

	if (args.Length() == 1) {
		// callback
		if(!args[0]->IsFunction()) {
			return Nan::ThrowTypeError("First argument must be a function");
		}

		callback = args[0].As<v8::Function>();
	}

	removedCallback = new Nan::Callback(callback);
	isRemovedRegistered = true;
}
开发者ID:Omosofe,项目名称:node-usb-detection,代码行数:21,代码来源:detection.cpp

示例10: GetClipDatabase

void GetClipDatabase(const Nan::FunctionCallbackInfo<v8::Value>& info) {
  if ((info.Length() < 1) || (info.Length() > 1)) {
    Nan::ThrowTypeError("Wrong number of arguments");
    return;
  }

  if (!info[0]->IsNumber()) {
    Nan::ThrowTypeError("Wrong arguments");
    return;
  }

  int sizeOfData = 0;
  char* clipDatabase = GetClipDatabase(sizeOfData);

  v8::Local<v8::String> v8ClipDatabase = v8::String::New(clipDatabase, sizeOfData);
  v8::Local<v8::Object> obj = Nan::New<v8::Object>();
  obj->Set(Nan::New("msg").ToLocalChecked(), v8ClipDatabase);
  info.GetReturnValue().Set(obj);

  FreeClipDatabase(clipDatabase);
}
开发者ID:cbiernaux,项目名称:EvsHammer,代码行数:21,代码来源:EvsHammer.cpp

示例11: Inverse

/**
  *  Inverse:
  *  Compute the (multiplicative) inverse of a matrix.
  *  Given a square matrix a, return the matrix ainv satisfying dot(a, ainv) = dot(ainv, a)
  *
  *  arguments:
  *  info[0]: Buffer(object created by Float64Array) represent the numjs.Matrix object to be inverted.
  *           Must be square, i.e. M.rows == M.cols.
  *  info[1]: Number represent the number of rows of the matrix.
  *  info[2]: Number represent the number of columns of the matrix.
  *  info[3]: Buffer(object created by Float64Array) for return value, inverse of the given matrix.
*/
void Inverse(const Nan::FunctionCallbackInfo<v8::Value>& info){
    using CMd = Eigen::Map <const Eigen::MatrixXd >;
    using Md = Eigen::Map <Eigen::MatrixXd >;

    if (info.Length() < 4) {
        Nan::ThrowTypeError("Wrong number of arguments");
        return;
    }

    if (!info[1]->IsNumber() || !info[2]->IsNumber()) {
        Nan::ThrowTypeError("Wrong arguments");
        return;
    }

	if (info[0]->IsFloat64Array()) {
		double *refMatrixData = *(Nan::TypedArrayContents<double>(info[0]));
        size_t rowsMatrix(info[1]->Uint32Value());
        size_t colsMatrix(info[2]->Uint32Value());

        Md inputMat(refMatrixData, rowsMatrix, colsMatrix);

		if (info[3]->IsFloat64Array()) {
			double *refResData = *(Nan::TypedArrayContents<double>(info[3]));
            Md res(refResData, rowsMatrix, colsMatrix);
            res = inputMat.inverse();
            Local<Boolean> b = Nan::New(true);
            info.GetReturnValue().Set(b);
        }
        else{
            Nan::ThrowTypeError("Wrong arguments (4th arg)");
            Local<Boolean> b = Nan::New(false);
            info.GetReturnValue().Set(b);
        }
    }
    else{
        Nan::ThrowTypeError("Wrong arguments (1st arg)");
        Local<Boolean> b = Nan::New(false);
        info.GetReturnValue().Set(b);
    }
}
开发者ID:datascience-js,项目名称:numjs.linalg,代码行数:52,代码来源:numjs.linalg.cpp

示例12: Parse

void MeCab_Tagger::Parse(const Nan::FunctionCallbackInfo<v8::Value>& info) {
  MeCab_Tagger* mecabTagger = ObjectWrap::Unwrap<MeCab_Tagger>(info.Holder());
  v8::String::Utf8Value input(info[0]);
  v8::Local<v8::Function> callback = info[1].As<v8::Function>();

  const char *result = mecabTagger->tagger->parse(*input);

  const unsigned argc = 2;
  v8::Local<v8::Value> argv[] = {
    Nan::Null(),
    Nan::New(result).ToLocalChecked()
  };
  Nan::MakeCallback(Nan::GetCurrentContext()->Global(), callback, argc, argv);
}
开发者ID:umatoma,项目名称:node-mecab-native,代码行数:14,代码来源:mecab.cpp

示例13: Tri

/**
  *  Tri:
  *  Creates a new nXm matrix with ones at and below the matrix diagonal
  *  and zeros elsewhere.
  *
  *  arguments:
  *  info[0]: Number n which represents the number of rows in the newly built matrix
  *  info[1]: Number m which represents the number of cols in the newly built matrix
  *  info[2]: Buffer(object created by Float64Array) for return value(eye matrix nXm).
*/
void Tri(const Nan::FunctionCallbackInfo<v8::Value>& info){
    using CMd = Eigen::Map <const Eigen::MatrixXd >;
    using Md = Eigen::Map <Eigen::MatrixXd >;

    if (info.Length() < 3) {
        Nan::ThrowTypeError("Wrong number of arguments");
        return;
    }

    if (!info[0]->IsNumber() || !info[1]->IsNumber()) {
        Nan::ThrowTypeError("Wrong argument given, should be a number");
        return;
    }

    if (info[2]->IsFloat64Array()) {
        size_t rowsMatrix(info[0]->Uint32Value());
        size_t colsMatrix(info[1]->Uint32Value());

        double *refResData = *(Nan::TypedArrayContents<double>(info[2]));
        Md res(refResData, rowsMatrix, colsMatrix);
        res = Md::Ones(rowsMatrix, colsMatrix);
        for (int i = 0; i < rowsMatrix; i++) {
            for (int j = i + 1; j < colsMatrix; j++) {
                res(i, j) = 0;
            }
        }

        Local<Boolean> b = Nan::New(true);
        info.GetReturnValue().Set(b);
    }

    else{
        Nan::ThrowTypeError("Wrong arguments2");
        Local<Boolean> b = Nan::New(false);
        info.GetReturnValue().Set(b);
    }
}
开发者ID:datascience-js,项目名称:numjs.linalg,代码行数:47,代码来源:numjs.linalg.cpp

示例14: getTelemetryDescription

  void getTelemetryDescription(const Nan::FunctionCallbackInfo<v8::Value>& args)
  {
    Local<Object> obj = Nan::New<Object>();
    std::vector<irsdk_varHeader*> headers = irsdk.getVarHeaders();

    for (const auto item : headers)
    {
      IRSDKWrapper::TelemetryVar var(item);
      irsdk.getVarVal(var);
      Handle<Object> varObj = Nan::New<Object>();
      convertVarHeaderToObject(var, varObj);
      Nan::Set(obj, Nan::New(var.header->name).ToLocalChecked(), varObj);
    }
    args.GetReturnValue().Set(obj);
  }
开发者ID:apihlaja,项目名称:node-irsdk,代码行数:15,代码来源:IrSdkNodeBindings.cpp

示例15: MGetAndFetchAll

void Client::MGetAndFetchAll(const Nan::FunctionCallbackInfo<v8::Value>& info) {
	Client* memClient = ObjectWrap::Unwrap<Client>(info.Holder());

	CHECK_ARGUMENT_LENGTH(info, 2, "2")
	CHECK_N_ARGS_IS_AN_ARRAY(info, 0, "0")
	CHECK_N_ARGS_IS_A_FUNCTION(info, 1, "1")

	v8::Local<v8::Object> arr = info[0]->ToObject();
	size_t number_of_keys = arr->GetOwnPropertyNames()->Length();
	memClient->debug && printf("%s %lu %s\n", "Array with", number_of_keys, "keys");

	std::vector<string> keys;
	for(size_t i = 0; i < number_of_keys; i++) {
		keys.push_back(GET_STRING_FROM_PARAM(arr->Get(i)));
	}

	Callback* callback = GET_CALLBACK_FROM_PARAM(info[1]);

	JobBase* job = new MGetAndFetchAllJob(callback, keys);
	job->setDebug(memClient->debug);
	memClient->jobs.insert(job);

	info.GetReturnValue().Set(Nan::Undefined());
}
开发者ID:allevo,项目名称:memcached-native,代码行数:24,代码来源:client.cpp


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