本文整理汇总了C++中nan::FunctionCallbackInfo::GetIsolate方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionCallbackInfo::GetIsolate方法的具体用法?C++ FunctionCallbackInfo::GetIsolate怎么用?C++ FunctionCallbackInfo::GetIsolate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nan::FunctionCallbackInfo
的用法示例。
在下文中一共展示了FunctionCallbackInfo::GetIsolate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: 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));
}
示例3: nodeGetVersion
/* Get version
*
* Get the version of the application based on hard-coded value above.
* @return (string) Version
*/
void nodeGetVersion(const Nan::FunctionCallbackInfo<v8::Value> &args) {
// Allocate a new scope when we create v8 JavaScript objects.
v8::Isolate *isolate = args.GetIsolate();
Nan::HandleScope scope;
// Convert to v8 String
v8::Handle<v8::String> result = v8::String::NewFromUtf8(isolate, version.c_str());
// Ship it out...
args.GetReturnValue().Set(result);
return;
}
示例4: 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;
}
示例5: 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;
}