Subj : Re: overriding JS_EnumerateStub To : Edward Chan From : Brendan Eich Date : Thu Aug 11 2005 12:05 am Edward Chan wrote: > I was wondering if someone can point me to some sample code, or explain to > me how to override the default JS_EnumerateStub. I basically want to add or > remove a property from an object's property spec at runtime. For example, > > I've defined my object and called JS_InitClass with some array of > JSPropertySpec's. But when someone does a for-in loop on the obj, I there > are some props I may not want to make enumerable based on the state of the > obj. Should I be doing this by overriding the JS_EnumerateStub? No, not if the only properties are those you predefine on the class prototype by passing non-null |ps| to JS_InitClass. Since you *do* predefine proto-properties, why not give them the right attributes up front? Or are you saying that JSPROP_ENUMERATE needs to be cleared and set at run-time depending on the object's state? If so, look into doing that on only those properties being mutated in so odd a fashion, via JS_GetPropertyAttributes and JS_SetPropertyAttributes. /be .