Boost logo

Boost :

From: Fredrik Blomqvist (fredrik_blomqvist_at_[hidden])
Date: 2004-03-18 18:32:48


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk