jsapigen-devel Mailing List for jsapigen
Status: Beta
Brought to you by:
tdz
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(8) |
Sep
|
Oct
(2) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(1) |
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(9) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: SourceForge.net <no...@so...> - 2013-05-13 05:03:10
|
Feature Requests item #3613163, was opened at 2013-05-12 22:03 Message generated for change (Tracker Item Submitted) made by kg6cvv You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1103475&aid=3613163&group_id=237508 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Priority: 5 Private: No Submitted By: Sean Lynch (kg6cvv) Assigned to: Nobody/Anonymous (nobody) Summary: JSAPI 17 support Initial Comment: I'm running into a few problems trying to use current git as of 2013-05-22 with jsapi 17: 1. uintN is gone, it's now just unsigned (resolved with a typedef in the ,j) 2. JS_NewNumberValue is gone, replaced by JS_NumberValue (resolved by defining a stub function) 3. There is a weird call to cstring() in the generated output. Probably nothing to do with the JSAPI version. If you don't have time to get around to this before I do I'll work on it and send a patch. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1103475&aid=3613163&group_id=237508 |
From: Thomas Z. <td...@us...> - 2013-02-05 09:14:22
|
Hi, Sure, feel free to translate the manual. It's licensed under the GNU FDL 1.2. You shouldn't use the URL that you mentioned. The manual's source code is available from git at git://jsapigen.git.sourceforge.net/gitroot/jsapigen/jsapigen You'll need a Linux system, git and docbook to check out the repository and build it. I think the docbook format also allows multi-language documents. I'd be interested in integrating the translation into the official files. Best regards Thomas Am 04.02.2013 15:20, schrieb Anja Skrba: > Dear Sir, > > My name is Anja and I am Computer Science student at the University > of Belgrade,Serbia. I found your web page about JavaScript, > SpiderMonkey, and JSAPI of a significant use for the community. > > Here is the URL of your page: > http://jsapigen.sourceforge.net/manual.html > > I was wondering if I could translate it to Serbo-Croatian language > and post it on my web site? > > See, my purpose is to help people from Ex Yugoslavia (Serbia, > Montenegro, Croatia, Bosnia and Hercegovina, Slovenia and > Macedonia) to better understand some very useful information about > computer science. > > I hope I'll hear from you soon. > > Many kind regards, > > Anja Skrba http://science.webhostinggeeks.com/ > an...@we... Tel: +381 62300604 > > > ------------------------------------------------------------------------------ > > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics Download AppDynamics > Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan > _______________________________________________ jsapigen-devel > mailing list jsa...@li... > https://lists.sourceforge.net/lists/listinfo/jsapigen-devel > -- GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08 jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See http://jsapigen.sourceforge.net for more information. |
From: Anja S. <an...@we...> - 2013-02-04 14:20:32
|
Dear Sir, My name is Anja and I am Computer Science student at the University of Belgrade,Serbia. I found your web page about JavaScript, SpiderMonkey, and JSAPI of a significant use for the community. Here is the URL of your page: http://jsapigen.sourceforge.net/manual.html I was wondering if I could translate it to Serbo-Croatian language and post it on my web site? See, my purpose is to help people from Ex Yugoslavia (Serbia, Montenegro, Croatia, Bosnia and Hercegovina, Slovenia and Macedonia) to better understand some very useful information about computer science. I hope I'll hear from you soon. Many kind regards, Anja Skrba http://science.webhostinggeeks.com/ an...@we... Tel: +381 62300604 |
From: SourceForge.net <no...@so...> - 2012-07-14 07:58:14
|
Bugs item #3543931, was opened at 2012-07-14 00:58 Message generated for change (Tracker Item Submitted) made by tdz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1103472&aid=3543931&group_id=237508 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Source code Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Thomas Zimmermann (tdz) Assigned to: Thomas Zimmermann (tdz) Summary: Properties cannot have keyword-like names Initial Comment: Naming a property like a keyword gererate a syntax error during parsing. An example class is shown below. class my_class { int property value : get_value; }; This probably happens with other fields then properies as well. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1103472&aid=3543931&group_id=237508 |
From: Thomas Z. <td...@us...> - 2012-07-08 15:27:17
|
Hi Vincent, I applied the first two patches from your series and pushed them upstream. The first one didn't return a value from one of the functions, which I fixed. I also added your name to the THANKS file. I didn't take your patch with the examples, but I created a new package jsapigen-extras, which I'll push upstream in the near future. It'll contain tests, examples, etc. I also pushed a patch for updating the jsapigen's autoconf macro. It now contains a bit of documentation and has its license clarified to use the GNU All-Permissive License. Best regards, Thomas Am Samstag, den 30.06.2012, 13:30 +0100 schrieb Vincent Sanders: > This series of patches applies on the current git master branch and > allows the generated code to be compiled on spidermonkey jsapi API > 1.8.5 indeed the genrated code should compile on all versions of the > api from 1.7 to 1.8.5 > > Also included is a working set of usage examples. > > I note that this project is not currently being maintained, which is > unfortunate. > > I have recently packaged the project for Debain and was hoping a new > release might be forthcoming compatible with later spidermonkey API. > > Is there likely to be any future development? or any objection to my > updates being put in the Debian packaging? > > Finally may I ask, for the debian packaging, could the copyright > status of files in contrib be clarified as this is required for > distribution with Debian. > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > jsapigen-devel mailing list > jsa...@li... > https://lists.sourceforge.net/lists/listinfo/jsapigen-devel -- GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08 jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See http://jsapigen.sourceforge.net for more information. |
From: Thomas Z. <td...@us...> - 2012-07-08 15:19:08
|
Hi Vincent, I also applied this patch. Thank you very much! A review is below. Best regards, Thomas Am Samstag, den 30.06.2012, 13:30 +0100 schrieb Vincent Sanders: > From: Vincent Sanders <vi...@co...> > > The charp parameter passing required updating to allow compilation useing > spidermonkey 1.8.5. In addition the constructed output was altered to use > the new charcter encoding routines to convert directly to utf-8 if > appropriate. > > Signed-off-by: Vincent Sanders <vi...@ky...> > --- > src/hlcl.c | 2 +- > src/jsapi.c | 2 +- > src/jsapiout.c | 47 +++++++++++++++++++++++++++++++++-------------- > 3 files changed, 35 insertions(+), 16 deletions(-) > > diff --git a/src/hlcl.c b/src/hlcl.c > index a06cba2..cee1edc 100644 > --- a/src/hlcl.c > +++ b/src/hlcl.c > @@ -144,7 +144,7 @@ static const struct hlcl_desc jjhlcldesc[] = { > {"CONVERT_INT32_TO_INT", PARAM_I_I}, > {"CONVERT_JSDOUBLE_TO_FLOAT", PARAM_I_I}, > {"CONVERT_JSDOUBLE_TO_DOUBLE", PARAM_I_I}, > - {"CONVERT_JSCHARP_TO_CHARP", PARAM_I_I_I}, > + {"CONVERT_JSCHARP_TO_CHARP", PARAM_I_I_I_I}, > {"CONVERT_JSCHARP_TO_WCHARP", PARAM_I_I_I}, > {"CONVERT_WCHARP_TO_JSCHARP", PARAM_I_I_I}, > {"OBJ_TO_VAR", PARAM_I}, > diff --git a/src/jsapi.c b/src/jsapi.c > index 0af8e46..c50a52d 100644 > --- a/src/jsapi.c > +++ b/src/jsapi.c > @@ -187,7 +187,7 @@ jsapi_append_jsstringp_to_charp_ip(int src, int dst, int len) > > return -((jsapi_append_vardecl(JSAPI_VARTYPE_JSCHAR, 1, var) < 0) || The statements > (hlcltab_append_i_i( HLCL_JS_GET_STRING_CHARS, src, var) < 0) || > - (hlcltab_append_i_i_i(HLCL_CONVERT_JSCHARP_TO_CHARP, dst, var, len) < 0)); belong together. The first one retrieves src's characters, which are then converted by the second. I see why you pass src to the statement below, > + (hlcltab_append_i_i_i_i(HLCL_CONVERT_JSCHARP_TO_CHARP, dst, var, len, src) < 0)); but the real solution would introduce new IR tokens that check for UTF-8 encoding and call the respective functions. But your solution is ok for now. > } > > static int > diff --git a/src/jsapiout.c b/src/jsapiout.c > index db741d6..ac7de1d 100644 > --- a/src/jsapiout.c > +++ b/src/jsapiout.c > @@ -1028,7 +1028,14 @@ jsapi_out_js_get_string_length(const struct hlcl *hlcl, struct jsapi_state *stat > src = hlcl->data.ii.i[0]; > dst = hlcl->data.ii.i[1]; > > - return sigfprintf(f, " var%d = JS_GetStringLength(var%d);\n", dst, src); > + return sigfprintf(f, > + "#if JS_VERSION >= 185\n" > + " if (JS_CStringsAreUTF8()) \n" > + " var%d = JS_GetStringEncodingLength(cx, var%d);\n" > + " else \n" > + "#endif\n" > + " var%d = JS_GetStringLength(var%d);\n", > + dst, src, dst, src); > } > > static int > @@ -1044,7 +1051,12 @@ jsapi_out_js_get_string_chars(const struct hlcl *hlcl, struct jsapi_state *state > src = hlcl->data.ii.i[0]; > dst = hlcl->data.ii.i[1]; > > - return sigfprintf(f, " var%d = JS_GetStringChars(var%d);\n", dst, src); > + return sigfprintf(f, > + "#if JS_VERSION >= 182\n" Is the test for 182 intentionally? AFAIK there is no version 182, just 180 and 185. > + " var%d = JS_GetStringCharsZ(cx, var%d);\n" > + "#else\n" > + " var%d = JS_GetStringChars(var%d);\n" > + "#endif\n", dst, src, dst, src); > } > > static int > @@ -1898,24 +1910,31 @@ jsapi_out_convert_jsdouble_to_double(const struct hlcl *hlcl, struct jsapi_state > static int > jsapi_out_convert_jscharp_to_charp(const struct hlcl *hlcl, struct jsapi_state *state, FILE * f) > { > - int src, dst, len; > + int src, dst, len, jsstr; > > assert(hlcl); > assert(hlcl->op == HLCL_CONVERT_JSCHARP_TO_CHARP); > assert(state); > assert(f); > > - dst = hlcl->data.iii.i[0]; > - src = hlcl->data.iii.i[1]; > - len = hlcl->data.iii.i[2]; > - > - return sigfprintf(f, " {\n" > - " size_t i;\n" > - " for (i = 0; i < var%d; ++i) {\n" > - " var%d[i] = wctob(var%d[i]);\n" > - " }\n" > - " var%d[var%d] = '\\0';\n" > - " }\n", len, dst, src, dst, len); > + dst = hlcl->data.iiii.i[0]; > + src = hlcl->data.iiii.i[1]; > + len = hlcl->data.iiii.i[2]; > + jsstr = hlcl->data.iiii.i[3]; > + > + return sigfprintf(f, > + "#if JS_VERSION >= 185\n" > + " if (JS_CStringsAreUTF8()) {\n" > + " JS_EncodeStringToBuffer(var%d, var%d, var%d);\n" > + " } else \n" > + "#endif\n" > + " {\n" > + " size_t i;\n" > + " for (i = 0; i < var%d; ++i) {\n" > + " var%d[i] = wctob(var%d[i]);\n" > + " }\n" > + " var%d[var%d] = '\\0';\n" > + " }\n", jsstr, dst, len, len, dst, src, dst, len); > } > > static int -- GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08 jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See http://jsapigen.sourceforge.net for more information. |
From: Thomas Z. <td...@us...> - 2012-07-08 15:06:45
|
Hi Vincent, I applied this patch to my tree. Thanks a lot! In case you're interested, you can find a review below. Am Samstag, den 30.06.2012, 13:30 +0100 schrieb Vincent Sanders: > From: Vincent Sanders <vi...@co...> > > The spidermonkey native calling convention changed. This change allows > the generated output to be compiled using this new API. > > Also changed is the constructor object creation, the constructor is now > expected to create its own object requiring a forward declaration of the > class structure. > > This change does not introduce a distinct constructor element (like > finalizers etc.) though given the number of checks on is_constructor > this might be desirable. > > Signed-off-by: Vincent Sanders <vi...@ky...> > --- > src/jsapi.c | 25 ++++++++++++++++++++----- > src/jsapiout.c | 31 ++++++++++++++++++++++++++----- > src/native.c | 1 + > src/native.h | 1 + > src/symtabs.c | 2 ++ > 5 files changed, 50 insertions(+), 10 deletions(-) > > diff --git a/src/jsapi.c b/src/jsapi.c > index d2bc833..0af8e46 100644 > --- a/src/jsapi.c > +++ b/src/jsapi.c > @@ -1589,15 +1589,30 @@ jsapi_build_hlcltab() > "#define JS_EndRequest(cx)\n" > "#define JS_SuspendRequest(cx)\n" > "#define JS_ResumeRequest(cx, saveDepth)\n" > - "#endif\n" > - "#endif\n" > + "#endif /* JS_VERSION */\n" > + "#endif /* JS_THREADSAFE */\n" > + "\n" > /* Function macros */ > "#ifndef JS_FS\n" > - "#define JS_FS(name, call, nargs, flags, extra) {name, call, nargs, flags, extra}\n" > + "#define JJ_JS_FS(name, call, nargs, flags, extra) {name, call, nargs, flags, extra}\n" > + "#elif JS_VERSION >= 185\n" > + "#define JJ_JS_FS(name, call, nargs, flags, extra) JS_FS(name, call, nargs, flags)\n" > + "#else\n" > + "#define JJ_JS_FS(name, call, nargs, flags, extra) JS_FS(name, call, nargs, flags, extra)\n" > "#endif\n" > "#ifndef JS_FS_END\n" > - "#define JS_FS_END {NULL, NULL, 0, 0, 0}\n" > - "#endif\n"}; > + "#define JJ_JS_FS_END JJ_JS_FS(NULL, NULL, 0, 0, 0)\n" > + "#else\n" > + "#define JJ_JS_FS_END JS_FS_END\n" > + "#endif\n" I know I introduced this code block in the first place, but I think a better way would be to get rid of such defines and handle the differences in the generated code below. > + "\n" > + /* native entry macro */ > + "#if JS_VERSION >= 185\n" > + "#define JJ_JSNative(name) name(JSContext *cx, uintN argc, jsval *vp)\n" > + "#else\n" > + "#define JJ_JSNative(name) name(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)\n" > + "#endif\n" Same here. > +}; > > static int regexit = 0; > > diff --git a/src/jsapiout.c b/src/jsapiout.c > index 5df6aa1..db741d6 100644 > --- a/src/jsapiout.c > +++ b/src/jsapiout.c > @@ -1187,9 +1187,30 @@ jsapi_out_enter_native(const struct hlcl *hlcl, struct jsapi_state *state, FILE > nat = hlcl->data.p.p; > assert(nat); > > - return sigfprintf(f, "static JSBool\n" > - "%s(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)\n" > - "{\n", nat->symbol); > + /* forward declare class for constructors */ > + if (nat->attrib.is_constructor && nat->class) { > + sigfprintf(f, "static JSClass %s_class;\n", nat->class->ns); > + } > + > + sigfprintf(f, > + "static JSBool\n" > + "JJ_JSNative(%s)\n" > + "{\n" > + "#if JS_VERSION >= 185\n" > + " jsval *argv = JS_ARGV(cx, vp);\n" > + " jsval *rval = vp;\n", nat->symbol); > + > + if (nat->attrib.is_constructor && nat->class) { I think this should also be handled at runtime via JS_IsConstruction(). Just in case someone uses the generated code for both cases. > + sigfprintf(f, > + " JSObject *obj = JS_NewObject(cx, &%s_class, NULL, NULL);\n" > + " *vp = OBJECT_TO_JSVAL(obj);\n" > + "#endif\n", > + nat->class->ns); > + } else { > + sigfprintf(f, > + " JSObject *obj = JS_THIS_OBJECT(cx, vp);\n" > + "#endif\n"); > + } > } One idea I had to handle the differences in the argument retrieval is to introduce IR tokens or retrieving objects, return values, arguments, etc. These would be called after having entered the native function and would generate the respective JS_VERSION-dependent code blocks. > static int > @@ -1474,7 +1495,7 @@ jsapi_out_leave_func_table(const struct hlcl *hlcl, struct jsapi_state *state, F > assert(state); > assert(f); > > - return sigfprintf(f, " JS_FS_END\n" > + return sigfprintf(f, " JJ_JS_FS_END\n" > "};\n"); > } > > @@ -1491,7 +1512,7 @@ jsapi_out_func_spec(const struct hlcl *hlcl, struct jsapi_state *state, FILE * f > nat = hlcl->data.p.p; > assert(nat); > > - return sigfprintf(f, " JS_FS(\"%s\", %s, %ld, 0, %ld),\n", > + return sigfprintf(f, " JJ_JS_FS(\"%s\", %s, %ld, 0, %ld),\n", > nat->name, > nat->symbol, > nat->argtablen, > diff --git a/src/native.c b/src/native.c > index 9f9b6bd..6d0fb29 100644 > --- a/src/native.c > +++ b/src/native.c > @@ -45,6 +45,7 @@ native_init(struct native *nat) > nat->argtablen = 0; > nat->call = NULL; > nat->nroots = 0; > + nat->class = NULL; > > return 0; > } > diff --git a/src/native.h b/src/native.h > index 42c39ef..6352e39 100644 > --- a/src/native.h > +++ b/src/native.h > @@ -26,6 +26,7 @@ struct native > const char *call; > char *symbol; > unsigned long nroots; > + struct class *class; > }; > > int > diff --git a/src/symtabs.c b/src/symtabs.c > index 332d2ca..5051a2f 100644 > --- a/src/symtabs.c > +++ b/src/symtabs.c > @@ -1217,6 +1217,8 @@ symtabs_construct_leave(struct ast_node *node) > > class->construct = nat-jjnativetab; > > + nat->class = class; > + > return 0; > } Besides the mentioned points, there were several white-space errors and non-expanded tabs. Anyway, thanks again for the patch. Best regards, Thomas -- GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08 jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See http://jsapigen.sourceforge.net for more information. |
From: Thomas Z. <td...@us...> - 2012-07-02 16:29:50
|
Hi Vincent, Thank you very much for your work! Am Samstag, den 30.06.2012, 13:30 +0100 schrieb Vincent Sanders: > This series of patches applies on the current git master branch and > allows the generated code to be compiled on spidermonkey jsapi API > 1.8.5 indeed the genrated code should compile on all versions of the > api from 1.7 to 1.8.5 Sounds good. I'm naturally short on spare time (who isn't? ;), but I'll review your patches over the weekend. > Also included is a working set of usage examples. In the commit message you mentioned that you took the examples from the manual, and like to re-license to the MIT license instead of the GPL. I don't want to mix examples with actual programs and have different licenses within the same package. I find this ugly and confusing. Instead, I'll put the examples in a new package and release it under MIT license. > I note that this project is not currently being maintained, which is > unfortunate. > > I have recently packaged the project for Debain and was hoping a new > release might be forthcoming compatible with later spidermonkey API. > > Is there likely to be any future development? or any objection to my > updates being put in the Debian packaging? Thanks for taking interest in jsapigen and packaging it. As I mentioned, my spare time is very limited; so don't expect any extensive development in the near future. But if you have some patches that you'd like to see upstream, I'm definitely interested. > Finally may I ask, for the debian packaging, could the copyright > status of files in contrib be clarified as this is required for > distribution with Debian. AFAICS there is only a simple autoconf macro, which is licensed under GPL-with-autoconf-exception [1]. I'll put in a more verbose statement. Anything else I can do to make packaging easier? Best regards, Thomas [1] http://www.gnu.org/licenses/autoconf-exception-3.0.html > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > jsapigen-devel mailing list > jsa...@li... > https://lists.sourceforge.net/lists/listinfo/jsapigen-devel -- GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08 jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See http://jsapigen.sourceforge.net for more information. |
From: Vincent S. <vi...@de...> - 2012-07-02 11:50:26
|
From: Vincent Sanders <vi...@co...> Add some examples partially based on examples from the manual. The common startup code may be compiled on any spidermonkey API I would have MIT licenced them all but I did cut and paste from the manual examples so I had to stick to your licence. Signed-off-by: Vincent Sanders <vi...@ky...> --- examples/Makefile | 31 +++++++++++ examples/hello-world.j | 43 +++++++++++++++ examples/hello-world.js | 1 + examples/main.c | 136 +++++++++++++++++++++++++++++++++++++++++++++++ examples/number.j | 42 +++++++++++++++ examples/number.js | 3 ++ examples/object-con.j | 90 +++++++++++++++++++++++++++++++ examples/object-con.js | 5 ++ examples/retval.j | 50 +++++++++++++++++ examples/retval.js | 2 + examples/square.j | 39 ++++++++++++++ examples/square.js | 1 + examples/window.j | 90 +++++++++++++++++++++++++++++++ examples/window.js | 5 ++ 14 files changed, 538 insertions(+) create mode 100644 examples/Makefile create mode 100644 examples/hello-world.j create mode 100644 examples/hello-world.js create mode 100644 examples/main.c create mode 100644 examples/number.j create mode 100644 examples/number.js create mode 100644 examples/object-con.j create mode 100644 examples/object-con.js create mode 100644 examples/retval.j create mode 100644 examples/retval.js create mode 100644 examples/square.j create mode 100644 examples/square.js create mode 100644 examples/window.j create mode 100644 examples/window.js diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..d64cce5 --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,31 @@ +#!/bin/make + +CFLAGS+=-DXP_UNIX -I/usr/include/mozjs -g3 -O2 -Wall -Wno-unused-variable +LDFLAGS+=-lmozjs + +.PHONY: all clean + +EXAMPLES:=hello-world number retval square object-con window + +EXAMPLE_OBJ:=$(addsuffix .o, ${EXAMPLES}) +EXAMPLE_C:=$(addsuffix .c, ${EXAMPLES}) + +all:${EXAMPLES} + +%.c:%.j + jsapigen -f $< -o $@ + +number:main.o number.o + +retval:main.o retval.o + +hello-world:main.o hello-world.o + +square:main.o square.o + +object-con:main.o object-con.o + +window:main.o window.o + +clean: + ${RM} main.o ${EXAMPLES} ${EXAMPLE_OBJ} ${EXAMPLE_C} diff --git a/examples/hello-world.j b/examples/hello-world.j new file mode 100644 index 0000000..38b7469 --- /dev/null +++ b/examples/hello-world.j @@ -0,0 +1,43 @@ +/* + * jsapi hello-world example + * Copyright 2012 Vincent Sanders <vi...@ky...> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +%{ +#include <stdio.h> +#include <jsapi.h> +#include <stdlib.h> + +static void +hello_world(void) +{ + printf("Hello world!\n"); +} + +%} + +function void js_hello_world : hello_world <static>; + +%< + +const char * jsfile = "hello-world.js"; + +JSBool setup_example(JSContext *cx, JSObject *global) +{ + return JS_DefineFunctions(cx, global, jj_fs); +} + +%> diff --git a/examples/hello-world.js b/examples/hello-world.js new file mode 100644 index 0000000..ea35196 --- /dev/null +++ b/examples/hello-world.js @@ -0,0 +1 @@ +js_hello_world(); diff --git a/examples/main.c b/examples/main.c new file mode 100644 index 0000000..75b3941 --- /dev/null +++ b/examples/main.c @@ -0,0 +1,136 @@ +/* + * jsapi examples common code + * Copyright 2012 Vincent Sanders <vi...@ky...> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <jsapi.h> +#include <stdlib.h> + +/* each example provides these two */ +extern const char * jsfile; +extern JSBool setup_example(JSContext *cx, JSObject *global); + +static void reportError(JSContext *cx, const char *message, JSErrorReport *report) +{ + fprintf(stderr, "%s:%u:%s\n", + report->filename ? report->filename : "<no filename>", + (unsigned int) report->lineno, + message); +} + +int +main(int argc, char **argv) +{ + /* The class of the global object. */ + static JSClass global_class = { + "global", + JSCLASS_GLOBAL_FLAGS, + JS_PropertyStub, + JS_PropertyStub, + JS_PropertyStub, +#if JS_VERSION <= 180 + JS_PropertyStub, +#else + JS_StrictPropertyStub, +#endif + JS_EnumerateStub, + JS_ResolveStub, + JS_ConvertStub, + JS_FinalizeStub, + JSCLASS_NO_OPTIONAL_MEMBERS + }; + + + JSRuntime *rt; + JSContext *cx; + JSObject *global; + JSScript *script; + jsval rval; + + /* Create an instance of the engine */ +#if JS_VERSION >= 180 + JS_SetCStringsAreUTF8(); +#endif + + rt = JS_NewRuntime(1024*1024); + + if (!rt) { + exit(EXIT_FAILURE); + } + + /* Create an execution context */ + + cx = JS_NewContext(rt, 8192); + + if (!cx) { + exit(EXIT_FAILURE); + } + + JS_SetVersion(cx, JSVERSION_LATEST); + JS_SetErrorReporter(cx, reportError); + + /* Create a global object and a set of standard objects */ + +#if JS_VERSION <= 180 + global = JS_NewObject(cx, &global_class, NULL, NULL); + if (global == NULL) { + exit(EXIT_FAILURE); + } + JS_SetGlobalObject(cx, global); +#else + global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL); + if (global == NULL) { + exit(EXIT_FAILURE); + } +#endif + + if (JS_InitStandardClasses(cx, global) != JS_TRUE) { + exit(EXIT_FAILURE); + } + + /* Setup example */ + if (setup_example(cx, global) != JS_TRUE) { + exit(EXIT_FAILURE); + } + + /* Execute a script */ + + + /* Compile a script file into a script object */ + + script = JS_CompileFile(cx, global, jsfile); + + if (!script) { + exit(EXIT_FAILURE); + } + + /* Execute script object */ + + JS_ExecuteScript(cx, global, script, &rval); + + /* Remove script object from memory */ +#if JS_VERSION <= 180 + JS_DestroyScript(cx, script); +#endif + + /* Cleanup */ + + JS_DestroyContext(cx); + JS_DestroyRuntime(rt); + JS_ShutDown(); + + exit(EXIT_SUCCESS); +} diff --git a/examples/number.j b/examples/number.j new file mode 100644 index 0000000..09aaf6a --- /dev/null +++ b/examples/number.j @@ -0,0 +1,42 @@ +/* + * jsapi number example + * Copyright 2012 Vincent Sanders <vi...@ky...> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +%{ +#include <jsapi.h> +#include <stdlib.h> +#include <stdio.h> + + static void + print_double(double x) + { + printf("The number is %f.\n", x); + } +%} + +function void js_print_double : print_double (double=1) <static>; + +%< + +const char * jsfile = "number.js"; + +JSBool setup_example(JSContext *cx, JSObject *global) +{ + return JS_DefineFunctions(cx, global, jj_fs); +} + +%> diff --git a/examples/number.js b/examples/number.js new file mode 100644 index 0000000..86438e8 --- /dev/null +++ b/examples/number.js @@ -0,0 +1,3 @@ +js_print_double(4.5); +js_print_double(); +js_print_double("4.5"); diff --git a/examples/object-con.j b/examples/object-con.j new file mode 100644 index 0000000..933cc2d --- /dev/null +++ b/examples/object-con.j @@ -0,0 +1,90 @@ +/* + * jsapi object constructor example + * Copyright 2012 Vincent Sanders <vi...@ky...> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +%{ + +#include <stdlib.h> +#include <stdio.h> + +struct data { + int n; +}; + +static void * +my_class_construct(int n) +{ + struct data *This; + + This = malloc(sizeof(*This)); + + if (!This) { + perror("malloc"); + return NULL; + } + + This->n = n; + + printf("Construting with value %d\n", This->n); + + return This; + + +} + +static void +my_class_show(struct data *This) +{ + printf("Value %d\n", This->n); +} + +static void +my_class_finalize(struct data *This) +{ + if (This) { + printf("Finalising with value %d\n", This->n); + } else { + printf("Finalising with NULL!\n"); + } + free(This); +} + + +%} + +class my_class + { + construct : my_class_construct (int); + function void show : my_class_show (); + finalize : my_class_finalize; + }; + + +%< + +const char * jsfile = "object-con.js"; + +JSBool setup_example(JSContext *cx, JSObject *global) +{ + if (!jjmy_class_init(cx, global)) { + return JS_FALSE; + } + + return JS_DefineFunctions(cx, global, jj_fs); +} + +%> diff --git a/examples/object-con.js b/examples/object-con.js new file mode 100644 index 0000000..aae5fb7 --- /dev/null +++ b/examples/object-con.js @@ -0,0 +1,5 @@ +var foo = new my_class(1); +foo.show(); + +var bar = new my_class(666); +bar.show(); diff --git a/examples/retval.j b/examples/retval.j new file mode 100644 index 0000000..786bb9e --- /dev/null +++ b/examples/retval.j @@ -0,0 +1,50 @@ +/* + * jsapi return value example + * Copyright 2012 Vincent Sanders <vi...@ky...> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +%{ +#include <jsapi.h> +#include <stdlib.h> +#include <stdio.h> + +static int + sum(int n, int m) + { + return n+m; + } + + static void + print_double(double x) + { + printf("The number is %f.\n", x); + } +%} + +function int js_sum : sum (int, int) <static>; +function void js_print_double : print_double (double=1) <static>; + + +%< + +const char * jsfile = "retval.js"; + +JSBool setup_example(JSContext *cx, JSObject *global) +{ + return JS_DefineFunctions(cx, global, jj_fs); +} + +%> diff --git a/examples/retval.js b/examples/retval.js new file mode 100644 index 0000000..5fa1715 --- /dev/null +++ b/examples/retval.js @@ -0,0 +1,2 @@ +js_print_double(js_sum(1, 2)); + js_print_double(js_sum(1, js_sum(2, 3))); diff --git a/examples/square.j b/examples/square.j new file mode 100644 index 0000000..b087039 --- /dev/null +++ b/examples/square.j @@ -0,0 +1,39 @@ +/* + * jsapi square example + * Copyright 2012 Vincent Sanders <vi...@ky...> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +%{ + +int c_square(int n) +{ + return n*n; +} + +%} + +function int js_square : c_square (int=2) <static>; + +%< + +const char * jsfile = "square.js"; + +JSBool setup_example(JSContext *cx, JSObject *global) +{ + return JS_DefineFunctions(cx, global, jj_fs); +} + +%> diff --git a/examples/square.js b/examples/square.js new file mode 100644 index 0000000..6b0521f --- /dev/null +++ b/examples/square.js @@ -0,0 +1 @@ +c_square(12); \ No newline at end of file diff --git a/examples/window.j b/examples/window.j new file mode 100644 index 0000000..a6c539f --- /dev/null +++ b/examples/window.j @@ -0,0 +1,90 @@ +/* + * jsapi browser window class example + * Copyright 2012 Vincent Sanders <vi...@ky...> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +%{ + +#include <stdio.h> + +void jsapi_window_close() +{ + printf("%s\n", __func__); + return; +} + +void jsapi_window_stop() +{ + printf("%s\n", __func__); + return; +} + +void jsapi_window_focus() +{ + printf("%s\n", __func__); + return; +} + +void jsapi_window_blur() +{ + printf("%s\n", __func__); + return; +} + +void jsapi_window_open(void *this, char *url, char *target, char *features, int replace) +{ + printf("%s(%s,%s,%s,%d)\n", __func__, url,target,features,replace); + return; +} + +/* attribute (property) setter/getetrs */ +char *jsapi_window_status_get(void) +{ + return NULL; +} + +void jsapi_window_status_set(char *s) +{ +} + +%} + +class window { + /* window functions */ + function void close : jsapi_window_close (); + function void stop : jsapi_window_stop (); + function void focus : jsapi_window_focus (); + function void blur : jsapi_window_blur (); + function void open : jsapi_window_open (cstring=NULL, cstring=NULL, cstring=NULL, int=0); + + /* window properties */ + property cstring status: jsapi_window_status_get , jsapi_window_status_set <static>; +}; + +%< + +const char * jsfile = "window.js"; + +JSBool setup_example(JSContext *cx, JSObject *global) +{ + if (!jjwindow_init(cx, global)) { + return JS_FALSE; + } + + return JS_TRUE; +} + +%> diff --git a/examples/window.js b/examples/window.js new file mode 100644 index 0000000..5a117d1 --- /dev/null +++ b/examples/window.js @@ -0,0 +1,5 @@ +window.close(); + +window.status = "hello"; + +window.open("http://www.ebay.co.uk/"); -- 1.7.10 |
From: Vincent S. <vi...@de...> - 2012-07-02 11:50:26
|
From: Vincent Sanders <vi...@co...> The charp parameter passing required updating to allow compilation useing spidermonkey 1.8.5. In addition the constructed output was altered to use the new charcter encoding routines to convert directly to utf-8 if appropriate. Signed-off-by: Vincent Sanders <vi...@ky...> --- src/hlcl.c | 2 +- src/jsapi.c | 2 +- src/jsapiout.c | 47 +++++++++++++++++++++++++++++++++-------------- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/hlcl.c b/src/hlcl.c index a06cba2..cee1edc 100644 --- a/src/hlcl.c +++ b/src/hlcl.c @@ -144,7 +144,7 @@ static const struct hlcl_desc jjhlcldesc[] = { {"CONVERT_INT32_TO_INT", PARAM_I_I}, {"CONVERT_JSDOUBLE_TO_FLOAT", PARAM_I_I}, {"CONVERT_JSDOUBLE_TO_DOUBLE", PARAM_I_I}, - {"CONVERT_JSCHARP_TO_CHARP", PARAM_I_I_I}, + {"CONVERT_JSCHARP_TO_CHARP", PARAM_I_I_I_I}, {"CONVERT_JSCHARP_TO_WCHARP", PARAM_I_I_I}, {"CONVERT_WCHARP_TO_JSCHARP", PARAM_I_I_I}, {"OBJ_TO_VAR", PARAM_I}, diff --git a/src/jsapi.c b/src/jsapi.c index 0af8e46..c50a52d 100644 --- a/src/jsapi.c +++ b/src/jsapi.c @@ -187,7 +187,7 @@ jsapi_append_jsstringp_to_charp_ip(int src, int dst, int len) return -((jsapi_append_vardecl(JSAPI_VARTYPE_JSCHAR, 1, var) < 0) || (hlcltab_append_i_i( HLCL_JS_GET_STRING_CHARS, src, var) < 0) || - (hlcltab_append_i_i_i(HLCL_CONVERT_JSCHARP_TO_CHARP, dst, var, len) < 0)); + (hlcltab_append_i_i_i_i(HLCL_CONVERT_JSCHARP_TO_CHARP, dst, var, len, src) < 0)); } static int diff --git a/src/jsapiout.c b/src/jsapiout.c index db741d6..ac7de1d 100644 --- a/src/jsapiout.c +++ b/src/jsapiout.c @@ -1028,7 +1028,14 @@ jsapi_out_js_get_string_length(const struct hlcl *hlcl, struct jsapi_state *stat src = hlcl->data.ii.i[0]; dst = hlcl->data.ii.i[1]; - return sigfprintf(f, " var%d = JS_GetStringLength(var%d);\n", dst, src); + return sigfprintf(f, + "#if JS_VERSION >= 185\n" + " if (JS_CStringsAreUTF8()) \n" + " var%d = JS_GetStringEncodingLength(cx, var%d);\n" + " else \n" + "#endif\n" + " var%d = JS_GetStringLength(var%d);\n", + dst, src, dst, src); } static int @@ -1044,7 +1051,12 @@ jsapi_out_js_get_string_chars(const struct hlcl *hlcl, struct jsapi_state *state src = hlcl->data.ii.i[0]; dst = hlcl->data.ii.i[1]; - return sigfprintf(f, " var%d = JS_GetStringChars(var%d);\n", dst, src); + return sigfprintf(f, + "#if JS_VERSION >= 182\n" + " var%d = JS_GetStringCharsZ(cx, var%d);\n" + "#else\n" + " var%d = JS_GetStringChars(var%d);\n" + "#endif\n", dst, src, dst, src); } static int @@ -1898,24 +1910,31 @@ jsapi_out_convert_jsdouble_to_double(const struct hlcl *hlcl, struct jsapi_state static int jsapi_out_convert_jscharp_to_charp(const struct hlcl *hlcl, struct jsapi_state *state, FILE * f) { - int src, dst, len; + int src, dst, len, jsstr; assert(hlcl); assert(hlcl->op == HLCL_CONVERT_JSCHARP_TO_CHARP); assert(state); assert(f); - dst = hlcl->data.iii.i[0]; - src = hlcl->data.iii.i[1]; - len = hlcl->data.iii.i[2]; - - return sigfprintf(f, " {\n" - " size_t i;\n" - " for (i = 0; i < var%d; ++i) {\n" - " var%d[i] = wctob(var%d[i]);\n" - " }\n" - " var%d[var%d] = '\\0';\n" - " }\n", len, dst, src, dst, len); + dst = hlcl->data.iiii.i[0]; + src = hlcl->data.iiii.i[1]; + len = hlcl->data.iiii.i[2]; + jsstr = hlcl->data.iiii.i[3]; + + return sigfprintf(f, + "#if JS_VERSION >= 185\n" + " if (JS_CStringsAreUTF8()) {\n" + " JS_EncodeStringToBuffer(var%d, var%d, var%d);\n" + " } else \n" + "#endif\n" + " {\n" + " size_t i;\n" + " for (i = 0; i < var%d; ++i) {\n" + " var%d[i] = wctob(var%d[i]);\n" + " }\n" + " var%d[var%d] = '\\0';\n" + " }\n", jsstr, dst, len, len, dst, src, dst, len); } static int -- 1.7.10 |
From: Vincent S. <vi...@de...> - 2012-07-02 11:50:25
|
From: Vincent Sanders <vi...@co...> The spidermonkey native calling convention changed. This change allows the generated output to be compiled using this new API. Also changed is the constructor object creation, the constructor is now expected to create its own object requiring a forward declaration of the class structure. This change does not introduce a distinct constructor element (like finalizers etc.) though given the number of checks on is_constructor this might be desirable. Signed-off-by: Vincent Sanders <vi...@ky...> --- src/jsapi.c | 25 ++++++++++++++++++++----- src/jsapiout.c | 31 ++++++++++++++++++++++++++----- src/native.c | 1 + src/native.h | 1 + src/symtabs.c | 2 ++ 5 files changed, 50 insertions(+), 10 deletions(-) diff --git a/src/jsapi.c b/src/jsapi.c index d2bc833..0af8e46 100644 --- a/src/jsapi.c +++ b/src/jsapi.c @@ -1589,15 +1589,30 @@ jsapi_build_hlcltab() "#define JS_EndRequest(cx)\n" "#define JS_SuspendRequest(cx)\n" "#define JS_ResumeRequest(cx, saveDepth)\n" - "#endif\n" - "#endif\n" + "#endif /* JS_VERSION */\n" + "#endif /* JS_THREADSAFE */\n" + "\n" /* Function macros */ "#ifndef JS_FS\n" - "#define JS_FS(name, call, nargs, flags, extra) {name, call, nargs, flags, extra}\n" + "#define JJ_JS_FS(name, call, nargs, flags, extra) {name, call, nargs, flags, extra}\n" + "#elif JS_VERSION >= 185\n" + "#define JJ_JS_FS(name, call, nargs, flags, extra) JS_FS(name, call, nargs, flags)\n" + "#else\n" + "#define JJ_JS_FS(name, call, nargs, flags, extra) JS_FS(name, call, nargs, flags, extra)\n" "#endif\n" "#ifndef JS_FS_END\n" - "#define JS_FS_END {NULL, NULL, 0, 0, 0}\n" - "#endif\n"}; + "#define JJ_JS_FS_END JJ_JS_FS(NULL, NULL, 0, 0, 0)\n" + "#else\n" + "#define JJ_JS_FS_END JS_FS_END\n" + "#endif\n" + "\n" + /* native entry macro */ + "#if JS_VERSION >= 185\n" + "#define JJ_JSNative(name) name(JSContext *cx, uintN argc, jsval *vp)\n" + "#else\n" + "#define JJ_JSNative(name) name(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)\n" + "#endif\n" +}; static int regexit = 0; diff --git a/src/jsapiout.c b/src/jsapiout.c index 5df6aa1..db741d6 100644 --- a/src/jsapiout.c +++ b/src/jsapiout.c @@ -1187,9 +1187,30 @@ jsapi_out_enter_native(const struct hlcl *hlcl, struct jsapi_state *state, FILE nat = hlcl->data.p.p; assert(nat); - return sigfprintf(f, "static JSBool\n" - "%s(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)\n" - "{\n", nat->symbol); + /* forward declare class for constructors */ + if (nat->attrib.is_constructor && nat->class) { + sigfprintf(f, "static JSClass %s_class;\n", nat->class->ns); + } + + sigfprintf(f, + "static JSBool\n" + "JJ_JSNative(%s)\n" + "{\n" + "#if JS_VERSION >= 185\n" + " jsval *argv = JS_ARGV(cx, vp);\n" + " jsval *rval = vp;\n", nat->symbol); + + if (nat->attrib.is_constructor && nat->class) { + sigfprintf(f, + " JSObject *obj = JS_NewObject(cx, &%s_class, NULL, NULL);\n" + " *vp = OBJECT_TO_JSVAL(obj);\n" + "#endif\n", + nat->class->ns); + } else { + sigfprintf(f, + " JSObject *obj = JS_THIS_OBJECT(cx, vp);\n" + "#endif\n"); + } } static int @@ -1474,7 +1495,7 @@ jsapi_out_leave_func_table(const struct hlcl *hlcl, struct jsapi_state *state, F assert(state); assert(f); - return sigfprintf(f, " JS_FS_END\n" + return sigfprintf(f, " JJ_JS_FS_END\n" "};\n"); } @@ -1491,7 +1512,7 @@ jsapi_out_func_spec(const struct hlcl *hlcl, struct jsapi_state *state, FILE * f nat = hlcl->data.p.p; assert(nat); - return sigfprintf(f, " JS_FS(\"%s\", %s, %ld, 0, %ld),\n", + return sigfprintf(f, " JJ_JS_FS(\"%s\", %s, %ld, 0, %ld),\n", nat->name, nat->symbol, nat->argtablen, diff --git a/src/native.c b/src/native.c index 9f9b6bd..6d0fb29 100644 --- a/src/native.c +++ b/src/native.c @@ -45,6 +45,7 @@ native_init(struct native *nat) nat->argtablen = 0; nat->call = NULL; nat->nroots = 0; + nat->class = NULL; return 0; } diff --git a/src/native.h b/src/native.h index 42c39ef..6352e39 100644 --- a/src/native.h +++ b/src/native.h @@ -26,6 +26,7 @@ struct native const char *call; char *symbol; unsigned long nroots; + struct class *class; }; int diff --git a/src/symtabs.c b/src/symtabs.c index 332d2ca..5051a2f 100644 --- a/src/symtabs.c +++ b/src/symtabs.c @@ -1217,6 +1217,8 @@ symtabs_construct_leave(struct ast_node *node) class->construct = nat-jjnativetab; + nat->class = class; + return 0; } -- 1.7.10 |
From: Vincent S. <vi...@de...> - 2012-07-02 11:50:25
|
This series of patches applies on the current git master branch and allows the generated code to be compiled on spidermonkey jsapi API 1.8.5 indeed the genrated code should compile on all versions of the api from 1.7 to 1.8.5 Also included is a working set of usage examples. I note that this project is not currently being maintained, which is unfortunate. I have recently packaged the project for Debain and was hoping a new release might be forthcoming compatible with later spidermonkey API. Is there likely to be any future development? or any objection to my updates being put in the Debian packaging? Finally may I ask, for the debian packaging, could the copyright status of files in contrib be clarified as this is required for distribution with Debian. |
From: Thomas Z. <zau...@go...> - 2011-06-13 18:52:35
|
Hi Richard! Thanks! :) I haven't had time to look at the files you sent me, but I'll look at your changes soon, add them to the git tree, and probably release a new version. Actually, I'm currently not working on jsapigen, and haven't for a while. However, if you find any bugs you can send me patches and I'll integrate them. IIRC the version in the public git repository should be 0.5.1. Thanks again for your submission! Regards Thomas Am Sonntag, den 12.06.2011, 21:24 -0400 schrieb Richard Hildred: > Hi: > > > Thanks for writing jsapigen. It seems like a good way to get started > as you have a hello world example, something which I didn't find > complete elsewhere. I did have to make a couple of changes to get it > working for js-1.8.5. I attached the example and the files I changed. > > > thanks again > > > Rich > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically advanced content > authoring tool. Experience the power of Track Changes, Inline Image > Editing and ensure content is compliant with Accessibility Checking. > http://p.sf.net/sfu/ephox-dev2dev > _______________________________________________ jsapigen-devel mailing list jsa...@li... https://lists.sourceforge.net/lists/listinfo/jsapigen-devel -- GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08 jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See http://jsapigen.sourceforge.net for more information. |
From: Richard H. <rhi...@us...> - 2011-06-13 01:32:05
|
Hi: Thanks for writing jsapigen. It seems like a good way to get started as you have a hello world example, something which I didn't find complete elsewhere. I did have to make a couple of changes to get it working for js-1.8.5. I attached the example and the files I changed. thanks again Rich |
From: Thomas Z. <td...@us...> - 2010-03-02 17:15:22
|
Hi > It is example 6 and 7 in Writing Interface Descriptions I am having problems with. The descriptions of constructors and finalizers were wrong. I just fixed the manual and uploaded a new version [1][2]. Thanks again for reporting. Regards Thomas [1] http://jsapigen.sourceforge.net/manual.html [2] http://downloads.sourceforge.net/project/jsapigen/jsapigen/jsapigen-0.5/jsapigen-0.5.1-manual.tar.gz -- GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08 jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See http://jsapigen.sourceforge.net for more information. |
From: Thomas Z. <td...@us...> - 2010-03-02 16:53:08
|
Hi > It is example 6 and 7 in Writing Interface Descriptions I am having problems with. Argh! This is a stupid bug in the manual. The keywords 'construct' and 'finalize' are always followed by a colon to make their syntax similar to 'function' or 'property' declarations. Also parameters do only have types, but not names. Example 6 should therefore read like this: class my_class { construct : my_class_construct (int) <static>; }; I attached both fixed examples and I'll updated the manual. Thanks for reporting this. Regards, Thomas -- GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08 jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See http://jsapigen.sourceforge.net for more information. |
From: Erik A. K. <eri...@em...> - 2010-03-02 15:14:19
|
Hi, I am sorry. It is not example 6 and 7 in the Introduction that are giving me problems. It is example 6 and 7 in Writing Interface Descriptions I am having problems with. I have attached them to this mail. The character encoding is ASCII, with cr, lf for line endings. Regards Erik > -----Original Message----- > From: Thomas Zimmermann [mailto:td...@us...] > Sent: Tuesday, March 02, 2010 1:50 PM > To: Erik Aagaard Knudsen > Cc: jsa...@li... > Subject: Re: [jsapigen-devel] Syntax error on example 6 and 7 in the > manual > > Hi, > > thanks for trying jsapigen. > > > > I use Cygwin under Windows Vista. The gcc compiler used for compiling > > jsapigen is version 3.4.4. > > I looked at the examples, but couldn't reproduce your error on my > machine (x86-64, Fedora 12, gcc 4.4.3). > > > > Any idea of what the problem is? > > Not yet. I attached my input and output files to this mail. > > Could you send me your input file? Sometimes it's just some typo. > > What character encoding do you use? jsapigen takes care of different > line endings, but maybe there are other problems lurking. > > Otherwise I'll take a closer look at it within the next few days. (I'll > have to install Cygwin first.) > > > Regards, Thomas > > > > -- > GnuPG: http://tdz.users.sourceforge.net/tdz.asc > Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08 > > jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See > http://jsapigen.sourceforge.net for more information. |
From: Thomas Z. <td...@us...> - 2010-03-02 12:53:10
|
Hi, thanks for trying jsapigen. > I use Cygwin under Windows Vista. The gcc compiler used for compiling > jsapigen is version 3.4.4. I looked at the examples, but couldn't reproduce your error on my machine (x86-64, Fedora 12, gcc 4.4.3). > Any idea of what the problem is? Not yet. I attached my input and output files to this mail. Could you send me your input file? Sometimes it's just some typo. What character encoding do you use? jsapigen takes care of different line endings, but maybe there are other problems lurking. Otherwise I'll take a closer look at it within the next few days. (I'll have to install Cygwin first.) Regards, Thomas -- GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08 jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See http://jsapigen.sourceforge.net for more information. |
From: Erik A. K. <eri...@em...> - 2010-03-02 11:54:19
|
Hello, I am having problems with example 6 and example 7 in the manual. Example 6. Static Constructors gives me the following error when processed with jsapigen: 18: m syntax error, unexpected TOK_IDENTIFIER, expecting ':' Line 18 is at eof. If I out commeny the "construct" line then jsapigen generates no error. Example 7. Constructors and Finalizers gives me the same error for both the "construct" and the "finalize line". Other examples are processed ok. I use Cygwin under Windows Vista. The gcc compiler used for compiling jsapigen is version 3.4.4. Any idea of what the problem is? -Erik Aagaard Knudsen |
From: Thomas Z. <td...@us...> - 2010-01-04 18:25:43
|
Hi, I'm happy to announce the immediate availability of jsapigen 0.5. jsapigen is a glue-code generator for embedding JavaScript in C-written applications. Some highlights of version 0.5 include - support for calls from C to JavaScript, - stack-based memory allocation for less overhead, and - an improved manual. Please have a look at http://jsapigen.sourceforge.net. Thomas -- GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08 jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See http://jsapigen.sourceforge.net for more information. |
From: Thomas Z. <td...@us...> - 2008-10-19 08:39:08
|
Hi > can i interface to C++ ? Well, jsapigen aims to generate pure ISO C89 code. So this can at least be linked together. My approach to C++ support has always been to auto-generate some wrapper code around C++ constructs, something like class my_class { public: int foo(); }; int my_class_foo(void *p) { return ((my_class*)p)->foo(); } and then call my_class_foo from within the JavaScript engine. But I don't know if there already is such a wrapper generator. Otherwise you might have a look at 'jsgen' [1]. AFAICS this program does something similar to jsapigen and uses C++. However it doesn't seem to be under active development. > what is the generated files' license? Whatever you want, copyleft, bsd-style, proprietary. Only jsapigen itself is covered by the GPL. Best regards, Thomas [1] http://www.cs.unm.edu/~cello/jsgen/ |
From: Christian R. B. <chr...@gm...> - 2008-10-18 21:48:31
|
Hello, i would have two questions regarding jsapigen: can i interface to C++ ? (instantiate objects .. call methods etc ..) and: what is the generated files' license? (this is because i would like to hook up an lgpl project) yours Christian -- Q: How many Zen masters does it take to screw in a light bulb? A: None. The Universe spins the bulb, and the Zen master stays out of the way. |
From: SourceForge.net <no...@so...> - 2008-08-27 09:36:38
|
Bugs item #2076578, was opened at 2008-08-26 21:44 Message generated for change (Comment added) made by tdz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1103472&aid=2076578&group_id=237508 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Thomas D. Zimmermann (tdz) Assigned to: Thomas D. Zimmermann (tdz) Summary: syntax error with lex Initial Comment: lex on SunOS 5.10 produces a syntax error. Example file attached. lex version is 'lex: Software Generation Utilities (SGU) Solaris-ELF (4.0)' -Thomas ---------------------------------------------------------------------- >Comment By: Thomas D. Zimmermann (tdz) Date: 2008-08-27 11:36 Message: Logged In: YES user_id=372719 Originator: YES This version of lex doesn't support character class expressions, e.g. [:blank:], [:alnum:], etc. The bug can be fixed by replacing these with more explicit character classes. -Thomas ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1103472&aid=2076578&group_id=237508 |
From: SourceForge.net <no...@so...> - 2008-08-26 19:49:51
|
Feature Requests item #2076583, was opened at 2008-08-26 21:45 Message generated for change (Settings changed) made by tdz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1103475&aid=2076583&group_id=237508 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Priority: 5 Private: No Submitted By: Thomas D. Zimmermann (tdz) >Assigned to: Thomas D. Zimmermann (tdz) Summary: Array support Initial Comment: Support arrays as function arguments. -Thomas ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1103475&aid=2076583&group_id=237508 |
From: SourceForge.net <no...@so...> - 2008-08-26 19:49:41
|
Feature Requests item #2076584, was opened at 2008-08-26 21:46 Message generated for change (Settings changed) made by tdz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1103475&aid=2076584&group_id=237508 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Priority: 5 Private: No Submitted By: Thomas D. Zimmermann (tdz) >Assigned to: Thomas D. Zimmermann (tdz) Summary: Support NULL as default string Initial Comment: Support NULL, 0, etc. as string default, e.g. f(cstring=NULL) -Thomas ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1103475&aid=2076584&group_id=237508 |