本文整理汇总了C++中FunctionCallbackInfo::Data方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionCallbackInfo::Data方法的具体用法?C++ FunctionCallbackInfo::Data怎么用?C++ FunctionCallbackInfo::Data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionCallbackInfo
的用法示例。
在下文中一共展示了FunctionCallbackInfo::Data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*
* 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);
}
示例2:
/*
* 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 ();
}
}
示例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: jsVelocity
void ModulePhysics::jsVelocity(const FunctionCallbackInfo<Value> &args)
{
Isolate* isolate = args.GetIsolate();
HandleScope scope(isolate);
ModulePhysics *module = (ModulePhysics*)HelperScript::Unwrap(args.Data());
if (args.Length() < 1 || !args[0]->IsString()) {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "first argument must be entity id as string")));
return;
}
uint64_t id = stoull(*String::Utf8Value(args[0]));
if (!id) {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "invalid entity id")));
return;
}
auto frm = module->Entity->Get<Form>(id);
if (!frm) {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "entity has no form property")));
return;
}
// set velocity
if(args.Length() > 1)
{
btVector3 velocity;
if (args.Length() > 3) {
if (!args[1]->IsNumber() || !args[2]->IsNumber() || !args[3]->IsNumber()) {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "second, third and fourth arguments must be velocity values as numbers")));
return;
}
velocity = btVector3((float)args[1]->NumberValue(), (float)args[2]->NumberValue(), (float)args[3]->NumberValue());
} else if (args.Length() > 1) {
if (!args[1]->IsNumber()) {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "second argument must be a velocity as number")));
return;
}
velocity = btVector3(0, (float)args[1]->NumberValue(), 0);
}
else {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "second or second, third and fourth arguments must be velocity values as numbers")));
return;
}
frm->Body->activate();
frm->Body->setLinearVelocity(velocity);
}
// get velocity
else {
btVector3 velocity = frm->Body->getLinearVelocity();
Handle<Array> result = Array::New(isolate, 3);
result->Set(0, Number::New(isolate, velocity.getX()));
result->Set(1, Number::New(isolate, velocity.getY()));
result->Set(2, Number::New(isolate, velocity.getZ()));
args.GetReturnValue().Set(result);
}
}
示例5: 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);
}
示例6: handle_scope
/**
* TJSオブジェクトのコンストラクタ
*/
void
TJSInstance::tjsConstructor(const FunctionCallbackInfo<Value>& args)
{
Isolate *isolate = args.GetIsolate();
HandleScope handle_scope(isolate);
tTJSVariant classObj;
if (getVariant(isolate, classObj, args.Data()->ToObject())) {
CreateInfo info(classObj, args);
args.GetReturnValue().Set(info.create());
return;
}
args.GetReturnValue().Set(ERROR_BADINSTANCE(isolate));
}
示例7: File
static void
gum_v8_file_on_new_file (const FunctionCallbackInfo<Value> & info)
{
GumV8File * self = static_cast<GumV8File *> (
info.Data ().As<External> ()->Value ());
Isolate * isolate = self->core->isolate;
if (!info.IsConstructCall ())
{
isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (
isolate, "Use `new File()` to create a new instance")));
return;
}
Local<Value> filename_val = info[0];
if (!filename_val->IsString ())
{
isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (isolate,
"File: first argument must be a string specifying filename")));
return;
}
String::Utf8Value filename (filename_val);
Local<Value> mode_val = info[1];
if (!mode_val->IsString ())
{
isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (isolate,
"File: second argument must be a string specifying mode")));
return;
}
String::Utf8Value mode (mode_val);
FILE * handle = fopen (*filename, *mode);
if (handle == NULL)
{
gchar * message = g_strdup_printf ("File: failed to open file (%s)",
strerror (errno));
isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (isolate,
message)));
g_free (message);
return;
}
Local<Object> instance (info.Holder ());
GumFile * file = gum_file_new (instance, handle, self);
instance->SetAlignedPointerInInternalField (0, file);
}
示例8:
/*
* Prototype:
* Process.enumerateMallocRanges(callback)
*
* Docs:
* TBW
*
* Example:
* TBW
*/
static void
gum_v8_process_on_enumerate_malloc_ranges (
const FunctionCallbackInfo<Value> & info)
{
GumV8MatchContext ctx;
ctx.isolate = info.GetIsolate ();
#ifdef HAVE_DARWIN
ctx.self = static_cast<GumV8Process *> (
info.Data ().As<External> ()->Value ());
Local<Value> callbacks_value = info[0];
if (!callbacks_value->IsObject ())
{
ctx.isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (
ctx.isolate, "Process.enumerateMallocRanges: first 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 ();
gum_process_enumerate_malloc_ranges (gum_v8_process_handle_malloc_range_match,
&ctx);
ctx.on_complete->Call (ctx.receiver, 0, 0);
#else
ctx.isolate->ThrowException (Exception::Error (String::NewFromUtf8 (
ctx.isolate, "Process.enumerateMallocRanges: not implemented yet for "
GUM_SCRIPT_PLATFORM)));
#endif
}
示例9:
static void
gum_script_process_on_enumerate_ranges (
const FunctionCallbackInfo<Value> & info)
{
GumScriptMatchContext ctx;
ctx.self = static_cast<GumScriptProcess *> (
info.Data ().As<External> ()->Value ());
ctx.isolate = info.GetIsolate ();
GumPageProtection prot;
if (!_gum_script_page_protection_get (info[0], &prot, ctx.self->core))
return;
Local<Value> callbacks_value = info[1];
if (!callbacks_value->IsObject ())
{
ctx.isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (
ctx.isolate, "Process.enumerateRanges: second argument must be "
"a callback object")));
return;
}
Local<Object> callbacks = Local<Object>::Cast (callbacks_value);
if (!_gum_script_callbacks_get (callbacks, "onMatch", &ctx.on_match,
ctx.self->core))
{
return;
}
if (!_gum_script_callbacks_get (callbacks, "onComplete", &ctx.on_complete,
ctx.self->core))
{
return;
}
ctx.receiver = info.This ();
gum_process_enumerate_ranges (prot, gum_script_process_handle_range_match,
&ctx);
ctx.on_complete->Call (ctx.receiver, 0, 0);
return;
}
示例10: jsImpulse
void ModulePhysics::jsImpulse(const FunctionCallbackInfo<Value> &args)
{
Isolate* isolate = args.GetIsolate();
HandleScope scope(isolate);
ModulePhysics *module = (ModulePhysics*)HelperScript::Unwrap(args.Data());
if (args.Length() < 1 || !args[0]->IsString()) {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "first argument must be entity id as string")));
return;
}
uint64_t id = stoull(*String::Utf8Value(args[0]));
if (!id) {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "invalid entity id")));
return;
}
auto frm = module->Entity->Get<Form>(id);
if (!frm) {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "entity has no form property")));
return;
}
btVector3 impulse;
if (args.Length() > 3) {
if (!args[1]->IsNumber() || !args[2]->IsNumber() || !args[3]->IsNumber()) {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "second, third and fourth arguments must be impulse values as numbers")));
return;
}
impulse = btVector3((float)args[1]->NumberValue(), (float)args[2]->NumberValue(), (float)args[3]->NumberValue());
}
else if (args.Length() > 1) {
if (!args[1]->IsNumber()) {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "second argument must be a impulse as number")));
return;
}
impulse = btVector3(0, (float)args[1]->NumberValue(), 0);
}
else {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "second or second, third and fourth arguments must be impulse values as numbers")));
return;
}
frm->Body->activate();
frm->Body->applyCentralImpulse(impulse);
}
示例11: sizeof
/*
* Prototype:
* Socket.peerAddress(socket_ptr)
*
* Docs:
* TBW
*
* Example:
* TBW
*/
static void
gum_v8_socket_on_peer_address (const FunctionCallbackInfo<Value> & info)
{
GumV8Socket * self = static_cast<GumV8Socket *> (
info.Data ().As<External> ()->Value ());
struct sockaddr_in6 large_addr;
struct sockaddr * addr = reinterpret_cast<struct sockaddr *> (&large_addr);
gum_socklen_t len = sizeof (large_addr);
if (getpeername (info[0]->ToInteger ()->Value (), addr, &len) == 0)
{
info.GetReturnValue ().Set (
gum_v8_socket_address_to_value (addr, self->core));
}
else
{
info.GetReturnValue ().SetNull ();
}
}
示例12: Log
void ConsoleInterfaces::Log(int type, const FunctionCallbackInfo<Value>& args)
{
Handle<External> ext = Handle<External>::Cast(args.Data());
Flathead *pFH = (Flathead *)ext->Value();
int counter = 0;
if (pFH->GetConfiguration()->LoggingFn() != NULL)
{
for (int i = 0; i < args.Length(); i++)
{
Local<Value> value = args[i];
String::Utf8Value outputString(value);
pFH->GetConfiguration()->LoggingFn()(type, *outputString);
counter++;
}
}
args.GetReturnValue().Set(counter);
}
示例13: InvocationCallbackProxy
void FunctionTemplateProxy::InvocationCallbackProxy(const FunctionCallbackInfo<Value>& args)
{
auto proxy = static_cast<ProxyBase*>(args.Data().As<External>()->Value());
V8EngineProxy *engine;
ManagedJSFunctionCallback callback;
if (proxy->GetType() == FunctionTemplateProxyClass)
{
engine = static_cast<FunctionTemplateProxy*>(proxy)->_EngineProxy;
callback = static_cast<FunctionTemplateProxy*>(proxy)->_ManagedCallback;
}
else if (proxy->GetType() == ObjectTemplateProxyClass)
{
engine = static_cast<ObjectTemplateProxy*>(proxy)->_EngineProxy;
callback = static_cast<ObjectTemplateProxy*>(proxy)->_ManagedCallback;
}
else throw exception("'args.Data()' is not recognized.");
if (callback != nullptr) // (note: '_ManagedCallback' may not be set on the proxy, and thus 'callback' may be null)
{
auto argLength = args.Length();
auto _args = argLength > 0 ? new HandleProxy*[argLength] : nullptr;
for (auto i = 0; i < argLength; i++)
_args[i] = engine->GetHandleProxy(args[i]);
auto _this = engine->GetHandleProxy(args.Holder());
auto result = callback(0, args.IsConstructCall(), _this, _args, argLength);
if (result != nullptr)
if (result->IsError())
args.GetReturnValue().Set(ThrowException(Exception::Error(result->Handle()->ToString())));
else
args.GetReturnValue().Set(result->Handle()); // (note: the returned value was created via p/invoke calls from the managed side, so the managed side is expected to tracked and free this handle when done)
// (result == null == undefined [which means the managed side didn't return anything])
}
}
示例14: if
/*
* Prototype:
* Process.setExceptionHandler(callback)
*
* Docs:
* TBW
*
* Example:
* TBW
*/
static void
gum_v8_process_on_set_exception_handler (
const FunctionCallbackInfo<Value> & info)
{
GumV8Process * self = static_cast<GumV8Process *> (
info.Data ().As<External> ()->Value ());
Isolate * isolate = info.GetIsolate ();
bool argument_valid = false;
Local<Function> callback;
if (info.Length () >= 1)
{
Local<Value> argument = info[0];
if (argument->IsFunction ())
{
argument_valid = true;
callback = argument.As<Function> ();
}
else if (argument->IsNull ())
{
argument_valid = true;
}
}
if (!argument_valid)
{
isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (
isolate, "invalid argument")));
return;
}
gum_v8_exception_handler_free (self->exception_handler);
self->exception_handler = NULL;
if (!callback.IsEmpty ())
{
self->exception_handler = gum_v8_exception_handler_new (callback,
self->core);
}
}
示例15: ConstructorCallback
void WeakRef::ConstructorCallback(const FunctionCallbackInfo<Value>& args)
{
try
{
auto extData = args.Data().As<External>();
auto thiz = reinterpret_cast<WeakRef*>(extData->Value());
thiz->ConstructorCallbackImpl(args);
}
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();
}
}