Subj : Re: Calling non-existent object function crashes engine To : sydlogan From : Syd Logan Date : Mon Sep 05 2005 06:11 pm GetComponent: found a component object! 94981D9E-FC99-11D9-8BDE-F66BAD1E3F3AButton1Click got the component Able to create a JS function for Hello!!! *****Created the JS object for GUUID 2ABDF00B-025E-11DA-BFFE-000A27942344 2ABDF00B-025E-11DA-BFFE-000A27942344Button1Click got the object ******Hello from HelloClass C++ TypeError: anobject.Foobar is not a function Oh joy, thanks for the tips. No more crashing, and a very sane error message. On to the next challenge: ensuring that the JS object is destroyed after it is used (meaning what references it goes out of scope), and how to hook into its destruction so that I can call into the component to release the C++ object it wraps. Fun stuff. syd Syd Logan wrote: > > > John Bandhauer wrote: > >> Syd Logan wrote: >> >>> JSClass objectClass = { >>> name.c_str(), JSCLASS_NEW_RESOLVE, >>> JS_PropertyStub, JS_PropertyStub, >>> JS_PropertyStub, JS_PropertyStub, >>> JS_EnumerateStub, JS_ResolveStub, >>> JS_ConvertStub, JS_FinalizeStub >>> }; >> >> >> >> >> I'd say one mistake is in using JSCLASS_NEW_RESOLVE and passing >> JS_ResolveStub. I believe that JSCLASS_NEW_RESOLVE tells the engine >> that the resolve callback is of type JSNewResolveOp, but you are >> passing in a callback of type JSResolveOp. That would be bad. > > > Does sound bad, I'll give that a try. > >> >> I'd also have to wonder if the name string you are passing is static >> (name.c_str()) - the engine doesn't make a copy of it. As Brendan >> pointed out, same story for the entire JSClass structure. > > > Right. It's not static, it lives on the stack. But I have a place for > both of these, thanks for pointing out the problem. > >> >> You are either calling the wrong address if the JSClass* is not >> pointing to data that doesn't change, or you are screwing up the stack >> on return from JS_ResolveStub. >> > >> >> John. > > .