Subj : Re: how to overload setter function, but keeping standard behavior in addition to specific one To : netscape.public.mozilla.jseng From : smaraux Date : Thu Mar 03 2005 04:53 am Brendan Eich wrote in message news:<42266733.9000401@meer.net>... > sebastien maraux wrote: > > Hello, > > > > I am using an array of js vals attached to a js object via > > JS_DefineElement function. When these js data are set, I need to apply > > a specific behavior in addition to the standard one. > > > > to summarize : > > > > I would like to use a class with this setter : > > > > setArrayElement(JSContext *pJSContext, JSObject *pJSObject, jsval id, > > jsval *pJSSetVal) > > { > > //... manipulating private data according to set value ... > > JS_SetElement(pJSContext, pJSObject, ind, pJSSetVal); > > } > > > > > Your setter is being called from generic "set property" code called from > the JS_SetElement API, so you don't want to call that code again > (recursively, divergently). You should just update *pJSSetVal (argh, > pseudo-Hungarian! ;-) and return true. > > /be Thanks for your answer, I am finally done with what I wanted to do, with clean memory management ;) It's always better to use js objects and values when it is possible, this simplifies GC management a lot. .