Subj : Re: String property & DOM synchro To : netscape.public.mozilla.jseng From : Lorenzo Pastrana Date : Mon Jun 28 2004 03:11 pm Hi, thanks for the reply :) > > What do you mean by 'flying' object? Well, actually the problem takes place in my 'native data to jsval conversion routine' The conversion is used in a dom where only methods and handlers can be implemented in js, the rest of the structure is native C++ and no js code can be fired outside a method or handler. It does the following : when SpiderMonkey asks for a property value in the getter of an object, it returns a proprely initialized jsval according to the following rule : if the data asked for is a 'scalar' (integer, real, boolean, etc.) get the value from the object and use appropriate conversion ok... if the data asked for is an object, build the corresponding object if not done yet (using JS_DefineObject or JS_NewObject depending on situations) and return with OBJECT_TO_JSVAL ok, my objects behaves nice.. then if SM is waiting for a string, I do the folowing for now : return STRING_TO_JSVAL(JS_NewString(jscontext, str_data, str_length)); String that gets GC'ed later : a flying object _as done for doubles_ This might not be the correct thing to do (you just tell me), but worked well for simple get/set operations until now : The particularity of this arises when in js code one comes to do something like : this.some_string_prop.concat(some_other_string); witch fails to update the right data (the dom's one) since it operates on the 'flying' object, now I'd like to get to a solution where the above js code works ok with methods on strings as it works with any method of my other objects... But the fact is that I can't reasonably tell (even if I actually kept a track of the instanciated string) 'when' the data was changed by a method, without doing ugly polling or whatever... The thing is : would there be an interception / notification mechanism you would think of in order to get my dom in sync with the strings data? I've been thru the apidoc and found nothing related, thru jsstr.c nothing that helps.. I thought of inserting a notification mechanism in jsstr.c but before I branch :( I call for help :) Thanks. > You really have to show your code for me to help effectively. > > /be > > >I've been looking the API doc but there's nothing like a > >'JS_NativeCallStub', > >I'd be glad if someone hinted me about some way to intercept changes in the > >string or some way to 'overload' the String type in order to keep my DOM in > >sYnc .. > > > >Thanks. > > > >Lorenzo. .