Subj : Re: Iterate all functions in script To : netscape.public.mozilla.jseng From : Forest Carlisle Date : Fri May 07 2004 11:56 am I get a vector with 15 itmes in it now, but not of the id's pass the JSVAL_IS_FUNCTION check. When I forgo this check I get errors that state "'string' is not a function" when I call JS_ValueToFunction. Any insights would be great. // code // evaluated the script with JS_ExecuteScript before this. JSIdArray* ida = JS_Enumerate(m_pContext, m_pGlobal); if (ida) { for (int i = 0, j = ida->length; i < j; i++) { jsid id = ida->vector[i]; if (!JSVAL_IS_INT(id)) { jsval val; if ( JS_IdToValue(m_pContext, id, &val) == JS_TRUE && JSVAL_IS_FUNCTION(m_pContext, val)) { JSFunction* pfun = JS_ValueToFunction(m_pContext, val); if (pfun) { JSString* pjssFunName = JS_GetFunctionId(pfun); if (pjssFunName) { CString strFunctionName(JS_GetStringBytes(pjssFunName)); int i = 0; } } } // got value } // is pointer } // for JS_DestroyIdArray(m_pContext, ida); } // if valid id array Ultimate goal is to build a list of all the function names defined in the script. forest "Issac Goldstand" wrote in message news:c7g6hh$mc31@ripley.netscape.com... > Just my $0.02: I just looked that up myself and it took a good few hours of > diving in the code and guessing which functions would work with it, what > exactly it did, etc... The APIDOCs on that specific function happen to be > rather unhelpful, IMHO. I'd be happy to submit a documentation patch as > soon as I get a chance to try to work with a bit and have some idea of what > I'm talking about . > > Issac > > "Sterling Bates" wrote in message > news:c7e5kr$kqr1@ripley.netscape.com... > > Forest Carlisle wrote: > > > I would like to build a list of all the functions declared a script. I > > > know I can get a function by name with JS_GetProperty for a given object > > > and then call JS_GetPrivate to get the JSFunction*, and finally call > > > JS_GetFunctionId to get the function name. > > > > > > Is there a way to get all the properties of a given object? > > > > Look up the JS_Enumerate API. > > > > http://www.mozilla.org/js/spidermonkey/apidoc/sparse-frameset.html > > > > Sterling > > .