Subj : Re: Iterate all functions in script To : netscape.public.mozilla.jseng From : Forest Carlisle Date : Thu May 06 2004 06:25 pm Thanks for the quick reply. This is what I came up with. JS_Enumerate always returns a 0 length array. JSIdArray* ida = JS_Enumerate(m_pContext, m_pGlobal); // tried both global and script object if (ida) { for (int i = 0, len = ida->length; i < len; i++) { jsid id = ida->vector[i]; // convert id to jsval and call JS_ValueToFunction then JS_GetFunctionId } } This code works to get a named function. void* mark = JS_ARENA_MARK(&m_pContext->tempPool); // get the Detect function jsval fval; if (JS_GetProperty(m_pContext, m_pGlobal, "Detection", &fval)) { if (JSVAL_IS_FUNCTION(m_pContext, fval)) { JSObject* pFunObj = JSVAL_TO_OBJECT(fval); ASSERT(pFunObj); JSFunction* pFun = (JSFunction*) JS_GetPrivate(m_pContext, pFunObj); ASSERT(pFun); } } Any ideas would be much appriciated. forest "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 .