Subj : Re: [spidermonkey] - determine JSVal is function To : =?ISO-8859-1?Q?Fr=E9d=E9ric_Lecointre?= From : Brendan Eich Date : Tue Mar 15 2005 03:17 pm Frédéric Lecointre wrote: > Hello all, > > i try to connect javascript with php and i want to know how i can determine > that a jsval passed to my GetPropertyStub is called as a function or as a > property. > > for example > > obj.func; as property return JSString > obj.func(); as function return JSFunction > > i try JSVAL_IS_FUNCTION(cx, id) without success both in GetProperty and > Resolve. The id is not the value, so why are you checking what kind of value id is? It's either a string or an int. The value is a function, but getting a function vs. getting it and then calling it does not clue the getter into the fact that the latter case involves a subsequent (possibly very delayed, due to actual argument expression evaluations) call operation. You need to return another object as the result value of the getter, an object that knows how to convert itself into a string or a function, depending on how it is used. See JSClass.convert. /be .