|
Boost : |
From: Warrick Buchanan (Warrick_at_[hidden])
Date: 2004-03-18 12:16:29
Aaah and I've just noticed that boost::python uses the boost preprocessor
stuff that I think does effectively through macros generate a load of
templates for up to a constant N number of templated function arguments -
and am I right in that this mad preprocessor stuff it recursively includes
itself?
eeek(!)
-----Original Message-----
From: Warrick Buchanan [mailto:Warrick_at_[hidden]]
Sent: 18 March 2004 10:44
To: 'boost_at_[hidden]'
Subject: [boost] Trying to do something like boost::python for Netscapes
SpiderMon key JavaScript engine
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?
Thanks,
Warrick
_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk