Subj : Re: how to overload setter function, but keeping standard behavior To : sebastien maraux From : Brendan Eich Date : Wed Mar 02 2005 05:24 pm 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 .