Subj : Re: distinguishing between constructor/function call To : netscape.public.mozilla.jseng From : Ludovic Delabre Date : Wed Feb 09 2005 06:02 pm Hi! For distinguish between construction and function call use JS_IsConstructing(cx)... But I don't know exactly what (I'm supposed) to do in case of function call... Ludovic. Lot's of info there Jason wrote: > If I create a new object class Thingamajig using JS_InitClass, > how can I distinguish between these syntaxes: > (1) a = new Thingamajig() > (2) b = Thingamajig() > and what's the recommended action in general for (2)? My thought is to > return null (safe) or make (2) behave like (1) by calling > JS_NewObject(). Right now my object's constructor causes a crash in > syntax (2) when it tries to call JS_SetPrivate(). > > I looked at jsdate.c which does this in the Date constructor: > /* Date called as function */ > if (!(cx->fp->flags & JSFRAME_CONSTRUCTING)) { > > but that's not a JSAPI call... > .