Subj : Re: Iterate all functions in script To : netscape.public.mozilla.jseng From : Forest Carlisle Date : Fri May 07 2004 10:50 am Sorry, my bad. I forgot to evaluate/execute the script. I am doing this in the second case I state below. And, about using the private API.... is there any "public" way to walk the token stream and get information on all the atoms? forest "Brendan Eich" wrote in message news:409B013A.2060603@meer.net... > Forest Carlisle wrote: > > 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 > > } > > } > > Have you evaluated the script containing the functions? > > > > > This code works to get a named function. > > > > void* mark = JS_ARENA_MARK(&m_pContext->tempPool); > > Please, no. Don't include private header files (jscntxt.h, jsarena.h), > don't use private APIs. > > > > > // 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. > > Is this before or after you've evaluated or compiled *and* executed the > script containing the functions? > > /be .