Hey,
I'm working on several programs that use v8 as front-end and I'm
trying to present my bindings as natural as possible to the users. I
must say I've been successful so far but this one has me stomped.
I'm going to use a metaphor to describe it: let's say I have birds and
cages. I can create a bunch of cages, and for each cage I can create a
bunch of birds. In JS it will look something like this:

cage1 = new Cage(...)
cage2 = new Cage(...)
bird1 = new cage1.Bird(...)
bird2 = new cage1.Bird(...)
bird3 = new cage2.Bird(...)

For each cage there will be a constructor that will only create birds
that are in that cage. To make it more concrete: the bird will have
access to some variables of its cage. The reason why I like to do it
like this is because it will ensure that for each bird there will be
at least and no more that one cage; a paradigm I feel is natural to
the back-end I'm writing.

In JS I would write something like this:
CageBird = function(cage, x){ this.cage = cage; this.x = x }
CageBird.prototype. (...)

Cage = function(x) {
    this.x = x; var cage = this;
    this.Bird = function(x){ CageBird.call(this, cage, x) }
}
Cage.prototype. (...)

Now how do I do this with the C++ API?
I can figure out I'll need to make two object templates, but I'm not
sure how to do the closure part as in the JS version I wrote above.
Your help is much appreciated!

- Ferry

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to