本文整理汇总了C++中FunctionCallbackInfo::GetReturnValue方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionCallbackInfo::GetReturnValue方法的具体用法?C++ FunctionCallbackInfo::GetReturnValue怎么用?C++ FunctionCallbackInfo::GetReturnValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionCallbackInfo
的用法示例。
在下文中一共展示了FunctionCallbackInfo::GetReturnValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*
* Prototype:
* Module.findBaseAddress(module_name)
*
* Docs:
* TBW
*
* Example:
* TBW
*/
static void
gum_v8_module_on_find_base_address (
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];
if (!module_name_val->IsString ())
{
isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (isolate,
"Module.findBaseAddress: argument must be a string "
"specifying module name")));
return;
}
String::Utf8Value module_name (module_name_val);
GumAddress raw_address = gum_module_find_base_address (*module_name);
if (raw_address != 0)
{
info.GetReturnValue ().Set (
_gum_v8_native_pointer_new (GSIZE_TO_POINTER (raw_address), self->core));
}
else
{
info.GetReturnValue ().SetNull ();
}
}
示例2: handle_scope
/**
* TJSオブジェクトのオーバライド処理
* @param args 引数
* @return 結果
*/
void
TJSInstance::tjsOverride(const FunctionCallbackInfo<Value>& args)
{
Isolate *isolate = args.GetIsolate();
HandleScope handle_scope(isolate);
tTJSVariant instance;
if (getVariant(isolate, instance, args.This())) {
if (args.Length() > 0) {
Local<Value> func = args.Length() > 1 ? args[1] : args.This()->Get(args[0]);
if (func->IsFunction()) {
tTJSVariant value = toVariant(isolate, func->ToObject(), args.This());
String::Value methodName(args[0]);
tjs_error error;
if (TJS_FAILED(error = instance.AsObjectClosureNoAddRef().PropSet(TJS_MEMBERENSURE, *methodName, NULL, &value, NULL))) {
args.GetReturnValue().Set(ERROR_KRKR(isolate, error));
return;
}
args.GetReturnValue().Set(Undefined(isolate));
return;
}
}
args.GetReturnValue().Set(isolate->ThrowException(String::NewFromUtf8(isolate, "not function")));
return;
}
args.GetReturnValue().Set(ERROR_BADINSTANCE(isolate));
}
示例3: Assert
void ConsoleInterfaces::Assert(const FunctionCallbackInfo<Value>& args)
{
Handle<External> ext = Handle<External>::Cast(args.Data());
Flathead *pFH = (Flathead *)ext->Value();
int counter = 0;
if (args.Length() == 0)
{
pFH->GetConfiguration()->LoggingFn()(LogLevels::Assert, "");
return;
}
Local<Value> value = args[0];
if (value->IsTrue())
{
args.GetReturnValue().Set(counter);
return;
}
if (pFH->GetConfiguration()->LoggingFn() != NULL)
{
for (int i = 1; i < args.Length(); i++)
{
Local<Value> value = args[i];
String::Utf8Value outputString(value);
pFH->GetConfiguration()->LoggingFn()(LogLevels::Assert, *outputString);
counter++;
}
}
args.GetReturnValue().Set(counter);
}
示例4: New
void ETW::New(const FunctionCallbackInfo<Value>& args)
{
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
if (args.IsConstructCall())
{
if (args[0]->IsUndefined())
{
Nan::ThrowTypeError("Session name is required.");
return;
}
int wchars_num = MultiByteToWideChar(CP_UTF8 , 0 , *String::Utf8Value(args[0]), -1, NULL , 0 );
wchar_t* szSessionName = new wchar_t[wchars_num];
MultiByteToWideChar(CP_UTF8, 0, *String::Utf8Value(args[0]), -1, szSessionName, wchars_num);
// Invoked as constructor: `new ETW(...)`
ETW* obj = new ETW(szSessionName);
obj->Wrap(args.This());
args.GetReturnValue().Set(args.This());
}
else
{
// Invoked as plain function `ETW(...)`, turn into construct call.
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));
}
}
示例5: 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;
}
}
示例6: 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));
}
}
示例7: New
void IdPool::New(const FunctionCallbackInfo<Value>& args)
{
Isolate* isolate = args.GetIsolate();
if (args.IsConstructCall()) {
// Invoked as constructor: `new IdPool(...)`
double value = args[0]->IsUndefined() || !args[0]->IsNumber()?
0 : args[0]->NumberValue() / 8;
if (value > DEFAULT_CTOR_MAX_POSSIBLE_SIZE) {
JS_THROW(isolate, "Size too large");
return;
}
// ceil
size_t poolSize = value + (size_t)((size_t)value != value);
try {
IdPool* obj = new IdPool(poolSize);
obj->Wrap(args.This());
args.GetReturnValue().Set(args.This());
}
catch (std::Exception e) {
JS_THROW(isolate, e.what());
return;
}
} else {
// Invoked as plain function `IdPool(...)`, turn into construct call.
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));
}
}
示例8: GettertCallback
void WeakRef::GettertCallback(const FunctionCallbackInfo<Value>& args)
{
try
{
auto holder = args.This();
auto poTarget = reinterpret_cast<Persistent<Object>*>(holder->GetHiddenValue(V8StringConstants::GetTarget()).As<External>()->Value());
auto isolate = args.GetIsolate();
if (poTarget != nullptr)
{
auto target = Local<Object>::New(isolate, *poTarget);
args.GetReturnValue().Set(target);
}
else
{
args.GetReturnValue().Set(Null(isolate));
}
}
catch (NativeScriptException& e)
{
e.ReThrowToV8();
}
catch (std::exception e) {
stringstream ss;
ss << "Error: c++ exception: " << e.what() << endl;
NativeScriptException nsEx(ss.str());
nsEx.ReThrowToV8();
}
catch (...) {
NativeScriptException nsEx(std::string("Error: c++ exception!"));
nsEx.ReThrowToV8();
}
}
示例9: get_game_player_sync_buffer
void get_game_player_sync_buffer(const FunctionCallbackInfo<Value>& args){
Block_Buffer *buf = MASTER_MANAGER->pop_master_player_sync_data();
if (buf) {
args.GetReturnValue().Set(wrap_buffer(args.GetIsolate(), buf));
} else {
//设置对象为空
args.GetReturnValue().SetNull();
}
}
示例10: pop_sync_master_data_buffer
void pop_sync_master_data_buffer(const FunctionCallbackInfo<Value>& args) {
Block_Buffer *buf = GAME_MANAGER->pop_sync_master_data_buffer();
if (buf) {
args.GetReturnValue().Set(wrap_buffer(args.GetIsolate(), buf));
} else {
//设置对象为空
args.GetReturnValue().SetNull();
}
}
示例11: pop_game_buffer
void pop_game_buffer(const FunctionCallbackInfo<Value>& args) {
Block_Buffer *buf = GAME_MANAGER->pop_block_buffer();
if (buf) {
buf->reset();
args.GetReturnValue().Set(wrap_buffer(args.GetIsolate(), buf));
} else {
//设置对象为空
args.GetReturnValue().SetNull();
}
}
示例12: JS_Escape
void MySQL::JS_Escape(const FunctionCallbackInfo<Value> & args){
if (args[0]->IsString()){
string str = JS2STRING(args[0]);
char* tmp = new char[str.length() * 2 + 1];
mysql_escape_string(tmp, str.c_str(),str.length());
args.GetReturnValue().Set(String::NewFromUtf8(args.GetIsolate(), tmp));
}
else {
args.GetReturnValue().Set(args[0]);
}
}
示例13: 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);
}
示例14: New
void Buffer::New(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
HandleScope handle_scope(isolate);
if (args.IsConstructCall()) {
Buffer* obj = new Buffer(args);
args.GetReturnValue().Set(args.This());
}
else {
std::array<Local<Value>, 1> argv{ args[0] };
Local<Function> cons = Local<Function>::New(isolate, constructor.Get(isolate));
args.GetReturnValue().Set(cons->NewInstance(SafeInt<int>(argv.size()), argv.data()));
}
}
示例15: close
void MyObject::close(const FunctionCallbackInfo<Value>& args)
{
Isolate* isolate=Isolate::GetCurrent();
HandleScope scope(isolate);
MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.Holder());
if(obj->leftPort.close() && obj->rightPort.close())
{
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "OK"));
}
else
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "ERROR - OPENING"));
}