|
From: Neil Madden on 2 Jul 2008 16:12 jalitt(a)gmail.com wrote: > Okay, taming spidermonkey is one possibility. I also found - > http://browsex.com/jstcl.html , which might be able to do the trick. > The source is available from the site. Maybe I'll get a chance to > play around with that or spidermonkey in the near future. I think > that developing a method of HTTP access behind these large corporate > firewalls would be an asset to the community. I've also wanted easy access to JavaScript from Tcl before (web-scraping needs it more and more these days). Well, I didn't feel like hacking around with SpiderMonkey (the install instructions seemed to start with a dozen or so dependencies, like most Mozilla stuff...), so I instead opted to quickly wrap the NJS JavaScript interpreter library (http://www.njs-javascript.org/), which is lightweight and pretty decent. I've put the result up at: http://www.cs.nott.ac.uk/~nem/tcl/ as the "tcljs" package. Note: it's LGPL as that is the license NJS uses (fine for me). Usage: package require tcljs 1.0 tcljs js ;# create interpreter instance js eval { function foo(a, b) { return a * b; } foo(12, 23) } Should make things pretty simple :-) Note though, that NJS does mention that it is not an entirely standards-compliant interpreter, so possibly might fail on some things. Should be fine for proxy .pac files, I'd guess, though. I was thinking about adding some more features to this, but then I remembered that TkHTML also has a JavaScript library -- this time to the SEE lib. See http://tkhtml.tcl.tk/hv3.html and the file hv3see.c for details. So, it looks like we are now spoiled for choice of JS interpreter bindings in Tcl... :-) Cheers, -- Neil
|
Pages: 1 Prev: Tk focus model in 8.5 on Windows XP Next: Efficient 32-bit arithmetic |