File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -175,9 +175,8 @@ sub new {
175175 return 1;
176176 };
177177
178- $duk -> push_perl_function($self -> {call }, -1, 1 );
178+ $duk -> push_perl_function($self -> {call }, -1);
179179 $duk -> put_global_string(' perlCall' );
180-
181180 return $self ;
182181}
183182
@@ -265,11 +264,20 @@ sub eval {
265264sub vm { shift -> {duk }; }
266265sub duk { shift -> {duk }; }
267266
267+ sub destroy {
268+ my $self = shift ;
269+ return if !$self -> {duk };
270+ local $@ ; # duk_desatroy_heap mess with $@!!
271+ $self -> {duk }-> gc(0);
272+ $self -> {duk }-> destroy_heap();
273+ delete $self -> {duk };
274+ }
275+
268276sub DESTROY {
269277 my $self = shift ;
270278 my $duk = $self -> duk;
271279 if ($self -> {pid } == $$ ){
272- $duk -> destroy_heap ();
280+ $self -> destroy ();
273281 }
274282}
275283
@@ -512,7 +520,6 @@ sub push_c_function {
512520 my $self = shift ;
513521 my $sub = shift ;
514522 my $nargs = shift || -1;
515- my $nofinalizer = shift ;
516523
517524 $GlobalRef -> {" $sub " } = sub {
518525 my @args = @_ ;
@@ -547,8 +554,6 @@ sub push_c_function {
547554 };
548555
549556 $self -> perl_push_function($GlobalRef -> {" $sub " }, $nargs );
550-
551- return if $nofinalizer ;
552557 $self -> eval_string(" (function(){perlFinalizer('$sub ')})" );
553558 $self -> set_finalizer(-2);
554559}
You can’t perform that action at this time.
0 commit comments