@@ -101,7 +101,7 @@ use constant {
101101 DUK_ENUM_SORT_ARRAY_INDICES => (1 << 4),
102102 DUK_ENUM_NO_PROXY_BEHAVIOR => (1 << 5),
103103
104- DUK_COMPILE_EVAL => (1 << 0),
104+ DUK_COMPILE_EVAL => (1 << 0),
105105 DUK_COMPILE_FUNCTION => (1 << 1),
106106 DUK_COMPILE_STRICT => (1 << 2),
107107 DUK_COMPILE_SAFE => (1 << 3),
@@ -146,7 +146,7 @@ sub new {
146146 delete $GlobalRef -> {$ref };
147147 return 1;
148148 };
149-
149+
150150 $duk -> perl_push_function($self -> {finalizer }, 1);
151151 $duk -> put_global_string(' perlFinalizer' );
152152
@@ -157,7 +157,7 @@ sub new {
157157 my $top = $duk -> get_top();
158158
159159 shift if ref $_ [0] eq ' JavaScript::Duktape::Cache' ;
160-
160+
161161 $THIS -> {heapptr } = $heapptr ;
162162 $THIS -> {duk } = $duk ;
163163
@@ -174,7 +174,7 @@ sub new {
174174 $duk -> push_perl($ret );
175175 return 1;
176176 };
177-
177+
178178 $duk -> push_perl_function($self -> {call }, -1);
179179 $duk -> put_global_string(' perlCall' );
180180
@@ -253,7 +253,7 @@ sub eval {
253253 my $duk = $self -> duk;
254254
255255 my $err = $duk -> peval_string($string );
256-
256+
257257 if ($err ){
258258 my $error_string = $duk -> safe_to_string(-1);
259259 croak $error_string ;
@@ -306,7 +306,7 @@ use Carp;
306306sub push_perl {
307307 my $self = shift ;
308308 my $val = shift ;
309-
309+
310310 if (my $ref = ref $val ){
311311 if ($ref eq ' JavaScript::Duktape::NULL' ){
312312 $self -> push_null();
@@ -368,7 +368,7 @@ sub to_perl_object {
368368 my $self = shift ;
369369 my $index = shift ;
370370 my $heapptr = $self -> require_heapptr($index );
371-
371+
372372 return JavaScript::Duktape::Util::jsObject({
373373 duk => $self ,
374374 heapptr => $heapptr
@@ -424,7 +424,7 @@ sub to_perl {
424424 # I'm not sure why I need to
425425 # substract 4 from stack top!!
426426 my $top = $self -> get_top() - 4;
427-
427+
428428 $key = $self -> to_perl(-2);
429429 my $found = 0;
430430 while ($top --){
@@ -463,12 +463,12 @@ sub to_perl {
463463 elsif ($type == JavaScript::Duktape::DUK_TYPE_NULL){
464464 $ret = JavaScript::Duktape::NULL::null();
465465 }
466-
466+
467467 elsif ($type == JavaScript::Duktape::DUK_TYPE_POINTER){
468468 my $p = $self -> get_pointer($index );
469469 $ret = bless \$p , ' JavaScript::Duktape::Pointer' ;
470470 }
471-
471+
472472 return $ret ;
473473}
474474
@@ -540,7 +540,7 @@ sub push_c_function {
540540sub cache {
541541 my $self = shift ;
542542 my $sub = shift ;
543-
543+
544544 my @caller = caller ;
545545 my $code_cache_name = $caller [0] . $caller [2];
546546
@@ -761,14 +761,14 @@ package JavaScript::Duktape::Util; {
761761
762762 my $val = undef ;
763763 $duk -> get_prop_string(-1, $method );
764-
764+
765765 my $type = $duk -> get_type(-1);
766766 if ($type == JavaScript::Duktape::DUK_TYPE_OBJECT ||
767767 $type == JavaScript::Duktape::DUK_TYPE_BUFFER){
768-
768+
769769 if ($duk -> is_function(-1)){
770770 my $function_heap = $duk -> get_heapptr(-1);
771-
771+
772772 if (@_ ){
773773 # called with special no arg _
774774 shift if (ref $_ [0] eq ' NOARGS' );
@@ -868,7 +868,7 @@ package JavaScript::Duktape::Util; {
868868 $duk -> push_heapptr($heapptr );
869869 $duk -> put_prop(-3); # PerlGlobalStash[heapptr] = object
870870 $duk -> pop_2();
871-
871+
872872 my $type = $duk -> get_type(-1);
873873
874874 # #if this is a function return sub immediately
@@ -895,7 +895,7 @@ JavaScript::Duktape - Perl interface to Duktape embeddable javascript engine
895895<a href="https://travis-ci.org/mamod/JavaScript-Duktape"><img src="https://travis-ci.org/mamod/JavaScript-Duktape.svg?branch=master"></a>
896896
897897=head1 SYNOPSIS
898-
898+
899899 use JavaScript::Duktape;
900900
901901 ##create new js context
@@ -917,7 +917,7 @@ JavaScript::Duktape - Perl interface to Duktape embeddable javascript engine
917917
918918=head1 DESCRIPTION
919919
920- JavaScript::Duktape implements almost all duktape javascript engine api, the c code is just
920+ JavaScript::Duktape implements almost all duktape javascript engine api, the c code is just
921921a thin layer that maps duktape api to perl, and all other functions implemented in perl
922922it self, so maintaing and contributing to the base code should be easy.
923923
@@ -947,7 +947,7 @@ To access vm create new context then call C<vm>
947947 my $js = JavaScript::Duktape->new();
948948 my $duk = $js->vm;
949949
950- #now you can call Duktape API from perl
950+ #now you can call Duktape API from perl
951951
952952 $duk->push_string('print');
953953 $duk->eval();
@@ -965,15 +965,15 @@ above but with using C<dump> function to get a glance of stack top
965965 #push "print" string
966966 $duk->push_string('print');
967967 $duk->dump(); #-> [ Duktape (top=1): print ]
968-
968+
969969 #since print is a native function we need to evaluate it
970970 $duk->eval();
971971 $duk->dump(); #-> [ Duktape (top=1): function print() {/* native */} ]
972972
973973 #push one argument to print function
974974 $duk->push_string('hi');
975975 $duk->dump(); #-> [ Duktape (top=2): function print() {/* native */} hi ]
976-
976+
977977 #now call print function and pass "hi" as one argument
978978 $duk->call(1);
979979
@@ -988,7 +988,7 @@ above but with using C<dump> function to get a glance of stack top
988988
989989=head1 VM methods
990990
991- As a general rule all duktape api supported, but I haven't had the chance to test them all,
991+ As a general rule all duktape api supported, but I haven't had the chance to test them all,
992992so please report any missing or failure api call and I'll try to fix
993993
994994For the list of duktape engine API please see L<http://duktape.org/api.html> , and here is how
@@ -1006,8 +1006,8 @@ you can translate duktape api to perl
10061006 # duk_pop(ctx);
10071007
10081008 #and here is how we can implement it in JavaScript::Duktape
1009-
1010- $duk->push_c_function(sub {
1009+
1010+ $duk->push_c_function(sub {
10111011 my $duk = shift;
10121012 my $num1 = $duk->get_int(0);
10131013 my $num2 = $duk->get_int(1);
@@ -1026,12 +1026,12 @@ you can translate duktape api to perl
10261026As you can see all you need to do is replacing C<duk_ > with C<$duk- > > and remove C<ctx > from the function call,
10271027this may sounds crazy but api tests have been generated by copying duktape tests and using search and replace tool :)
10281028
1029- Besides duktape api, C<JavaScript::Duktape::Vm > implements the following methods
1029+ Besides duktape api, C<JavaScript::Duktape::Vm > implements the following methods
10301030
10311031=over 4
1032-
1032+
10331033=item push_function ( code_ref, num_of_args );
1034-
1034+
10351035an alias to push_c_function
10361036
10371037=item push_perl( ... );
@@ -1049,7 +1049,7 @@ resets duktape stack top
10491049=back
10501050
10511051=head1 AUTHOR
1052-
1052+
10531053Mamod Mehyar C<< <[email protected] > >> 10541054
10551055=head1 LICENSE
0 commit comments