void transfer(const FunctionCallbackInfo<Value> &args) { /* fd, SSL */ int *fd = new int(dup(args[0]->IntegerValue())); SSL *ssl = nullptr; if (args[1]->IsExternal()) { ssl = (SSL *) args[1].As<External>()->Value(); ssl->references++; } Local<Object> ticket = Local<Object>::New(args.GetIsolate(), persistentTicket)->Clone(); ticket->SetAlignedPointerInInternalField(0, fd); ticket->SetAlignedPointerInInternalField(1, ssl); args.GetReturnValue().Set(ticket); }
void JavaObject::wrap(Isolate* isolate, Local<Object> jsObject) { ASSERT(persistent().IsEmpty()); ASSERT(jsObject->InternalFieldCount() > 0); jsObject->SetAlignedPointerInInternalField(0, this); persistent().Reset(isolate, jsObject); }
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); }
static void gum_v8_call_probe_fire (GumCallSite * site, gpointer user_data) { GumV8CallProbe * self = static_cast<GumV8CallProbe *> (user_data); ScriptScope scope (self->parent->core->script); Isolate * isolate = self->parent->core->isolate; Local<ObjectTemplate> probe_args ( Local<ObjectTemplate>::New (isolate, *self->parent->probe_args)); Local<Object> args = probe_args->NewInstance (); args->SetAlignedPointerInInternalField (0, self); args->SetAlignedPointerInInternalField (1, site); Local<Function> callback (Local<Function>::New (isolate, *self->callback)); Local<Value> receiver (Local<Value>::New (isolate, *self->receiver)); Handle<Value> argv[] = { args }; callback->Call (receiver, 1, argv); }
Local<Object> wrap(Local<Object> s) { s->SetAlignedPointerInInternalField(0, wsi); s->SetAlignedPointerInInternalField(1, extension); return s; }
Handle<Value> wrap_lisp_symbol(Lisp_Object sym) { Local<Object> obj = symbol_templ->GetFunction()->NewInstance(); //obj->SetInternalField(0, External::New((void*)sym)); obj->SetAlignedPointerInInternalField(0, (void*) sym); return obj; }