Skip Menu |
 

This queue is for tickets about the JavaScript CPAN distribution.

Report information
The Basics
Id: 13294
Status: resolved
Priority: 0/
Queue: JavaScript

People
Owner: CLAESJAC [...] cpan.org
Requestors: gam3 [...] gam3.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.53
Fixed in:
  • 0.55
  • 1.00

Attachments


Subject: added set_error_handler code
This was tested on a Debian Threaded system.
Download JavaScript.patch
text/x-diff 5k
Binary files JavaScript-0.53/JavaScript-0.54.tar.gz and JavaScript-0.53.gam3/JavaScript-0.54.tar.gz differ diff -uN JavaScript-0.53/JavaScript.pm JavaScript-0.53.gam3/JavaScript.pm --- JavaScript-0.53/JavaScript.pm 2005-03-20 06:16:42.000000000 -0500 +++ JavaScript-0.53.gam3/JavaScript.pm 2005-06-17 17:29:13.000000000 -0400 @@ -152,7 +152,9 @@ die "Argument isn't a CODE reference\n" unless(ref($sub) eq 'CODE'); - SetErrorCallbackImpl($self->{impl}, $sub); + $self->{_error_handler} = $sub; + + SetErrorCallbackImpl($self->{impl}, $self->{_error_handler}); } sub compile { @@ -178,6 +180,7 @@ sub DESTROY { my ($self) = @_; + delete $self->{_error_handler}; } sub create_context { @@ -216,7 +219,7 @@ JS_CLASS_NO_INSTANCE ); -our $VERSION = '0.53'; +our $VERSION = '0.54'; use vars qw($STACKSIZE $MAXBYTES $INITIALIZED); diff -uN JavaScript-0.53/JavaScript.xs JavaScript-0.53.gam3/JavaScript.xs --- JavaScript-0.53/JavaScript.xs 2005-03-20 06:12:15.000000000 -0500 +++ JavaScript-0.53.gam3/JavaScript.xs 2005-06-17 17:25:32.000000000 -0400 @@ -72,9 +72,9 @@ JSContext *cx; /* The JavaScript context which this instance belongs to */ PCB_Function *func_list; /* Pointer to the first callback item that is registered */ PCB_Class *class_list; - SV *error; struct PCB_Context *next; /* Pointer to the next created context */ struct PCB_Runtime *rt; + SV *error_handler; }; typedef struct PCB_Context PCB_Context; @@ -1154,28 +1154,28 @@ /* Error rapporting */ static void PCB_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report) { - fprintf(stderr, "%s at line %d: %s\n", message, report->lineno, report->linebuf); - -/* PCB_Context *context; + PCB_Context *context; SV *errfunc; dSP; context = PCB_GetContext(cx); - if(context != null) { - errfunc = context->error; - + if (context != NULL) { + if (context->error_handler) { ENTER ; SAVETMPS ; PUSHMARK(SP) ; - XPUSHs(newSVpv(message, strlen(message)); - XPUSHs(newSViv(report->lineno); - XPUSHs(newSVpv(report->linebuf, strlen(report->linebuf)); + XPUSHs(newSVpv(message, strlen(message))); + XPUSHs(newSViv(report->lineno)); + if (report->linebuf) { + XPUSHs(newSVpv(report->linebuf, strlen(report->linebuf))); + } PUTBACK; - - perl_call_sv(SvRV(context->error), G_SCALAR); - } */ + perl_call_sv(SvRV(context->error_handler), G_DISCARD); + } else + fprintf(stderr, "%s at line %d: %s\n", message, report->lineno, report->linebuf); + } } /* Calls a Perl function which is bound to a JavaScript function */ @@ -1281,7 +1281,7 @@ croak("Callback is not a reference\n"); } else { if(SvTYPE(SvRV(function)) == SVt_PVCV) { - cx->error = function; + cx->error_handler = function; } else { croak("Callback is not a code reference\n"); } diff -uN JavaScript-0.53/MANIFEST JavaScript-0.53.gam3/MANIFEST --- JavaScript-0.53/MANIFEST 2005-03-20 06:39:23.000000000 -0500 +++ JavaScript-0.53.gam3/MANIFEST 2005-06-17 17:19:31.000000000 -0400 @@ -16,4 +16,5 @@ t/t60can.t t/t70file.js t/t70file.t +t/t90error.t META.yml Module meta-data (added by MakeMaker) diff -uN JavaScript-0.53/META.yml JavaScript-0.53.gam3/META.yml --- JavaScript-0.53/META.yml 2005-03-20 06:39:23.000000000 -0500 +++ JavaScript-0.53.gam3/META.yml 2005-06-17 17:29:39.000000000 -0400 @@ -1,9 +1,10 @@ +# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: JavaScript -version: 0.53 +version: 0.54 version_from: JavaScript.pm installdirs: site requires: distribution_type: module -generated_by: ExtUtils::MakeMaker version 6.12 +generated_by: ExtUtils::MakeMaker version 6.17 Common subdirectories: JavaScript-0.53/t and JavaScript-0.53.gam3/t


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.