зеркало из https://github.com/mozilla/gecko-dev.git
bug 129519, "JS_GetPropertyDesc gives up too easily", r=jband, sr=shaver, a=bren
dan Reflect new JSPD_* defines, make jsd_GetValueProperty degrade gracefully instead of fail outright when we run into a problem fetching the property value.
This commit is contained in:
Родитель
5ab837c899
Коммит
f7bdb90b75
|
@ -1151,7 +1151,11 @@ interface jsdIProperty : jsdIEphemeral
|
|||
const unsigned long FLAG_ARGUMENT = 0x10;
|
||||
/** local variable in function */
|
||||
const unsigned long FLAG_VARIABLE = 0x20;
|
||||
/** found via explicit lookup */
|
||||
/** exception occurred looking up property, value is exception */
|
||||
const unsigned long FLAG_EXCEPTION = 0x40;
|
||||
/** native getter returned JS_FALSE without throwing an exception */
|
||||
const unsigned long FLAG_ERROR = 0x80;
|
||||
/** found via explicit lookup (property defined elsewhere.) */
|
||||
const unsigned long FLAG_HINTED = 0x800;
|
||||
|
||||
/** FLAG_* values OR'd together, representing the flags for this property. */
|
||||
|
|
|
@ -462,21 +462,34 @@ jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* name)
|
|||
nameChars = JS_GetStringChars(name);
|
||||
nameLen = JS_GetStringLength(name);
|
||||
|
||||
/* It's OK if this fails - we just don't get attribs */
|
||||
JS_GetUCPropertyAttributes(cx, obj, nameChars, nameLen, &attrs, &found);
|
||||
if (!found)
|
||||
return NULL;
|
||||
|
||||
JS_ClearPendingException(cx);
|
||||
|
||||
if(!JS_GetUCProperty(cx, obj, nameChars, nameLen, &val))
|
||||
return NULL;
|
||||
|
||||
/* XXX screwy! no good way to detect that property does not exist at all */
|
||||
if(!found && JSVAL_IS_VOID(val))
|
||||
return NULL;
|
||||
{
|
||||
if (JS_IsExceptionPending(cx))
|
||||
{
|
||||
if (!JS_GetPendingException(cx, &pd.value))
|
||||
return NULL;
|
||||
pd.flags = JSPD_EXCEPTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
pd.flags = JSPD_ERROR;
|
||||
pd.value = JSVAL_VOID;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pd.value = val;
|
||||
}
|
||||
|
||||
pd.id = STRING_TO_JSVAL(name);
|
||||
pd.value = val;
|
||||
pd.alias = pd.slot = pd.spare = 0;
|
||||
pd.flags = 0
|
||||
| (attrs & JSPROP_ENUMERATE) ? JSPD_ENUMERATE : 0
|
||||
pd.flags |= (attrs & JSPROP_ENUMERATE) ? JSPD_ENUMERATE : 0
|
||||
| (attrs & JSPROP_READONLY) ? JSPD_READONLY : 0
|
||||
| (attrs & JSPROP_PERMANENT) ? JSPD_PERMANENT : 0;
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ extern "C"
|
|||
|
||||
JS_BEGIN_EXTERN_C
|
||||
#include "jsapi.h"
|
||||
#include "jsdbgapi.h"
|
||||
#ifdef LIVEWIRE
|
||||
#include "lwdbgapi.h"
|
||||
#endif
|
||||
|
@ -1293,14 +1294,18 @@ JSD_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval);
|
|||
*
|
||||
* XXX these must stay the same as the JSPD_ flags in jsdbgapi.h
|
||||
*/
|
||||
#define JSDPD_ENUMERATE 0x01 /* visible to for/in loop */
|
||||
#define JSDPD_READONLY 0x02 /* assignment is error */
|
||||
#define JSDPD_PERMANENT 0x04 /* property cannot be deleted */
|
||||
#define JSDPD_ALIAS 0x08 /* property has an alias id */
|
||||
#define JSDPD_ARGUMENT 0x10 /* argument to function */
|
||||
#define JSDPD_VARIABLE 0x20 /* local variable in function */
|
||||
#define JSDPD_ENUMERATE JSPD_ENUMERATE /* visible to for/in loop */
|
||||
#define JSDPD_READONLY JSPD_READONLY /* assignment is error */
|
||||
#define JSDPD_PERMANENT JSPD_PERMANENT /* property cannot be deleted */
|
||||
#define JSDPD_ALIAS JSPD_ALIAS /* property has an alias id */
|
||||
#define JSDPD_ARGUMENT JSPD_ARGUMENT /* argument to function */
|
||||
#define JSDPD_VARIABLE JSPD_VARIABLE /* local variable in function */
|
||||
#define JSDPD_EXCEPTION JSPD_EXCEPTION /* exception occurred looking up */
|
||||
/* proprety, value is exception */
|
||||
#define JSDPD_ERROR JSPD_ERROR /* native getter returned JS_FALSE */
|
||||
/* without throwing an exception */
|
||||
/* this is not one of the JSPD_ flags in jsdbgapi.h - careful not to overlap*/
|
||||
#define JSDPD_HINTED 0x800 /* found via explicit lookup */
|
||||
#define JSDPD_HINTED 0x800 /* found via explicit lookup */
|
||||
|
||||
/*
|
||||
* Release this JSDProperty
|
||||
|
|
Загрузка…
Ссылка в новой задаче