var g_number = 2;
var str = "test";
I would like to be able to enumerate all the properties (e.g.
'g_number' and 'str') and get their names and values. I've tried
several different methods for doing so. So far, I've had the most
success using JS_GetPropertyDescArray. However, I haven't been able to
get the property values or any information about global properties.
Here's some simple test code:
JS_GetPropertyDescArray(pContext, pObject, &pda);
for(int j = 0; j < pda.length; j++)
JSPropertyDesc desc = pda.array[j];
std::string strPropertyName =
JSString* pString = JS_ValueToString(pContext, desc.value);
std::string strValue = "";
strValue = JS_GetStringBytes( pString );
'strValue' comes back as 'undefined'. I've also tried calling
JS_GetProperty after retrieving the name, but without success.
Any ideas? One piece of information which might be useful: I'm using
JS_CompileScript to generate a JSScript object and then I'm iterating
through the atomMap in the script object.