Subj : Re: Exporting Object Constructor To : netscape.public.mozilla.jseng From : Brian Genisio Date : Thu Feb 12 2004 11:12 am Brian Genisio wrote: > Hi all, > > I am creating a whole bunch of objects that have interfaces in my > spidermonkey code. I use JS_InitClass to do this. Everything is > accessable through my global object, and all of my objects are working > well. > > Now, I have a class named MyClass, which I want the user to be able to > create a new class: > > var my_new_class = new MyClass(arg1, arg2); > > In my JS_InitClass, I have defined a constructor, but it never gets > called. In fact, the JS_ExecuteScript quietly exits when I do this. > > Any Ideas to what I am missing? Do I need to create a MyClass method in > my global class, in order to construct the object? That shouldnt be > that hard, but I guess I assumed that the MyClass constructor would be > called automatically, using new. > > Thanks, > Brian > *doat* I found my problem. Obviously nothing wrong with the API... and I understood the API correctly. I have a class template in place for my objects. I had a screwy problem where the wrong function was being called for the constructor. Then, in that constructor, it had a check, that returned with JS_FALSE, but no JS_ReportError, which caused the silent failure. I was not able to find the problem right away, because I was breaking in the wrong places... :) All fixed. Brian .