Subj : Re: question about javascript functions To : netscape.public.mozilla.jseng From : Ludovic Delabre Date : Tue Feb 08 2005 08:43 pm Béatrice Philippe wrote: > yes, your example is working ! > but i'm trying to do this in my C++ application, using jsapi. And here is > the problem... Yeah I understood you wanted to play with jsapi but I first needed to get your problem... :-p > > I'm interrested in modifying the body of an existing javascript function in > its global object. I just played a bit with jsapi using JS_CompileFunction() to dynamically changes a function at runtime and ... no problem !? BTW, it also works fine for me without calling deleteProperty()... > So for the moment, i'm currently trying to delete my old function 'fun1' > with 'js_deleteProperty()' in the global object, and then i create a new > function with 'js_compileFunction()' method with the same name 'fun1'. > If my application tries to call the new fun1 with 'js_callFunction..()', > it's working. But if the new fun1 function is called by others existing > functions, it crashes. > I think when i try to delete a function fun1 with 'js_deleteProperty()', all > functions that referenced this function fun1 are not notified about this > change. They don't know fun1 was deleted and replaced by a new fun1 > function. From what I know, there're no hidden reference lying around, everythin' is evaluated at runtime (but I might be mistaken?). > > My question is: > is there any way to change dynamically the body of an existing function in a > C++ application, using jsapi ? > or if no, is there any solution to create a new function that would replace > the old one ? > Thank you very much for your help. Well I don't know why it doesn't work for you when it works fine for me... What are you doing exactly ? See ya, Ludovic. .