@@ -555,20 +555,28 @@ class TrampolineInfo {
555
555
GICallableInfo *info;
556
556
GIScopeType scope_type;
557
557
558
- TrampolineInfo(Handle<Function> function,
559
- GICallableInfo *info,
560
- GIScopeType scope_type);
558
+ TrampolineInfo(Local<Function> function, GICallableInfo *info, GIScopeType scope_type);
561
559
562
560
void Dispose();
563
- static void Call(ffi_cif *cif, void *result, void **args, void *data);
564
561
void *GetClosure();
562
+
563
+ static void Call(ffi_cif *cif, void *result, void **args, void *data);
565
564
};
566
565
566
+ TrampolineInfo::TrampolineInfo(Local<Function> function,
567
+ GICallableInfo *info,
568
+ GIScopeType scope_type) {
569
+ this->closure = g_callable_info_prepare_closure (info, &cif, TrampolineInfo::Call, this);
570
+ this->persistent.Reset(Isolate::GetCurrent(), function);
571
+ this->info = g_base_info_ref (info);
572
+ this->scope_type = scope_type;
573
+ }
574
+
567
575
void TrampolineInfo::Dispose() {
568
- persistent = nullptr ;
576
+ persistent.Reset() ;
569
577
g_base_info_unref (info);
570
578
g_callable_info_free_closure (info, closure);
571
- };
579
+ }
572
580
573
581
void TrampolineInfo::Call(ffi_cif *cif,
574
582
void *result,
@@ -577,7 +585,7 @@ void TrampolineInfo::Call(ffi_cif *cif,
577
585
TrampolineInfo *trampoline = (TrampolineInfo *) data;
578
586
579
587
int argc = g_callable_info_get_n_args (trampoline->info);
580
- Handle <Value> argv[argc];
588
+ Local <Value> argv[argc];
581
589
582
590
for (int i = 0; i < argc; i++) {
583
591
GIArgInfo arg_info;
@@ -587,25 +595,17 @@ void TrampolineInfo::Call(ffi_cif *cif,
587
595
argv[i] = GIArgumentToV8 (&type_info, (GIArgument *) &args[i]);
588
596
}
589
597
590
- Handle <Function> func = trampoline->func ;
591
- /* Provide a bogus "this" function. Any interested callers should
592
- * bind their callbacks to what they're intersted in... */
593
- Handle<Object> this_obj = func;
594
- Handle<Value> return_value = func->Call (this_obj, argc, argv);
598
+ Local <Function> func = Nan::New<Function> ( trampoline->persistent) ;
599
+ Local<Object> this_obj = func;
600
+
601
+ Local<Value> return_value = func->Call (this_obj, argc, argv) ;
602
+
595
603
GITypeInfo type_info;
596
604
g_callable_info_load_return_type (trampoline->info, &type_info);
605
+
597
606
V8ToGIArgument (&type_info, (GIArgument *) &result, return_value,
598
607
g_callable_info_may_return_null (trampoline->info));
599
608
}
600
-
601
- TrampolineInfo::TrampolineInfo(Handle<Function> function,
602
- GICallableInfo *info,
603
- GIScopeType scope_type) {
604
- this->closure = g_callable_info_prepare_closure (info, &cif, Call, this);
605
- this->func = Persistent<Function>::New (function);
606
- this->info = g_base_info_ref (info);
607
- this->scope_type = scope_type;
608
- }
609
609
#endif
610
610
611
611
};
0 commit comments