RE: [boost] Re: Trying to do something like boost::python for Net scapesSpiderMon key JavaScript engine

I also stumbled across CliPP a few days ago and have been examining it somewhat but unfortunately the interpreter is not yet completely finished but I'm certainly going to keep an eye on that one :) Thanks, Warrick. -----Original Message----- From: Fredrik Blomqvist [mailto:fredrik_blomqvist@home.se] Sent: 18 March 2004 23:33 To: boost@lists.boost.org Subject: [boost] Re: Trying to do something like boost::python for NetscapesSpiderMon key JavaScript engine Warrick Buchanan wrote:
Hi,
As the subject says I'm trying to a boost::python like equivalent for SpiderMonkey (Netscape's JavaScript engine) and I've been trying(!) to look at boost::python for inspiration. I've got to the stage where I can quite happily expose a class like so:
// D3D's Vector class just for example Declare<D3DXVECTOR>::Property<0>("x", &D3DXVECTOR3::x); // 0 is 'tinyid' Declare<D3DXVECTOR>::Property<1>("y", &D3DXVECTOR3::y); // 1 is 'tinyid' Declare<D3DXVECTOR>::Property<2>("z", &D3DXVECTOR3::z); // 2 is 'tinyid' Declare<D3DXVECTOR>::Definition("Vector3", jsContext, jsObject, jsPrototype);
Just from those four lines you can then use the C++ class in JavaScript without issue ie:
var v = new Vector3();
v.x = 4.0f; ...etc...
Now I want to expose methods and constructors. Originally I was planning to have a load of templates for each number of arguments a function could possibly take (which obviously isn't ideal), but looking at boost::python it seems it has a more elegant but currently illegible to me way of doing this? Has anyone got any pointers to how this works or comments that would help my understanding?
This isn't really my domain but I recently stumbled into a lib called CliPP http://clipp.sourceforge.net by Peder Holt. It claims to do Javascript-style C++ bindings. It seems quite "boostified" also, with connection to boost::spirit and, obviously boost::python. Might give you some ideas if nothing else. Regards // Fredrik Blomqvist _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (1)
-
Warrick Buchanan