Encapsulated bindings.
Make all bindings available w/ some naming convention for the namespaces.
Have a constructor function per type
* Have Animal.prototype be the members of Animal::
* Have Dog.prototype be the members of Dog::
Attach the static functions to constructor functions
Add sugar if you need a destructor / be sure to call the parent function
constructor inside of subclasses:
function Dog() {
Animal.call(this);
return this;
}
Checking for instance type:
// since people should be using our constructor that maps to an instance
via ObjectWrap....
if (spot instanceof Dog) { ... }
When using virtual static functions [ :-( ] you can add them to the
constructor (this pattern is highly discouraged generally):
function Dog() { ... }
var DogStatics = Object.create(AnimalStatics)
...
Object.keys(DogStatics).forEach(function (key) {
Dog[key] = DogStatics[key]
});
In general however, directly mapping C++ onto JS will meet with some
confusion as the mentalities of the languages are vast, so be sure that
this is what you want to do.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en