Hey everyone,

I'm currently implementing a v8 with gl bindings and much other stuff, but 
I'm stuck whilst trying to implement a namespaced class.

I have a namespaced class, it is available in c++ via lychee::Preloader and 
has (for testing purposes) only one public, static method load().
This class is available in my main() method where the namespaces are 
constructed and passed to the javascript context.

What I originally want to achieve for the JavaScript context is something 
like this:

global.lychee.Preloader = function() {};
lychee.Preloader.prototype = { load: function(foo) {} };

var myPreloader = new lychee.Preloader();
myPreloader.load(); // do some stuff



What I'm doing in the embed v8 c++ code is inside lychee::createLychee():

    Handle<ObjectTemplate> preloader = ObjectTemplate::New();
    preloader->Set(String::NewSymbol("load"), 
FunctionTemplate::New(Preloader::load));


    Handle<ObjectTemplate> ly = ObjectTemplate::New();
    ly->Set(String::NewSymbol("Preloader"), preloader);


So the result should now be something like this for the JavaScript context 
(which isn't wanted, but anyways):

global.lychee = { Preloader: { load: function(foo){} } };



But it strangely doesn't work and gives me a linking error:

/tmp/ccTJun8w.o: In function `lychee::createLychee()':
lychee.cpp:(.text+0x65): undefined reference to 
`lychee::Preloader::load(v8::Arguments const&)'
collect2: ld returned 1 exit status


Dunno what to do now, the solutions on the web are something like putting 
the linked library after the module being compiled, but it's main()?

The lychee::Preloader::load method can be called inside the createLychee 
method, because it's in the same namespace.
I currently don't know if I'm just too stupid to debug or if I'm missing 
something.

Is there an example or tutorial available for "best practices" on how to 
implement custom classes like that?


Greets and Thanks for helping,
Christoph

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

Reply via email to