Skip Menu |

This queue is for tickets about the JavaScript CPAN distribution.

Report information
The Basics
Id: 71040
Status: open
Priority: 0/
Queue: JavaScript

People
Owner: Nobody in particular
Requestors: cp.montanari [...] tiscali.co.uk
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.16
Fixed in: (no value)



Subject: any attempt to use Javascript to in C++ mode with mozilla jsapi 1.8.5 ?
Hi, I am trying JavaScript 1.16, out of the cpan box. but I am using JS_VERSION 185 (from a debian distro) it has become a bit troublesome. I wonder if there is an attempt on the way to upgrade this package JavaScript to the mozilla JS interface 1.8? which happen to be in C++ now, and with some of the API being phased out! a pre-work would start after applying those patches : diff --git a/Makefile.PL b/Makefile.PL index 4a332cf..6eb20f7 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -177,7 +177,14 @@ END_OF_SOURCE close $test_script; my $exe = tmpnam();; - my $cc = join(" ", $Config{cc}, @ccflags, "-o", $exe, "test_js.c", "-I.", (map { "-I$_" } @incs), $libs, "-l${lib}" ); + +#CPM110827 +# here need to compile with c++ in insing /usr/include/mozjs/jsalloc.h,jsbit.h,jstl.h,.. + + my $cc = join(" ", $Config{'c++'} || 'c++', @ccflags + , "-o", $exe, "test_js.c" + , "-I.", (map { "-I$_" } @incs) + , $libs, "-l${lib}" ); qx($cc); if ($?) { print "Failed compiling test_js.c. ABORTING\n\n$cc\n"; @@ -226,6 +233,14 @@ WriteMakefile( repository => "svn://svn.versed.se/public/Perl/modules/JavaScript" } }, +#CPM110827 +# here need to compile with c++ in insing /usr/include/mozjs/jsalloc.h,jsbit.h,jstl.h,.. + , 'CC' => "c++" + , 'XSOPT' => '-C++' +# , 'XSOPT' => '-C++ -hiertype' + , 'TYPEMAPS' => ['perlobject.map' ] + , LD => 'c++' + ); sub get_paths { Modified Makefile.old then you would have many ... +#ifdef __cplusplus +extern "C" { +#endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#ifdef __cplusplus +} +#endif ... diff --git a/JavaScript.xs b/JavaScript.xs index f251296..65af495 100755 --- a/JavaScript.xs +++ b/JavaScript.xs @@ -1,11 +1,17 @@ +#ifdef __cplusplus +extern "C" { +#endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#ifdef __cplusplus +} +#endif #include "JavaScript.h" -#ifndef FUN_OBJECT(fun) -#define FUN_OBJECT(fun) (jsval)(fun->object) +#ifndef FUN_OBJECT +#define FUN_OBJECT(_fun_) (jsval)(_fun_->object) #endif typedef PJS_PerlArray * JavaScript__PerlArray; @@ -103,7 +109,7 @@ jsr_init_perl_interrupt_handler(cb) RETVAL = handler; OUTPUT: RETVAL - + void jsr_destroy_perl_interrupt_handler(handler) PJS_TrapHandler *handler; @@ -165,7 +171,7 @@ jsc_set_branch_handler(cx, handler) } cx->branch_handler = NULL; - JS_SetBranchCallback(PJS_GetJSContext(cx), NULL); + JS_SetOperationCallback(PJS_GetJSContext(cx), NULL); } else if (SvROK(handler) && SvTYPE(SvRV(handler)) == SVt_PVCV) { if (cx->branch_handler != NULL) { @@ -173,7 +179,7 @@ jsc_set_branch_handler(cx, handler) } cx->branch_handler = SvREFCNT_inc(handler); - JS_SetBranchCallback(PJS_GetJSContext(cx), PJS_branch_handler); + JS_SetOperationCallback(PJS_GetJSContext(cx), (JSOperationCallback)PJS_branch_handler); } void @@ -331,7 +337,7 @@ jsc_free_root(cx, root) jsval *x; CODE: x = INT2PTR(jsval *, SvIV(root)); - JS_RemoveRoot(PJS_GetJSContext(cx), x); + JS_RemoveValueRoot(PJS_GetJSContext(cx), x); jsval jsc_call(cx, function, args) @@ -350,7 +356,7 @@ jsc_call(cx, function, args) tmp = SvIV((SV*)SvRV(PJS_call_perl_method("content", function, NULL))); func = INT2PTR(JSFunction *, tmp); - if (PJS_call_javascript_function(cx, FUN_OBJECT(func), args, &rval) == JS_FALSE) { + if (PJS_call_javascript_function(cx, (jsval) FUN_OBJECT(func), args, &rval) == JS_FALSE) { /* Exception was thrown */ XSRETURN_UNDEF; } @@ -381,12 +387,12 @@ jsc_call(cx, function, args) RETVAL SV * -jsc_call_in_context( cx, afunc, args, rcx, class ) +jsc_call_in_context( cx, afunc, args, rcx, _class ) JavaScript::Context cx; SV *afunc SV *args; SV *rcx; - char *class; + char *_class; PREINIT: jsval rval; jsval aval; @@ -416,9 +422,9 @@ jsc_call_in_context( cx, afunc, args, rcx, class ) } jsobj = JSVAL_TO_OBJECT(context); - if (strlen(class) > 0) { - if( JS_GetProperty(PJS_GetJSContext(cx), JS_GetGlobalObject(PJS_GetJSContext(cx)), class, &aval) == JS_FALSE ) { - croak("cannot get property %s",class); + if (strlen(_class) > 0) { + if( JS_GetProperty(PJS_GetJSContext(cx), JS_GetGlobalObject(PJS_GetJSContext(cx)), _class, &aval) == JS_FALSE ) { + croak("cannot get property %s",_class); Safefree(arg_list); XSRETURN_UNDEF; } @@ -449,7 +455,7 @@ jsc_can(cx, func_name) if (JS_GetProperty(PJS_GetJSContext(cx), JS_GetGlobalObject(PJS_GetJSContext(cx)), func_name, &val)) { if (JSVAL_IS_OBJECT(val)) { JS_ValueToObject(PJS_GetJSContext(cx), val, &object); - if (strcmp(OBJ_GET_CLASS(PJS_GetJSContext(cx), object)->name, "Function") == 0 && + if (strcmp(JS_GET_CLASS(PJS_GetJSContext(cx), object)->name, "Function") == 0 && JS_ValueToFunction(PJS_GetJSContext(cx), val) != NULL) { RETVAL = 1; } @@ -601,3 +607,4 @@ DESTROY(func) JavaScript::PerlFunction func; CODE: PJS_DestroyFunction(func); + Modified JavaScript_Env.h and so on... I am using example of the JSPL package which seems to be more up for the new stuff. but is there already an attempt on the way from JavaScript 1.16? CPM.
Subject: Re: [rt.cpan.org #71040] any attempt to use Javascript to in C++ mode with mozilla jsapi 1.8.5 ?
Date: Sun, 25 Sep 2011 13:15:07 +0200
To: bug-JavaScript [...] rt.cpan.org
From: Claes Jakobsson <claes [...] surfar.nu>
Hi, On Sep 17, 2011, at 10:35 PM, Christian Monatanari via RT wrote: Show quoted text
> Sat Sep 17 16:35:10 2011: Request 71040 was acted upon. > Transaction: Ticket created by ptizoom > Queue: JavaScript > Subject: any attempt to use Javascript to in C++ mode with mozilla jsapi > 1.8.5 ? > Broken in: 1.16 > Severity: Critical > Owner: Nobody > Requestors: cp.montanari@tiscali.co.uk > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=71040 > > > > Hi, I am trying JavaScript 1.16, out of the cpan box. but I am using > JS_VERSION 185 (from a debian distro) > > it has become a bit troublesome. > > I wonder if there is an attempt on the way to upgrade this package > JavaScript to the mozilla JS interface 1.8?
yes, but no ETA Show quoted text
> which happen to be in C++ now, and with some of the API being phased out! > > a pre-work would start after applying those patches :
your patches doesn't apply cleanly as your MUA (or perhaps RT) reformatted it. Please always send patches as attachments. They also break backwards compatibility which is a no-no. I'd like the module to work with at least 1.7 /Claes
Hi, migrating to 1.8.5 at second observation, is quite an undertaking indeed. and I have looked into JSPL package it seems "they" have already a working solutions (which also has been derived from Javascript itself). but if you want to handle backward compatibility with 1.7 which is not in C++, this will even raise the bar. I agree this (embryonic) patch is not a good one for preserving the package ethos, anyway, I think we better have a look into merging JSPL into Javascript, respecting your constraints of backward compatibility and others. Ta for now, Christian Montanari. Show quoted text
> > Hi, I am trying JavaScript 1.16, out of the cpan box. but I am using > > JS_VERSION 185 (from a debian distro) > > > > I wonder if there is an attempt on the way to upgrade this package > > JavaScript to the mozilla JS interface 1.8?
> yes, but no ETA >
> > a pre-work would start after applying those patches :
> > your patches doesn't apply cleanly as your MUA (or perhaps RT) > reformatted it. Please always send patches as attachments. > > They also break backwards compatibility which is a no-no. I'd like the > module to work with at least 1.7
RT-Send-CC: pere [...] hungry.com, 631045 [...] bugs.debian.org
Is there any chance this will be resolved in the next 3 months? If not we could have a play with the ideas described here. Otherwise we would obviously wait.
Subject: Bug#631045: Info received ([rt.cpan.org #71040] any attempt to use Javascript to in C++ mode with mozilla jsapi 1.8.5 ? )
Date: Thu, 05 Jan 2012 20:18:03 +0000
To: bug-JavaScript [...] rt.cpan.org
From: owner [...] bugs.debian.org (Debian Bug Tracking System)
Thank you for the additional information you have supplied regarding this Bug report. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): Debian Perl Group <pkg-perl-maintainers@lists.alioth.debian.org> If you wish to submit further information on this problem, please send it to 631045@bugs.debian.org. Please do not send mail to owner@bugs.debian.org unless you wish to report a problem with the Bug-tracking system. -- 631045: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=631045 Debian Bug Tracking System Contact owner@bugs.debian.org with problems
Hi, Sorry, I did not attempt yet to improve this package. althought the patch I posted shall be quite a good start to do it, but it is just a dent to the amount of work to resolve. then I used instead JSPL whith some relative success... so not planning to work on this for now! Cheers, Christian Montanari.