зеркало из https://github.com/mozilla/pjs.git
[JAEGER] Merge from fatval branch.
This commit is contained in:
Коммит
63c36bb9b8
|
@ -51,7 +51,7 @@ interface nsIScriptSecurityManager : nsIXPCSecurityManager
|
|||
[noscript] void checkPropertyAccess(in JSContextPtr aJSContext,
|
||||
in JSObjectPtr aJSObject,
|
||||
in string aClassName,
|
||||
in jsval aProperty,
|
||||
in jsid aProperty,
|
||||
in PRUint32 aAction);
|
||||
|
||||
/**
|
||||
|
|
|
@ -429,7 +429,7 @@ private:
|
|||
|
||||
static JSBool
|
||||
CheckObjectAccess(JSContext *cx, JSObject *obj,
|
||||
jsval id, JSAccessMode mode,
|
||||
jsid id, JSAccessMode mode,
|
||||
jsval *vp);
|
||||
|
||||
// Decides, based on CSP, whether or not eval() and stuff can be executed.
|
||||
|
@ -456,7 +456,7 @@ private:
|
|||
JSContext* cx, JSObject* aJSObject,
|
||||
nsISupports* aObj, nsIURI* aTargetURI,
|
||||
nsIClassInfo* aClassInfo,
|
||||
const char* aClassName, jsval aProperty,
|
||||
const char* aClassName, jsid aProperty,
|
||||
void** aCachedClassPolicy);
|
||||
|
||||
nsresult
|
||||
|
@ -466,7 +466,7 @@ private:
|
|||
|
||||
nsresult
|
||||
LookupPolicy(nsIPrincipal* principal,
|
||||
ClassInfoData& aClassData, jsval aProperty,
|
||||
ClassInfoData& aClassData, jsid aProperty,
|
||||
PRUint32 aAction,
|
||||
ClassPolicy** aCachedClassPolicy,
|
||||
SecurityLevel* result);
|
||||
|
@ -616,7 +616,7 @@ private:
|
|||
};
|
||||
|
||||
// JS strings we need to clean up on shutdown
|
||||
static jsval sEnabledID;
|
||||
static jsid sEnabledID;
|
||||
|
||||
inline void
|
||||
ScriptSecurityPrefChanged();
|
||||
|
|
|
@ -116,9 +116,15 @@ static JSEqualityOp sXPCWrappedNativeEqualityOps;
|
|||
///////////////////////////
|
||||
// Result of this function should not be freed.
|
||||
static inline const PRUnichar *
|
||||
JSValIDToString(JSContext *cx, const jsval idval)
|
||||
IDToString(JSContext *cx, jsid id)
|
||||
{
|
||||
if (JSID_IS_STRING(id))
|
||||
return reinterpret_cast<PRUnichar*>(JS_GetStringChars(JSID_TO_STRING(id)));
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
jsval idval;
|
||||
if (!JS_IdToValue(cx, id, &idval))
|
||||
return nsnull;
|
||||
JSString *str = JS_ValueToString(cx, idval);
|
||||
if(!str)
|
||||
return nsnull;
|
||||
|
@ -566,7 +572,7 @@ nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(JSContext *cx)
|
|||
|
||||
JSBool
|
||||
nsScriptSecurityManager::CheckObjectAccess(JSContext *cx, JSObject *obj,
|
||||
jsval id, JSAccessMode mode,
|
||||
jsid id, JSAccessMode mode,
|
||||
jsval *vp)
|
||||
{
|
||||
// Get the security manager
|
||||
|
@ -605,7 +611,7 @@ NS_IMETHODIMP
|
|||
nsScriptSecurityManager::CheckPropertyAccess(JSContext* cx,
|
||||
JSObject* aJSObject,
|
||||
const char* aClassName,
|
||||
jsval aProperty,
|
||||
jsid aProperty,
|
||||
PRUint32 aAction)
|
||||
{
|
||||
return CheckPropertyAccessImpl(aAction, nsnull, cx, aJSObject,
|
||||
|
@ -685,7 +691,7 @@ nsScriptSecurityManager::CheckPropertyAccessImpl(PRUint32 aAction,
|
|||
JSContext* cx, JSObject* aJSObject,
|
||||
nsISupports* aObj, nsIURI* aTargetURI,
|
||||
nsIClassInfo* aClassInfo,
|
||||
const char* aClassName, jsval aProperty,
|
||||
const char* aClassName, jsid aProperty,
|
||||
void** aCachedClassPolicy)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -704,7 +710,7 @@ nsScriptSecurityManager::CheckPropertyAccessImpl(PRUint32 aAction,
|
|||
ClassInfoData classInfoData(aClassInfo, aClassName);
|
||||
#ifdef DEBUG_CAPS_CheckPropertyAccessImpl
|
||||
nsCAutoString propertyName;
|
||||
propertyName.AssignWithConversion((PRUnichar*)JSValIDToString(cx, aProperty));
|
||||
propertyName.AssignWithConversion((PRUnichar*)IDToString(cx, aProperty));
|
||||
printf("### CanAccess(%s.%s, %i) ", classInfoData.GetName(),
|
||||
propertyName.get(), aAction);
|
||||
#endif
|
||||
|
@ -826,17 +832,17 @@ nsScriptSecurityManager::CheckPropertyAccessImpl(PRUint32 aAction,
|
|||
{
|
||||
case nsIXPCSecurityManager::ACCESS_GET_PROPERTY:
|
||||
checkedComponent->CanGetProperty(objIID,
|
||||
JSValIDToString(cx, aProperty),
|
||||
IDToString(cx, aProperty),
|
||||
getter_Copies(objectSecurityLevel));
|
||||
break;
|
||||
case nsIXPCSecurityManager::ACCESS_SET_PROPERTY:
|
||||
checkedComponent->CanSetProperty(objIID,
|
||||
JSValIDToString(cx, aProperty),
|
||||
IDToString(cx, aProperty),
|
||||
getter_Copies(objectSecurityLevel));
|
||||
break;
|
||||
case nsIXPCSecurityManager::ACCESS_CALL_METHOD:
|
||||
checkedComponent->CanCallMethod(objIID,
|
||||
JSValIDToString(cx, aProperty),
|
||||
IDToString(cx, aProperty),
|
||||
getter_Copies(objectSecurityLevel));
|
||||
}
|
||||
}
|
||||
|
@ -907,7 +913,7 @@ nsScriptSecurityManager::CheckPropertyAccessImpl(PRUint32 aAction,
|
|||
{
|
||||
subjectOriginUnicode.get(),
|
||||
className.get(),
|
||||
JSValIDToString(cx, aProperty),
|
||||
IDToString(cx, aProperty),
|
||||
objectOriginUnicode.get(),
|
||||
subjectDomainUnicode.get(),
|
||||
objectDomainUnicode.get()
|
||||
|
@ -1076,7 +1082,7 @@ nsScriptSecurityManager::CheckSameOriginDOMProp(nsIPrincipal* aSubject,
|
|||
nsresult
|
||||
nsScriptSecurityManager::LookupPolicy(nsIPrincipal* aPrincipal,
|
||||
ClassInfoData& aClassData,
|
||||
jsval aProperty,
|
||||
jsid aProperty,
|
||||
PRUint32 aAction,
|
||||
ClassPolicy** aCachedClassPolicy,
|
||||
SecurityLevel* result)
|
||||
|
@ -1187,14 +1193,14 @@ nsScriptSecurityManager::LookupPolicy(nsIPrincipal* aPrincipal,
|
|||
*aCachedClassPolicy = cpolicy;
|
||||
}
|
||||
|
||||
NS_ASSERTION(JSVAL_IS_INT(aProperty) || JSVAL_IS_OBJECT(aProperty) ||
|
||||
JSVAL_IS_STRING(aProperty), "Property must be a valid id");
|
||||
NS_ASSERTION(JSID_IS_INT(aProperty) || JSID_IS_OBJECT(aProperty) ||
|
||||
JSID_IS_STRING(aProperty), "Property must be a valid id");
|
||||
|
||||
// Only atomized strings are stored in the policies' hash tables.
|
||||
if (!JSVAL_IS_STRING(aProperty))
|
||||
if (!JSID_IS_STRING(aProperty))
|
||||
return NS_OK;
|
||||
|
||||
JSString *propertyKey = JSVAL_TO_STRING(aProperty);
|
||||
JSString *propertyKey = JSID_TO_STRING(aProperty);
|
||||
|
||||
// We look for a PropertyPolicy in the following places:
|
||||
// 1) The ClassPolicy for our class we got from our DomainPolicy
|
||||
|
@ -3071,11 +3077,11 @@ nsScriptSecurityManager::CheckComponentPermissions(JSContext *cx,
|
|||
// Look up the policy for this class.
|
||||
// while this isn't a property we'll treat it as such, using ACCESS_CALL_METHOD
|
||||
JSAutoRequest ar(cx);
|
||||
jsval cidVal = STRING_TO_JSVAL(::JS_InternString(cx, cid.get()));
|
||||
jsid cidId = INTERNED_STRING_TO_JSID(::JS_InternString(cx, cid.get()));
|
||||
|
||||
ClassInfoData nameData(nsnull, "ClassID");
|
||||
SecurityLevel securityLevel;
|
||||
rv = LookupPolicy(subjectPrincipal, nameData, cidVal,
|
||||
rv = LookupPolicy(subjectPrincipal, nameData, cidId,
|
||||
nsIXPCSecurityManager::ACCESS_CALL_METHOD,
|
||||
nsnull, &securityLevel);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -3178,7 +3184,7 @@ nsScriptSecurityManager::CanAccess(PRUint32 aAction,
|
|||
JSObject* aJSObject,
|
||||
nsISupports* aObj,
|
||||
nsIClassInfo* aClassInfo,
|
||||
jsval aPropertyName,
|
||||
jsid aPropertyName,
|
||||
void** aPolicy)
|
||||
{
|
||||
return CheckPropertyAccessImpl(aAction, aCallContext, cx,
|
||||
|
@ -3388,8 +3394,8 @@ nsresult nsScriptSecurityManager::Init()
|
|||
if (!cx) return NS_ERROR_FAILURE; // this can happen of xpt loading fails
|
||||
|
||||
::JS_BeginRequest(cx);
|
||||
if (sEnabledID == JSVAL_VOID)
|
||||
sEnabledID = STRING_TO_JSVAL(::JS_InternString(cx, "enabled"));
|
||||
if (sEnabledID == JSID_VOID)
|
||||
sEnabledID = INTERNED_STRING_TO_JSID(::JS_InternString(cx, "enabled"));
|
||||
::JS_EndRequest(cx);
|
||||
|
||||
InitPrefs();
|
||||
|
@ -3442,7 +3448,7 @@ nsresult nsScriptSecurityManager::Init()
|
|||
|
||||
static nsScriptSecurityManager *gScriptSecMan = nsnull;
|
||||
|
||||
jsval nsScriptSecurityManager::sEnabledID = JSVAL_VOID;
|
||||
jsid nsScriptSecurityManager::sEnabledID = JSID_VOID;
|
||||
|
||||
nsScriptSecurityManager::~nsScriptSecurityManager(void)
|
||||
{
|
||||
|
@ -3461,7 +3467,7 @@ nsScriptSecurityManager::Shutdown()
|
|||
JS_SetRuntimeSecurityCallbacks(sRuntime, NULL);
|
||||
sRuntime = nsnull;
|
||||
}
|
||||
sEnabledID = JSVAL_VOID;
|
||||
sEnabledID = JSID_VOID;
|
||||
|
||||
NS_IF_RELEASE(sIOService);
|
||||
NS_IF_RELEASE(sXPConnect);
|
||||
|
|
|
@ -44,7 +44,7 @@ typedef nsresult (NS_STDCALL nsIDOMCanvasRenderingContext2D::*CanvasStyleSetterT
|
|||
typedef nsresult (NS_STDCALL nsIDOMCanvasRenderingContext2D::*CanvasStyleGetterType)(nsAString &, nsISupports **, PRInt32 *);
|
||||
|
||||
static JSBool
|
||||
Canvas2D_SetStyleHelper(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
||||
Canvas2D_SetStyleHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
CanvasStyleSetterType setfunc)
|
||||
{
|
||||
XPC_QS_ASSERT_CONTEXT_OK(cx);
|
||||
|
@ -86,7 +86,7 @@ Canvas2D_SetStyleHelper(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
Canvas2D_GetStyleHelper(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
||||
Canvas2D_GetStyleHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
CanvasStyleGetterType getfunc)
|
||||
{
|
||||
XPC_QS_ASSERT_CONTEXT_OK(cx);
|
||||
|
@ -122,25 +122,25 @@ Canvas2D_GetStyleHelper(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_SetStrokeStyle(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
nsIDOMCanvasRenderingContext2D_SetStrokeStyle(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return Canvas2D_SetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::SetStrokeStyle_multi);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_GetStrokeStyle(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
nsIDOMCanvasRenderingContext2D_GetStrokeStyle(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return Canvas2D_GetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::GetStrokeStyle_multi);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_SetFillStyle(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
nsIDOMCanvasRenderingContext2D_SetFillStyle(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return Canvas2D_SetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::SetFillStyle_multi);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_GetFillStyle(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
nsIDOMCanvasRenderingContext2D_GetFillStyle(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return Canvas2D_GetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::GetFillStyle_multi);
|
||||
}
|
||||
|
|
|
@ -768,3 +768,327 @@ nsICanvasRenderingContextWebGL_VertexAttrib4fv(JSContext *cx, uintN argc, jsval
|
|||
{
|
||||
return helper_nsICanvasRenderingContextWebGL_VertexAttrib_x_fv(cx, argc, vp, 4);
|
||||
}
|
||||
|
||||
#ifdef JS_TRACER
|
||||
|
||||
static inline void FASTCALL
|
||||
helper_nsICanvasRenderingContextWebGL_Uniform_x_iv_tn(JSContext *cx, JSObject *obj, JSObject *locationobj,
|
||||
JSObject *arg, int nElements)
|
||||
{
|
||||
XPC_QS_ASSERT_CONTEXT_OK(cx);
|
||||
|
||||
nsICanvasRenderingContextWebGL *self;
|
||||
xpc_qsSelfRef selfref;
|
||||
xpc_qsArgValArray<3> vp(cx);
|
||||
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, &vp.array[0], nsnull)) {
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
js::AutoValueRooter obj_tvr(cx);
|
||||
|
||||
nsIWebGLUniformLocation *location;
|
||||
xpc_qsSelfRef location_selfref;
|
||||
nsresult rv_convert_arg0
|
||||
= xpc_qsUnwrapThis(cx, locationobj, nsnull, &location, &location_selfref.ptr, &vp.array[1], nsnull);
|
||||
if (NS_FAILED(rv_convert_arg0)) {
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
js::TypedArray *wa = 0;
|
||||
|
||||
if (helper_isInt32Array(arg)) {
|
||||
wa = js::TypedArray::fromJSObject(arg);
|
||||
} else if (JS_IsArrayObject(cx, arg)) {
|
||||
JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_INT32, arg);
|
||||
if (!nobj) {
|
||||
// XXX this will likely return a strange error message if it goes wrong
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
*obj_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj);
|
||||
wa = js::TypedArray::fromJSObject(nobj);
|
||||
} else {
|
||||
xpc_qsThrowMethodFailedWithDetails(cx, NS_ERROR_FAILURE, "nsICanvasRenderingContextWebGL", "uniformNiv");
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (nElements == 1) {
|
||||
rv = self->Uniform1iv_array(location, wa);
|
||||
} else if (nElements == 2) {
|
||||
rv = self->Uniform2iv_array(location, wa);
|
||||
} else if (nElements == 3) {
|
||||
rv = self->Uniform3iv_array(location, wa);
|
||||
} else if (nElements == 4) {
|
||||
rv = self->Uniform4iv_array(location, wa);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
xpc_qsThrowMethodFailedWithDetails(cx, rv, "nsICanvasRenderingContextWebGL", "uniformNiv");
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void FASTCALL
|
||||
helper_nsICanvasRenderingContextWebGL_Uniform_x_fv_tn(JSContext *cx, JSObject *obj, JSObject *locationobj,
|
||||
JSObject *arg, int nElements)
|
||||
{
|
||||
XPC_QS_ASSERT_CONTEXT_OK(cx);
|
||||
|
||||
nsICanvasRenderingContextWebGL *self;
|
||||
xpc_qsSelfRef selfref;
|
||||
xpc_qsArgValArray<3> vp(cx);
|
||||
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, &vp.array[0], nsnull)) {
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
js::AutoValueRooter obj_tvr(cx);
|
||||
|
||||
nsIWebGLUniformLocation *location;
|
||||
xpc_qsSelfRef location_selfref;
|
||||
nsresult rv_convert_arg0
|
||||
= xpc_qsUnwrapThis(cx, locationobj, nsnull, &location, &location_selfref.ptr, &vp.array[1], nsnull);
|
||||
if (NS_FAILED(rv_convert_arg0)) {
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
js::TypedArray *wa = 0;
|
||||
|
||||
if (helper_isFloat32Array(arg)) {
|
||||
wa = js::TypedArray::fromJSObject(arg);
|
||||
} else if (JS_IsArrayObject(cx, arg)) {
|
||||
JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg);
|
||||
if (!nobj) {
|
||||
// XXX this will likely return a strange error message if it goes wrong
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
*obj_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj);
|
||||
wa = js::TypedArray::fromJSObject(nobj);
|
||||
} else {
|
||||
xpc_qsThrowMethodFailedWithDetails(cx, NS_ERROR_FAILURE, "nsICanvasRenderingContextWebGL", "uniformNfv");
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (nElements == 1) {
|
||||
rv = self->Uniform1fv_array(location, wa);
|
||||
} else if (nElements == 2) {
|
||||
rv = self->Uniform2fv_array(location, wa);
|
||||
} else if (nElements == 3) {
|
||||
rv = self->Uniform3fv_array(location, wa);
|
||||
} else if (nElements == 4) {
|
||||
rv = self->Uniform4fv_array(location, wa);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
xpc_qsThrowMethodFailedWithDetails(cx, rv, "nsICanvasRenderingContextWebGL", "uniformNfv");
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void FASTCALL
|
||||
helper_nsICanvasRenderingContextWebGL_UniformMatrix_x_fv_tn(JSContext *cx, JSObject *obj, JSObject *locationobj,
|
||||
JSBool transpose, JSObject *arg, int nElements)
|
||||
{
|
||||
XPC_QS_ASSERT_CONTEXT_OK(cx);
|
||||
|
||||
nsICanvasRenderingContextWebGL *self;
|
||||
xpc_qsSelfRef selfref;
|
||||
xpc_qsArgValArray<4> vp(cx);
|
||||
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, &vp.array[0], nsnull)) {
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
js::AutoValueRooter obj_tvr(cx);
|
||||
|
||||
nsIWebGLUniformLocation *location;
|
||||
xpc_qsSelfRef location_selfref;
|
||||
nsresult rv_convert_arg0
|
||||
= xpc_qsUnwrapThis(cx, locationobj, nsnull, &location, &location_selfref.ptr, &vp.array[1], nsnull);
|
||||
if (NS_FAILED(rv_convert_arg0)) {
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
js::TypedArray *wa = 0;
|
||||
|
||||
if (helper_isFloat32Array(arg)) {
|
||||
wa = js::TypedArray::fromJSObject(arg);
|
||||
} else if (JS_IsArrayObject(cx, arg)) {
|
||||
JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg);
|
||||
if (!nobj) {
|
||||
// XXX this will likely return a strange error message if it goes wrong
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
*obj_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj);
|
||||
wa = js::TypedArray::fromJSObject(nobj);
|
||||
} else {
|
||||
xpc_qsThrowMethodFailedWithDetails(cx, NS_ERROR_FAILURE, "nsICanvasRenderingContextWebGL", "uniformMatrixNfv");
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
if (nElements == 2) {
|
||||
rv = self->UniformMatrix2fv_array(location, transpose, wa);
|
||||
} else if (nElements == 3) {
|
||||
rv = self->UniformMatrix3fv_array(location, transpose, wa);
|
||||
} else if (nElements == 4) {
|
||||
rv = self->UniformMatrix4fv_array(location, transpose, wa);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
xpc_qsThrowMethodFailedWithDetails(cx, rv, "nsICanvasRenderingContextWebGL", "uniformMatrixNfv");
|
||||
js_SetTraceableNativeFailed(cx);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME This should return void, not uint32
|
||||
// (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
static uint32 FASTCALL
|
||||
nsICanvasRenderingContextWebGL_Uniform1iv_tn(JSContext *cx, JSObject *obj, JSObject *location, JSObject *arg)
|
||||
{
|
||||
helper_nsICanvasRenderingContextWebGL_Uniform_x_iv_tn(cx, obj, location, arg, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_DEFINE_TRCINFO_1(nsICanvasRenderingContextWebGL_Uniform1iv,
|
||||
(4, (static, UINT32_FAIL, nsICanvasRenderingContextWebGL_Uniform1iv_tn, CONTEXT, THIS, OBJECT, OBJECT, 0, nanojit::ACC_STORE_ANY)))
|
||||
|
||||
// FIXME This should return void, not uint32
|
||||
// (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
static uint32 FASTCALL
|
||||
nsICanvasRenderingContextWebGL_Uniform2iv_tn(JSContext *cx, JSObject *obj, JSObject *location, JSObject *arg)
|
||||
{
|
||||
helper_nsICanvasRenderingContextWebGL_Uniform_x_iv_tn(cx, obj, location, arg, 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_DEFINE_TRCINFO_1(nsICanvasRenderingContextWebGL_Uniform2iv,
|
||||
(4, (static, UINT32_FAIL, nsICanvasRenderingContextWebGL_Uniform2iv_tn, CONTEXT, THIS, OBJECT, OBJECT, 0, nanojit::ACC_STORE_ANY)))
|
||||
|
||||
// FIXME This should return void, not uint32
|
||||
// (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
static uint32 FASTCALL
|
||||
nsICanvasRenderingContextWebGL_Uniform3iv_tn(JSContext *cx, JSObject *obj, JSObject *location, JSObject *arg)
|
||||
{
|
||||
helper_nsICanvasRenderingContextWebGL_Uniform_x_iv_tn(cx, obj, location, arg, 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_DEFINE_TRCINFO_1(nsICanvasRenderingContextWebGL_Uniform3iv,
|
||||
(4, (static, UINT32_FAIL, nsICanvasRenderingContextWebGL_Uniform3iv_tn, CONTEXT, THIS, OBJECT, OBJECT, 0, nanojit::ACC_STORE_ANY)))
|
||||
|
||||
// FIXME This should return void, not uint32
|
||||
// (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
static uint32 FASTCALL
|
||||
nsICanvasRenderingContextWebGL_Uniform4iv_tn(JSContext *cx, JSObject *obj, JSObject *location, JSObject *arg)
|
||||
{
|
||||
helper_nsICanvasRenderingContextWebGL_Uniform_x_iv_tn(cx, obj, location, arg, 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_DEFINE_TRCINFO_1(nsICanvasRenderingContextWebGL_Uniform4iv,
|
||||
(4, (static, UINT32_FAIL, nsICanvasRenderingContextWebGL_Uniform4iv_tn, CONTEXT, THIS, OBJECT, OBJECT, 0, nanojit::ACC_STORE_ANY)))
|
||||
|
||||
// FIXME This should return void, not uint32
|
||||
// (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
static uint32 FASTCALL
|
||||
nsICanvasRenderingContextWebGL_Uniform1fv_tn(JSContext *cx, JSObject *obj, JSObject *location, JSObject *arg)
|
||||
{
|
||||
helper_nsICanvasRenderingContextWebGL_Uniform_x_fv_tn(cx, obj, location, arg, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_DEFINE_TRCINFO_1(nsICanvasRenderingContextWebGL_Uniform1fv,
|
||||
(4, (static, UINT32_FAIL, nsICanvasRenderingContextWebGL_Uniform1fv_tn, CONTEXT, THIS, OBJECT, OBJECT, 0, nanojit::ACC_STORE_ANY)))
|
||||
|
||||
// FIXME This should return void, not uint32
|
||||
// (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
static uint32 FASTCALL
|
||||
nsICanvasRenderingContextWebGL_Uniform2fv_tn(JSContext *cx, JSObject *obj, JSObject *location, JSObject *arg)
|
||||
{
|
||||
helper_nsICanvasRenderingContextWebGL_Uniform_x_fv_tn(cx, obj, location, arg, 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_DEFINE_TRCINFO_1(nsICanvasRenderingContextWebGL_Uniform2fv,
|
||||
(4, (static, UINT32_FAIL, nsICanvasRenderingContextWebGL_Uniform2fv_tn, CONTEXT, THIS, OBJECT, OBJECT, 0, nanojit::ACC_STORE_ANY)))
|
||||
|
||||
// FIXME This should return void, not uint32
|
||||
// (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
static uint32 FASTCALL
|
||||
nsICanvasRenderingContextWebGL_Uniform3fv_tn(JSContext *cx, JSObject *obj, JSObject *location, JSObject *arg)
|
||||
{
|
||||
helper_nsICanvasRenderingContextWebGL_Uniform_x_fv_tn(cx, obj, location, arg, 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_DEFINE_TRCINFO_1(nsICanvasRenderingContextWebGL_Uniform3fv,
|
||||
(4, (static, UINT32_FAIL, nsICanvasRenderingContextWebGL_Uniform3fv_tn, CONTEXT, THIS, OBJECT, OBJECT, 0, nanojit::ACC_STORE_ANY)))
|
||||
|
||||
// FIXME This should return void, not uint32
|
||||
// (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
static uint32 FASTCALL
|
||||
nsICanvasRenderingContextWebGL_Uniform4fv_tn(JSContext *cx, JSObject *obj, JSObject *location, JSObject *arg)
|
||||
{
|
||||
helper_nsICanvasRenderingContextWebGL_Uniform_x_fv_tn(cx, obj, location, arg, 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_DEFINE_TRCINFO_1(nsICanvasRenderingContextWebGL_Uniform4fv,
|
||||
(4, (static, UINT32_FAIL, nsICanvasRenderingContextWebGL_Uniform4fv_tn, CONTEXT, THIS, OBJECT, OBJECT, 0, nanojit::ACC_STORE_ANY)))
|
||||
|
||||
// FIXME This should return void, not uint32
|
||||
// (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
static uint32 FASTCALL
|
||||
nsICanvasRenderingContextWebGL_UniformMatrix2fv_tn(JSContext *cx, JSObject *obj, JSObject *loc, JSBool transpose, JSObject *arg)
|
||||
{
|
||||
helper_nsICanvasRenderingContextWebGL_UniformMatrix_x_fv_tn(cx, obj, loc, transpose, arg, 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_DEFINE_TRCINFO_1(nsICanvasRenderingContextWebGL_UniformMatrix2fv,
|
||||
(5, (static, UINT32_FAIL, nsICanvasRenderingContextWebGL_UniformMatrix2fv_tn, CONTEXT, THIS, OBJECT, BOOL, OBJECT, 0, nanojit::ACC_STORE_ANY)))
|
||||
|
||||
// FIXME This should return void, not uint32
|
||||
// (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
static uint32 FASTCALL
|
||||
nsICanvasRenderingContextWebGL_UniformMatrix3fv_tn(JSContext *cx, JSObject *obj, JSObject *loc, JSBool transpose, JSObject *arg)
|
||||
{
|
||||
helper_nsICanvasRenderingContextWebGL_UniformMatrix_x_fv_tn(cx, obj, loc, transpose, arg, 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_DEFINE_TRCINFO_1(nsICanvasRenderingContextWebGL_UniformMatrix3fv,
|
||||
(5, (static, UINT32_FAIL, nsICanvasRenderingContextWebGL_UniformMatrix3fv_tn, CONTEXT, THIS, OBJECT, BOOL, OBJECT, 0, nanojit::ACC_STORE_ANY)))
|
||||
|
||||
// FIXME This should return void, not uint32
|
||||
// (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
static uint32 FASTCALL
|
||||
nsICanvasRenderingContextWebGL_UniformMatrix4fv_tn(JSContext *cx, JSObject *obj, JSObject *loc, JSBool transpose, JSObject *arg)
|
||||
{
|
||||
helper_nsICanvasRenderingContextWebGL_UniformMatrix_x_fv_tn(cx, obj, loc, transpose, arg, 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_DEFINE_TRCINFO_1(nsICanvasRenderingContextWebGL_UniformMatrix4fv,
|
||||
(5, (static, UINT32_FAIL, nsICanvasRenderingContextWebGL_UniformMatrix4fv_tn, CONTEXT, THIS, OBJECT, BOOL, OBJECT, 0, nanojit::ACC_STORE_ANY)))
|
||||
|
||||
#endif /* JS_TRACER */
|
||||
|
|
|
@ -311,7 +311,7 @@ nsEventListenerManager::RemoveAllListeners()
|
|||
void
|
||||
nsEventListenerManager::Shutdown()
|
||||
{
|
||||
sAddListenerID = JSVAL_VOID;
|
||||
sAddListenerID = JSID_VOID;
|
||||
nsDOMEvent::Shutdown();
|
||||
}
|
||||
|
||||
|
@ -832,8 +832,8 @@ nsEventListenerManager::RemoveScriptEventListener(nsIAtom* aName)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
jsval
|
||||
nsEventListenerManager::sAddListenerID = JSVAL_VOID;
|
||||
jsid
|
||||
nsEventListenerManager::sAddListenerID = JSID_VOID;
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
|
||||
|
@ -857,10 +857,10 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
|
|||
return rv;
|
||||
|
||||
if (cx) {
|
||||
if (sAddListenerID == JSVAL_VOID) {
|
||||
if (sAddListenerID == JSID_VOID) {
|
||||
JSAutoRequest ar(cx);
|
||||
sAddListenerID =
|
||||
STRING_TO_JSVAL(::JS_InternString(cx, "addEventListener"));
|
||||
INTERNED_STRING_TO_JSID(::JS_InternString(cx, "addEventListener"));
|
||||
}
|
||||
|
||||
if (aContext->GetScriptTypeID() == nsIProgrammingLanguage::JAVASCRIPT) {
|
||||
|
|
|
@ -227,7 +227,7 @@ protected:
|
|||
nsCOMPtr<nsIAtom> mNoListenerForEventAtom;
|
||||
|
||||
static PRUint32 mInstanceCount;
|
||||
static jsval sAddListenerID;
|
||||
static jsid sAddListenerID;
|
||||
|
||||
friend class nsEventTargetChainItem;
|
||||
static PRUint32 sCreatedCount;
|
||||
|
|
|
@ -3636,10 +3636,10 @@ ConvertToMidasInternalCommand(const nsAString & inCommandID,
|
|||
dummyBool, dummyBool, PR_TRUE);
|
||||
}
|
||||
|
||||
jsval
|
||||
nsHTMLDocument::sCutCopyInternal_id = JSVAL_VOID;
|
||||
jsval
|
||||
nsHTMLDocument::sPasteInternal_id = JSVAL_VOID;
|
||||
jsid
|
||||
nsHTMLDocument::sCutCopyInternal_id = JSID_VOID;
|
||||
jsid
|
||||
nsHTMLDocument::sPasteInternal_id = JSID_VOID;
|
||||
|
||||
/* Helper function to check security of clipboard commands. If aPaste is */
|
||||
/* true, we check paste, else we check cutcopy */
|
||||
|
@ -3665,17 +3665,17 @@ nsHTMLDocument::DoClipboardSecurityCheck(PRBool aPaste)
|
|||
nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
|
||||
|
||||
if (aPaste) {
|
||||
if (nsHTMLDocument::sPasteInternal_id == JSVAL_VOID) {
|
||||
if (nsHTMLDocument::sPasteInternal_id == JSID_VOID) {
|
||||
nsHTMLDocument::sPasteInternal_id =
|
||||
STRING_TO_JSVAL(::JS_InternString(cx, "paste"));
|
||||
INTERNED_STRING_TO_JSID(::JS_InternString(cx, "paste"));
|
||||
}
|
||||
rv = secMan->CheckPropertyAccess(cx, nsnull, classNameStr.get(),
|
||||
nsHTMLDocument::sPasteInternal_id,
|
||||
nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
|
||||
} else {
|
||||
if (nsHTMLDocument::sCutCopyInternal_id == JSVAL_VOID) {
|
||||
if (nsHTMLDocument::sCutCopyInternal_id == JSID_VOID) {
|
||||
nsHTMLDocument::sCutCopyInternal_id =
|
||||
STRING_TO_JSVAL(::JS_InternString(cx, "cutcopy"));
|
||||
INTERNED_STRING_TO_JSID(::JS_InternString(cx, "cutcopy"));
|
||||
}
|
||||
rv = secMan->CheckPropertyAccess(cx, nsnull, classNameStr.get(),
|
||||
nsHTMLDocument::sCutCopyInternal_id,
|
||||
|
|
|
@ -375,8 +375,8 @@ protected:
|
|||
EditingState mEditingState;
|
||||
|
||||
nsresult DoClipboardSecurityCheck(PRBool aPaste);
|
||||
static jsval sCutCopyInternal_id;
|
||||
static jsval sPasteInternal_id;
|
||||
static jsid sCutCopyInternal_id;
|
||||
static jsid sPasteInternal_id;
|
||||
|
||||
// When false, the .cookies property is completely disabled
|
||||
PRBool mDisableCookieAccess;
|
||||
|
|
|
@ -123,7 +123,7 @@ XBLFinalize(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XBLResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
XBLResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp)
|
||||
{
|
||||
// Note: if we get here, that means that the implementation for some binding
|
||||
|
@ -136,7 +136,7 @@ XBLResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
|||
JSObject* origObj = *objp;
|
||||
*objp = NULL;
|
||||
|
||||
if (!JSVAL_IS_STRING(id)) {
|
||||
if (!JSID_IS_STRING(id)) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
// nsIScriptObjectPrincipal methods
|
||||
virtual nsIPrincipal* GetPrincipal();
|
||||
|
||||
static JSBool doCheckAccess(JSContext *cx, JSObject *obj, jsval id,
|
||||
static JSBool doCheckAccess(JSContext *cx, JSObject *obj, jsid id,
|
||||
PRUint32 accessType);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXBLDocGlobalObject,
|
||||
|
@ -104,7 +104,7 @@ protected:
|
|||
};
|
||||
|
||||
JSBool
|
||||
nsXBLDocGlobalObject::doCheckAccess(JSContext *cx, JSObject *obj, jsval id, PRUint32 accessType)
|
||||
nsXBLDocGlobalObject::doCheckAccess(JSContext *cx, JSObject *obj, jsid id, PRUint32 accessType)
|
||||
{
|
||||
nsIScriptSecurityManager *ssm = nsContentUtils::GetSecurityManager();
|
||||
if (!ssm) {
|
||||
|
@ -129,7 +129,7 @@ nsXBLDocGlobalObject::doCheckAccess(JSContext *cx, JSObject *obj, jsval id, PRUi
|
|||
|
||||
static JSBool
|
||||
nsXBLDocGlobalObject_getProperty(JSContext *cx, JSObject *obj,
|
||||
jsval id, jsval *vp)
|
||||
jsid id, jsval *vp)
|
||||
{
|
||||
return nsXBLDocGlobalObject::
|
||||
doCheckAccess(cx, obj, id, nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
|
||||
|
@ -137,14 +137,14 @@ nsXBLDocGlobalObject_getProperty(JSContext *cx, JSObject *obj,
|
|||
|
||||
static JSBool
|
||||
nsXBLDocGlobalObject_setProperty(JSContext *cx, JSObject *obj,
|
||||
jsval id, jsval *vp)
|
||||
jsid id, jsval *vp)
|
||||
{
|
||||
return nsXBLDocGlobalObject::
|
||||
doCheckAccess(cx, obj, id, nsIXPCSecurityManager::ACCESS_SET_PROPERTY);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsXBLDocGlobalObject_checkAccess(JSContext *cx, JSObject *obj, jsval id,
|
||||
nsXBLDocGlobalObject_checkAccess(JSContext *cx, JSObject *obj, jsid id,
|
||||
JSAccessMode mode, jsval *vp)
|
||||
{
|
||||
PRUint32 translated;
|
||||
|
@ -173,7 +173,7 @@ nsXBLDocGlobalObject_finalize(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
nsXBLDocGlobalObject_resolve(JSContext *cx, JSObject *obj, jsval id)
|
||||
nsXBLDocGlobalObject_resolve(JSContext *cx, JSObject *obj, jsid id)
|
||||
{
|
||||
JSBool did_resolve = JS_FALSE;
|
||||
return JS_ResolveStandardClass(cx, obj, id, &did_resolve);
|
||||
|
|
|
@ -132,7 +132,7 @@ nsXULPDGlobalObject_finalize(JSContext *cx, JSObject *obj)
|
|||
|
||||
|
||||
JSBool
|
||||
nsXULPDGlobalObject_resolve(JSContext *cx, JSObject *obj, jsval id)
|
||||
nsXULPDGlobalObject_resolve(JSContext *cx, JSObject *obj, jsid id)
|
||||
{
|
||||
JSBool did_resolve = JS_FALSE;
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -229,10 +229,10 @@ protected:
|
|||
// Checks if id is a number and returns the number, if aIsNumber is
|
||||
// non-null it's set to true if the id is a number and false if it's
|
||||
// not a number. If id is not a number this method returns -1
|
||||
static PRInt32 GetArrayIndexFromId(JSContext *cx, jsval id,
|
||||
static PRInt32 GetArrayIndexFromId(JSContext *cx, jsid id,
|
||||
PRBool *aIsNumber = nsnull);
|
||||
|
||||
static inline PRBool IsReadonlyReplaceable(jsval id)
|
||||
static inline PRBool IsReadonlyReplaceable(jsid id)
|
||||
{
|
||||
return (id == sTop_id ||
|
||||
id == sParent_id ||
|
||||
|
@ -253,7 +253,7 @@ protected:
|
|||
id == sSelf_id);
|
||||
}
|
||||
|
||||
static inline PRBool IsWritableReplaceable(jsval id)
|
||||
static inline PRBool IsWritableReplaceable(jsid id)
|
||||
{
|
||||
return (id == sInnerHeight_id ||
|
||||
id == sInnerWidth_id ||
|
||||
|
@ -276,90 +276,90 @@ protected:
|
|||
static PRBool sDisableDocumentAllSupport;
|
||||
static PRBool sDisableGlobalScopePollutionSupport;
|
||||
|
||||
static jsval sTop_id;
|
||||
static jsval sParent_id;
|
||||
static jsval sScrollbars_id;
|
||||
static jsval sLocation_id;
|
||||
static jsval sConstructor_id;
|
||||
static jsval s_content_id;
|
||||
static jsval sContent_id;
|
||||
static jsval sMenubar_id;
|
||||
static jsval sToolbar_id;
|
||||
static jsval sLocationbar_id;
|
||||
static jsval sPersonalbar_id;
|
||||
static jsval sStatusbar_id;
|
||||
static jsval sDialogArguments_id;
|
||||
static jsval sControllers_id;
|
||||
static jsval sLength_id;
|
||||
static jsval sInnerHeight_id;
|
||||
static jsval sInnerWidth_id;
|
||||
static jsval sOuterHeight_id;
|
||||
static jsval sOuterWidth_id;
|
||||
static jsval sScreenX_id;
|
||||
static jsval sScreenY_id;
|
||||
static jsval sStatus_id;
|
||||
static jsval sName_id;
|
||||
static jsval sOnmousedown_id;
|
||||
static jsval sOnmouseup_id;
|
||||
static jsval sOnclick_id;
|
||||
static jsval sOndblclick_id;
|
||||
static jsval sOncontextmenu_id;
|
||||
static jsval sOnmouseover_id;
|
||||
static jsval sOnmouseout_id;
|
||||
static jsval sOnkeydown_id;
|
||||
static jsval sOnkeyup_id;
|
||||
static jsval sOnkeypress_id;
|
||||
static jsval sOnmousemove_id;
|
||||
static jsval sOnfocus_id;
|
||||
static jsval sOnblur_id;
|
||||
static jsval sOnsubmit_id;
|
||||
static jsval sOnreset_id;
|
||||
static jsval sOnchange_id;
|
||||
static jsval sOnselect_id;
|
||||
static jsval sOnload_id;
|
||||
static jsval sOnpopstate_id;
|
||||
static jsval sOnbeforeunload_id;
|
||||
static jsval sOnunload_id;
|
||||
static jsval sOnhashchange_id;
|
||||
static jsval sOnpageshow_id;
|
||||
static jsval sOnpagehide_id;
|
||||
static jsval sOnabort_id;
|
||||
static jsval sOnerror_id;
|
||||
static jsval sOnpaint_id;
|
||||
static jsval sOnresize_id;
|
||||
static jsval sOnscroll_id;
|
||||
static jsval sOndrag_id;
|
||||
static jsval sOndragend_id;
|
||||
static jsval sOndragenter_id;
|
||||
static jsval sOndragleave_id;
|
||||
static jsval sOndragover_id;
|
||||
static jsval sOndragstart_id;
|
||||
static jsval sOndrop_id;
|
||||
static jsval sScrollX_id;
|
||||
static jsval sScrollY_id;
|
||||
static jsval sScrollMaxX_id;
|
||||
static jsval sScrollMaxY_id;
|
||||
static jsval sOpen_id;
|
||||
static jsval sItem_id;
|
||||
static jsval sNamedItem_id;
|
||||
static jsval sEnumerate_id;
|
||||
static jsval sNavigator_id;
|
||||
static jsval sDocument_id;
|
||||
static jsval sWindow_id;
|
||||
static jsval sFrames_id;
|
||||
static jsval sSelf_id;
|
||||
static jsval sOpener_id;
|
||||
static jsval sAll_id;
|
||||
static jsval sTags_id;
|
||||
static jsval sAddEventListener_id;
|
||||
static jsval sBaseURIObject_id;
|
||||
static jsval sNodePrincipal_id;
|
||||
static jsval sDocumentURIObject_id;
|
||||
static jsval sOncopy_id;
|
||||
static jsval sOncut_id;
|
||||
static jsval sOnpaste_id;
|
||||
static jsval sJava_id;
|
||||
static jsval sPackages_id;
|
||||
static jsid sTop_id;
|
||||
static jsid sParent_id;
|
||||
static jsid sScrollbars_id;
|
||||
static jsid sLocation_id;
|
||||
static jsid sConstructor_id;
|
||||
static jsid s_content_id;
|
||||
static jsid sContent_id;
|
||||
static jsid sMenubar_id;
|
||||
static jsid sToolbar_id;
|
||||
static jsid sLocationbar_id;
|
||||
static jsid sPersonalbar_id;
|
||||
static jsid sStatusbar_id;
|
||||
static jsid sDialogArguments_id;
|
||||
static jsid sControllers_id;
|
||||
static jsid sLength_id;
|
||||
static jsid sInnerHeight_id;
|
||||
static jsid sInnerWidth_id;
|
||||
static jsid sOuterHeight_id;
|
||||
static jsid sOuterWidth_id;
|
||||
static jsid sScreenX_id;
|
||||
static jsid sScreenY_id;
|
||||
static jsid sStatus_id;
|
||||
static jsid sName_id;
|
||||
static jsid sOnmousedown_id;
|
||||
static jsid sOnmouseup_id;
|
||||
static jsid sOnclick_id;
|
||||
static jsid sOndblclick_id;
|
||||
static jsid sOncontextmenu_id;
|
||||
static jsid sOnmouseover_id;
|
||||
static jsid sOnmouseout_id;
|
||||
static jsid sOnkeydown_id;
|
||||
static jsid sOnkeyup_id;
|
||||
static jsid sOnkeypress_id;
|
||||
static jsid sOnmousemove_id;
|
||||
static jsid sOnfocus_id;
|
||||
static jsid sOnblur_id;
|
||||
static jsid sOnsubmit_id;
|
||||
static jsid sOnreset_id;
|
||||
static jsid sOnchange_id;
|
||||
static jsid sOnselect_id;
|
||||
static jsid sOnload_id;
|
||||
static jsid sOnpopstate_id;
|
||||
static jsid sOnbeforeunload_id;
|
||||
static jsid sOnunload_id;
|
||||
static jsid sOnhashchange_id;
|
||||
static jsid sOnpageshow_id;
|
||||
static jsid sOnpagehide_id;
|
||||
static jsid sOnabort_id;
|
||||
static jsid sOnerror_id;
|
||||
static jsid sOnpaint_id;
|
||||
static jsid sOnresize_id;
|
||||
static jsid sOnscroll_id;
|
||||
static jsid sOndrag_id;
|
||||
static jsid sOndragend_id;
|
||||
static jsid sOndragenter_id;
|
||||
static jsid sOndragleave_id;
|
||||
static jsid sOndragover_id;
|
||||
static jsid sOndragstart_id;
|
||||
static jsid sOndrop_id;
|
||||
static jsid sScrollX_id;
|
||||
static jsid sScrollY_id;
|
||||
static jsid sScrollMaxX_id;
|
||||
static jsid sScrollMaxY_id;
|
||||
static jsid sOpen_id;
|
||||
static jsid sItem_id;
|
||||
static jsid sNamedItem_id;
|
||||
static jsid sEnumerate_id;
|
||||
static jsid sNavigator_id;
|
||||
static jsid sDocument_id;
|
||||
static jsid sWindow_id;
|
||||
static jsid sFrames_id;
|
||||
static jsid sSelf_id;
|
||||
static jsid sOpener_id;
|
||||
static jsid sAll_id;
|
||||
static jsid sTags_id;
|
||||
static jsid sAddEventListener_id;
|
||||
static jsid sBaseURIObject_id;
|
||||
static jsid sNodePrincipal_id;
|
||||
static jsid sDocumentURIObject_id;
|
||||
static jsid sOncopy_id;
|
||||
static jsid sOncut_id;
|
||||
static jsid sOnpaste_id;
|
||||
static jsid sJava_id;
|
||||
static jsid sPackages_id;
|
||||
|
||||
static JSPropertyOp sXPCNativeWrapperGetPropertyOp;
|
||||
};
|
||||
|
@ -418,13 +418,13 @@ protected:
|
|||
{
|
||||
}
|
||||
|
||||
static PRBool ReallyIsEventName(jsval id, jschar aFirstChar);
|
||||
static PRBool ReallyIsEventName(jsid id, jschar aFirstChar);
|
||||
|
||||
static inline PRBool IsEventName(jsval id)
|
||||
static inline PRBool IsEventName(jsid id)
|
||||
{
|
||||
NS_ASSERTION(JSVAL_IS_STRING(id), "Don't pass non-string jsval's here!");
|
||||
NS_ASSERTION(JSID_IS_STRING(id), "Don't pass non-string jsid's here!");
|
||||
|
||||
jschar *str = ::JS_GetStringChars(JSVAL_TO_STRING(id));
|
||||
jschar *str = ::JS_GetStringChars(JSID_TO_STRING(id));
|
||||
|
||||
if (str[0] == 'o' && str[1] == 'n') {
|
||||
return ReallyIsEventName(id, str[2]);
|
||||
|
@ -434,19 +434,19 @@ protected:
|
|||
}
|
||||
|
||||
nsresult RegisterCompileHandler(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj, jsval id,
|
||||
JSContext *cx, JSObject *obj, jsid id,
|
||||
PRBool compile, PRBool remove,
|
||||
PRBool *did_define);
|
||||
|
||||
public:
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject *obj, jsid id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp,
|
||||
JSObject *obj, jsid id, jsval *vp,
|
||||
PRBool *_retval);
|
||||
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
};
|
||||
|
||||
// Simpler than nsEventReceiverSH
|
||||
|
@ -465,7 +465,7 @@ public:
|
|||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj);
|
||||
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
|
||||
virtual void PreserveWrapper(nsISupports *aNative);
|
||||
|
||||
|
@ -520,15 +520,15 @@ public:
|
|||
}
|
||||
#endif
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject *obj, jsid id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, PRUint32 enum_op, jsval *statep,
|
||||
|
@ -543,11 +543,11 @@ public:
|
|||
JSObject * obj, JSObject * *_retval);
|
||||
|
||||
static JSBool GlobalScopePolluterNewResolve(JSContext *cx, JSObject *obj,
|
||||
jsval id, uintN flags,
|
||||
jsid id, uintN flags,
|
||||
JSObject **objp);
|
||||
static JSBool GlobalScopePolluterGetProperty(JSContext *cx, JSObject *obj,
|
||||
jsval id, jsval *vp);
|
||||
static JSBool SecurityCheckOnSetProp(JSContext *cx, JSObject *obj, jsval id,
|
||||
jsid id, jsval *vp);
|
||||
static JSBool SecurityCheckOnSetProp(JSContext *cx, JSObject *obj, jsid id,
|
||||
jsval *vp);
|
||||
static void InvalidateGlobalScopePolluter(JSContext *cx, JSObject *obj);
|
||||
static nsresult InstallGlobalScopePolluter(JSContext *cx, JSObject *obj,
|
||||
|
@ -575,7 +575,7 @@ protected:
|
|||
|
||||
public:
|
||||
NS_IMETHOD CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 mode,
|
||||
JSObject *obj, jsid id, PRUint32 mode,
|
||||
jsval *vp, PRBool *_retval);
|
||||
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
|
@ -637,21 +637,21 @@ protected:
|
|||
// work so it's safe to just return whatever it returns. |obj| is the object
|
||||
// we're defining on, |id| is the name of the prop. This must be a string
|
||||
// jsval. |objp| is the out param if we define successfully.
|
||||
nsresult DefineVoidProp(JSContext* cx, JSObject* obj, jsval id,
|
||||
nsresult DefineVoidProp(JSContext* cx, JSObject* obj, jsid id,
|
||||
JSObject** objp);
|
||||
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj);
|
||||
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject *obj, jsid id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags);
|
||||
|
||||
virtual void PreserveWrapper(nsISupports *aNative);
|
||||
|
@ -706,7 +706,7 @@ protected:
|
|||
|
||||
public:
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject *obj, jsid id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, PRBool *_retval);
|
||||
|
@ -741,7 +741,7 @@ protected:
|
|||
|
||||
public:
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
|
||||
private:
|
||||
// Not implemented, nothing should create an instance of this class.
|
||||
|
@ -793,7 +793,7 @@ protected:
|
|||
|
||||
public:
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
|
||||
private:
|
||||
// Not implemented, nothing should create an instance of this class.
|
||||
|
@ -905,12 +905,12 @@ public:
|
|||
|
||||
public:
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject *obj, jsid id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD GetFlags(PRUint32* aFlags);
|
||||
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
|
@ -936,7 +936,7 @@ protected:
|
|||
}
|
||||
|
||||
static nsresult ResolveImpl(JSContext *cx,
|
||||
nsIXPConnectWrappedNative *wrapper, jsval id,
|
||||
nsIXPConnectWrappedNative *wrapper, jsid id,
|
||||
nsISupports **result);
|
||||
static JSBool DocumentOpen(JSContext *cx, JSObject *obj, uintN argc,
|
||||
jsval *argv, jsval *rval);
|
||||
|
@ -945,27 +945,27 @@ protected:
|
|||
nsIDOMNodeList **nodeList);
|
||||
|
||||
public:
|
||||
static JSBool DocumentAllGetProperty(JSContext *cx, JSObject *obj, jsval id,
|
||||
static JSBool DocumentAllGetProperty(JSContext *cx, JSObject *obj, jsid id,
|
||||
jsval *vp);
|
||||
static JSBool DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsval id,
|
||||
static JSBool DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
|
||||
uintN flags, JSObject **objp);
|
||||
static void ReleaseDocument(JSContext *cx, JSObject *obj);
|
||||
static JSBool CallToGetPropMapper(JSContext *cx, JSObject *obj, uintN argc,
|
||||
jsval *argv, jsval *rval);
|
||||
static JSBool DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
|
||||
jsval id, jsval *vp);
|
||||
jsid id, jsval *vp);
|
||||
static JSBool DocumentAllHelperNewResolve(JSContext *cx, JSObject *obj,
|
||||
jsval id, uintN flags,
|
||||
jsid id, uintN flags,
|
||||
JSObject **objp);
|
||||
static JSBool DocumentAllTagsNewResolve(JSContext *cx, JSObject *obj,
|
||||
jsval id, uintN flags,
|
||||
jsid id, uintN flags,
|
||||
JSObject **objp);
|
||||
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject *obj, jsid id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
|
@ -989,15 +989,15 @@ protected:
|
|||
|
||||
public:
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject *obj, jsid id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp,
|
||||
JSObject *obj, jsid id, jsval *vp,
|
||||
PRBool *_retval);
|
||||
|
||||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
|
@ -1024,10 +1024,10 @@ protected:
|
|||
|
||||
public:
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject *obj, jsid id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp,
|
||||
JSObject *obj, jsid id, jsval *vp,
|
||||
PRBool *_retval);
|
||||
|
||||
NS_IMETHOD NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
|
@ -1057,10 +1057,10 @@ protected:
|
|||
|
||||
public:
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp,
|
||||
JSObject *obj, jsid id, jsval *vp,
|
||||
PRBool *_retval);
|
||||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
|
||||
static nsresult SetOption(JSContext *cx, jsval *vp, PRUint32 aIndex,
|
||||
nsIDOMNSHTMLOptionCollection *aOptCollection);
|
||||
|
@ -1097,16 +1097,16 @@ protected:
|
|||
|
||||
public:
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject *obj, jsid id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj);
|
||||
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, PRUint32 argc, jsval *argv, jsval *vp,
|
||||
PRBool *_retval);
|
||||
|
@ -1138,7 +1138,7 @@ protected:
|
|||
|
||||
public:
|
||||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
|
@ -1252,7 +1252,7 @@ protected:
|
|||
|
||||
public:
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
};
|
||||
|
||||
|
||||
|
@ -1274,7 +1274,7 @@ protected:
|
|||
|
||||
public:
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
|
@ -1547,12 +1547,12 @@ protected:
|
|||
}
|
||||
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject *obj, jsid id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, PRUint32 enum_op, jsval *statep,
|
||||
jsid *idp, PRBool *_retval);
|
||||
|
@ -1587,14 +1587,14 @@ protected:
|
|||
}
|
||||
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject *obj, jsid id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, PRUint32 enum_op, jsval *statep,
|
||||
jsid *idp, PRBool *_retval);
|
||||
|
|
|
@ -9769,7 +9769,7 @@ nsNavigator::nsNavigator(nsIDocShell *aDocShell)
|
|||
|
||||
nsNavigator::~nsNavigator()
|
||||
{
|
||||
sPrefInternal_id = JSVAL_VOID;
|
||||
sPrefInternal_id = JSID_VOID;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -10196,8 +10196,8 @@ nsNavigator::TaintEnabled(PRBool *aReturn)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
jsval
|
||||
nsNavigator::sPrefInternal_id = JSVAL_VOID;
|
||||
jsid
|
||||
nsNavigator::sPrefInternal_id = JSID_VOID;
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavigator::Preference()
|
||||
|
@ -10235,9 +10235,9 @@ nsNavigator::Preference()
|
|||
JSAutoRequest ar(cx);
|
||||
|
||||
//--Check to see if the caller is allowed to access prefs
|
||||
if (sPrefInternal_id == JSVAL_VOID) {
|
||||
if (sPrefInternal_id == JSID_VOID) {
|
||||
sPrefInternal_id =
|
||||
STRING_TO_JSVAL(::JS_InternString(cx, "preferenceinternal"));
|
||||
INTERNED_STRING_TO_JSID(::JS_InternString(cx, "preferenceinternal"));
|
||||
}
|
||||
|
||||
PRUint32 action;
|
||||
|
|
|
@ -926,7 +926,7 @@ protected:
|
|||
nsRefPtr<nsGeolocation> mGeolocation;
|
||||
nsIDocShell* mDocShell; // weak reference
|
||||
|
||||
static jsval sPrefInternal_id;
|
||||
static jsid sPrefInternal_id;
|
||||
};
|
||||
|
||||
class nsIURI;
|
||||
|
|
|
@ -3041,10 +3041,10 @@ static JSPropertySpec OptionsProperties[] = {
|
|||
};
|
||||
|
||||
static JSBool
|
||||
GetOptionsProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
GetOptionsProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
uint32 optbit = (uint32) JSVAL_TO_INT(id);
|
||||
if (JSID_IS_INT(id)) {
|
||||
uint32 optbit = (uint32) JSID_TO_INT(id);
|
||||
if (((optbit & (optbit - 1)) == 0 && optbit <= JSOPTION_WERROR) ||
|
||||
optbit == JSOPTION_RELIMIT)
|
||||
*vp = (JS_GetOptions(cx) & optbit) ? JSVAL_TRUE : JSVAL_FALSE;
|
||||
|
@ -3053,10 +3053,10 @@ GetOptionsProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
SetOptionsProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
SetOptionsProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
uint32 optbit = (uint32) JSVAL_TO_INT(id);
|
||||
if (JSID_IS_INT(id)) {
|
||||
uint32 optbit = (uint32) JSID_TO_INT(id);
|
||||
|
||||
// Don't let options other than strict, werror, or relimit be set -- it
|
||||
// would be bad if web page script could clear
|
||||
|
|
|
@ -81,6 +81,12 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
explicit nsDependentJSString(jsid id)
|
||||
: nsDependentString((PRUnichar *)::JS_GetStringChars(JSID_TO_STRING(id)),
|
||||
::JS_GetStringLength(JSID_TO_STRING(id)))
|
||||
{
|
||||
}
|
||||
|
||||
explicit nsDependentJSString(JSString *str)
|
||||
: nsDependentString((PRUnichar *)::JS_GetStringChars(str), ::JS_GetStringLength(str))
|
||||
{
|
||||
|
|
|
@ -116,7 +116,7 @@ public:
|
|||
|
||||
#ifdef BUILD_CTYPES
|
||||
static JSBool
|
||||
CTypesLazyGetter(JSContext* aCx, JSObject* aObj, jsval aId, jsval* aVp);
|
||||
CTypesLazyGetter(JSContext* aCx, JSObject* aObj, jsid aId, jsval* aVp);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@ -434,14 +434,14 @@ nsDOMWorkerFunctions::MakeNewWorker(JSContext* aCx,
|
|||
JSBool
|
||||
nsDOMWorkerFunctions::CTypesLazyGetter(JSContext* aCx,
|
||||
JSObject* aObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
jsval* aVp)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
NS_ASSERTION(JS_GetGlobalForObject(aCx, aObj) == aObj, "Bad object!");
|
||||
NS_ASSERTION(JSVAL_IS_STRING(aId), "Not a string!");
|
||||
JSString* str = JSVAL_TO_STRING(aId);
|
||||
NS_ASSERTION(JSID_IS_STRING(aId), "Not a string!");
|
||||
JSString* str = JSID_TO_STRING(aId);
|
||||
NS_ASSERTION(nsDependentJSString(str).EqualsLiteral("ctypes"), "Bad id!");
|
||||
}
|
||||
#endif
|
||||
|
@ -453,11 +453,9 @@ nsDOMWorkerFunctions::CTypesLazyGetter(JSContext* aCx,
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
js::AutoIdRooter rooter(aCx);
|
||||
return JS_ValueToId(aCx, aId, rooter.addr()) &&
|
||||
JS_DeletePropertyById(aCx, aObj, rooter.id()) &&
|
||||
return JS_DeletePropertyById(aCx, aObj, aId) &&
|
||||
JS_InitCTypesClass(aCx, aObj) &&
|
||||
JS_GetPropertyById(aCx, aObj, rooter.id(), aVp);
|
||||
JS_GetPropertyById(aCx, aObj, aId, aVp);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -586,7 +584,7 @@ NS_IMETHODIMP
|
|||
nsDOMWorkerScope::AddProperty(nsIXPConnectWrappedNative* aWrapper,
|
||||
JSContext* aCx,
|
||||
JSObject* aObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
jsval* aVp,
|
||||
PRBool* _retval)
|
||||
{
|
||||
|
@ -598,14 +596,14 @@ nsDOMWorkerScope::AddProperty(nsIXPConnectWrappedNative* aWrapper,
|
|||
// someone making an 'onmessage' or 'onerror' function so aId must be a
|
||||
// string and aVp must be a function.
|
||||
JSObject* funObj;
|
||||
if (!(JSVAL_IS_STRING(aId) &&
|
||||
if (!(JSID_IS_STRING(aId) &&
|
||||
JSVAL_IS_OBJECT(*aVp) &&
|
||||
(funObj = JSVAL_TO_OBJECT(*aVp)) &&
|
||||
JS_ObjectIsFunction(aCx, funObj))) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const char* name = JS_GetStringBytes(JSVAL_TO_STRING(aId));
|
||||
const char* name = JS_GetStringBytes(JSID_TO_STRING(aId));
|
||||
|
||||
// Figure out which listener we're setting.
|
||||
SetListenerFunc func;
|
||||
|
|
|
@ -108,7 +108,7 @@ nsDOMWorkerSecurityManager::CanAccess(PRUint32 aAction,
|
|||
JSObject* aJSObject,
|
||||
nsISupports* aObj,
|
||||
nsIClassInfo* aClassInfo,
|
||||
jsval aName,
|
||||
jsid aName,
|
||||
void** aPolicy)
|
||||
{
|
||||
return NS_OK;
|
||||
|
@ -123,7 +123,7 @@ nsDOMWorkerSecurityManager::WorkerPrincipal()
|
|||
JSBool
|
||||
nsDOMWorkerSecurityManager::JSCheckAccess(JSContext* aCx,
|
||||
JSObject* aObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
JSAccessMode aMode,
|
||||
jsval* aVp)
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
static JSPrincipals* WorkerPrincipal();
|
||||
|
||||
static JSBool JSCheckAccess(JSContext* aCx, JSObject* aObj, jsval aId,
|
||||
static JSBool JSCheckAccess(JSContext* aCx, JSObject* aObj, jsid aId,
|
||||
JSAccessMode aMode, jsval* aVp);
|
||||
|
||||
static JSPrincipals* JSFindPrincipal(JSContext* aCx, JSObject* aObj);
|
||||
|
|
|
@ -97,7 +97,7 @@ AutoConfigSecMan::CanAccess(PRUint32 aAction,
|
|||
nsAXPCNativeCallContext *aCallContext,
|
||||
JSContext *aJSContext, JSObject *aJSObject,
|
||||
nsISupports *aObj, nsIClassInfo *aClassInfo,
|
||||
jsval aName, void **aPolicy)
|
||||
jsid aName, void **aPolicy)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -341,14 +341,14 @@ static JSDProperty* _newProperty(JSDContext* jsdc, JSPropertyDesc* pd,
|
|||
jsdprop->flags = pd->flags | additionalFlags;
|
||||
jsdprop->slot = pd->slot;
|
||||
|
||||
if(!(jsdprop->name = jsd_NewValue(jsdc, ID_TO_JSVAL(pd->id))))
|
||||
if(!(jsdprop->name = jsd_NewValue(jsdc, pd->id)))
|
||||
goto new_prop_fail;
|
||||
|
||||
if(!(jsdprop->val = jsd_NewValue(jsdc, pd->value)))
|
||||
goto new_prop_fail;
|
||||
|
||||
if((jsdprop->flags & JSDPD_ALIAS) &&
|
||||
!(jsdprop->alias = jsd_NewValue(jsdc, ID_TO_JSVAL(pd->alias))))
|
||||
!(jsdprop->alias = jsd_NewValue(jsdc, pd->alias)))
|
||||
goto new_prop_fail;
|
||||
|
||||
return jsdprop;
|
||||
|
@ -492,6 +492,7 @@ jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* name)
|
|||
const jschar * nameChars;
|
||||
size_t nameLen;
|
||||
jsval val, nameval;
|
||||
jsid nameid;
|
||||
|
||||
if(!jsd_IsValueObject(jsdc, jsdval))
|
||||
return NULL;
|
||||
|
@ -548,8 +549,11 @@ jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* name)
|
|||
JS_EndRequest(cx);
|
||||
|
||||
nameval = STRING_TO_JSVAL(name);
|
||||
if (!JS_ValueToId(cx, nameval, &pd.id))
|
||||
if (!JS_ValueToId(cx, nameval, &nameid) ||
|
||||
!JS_IdToValue(cx, nameid, &pd.id)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pd.slot = pd.spare = 0;
|
||||
pd.alias = JSVAL_NULL;
|
||||
pd.flags |= (attrs & JSPROP_ENUMERATE) ? JSPD_ENUMERATE : 0
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace CType {
|
|||
static JSBool CreateArray(JSContext* cx, uintN argc, jsval* vp);
|
||||
static JSBool ToString(JSContext* cx, uintN argc, jsval* vp);
|
||||
static JSBool ToSource(JSContext* cx, uintN argc, jsval* vp);
|
||||
static JSBool HasInstance(JSContext* cx, JSObject* obj, jsval v, JSBool* bp);
|
||||
static JSBool HasInstance(JSContext* cx, JSObject* obj, const jsval *v, JSBool* bp);
|
||||
}
|
||||
|
||||
namespace PointerType {
|
||||
|
@ -1317,6 +1317,62 @@ jsvalToSize(JSContext* cx, jsval val, bool allowString, size_t* result)
|
|||
return Convert<size_t>(jsdouble(*result)) == *result;
|
||||
}
|
||||
|
||||
// Implicitly convert val to IntegerType, allowing jsint, jsdouble,
|
||||
// Int64, UInt64, and optionally a decimal or hexadecimal string argument.
|
||||
// (This is common code shared by jsvalToSize and the Int64/UInt64 constructors.)
|
||||
template<class IntegerType>
|
||||
static bool
|
||||
jsidToBigInteger(JSContext* cx,
|
||||
jsid val,
|
||||
bool allowString,
|
||||
IntegerType* result)
|
||||
{
|
||||
JS_STATIC_ASSERT(numeric_limits<IntegerType>::is_exact);
|
||||
|
||||
if (JSID_IS_INT(val)) {
|
||||
// Make sure the integer fits in the alotted precision, and has the right
|
||||
// sign.
|
||||
jsint i = JSID_TO_INT(val);
|
||||
return ConvertExact(i, result);
|
||||
}
|
||||
if (allowString && JSID_IS_STRING(val)) {
|
||||
// Allow conversion from base-10 or base-16 strings, provided the result
|
||||
// fits in IntegerType. (This allows an Int64 or UInt64 object to be passed
|
||||
// to the JS array element operator, which will automatically call
|
||||
// toString() on the object for us.)
|
||||
return StringToInteger(cx, JSID_TO_STRING(val), result);
|
||||
}
|
||||
if (JSID_IS_OBJECT(val)) {
|
||||
// Allow conversion from an Int64 or UInt64 object directly.
|
||||
JSObject* obj = JSID_TO_OBJECT(val);
|
||||
|
||||
if (UInt64::IsUInt64(cx, obj)) {
|
||||
// Make sure the integer fits in IntegerType.
|
||||
JSUint64 i = Int64Base::GetInt(cx, obj);
|
||||
return ConvertExact(i, result);
|
||||
}
|
||||
|
||||
if (Int64::IsInt64(cx, obj)) {
|
||||
// Make sure the integer fits in IntegerType.
|
||||
JSInt64 i = Int64Base::GetInt(cx, obj);
|
||||
return ConvertExact(i, result);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Implicitly convert val to a size value, where the size value is represented
|
||||
// by size_t but must also fit in a jsdouble.
|
||||
static bool
|
||||
jsidToSize(JSContext* cx, jsid val, bool allowString, size_t* result)
|
||||
{
|
||||
if (!jsidToBigInteger(cx, val, allowString, result))
|
||||
return false;
|
||||
|
||||
// Also check that the result fits in a jsdouble.
|
||||
return Convert<size_t>(jsdouble(*result)) == *result;
|
||||
}
|
||||
|
||||
// Implicitly convert a size value to a jsval, ensuring that the size_t value
|
||||
// fits in a jsdouble.
|
||||
static JSBool
|
||||
|
@ -1899,7 +1955,7 @@ ImplicitConvert(JSContext* cx,
|
|||
while (1) {
|
||||
if (!JS_NextProperty(cx, iter, &id))
|
||||
return false;
|
||||
if (JSVAL_IS_VOID(id))
|
||||
if (JSID_IS_VOID(id))
|
||||
break;
|
||||
|
||||
js::AutoValueRooter fieldVal(cx);
|
||||
|
@ -1910,7 +1966,7 @@ ImplicitConvert(JSContext* cx,
|
|||
}
|
||||
|
||||
const FieldInfo* field = StructType::LookupField(cx, targetType,
|
||||
Jsvalify(fieldVal.value()));
|
||||
fieldVal.value().asString());
|
||||
if (!field)
|
||||
return false;
|
||||
|
||||
|
@ -3078,7 +3134,7 @@ CType::ToSource(JSContext* cx, uintN argc, jsval *vp)
|
|||
}
|
||||
|
||||
JSBool
|
||||
CType::HasInstance(JSContext* cx, JSObject* obj, jsval v, JSBool* bp)
|
||||
CType::HasInstance(JSContext* cx, JSObject* obj, const jsval *v, JSBool* bp)
|
||||
{
|
||||
JS_ASSERT(CType::IsCType(cx, obj));
|
||||
|
||||
|
@ -3089,10 +3145,10 @@ CType::HasInstance(JSContext* cx, JSObject* obj, jsval v, JSBool* bp)
|
|||
JS_ASSERT(JS_GET_CLASS(cx, prototype) == &sCDataProtoClass);
|
||||
|
||||
*bp = JS_FALSE;
|
||||
if (JSVAL_IS_PRIMITIVE(v))
|
||||
if (JSVAL_IS_PRIMITIVE(*v))
|
||||
return JS_TRUE;
|
||||
|
||||
JSObject* proto = JSVAL_TO_OBJECT(v);
|
||||
JSObject* proto = JSVAL_TO_OBJECT(*v);
|
||||
while ((proto = JS_GetPrototype(cx, proto))) {
|
||||
if (proto == prototype) {
|
||||
*bp = JS_TRUE;
|
||||
|
@ -3684,8 +3740,8 @@ ArrayType::Getter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
|
|||
// Convert the index to a size_t and bounds-check it.
|
||||
size_t index;
|
||||
size_t length = GetLength(cx, typeObj);
|
||||
bool ok = jsvalToSize(cx, idval, true, &index);
|
||||
if (!ok && JSVAL_IS_STRING(idval)) {
|
||||
bool ok = jsidToSize(cx, idval, true, &index);
|
||||
if (!ok && JSID_IS_STRING(idval)) {
|
||||
// String either isn't a number, or doesn't fit in size_t.
|
||||
// Chances are it's a regular property lookup, so return.
|
||||
return JS_TRUE;
|
||||
|
@ -3719,8 +3775,8 @@ ArrayType::Setter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
|
|||
// Convert the index to a size_t and bounds-check it.
|
||||
size_t index;
|
||||
size_t length = GetLength(cx, typeObj);
|
||||
bool ok = jsvalToSize(cx, idval, true, &index);
|
||||
if (!ok && JSVAL_IS_STRING(idval)) {
|
||||
bool ok = jsidToSize(cx, idval, true, &index);
|
||||
if (!ok && JSID_IS_STRING(idval)) {
|
||||
// String either isn't a number, or doesn't fit in size_t.
|
||||
// Chances are it's a regular property lookup, so return.
|
||||
return JS_TRUE;
|
||||
|
@ -3822,7 +3878,7 @@ ExtractStructField(JSContext* cx, jsval val, JSObject** typeObj)
|
|||
// make sure we have one, and only one, property
|
||||
if (!JS_NextProperty(cx, iter, &id))
|
||||
return NULL;
|
||||
if (!JSVAL_IS_VOID(id)) {
|
||||
if (!JSID_IS_VOID(id)) {
|
||||
JS_ReportError(cx, "struct field descriptors must contain one property");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -4236,12 +4292,11 @@ StructType::GetFieldInfo(JSContext* cx, JSObject* obj)
|
|||
}
|
||||
|
||||
const FieldInfo*
|
||||
StructType::LookupField(JSContext* cx, JSObject* obj, jsval idval)
|
||||
StructType::LookupField(JSContext* cx, JSObject* obj, JSString *name)
|
||||
{
|
||||
JS_ASSERT(CType::IsCType(cx, obj));
|
||||
JS_ASSERT(CType::GetTypeCode(cx, obj) == TYPE_struct);
|
||||
|
||||
JSString* name = JSVAL_TO_STRING(idval);
|
||||
FieldInfoHash::Ptr ptr = GetFieldInfo(cx, obj)->lookup(name);
|
||||
if (ptr)
|
||||
return &ptr->value;
|
||||
|
@ -4332,7 +4387,7 @@ StructType::FieldGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
const FieldInfo* field = LookupField(cx, typeObj, idval);
|
||||
const FieldInfo* field = LookupField(cx, typeObj, JSID_TO_STRING(idval));
|
||||
if (!field)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -4354,7 +4409,7 @@ StructType::FieldSetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
const FieldInfo* field = LookupField(cx, typeObj, idval);
|
||||
const FieldInfo* field = LookupField(cx, typeObj, JSID_TO_STRING(idval));
|
||||
if (!field)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -4384,7 +4439,8 @@ StructType::AddressOfField(JSContext* cx, uintN argc, jsval *vp)
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
const FieldInfo* field = LookupField(cx, typeObj, JS_ARGV(cx, vp)[0]);
|
||||
const FieldInfo* field = LookupField(cx, typeObj,
|
||||
JSVAL_TO_STRING(JS_ARGV(cx, vp)[0]));
|
||||
if (!field)
|
||||
return JS_FALSE;
|
||||
|
||||
|
|
|
@ -448,7 +448,7 @@ namespace StructType {
|
|||
JSBool DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj);
|
||||
|
||||
const FieldInfoHash* GetFieldInfo(JSContext* cx, JSObject* obj);
|
||||
const FieldInfo* LookupField(JSContext* cx, JSObject* obj, jsval idval);
|
||||
const FieldInfo* LookupField(JSContext* cx, JSObject* obj, JSString *name);
|
||||
JSObject* BuildFieldsArray(JSContext* cx, JSObject* obj);
|
||||
ffi_type* BuildFFIType(JSContext* cx, JSObject* obj);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "tests.h"
|
||||
|
||||
static JSBool
|
||||
my_Equality(JSContext *cx, JSObject *obj, jsval, JSBool *bp)
|
||||
my_Equality(JSContext *cx, JSObject *obj, const jsval *, JSBool *bp)
|
||||
{
|
||||
*bp = JS_TRUE;
|
||||
return JS_TRUE;
|
||||
|
|
|
@ -29,7 +29,7 @@ BEGIN_TEST(testLookup_bug522590)
|
|||
END_TEST(testLookup_bug522590)
|
||||
|
||||
JSBool
|
||||
document_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp)
|
||||
document_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
|
||||
{
|
||||
// If id is "all", and we're not detecting, resolve document.all=true.
|
||||
jsvalRoot v(cx);
|
||||
|
|
|
@ -107,6 +107,10 @@ using namespace js;
|
|||
#define JS_ADDRESSOF_VA_LIST(ap) (&(ap))
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
JS_PUBLIC_DATA(jsid) JSID_VOID = { (size_t)JSID_VOID_TYPE };
|
||||
#endif
|
||||
|
||||
JS_PUBLIC_API(int64)
|
||||
JS_Now()
|
||||
{
|
||||
|
@ -2566,7 +2570,7 @@ JS_PUBLIC_API(JSBool)
|
|||
JS_IdToValue(JSContext *cx, jsid id, jsval *vp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
*vp = ID_TO_JSVAL(id);
|
||||
*vp = IdToJsval(id);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -2635,7 +2639,7 @@ JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv)
|
|||
JS_PUBLIC_API(JSBool)
|
||||
JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
{
|
||||
return js_HasInstance(cx, obj, Valueify(v), bp);
|
||||
return js_HasInstance(cx, obj, Valueify(&v), bp);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void *)
|
||||
|
@ -3157,7 +3161,7 @@ JS_DefineConstDoubles(JSContext *cx, JSObject *obj, JSConstDoubleSpec *cds)
|
|||
|
||||
CHECK_REQUEST(cx);
|
||||
for (ok = JS_TRUE; cds->name; cds++) {
|
||||
Value value(DoubleTag(cds->dval));
|
||||
Value value = DoubleTag(cds->dval);
|
||||
attrs = cds->flags;
|
||||
if (!attrs)
|
||||
attrs = JSPROP_READONLY | JSPROP_PERMANENT;
|
||||
|
@ -3695,7 +3699,7 @@ JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp)
|
|||
sprop = sprop->parent;
|
||||
|
||||
if (!sprop) {
|
||||
*idp = JSVAL_VOID;
|
||||
*idp = JSID_VOID;
|
||||
} else {
|
||||
iterobj->setPrivate(sprop->parent);
|
||||
*idp = sprop->id;
|
||||
|
@ -3705,7 +3709,7 @@ JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp)
|
|||
ida = (JSIdArray *) iterobj->getPrivate();
|
||||
JS_ASSERT(i <= ida->length);
|
||||
if (i == 0) {
|
||||
*idp = JSVAL_VOID;
|
||||
*idp = JSID_VOID;
|
||||
} else {
|
||||
*idp = ida->vector[--i];
|
||||
iterobj->setSlot(JSSLOT_ITER_INDEX, Int32Tag(i));
|
||||
|
@ -4755,6 +4759,12 @@ JS_NewStringCopyZ(JSContext *cx, const char *s)
|
|||
return str;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_StringHasBeenInterned(JSString *str)
|
||||
{
|
||||
return str->isAtomized();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSString *)
|
||||
JS_InternString(JSContext *cx, const char *s)
|
||||
{
|
||||
|
|
321
js/src/jsapi.h
321
js/src/jsapi.h
|
@ -52,15 +52,12 @@
|
|||
JS_BEGIN_EXTERN_C
|
||||
|
||||
/* Well-known JS values, initialized on startup. */
|
||||
#define JSVAL_NULL BUILD_JSVAL(JSVAL_MASK32_NULL, 0)
|
||||
#define JSVAL_ZERO BUILD_JSVAL(JSVAL_MASK32_INT32, 0)
|
||||
#define JSVAL_ONE BUILD_JSVAL(JSVAL_MASK32_INT32, 1)
|
||||
#define JSVAL_FALSE BUILD_JSVAL(JSVAL_MASK32_BOOLEAN, JS_FALSE)
|
||||
#define JSVAL_TRUE BUILD_JSVAL(JSVAL_MASK32_BOOLEAN, JS_TRUE)
|
||||
#define JSVAL_VOID BUILD_JSVAL(JSVAL_MASK32_UNDEFINED, 0)
|
||||
#define JSVAL_HOLE BUILD_JSVAL(JSVAL_MASK32_MAGIC, 0)
|
||||
|
||||
/* Predicates for type testing. */
|
||||
#define JSVAL_NULL BUILD_JSVAL(JSVAL_TAG_NULL, 0)
|
||||
#define JSVAL_ZERO BUILD_JSVAL(JSVAL_TAG_INT32, 0)
|
||||
#define JSVAL_ONE BUILD_JSVAL(JSVAL_TAG_INT32, 1)
|
||||
#define JSVAL_FALSE BUILD_JSVAL(JSVAL_TAG_BOOLEAN, JS_FALSE)
|
||||
#define JSVAL_TRUE BUILD_JSVAL(JSVAL_TAG_BOOLEAN, JS_TRUE)
|
||||
#define JSVAL_VOID BUILD_JSVAL(JSVAL_TAG_UNDEFINED, 0)
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_NULL(jsval v)
|
||||
|
@ -83,7 +80,7 @@ JSVAL_IS_INT(jsval v)
|
|||
{
|
||||
jsval_layout l;
|
||||
l.asBits = v;
|
||||
return l.s.u.mask32 == JSVAL_MASK32_INT32;
|
||||
return JSVAL_IS_INT32_IMPL(l);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE jsint
|
||||
|
@ -92,7 +89,7 @@ JSVAL_TO_INT(jsval v)
|
|||
jsval_layout l;
|
||||
JS_ASSERT(JSVAL_IS_INT(v));
|
||||
l.asBits = v;
|
||||
return l.s.payload.i32;
|
||||
return JSVAL_TO_INT32_IMPL(l);
|
||||
}
|
||||
|
||||
#define JSVAL_INT_BITS 32
|
||||
|
@ -149,7 +146,7 @@ JSVAL_IS_STRING(jsval v)
|
|||
{
|
||||
jsval_layout l;
|
||||
l.asBits = v;
|
||||
return l.s.u.mask32 == JSVAL_MASK32_STRING;
|
||||
return JSVAL_IS_STRING_IMPL(l);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSString *
|
||||
|
@ -187,12 +184,11 @@ JSVAL_TO_OBJECT(jsval v)
|
|||
static JS_ALWAYS_INLINE jsval
|
||||
OBJECT_TO_JSVAL(JSObject *obj)
|
||||
{
|
||||
JSValueMask32 mask;
|
||||
JSValueType type;
|
||||
if (!obj)
|
||||
return JSVAL_NULL;
|
||||
mask = JS_OBJ_IS_FUN_IMPL(obj) ? JSVAL_MASK32_FUNOBJ
|
||||
: JSVAL_MASK32_NONFUNOBJ;
|
||||
return OBJECT_TO_JSVAL_IMPL(mask, obj).asBits;
|
||||
type = JS_OBJ_IS_FUN_IMPL(obj) ? JSVAL_TYPE_FUNOBJ : JSVAL_TYPE_NONFUNOBJ;
|
||||
return OBJECT_TO_JSVAL_IMPL(type, obj).asBits;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
|
@ -200,7 +196,7 @@ JSVAL_IS_BOOLEAN(jsval v)
|
|||
{
|
||||
jsval_layout l;
|
||||
l.asBits = v;
|
||||
return l.s.u.mask32 == JSVAL_MASK32_BOOLEAN;
|
||||
return JSVAL_IS_BOOLEAN_IMPL(l);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
|
@ -209,7 +205,7 @@ JSVAL_TO_BOOLEAN(jsval v)
|
|||
jsval_layout l;
|
||||
JS_ASSERT(JSVAL_IS_BOOLEAN(v));
|
||||
l.asBits = v;
|
||||
return l.s.payload.boo;
|
||||
return JSVAL_TO_BOOLEAN_IMPL(l);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE jsval
|
||||
|
@ -268,12 +264,187 @@ JSVAL_IS_UNDERLYING_TYPE_OF_PRIVATE(jsval v)
|
|||
return JSVAL_IS_UNDERLYING_TYPE_OF_PRIVATE_IMPL(l);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
* A jsid is an identifier for a property or method of an object which is
|
||||
* either a 31-bit signed integer, interned string or object. If XML is
|
||||
* enabled, there is an additional singleton jsid value; see
|
||||
* JS_DEFAULT_XML_NAMESPACE_ID below. Finally, there is an additional jsid
|
||||
* value, JSID_VOID, which does not occur in JS scripts but may be used to
|
||||
* indicate the absence of a valid jsid.
|
||||
*
|
||||
* A jsid is not implicitly convertible to or from a jsval; JS_ValueToId or
|
||||
* JS_IdToValue must be used instead.
|
||||
*/
|
||||
|
||||
#define JSID_STRING_TYPE 0x0
|
||||
#define JSID_INT_TYPE 0x1
|
||||
#define JSID_OBJECT_TYPE 0x2
|
||||
#define JSID_VOID_TYPE 0x4
|
||||
#define JSID_DEFAULT_XML_NAMESPACE_TYPE 0x6
|
||||
#define JSID_TYPE_MASK 0x7
|
||||
|
||||
/*
|
||||
* Do not use canonical 'id' for jsid parameters since this is a magic word in
|
||||
* Objective-C++ which, apparently, wants to be able to #include jsapi.h.
|
||||
*/
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_MAY_BE_PRIVATE(jsval v)
|
||||
JSID_IS_STRING(jsid iden)
|
||||
{
|
||||
return JSVAL_IS_UNDERLYING_TYPE_OF_PRIVATE(v);
|
||||
return (JSID_BITS(iden) & JSID_TYPE_MASK) == 0;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSString *
|
||||
JSID_TO_STRING(jsid iden)
|
||||
{
|
||||
JS_ASSERT(JSID_IS_STRING(iden));
|
||||
return (JSString *)(JSID_BITS(iden));
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_StringHasBeenInterned(JSString *str);
|
||||
|
||||
static JS_ALWAYS_INLINE jsid
|
||||
INTERNED_STRING_TO_JSID(JSString *str)
|
||||
{
|
||||
jsid iden;
|
||||
JS_ASSERT(JS_StringHasBeenInterned(str));
|
||||
JS_ASSERT(((size_t)str & JSID_TYPE_MASK) == 0);
|
||||
JSID_BITS(iden) = (size_t)str;
|
||||
return iden;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSID_IS_INT(jsid iden)
|
||||
{
|
||||
return !!(JSID_BITS(iden) & JSID_INT_TYPE);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE int32
|
||||
JSID_TO_INT(jsid iden)
|
||||
{
|
||||
JS_ASSERT(JSID_IS_INT(iden));
|
||||
return ((int32)JSID_BITS(iden)) >> 1;
|
||||
}
|
||||
|
||||
#define JSID_INT_MIN (-(1 << 30))
|
||||
#define JSID_INT_MAX ((1 << 30) - 1)
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
INT_FITS_IN_JSID(int32 i)
|
||||
{
|
||||
return ((jsuint)(i) - (jsuint)JSID_INT_MIN <=
|
||||
(jsuint)(JSID_INT_MAX - JSID_INT_MIN));
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE jsid
|
||||
INT_TO_JSID(int32 i)
|
||||
{
|
||||
jsid iden;
|
||||
JS_ASSERT(INT_FITS_IN_JSID(i));
|
||||
JSID_BITS(iden) = ((i << 1) | JSID_INT_TYPE);
|
||||
return iden;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSID_IS_OBJECT(jsid iden)
|
||||
{
|
||||
return (JSID_BITS(iden) & JSID_TYPE_MASK) == JSID_OBJECT_TYPE;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSObject *
|
||||
JSID_TO_OBJECT(jsid iden)
|
||||
{
|
||||
JS_ASSERT(JSID_IS_OBJECT(iden));
|
||||
return (JSObject *)(JSID_BITS(iden) & ~(size_t)JSID_TYPE_MASK);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE jsid
|
||||
OBJECT_TO_JSID(JSObject *obj)
|
||||
{
|
||||
jsid iden;
|
||||
JS_ASSERT(obj != NULL);
|
||||
JS_ASSERT(((size_t)obj & JSID_TYPE_MASK) == 0);
|
||||
JSID_BITS(iden) = ((size_t)obj | JSID_OBJECT_TYPE);
|
||||
return iden;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSID_IS_GCTHING(jsid iden)
|
||||
{
|
||||
return JSID_IS_STRING(iden) || JSID_IS_OBJECT(iden);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE void *
|
||||
JSID_TO_GCTHING(jsid iden)
|
||||
{
|
||||
return (void *)(JSID_BITS(iden) & ~(size_t)JSID_TYPE_MASK);
|
||||
}
|
||||
|
||||
/*
|
||||
* The magic XML namespace id is not a valid jsid. Global object classes in
|
||||
* embeddings that enable JS_HAS_XML_SUPPORT (E4X) should handle this id.
|
||||
*/
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSID_IS_DEFAULT_XML_NAMESPACE(jsid iden)
|
||||
{
|
||||
JS_ASSERT_IF(((size_t)JSID_BITS(iden) & JSID_TYPE_MASK) == JSID_DEFAULT_XML_NAMESPACE_TYPE,
|
||||
JSID_BITS(iden) == JSID_DEFAULT_XML_NAMESPACE_TYPE);
|
||||
return ((size_t)JSID_BITS(iden) == JSID_DEFAULT_XML_NAMESPACE_TYPE);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE jsid
|
||||
JSID_DEFAULT_XML_NAMESPACE()
|
||||
{
|
||||
jsid iden;
|
||||
JSID_BITS(iden) = JSID_DEFAULT_XML_NAMESPACE_TYPE;
|
||||
return iden;
|
||||
}
|
||||
|
||||
/*
|
||||
* A void jsid is not a valid id and only arises as an exceptional API return
|
||||
* value, such as in JS_NextProperty.
|
||||
*/
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSID_IS_VOID(jsid iden)
|
||||
{
|
||||
JS_ASSERT_IF(((size_t)JSID_BITS(iden) & JSID_TYPE_MASK) == JSID_VOID_TYPE,
|
||||
JSID_BITS(iden) == JSID_VOID_TYPE);
|
||||
return ((size_t)JSID_BITS(iden) == JSID_VOID_TYPE);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
extern JS_PUBLIC_DATA(jsid) JSID_VOID;
|
||||
#else
|
||||
# define JSID_VOID ((jsid)JSID_VOID_TYPE)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG) && defined(__cplusplus)
|
||||
extern "C++" {
|
||||
/*
|
||||
* Internally we can use C++ to allow jsids, which are structs in debug builds,
|
||||
* to be compared with ==.
|
||||
*/
|
||||
static JS_ALWAYS_INLINE bool
|
||||
operator==(jsid lhs, jsid rhs)
|
||||
{
|
||||
return JSID_BITS(lhs) == JSID_BITS(rhs);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE bool
|
||||
operator!=(jsid lhs, jsid rhs)
|
||||
{
|
||||
return JSID_BITS(lhs) != JSID_BITS(rhs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/* Lock and unlock the GC thing held by a jsval. */
|
||||
#define JSVAL_LOCK(cx,v) (JSVAL_IS_GCTHING(v) \
|
||||
? JS_LockGCThing(cx, JSVAL_TO_GCTHING(v)) \
|
||||
|
@ -1624,13 +1795,6 @@ JS_ValueToId(JSContext *cx, jsval v, jsid *idp);
|
|||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_IdToValue(JSContext *cx, jsid id, jsval *vp);
|
||||
|
||||
/*
|
||||
* The magic XML namespace id is int-tagged, but not a valid integer jsval.
|
||||
* Global object classes in embeddings that enable JS_HAS_XML_SUPPORT (E4X)
|
||||
* should handle this id specially before converting id via JSVAL_TO_INT.
|
||||
*/
|
||||
#define JS_DEFAULT_XML_NAMESPACE_ID ((jsid) JSVAL_VOID)
|
||||
|
||||
/*
|
||||
* JSNewResolveOp flag bits.
|
||||
*/
|
||||
|
@ -2088,7 +2252,7 @@ JS_NewPropertyIterator(JSContext *cx, JSObject *obj);
|
|||
|
||||
/*
|
||||
* Return true on success with *idp containing the id of the next enumerable
|
||||
* property to visit using iterobj, or JSVAL_VOID if there is no such property
|
||||
* property to visit using iterobj, or JSID_IS_VOID if there is no such property
|
||||
* left to visit. Return false on error.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
|
@ -3036,8 +3200,11 @@ class Value
|
|||
* break this encapsulation should be listed as friends below. Also see
|
||||
* uses of public jsval members in jsapi.h/jspubtd.h.
|
||||
*/
|
||||
friend class PrimitiveValue;
|
||||
#ifdef JS_TRACER
|
||||
friend jsdouble UnboxDoubleHelper(uint32 mask, uint32 payload);
|
||||
friend void NonDoubleNativeToValue(JSValueType type, double *slot, Value *vp);
|
||||
friend void NonNumberValueToSlot(const Value &v, JSValueType type, double *slot);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
/* Type masks */
|
||||
|
@ -3045,13 +3212,10 @@ class Value
|
|||
template <int I> class T {};
|
||||
|
||||
void staticAssertions() {
|
||||
JS_STATIC_ASSERT(sizeof(JSValueMask16) == 2);
|
||||
JS_STATIC_ASSERT(JSVAL_NANBOX_PATTERN == 0xFFFF);
|
||||
JS_STATIC_ASSERT(sizeof(JSValueMask32) == 4);
|
||||
JS_STATIC_ASSERT(JSVAL_MASK32_CLEAR == 0xFFFF0000);
|
||||
JS_STATIC_ASSERT(sizeof(JSValueType) == 1);
|
||||
JS_STATIC_ASSERT(sizeof(JSValueTag) == 4);
|
||||
JS_STATIC_ASSERT(sizeof(JSBool) == 4);
|
||||
JS_STATIC_ASSERT(sizeof(JSWhyMagic) <= 4);
|
||||
JS_STATIC_ASSERT(sizeof(((jsval_layout *)0)->s.payload) == 4);
|
||||
JS_STATIC_ASSERT(sizeof(jsval) == 8);
|
||||
}
|
||||
|
||||
|
@ -3118,12 +3282,12 @@ class Value
|
|||
|
||||
void setFunObj(JSObject &arg) {
|
||||
JS_ASSERT(JS_OBJ_IS_FUN_IMPL(&arg));
|
||||
data = OBJECT_TO_JSVAL_IMPL(JSVAL_MASK32_FUNOBJ, &arg);
|
||||
data = OBJECT_TO_JSVAL_IMPL(JSVAL_TYPE_FUNOBJ, &arg);
|
||||
}
|
||||
|
||||
void setNonFunObj(JSObject &arg) {
|
||||
JS_ASSERT(!JS_OBJ_IS_FUN_IMPL(&arg));
|
||||
data = OBJECT_TO_JSVAL_IMPL(JSVAL_MASK32_NONFUNOBJ, &arg);
|
||||
data = OBJECT_TO_JSVAL_IMPL(JSVAL_TYPE_NONFUNOBJ, &arg);
|
||||
}
|
||||
|
||||
void setBoolean(bool b) {
|
||||
|
@ -3147,27 +3311,27 @@ class Value
|
|||
|
||||
void setFunObjOrNull(JSObject *arg) {
|
||||
JS_ASSERT_IF(arg, JS_OBJ_IS_FUN_IMPL(arg));
|
||||
JSValueMask32 mask = arg ? JSVAL_MASK32_FUNOBJ : JSVAL_MASK32_NULL;
|
||||
data = OBJECT_TO_JSVAL_IMPL(mask, arg);
|
||||
JSValueType type = arg ? JSVAL_TYPE_FUNOBJ : JSVAL_TYPE_NULL;
|
||||
data = OBJECT_TO_JSVAL_IMPL(type, arg);
|
||||
}
|
||||
|
||||
void setNonFunObjOrNull(JSObject *arg) {
|
||||
JS_ASSERT_IF(arg, !JS_OBJ_IS_FUN_IMPL(arg));
|
||||
JSValueMask32 mask = arg ? JSVAL_MASK32_NONFUNOBJ : JSVAL_MASK32_NULL;
|
||||
data = OBJECT_TO_JSVAL_IMPL(mask, arg);
|
||||
JSValueType type = arg ? JSVAL_TYPE_NONFUNOBJ : JSVAL_TYPE_NULL;
|
||||
data = OBJECT_TO_JSVAL_IMPL(type, arg);
|
||||
}
|
||||
|
||||
inline void setObject(JSObject &arg) {
|
||||
JSValueMask32 mask = JS_OBJ_IS_FUN_IMPL(&arg) ? JSVAL_MASK32_FUNOBJ
|
||||
: JSVAL_MASK32_NONFUNOBJ;
|
||||
data = OBJECT_TO_JSVAL_IMPL(mask, &arg);
|
||||
JSValueType type = JS_OBJ_IS_FUN_IMPL(&arg) ? JSVAL_TYPE_FUNOBJ
|
||||
: JSVAL_TYPE_NONFUNOBJ;
|
||||
data = OBJECT_TO_JSVAL_IMPL(type, &arg);
|
||||
}
|
||||
|
||||
inline void setObjectOrNull(JSObject *arg) {
|
||||
JSValueMask32 mask = arg ? JS_OBJ_IS_FUN_IMPL(arg) ? JSVAL_MASK32_FUNOBJ
|
||||
: JSVAL_MASK32_NONFUNOBJ
|
||||
: JSVAL_MASK32_NULL;
|
||||
data = OBJECT_TO_JSVAL_IMPL(mask, arg);
|
||||
JSValueType type = arg ? JS_OBJ_IS_FUN_IMPL(arg) ? JSVAL_TYPE_FUNOBJ
|
||||
: JSVAL_TYPE_NONFUNOBJ
|
||||
: JSVAL_TYPE_NULL;
|
||||
data = OBJECT_TO_JSVAL_IMPL(type, arg);
|
||||
}
|
||||
|
||||
inline void setObjectOrUndefined(JSObject *arg) {
|
||||
|
@ -3188,11 +3352,11 @@ class Value
|
|||
}
|
||||
|
||||
bool isNullOrUndefined() const {
|
||||
return JSVAL_IS_SINGLETON_IMPL(data);
|
||||
return isNull() || isUndefined();
|
||||
}
|
||||
|
||||
bool isInt32() const {
|
||||
return data.s.u.mask32 == JSVAL_MASK32_INT32;
|
||||
return JSVAL_IS_INT32_IMPL(data);
|
||||
}
|
||||
|
||||
bool isInt32(int32 i32) const {
|
||||
|
@ -3208,15 +3372,15 @@ class Value
|
|||
}
|
||||
|
||||
bool isString() const {
|
||||
return data.s.u.mask32 == JSVAL_MASK32_STRING;
|
||||
return JSVAL_IS_STRING_IMPL(data);
|
||||
}
|
||||
|
||||
bool isNonFunObj() const {
|
||||
return data.s.u.mask32 == JSVAL_MASK32_NONFUNOBJ;
|
||||
return JSVAL_IS_NONFUNOBJ_IMPL(data);
|
||||
}
|
||||
|
||||
bool isFunObj() const {
|
||||
return data.s.u.mask32 == JSVAL_MASK32_FUNOBJ;
|
||||
return JSVAL_IS_FUNOBJ_IMPL(data);
|
||||
}
|
||||
|
||||
bool isObject() const {
|
||||
|
@ -3236,7 +3400,7 @@ class Value
|
|||
}
|
||||
|
||||
bool isBoolean() const {
|
||||
return data.s.u.mask32 == JSVAL_MASK32_BOOLEAN;
|
||||
return JSVAL_IS_BOOLEAN_IMPL(data);
|
||||
}
|
||||
|
||||
bool isTrue() const {
|
||||
|
@ -3248,16 +3412,14 @@ class Value
|
|||
}
|
||||
|
||||
bool isMagic() const {
|
||||
return data.s.u.mask32 == JSVAL_MASK32_MAGIC;
|
||||
return JSVAL_IS_MAGIC_IMPL(data);
|
||||
}
|
||||
|
||||
bool isMagic(JSWhyMagic why) const {
|
||||
JS_ASSERT_IF(isMagic(), data.s.payload.why == why);
|
||||
return isMagic();
|
||||
return JSVAL_IS_MAGIC_IMPL(data);
|
||||
}
|
||||
|
||||
bool isIntDouble() const;
|
||||
|
||||
int32 traceKind() const {
|
||||
JS_ASSERT(isGCThing());
|
||||
return JSVAL_TRACE_KIND_IMPL(data);
|
||||
|
@ -3284,19 +3446,11 @@ class Value
|
|||
return JSVAL_SAME_PRIMITIVE_TYPE_OR_BOTH_OBJECTS_IMPL(lhs.data, rhs.data);
|
||||
}
|
||||
|
||||
friend bool BothInt32(const Value &lhs, const Value &rhs) {
|
||||
return JSVAL_BOTH_INT32_IMPL(lhs.data, rhs.data);
|
||||
}
|
||||
|
||||
friend bool BothString(const Value &lhs, const Value &rhs) {
|
||||
return JSVAL_BOTH_STRING_IMPL(lhs.data, rhs.data);
|
||||
}
|
||||
|
||||
/* Extract a Value's payload */
|
||||
|
||||
int32 asInt32() const {
|
||||
JS_ASSERT(isInt32());
|
||||
return data.s.payload.i32;
|
||||
return JSVAL_TO_INT32_IMPL(data);
|
||||
}
|
||||
|
||||
double asDouble() const {
|
||||
|
@ -3342,7 +3496,7 @@ class Value
|
|||
|
||||
bool asBoolean() const {
|
||||
JS_ASSERT(isBoolean());
|
||||
return data.s.payload.boo;
|
||||
return JSVAL_TO_BOOLEAN_IMPL(data);
|
||||
}
|
||||
|
||||
uint32 asRawUint32() const {
|
||||
|
@ -3354,18 +3508,13 @@ class Value
|
|||
return data.asBits;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
char typeTag() const {
|
||||
if (isInt32()) return 'I';
|
||||
if (isDouble()) return 'D';
|
||||
if (isString()) return 'S';
|
||||
if (isFunObj()) return 'F';
|
||||
if (isNonFunObj()) return 'O';
|
||||
if (isBoolean()) return 'B';
|
||||
if (isNull()) return 'N';
|
||||
if (isUndefined()) return 'U';
|
||||
if (isMagic()) return 'H';
|
||||
return '?';
|
||||
JSValueType extractNonDoubleType() const {
|
||||
return JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(data);
|
||||
}
|
||||
|
||||
#if JS_BITS_PER_WORD == 32
|
||||
JSValueTag extractNonDoubleTag() const {
|
||||
return JSVAL_EXTRACT_NON_DOUBLE_TAG_IMPL(data);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -3395,12 +3544,12 @@ class Value
|
|||
}
|
||||
|
||||
void setPrivate(void *ptr) {
|
||||
data = PRIVATE_PTR_TO_JSVAL_IMPL(ptr);
|
||||
data = PRIVATE_PTR_TO_JSVAL_IMPL(ptr);
|
||||
}
|
||||
|
||||
void *asPrivate() const {
|
||||
JS_ASSERT(JSVAL_IS_UNDERLYING_TYPE_OF_PRIVATE_IMPL(data));
|
||||
return JSVAL_TO_PRIVATE_PTR_IMPL(data);
|
||||
JS_ASSERT(JSVAL_IS_UNDERLYING_TYPE_OF_PRIVATE_IMPL(data));
|
||||
return JSVAL_TO_PRIVATE_PTR_IMPL(data);
|
||||
}
|
||||
|
||||
void setPrivateUint32(uint32 ui) {
|
||||
|
@ -3408,13 +3557,13 @@ class Value
|
|||
}
|
||||
|
||||
uint32 asPrivateUint32() const {
|
||||
JS_ASSERT(JSVAL_IS_UNDERLYING_TYPE_OF_PRIVATE_IMPL(data));
|
||||
return JSVAL_TO_PRIVATE_UINT32_IMPL(data);
|
||||
JS_ASSERT(JSVAL_IS_UNDERLYING_TYPE_OF_PRIVATE_IMPL(data));
|
||||
return JSVAL_TO_PRIVATE_UINT32_IMPL(data);
|
||||
}
|
||||
|
||||
uint32 &asPrivateUint32Ref() {
|
||||
JS_ASSERT(isDouble());
|
||||
return data.s.payload.u32;
|
||||
JS_ASSERT(isDouble());
|
||||
return data.s.payload.u32;
|
||||
}
|
||||
|
||||
/* Tracing support API.
|
||||
|
|
|
@ -161,22 +161,8 @@ INDEX_TOO_BIG(jsuint index)
|
|||
* an atomized string.
|
||||
*/
|
||||
JSBool
|
||||
js_IdIsIndex(jsid id, jsuint *indexp)
|
||||
js_StringIsIndex(JSString *str, jsuint *indexp)
|
||||
{
|
||||
if (JSID_IS_INT(id)) {
|
||||
jsint i;
|
||||
i = JSID_TO_INT(id);
|
||||
if (i < 0)
|
||||
return JS_FALSE;
|
||||
*indexp = (jsuint)i;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/* NB: id should be a string, but jsxml.c may call us with an object id. */
|
||||
if (!JSID_IS_ATOM(id))
|
||||
return JS_FALSE;
|
||||
|
||||
JSString *str = JSID_TO_STRING(id);
|
||||
jschar *cp = str->chars();
|
||||
if (JS7_ISDEC(*cp) && str->length() < sizeof(MAXSTR)) {
|
||||
jsuint index = JS7_UNDEC(*cp++);
|
||||
|
@ -258,22 +244,12 @@ js_GetLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp)
|
|||
return ValueToECMAUint32(cx, tvr.value(), (uint32_t *)lengthp);
|
||||
}
|
||||
|
||||
static inline void
|
||||
IndexToValue(JSContext *cx, jsdouble index, Value *vp)
|
||||
{
|
||||
int32_t i;
|
||||
if (JSDOUBLE_IS_INT32(index, i))
|
||||
vp->setInt32(i);
|
||||
else
|
||||
vp->setDouble(index);
|
||||
}
|
||||
|
||||
JSBool JS_FASTCALL
|
||||
js_IndexToId(JSContext *cx, jsuint index, jsid *idp)
|
||||
{
|
||||
JSString *str;
|
||||
|
||||
if (index <= JSVAL_INT_MAX) {
|
||||
if (index <= JSID_INT_MAX) {
|
||||
*idp = INT_TO_JSID(index);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -292,7 +268,7 @@ BigIndexToId(JSContext *cx, JSObject *obj, jsuint index, JSBool createAtom,
|
|||
JSAtom *atom;
|
||||
JS_STATIC_ASSERT((jsuint)-1 == 4294967295U);
|
||||
|
||||
JS_ASSERT(index > JSVAL_INT_MAX);
|
||||
JS_ASSERT(index > JSID_INT_MAX);
|
||||
|
||||
start = JS_ARRAY_END(buf);
|
||||
do {
|
||||
|
@ -315,7 +291,7 @@ BigIndexToId(JSContext *cx, JSObject *obj, jsuint index, JSBool createAtom,
|
|||
clasp == &js_ObjectClass)) {
|
||||
atom = js_GetExistingStringAtom(cx, start, JS_ARRAY_END(buf) - start);
|
||||
if (!atom) {
|
||||
*idp = JSVAL_VOID;
|
||||
*idp = JSID_VOID;
|
||||
return JS_TRUE;
|
||||
}
|
||||
} else {
|
||||
|
@ -339,7 +315,9 @@ JSObject::resizeDenseArrayElements(JSContext *cx, uint32 oldcap, uint32 newcap,
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (newcap > MAX_DSLOTS_LENGTH) {
|
||||
/* Silence warning */
|
||||
size_t newcapBig = newcap;
|
||||
if (newcapBig > MAX_DSLOTS_LENGTH) {
|
||||
js_ReportAllocationOverflow(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -427,7 +405,7 @@ static bool
|
|||
IndexToId(JSContext* cx, JSObject* obj, jsdouble index, JSBool* hole, jsid* idp,
|
||||
JSBool createAtom = JS_FALSE)
|
||||
{
|
||||
if (index <= JSVAL_INT_MAX) {
|
||||
if (index <= JSID_INT_MAX) {
|
||||
*idp = INT_TO_JSID(int(index));
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -435,7 +413,7 @@ IndexToId(JSContext* cx, JSObject* obj, jsdouble index, JSBool* hole, jsid* idp,
|
|||
if (index <= jsuint(-1)) {
|
||||
if (!BigIndexToId(cx, obj, jsuint(index), createAtom, idp))
|
||||
return JS_FALSE;
|
||||
if (hole && JSVAL_IS_VOID(*idp))
|
||||
if (hole && JSID_IS_VOID(*idp))
|
||||
*hole = JS_TRUE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -519,7 +497,7 @@ SetArrayElement(JSContext *cx, JSObject *obj, jsdouble index, const Value &v)
|
|||
|
||||
if (!IndexToId(cx, obj, index, NULL, idr.addr(), JS_TRUE))
|
||||
return JS_FALSE;
|
||||
JS_ASSERT(!JSVAL_IS_VOID(idr.id()));
|
||||
JS_ASSERT(!JSID_IS_VOID(idr.id()));
|
||||
|
||||
Value tmp = v;
|
||||
return obj->setProperty(cx, idr.id(), &tmp);
|
||||
|
@ -546,7 +524,7 @@ DeleteArrayElement(JSContext *cx, JSObject *obj, jsdouble index)
|
|||
|
||||
if (!IndexToId(cx, obj, index, NULL, idr.addr()))
|
||||
return JS_FALSE;
|
||||
if (JSVAL_IS_VOID(idr.id()))
|
||||
if (JSID_IS_VOID(idr.id()))
|
||||
return JS_TRUE;
|
||||
|
||||
Value junk;
|
||||
|
@ -574,7 +552,7 @@ js_SetLengthProperty(JSContext *cx, JSObject *obj, jsdouble length)
|
|||
Value v;
|
||||
jsid id;
|
||||
|
||||
IndexToValue(cx, length, &v);
|
||||
v.setNumber(length);
|
||||
id = ATOM_TO_JSID(cx->runtime->atomState.lengthAtom);
|
||||
return obj->setProperty(cx, id, &v);
|
||||
}
|
||||
|
@ -619,7 +597,7 @@ array_length_getter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
{
|
||||
do {
|
||||
if (obj->isArray()) {
|
||||
IndexToValue(cx, obj->getArrayLength(), vp);
|
||||
vp->setNumber(obj->getArrayLength());
|
||||
return JS_TRUE;
|
||||
}
|
||||
} while ((obj = obj->getProto()) != NULL);
|
||||
|
@ -646,7 +624,7 @@ array_length_setter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
if (oldlen == newlen)
|
||||
return true;
|
||||
|
||||
IndexToValue(cx, newlen, vp);
|
||||
vp->setNumber(newlen);
|
||||
if (oldlen < newlen) {
|
||||
if (obj->isDenseArray())
|
||||
obj->setDenseArrayLength(newlen);
|
||||
|
@ -687,7 +665,7 @@ array_length_setter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
for (;;) {
|
||||
if (!JS_CHECK_OPERATION_LIMIT(cx) || !JS_NextProperty(cx, iter, &id))
|
||||
return false;
|
||||
if (JSVAL_IS_VOID(id))
|
||||
if (JSID_IS_VOID(id))
|
||||
break;
|
||||
if (js_IdIsIndex(id, &index) && index - newlen < gap &&
|
||||
!obj->deleteProperty(cx, id, &junk)) {
|
||||
|
@ -710,7 +688,7 @@ IsDenseArrayId(JSContext *cx, JSObject *obj, jsid id)
|
|||
JS_ASSERT(obj->isDenseArray());
|
||||
|
||||
uint32 i;
|
||||
return id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom) ||
|
||||
return JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom) ||
|
||||
(js_IdIsIndex(id, &i) &&
|
||||
obj->getArrayLength() != 0 &&
|
||||
i < obj->getDenseArrayCapacity() &&
|
||||
|
@ -746,8 +724,8 @@ js_GetDenseArrayElementValue(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
|
||||
uint32 i;
|
||||
if (!js_IdIsIndex(id, &i)) {
|
||||
JS_ASSERT(id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom));
|
||||
IndexToValue(cx, obj->getArrayLength(), vp);
|
||||
JS_ASSERT(JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom));
|
||||
vp->setNumber(obj->getArrayLength());
|
||||
return JS_TRUE;
|
||||
}
|
||||
*vp = obj->getDenseArrayElement(i);
|
||||
|
@ -759,12 +737,12 @@ array_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
{
|
||||
uint32 i;
|
||||
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
IndexToValue(cx, obj->getArrayLength(), vp);
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
vp->setNumber(obj->getArrayLength());
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.protoAtom)) {
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.protoAtom)) {
|
||||
*vp = obj->getProtoValue();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -854,7 +832,7 @@ array_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
{
|
||||
uint32 i;
|
||||
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom))
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
|
||||
return array_length_setter(cx, obj, id, vp);
|
||||
|
||||
if (!obj->isDenseArray())
|
||||
|
@ -974,7 +952,7 @@ array_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *value,
|
|||
uint32 i = 0; // init to shut GCC up
|
||||
JSBool isIndex;
|
||||
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom))
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
|
||||
return JS_TRUE;
|
||||
|
||||
isIndex = js_IdIsIndex(id, &i);
|
||||
|
@ -991,7 +969,7 @@ array_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *value,
|
|||
static JSBool
|
||||
array_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
|
||||
{
|
||||
*attrsp = id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)
|
||||
*attrsp = JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)
|
||||
? JSPROP_PERMANENT : JSPROP_ENUMERATE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -1012,7 +990,7 @@ array_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval)
|
|||
if (!obj->isDenseArray())
|
||||
return js_DeleteProperty(cx, obj, id, rval);
|
||||
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
rval->setBoolean(false);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -1470,7 +1448,7 @@ InitArrayElements(JSContext *cx, JSObject *obj, jsuint start, jsuint count, Valu
|
|||
if (newlen > obj->getArrayLength())
|
||||
obj->setDenseArrayLength(newlen);
|
||||
|
||||
JS_ASSERT(count < size_t(-1) / sizeof(Value));
|
||||
JS_ASSERT(count < uint32(-1) / sizeof(Value));
|
||||
if (targetType == TargetElementsMayContainValues) {
|
||||
jsuint valueCount = 0;
|
||||
for (jsuint i = 0; i < count; i++) {
|
||||
|
@ -1513,7 +1491,7 @@ InitArrayElements(JSContext *cx, JSObject *obj, jsuint start, jsuint count, Valu
|
|||
JS_ASSERT(start == MAXINDEX);
|
||||
AutoValueRooter tvr(cx);
|
||||
AutoIdRooter idr(cx);
|
||||
Value idval(DoubleTag(MAXINDEX));
|
||||
Value idval = DoubleTag(MAXINDEX);
|
||||
do {
|
||||
*tvr.addr() = *vector++;
|
||||
if (!js_ValueToStringId(cx, idval, idr.addr()) ||
|
||||
|
@ -2123,7 +2101,7 @@ array_push_slowly(JSContext *cx, JSObject *obj, uintN argc, Value *argv, Value *
|
|||
|
||||
/* Per ECMA-262, return the new array length. */
|
||||
jsdouble newlength = length + jsdouble(argc);
|
||||
IndexToValue(cx, newlength, rval);
|
||||
rval->setNumber(newlength);
|
||||
return js_SetLengthProperty(cx, obj, newlength);
|
||||
}
|
||||
|
||||
|
@ -2145,7 +2123,7 @@ array_push1_dense(JSContext* cx, JSObject* obj, const Value &v, Value *rval)
|
|||
JS_ASSERT(obj->getDenseArrayElement(length).isMagic(JS_ARRAY_HOLE));
|
||||
obj->incDenseArrayCountBy(1);
|
||||
obj->setDenseArrayElement(length, v);
|
||||
IndexToValue(cx, obj->getArrayLength(), rval);
|
||||
rval->setNumber(obj->getArrayLength());
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -2341,7 +2319,7 @@ array_unshift(JSContext *cx, uintN argc, Value *vp)
|
|||
}
|
||||
|
||||
/* Follow Perl by returning the new array length. */
|
||||
IndexToValue(cx, newlen, vp);
|
||||
vp->setNumber(newlen);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,11 +45,49 @@
|
|||
#include "jsprvtd.h"
|
||||
#include "jspubtd.h"
|
||||
#include "jsobj.h"
|
||||
#include "jsatom.h"
|
||||
|
||||
#define ARRAY_CAPACITY_MIN 7
|
||||
|
||||
extern JSBool
|
||||
js_IdIsIndex(jsid id, jsuint *indexp);
|
||||
js_StringIsIndex(JSString *str, jsuint *indexp);
|
||||
|
||||
inline JSBool
|
||||
js_IdIsIndex(jsid id, jsuint *indexp)
|
||||
{
|
||||
if (JSID_IS_INT(id)) {
|
||||
jsint i;
|
||||
i = JSID_TO_INT(id);
|
||||
if (i < 0)
|
||||
return JS_FALSE;
|
||||
*indexp = (jsuint)i;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JS_UNLIKELY(!JSID_IS_ATOM(id)))
|
||||
return JS_FALSE;
|
||||
|
||||
return js_StringIsIndex(JSID_TO_STRING(id), indexp);
|
||||
}
|
||||
|
||||
/* XML really wants to pretend jsvals are jsids. */
|
||||
inline JSBool
|
||||
js_IdValIsIndex(jsval id, jsuint *indexp)
|
||||
{
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
jsint i;
|
||||
i = JSVAL_TO_INT(id);
|
||||
if (i < 0)
|
||||
return JS_FALSE;
|
||||
*indexp = (jsuint)i;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (!JSVAL_IS_STRING(id))
|
||||
return JS_FALSE;
|
||||
|
||||
return js_StringIsIndex(JSVAL_TO_STRING(id), indexp);
|
||||
}
|
||||
|
||||
extern js::Class js_ArrayClass, js_SlowArrayClass;
|
||||
|
||||
|
|
|
@ -1147,7 +1147,7 @@ js_InternNonIntElementIdSlow(JSContext *cx, JSObject *obj, const Value &idval,
|
|||
|
||||
if (!js_IsFunctionQName(cx, &idval.asObject(), idp))
|
||||
return JS_FALSE;
|
||||
if (*idp != 0)
|
||||
if (!JSID_IS_VOID(*idp))
|
||||
return true;
|
||||
|
||||
return js_ValueToStringId(cx, idval, idp);
|
||||
|
@ -1167,8 +1167,8 @@ js_InternNonIntElementIdSlow(JSContext *cx, JSObject *obj, const Value &idval,
|
|||
|
||||
if (!js_IsFunctionQName(cx, &idval.asObject(), idp))
|
||||
return JS_FALSE;
|
||||
if (*idp != 0) {
|
||||
*vp = ID_TO_VALUE(*idp);
|
||||
if (!JSID_IS_VOID(*idp)) {
|
||||
*vp = IdToValue(*idp);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,62 @@
|
|||
#define ATOM_TO_STRING(atom) ((JSString *)atom)
|
||||
#define ATOM_TO_JSVAL(atom) STRING_TO_JSVAL(ATOM_TO_STRING(atom))
|
||||
|
||||
/* Engine-internal extensions of jsid */
|
||||
|
||||
static JS_ALWAYS_INLINE jsid
|
||||
JSID_FROM_BITS(size_t bits)
|
||||
{
|
||||
jsid id;
|
||||
JSID_BITS(id) = bits;
|
||||
return id;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE jsid
|
||||
ATOM_TO_JSID(JSAtom *atom)
|
||||
{
|
||||
JS_ASSERT(((size_t)atom & 0x7) == 0);
|
||||
return JSID_FROM_BITS((size_t)atom);
|
||||
}
|
||||
|
||||
/* All strings stored in jsids are atomized. */
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSID_IS_ATOM(jsid id)
|
||||
{
|
||||
return JSID_IS_STRING(id);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSID_IS_ATOM(jsid id, JSAtom *atom)
|
||||
{
|
||||
return JSID_BITS(id) == JSID_BITS(ATOM_TO_JSID(atom));
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSAtom *
|
||||
JSID_TO_ATOM(jsid id)
|
||||
{
|
||||
return (JSAtom *)JSID_TO_STRING(id);
|
||||
}
|
||||
|
||||
namespace js {
|
||||
|
||||
static JS_ALWAYS_INLINE Value
|
||||
IdToValue(jsid id)
|
||||
{
|
||||
if (JSID_IS_STRING(id))
|
||||
return StringTag(JSID_TO_STRING(id));
|
||||
if (JS_LIKELY(JSID_IS_INT(id)))
|
||||
return Int32Tag(JSID_TO_INT(id));
|
||||
return ObjectTag(*JSID_TO_OBJECT(id));
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE jsval
|
||||
IdToJsval(jsid id)
|
||||
{
|
||||
return Jsvalify(IdToValue(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if JS_BYTES_PER_WORD == 4
|
||||
# define ATOM_HASH(atom) ((JSHashNumber)(atom) >> 2)
|
||||
#elif JS_BYTES_PER_WORD == 8
|
||||
|
|
|
@ -92,7 +92,7 @@ inline bool
|
|||
js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval,
|
||||
jsid *idp)
|
||||
{
|
||||
JS_ASSERT(!idval.isInt32());
|
||||
JS_ASSERT(!idval.isInt32() || !INT_FITS_IN_JSID(idval.asInt32()));
|
||||
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
extern bool js_InternNonIntElementIdSlow(JSContext *, JSObject *,
|
||||
|
@ -108,7 +108,7 @@ inline bool
|
|||
js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval,
|
||||
jsid *idp, js::Value *vp)
|
||||
{
|
||||
JS_ASSERT(!idval.isInt32());
|
||||
JS_ASSERT(!idval.isInt32() || !INT_FITS_IN_JSID(idval.asInt32()));
|
||||
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
extern bool js_InternNonIntElementIdSlow(JSContext *, JSObject *,
|
||||
|
@ -127,4 +127,19 @@ js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval,
|
|||
return false;
|
||||
}
|
||||
|
||||
inline bool
|
||||
js_Int32ToId(JSContext* cx, int32 index, jsid* id)
|
||||
{
|
||||
if (INT_FITS_IN_JSID(index)) {
|
||||
*id = INT_TO_JSID(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
JSString* str = js_NumberToString(cx, index);
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
return js_ValueToStringId(cx, js::StringTag(str), id);
|
||||
}
|
||||
|
||||
#endif /* jsatominlines_h___ */
|
||||
|
|
|
@ -106,13 +106,13 @@ JS_DEFINE_CALLINFO_2(extern, INT32, js_imod, INT32, INT32, 1, ACC_NONE)
|
|||
namespace js {
|
||||
|
||||
jsdouble JS_ALWAYS_INLINE
|
||||
UnboxDoubleHelper(uint32 mask, uint32 payload)
|
||||
UnboxDoubleHelper(uint32 tag, uint32 payload)
|
||||
{
|
||||
if (mask == JSVAL_MASK32_INT32) {
|
||||
if (tag == JSVAL_TAG_INT32) {
|
||||
return int32(payload);
|
||||
} else {
|
||||
Value v;
|
||||
v.data.s.u.mask32 = mask;
|
||||
v.data.s.tag = (JSValueTag)tag;
|
||||
v.data.s.payload.u32 = payload;
|
||||
return v.asDouble();
|
||||
}
|
||||
|
@ -121,9 +121,9 @@ UnboxDoubleHelper(uint32 mask, uint32 payload)
|
|||
}
|
||||
|
||||
jsdouble FASTCALL
|
||||
js_UnboxDouble(uint32 mask, uint32 payload)
|
||||
js_UnboxDouble(uint32 tag, uint32 payload)
|
||||
{
|
||||
return UnboxDoubleHelper(mask, payload);
|
||||
return UnboxDoubleHelper(tag, payload);
|
||||
}
|
||||
JS_DEFINE_CALLINFO_2(extern, DOUBLE, js_UnboxDouble, UINT32, UINT32, 1, ACC_NONE)
|
||||
|
||||
|
@ -275,18 +275,22 @@ HasProperty(JSContext* cx, JSObject* obj, jsid id)
|
|||
JSBool FASTCALL
|
||||
js_HasNamedProperty(JSContext* cx, JSObject* obj, JSString* idstr)
|
||||
{
|
||||
jsid id;
|
||||
if (!js_ValueToStringId(cx, StringTag(idstr), &id))
|
||||
JSAtom *atom = js_AtomizeString(cx, idstr, 0);
|
||||
if (!atom)
|
||||
return JS_NEITHER;
|
||||
|
||||
return HasProperty(cx, obj, id);
|
||||
return HasProperty(cx, obj, ATOM_TO_JSID(atom));
|
||||
}
|
||||
JS_DEFINE_CALLINFO_3(extern, BOOL, js_HasNamedProperty, CONTEXT, OBJECT, STRING, 0, ACC_STORE_ANY)
|
||||
|
||||
JSBool FASTCALL
|
||||
js_HasNamedPropertyInt32(JSContext* cx, JSObject* obj, int32 index)
|
||||
{
|
||||
return HasProperty(cx, obj, INT_TO_JSID(index));
|
||||
jsid id;
|
||||
if (!js_Int32ToId(cx, index, &id))
|
||||
return JS_NEITHER;
|
||||
|
||||
return HasProperty(cx, obj, id);
|
||||
}
|
||||
JS_DEFINE_CALLINFO_3(extern, BOOL, js_HasNamedPropertyInt32, CONTEXT, OBJECT, INT32, 0,
|
||||
ACC_STORE_ANY)
|
||||
|
|
|
@ -48,9 +48,15 @@
|
|||
#undef THIS
|
||||
#endif
|
||||
|
||||
enum JSTNErrType { INFALLIBLE, FAIL_STATUS, FAIL_NULL, FAIL_NEG, FAIL_VOID };
|
||||
enum { JSTN_ERRTYPE_MASK = 0x07, JSTN_UNBOX_AFTER = 0x08, JSTN_MORE = 0x10,
|
||||
JSTN_CONSTRUCTOR = 0x20 };
|
||||
enum JSTNErrType { INFALLIBLE, FAIL_STATUS, FAIL_NULL, FAIL_NEG, FAIL_NEITHER };
|
||||
enum {
|
||||
JSTN_ERRTYPE_MASK = 0x07,
|
||||
JSTN_UNBOX_AFTER = 0x08,
|
||||
JSTN_MORE = 0x10,
|
||||
JSTN_CONSTRUCTOR = 0x20,
|
||||
JSTN_RETURN_NULLABLE_STR = 0x40,
|
||||
JSTN_RETURN_NULLABLE_OBJ = 0x80
|
||||
};
|
||||
|
||||
#define JSTN_ERRTYPE(jstn) ((jstn)->flags & JSTN_ERRTYPE_MASK)
|
||||
|
||||
|
@ -80,6 +86,7 @@ enum { JSTN_ERRTYPE_MASK = 0x07, JSTN_UNBOX_AFTER = 0x08, JSTN_MORE = 0x10,
|
|||
* 'o': a JSObject* argument
|
||||
* 'r': a JSObject* argument that is of class js_RegExpClass
|
||||
* 'f': a JSObject* argument that is of class js_FunctionClass
|
||||
* 'p': a js::Value* argument
|
||||
*/
|
||||
struct JSSpecializedNative {
|
||||
const nanojit::CallInfo *builtin;
|
||||
|
@ -147,7 +154,7 @@ struct ClosureVarInfo;
|
|||
* _RETRY builtins indicate failure with a special return value that
|
||||
* depends on the return type:
|
||||
*
|
||||
* BOOL_RETRY: JSVAL_TO_BOOLEAN(JSVAL_VOID)
|
||||
* BOOL_RETRY: JS_NEITHER
|
||||
* INT32_RETRY: any negative value
|
||||
* STRING_RETRY: NULL
|
||||
* OBJECT_RETRY_NULL: NULL
|
||||
|
@ -182,10 +189,11 @@ struct ClosureVarInfo;
|
|||
#define _JS_CTYPE_CALLEE_PROTOTYPE _JS_CTYPE(JSObject *, _JS_PTR,"p","", INFALLIBLE)
|
||||
#define _JS_CTYPE_FUNCTION _JS_CTYPE(JSFunction *, _JS_PTR, --, --, INFALLIBLE)
|
||||
#define _JS_CTYPE_PC _JS_CTYPE(jsbytecode *, _JS_PTR,"P", "", INFALLIBLE)
|
||||
#define _JS_CTYPE_VALUEPTR _JS_CTYPE(Value *, _JS_PTR, --, --, INFALLIBLE)
|
||||
#define _JS_CTYPE_CVALUEPTR _JS_CTYPE(const Value *, _JS_PTR, --, --, INFALLIBLE)
|
||||
#define _JS_CTYPE_VALUEPTR _JS_CTYPE(js::Value *, _JS_PTR, "","p", INFALLIBLE)
|
||||
#define _JS_CTYPE_CVALUEPTR _JS_CTYPE(const js::Value *, _JS_PTR, "","p", INFALLIBLE)
|
||||
#define _JS_CTYPE_SIZET _JS_CTYPE(size_t, _JS_PTR, --, --, INFALLIBLE)
|
||||
#define _JS_CTYPE_BOOL _JS_CTYPE(JSBool, _JS_I32, "","i", INFALLIBLE)
|
||||
#define _JS_CTYPE_BOOL_RETRY _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_VOID)
|
||||
#define _JS_CTYPE_BOOL_RETRY _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_NEITHER)
|
||||
#define _JS_CTYPE_BOOL_FAIL _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_STATUS)
|
||||
#define _JS_CTYPE_BOOLPTR _JS_CTYPE(JSBool *, _JS_PTR, --, --, INFALLIBLE)
|
||||
#define _JS_CTYPE_INT32 _JS_CTYPE(int32, _JS_I32, "","i", INFALLIBLE)
|
||||
|
@ -200,10 +208,14 @@ struct ClosureVarInfo;
|
|||
#define _JS_CTYPE_STRING _JS_CTYPE(JSString *, _JS_PTR, "","s", INFALLIBLE)
|
||||
#define _JS_CTYPE_STRING_RETRY _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_NULL)
|
||||
#define _JS_CTYPE_STRING_FAIL _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_STATUS)
|
||||
#define _JS_CTYPE_STRING_OR_NULL_FAIL _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_STATUS | \
|
||||
JSTN_RETURN_NULLABLE_STR)
|
||||
#define _JS_CTYPE_STRINGPTR _JS_CTYPE(JSString **, _JS_PTR, --, --, INFALLIBLE)
|
||||
#define _JS_CTYPE_OBJECT _JS_CTYPE(JSObject *, _JS_PTR, "","o", INFALLIBLE)
|
||||
#define _JS_CTYPE_OBJECT_RETRY _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_NULL)
|
||||
#define _JS_CTYPE_OBJECT_FAIL _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_STATUS)
|
||||
#define _JS_CTYPE_OBJECT_OR_NULL_FAIL _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_STATUS | \
|
||||
JSTN_RETURN_NULLABLE_OBJ)
|
||||
#define _JS_CTYPE_OBJECTPTR _JS_CTYPE(JSObject **, _JS_PTR, --, --, INFALLIBLE)
|
||||
#define _JS_CTYPE_CONSTRUCTOR_RETRY _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_NULL | \
|
||||
JSTN_CONSTRUCTOR)
|
||||
|
|
|
@ -1296,8 +1296,7 @@ resolving_HashKey(JSDHashTable *table, const void *ptr)
|
|||
{
|
||||
const JSResolvingKey *key = (const JSResolvingKey *)ptr;
|
||||
|
||||
return (JSDHashNumber(uintptr_t(key->obj)) >> JS_GCTHING_ALIGN) ^
|
||||
JSDHashNumber(key->id) ^ JSDHashNumber(key->id >> 32);
|
||||
return (JSDHashNumber(uintptr_t(key->obj)) >> JS_GCTHING_ALIGN) ^ JSID_BITS(key->id);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
|
|
@ -2268,9 +2268,10 @@ class AutoGCRooter {
|
|||
XML = -10, /* js::AutoXMLRooter */
|
||||
OBJECT = -11, /* js::AutoObjectRooter */
|
||||
ID = -12, /* js::AutoIdRooter */
|
||||
VECTOR = -13, /* js::AutoValueVector */
|
||||
VALVECTOR = -13, /* js::AutoValueVector */
|
||||
DESCRIPTOR = -14, /* js::AutoPropertyDescriptorRooter */
|
||||
STRING = -15 /* js::AutoStringRooter */
|
||||
STRING = -15, /* js::AutoStringRooter */
|
||||
IDVECTOR = -16 /* js::AutoIdVector */
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -3109,7 +3110,7 @@ class AutoValueVector : private AutoGCRooter
|
|||
public:
|
||||
explicit AutoValueVector(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, VECTOR), vector(cx)
|
||||
: AutoGCRooter(cx, VALVECTOR), vector(cx)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
@ -3120,6 +3121,10 @@ class AutoValueVector : private AutoGCRooter
|
|||
|
||||
void popBack() { vector.popBack(); }
|
||||
|
||||
bool growBy(size_t inc) {
|
||||
return vector.growBy(inc);
|
||||
}
|
||||
|
||||
bool resize(size_t newLength) {
|
||||
return vector.resize(newLength);
|
||||
}
|
||||
|
@ -3146,6 +3151,52 @@ class AutoValueVector : private AutoGCRooter
|
|||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoIdVector : private AutoGCRooter
|
||||
{
|
||||
public:
|
||||
explicit AutoIdVector(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, IDVECTOR), vector(cx)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
size_t length() const { return vector.length(); }
|
||||
|
||||
bool append(jsid id) { return vector.append(id); }
|
||||
|
||||
void popBack() { vector.popBack(); }
|
||||
|
||||
bool growBy(size_t inc) {
|
||||
return vector.growBy(inc);
|
||||
}
|
||||
|
||||
bool resize(size_t newLength) {
|
||||
return vector.resize(newLength);
|
||||
}
|
||||
|
||||
bool reserve(size_t newLength) {
|
||||
return vector.reserve(newLength);
|
||||
}
|
||||
|
||||
const jsid &operator[](size_t i) { return vector[i]; }
|
||||
const jsid &operator[](size_t i) const { return vector[i]; }
|
||||
|
||||
const jsid *begin() const { return vector.begin(); }
|
||||
jsid *begin() { return vector.begin(); }
|
||||
|
||||
const jsid *end() const { return vector.end(); }
|
||||
jsid *end() { return vector.end(); }
|
||||
|
||||
const jsid &back() const { return vector.back(); }
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
|
||||
private:
|
||||
Vector<jsid, 8> vector;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
JSIdArray *
|
||||
NewIdArray(JSContext *cx, jsint length);
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ AutoGCRooter::trace(JSTracer *trc)
|
|||
MarkId(trc, static_cast<AutoIdRooter *>(this)->idval, "js::AutoIdRooter.val");
|
||||
return;
|
||||
|
||||
case VECTOR: {
|
||||
case VALVECTOR: {
|
||||
Vector<Value, 8> &vector = static_cast<AutoValueVector *>(this)->vector;
|
||||
MarkValueRange(trc, vector.length(), vector.begin(), "js::AutoValueVector.vector");
|
||||
return;
|
||||
|
@ -286,6 +286,12 @@ AutoGCRooter::trace(JSTracer *trc)
|
|||
if (JSString *str = static_cast<AutoStringRooter *>(this)->str)
|
||||
Mark(trc, str, JSTRACE_STRING, "js::AutoStringRooter.str");
|
||||
return;
|
||||
|
||||
case IDVECTOR: {
|
||||
Vector<jsid, 8> &vector = static_cast<AutoIdVector *>(this)->vector;
|
||||
MarkIdRange(trc, vector.length(), vector.begin(), "js::AutoIdVector.vector");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
JS_ASSERT(tag >= 0);
|
||||
|
|
|
@ -617,7 +617,7 @@ date_UTC(JSContext *cx, uintN argc, Value *vp)
|
|||
|
||||
msec_time = TIMECLIP(msec_time);
|
||||
|
||||
vp->setDouble(msec_time);
|
||||
vp->setNumber(msec_time);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1164,7 +1164,7 @@ date_parse(JSContext *cx, uintN argc, Value *vp)
|
|||
}
|
||||
|
||||
result = TIMECLIP(result);
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ GetUTCTime(JSContext *cx, JSObject *obj, Value *vp, jsdouble *dp)
|
|||
{
|
||||
if (!InstanceOf(cx, obj, &js_DateClass, vp ? vp + 2 : NULL))
|
||||
return JS_FALSE;
|
||||
*dp = obj->getDateUTCTime().asDouble();
|
||||
*dp = obj->getDateUTCTime().asNumber();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1238,7 +1238,7 @@ GetAndCacheLocalTime(JSContext *cx, JSObject *obj, Value *vp, jsdouble *dp)
|
|||
if (!obj || !InstanceOf(cx, obj, &js_DateClass, vp ? vp + 2 : NULL))
|
||||
return false;
|
||||
|
||||
jsdouble result = obj->getDateLocalTime().asDouble();
|
||||
jsdouble result = obj->getDateLocalTime().asNumber();
|
||||
if (JSDOUBLE_IS_NaN(result)) {
|
||||
result = obj->getDateUTCTime().asDouble();
|
||||
|
||||
|
@ -1263,7 +1263,7 @@ date_getTime(JSContext *cx, uintN argc, Value *vp)
|
|||
|
||||
if (!GetUTCTime(cx, ComputeThisObjectFromVp(cx, vp), vp, &result))
|
||||
return JS_FALSE;
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1283,7 +1283,7 @@ GetYear(JSContext *cx, JSBool fullyear, Value *vp)
|
|||
result -= 1900;
|
||||
}
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1310,7 +1310,7 @@ date_getUTCFullYear(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = YearFromTime(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1325,7 +1325,7 @@ date_getMonth(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = MonthFromTime(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1340,7 +1340,7 @@ date_getUTCMonth(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = MonthFromTime(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1355,7 +1355,7 @@ date_getDate(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = DateFromTime(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1370,7 +1370,7 @@ date_getUTCDate(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = DateFromTime(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1385,7 +1385,7 @@ date_getDay(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = WeekDay(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1400,7 +1400,7 @@ date_getUTCDay(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = WeekDay(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1415,7 +1415,7 @@ date_getHours(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = HourFromTime(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1430,7 +1430,7 @@ date_getUTCHours(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = HourFromTime(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1445,7 +1445,7 @@ date_getMinutes(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = MinFromTime(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1460,7 +1460,7 @@ date_getUTCMinutes(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = MinFromTime(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1477,7 +1477,7 @@ date_getUTCSeconds(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = SecFromTime(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1494,7 +1494,7 @@ date_getUTCMilliseconds(JSContext *cx, uintN argc, Value *vp)
|
|||
if (JSDOUBLE_IS_FINITE(result))
|
||||
result = msFromTime(result);
|
||||
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1516,7 +1516,7 @@ date_getTimezoneOffset(JSContext *cx, uintN argc, Value *vp)
|
|||
* daylight savings time.
|
||||
*/
|
||||
result = (utctime - localtime) / msPerMinute;
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1558,7 +1558,7 @@ date_makeTime(JSContext *cx, uintN maxargs, JSBool local, uintN argc, Value *vp)
|
|||
|
||||
/* just return NaN if the date is already NaN */
|
||||
if (!JSDOUBLE_IS_FINITE(result)) {
|
||||
vp->setDouble(result);
|
||||
vp->setNumber(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -765,7 +765,7 @@ js_WrapWatchedSetter(JSContext *cx, jsid id, uintN attrs, PropertyOp setter)
|
|||
if (JSID_IS_ATOM(id)) {
|
||||
atom = JSID_TO_ATOM(id);
|
||||
} else if (JSID_IS_INT(id)) {
|
||||
if (!js_ValueToStringId(cx, ID_TO_VALUE(id), &id))
|
||||
if (!js_ValueToStringId(cx, IdToValue(id), &id))
|
||||
return NULL;
|
||||
atom = JSID_TO_ATOM(id);
|
||||
} else {
|
||||
|
@ -805,10 +805,10 @@ JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsid id,
|
|||
if (JSID_IS_INT(id)) {
|
||||
propid = id;
|
||||
} else {
|
||||
if (!js_ValueToStringId(cx, ID_TO_VALUE(id), &propid))
|
||||
if (!js_ValueToStringId(cx, IdToValue(id), &propid))
|
||||
return JS_FALSE;
|
||||
propid = js_CheckForStringIndex(propid);
|
||||
idroot.set(ID_TO_VALUE(propid));
|
||||
idroot.set(IdToValue(propid));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1453,7 +1453,7 @@ JS_PUBLIC_API(JSBool)
|
|||
JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *sprop,
|
||||
JSPropertyDesc *pd)
|
||||
{
|
||||
pd->id = ID_TO_JSVAL(sprop->id);
|
||||
pd->id = IdToJsval(sprop->id);
|
||||
|
||||
JSBool wasThrowing = cx->throwing;
|
||||
AutoValueRooter lastException(cx, cx->exception);
|
||||
|
@ -1495,7 +1495,7 @@ JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *sprop,
|
|||
JSScopeProperty *aprop;
|
||||
for (aprop = scope->lastProperty(); aprop; aprop = aprop->parent) {
|
||||
if (aprop != sprop && aprop->slot == sprop->slot) {
|
||||
pd->alias = ID_TO_JSVAL(aprop->id);
|
||||
pd->alias = IdToJsval(aprop->id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ js_GetArgsProperty(JSContext *cx, JSStackFrame *fp, jsid id, Value *vp)
|
|||
if (argsobj)
|
||||
return argsobj->getProperty(cx, id, vp);
|
||||
}
|
||||
} else if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
} else if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
JSObject *argsobj = fp->argsObj();
|
||||
if (argsobj && argsobj->isArgsLengthOverridden())
|
||||
return argsobj->getProperty(cx, id, vp);
|
||||
|
@ -297,9 +297,9 @@ args_delProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
uintN arg = uintN(JSID_TO_INT(id));
|
||||
if (arg < obj->getArgsLength())
|
||||
obj->setArgsElement(arg, Value(JS_ARGS_HOLE));
|
||||
} else if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
} else if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
obj->setArgsLengthOverridden();
|
||||
} else if (id == ATOM_TO_JSID(cx->runtime->atomState.calleeAtom)) {
|
||||
} else if (JSID_IS_ATOM(id, cx->runtime->atomState.calleeAtom)) {
|
||||
obj->setArgsCallee(Value(JS_ARGS_HOLE));
|
||||
}
|
||||
return true;
|
||||
|
@ -502,10 +502,8 @@ ArgGetter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
#ifdef JS_TRACER
|
||||
ArgsPrivateNative *argp = GetArgsPrivateNative(obj);
|
||||
if (argp) {
|
||||
if (NativeToValue(cx, *vp, argp->typemap()[arg], &argp->argv[arg]))
|
||||
return true;
|
||||
LeaveTrace(cx);
|
||||
return false;
|
||||
ExternNativeToValue(cx, *vp, argp->typemap()[arg], &argp->argv[arg]);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -518,11 +516,11 @@ ArgGetter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
*vp = v;
|
||||
}
|
||||
}
|
||||
} else if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
} else if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
if (!obj->isArgsLengthOverridden())
|
||||
vp->setInt32(obj->getArgsLength());
|
||||
} else {
|
||||
JS_ASSERT(id == ATOM_TO_JSID(cx->runtime->atomState.calleeAtom));
|
||||
JS_ASSERT(JSID_IS_ATOM(id, cx->runtime->atomState.calleeAtom));
|
||||
const Value &v = obj->getArgsCallee();
|
||||
if (!v.isMagic(JS_ARGS_HOLE)) {
|
||||
/*
|
||||
|
@ -571,8 +569,8 @@ ArgSetter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
JS_ASSERT(id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom) ||
|
||||
id == ATOM_TO_JSID(cx->runtime->atomState.calleeAtom));
|
||||
JS_ASSERT(JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom) ||
|
||||
JSID_IS_ATOM(id, cx->runtime->atomState.calleeAtom));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -598,10 +596,10 @@ args_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
|||
uint32 arg = uint32(JSID_TO_INT(id));
|
||||
if (arg < obj->getArgsLength() && !obj->getArgsElement(arg).isMagic(JS_ARGS_HOLE))
|
||||
valid = true;
|
||||
} else if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
} else if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
if (!obj->isArgsLengthOverridden())
|
||||
valid = true;
|
||||
} else if (id == ATOM_TO_JSID(cx->runtime->atomState.calleeAtom)) {
|
||||
} else if (JSID_IS_ATOM(id, cx->runtime->atomState.calleeAtom)) {
|
||||
if (!obj->getArgsCallee().isMagic(JS_ARGS_HOLE))
|
||||
valid = true;
|
||||
}
|
||||
|
@ -1097,37 +1095,37 @@ SetCallArguments(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
}
|
||||
|
||||
JSBool
|
||||
js_GetCallArg(JSContext *cx, JSObject *obj, jsval id, Value *vp)
|
||||
js_GetCallArg(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, id, vp, JSCPK_ARG);
|
||||
}
|
||||
|
||||
JSBool
|
||||
SetCallArg(JSContext *cx, JSObject *obj, jsval id, Value *vp)
|
||||
SetCallArg(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, id, vp, JSCPK_ARG, true);
|
||||
}
|
||||
|
||||
JSBool
|
||||
GetFlatUpvar(JSContext *cx, JSObject *obj, jsval id, Value *vp)
|
||||
GetFlatUpvar(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, id, vp, JSCPK_UPVAR);
|
||||
}
|
||||
|
||||
JSBool
|
||||
SetFlatUpvar(JSContext *cx, JSObject *obj, jsval id, Value *vp)
|
||||
SetFlatUpvar(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, id, vp, JSCPK_UPVAR, true);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_GetCallVar(JSContext *cx, JSObject *obj, jsval id, Value *vp)
|
||||
js_GetCallVar(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, id, vp, JSCPK_VAR);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_GetCallVarChecked(JSContext *cx, JSObject *obj, jsval id, Value *vp)
|
||||
js_GetCallVarChecked(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
{
|
||||
if (!CallPropertyOp(cx, obj, id, vp, JSCPK_VAR))
|
||||
return false;
|
||||
|
@ -1136,26 +1134,26 @@ js_GetCallVarChecked(JSContext *cx, JSObject *obj, jsval id, Value *vp)
|
|||
}
|
||||
|
||||
JSBool
|
||||
SetCallVar(JSContext *cx, JSObject *obj, jsval id, Value *vp)
|
||||
SetCallVar(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, id, vp, JSCPK_VAR, true);
|
||||
}
|
||||
|
||||
#if JS_TRACER
|
||||
JSBool JS_FASTCALL
|
||||
js_SetCallArg(JSContext *cx, JSObject *obj, uint32 slotid, Value *vp)
|
||||
js_SetCallArg(JSContext *cx, JSObject *obj, size_t slotid, Value *vp)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, INT_TO_JSID(slotid), vp, JSCPK_ARG, true);
|
||||
return CallPropertyOp(cx, obj, JSID_FROM_BITS(slotid), vp, JSCPK_ARG, true);
|
||||
}
|
||||
|
||||
JSBool JS_FASTCALL
|
||||
js_SetCallVar(JSContext *cx, JSObject *obj, uint32 slotid, Value *vp)
|
||||
js_SetCallVar(JSContext *cx, JSObject *obj, size_t slotid, Value *vp)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, INT_TO_JSID(slotid), vp, JSCPK_VAR, true);
|
||||
return CallPropertyOp(cx, obj, JSID_FROM_BITS(slotid), vp, JSCPK_VAR, true);
|
||||
}
|
||||
JS_DEFINE_CALLINFO_4(extern, BOOL, js_SetCallArg, CONTEXT, OBJECT, UINT32, VALUEPTR, 0,
|
||||
JS_DEFINE_CALLINFO_4(extern, BOOL, js_SetCallArg, CONTEXT, OBJECT, SIZET, VALUEPTR, 0,
|
||||
nanojit::ACC_STORE_ANY)
|
||||
JS_DEFINE_CALLINFO_4(extern, BOOL, js_SetCallVar, CONTEXT, OBJECT, UINT32, VALUEPTR, 0,
|
||||
JS_DEFINE_CALLINFO_4(extern, BOOL, js_SetCallVar, CONTEXT, OBJECT, SIZET, VALUEPTR, 0,
|
||||
nanojit::ACC_STORE_ANY)
|
||||
#endif
|
||||
|
||||
|
@ -1247,7 +1245,7 @@ call_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
|||
* Resolve arguments so that we never store a particular Call object's
|
||||
* arguments object reference in a Call prototype's |arguments| slot.
|
||||
*/
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.argumentsAtom)) {
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.argumentsAtom)) {
|
||||
if (!js_DefineNativeProperty(cx, obj, id, Value(UndefinedTag()),
|
||||
GetCallArguments, SetCallArguments,
|
||||
JSPROP_PERMANENT | JSPROP_SHARED,
|
||||
|
@ -1438,7 +1436,7 @@ fun_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
|
|||
* fun is not a compiler-created function object, which must never leak to
|
||||
* script or embedding code and then be mutated.
|
||||
*/
|
||||
if ((flags & JSRESOLVE_ASSIGNING) && id != ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
if ((flags & JSRESOLVE_ASSIGNING) && !JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
JS_ASSERT(!IsInternalFunctionObject(obj));
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -1712,7 +1710,7 @@ js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp)
|
|||
* if v is an object) returning true if .prototype is found.
|
||||
*/
|
||||
static JSBool
|
||||
fun_hasInstance(JSContext *cx, JSObject *obj, Value v, JSBool *bp)
|
||||
fun_hasInstance(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
|
||||
{
|
||||
jsid id = ATOM_TO_JSID(cx->runtime->atomState.classPrototypeAtom);
|
||||
Value pval;
|
||||
|
@ -1728,7 +1726,7 @@ fun_hasInstance(JSContext *cx, JSObject *obj, Value v, JSBool *bp)
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*bp = js_IsDelegate(cx, &pval.asObject(), v);
|
||||
*bp = js_IsDelegate(cx, &pval.asObject(), *v);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -256,12 +256,7 @@ JSObject::isFunction() const
|
|||
return getClass() == &js_FunctionClass;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: remove once all internal jsval use goes away.
|
||||
* NB: jsapi.h and jsobj.h must be included before any call to this macro.
|
||||
*/
|
||||
#define VALUE_IS_FUNCTION(cx, v) \
|
||||
(!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isFunction())
|
||||
#define VALUE_IS_FUNCTION(cx, v) (Valueify(v).isFunObj())
|
||||
|
||||
/*
|
||||
* Macro to access the private slot of the function object after the slot is
|
||||
|
@ -375,16 +370,16 @@ extern JSFunction *
|
|||
js_GetCallObjectFunction(JSObject *obj);
|
||||
|
||||
extern JSBool
|
||||
js_GetCallArg(JSContext *cx, JSObject *obj, jsval id, js::Value *vp);
|
||||
js_GetCallArg(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
|
||||
|
||||
extern JSBool
|
||||
js_GetCallVar(JSContext *cx, JSObject *obj, jsval id, js::Value *vp);
|
||||
js_GetCallVar(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
|
||||
|
||||
extern JSBool
|
||||
SetCallArg(JSContext *cx, JSObject *obj, jsval id, js::Value *vp);
|
||||
SetCallArg(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
|
||||
|
||||
extern JSBool
|
||||
SetCallVar(JSContext *cx, JSObject *obj, jsval id, js::Value *vp);
|
||||
SetCallVar(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
|
||||
|
||||
/*
|
||||
* js_SetCallArg and js_SetCallVar are extern fastcall copies of the setter
|
||||
|
@ -393,17 +388,17 @@ SetCallVar(JSContext *cx, JSObject *obj, jsval id, js::Value *vp);
|
|||
* property ops map.
|
||||
*/
|
||||
extern JSBool JS_FASTCALL
|
||||
js_SetCallArg(JSContext *cx, JSObject *obj, uint32 slotid, js::Value *vp);
|
||||
js_SetCallArg(JSContext *cx, JSObject *obj, size_t slotid, js::Value *vp);
|
||||
|
||||
extern JSBool JS_FASTCALL
|
||||
js_SetCallVar(JSContext *cx, JSObject *obj, uint32 slotid, js::Value *vp);
|
||||
js_SetCallVar(JSContext *cx, JSObject *obj, size_t slotid, js::Value *vp);
|
||||
|
||||
/*
|
||||
* Slower version of js_GetCallVar used when call_resolve detects an attempt to
|
||||
* leak an optimized closure via indirect or debugger eval.
|
||||
*/
|
||||
extern JSBool
|
||||
js_GetCallVarChecked(JSContext *cx, JSObject *obj, jsval id, js::Value *vp);
|
||||
js_GetCallVarChecked(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
|
||||
|
||||
extern JSBool
|
||||
js_GetArgsValue(JSContext *cx, JSStackFrame *fp, js::Value *vp);
|
||||
|
|
|
@ -541,19 +541,23 @@ MarkValueRange(JSTracer *trc, size_t len, Value *vec, const char *name)
|
|||
static inline void
|
||||
MarkId(JSTracer *trc, jsid id, const char *name)
|
||||
{
|
||||
MarkValue(trc, Valueify(id), name);
|
||||
if (JSID_IS_STRING(id))
|
||||
Mark(trc, JSID_TO_STRING(id), JSTRACE_STRING, name);
|
||||
else if (JS_UNLIKELY(JSID_IS_OBJECT(id)))
|
||||
Mark(trc, JSID_TO_OBJECT(id), JSTRACE_OBJECT, name);
|
||||
}
|
||||
|
||||
static inline void
|
||||
MarkIdRange(JSTracer *trc, jsid *beg, jsid *end, const char *name)
|
||||
{
|
||||
MarkValueRange(trc, Valueify(beg), Valueify(end), name);
|
||||
for (jsid *idp = beg; idp != end; ++idp)
|
||||
MarkId(trc, *idp, name);
|
||||
}
|
||||
|
||||
static inline void
|
||||
MarkIdRange(JSTracer *trc, size_t len, jsid *vec, const char *name)
|
||||
{
|
||||
MarkValueRange(trc, len, Valueify(vec), name);
|
||||
MarkIdRange(trc, vec, vec + len, name);
|
||||
}
|
||||
|
||||
/* N.B. Assumes JS_SET_TRACING_NAME/INDEX has already been called. */
|
||||
|
|
|
@ -35,10 +35,6 @@
|
|||
#include "jstypes.h"
|
||||
#include "jsstdint.h"
|
||||
#include "jsgcchunk.h"
|
||||
#ifdef JS_64BIT
|
||||
# include "jsstr.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XP_WIN
|
||||
# include "jswin.h"
|
||||
|
@ -144,47 +140,6 @@ UnmapPages(void *p, size_t size)
|
|||
|
||||
# else /* WINCE */
|
||||
|
||||
# ifdef _M_X64
|
||||
|
||||
typedef long (*ntavm_fun)(HANDLE handle, void **addr, ULONG zbits,
|
||||
size_t *size, ULONG alloctype, ULONG prot);
|
||||
typedef long (*ntfvm_fun)(HANDLE handle, void **addr, size_t *size,
|
||||
ULONG freetype);
|
||||
|
||||
static ntavm_fun NtAllocateVirtualMemory;
|
||||
static ntfvm_fun NtFreeVirtualMemory;
|
||||
|
||||
bool
|
||||
js::InitNtAllocAPIs()
|
||||
{
|
||||
HMODULE h = GetModuleHandle("ntdll.dll");
|
||||
if (!h)
|
||||
return false;
|
||||
NtAllocateVirtualMemory = ntavm_fun(GetProcAddress(h, "NtAllocateVirtualMemory"));
|
||||
if (!NtAllocateVirtualMemory)
|
||||
return false;
|
||||
NtFreeVirtualMemory = ntfvm_fun(GetProcAddress(h, "NtFreeVirtualMemory"));
|
||||
if (!NtFreeVirtualMemory)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allocate pages with 32-bit addresses (i.e., top 16 bits are all 0).
|
||||
static void *
|
||||
MapPages(void *addr, size_t size)
|
||||
{
|
||||
long rc = NtAllocateVirtualMemory(INVALID_HANDLE_VALUE, &addr, 1, &size,
|
||||
MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
|
||||
return rc ? NULL : addr;
|
||||
}
|
||||
|
||||
static void
|
||||
UnmapPages(void *addr, size_t size)
|
||||
{
|
||||
NtFreeVirtualMemory(INVALID_HANDLE_VALUE, &addr, &size, MEM_RELEASE);
|
||||
}
|
||||
|
||||
# else /* _M_X64 */
|
||||
|
||||
static void *
|
||||
MapPages(void *addr, size_t size)
|
||||
{
|
||||
|
@ -199,8 +154,6 @@ UnmapPages(void *addr, size_t size)
|
|||
JS_ALWAYS_TRUE(VirtualFree(addr, 0, MEM_RELEASE));
|
||||
}
|
||||
|
||||
# endif /* _M_X64 */
|
||||
|
||||
# endif /* !WINCE */
|
||||
|
||||
#elif defined(XP_MACOSX) || defined(DARWIN)
|
||||
|
@ -249,7 +202,6 @@ MapAlignedPages(size_t size, size_t alignment)
|
|||
* We don't use MAP_FIXED here, because it can cause the *replacement*
|
||||
* of existing mappings, and we only want to create new mappings.
|
||||
*/
|
||||
// TODO: this is totally a hack for now; need to replace
|
||||
void *p = mmap((caddr_t) alignment, size, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_NOSYNC | MAP_ALIGN | MAP_ANON, -1, 0);
|
||||
if (p == MAP_FAILED)
|
||||
|
@ -259,53 +211,6 @@ MapAlignedPages(size_t size, size_t alignment)
|
|||
|
||||
# else /* JS_GC_HAS_MAP_ALIGN */
|
||||
|
||||
# if defined(__MACH__) && defined(__APPLE__) && defined(__x86_64__)
|
||||
|
||||
// Make sure the result is in the 32-bit address region.
|
||||
static void *
|
||||
MapPages(void *addr, size_t size)
|
||||
{
|
||||
void * const start = (void *) 0x10000;
|
||||
void * const end = (void *) 0x100000000;
|
||||
|
||||
// If an addr is given, try once there.
|
||||
if (addr) {
|
||||
JS_ASSERT(addr < end);
|
||||
void *p = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
if (p == MAP_FAILED)
|
||||
return NULL;
|
||||
if (p != addr) {
|
||||
JS_ALWAYS_TRUE(munmap(p, size) == 0);
|
||||
return NULL;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
// FIXME: this depends on implementation details of OSX mmap, namely
|
||||
// that it searches for free memory starting from the hint,
|
||||
// so that it will find free memory addresses in 32-bit space
|
||||
// if it exists.
|
||||
static void *base = start;
|
||||
while (true) {
|
||||
void *p = mmap(base, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
if (p == MAP_FAILED)
|
||||
return NULL;
|
||||
// Got a region in range, so return it.
|
||||
if (start <= p && p < end) {
|
||||
base = (void *) (uintptr_t(p) + size);
|
||||
return p;
|
||||
}
|
||||
// Out of range. If we started past 'start', then we can try
|
||||
// again from there.
|
||||
munmap(p, size);
|
||||
if (base != start)
|
||||
return NULL;
|
||||
base = start;
|
||||
}
|
||||
}
|
||||
|
||||
# else /* DARWIN && __x86_64__ */
|
||||
|
||||
static void *
|
||||
MapPages(void *addr, size_t size)
|
||||
{
|
||||
|
@ -313,7 +218,6 @@ MapPages(void *addr, size_t size)
|
|||
* We don't use MAP_FIXED here, because it can cause the *replacement*
|
||||
* of existing mappings, and we only want to create new mappings.
|
||||
*/
|
||||
// TODO: this is totally a hack for now; need to replace
|
||||
void *p = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON,
|
||||
-1, 0);
|
||||
if (p == MAP_FAILED)
|
||||
|
@ -326,8 +230,6 @@ MapPages(void *addr, size_t size)
|
|||
return p;
|
||||
}
|
||||
|
||||
# endif /* DARWIN && __x86_64__ */
|
||||
|
||||
# endif /* !JS_GC_HAS_MAP_ALIGN */
|
||||
|
||||
static void
|
||||
|
@ -338,29 +240,6 @@ UnmapPages(void *addr, size_t size)
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef JS_64BIT
|
||||
bool
|
||||
JSString::initStringTables()
|
||||
{
|
||||
char *p = (char *) MapPages(NULL, unitStringTableSize + intStringTableSize);
|
||||
if (!p)
|
||||
return false;
|
||||
unitStringTable = (JSString*) memcpy(p, staticUnitStringTable, unitStringTableSize);
|
||||
intStringTable = (JSString*) memcpy(p + unitStringTableSize,
|
||||
staticIntStringTable, intStringTableSize);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
JSString::freeStringTables()
|
||||
{
|
||||
UnmapPages(unitStringTable, unitStringTableSize + intStringTableSize);
|
||||
unitStringTable = NULL;
|
||||
intStringTable = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace js {
|
||||
|
||||
GCChunkAllocator defaultGCChunkAllocator;
|
||||
|
|
|
@ -342,8 +342,8 @@ js_OnUnknownMethod(JSContext *cx, Value *vp)
|
|||
obj = &vp[0].asObject();
|
||||
if (!js_IsFunctionQName(cx, obj, &id))
|
||||
return false;
|
||||
if (id != 0)
|
||||
vp[0] = ID_TO_VALUE(id);
|
||||
if (!JSID_IS_VOID(id))
|
||||
vp[0] = IdToValue(id);
|
||||
}
|
||||
#endif
|
||||
obj = NewObjectWithGivenProto(cx, &js_NoSuchMethodClass, NULL, NULL);
|
||||
|
@ -387,19 +387,6 @@ NoSuchMethod(JSContext *cx, uintN argc, Value *vp, uint32 flags)
|
|||
|
||||
namespace js {
|
||||
|
||||
static const uint32 FAKE_NUMBER_MASK = JSVAL_MASK32_INT32 | PrimitiveValue::DOUBLE_MASK;
|
||||
|
||||
const uint32 PrimitiveValue::Masks[PrimitiveValue::THISP_ARRAY_SIZE] = {
|
||||
0, /* 000 */
|
||||
JSVAL_MASK32_STRING, /* 001 */
|
||||
FAKE_NUMBER_MASK, /* 010 */
|
||||
FAKE_NUMBER_MASK | JSVAL_MASK32_STRING, /* 011 */
|
||||
JSVAL_MASK32_BOOLEAN, /* 100 */
|
||||
JSVAL_MASK32_BOOLEAN | JSVAL_MASK32_STRING, /* 101 */
|
||||
JSVAL_MASK32_BOOLEAN | FAKE_NUMBER_MASK, /* 110 */
|
||||
JSVAL_MASK32_BOOLEAN | FAKE_NUMBER_MASK | JSVAL_MASK32_STRING /* 111 */
|
||||
};
|
||||
|
||||
class AutoPreserveEnumerators {
|
||||
JSContext *cx;
|
||||
JSObject *enumerators;
|
||||
|
@ -541,7 +528,7 @@ Invoke(JSContext *cx, const InvokeArgsGuard &args, uintN flags)
|
|||
vp[1].setObjectOrNull(parent);
|
||||
} else if (vp[1].isPrimitive()) {
|
||||
JS_ASSERT(!(flags & JSINVOKE_CONSTRUCT));
|
||||
if (PrimitiveValue::test(fun, vp[1]))
|
||||
if (PrimitiveThisTest(fun, vp[1]))
|
||||
goto start_call;
|
||||
}
|
||||
}
|
||||
|
@ -1007,7 +994,7 @@ CheckRedeclaration(JSContext *cx, JSObject *obj, jsid id, uintN attrs,
|
|||
: isFunction
|
||||
? js_function_str
|
||||
: js_var_str;
|
||||
name = js_ValueToPrintableString(cx, ID_TO_VALUE(id));
|
||||
name = js_ValueToPrintableString(cx, IdToValue(id));
|
||||
if (!name)
|
||||
return JS_FALSE;
|
||||
return !!JS_ReportErrorFlagsAndNumber(cx, report,
|
||||
|
@ -1188,7 +1175,7 @@ bool
|
|||
ValueToId(JSContext *cx, const Value &v, jsid *idp)
|
||||
{
|
||||
int32_t i;
|
||||
if (ValueFitsInInt32(v, &i)) {
|
||||
if (ValueFitsInInt32(v, &i) && INT_FITS_IN_JSID(i)) {
|
||||
*idp = INT_TO_JSID(i);
|
||||
return true;
|
||||
}
|
||||
|
@ -1202,7 +1189,7 @@ ValueToId(JSContext *cx, const Value &v, jsid *idp)
|
|||
}
|
||||
if (!js_IsFunctionQName(cx, obj, idp))
|
||||
return JS_FALSE;
|
||||
if (*idp != 0)
|
||||
if (!JSID_IS_VOID(*idp))
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
@ -2033,12 +2020,19 @@ IteratorNext(JSContext *cx, JSObject *iterobj, Value *rval)
|
|||
if (iterobj->getClass() == &js_IteratorClass.base) {
|
||||
NativeIterator *ni = (NativeIterator *) iterobj->getPrivate();
|
||||
JS_ASSERT(ni->props_cursor < ni->props_end);
|
||||
*rval = ID_TO_VALUE(*ni->props_cursor);
|
||||
if (rval->isString() || (ni->flags & JSITER_FOREACH)) {
|
||||
ni->props_cursor++;
|
||||
if ((ni->flags & JSITER_FOREACH) == 0) {
|
||||
jsid id = ni->currentId();
|
||||
if (JSID_IS_ATOM(id)) {
|
||||
rval->setString(JSID_TO_STRING(id));
|
||||
ni->incIdCursor();
|
||||
return true;
|
||||
}
|
||||
/* Take the slow path if we have to stringify a numeric property name. */
|
||||
} else {
|
||||
*rval = ni->currentValue();
|
||||
ni->incValueCursor();
|
||||
return true;
|
||||
}
|
||||
/* Take the slow path if we have to stringify a numeric property name. */
|
||||
}
|
||||
return js_IteratorNext(cx, iterobj, rval);
|
||||
}
|
||||
|
|
|
@ -292,28 +292,14 @@ ComputeThisFromVpInPlace(JSContext *cx, js::Value *vp)
|
|||
return ComputeThisFromArgv(cx, vp + 2);
|
||||
}
|
||||
|
||||
class PrimitiveValue
|
||||
JS_ALWAYS_INLINE bool
|
||||
PrimitiveThisTest(JSFunction *fun, const Value &v)
|
||||
{
|
||||
static const unsigned THISP_MASK = 0x7;
|
||||
static const unsigned THISP_ARRAY_SIZE = 8;
|
||||
static const unsigned THISP_SHIFT = 8;
|
||||
|
||||
void staticAssert() {
|
||||
JS_STATIC_ASSERT(JSFUN_THISP_PRIMITIVE >> THISP_SHIFT == THISP_MASK);
|
||||
JS_STATIC_ASSERT(THISP_MASK == THISP_ARRAY_SIZE - 1);
|
||||
}
|
||||
|
||||
static const uint32 Masks[THISP_ARRAY_SIZE];
|
||||
|
||||
public:
|
||||
static const uint32 DOUBLE_MASK = 0xFFFF8000;
|
||||
|
||||
static bool test(JSFunction *fun, const Value &v) {
|
||||
uint32 mask = Masks[(fun->flags >> THISP_SHIFT) & THISP_MASK];
|
||||
return (((mask & DOUBLE_MASK) != 0) & v.isDouble()) |
|
||||
((mask & v.data.s.u.mask32) > JSVAL_MASK32_CLEAR);
|
||||
}
|
||||
};
|
||||
uint16 flags = fun->flags;
|
||||
return (v.isString() && !!(flags & JSFUN_THISP_STRING)) ||
|
||||
(v.isNumber() && !!(flags & JSFUN_THISP_NUMBER)) ||
|
||||
(v.isBoolean() && !!(flags & JSFUN_THISP_BOOLEAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* The js::InvokeArgumentsGuard passed to js_Invoke must come from an
|
||||
|
|
|
@ -105,7 +105,10 @@ ExtendedClass js_IteratorClass = {
|
|||
void
|
||||
NativeIterator::mark(JSTracer *trc)
|
||||
{
|
||||
MarkIdRange(trc, props_array, props_end, "props");
|
||||
if ((flags & JSITER_FOREACH) == 0)
|
||||
MarkIdRange(trc, (jsid *)props_array, (jsid *)props_end, "props");
|
||||
else
|
||||
MarkValueRange(trc, (Value *)props_array, (Value *)props_end, "props");
|
||||
MarkObject(trc, obj, "obj");
|
||||
}
|
||||
|
||||
|
@ -136,9 +139,9 @@ iterator_trace(JSTracer *trc, JSObject *obj)
|
|||
}
|
||||
|
||||
static inline bool
|
||||
NewKeyValuePair(JSContext *cx, jsid key, const Value &val, Value *rval)
|
||||
NewKeyValuePair(JSContext *cx, jsid id, const Value &val, Value *rval)
|
||||
{
|
||||
Value vec[2] = { ID_TO_VALUE(key), val };
|
||||
Value vec[2] = { IdToValue(id), val };
|
||||
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vec), vec);
|
||||
|
||||
JSObject *aobj = js_NewArrayObject(cx, 2, vec);
|
||||
|
@ -148,70 +151,133 @@ NewKeyValuePair(JSContext *cx, jsid key, const Value &val, Value *rval)
|
|||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static inline void
|
||||
Reverse(T *beg, T *end)
|
||||
{
|
||||
while (beg != end) {
|
||||
if (--end == beg)
|
||||
return;
|
||||
T tmp = *beg;
|
||||
*beg = *end;
|
||||
*end = tmp;
|
||||
++beg;
|
||||
}
|
||||
}
|
||||
|
||||
struct IterateKeyResults
|
||||
{
|
||||
AutoIdVector vec;
|
||||
IterateKeyResults(JSContext *cx) : vec(cx) {}
|
||||
|
||||
const jsid *begin() const { return vec.begin(); }
|
||||
size_t length() const { return vec.length(); }
|
||||
|
||||
void reverse(size_t startingAt) {
|
||||
Reverse(vec.begin() + startingAt, vec.end());
|
||||
}
|
||||
|
||||
JS_ALWAYS_INLINE bool addProperty(JSContext *, JSObject *, jsid id, uintN flags)
|
||||
{
|
||||
JS_ASSERT((flags & JSITER_FOREACH) == 0);
|
||||
return vec.append(id);
|
||||
}
|
||||
};
|
||||
|
||||
struct IterateValueResults
|
||||
{
|
||||
AutoValueVector vec;
|
||||
IterateValueResults(JSContext *cx) : vec(cx) {}
|
||||
|
||||
const Value *begin() const { return vec.begin(); }
|
||||
size_t length() const { return vec.length(); }
|
||||
|
||||
void reverse(size_t startingAt) {
|
||||
Reverse(vec.begin() + startingAt, vec.end());
|
||||
}
|
||||
|
||||
bool addProperty(JSContext *cx, JSObject *obj, jsid id, uintN flags)
|
||||
{
|
||||
JS_ASSERT(flags & JSITER_FOREACH);
|
||||
|
||||
if (!vec.growBy(1))
|
||||
return false;
|
||||
|
||||
/* Do the lookup on the original object instead of the prototype. */
|
||||
Value *vp = vec.end() - 1;
|
||||
if (!obj->getProperty(cx, id, vp))
|
||||
return false;
|
||||
if ((flags & JSITER_KEYVALUE) && !NewKeyValuePair(cx, id, *vp, vp))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct IdHashPolicy {
|
||||
typedef jsid Lookup;
|
||||
static HashNumber hash(jsid id) {
|
||||
return JSID_BITS(id);
|
||||
}
|
||||
static bool match(jsid id1, jsid id2) {
|
||||
return id1 == id2;
|
||||
}
|
||||
};
|
||||
|
||||
typedef HashSet<jsid, IdHashPolicy, ContextAllocPolicy> IdSet;
|
||||
|
||||
template <class ResultSet>
|
||||
static inline bool
|
||||
Enumerate(JSContext *cx, JSObject *obj, JSObject *pobj, jsid id,
|
||||
bool enumerable, uintN flags, HashSet<jsid>& ht,
|
||||
AutoValueVector& vec)
|
||||
bool enumerable, uintN flags, IdSet& seen, ResultSet &results)
|
||||
{
|
||||
JS_ASSERT(JSID_IS_INT(id) || JSID_IS_ATOM(id));
|
||||
|
||||
if (JS_LIKELY(!(flags & JSITER_OWNONLY))) {
|
||||
HashSet<jsid>::AddPtr p = ht.lookupForAdd(id);
|
||||
IdSet::AddPtr p = seen.lookupForAdd(id);
|
||||
/* property already encountered, done. */
|
||||
if (JS_UNLIKELY(!!p))
|
||||
return true;
|
||||
/* no need to add properties to the hash table at the end of the prototype chain */
|
||||
if (pobj->getProto() && !ht.add(p, id))
|
||||
if (pobj->getProto() && !seen.add(p, id))
|
||||
return false;
|
||||
}
|
||||
if (enumerable || (flags & JSITER_HIDDEN)) {
|
||||
if (!vec.append(ID_TO_VALUE(id)))
|
||||
return false;
|
||||
if (flags & JSITER_FOREACH) {
|
||||
Value *vp = vec.end() - 1;
|
||||
|
||||
/* Do the lookup on the original object instead of the prototype. */
|
||||
if (!obj->getProperty(cx, id, vp))
|
||||
return false;
|
||||
if ((flags & JSITER_KEYVALUE) && !NewKeyValuePair(cx, id, *vp, vp))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (enumerable || (flags & JSITER_HIDDEN))
|
||||
return results.addProperty(cx, obj, id, flags);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class ResultSet>
|
||||
static bool
|
||||
EnumerateNativeProperties(JSContext *cx, JSObject *obj, JSObject *pobj, uintN flags,
|
||||
HashSet<jsid> &ht, AutoValueVector& props)
|
||||
IdSet &seen, ResultSet &results)
|
||||
{
|
||||
AutoValueVector sprops(cx);
|
||||
|
||||
JS_LOCK_OBJ(cx, pobj);
|
||||
|
||||
size_t initialLength = results.length();
|
||||
|
||||
/* Collect all unique properties from this object's scope. */
|
||||
JSScope *scope = pobj->scope();
|
||||
for (JSScopeProperty *sprop = scope->lastProperty(); sprop; sprop = sprop->parent) {
|
||||
if (sprop->id != JSVAL_VOID &&
|
||||
if (!JSID_IS_DEFAULT_XML_NAMESPACE(sprop->id) &&
|
||||
!sprop->isAlias() &&
|
||||
!Enumerate(cx, obj, pobj, sprop->id, sprop->enumerable(), flags, ht, sprops)) {
|
||||
!Enumerate(cx, obj, pobj, sprop->id, sprop->enumerable(), flags, seen, results)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
while (sprops.length() > 0) {
|
||||
if (!props.append(sprops.back()))
|
||||
return false;
|
||||
sprops.popBack();
|
||||
}
|
||||
results.reverse(initialLength);
|
||||
|
||||
JS_UNLOCK_SCOPE(cx, scope);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class ResultSet>
|
||||
static bool
|
||||
EnumerateDenseArrayProperties(JSContext *cx, JSObject *obj, JSObject *pobj, uintN flags,
|
||||
HashSet<jsid> &ht, AutoValueVector& props)
|
||||
IdSet &seen, ResultSet &results)
|
||||
{
|
||||
size_t count = pobj->getDenseArrayCount();
|
||||
|
||||
|
@ -221,7 +287,7 @@ EnumerateDenseArrayProperties(JSContext *cx, JSObject *obj, JSObject *pobj, uint
|
|||
for (size_t i = 0; i < capacity; ++i, ++vp) {
|
||||
if (!vp->isMagic(JS_ARRAY_HOLE)) {
|
||||
/* Dense arrays never get so large that i would not fit into an integer id. */
|
||||
if (!Enumerate(cx, obj, pobj, INT_TO_JSID(i), true, flags, ht, props))
|
||||
if (!Enumerate(cx, obj, pobj, INT_TO_JSID(i), true, flags, seen, results))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -229,36 +295,55 @@ EnumerateDenseArrayProperties(JSContext *cx, JSObject *obj, JSObject *pobj, uint
|
|||
return true;
|
||||
}
|
||||
|
||||
inline void
|
||||
NativeIterator::init(JSObject *obj, uintN flags, uint32 *sarray, uint32 slength, uint32 key)
|
||||
{
|
||||
this->obj = obj;
|
||||
this->flags = flags;
|
||||
this->shapes_array = (uint32 *) this->props_end;
|
||||
this->shapes_length = slength;
|
||||
this->shapes_key = key;
|
||||
if (slength)
|
||||
memcpy(this->shapes_array, sarray, slength * sizeof(uint32));
|
||||
}
|
||||
|
||||
NativeIterator *
|
||||
NativeIterator::allocate(JSContext *cx, JSObject *obj, uintN flags, uint32 *sarray, uint32 slength,
|
||||
uint32 key, jsid *parray, uint32 plength)
|
||||
NativeIterator::allocateKeyIterator(JSContext *cx, uint32 slength,
|
||||
const jsid *parray, uint32 plength)
|
||||
{
|
||||
NativeIterator *ni = (NativeIterator *)
|
||||
cx->malloc(sizeof(NativeIterator) + plength * sizeof(jsid) + slength * sizeof(uint32));
|
||||
if (!ni)
|
||||
return NULL;
|
||||
ni->obj = obj;
|
||||
ni->props_array = ni->props_cursor = (jsid *) (ni + 1);
|
||||
ni->props_end = ni->props_array + plength;
|
||||
ni->props_end = (jsid *)ni->props_array + plength;
|
||||
if (plength)
|
||||
memcpy(ni->props_array, parray, plength * sizeof(jsid));
|
||||
ni->shapes_array = (uint32 *) ni->props_end;
|
||||
ni->shapes_length = slength;
|
||||
ni->shapes_key = key;
|
||||
ni->flags = flags;
|
||||
if (slength)
|
||||
memcpy(ni->shapes_array, sarray, slength * sizeof(uint32));
|
||||
return ni;
|
||||
}
|
||||
|
||||
static NativeIterator *
|
||||
Snapshot(JSContext *cx, JSObject *obj, uintN flags, uint32 *sarray, uint32 slength, uint32 key)
|
||||
NativeIterator *
|
||||
NativeIterator::allocateValueIterator(JSContext *cx, uint32 slength,
|
||||
const Value *parray, uint32 plength)
|
||||
{
|
||||
HashSet<jsid> ht(cx);
|
||||
if (!(flags & JSITER_OWNONLY) && !ht.init(32))
|
||||
NativeIterator *ni = (NativeIterator *)
|
||||
cx->malloc(sizeof(NativeIterator) + plength * sizeof(Value) + slength * sizeof(uint32));
|
||||
if (!ni)
|
||||
return NULL;
|
||||
ni->props_array = ni->props_cursor = (Value *) (ni + 1);
|
||||
ni->props_end = (Value *)ni->props_array + plength;
|
||||
if (plength)
|
||||
memcpy(ni->props_array, parray, plength * sizeof(Value));
|
||||
return ni;
|
||||
}
|
||||
|
||||
AutoValueVector props(cx);
|
||||
template <class ResultSet>
|
||||
static bool
|
||||
Snapshot(JSContext *cx, JSObject *obj, uintN flags, ResultSet &results)
|
||||
{
|
||||
IdSet seen(cx);
|
||||
if (!(flags & JSITER_OWNONLY) && !seen.init(32))
|
||||
return NULL;
|
||||
|
||||
JSObject *pobj = obj;
|
||||
while (pobj) {
|
||||
|
@ -267,45 +352,45 @@ Snapshot(JSContext *cx, JSObject *obj, uintN flags, uint32 *sarray, uint32 sleng
|
|||
pobj->map->ops->enumerate == js_Enumerate &&
|
||||
!(clasp->flags & JSCLASS_NEW_ENUMERATE)) {
|
||||
if (!clasp->enumerate(cx, pobj))
|
||||
return NULL;
|
||||
if (!EnumerateNativeProperties(cx, obj, pobj, flags, ht, props))
|
||||
return NULL;
|
||||
return false;
|
||||
if (!EnumerateNativeProperties(cx, obj, pobj, flags, seen, results))
|
||||
return false;
|
||||
} else if (pobj->isDenseArray()) {
|
||||
if (!EnumerateDenseArrayProperties(cx, obj, pobj, flags, ht, props))
|
||||
return NULL;
|
||||
if (!EnumerateDenseArrayProperties(cx, obj, pobj, flags, seen, results))
|
||||
return false;
|
||||
} else {
|
||||
if (pobj->isProxy()) {
|
||||
JSIdArray *ida;
|
||||
if (flags & JSITER_OWNONLY) {
|
||||
if (!JSProxy::enumerateOwn(cx, pobj, &ida))
|
||||
return NULL;
|
||||
return false;
|
||||
} else {
|
||||
if (!JSProxy::enumerate(cx, pobj, &ida))
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
AutoIdArray idar(cx, ida);
|
||||
for (size_t n = 0; n < size_t(ida->length); ++n) {
|
||||
if (!Enumerate(cx, obj, pobj, ida->vector[n], true, flags, ht, props))
|
||||
return NULL;
|
||||
if (!Enumerate(cx, obj, pobj, ida->vector[n], true, flags, seen, results))
|
||||
return false;
|
||||
}
|
||||
/* Proxy objects enumerate the prototype on their own, so we are done here. */
|
||||
break;
|
||||
}
|
||||
Value state;
|
||||
if (!pobj->enumerate(cx, JSENUMERATE_INIT, &state, NULL))
|
||||
return NULL;
|
||||
return false;
|
||||
if (state.isMagic(JS_NATIVE_ENUMERATE)) {
|
||||
if (!EnumerateNativeProperties(cx, obj, pobj, flags, ht, props))
|
||||
return NULL;
|
||||
if (!EnumerateNativeProperties(cx, obj, pobj, flags, seen, results))
|
||||
return false;
|
||||
} else {
|
||||
while (true) {
|
||||
jsid id;
|
||||
if (!pobj->enumerate(cx, JSENUMERATE_NEXT, &state, &id))
|
||||
return NULL;
|
||||
return false;
|
||||
if (state.isNull())
|
||||
break;
|
||||
if (!Enumerate(cx, obj, pobj, id, true, flags, ht, props))
|
||||
return NULL;
|
||||
if (!Enumerate(cx, obj, pobj, id, true, flags, seen, results))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -316,24 +401,55 @@ Snapshot(JSContext *cx, JSObject *obj, uintN flags, uint32 *sarray, uint32 sleng
|
|||
pobj = pobj->getProto();
|
||||
}
|
||||
|
||||
/* The cast is valid since jsid and Value have the same representation. */
|
||||
JS_STATIC_ASSERT(sizeof(Value) == sizeof(jsid));
|
||||
jsid *parray = reinterpret_cast<jsid *>(props.begin());
|
||||
|
||||
return NativeIterator::allocate(cx, obj, flags, sarray, slength, key, parray, props.length());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
static NativeIterator *
|
||||
SnapshotValues(JSContext *cx, JSObject *obj, uintN flags, uint32 *sarray, uint32 slength, uint32 key)
|
||||
{
|
||||
JS_ASSERT(flags & JSITER_FOREACH);
|
||||
|
||||
IterateValueResults results(cx);
|
||||
if (!Snapshot(cx, obj, flags, results))
|
||||
return NULL;
|
||||
|
||||
NativeIterator *ni = NativeIterator::allocateValueIterator(cx, slength,
|
||||
results.begin(), results.length());
|
||||
if (!ni)
|
||||
return NULL;
|
||||
ni->init(obj, flags, sarray, slength, key);
|
||||
return ni;
|
||||
}
|
||||
|
||||
static NativeIterator *
|
||||
SnapshotKeys(JSContext *cx, JSObject *obj, uintN flags, uint32 *sarray, uint32 slength, uint32 key)
|
||||
{
|
||||
JS_ASSERT(!(flags & JSITER_FOREACH));
|
||||
|
||||
IterateKeyResults results(cx);
|
||||
if (!Snapshot(cx, obj, flags, results))
|
||||
return NULL;
|
||||
|
||||
NativeIterator *ni = NativeIterator::allocateKeyIterator(cx, slength,
|
||||
results.begin(), results.length());
|
||||
if (!ni)
|
||||
return NULL;
|
||||
ni->init(obj, flags, sarray, slength, key);
|
||||
return ni;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
NativeIteratorToJSIdArray(JSContext *cx, NativeIterator *ni, JSIdArray **idap)
|
||||
{
|
||||
/* Morph the NativeIterator into a JSIdArray. The caller will deallocate it. */
|
||||
JS_ASSERT(sizeof(NativeIterator) > sizeof(JSIdArray));
|
||||
JS_ASSERT(!(ni->flags & JSITER_FOREACH));
|
||||
JS_ASSERT(ni->props_array == (jsid *) (ni + 1));
|
||||
size_t length = size_t(ni->props_end - ni->props_array);
|
||||
size_t length = size_t((jsid *)ni->props_end - (jsid *)ni->props_array);
|
||||
JSIdArray *ida = (JSIdArray *) (uintptr_t(ni->props_array) - (sizeof(JSIdArray) - sizeof(jsid)));
|
||||
ida->self = ni;
|
||||
ida->length = length;
|
||||
JS_ASSERT(&ida->vector[0] == (jsid *)&ni->props_array[0]);
|
||||
JS_ASSERT(&ida->vector[0] == (jsid *)ni->props_array);
|
||||
*idap = ida;
|
||||
return true;
|
||||
}
|
||||
|
@ -341,7 +457,7 @@ NativeIteratorToJSIdArray(JSContext *cx, NativeIterator *ni, JSIdArray **idap)
|
|||
bool
|
||||
GetPropertyNames(JSContext *cx, JSObject *obj, uintN flags, JSIdArray **idap)
|
||||
{
|
||||
NativeIterator *ni = Snapshot(cx, obj, flags & (JSITER_OWNONLY | JSITER_HIDDEN), NULL, 0, true);
|
||||
NativeIterator *ni = SnapshotKeys(cx, obj, flags & (JSITER_OWNONLY | JSITER_HIDDEN), NULL, 0, true);
|
||||
if (!ni)
|
||||
return false;
|
||||
return NativeIteratorToJSIdArray(cx, ni, idap);
|
||||
|
@ -417,16 +533,18 @@ RegisterEnumerator(JSContext *cx, JSObject *iterobj, NativeIterator *ni)
|
|||
bool
|
||||
JSIdArrayToIterator(JSContext *cx, JSObject *obj, uintN flags, JSIdArray *ida, Value *vp)
|
||||
{
|
||||
JS_ASSERT((flags & JSITER_FOREACH) == 0);
|
||||
|
||||
JSObject *iterobj = NewIteratorObject(cx, flags);
|
||||
if (!iterobj)
|
||||
return false;
|
||||
|
||||
vp->setNonFunObj(*iterobj);
|
||||
|
||||
NativeIterator *ni = NativeIterator::allocate(cx, obj, flags, NULL, 0, 0,
|
||||
ida->vector, ida->length);
|
||||
NativeIterator *ni = NativeIterator::allocateKeyIterator(cx, 0, ida->vector, ida->length);
|
||||
if (!ni)
|
||||
return false;
|
||||
ni->init(obj, flags, NULL, 0, 0);
|
||||
|
||||
iterobj->setNativeIterator(ni);
|
||||
|
||||
|
@ -500,7 +618,9 @@ GetIterator(JSContext *cx, JSObject *obj, uintN flags, Value *vp)
|
|||
/* Store in *vp to protect it from GC (callers must root vp). */
|
||||
vp->setNonFunObj(*iterobj);
|
||||
|
||||
NativeIterator *ni = Snapshot(cx, obj, flags, shapes.begin(), shapes.length(), key);
|
||||
NativeIterator *ni = (flags & JSITER_FOREACH)
|
||||
? SnapshotValues(cx, obj, flags, shapes.begin(), shapes.length(), key)
|
||||
: SnapshotKeys(cx, obj, flags, shapes.begin(), shapes.length(), key);
|
||||
if (!ni)
|
||||
return false;
|
||||
|
||||
|
@ -681,10 +801,11 @@ js_SuppressDeletedProperty(JSContext *cx, JSObject *obj, jsid id)
|
|||
while (iterobj) {
|
||||
again:
|
||||
NativeIterator *ni = iterobj->getNativeIterator();
|
||||
if (ni->obj == obj && ni->props_cursor < ni->props_end) {
|
||||
/* This only works for identified surpressed keys, not values. */
|
||||
if ((ni->flags & JSITER_FOREACH) && ni->obj == obj && ni->props_cursor < ni->props_end) {
|
||||
/* Check whether id is still to come. */
|
||||
jsid *props_cursor = ni->props_cursor;
|
||||
jsid *props_end = ni->props_end;
|
||||
jsid *props_cursor = (jsid *)ni->props_cursor;
|
||||
jsid *props_end = (jsid *)ni->props_end;
|
||||
for (jsid *idp = props_cursor; idp < props_end; ++idp) {
|
||||
if (*idp == id) {
|
||||
/*
|
||||
|
@ -723,10 +844,10 @@ js_SuppressDeletedProperty(JSContext *cx, JSObject *obj, jsid id)
|
|||
* If it is the next property to be enumerated, just skip it.
|
||||
*/
|
||||
if (idp == props_cursor) {
|
||||
ni->props_cursor++;
|
||||
ni->props_cursor = (jsid *)ni->props_cursor + 1;
|
||||
} else {
|
||||
memmove(idp, idp + 1, (props_end - (idp + 1)) * sizeof(jsid));
|
||||
ni->props_end--;
|
||||
ni->props_end = (jsid *)ni->props_end - 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -792,7 +913,13 @@ js_IteratorNext(JSContext *cx, JSObject *iterobj, Value *rval)
|
|||
*/
|
||||
NativeIterator *ni = iterobj->getNativeIterator();
|
||||
JS_ASSERT(ni->props_cursor < ni->props_end);
|
||||
*rval = ID_TO_VALUE(*ni->props_cursor++);
|
||||
if ((ni->flags & JSITER_FOREACH) == 0) {
|
||||
*rval = IdToValue(ni->currentId());
|
||||
ni->incIdCursor();
|
||||
} else {
|
||||
*rval = ni->currentValue();
|
||||
ni->incValueCursor();
|
||||
}
|
||||
|
||||
if (rval->isString() || (ni->flags & JSITER_FOREACH))
|
||||
return true;
|
||||
|
@ -819,9 +946,9 @@ js_IteratorNext(JSContext *cx, JSObject *iterobj, Value *rval)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
stopiter_hasInstance(JSContext *cx, JSObject *obj, Value v, JSBool *bp)
|
||||
stopiter_hasInstance(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
|
||||
{
|
||||
*bp = js_ValueIsStopIteration(v);
|
||||
*bp = js_ValueIsStopIteration(*v);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,18 +60,40 @@
|
|||
|
||||
struct NativeIterator {
|
||||
JSObject *obj;
|
||||
jsid *props_array;
|
||||
jsid *props_cursor;
|
||||
jsid *props_end;
|
||||
void *props_array;
|
||||
void *props_cursor;
|
||||
void *props_end;
|
||||
uint32 *shapes_array;
|
||||
uint32 shapes_length;
|
||||
uint32 shapes_key;
|
||||
uintN flags;
|
||||
JSObject *next;
|
||||
|
||||
static NativeIterator *allocate(JSContext *cx, JSObject *obj, uintN flags,
|
||||
uint32 *sarray, uint32 slength, uint32 key,
|
||||
jsid *parray, uint32 plength);
|
||||
jsid currentId() const {
|
||||
JS_ASSERT((flags & JSITER_FOREACH) == 0);
|
||||
return *reinterpret_cast<jsid *>(props_cursor);
|
||||
}
|
||||
|
||||
void incIdCursor() {
|
||||
JS_ASSERT((flags & JSITER_FOREACH) == 0);
|
||||
props_cursor = reinterpret_cast<jsid *>(props_cursor) + 1;
|
||||
}
|
||||
|
||||
const js::Value ¤tValue() const {
|
||||
JS_ASSERT((flags & JSITER_FOREACH) != 0);
|
||||
return *reinterpret_cast<js::Value *>(props_cursor);
|
||||
}
|
||||
|
||||
void incValueCursor() {
|
||||
JS_ASSERT((flags & JSITER_FOREACH) != 0);
|
||||
props_cursor = reinterpret_cast<js::Value *>(props_cursor) + 1;
|
||||
}
|
||||
|
||||
static NativeIterator *allocateKeyIterator(JSContext *cx, uint32 slength,
|
||||
const jsid *parray, uint32 plength);
|
||||
static NativeIterator *allocateValueIterator(JSContext *cx, uint32 slength,
|
||||
const js::Value *parray, uint32 plength);
|
||||
void init(JSObject *obj, uintN flags, uint32 *sarray, uint32 slength, uint32 key);
|
||||
|
||||
void mark(JSTracer *trc);
|
||||
};
|
||||
|
|
|
@ -1305,12 +1305,3 @@ js_strtointeger(JSContext *cx, const jschar *s, const jschar *send,
|
|||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
bool
|
||||
Value::isIntDouble() const {
|
||||
if (!isDouble())
|
||||
return false;
|
||||
double d = asDouble();
|
||||
return !JSDOUBLE_IS_NEGZERO(d) && (d == jsint(d));
|
||||
}
|
||||
|
||||
|
|
|
@ -625,7 +625,7 @@ obj_toSource(JSContext *cx, uintN argc, Value *vp)
|
|||
* Convert id to a value and then to a string. Decide early whether we
|
||||
* prefer get/set or old getter/setter syntax.
|
||||
*/
|
||||
idstr = js_ValueToString(cx, ID_TO_VALUE(id));
|
||||
idstr = js_ValueToString(cx, IdToValue(id));
|
||||
if (!idstr) {
|
||||
ok = JS_FALSE;
|
||||
obj2->dropProperty(cx, prop);
|
||||
|
@ -1407,7 +1407,7 @@ obj_watch_handler(JSContext *cx, JSObject *obj, jsid id, jsval old,
|
|||
return JS_TRUE;
|
||||
generation = cx->resolvingTable->generation;
|
||||
|
||||
argv[0] = ID_TO_VALUE(id);
|
||||
argv[0] = IdToValue(id);
|
||||
argv[1] = Valueify(old);
|
||||
argv[2] = Valueify(*nvp);
|
||||
ok = InternalCall(cx, obj, ObjectOrNullTag(callable), 3, argv, Valueify(nvp));
|
||||
|
@ -1913,7 +1913,7 @@ obj_keys(JSContext *cx, uintN argc, Value *vp)
|
|||
* to by a QName, actually appears as a string jsid -- but in the
|
||||
* interests of fidelity we pass object jsids through unchanged.
|
||||
*/
|
||||
aobj->setDenseArrayElement(i, ID_TO_VALUE(id));
|
||||
aobj->setDenseArrayElement(i, IdToValue(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2053,7 +2053,7 @@ Reject(JSContext *cx, uintN errorNumber, bool throwError, jsid id, bool *rval)
|
|||
{
|
||||
if (throwError) {
|
||||
jsid idstr;
|
||||
if (!js_ValueToStringId(cx, ID_TO_VALUE(id), &idstr))
|
||||
if (!js_ValueToStringId(cx, IdToValue(id), &idstr))
|
||||
return JS_FALSE;
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, errorNumber,
|
||||
JS_GetStringBytes(JSID_TO_STRING(idstr)));
|
||||
|
@ -2369,7 +2369,7 @@ DefinePropertyOnArray(JSContext *cx, JSObject *obj, const PropDesc &desc,
|
|||
|
||||
jsuint oldLen = obj->getArrayLength();
|
||||
|
||||
if (desc.id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
if (JSID_IS_ATOM(desc.id, cx->runtime->atomState.lengthAtom)) {
|
||||
/*
|
||||
* Our optimization of storage of the length property of arrays makes
|
||||
* it very difficult to properly implement defining the property. For
|
||||
|
@ -4012,8 +4012,8 @@ js_CheckForStringIndex(jsid id)
|
|||
if (cp != end || (negative && index == 0))
|
||||
return id;
|
||||
|
||||
if (oldIndex < JSVAL_INT_MAX / 10 ||
|
||||
(oldIndex == JSVAL_INT_MAX / 10 && c <= (JSVAL_INT_MAX % 10))) {
|
||||
if (oldIndex < JSID_INT_MAX / 10 ||
|
||||
(oldIndex == JSID_INT_MAX / 10 && c <= (JSID_INT_MAX % 10))) {
|
||||
if (negative)
|
||||
index = 0 - index;
|
||||
id = INT_TO_JSID((jsint)index);
|
||||
|
@ -4859,7 +4859,7 @@ js_GetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN getHow,
|
|||
* XXX do not warn about missing __iterator__ as the function
|
||||
* may be called from JS_GetMethodById. See bug 355145.
|
||||
*/
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.iteratorAtom))
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.iteratorAtom))
|
||||
return JS_TRUE;
|
||||
|
||||
/* Do not warn about tests like (obj[prop] == undefined). */
|
||||
|
@ -4877,7 +4877,7 @@ js_GetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN getHow,
|
|||
|
||||
/* Ok, bad undefined property reference: whine about it. */
|
||||
if (!js_ReportValueErrorFlags(cx, flags, JSMSG_UNDEFINED_PROP,
|
||||
JSDVG_IGNORE_STACK, ID_TO_VALUE(id),
|
||||
JSDVG_IGNORE_STACK, IdToValue(id),
|
||||
NULL, NULL, NULL)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -4953,7 +4953,7 @@ JSBool
|
|||
ReportReadOnly(JSContext* cx, jsid id, uintN flags)
|
||||
{
|
||||
return js_ReportValueErrorFlags(cx, flags, JSMSG_READ_ONLY,
|
||||
JSDVG_IGNORE_STACK, ID_TO_VALUE(id), NULL,
|
||||
JSDVG_IGNORE_STACK, IdToValue(id), NULL,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
|
@ -5652,7 +5652,7 @@ js_Construct(JSContext *cx, JSObject *obj, uintN argc, Value *argv, Value *rval)
|
|||
}
|
||||
|
||||
JSBool
|
||||
js_HasInstance(JSContext *cx, JSObject *obj, Value v, JSBool *bp)
|
||||
js_HasInstance(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
|
||||
{
|
||||
Class *clasp = obj->getClass();
|
||||
if (clasp->hasInstance)
|
||||
|
@ -6401,8 +6401,8 @@ DumpValue(const Value &val)
|
|||
JS_FRIEND_API(void)
|
||||
DumpId(jsid id)
|
||||
{
|
||||
fprintf(stderr, "jsid %p = ", (void *) id);
|
||||
dumpValue(ID_TO_VALUE(id));
|
||||
fprintf(stderr, "jsid %p = ", (void *) JSID_BITS(id));
|
||||
dumpValue(IdToValue(id));
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
|
@ -6425,7 +6425,7 @@ dumpScopeProp(JSScopeProperty *sprop)
|
|||
else if (JSID_IS_INT(id))
|
||||
fprintf(stderr, "%d", (int) JSID_TO_INT(id));
|
||||
else
|
||||
fprintf(stderr, "unknown jsid %p", (void *) id);
|
||||
fprintf(stderr, "unknown jsid %p", (void *) JSID_BITS(id));
|
||||
fprintf(stderr, ": slot %d", sprop->slot);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ CastAsObject(PropertyOp op)
|
|||
}
|
||||
|
||||
inline Value
|
||||
CastAsObjectJSVal(PropertyOp op)
|
||||
CastAsObjectJsval(PropertyOp op)
|
||||
{
|
||||
return ObjectTag(*CastAsObject(op));
|
||||
}
|
||||
|
@ -1242,7 +1242,7 @@ js_Construct(JSContext *cx, JSObject *obj, uintN argc, js::Value *argv,
|
|||
js::Value *rval);
|
||||
|
||||
extern JSBool
|
||||
js_HasInstance(JSContext *cx, JSObject *obj, js::Value v, JSBool *bp);
|
||||
js_HasInstance(JSContext *cx, JSObject *obj, const js::Value *v, JSBool *bp);
|
||||
|
||||
extern JSBool
|
||||
js_SetProtoOrParent(JSContext *cx, JSObject *obj, uint32 slot, JSObject *pobj,
|
||||
|
@ -1312,10 +1312,6 @@ js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, const js::Value &
|
|||
/*
|
||||
* Precondition: obj must be locked.
|
||||
*/
|
||||
extern JSBool
|
||||
js_ReallocSlots(JSContext *cx, JSObject *obj, uint32 nslots,
|
||||
JSBool exactAllocation);
|
||||
|
||||
extern JSObject *
|
||||
js_CheckScopeChainValidity(JSContext *cx, JSObject *scopeobj, const char *caller);
|
||||
|
||||
|
@ -1340,7 +1336,7 @@ extern JSBool
|
|||
js_ReportGetterOnlyAssignment(JSContext *cx);
|
||||
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
js_GetterOnlyPropertyStub(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
js_GetterOnlyPropertyStub(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
#ifdef DEBUG
|
||||
namespace js {
|
||||
|
|
|
@ -285,7 +285,7 @@ JO(JSContext *cx, jsval *vp, StringifyContext *scx)
|
|||
outputValue = JSVAL_VOID;
|
||||
|
||||
if (!usingWhitelist) {
|
||||
if (!js_ValueToStringId(cx, ID_TO_VALUE(ida[i]), &id))
|
||||
if (!js_ValueToStringId(cx, IdToValue(ida[i]), &id))
|
||||
return JS_FALSE;
|
||||
} else {
|
||||
// skip non-index properties
|
||||
|
@ -331,7 +331,7 @@ JO(JSContext *cx, jsval *vp, StringifyContext *scx)
|
|||
return JS_FALSE;
|
||||
|
||||
// Be careful below, this string is weakly rooted
|
||||
JSString *s = js_ValueToString(cx, ID_TO_VALUE(id));
|
||||
JSString *s = js_ValueToString(cx, IdToValue(id));
|
||||
if (!s)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -402,7 +402,7 @@ static JSBool
|
|||
CallReplacerFunction(JSContext *cx, jsid id, JSObject *holder, StringifyContext *scx, jsval *vp)
|
||||
{
|
||||
if (scx->replacer && scx->replacer->isCallable()) {
|
||||
jsval vec[2] = { ID_TO_JSVAL(id), *vp};
|
||||
jsval vec[2] = { IdToJsval(id), *vp};
|
||||
if (!JS_CallFunctionValue(cx, holder, OBJECT_TO_JSVAL(scx->replacer), 2, vec, vp))
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ Walk(JSContext *cx, jsid id, JSObject *holder, jsval reviver, jsval *vp)
|
|||
|
||||
// return reviver.call(holder, key, value);
|
||||
jsval value = *vp;
|
||||
JSString *key = js_ValueToString(cx, ID_TO_VALUE(id));
|
||||
JSString *key = js_ValueToString(cx, IdToValue(id));
|
||||
if (!key)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -443,7 +443,7 @@ END_CASE(JSOP_ANDX)
|
|||
JS_BEGIN_MACRO \
|
||||
const Value &idval_ = regs.sp[n]; \
|
||||
int32_t i_; \
|
||||
if (ValueFitsInInt32(idval_, &i_)) { \
|
||||
if (ValueFitsInInt32(idval_, &i_) && INT_FITS_IN_JSID(i_)) { \
|
||||
id = INT_TO_JSID(i_); \
|
||||
} else { \
|
||||
if (!js_InternNonIntElementId(cx, obj, idval_, &id, ®s.sp[n])) \
|
||||
|
@ -830,7 +830,7 @@ END_CASE(JSOP_BITAND)
|
|||
#define EXTENDED_EQUALITY_OP(OP) \
|
||||
if (((clasp = l->getClass())->flags & JSCLASS_IS_EXTENDED) && \
|
||||
((ExtendedClass *)clasp)->equality) { \
|
||||
if (!((ExtendedClass *)clasp)->equality(cx, l, rval, &cond)) \
|
||||
if (!((ExtendedClass *)clasp)->equality(cx, l, &rval, &cond)) \
|
||||
goto error; \
|
||||
cond = cond OP JS_TRUE; \
|
||||
} else
|
||||
|
@ -870,7 +870,7 @@ END_CASE(JSOP_BITAND)
|
|||
DEFAULT_VALUE(cx, -2, JSTYPE_VOID, lval); \
|
||||
if (rval.isObject()) \
|
||||
DEFAULT_VALUE(cx, -1, JSTYPE_VOID, rval); \
|
||||
if (BothString(lval, rval)) { \
|
||||
if (lval.isString() && rval.isString()) { \
|
||||
JSString *l = lval.asString(), *r = rval.asString(); \
|
||||
cond = js_EqualStrings(l, r) OP JS_TRUE; \
|
||||
} else { \
|
||||
|
@ -956,14 +956,14 @@ END_CASE(JSOP_CASEX)
|
|||
Value lval = regs.sp[-2]; \
|
||||
bool cond; \
|
||||
/* Optimize for two int-tagged operands (typical loop control). */ \
|
||||
if (BothInt32(lval, rval)) { \
|
||||
if (lval.isInt32() && rval.isInt32()) { \
|
||||
cond = lval.asInt32() OP rval.asInt32(); \
|
||||
} else { \
|
||||
if (lval.isObject()) \
|
||||
DEFAULT_VALUE(cx, -2, JSTYPE_NUMBER, lval); \
|
||||
if (rval.isObject()) \
|
||||
DEFAULT_VALUE(cx, -1, JSTYPE_NUMBER, rval); \
|
||||
if (BothString(lval, rval)) { \
|
||||
if (lval.isString() && rval.isString()) { \
|
||||
JSString *l = lval.asString(), *r = rval.asString(); \
|
||||
cond = js_CompareStrings(l, r) OP 0; \
|
||||
} else { \
|
||||
|
@ -1041,7 +1041,7 @@ BEGIN_CASE(JSOP_ADD)
|
|||
Value rval = regs.sp[-1];
|
||||
Value lval = regs.sp[-2];
|
||||
|
||||
if (BothInt32(lval, rval)) {
|
||||
if (lval.isInt32() && rval.isInt32()) {
|
||||
int32_t l = lval.asInt32(), r = rval.asInt32();
|
||||
int32_t sum = l + r;
|
||||
regs.sp--;
|
||||
|
@ -1338,7 +1338,7 @@ BEGIN_CASE(JSOP_ELEMDEC)
|
|||
* Delay fetching of id until we have the object to ensure the proper
|
||||
* evaluation order. See bug 372331.
|
||||
*/
|
||||
id = 0;
|
||||
id = JSID_VOID;
|
||||
i = -2;
|
||||
goto fetch_incop_obj;
|
||||
|
||||
|
@ -1352,7 +1352,7 @@ BEGIN_CASE(JSOP_PROPDEC)
|
|||
|
||||
fetch_incop_obj:
|
||||
FETCH_OBJECT(cx, i, obj);
|
||||
if (id == 0)
|
||||
if (JSID_IS_VOID(id))
|
||||
FETCH_ELEMENT_ID(obj, -1, id);
|
||||
goto do_incop;
|
||||
|
||||
|
@ -1653,7 +1653,7 @@ BEGIN_CASE(JSOP_LENGTH)
|
|||
JSObject *obj = &vp->asObject();
|
||||
if (obj->isArray()) {
|
||||
jsuint length = obj->getArrayLength();
|
||||
regs.sp[-1].setDouble(length);
|
||||
regs.sp[-1].setNumber(length);
|
||||
} else if (obj->isArguments() && !obj->isArgsLengthOverridden()) {
|
||||
uint32 length = obj->getArgsLength();
|
||||
JS_ASSERT(length < INT32_MAX);
|
||||
|
@ -1755,8 +1755,7 @@ BEGIN_CASE(JSOP_CALLPROP)
|
|||
if (lval.isPrimitive()) {
|
||||
/* FIXME: https://bugzilla.mozilla.org/show_bug.cgi?id=412571 */
|
||||
if (!rval.isFunObj() ||
|
||||
!PrimitiveValue::test(GET_FUNCTION_PRIVATE(cx, &rval.asFunObj()),
|
||||
lval)) {
|
||||
!PrimitiveThisTest(GET_FUNCTION_PRIVATE(cx, &rval.asFunObj()), lval)) {
|
||||
if (!js_PrimitiveToObject(cx, ®s.sp[-1]))
|
||||
goto error;
|
||||
}
|
||||
|
@ -2014,8 +2013,9 @@ BEGIN_CASE(JSOP_GETELEM)
|
|||
Value rval;
|
||||
jsid id;
|
||||
if (rref.isInt32()) {
|
||||
int32_t i = rref.asInt32();
|
||||
if (obj->isDenseArray()) {
|
||||
jsuint idx = jsuint(rref.asInt32());
|
||||
jsuint idx = jsuint(i);
|
||||
|
||||
if (idx < obj->getArrayLength() &&
|
||||
idx < obj->getDenseArrayCapacity()) {
|
||||
|
@ -2031,7 +2031,7 @@ BEGIN_CASE(JSOP_GETELEM)
|
|||
&& !GetArgsPrivateNative(obj)
|
||||
#endif
|
||||
) {
|
||||
uint32 arg = uint32(rref.asInt32());
|
||||
uint32 arg = uint32(i);
|
||||
|
||||
if (arg < obj->getArgsLength()) {
|
||||
JSStackFrame *afp = (JSStackFrame *) obj->getPrivate();
|
||||
|
@ -2046,8 +2046,12 @@ BEGIN_CASE(JSOP_GETELEM)
|
|||
copyFrom = ®s.sp[-1];
|
||||
}
|
||||
}
|
||||
id = INT_TO_JSID(rref.asInt32());
|
||||
if (JS_LIKELY(INT_FITS_IN_JSID(i)))
|
||||
id = INT_TO_JSID(i);
|
||||
else
|
||||
goto intern_big_int;
|
||||
} else {
|
||||
intern_big_int:
|
||||
if (!js_InternNonIntElementId(cx, obj, rref, &id))
|
||||
goto error;
|
||||
}
|
||||
|
@ -2347,7 +2351,7 @@ BEGIN_CASE(JSOP_APPLY)
|
|||
DTrace::enterJSFun(cx, NULL, fun, fp, argc, vp + 2, vp);
|
||||
|
||||
JS_ASSERT(fun->u.n.extra == 0);
|
||||
JS_ASSERT(vp[1].isObjectOrNull() || PrimitiveValue::test(fun, vp[1]));
|
||||
JS_ASSERT(vp[1].isObjectOrNull() || PrimitiveThisTest(fun, vp[1]));
|
||||
JSBool ok = ((FastNative) fun->u.n.native)(cx, argc, vp);
|
||||
DTrace::exitJSFun(cx, NULL, fun, *vp, vp);
|
||||
regs.sp = vp + 1;
|
||||
|
@ -3392,7 +3396,7 @@ BEGIN_CASE(JSOP_SETTER)
|
|||
}
|
||||
case JSOP_SETELEM:
|
||||
rval = regs.sp[-1];
|
||||
id = 0;
|
||||
id = JSID_VOID;
|
||||
i = -2;
|
||||
gs_pop_lval:
|
||||
FETCH_OBJECT(cx, i - 1, obj);
|
||||
|
@ -3413,7 +3417,7 @@ BEGIN_CASE(JSOP_SETTER)
|
|||
|
||||
JS_ASSERT(regs.sp - fp->base() >= 3);
|
||||
rval = regs.sp[-1];
|
||||
id = 0;
|
||||
id = JSID_VOID;
|
||||
i = -2;
|
||||
gs_get_lval:
|
||||
{
|
||||
|
@ -3425,7 +3429,7 @@ BEGIN_CASE(JSOP_SETTER)
|
|||
}
|
||||
|
||||
/* Ensure that id has a type suitable for use with obj. */
|
||||
if (id == 0)
|
||||
if (JSID_IS_VOID(id))
|
||||
FETCH_ELEMENT_ID(obj, i, id);
|
||||
|
||||
if (!js_IsCallable(rval)) {
|
||||
|
@ -3882,7 +3886,7 @@ BEGIN_CASE(JSOP_INSTANCEOF)
|
|||
}
|
||||
const Value &lref = regs.sp[-2];
|
||||
JSBool cond = JS_FALSE;
|
||||
if (!obj->map->ops->hasInstance(cx, obj, lref, &cond))
|
||||
if (!obj->map->ops->hasInstance(cx, obj, &lref, &cond))
|
||||
goto error;
|
||||
regs.sp--;
|
||||
regs.sp[-1].setBoolean(cond);
|
||||
|
@ -3931,7 +3935,7 @@ BEGIN_CASE(JSOP_ANYNAME)
|
|||
jsid id;
|
||||
if (!js_GetAnyName(cx, &id))
|
||||
goto error;
|
||||
PUSH_COPY(ID_TO_VALUE(id));
|
||||
PUSH_COPY(IdToValue(id));
|
||||
}
|
||||
END_CASE(JSOP_ANYNAME)
|
||||
|
||||
|
@ -4014,7 +4018,7 @@ BEGIN_CASE(JSOP_BINDXMLNAME)
|
|||
if (!js_FindXMLProperty(cx, lval, &obj, &id))
|
||||
goto error;
|
||||
regs.sp[-1].setObjectOrNull(obj);
|
||||
PUSH_COPY(ID_TO_VALUE(id));
|
||||
PUSH_COPY(IdToValue(id));
|
||||
}
|
||||
END_CASE(JSOP_BINDXMLNAME)
|
||||
|
||||
|
|
|
@ -235,8 +235,8 @@ PropertyTree::insertChild(JSContext *cx, JSScopeProperty *parent,
|
|||
{
|
||||
JS_ASSERT(parent);
|
||||
JS_ASSERT(!child->parent);
|
||||
JS_ASSERT(!JSVAL_IS_NULL(parent->id));
|
||||
JS_ASSERT(!JSVAL_IS_NULL(child->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(parent->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(child->id));
|
||||
|
||||
JSScopeProperty **childp = &parent->kids;
|
||||
if (JSScopeProperty *kids = *childp) {
|
||||
|
@ -332,7 +332,7 @@ PropertyTree::removeChild(JSContext *cx, JSScopeProperty *child)
|
|||
|
||||
JSScopeProperty *parent = child->parent;
|
||||
JS_ASSERT(parent);
|
||||
JS_ASSERT(!JSVAL_IS_NULL(parent->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(parent->id));
|
||||
|
||||
JSScopeProperty *kids = parent->kids;
|
||||
if (!KIDS_IS_CHUNKY(kids)) {
|
||||
|
@ -469,7 +469,7 @@ PropertyTree::getChild(JSContext *cx, JSScopeProperty *parent, uint32 shape,
|
|||
if (sprop)
|
||||
goto out;
|
||||
} else {
|
||||
JS_ASSERT(!JSVAL_IS_NULL(parent->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(parent->id));
|
||||
|
||||
/*
|
||||
* Because chunks are appended at the end and never deleted except by
|
||||
|
@ -617,7 +617,7 @@ js_MeterPropertyTree(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 number,
|
|||
void
|
||||
JSScopeProperty::dump(JSContext *cx, FILE *fp)
|
||||
{
|
||||
JS_ASSERT(!JSVAL_IS_NULL(id));
|
||||
JS_ASSERT(!JSID_IS_VOID(id));
|
||||
|
||||
if (JSID_IS_INT(id)) {
|
||||
fprintf(fp, "[%ld]", (long) JSID_TO_INT(id));
|
||||
|
@ -627,7 +627,7 @@ JSScopeProperty::dump(JSContext *cx, FILE *fp)
|
|||
str = JSID_TO_STRING(id);
|
||||
} else {
|
||||
JS_ASSERT(JSID_IS_OBJECT(id));
|
||||
str = js_ValueToString(cx, ID_TO_VALUE(id));
|
||||
str = js_ValueToString(cx, IdToValue(id));
|
||||
fputs("object ", fp);
|
||||
}
|
||||
if (!str)
|
||||
|
@ -725,7 +725,7 @@ OrphanNodeKids(JSContext *cx, JSScopeProperty *sprop)
|
|||
if (!kid)
|
||||
break;
|
||||
|
||||
if (!JSVAL_IS_NULL(kid->id)) {
|
||||
if (!JSID_IS_VOID(kid->id)) {
|
||||
JS_ASSERT(kid->parent == sprop);
|
||||
kid->parent = NULL;
|
||||
}
|
||||
|
@ -734,7 +734,7 @@ OrphanNodeKids(JSContext *cx, JSScopeProperty *sprop)
|
|||
} else {
|
||||
JSScopeProperty *kid = kids;
|
||||
|
||||
if (!JSVAL_IS_NULL(kid->id)) {
|
||||
if (!JSID_IS_VOID(kid->id)) {
|
||||
JS_ASSERT(kid->parent == sprop);
|
||||
kid->parent = NULL;
|
||||
}
|
||||
|
@ -857,7 +857,7 @@ js::SweepScopeProperties(JSContext *cx)
|
|||
|
||||
for (JSScopeProperty *sprop = (JSScopeProperty *) a->base; sprop < limit; sprop++) {
|
||||
/* If the id is null, sprop is already on the freelist. */
|
||||
if (JSVAL_IS_NULL(sprop->id))
|
||||
if (JSID_IS_VOID(sprop->id))
|
||||
continue;
|
||||
|
||||
/*
|
||||
|
|
|
@ -108,7 +108,7 @@ JSProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id,
|
|||
return true;
|
||||
}
|
||||
if (desc.attrs & JSPROP_GETTER) {
|
||||
return InternalGetOrSet(cx, proxy, id, CastAsObjectJSVal(desc.getter),
|
||||
return InternalGetOrSet(cx, proxy, id, CastAsObjectJsval(desc.getter),
|
||||
JSACC_READ, 0, 0, vp);
|
||||
}
|
||||
if (desc.attrs & JSPROP_SHORTID)
|
||||
|
@ -127,7 +127,7 @@ JSProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id,
|
|||
if (desc.obj) {
|
||||
if (desc.setter) {
|
||||
if (desc.attrs & JSPROP_SETTER) {
|
||||
return InternalGetOrSet(cx, proxy, id, CastAsObjectJSVal(desc.setter),
|
||||
return InternalGetOrSet(cx, proxy, id, CastAsObjectJsval(desc.setter),
|
||||
JSACC_READ, 0, 0, vp);
|
||||
}
|
||||
if (desc.attrs & JSPROP_SHORTID)
|
||||
|
@ -144,7 +144,7 @@ JSProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id,
|
|||
if (desc.obj) {
|
||||
if (desc.setter) {
|
||||
if (desc.attrs & JSPROP_SETTER) {
|
||||
return InternalGetOrSet(cx, proxy, id, CastAsObjectJSVal(desc.setter),
|
||||
return InternalGetOrSet(cx, proxy, id, CastAsObjectJsval(desc.setter),
|
||||
JSACC_READ, 0, 0, vp);
|
||||
}
|
||||
if (desc.attrs & JSPROP_SHORTID)
|
||||
|
@ -191,10 +191,15 @@ bool
|
|||
JSProxyHandler::iterate(JSContext *cx, JSObject *proxy, uintN flags, Value *vp)
|
||||
{
|
||||
JS_ASSERT(OperationInProgress(cx, proxy));
|
||||
|
||||
/* TODO: https://bugzilla.mozilla.org/show_bug.cgi?id=572298 */
|
||||
JS_ASSERT((flags & JSITER_FOREACH) == 0);
|
||||
|
||||
JSIdArray *ida;
|
||||
if (!enumerate(cx, proxy, &ida))
|
||||
return false;
|
||||
AutoIdArray idar(cx, ida);
|
||||
|
||||
return JSIdArrayToIterator(cx, proxy, flags, ida, vp);
|
||||
}
|
||||
|
||||
|
@ -253,7 +258,7 @@ Trap(JSContext *cx, JSObject *handler, Value fval, uintN argc, Value* argv, Valu
|
|||
static bool
|
||||
Trap1(JSContext *cx, JSObject *handler, Value fval, jsid id, Value *rval)
|
||||
{
|
||||
JSString *str = js_ValueToString(cx, ID_TO_VALUE(id));
|
||||
JSString *str = js_ValueToString(cx, IdToValue(id));
|
||||
if (!str)
|
||||
return false;
|
||||
rval->setString(str);
|
||||
|
@ -263,7 +268,7 @@ Trap1(JSContext *cx, JSObject *handler, Value fval, jsid id, Value *rval)
|
|||
static bool
|
||||
Trap2(JSContext *cx, JSObject *handler, Value fval, jsid id, Value v, Value *rval)
|
||||
{
|
||||
JSString *str = js_ValueToString(cx, ID_TO_VALUE(id));
|
||||
JSString *str = js_ValueToString(cx, IdToValue(id));
|
||||
if (!str)
|
||||
return false;
|
||||
rval->setString(str);
|
||||
|
@ -297,8 +302,8 @@ MakePropertyDescriptorObject(JSContext *cx, jsid id, PropertyDescriptor *desc, V
|
|||
return true;
|
||||
}
|
||||
uintN attrs = desc->attrs;
|
||||
Value getter = (attrs & JSPROP_GETTER) ? CastAsObjectJSVal(desc->getter) : undefinedValue();
|
||||
Value setter = (attrs & JSPROP_SETTER) ? CastAsObjectJSVal(desc->setter) : undefinedValue();
|
||||
Value getter = (attrs & JSPROP_GETTER) ? CastAsObjectJsval(desc->getter) : undefinedValue();
|
||||
Value setter = (attrs & JSPROP_SETTER) ? CastAsObjectJsval(desc->setter) : undefinedValue();
|
||||
return js_NewPropertyDescriptorObject(cx, id, attrs, getter, setter, desc->value, vp);
|
||||
}
|
||||
|
||||
|
@ -502,7 +507,7 @@ bool
|
|||
JSScriptedProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, Value *vp)
|
||||
{
|
||||
JSObject *handler = GetProxyHandlerObject(cx, proxy);
|
||||
JSString *str = js_ValueToString(cx, ID_TO_VALUE(id));
|
||||
JSString *str = js_ValueToString(cx, IdToValue(id));
|
||||
if (!str)
|
||||
return false;
|
||||
AutoValueRooter tvr(cx, StringTag(str));
|
||||
|
@ -519,7 +524,7 @@ bool
|
|||
JSScriptedProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, Value *vp)
|
||||
{
|
||||
JSObject *handler = GetProxyHandlerObject(cx, proxy);
|
||||
JSString *str = js_ValueToString(cx, ID_TO_VALUE(id));
|
||||
JSString *str = js_ValueToString(cx, IdToValue(id));
|
||||
if (!str)
|
||||
return false;
|
||||
AutoValueRooter tvr(cx, StringTag(str));
|
||||
|
@ -780,7 +785,7 @@ proxy_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
|
|||
return false;
|
||||
|
||||
if (found) {
|
||||
*propp = (JSProperty *)id;
|
||||
*propp = (JSProperty *)0x1;
|
||||
*objp = obj;
|
||||
} else {
|
||||
*objp = NULL;
|
||||
|
|
|
@ -57,29 +57,6 @@
|
|||
#include "jspubtd.h"
|
||||
#include "jsutil.h"
|
||||
|
||||
/* Internal identifier (jsid) macros. */
|
||||
|
||||
#define JSID_IS_ATOM(id) JSVAL_IS_STRING((jsval)(id))
|
||||
#define JSID_TO_ATOM(id) ((JSAtom *)JSVAL_TO_STRING((jsval)(id)))
|
||||
#define JSID_TO_STRING(id) ATOM_TO_STRING(JSID_TO_ATOM(id))
|
||||
#define ATOM_TO_JSID(atom) ((jsid)STRING_TO_JSVAL((JSString *)atom))
|
||||
|
||||
#define JSID_IS_INT(id) JSVAL_IS_INT((jsval)(id))
|
||||
#define JSID_TO_INT(id) JSVAL_TO_INT((jsval)(id))
|
||||
#define INT_TO_JSID(i) ((jsid)INT_TO_JSVAL(i))
|
||||
#define INT_JSVAL_TO_JSID(v) ((jsid)(v))
|
||||
#define INT_JSID_TO_VALUE(id) (js::Valueify((jsval)(id)))
|
||||
#define INT_JSID_TO_JSVAL(id) ((jsval)(id))
|
||||
#define INT_FITS_IN_JSID(i) INT_FITS_IN_JSVAL(i)
|
||||
|
||||
#define JSID_IS_OBJECT(id) JSVAL_IS_OBJECT((jsval)(id))
|
||||
#define JSID_TO_OBJECT(id) JSVAL_TO_OBJECT((jsval)(id))
|
||||
#define OBJECT_TO_JSID(obj) ((jsid)OBJECT_TO_JSVAL(obj))
|
||||
#define OBJECT_JSVAL_TO_JSID(v) ((jsid)v)
|
||||
|
||||
#define ID_TO_VALUE(id) (js::Valueify(id))
|
||||
#define ID_TO_JSVAL(id) ((jsval)(id))
|
||||
|
||||
/*
|
||||
* Convenience constants.
|
||||
*/
|
||||
|
|
964
js/src/jspubtd.h
964
js/src/jspubtd.h
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -130,15 +130,15 @@ TraceRecorder::assertDownFrameIsConsistent(VMSideExit* anchor, FrameInfo* fi)
|
|||
JS_ASSERT(anchor->recursive_down->callerHeight == fi->callerHeight);
|
||||
|
||||
unsigned downPostSlots = fi->callerHeight;
|
||||
TraceType* typeMap = fi->get_typemap();
|
||||
JSValueType* typeMap = fi->get_typemap();
|
||||
|
||||
captureStackTypes(1, typeMap);
|
||||
const TraceType* m1 = anchor->recursive_down->get_typemap();
|
||||
const JSValueType* m1 = anchor->recursive_down->get_typemap();
|
||||
for (unsigned i = 0; i < downPostSlots; i++) {
|
||||
if (m1[i] == typeMap[i])
|
||||
continue;
|
||||
if ((typeMap[i] == TT_INT32 && m1[i] == TT_DOUBLE) ||
|
||||
(typeMap[i] == TT_DOUBLE && m1[i] == TT_INT32)) {
|
||||
if ((typeMap[i] == JSVAL_TYPE_INT32 && m1[i] == JSVAL_TYPE_DOUBLE) ||
|
||||
(typeMap[i] == JSVAL_TYPE_DOUBLE && m1[i] == JSVAL_TYPE_INT32)) {
|
||||
continue;
|
||||
}
|
||||
JS_NOT_REACHED("invalid RECURSIVE_MISMATCH exit");
|
||||
|
@ -156,8 +156,8 @@ TraceRecorder::downSnapshot(FrameInfo* downFrame)
|
|||
unsigned downPostSlots = downFrame->callerHeight;
|
||||
unsigned ngslots = tree->globalSlots->length();
|
||||
unsigned exitTypeMapLen = downPostSlots + 1 + ngslots;
|
||||
TraceType* exitTypeMap = (TraceType*)alloca(sizeof(TraceType) * exitTypeMapLen);
|
||||
TraceType* typeMap = downFrame->get_typemap();
|
||||
JSValueType* exitTypeMap = (JSValueType*)alloca(sizeof(JSValueType) * exitTypeMapLen);
|
||||
JSValueType* typeMap = downFrame->get_typemap();
|
||||
|
||||
|
||||
/* Add stack slots. */
|
||||
|
@ -169,13 +169,13 @@ TraceRecorder::downSnapshot(FrameInfo* downFrame)
|
|||
if (*cx->regs->pc == JSOP_RETURN)
|
||||
exitTypeMap[downPostSlots] = determineSlotType(&stackval(-1));
|
||||
else
|
||||
exitTypeMap[downPostSlots] = TT_VOID;
|
||||
exitTypeMap[downPostSlots] = JSVAL_TYPE_UNDEFINED;
|
||||
|
||||
/* Add global types. */
|
||||
determineGlobalTypes(&exitTypeMap[downPostSlots + 1]);
|
||||
|
||||
VMSideExit* exit = (VMSideExit*)
|
||||
traceMonitor->traceAlloc->alloc(sizeof(VMSideExit) + sizeof(TraceType) * exitTypeMapLen);
|
||||
traceMonitor->traceAlloc->alloc(sizeof(VMSideExit) + sizeof(JSValueType) * exitTypeMapLen);
|
||||
|
||||
PodZero(exit);
|
||||
exit->from = fragment;
|
||||
|
@ -193,7 +193,7 @@ TraceRecorder::downSnapshot(FrameInfo* downFrame)
|
|||
exit->rp_adj = exit->calldepth * sizeof(FrameInfo*);
|
||||
exit->nativeCalleeWord = 0;
|
||||
exit->lookupFlags = js_InferFlags(cx, 0);
|
||||
memcpy(exit->fullTypeMap(), exitTypeMap, sizeof(TraceType) * exitTypeMapLen);
|
||||
memcpy(exit->fullTypeMap(), exitTypeMap, sizeof(JSValueType) * exitTypeMapLen);
|
||||
#if defined JS_JIT_SPEW
|
||||
TreevisLogExit(cx, exit);
|
||||
#endif
|
||||
|
@ -247,7 +247,7 @@ TraceRecorder::upRecursion()
|
|||
*/
|
||||
unsigned totalSlots = NativeStackSlots(cx, 1);
|
||||
unsigned downPostSlots = totalSlots - NativeStackSlots(cx, 0);
|
||||
FrameInfo* fi = (FrameInfo*)alloca(sizeof(FrameInfo) + totalSlots * sizeof(TraceType));
|
||||
FrameInfo* fi = (FrameInfo*)alloca(sizeof(FrameInfo) + totalSlots * sizeof(JSValueType));
|
||||
fi->block = NULL;
|
||||
fi->pc = (jsbytecode*)return_pc;
|
||||
fi->imacpc = NULL;
|
||||
|
@ -281,7 +281,7 @@ TraceRecorder::upRecursion()
|
|||
} else {
|
||||
/* Case 2: Guess that up-recursion is backing out, infer types from our Tree. */
|
||||
JS_ASSERT(tree->nStackTypes == downPostSlots + 1);
|
||||
TraceType* typeMap = fi->get_typemap();
|
||||
JSValueType* typeMap = fi->get_typemap();
|
||||
for (unsigned i = 0; i < downPostSlots; i++)
|
||||
typeMap[i] = tree->typeMap[i];
|
||||
}
|
||||
|
@ -327,10 +327,10 @@ TraceRecorder::upRecursion()
|
|||
rval_ins = INS_VOID();
|
||||
}
|
||||
|
||||
TraceType returnType = exit->stackTypeMap()[downPostSlots];
|
||||
if (returnType == TT_INT32) {
|
||||
JSValueType returnType = exit->stackTypeMap()[downPostSlots];
|
||||
if (returnType == JSVAL_TYPE_INT32) {
|
||||
JS_ASSERT(*cx->regs->pc == JSOP_RETURN);
|
||||
JS_ASSERT(determineSlotType(&stackval(-1)) == TT_INT32);
|
||||
JS_ASSERT(determineSlotType(&stackval(-1)) == JSVAL_TYPE_INT32);
|
||||
JS_ASSERT(isPromoteInt(rval_ins));
|
||||
rval_ins = demote(lir, rval_ins);
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ TraceRecorder::upRecursion()
|
|||
if (*cx->regs->pc == JSOP_RETURN)
|
||||
slotMap.addSlot(&stackval(-1));
|
||||
else
|
||||
slotMap.addSlot(TT_VOID);
|
||||
slotMap.addSlot(JSVAL_TYPE_UNDEFINED);
|
||||
VisitGlobalSlots(slotMap, cx, *tree->globalSlots);
|
||||
if (recursive_pc == (jsbytecode*)fragment->root->ip) {
|
||||
debug_only_print0(LC_TMTracer, "Compiling up-recursive loop...\n");
|
||||
|
@ -360,7 +360,7 @@ class SlurpInfo
|
|||
{
|
||||
public:
|
||||
unsigned curSlot;
|
||||
TraceType* typeMap;
|
||||
JSValueType* typeMap;
|
||||
VMSideExit* exit;
|
||||
unsigned slurpFailSlot;
|
||||
};
|
||||
|
@ -483,7 +483,7 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
|
|||
unsigned safeSlots = NativeStackSlots(cx, frameDepth) + 1 + numGlobalSlots;
|
||||
jsbytecode* recursive_pc = return_pc + JSOP_CALL_LENGTH;
|
||||
VMSideExit* exit = (VMSideExit*)
|
||||
traceMonitor->traceAlloc->alloc(sizeof(VMSideExit) + sizeof(TraceType) * safeSlots);
|
||||
traceMonitor->traceAlloc->alloc(sizeof(VMSideExit) + sizeof(JSValueType) * safeSlots);
|
||||
PodZero(exit);
|
||||
exit->pc = (jsbytecode*)recursive_pc;
|
||||
exit->from = fragment;
|
||||
|
@ -497,7 +497,7 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
|
|||
* Build the exit typemap. This may capture extra types, but they are
|
||||
* thrown away.
|
||||
*/
|
||||
TraceType* typeMap = exit->stackTypeMap();
|
||||
JSValueType* typeMap = exit->stackTypeMap();
|
||||
jsbytecode* oldpc = cx->regs->pc;
|
||||
cx->regs->pc = exit->pc;
|
||||
captureStackTypes(frameDepth, typeMap);
|
||||
|
@ -507,7 +507,7 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
|
|||
if (*cx->regs->pc == JSOP_RETURN)
|
||||
typeMap[downPostSlots] = determineSlotType(&stackval(-1));
|
||||
else
|
||||
typeMap[downPostSlots] = TT_VOID;
|
||||
typeMap[downPostSlots] = JSVAL_TYPE_UNDEFINED;
|
||||
} else {
|
||||
typeMap[downPostSlots] = anchor->stackTypeMap()[anchor->numStackSlots - 1];
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
|
|||
*/
|
||||
LIns* rval_ins;
|
||||
intptr_t offset = exit->sp_adj - sizeof(double);
|
||||
TraceType returnType = exit->stackTypeMap()[downPostSlots];
|
||||
JSValueType returnType = exit->stackTypeMap()[downPostSlots];
|
||||
|
||||
if (!anchor || anchor->exitType != RECURSIVE_SLURP_FAIL_EXIT) {
|
||||
/*
|
||||
|
@ -539,8 +539,8 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
|
|||
|
||||
if (op == JSOP_RETURN) {
|
||||
rval_ins = get(&stackval(-1));
|
||||
if (returnType == TT_INT32) {
|
||||
JS_ASSERT(determineSlotType(&stackval(-1)) == TT_INT32);
|
||||
if (returnType == JSVAL_TYPE_INT32) {
|
||||
JS_ASSERT(determineSlotType(&stackval(-1)) == JSVAL_TYPE_INT32);
|
||||
JS_ASSERT(isPromoteInt(rval_ins));
|
||||
rval_ins = demote(lir, rval_ins);
|
||||
}
|
||||
|
@ -556,18 +556,18 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
|
|||
} else {
|
||||
switch (returnType)
|
||||
{
|
||||
case TT_SPECIAL:
|
||||
case TT_VOID:
|
||||
case TT_INT32:
|
||||
case JSVAL_TYPE_BOOLEAN:
|
||||
case JSVAL_TYPE_UNDEFINED:
|
||||
case JSVAL_TYPE_INT32:
|
||||
rval_ins = lir->insLoad(LIR_ldi, lirbuf->sp, offset, ACC_STACK);
|
||||
break;
|
||||
case TT_DOUBLE:
|
||||
case JSVAL_TYPE_DOUBLE:
|
||||
rval_ins = lir->insLoad(LIR_ldd, lirbuf->sp, offset, ACC_STACK);
|
||||
break;
|
||||
case TT_FUNCTION:
|
||||
case TT_OBJECT:
|
||||
case TT_STRING:
|
||||
case TT_NULL:
|
||||
case JSVAL_TYPE_FUNOBJ:
|
||||
case JSVAL_TYPE_NONFUNOBJ:
|
||||
case JSVAL_TYPE_STRING:
|
||||
case JSVAL_TYPE_NULL:
|
||||
rval_ins = lir->insLoad(LIR_ldp, lirbuf->sp, offset, ACC_STACK);
|
||||
break;
|
||||
default:
|
||||
|
@ -633,7 +633,7 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
|
|||
if (*cx->regs->pc == JSOP_RETURN)
|
||||
slotMap.addSlot(&stackval(-1), typeMap[downPostSlots]);
|
||||
else
|
||||
slotMap.addSlot(TT_VOID);
|
||||
slotMap.addSlot(JSVAL_TYPE_UNDEFINED);
|
||||
VisitGlobalSlots(slotMap, cx, *tree->globalSlots);
|
||||
debug_only_print0(LC_TMTracer, "Compiling up-recursive slurp...\n");
|
||||
exit = copy(exit);
|
||||
|
@ -726,62 +726,45 @@ TraceRecorder::downRecursion()
|
|||
return closeLoop(exit);
|
||||
}
|
||||
|
||||
JS_REQUIRES_STACK LIns*
|
||||
TraceRecorder::slurpInt32Slot(LIns* addr_ins, ptrdiff_t offset, Value* vp, VMSideExit* exit)
|
||||
{
|
||||
LIns *mask_ins = lir->insLoad(LIR_ldi, addr_ins, offset + offsetof(jsval_layout, s.u.mask32),
|
||||
ACC_OTHER);
|
||||
guard(true, lir->ins2(LIR_eqi, mask_ins, INS_CONST(JSVAL_MASK32_INT32)), exit);
|
||||
return lir->insLoad(LIR_ldi, addr_ins, offset + offsetof(jsval_layout, s.payload), ACC_OTHER);
|
||||
}
|
||||
|
||||
JS_REQUIRES_STACK LIns*
|
||||
TraceRecorder::slurpDoubleSlot(LIns* addr_ins, ptrdiff_t offset, Value* vp, VMSideExit* exit)
|
||||
{
|
||||
LIns *mask_ins = lir->insLoad(LIR_ldi, addr_ins, offset + offsetof(jsval_layout, s.u.mask32),
|
||||
ACC_OTHER);
|
||||
guard(true, lir->ins2(LIR_ltui, mask_ins, INS_CONST(JSVAL_MASK32_CLEAR)), exit);
|
||||
return lir->insLoad(LIR_ldd, addr_ins, offset + offsetof(jsval_layout, s.payload), ACC_OTHER);
|
||||
LIns *mask_ins = lir->insLoad(LIR_ldi, addr_ins, offset + sTagOffset, ACC_OTHER);
|
||||
guard(true, lir->ins2(LIR_ltui, mask_ins, INS_CONSTU(JSVAL_TAG_CLEAR)), exit);
|
||||
return lir->insLoad(LIR_ldd, addr_ins, offset + sPayloadOffset, ACC_OTHER);
|
||||
}
|
||||
|
||||
JS_REQUIRES_STACK LIns*
|
||||
TraceRecorder::slurpTypedSlot(LIns* addr_ins, ptrdiff_t offset, Value* vp, uint32 mask, VMSideExit* exit)
|
||||
TraceRecorder::slurpTypedSlot(LIns* addr_ins, ptrdiff_t offset, Value* vp, JSValueTag mask, VMSideExit* exit)
|
||||
{
|
||||
LIns *mask_ins = lir->insLoad(LIR_ldi, addr_ins, offset + offsetof(jsval_layout, s.u.mask32),
|
||||
ACC_OTHER);
|
||||
guard(true, lir->ins2(LIR_eqi, mask_ins, INS_CONST(mask)), exit);
|
||||
switch (mask) {
|
||||
case JSVAL_MASK32_UNDEFINED:
|
||||
LIns *mask_ins = lir->insLoad(LIR_ldi, addr_ins, offset + sTagOffset, ACC_OTHER);
|
||||
guard(true, lir->ins2(LIR_eqi, mask_ins, INS_CONSTU(mask)), exit);
|
||||
if (mask == JSVAL_TAG_UNDEFINED)
|
||||
return INS_VOID();
|
||||
case JSVAL_MASK32_MAGIC:
|
||||
return INS_HOLE();
|
||||
default:
|
||||
return lir->insLoad(LIR_ldi, addr_ins, offset + offsetof(jsval_layout, s.payload),
|
||||
ACC_OTHER);
|
||||
}
|
||||
return lir->insLoad(LIR_ldi, addr_ins, offset + sPayloadOffset, ACC_OTHER);
|
||||
}
|
||||
JS_REQUIRES_STACK LIns*
|
||||
TraceRecorder::slurpSlot(LIns* addr_ins, ptrdiff_t offset, Value* vp, VMSideExit* exit)
|
||||
{
|
||||
switch (exit->slurpType)
|
||||
{
|
||||
case TT_SPECIAL:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_MASK32_BOOLEAN, exit);
|
||||
case TT_VOID:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_MASK32_UNDEFINED, exit);
|
||||
case TT_INT32:
|
||||
return slurpInt32Slot(addr_ins, offset, vp, exit);
|
||||
case TT_DOUBLE:
|
||||
case JSVAL_TYPE_BOOLEAN:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_TAG_BOOLEAN, exit);
|
||||
case JSVAL_TYPE_UNDEFINED:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_TAG_UNDEFINED, exit);
|
||||
case JSVAL_TYPE_INT32:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_TAG_INT32, exit);
|
||||
case JSVAL_TYPE_DOUBLE:
|
||||
return slurpDoubleSlot(addr_ins, offset, vp, exit);
|
||||
case TT_STRING:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_MASK32_STRING, exit);
|
||||
case TT_NULL:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_MASK32_NULL, exit);
|
||||
case TT_OBJECT:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_MASK32_NONFUNOBJ, exit);
|
||||
case TT_FUNCTION:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_MASK32_FUNOBJ, exit);
|
||||
default:
|
||||
case JSVAL_TYPE_STRING:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_TAG_STRING, exit);
|
||||
case JSVAL_TYPE_NULL:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_TAG_NULL, exit);
|
||||
case JSVAL_TYPE_NONFUNOBJ:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_TAG_NONFUNOBJ, exit);
|
||||
case JSVAL_TYPE_FUNOBJ:
|
||||
return slurpTypedSlot(addr_ins, offset, vp, JSVAL_TAG_FUNOBJ, exit);
|
||||
default:
|
||||
JS_NOT_REACHED("invalid type in typemap");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -5097,7 +5097,7 @@ SetRegExpLastIndex(JSContext *cx, JSObject *obj, jsdouble lastIndex)
|
|||
|
||||
#define DEFINE_GETTER(name, code) \
|
||||
static JSBool \
|
||||
name(JSContext *cx, JSObject *obj, jsval id, jsval *vp) \
|
||||
name(JSContext *cx, JSObject *obj, jsid id, jsval *vp) \
|
||||
{ \
|
||||
while (obj->getClass() != &js_RegExpClass) { \
|
||||
obj = obj->getProto(); \
|
||||
|
@ -5120,7 +5120,7 @@ DEFINE_GETTER(multiline_getter, *vp = BOOLEAN_TO_JSVAL((re->flags & JSREG_MULTI
|
|||
DEFINE_GETTER(sticky_getter, *vp = BOOLEAN_TO_JSVAL((re->flags & JSREG_STICKY) != 0))
|
||||
|
||||
static JSBool
|
||||
lastIndex_setter(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
lastIndex_setter(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
while (obj->getClass() != &js_RegExpClass) {
|
||||
obj = obj->getProto();
|
||||
|
@ -5213,7 +5213,7 @@ js_FreeRegExpStatics(JSContext *cx)
|
|||
|
||||
#define DEFINE_STATIC_GETTER(name, code) \
|
||||
static JSBool \
|
||||
name(JSContext *cx, JSObject *obj, jsval id, jsval *vp) \
|
||||
name(JSContext *cx, JSObject *obj, jsid id, jsval *vp) \
|
||||
{ \
|
||||
JSRegExpStatics *res = &cx->regExpStatics; \
|
||||
code; \
|
||||
|
@ -5258,7 +5258,7 @@ DEFINE_STATIC_GETTER(static_paren9_getter, return Paren(cx, res, 8, vp))
|
|||
|
||||
#define DEFINE_STATIC_SETTER(name, code) \
|
||||
static JSBool \
|
||||
name(JSContext *cx, JSObject *obj, jsval id, jsval *vp) \
|
||||
name(JSContext *cx, JSObject *obj, jsid id, jsval *vp) \
|
||||
{ \
|
||||
JSRegExpStatics *res = &cx->regExpStatics; \
|
||||
code; \
|
||||
|
|
|
@ -363,8 +363,15 @@ JSScope::finishRuntimeState(JSContext *cx)
|
|||
}
|
||||
|
||||
JS_STATIC_ASSERT(sizeof(JSHashNumber) == 4);
|
||||
JS_STATIC_ASSERT(sizeof(jsid) == 8);
|
||||
#define HASH_ID(id) ((JSHashNumber)(id) ^ (JSHashNumber)((id) >> 32))
|
||||
JS_STATIC_ASSERT(sizeof(jsid) == JS_BYTES_PER_WORD);
|
||||
|
||||
#if JS_BYTES_PER_WORD == 4
|
||||
# define HASH_ID(id) ((JSHashNumber)(JSID_BITS(id)))
|
||||
#elif JS_BYTES_PER_WORD == 8
|
||||
# define HASH_ID(id) ((JSHashNumber)(JSID_BITS(id)) ^ (JSHashNumber)((JSID_BITS(id)) >> 32))
|
||||
#else
|
||||
# error "Unsupported configuration"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Double hashing needs the second hash code to be relatively prime to table
|
||||
|
@ -385,7 +392,7 @@ JSScope::searchTable(jsid id, bool adding)
|
|||
uint32 sizeMask;
|
||||
|
||||
JS_ASSERT(table);
|
||||
JS_ASSERT(!JSVAL_IS_NULL(id));
|
||||
JS_ASSERT(!JSID_IS_VOID(id));
|
||||
|
||||
/* Compute the primary hash address. */
|
||||
METER(hashes);
|
||||
|
@ -519,7 +526,7 @@ JSScopeProperty *
|
|||
JSScope::getChildProperty(JSContext *cx, JSScopeProperty *parent,
|
||||
JSScopeProperty &child)
|
||||
{
|
||||
JS_ASSERT(!JSVAL_IS_NULL(child.id));
|
||||
JS_ASSERT(!JSID_IS_VOID(child.id));
|
||||
JS_ASSERT(!child.inDictionary());
|
||||
|
||||
/*
|
||||
|
@ -757,7 +764,7 @@ JSScope::addProperty(JSContext *cx, jsid id,
|
|||
JS_ASSERT(JS_IS_SCOPE_LOCKED(cx, this));
|
||||
CHECK_ANCESTOR_LINE(this, true);
|
||||
|
||||
JS_ASSERT(!JSVAL_IS_NULL(id));
|
||||
JS_ASSERT(!JSID_IS_VOID(id));
|
||||
JS_ASSERT_IF(!cx->runtime->gcRegenShapes,
|
||||
hasRegenFlag(cx->runtime->gcRegenShapesScopeFlag));
|
||||
|
||||
|
@ -890,7 +897,7 @@ JSScope::putProperty(JSContext *cx, jsid id,
|
|||
JS_ASSERT(JS_IS_SCOPE_LOCKED(cx, this));
|
||||
CHECK_ANCESTOR_LINE(this, true);
|
||||
|
||||
JS_ASSERT(!JSVAL_IS_NULL(id));
|
||||
JS_ASSERT(!JSID_IS_VOID(id));
|
||||
|
||||
JS_ASSERT_IF(!cx->runtime->gcRegenShapes,
|
||||
hasRegenFlag(cx->runtime->gcRegenShapesScopeFlag));
|
||||
|
@ -998,7 +1005,7 @@ JSScope::changeProperty(JSContext *cx, JSScopeProperty *sprop,
|
|||
JS_ASSERT(JS_IS_SCOPE_LOCKED(cx, this));
|
||||
CHECK_ANCESTOR_LINE(this, true);
|
||||
|
||||
JS_ASSERT(!JSVAL_IS_NULL(sprop->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(sprop->id));
|
||||
JS_ASSERT(hasProperty(sprop));
|
||||
|
||||
attrs |= sprop->attrs & mask;
|
||||
|
@ -1177,14 +1184,14 @@ JSScope::clear(JSContext *cx)
|
|||
void
|
||||
JSScope::deletingShapeChange(JSContext *cx, JSScopeProperty *sprop)
|
||||
{
|
||||
JS_ASSERT(!JSVAL_IS_NULL(sprop->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(sprop->id));
|
||||
generateOwnShape(cx);
|
||||
}
|
||||
|
||||
bool
|
||||
JSScope::methodShapeChange(JSContext *cx, JSScopeProperty *sprop)
|
||||
{
|
||||
JS_ASSERT(!JSVAL_IS_NULL(sprop->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(sprop->id));
|
||||
if (sprop->isMethod()) {
|
||||
#ifdef DEBUG
|
||||
const Value &prev = object->lockedGetSlot(sprop->slot);
|
||||
|
@ -1219,7 +1226,7 @@ JSScope::methodShapeChange(JSContext *cx, uint32 slot)
|
|||
generateOwnShape(cx);
|
||||
} else {
|
||||
for (JSScopeProperty *sprop = lastProp; sprop; sprop = sprop->parent) {
|
||||
JS_ASSERT(!JSVAL_IS_NULL(sprop->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(sprop->id));
|
||||
if (sprop->slot == slot)
|
||||
return methodShapeChange(cx, sprop);
|
||||
}
|
||||
|
@ -1236,7 +1243,7 @@ JSScope::protoShapeChange(JSContext *cx)
|
|||
void
|
||||
JSScope::shadowingShapeChange(JSContext *cx, JSScopeProperty *sprop)
|
||||
{
|
||||
JS_ASSERT(!JSVAL_IS_NULL(sprop->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(sprop->id));
|
||||
generateOwnShape(cx);
|
||||
}
|
||||
|
||||
|
@ -1259,7 +1266,7 @@ PrintPropertyGetterOrSetter(JSTracer *trc, char *buf, size_t bufsize)
|
|||
JS_ASSERT(trc->debugPrinter == PrintPropertyGetterOrSetter);
|
||||
sprop = (JSScopeProperty *)trc->debugPrintArg;
|
||||
id = sprop->id;
|
||||
JS_ASSERT(!JSVAL_IS_NULL(id));
|
||||
JS_ASSERT(!JSID_IS_VOID(id));
|
||||
name = trc->debugPrintIndex ? js_setter_str : js_getter_str;
|
||||
|
||||
if (JSID_IS_ATOM(id)) {
|
||||
|
@ -1284,7 +1291,7 @@ PrintPropertyMethod(JSTracer *trc, char *buf, size_t bufsize)
|
|||
JS_ASSERT(trc->debugPrinter == PrintPropertyMethod);
|
||||
sprop = (JSScopeProperty *)trc->debugPrintArg;
|
||||
id = sprop->id;
|
||||
JS_ASSERT(!JSVAL_IS_NULL(id));
|
||||
JS_ASSERT(!JSID_IS_VOID(id));
|
||||
|
||||
JS_ASSERT(JSID_IS_ATOM(id));
|
||||
n = js_PutEscapedString(buf, bufsize - 1, JSID_TO_STRING(id), 0);
|
||||
|
|
|
@ -623,7 +623,7 @@ struct JSScopeProperty {
|
|||
};
|
||||
|
||||
void insertFree(JSScopeProperty *&list) {
|
||||
id = JSVAL_NULL;
|
||||
id = JSID_VOID;
|
||||
next = list;
|
||||
prevp = &list;
|
||||
if (list)
|
||||
|
@ -632,7 +632,7 @@ struct JSScopeProperty {
|
|||
}
|
||||
|
||||
void removeFree() {
|
||||
JS_ASSERT(JSVAL_IS_NULL(id));
|
||||
JS_ASSERT(JSID_IS_VOID(id));
|
||||
*prevp = next;
|
||||
if (next)
|
||||
next->prevp = prevp;
|
||||
|
@ -813,7 +813,7 @@ JSScope::hasProperty(JSScopeProperty *sprop)
|
|||
inline JSScopeProperty *
|
||||
JSScope::lastProperty() const
|
||||
{
|
||||
JS_ASSERT_IF(lastProp, !JSVAL_IS_NULL(lastProp->id));
|
||||
JS_ASSERT_IF(lastProp, !JSID_IS_VOID(lastProp->id));
|
||||
return lastProp;
|
||||
}
|
||||
|
||||
|
@ -824,8 +824,8 @@ JSScope::lastProperty() const
|
|||
inline void
|
||||
JSScope::setLastProperty(JSScopeProperty *sprop)
|
||||
{
|
||||
JS_ASSERT(!JSVAL_IS_NULL(sprop->id));
|
||||
JS_ASSERT_IF(lastProp, !JSVAL_IS_NULL(lastProp->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(sprop->id));
|
||||
JS_ASSERT_IF(lastProp, !JSID_IS_VOID(lastProp->id));
|
||||
|
||||
lastProp = sprop;
|
||||
}
|
||||
|
@ -834,7 +834,7 @@ inline void
|
|||
JSScope::removeLastProperty()
|
||||
{
|
||||
JS_ASSERT(!inDictionaryMode());
|
||||
JS_ASSERT_IF(lastProp->parent, !JSVAL_IS_NULL(lastProp->parent->id));
|
||||
JS_ASSERT_IF(lastProp->parent, !JSID_IS_VOID(lastProp->parent->id));
|
||||
|
||||
lastProp = lastProp->parent;
|
||||
--entryCount;
|
||||
|
@ -846,12 +846,12 @@ JSScope::removeDictionaryProperty(JSScopeProperty *sprop)
|
|||
JS_ASSERT(inDictionaryMode());
|
||||
JS_ASSERT(sprop->inDictionary());
|
||||
JS_ASSERT(sprop->childp);
|
||||
JS_ASSERT(!JSVAL_IS_NULL(sprop->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(sprop->id));
|
||||
|
||||
JS_ASSERT(lastProp->inDictionary());
|
||||
JS_ASSERT(lastProp->childp == &lastProp);
|
||||
JS_ASSERT_IF(lastProp != sprop, !JSVAL_IS_NULL(lastProp->id));
|
||||
JS_ASSERT_IF(lastProp->parent, !JSVAL_IS_NULL(lastProp->parent->id));
|
||||
JS_ASSERT_IF(lastProp != sprop, !JSID_IS_VOID(lastProp->id));
|
||||
JS_ASSERT_IF(lastProp->parent, !JSID_IS_VOID(lastProp->parent->id));
|
||||
|
||||
if (sprop->parent)
|
||||
sprop->parent->childp = sprop->childp;
|
||||
|
@ -869,12 +869,12 @@ JSScope::insertDictionaryProperty(JSScopeProperty *sprop, JSScopeProperty **chil
|
|||
*/
|
||||
JS_ASSERT(sprop->inDictionary());
|
||||
JS_ASSERT(!sprop->childp);
|
||||
JS_ASSERT(!JSVAL_IS_NULL(sprop->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(sprop->id));
|
||||
|
||||
JS_ASSERT_IF(*childp, (*childp)->inDictionary());
|
||||
JS_ASSERT_IF(lastProp, lastProp->inDictionary());
|
||||
JS_ASSERT_IF(lastProp, lastProp->childp == &lastProp);
|
||||
JS_ASSERT_IF(lastProp, !JSVAL_IS_NULL(lastProp->id));
|
||||
JS_ASSERT_IF(lastProp, !JSID_IS_VOID(lastProp->id));
|
||||
|
||||
sprop->parent = *childp;
|
||||
*childp = sprop;
|
||||
|
@ -973,7 +973,7 @@ JSScope::canProvideEmptyScope(JSObjectOps *ops, js::Class *clasp)
|
|||
inline bool
|
||||
JSScopeProperty::get(JSContext* cx, JSObject *obj, JSObject *pobj, js::Value* vp)
|
||||
{
|
||||
JS_ASSERT(!JSVAL_IS_NULL(this->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(this->id));
|
||||
JS_ASSERT(!hasDefaultGetter());
|
||||
|
||||
if (hasGetterValue()) {
|
||||
|
|
|
@ -241,16 +241,15 @@ JSScopeProperty::hash() const
|
|||
hash = JS_ROTATE_LEFT32(hash, 4) ^ attrs;
|
||||
hash = JS_ROTATE_LEFT32(hash, 4) ^ shortid;
|
||||
hash = JS_ROTATE_LEFT32(hash, 4) ^ slot;
|
||||
hash = JS_ROTATE_LEFT32(hash, 4) ^ JSDHashNumber(id);
|
||||
hash = JS_ROTATE_LEFT32(hash, 4) ^ JSDHashNumber(id >> 32);
|
||||
hash = JS_ROTATE_LEFT32(hash, 4) ^ JSID_BITS(id);
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline bool
|
||||
JSScopeProperty::matches(const JSScopeProperty *p) const
|
||||
{
|
||||
JS_ASSERT(!JSVAL_IS_NULL(id));
|
||||
JS_ASSERT(!JSVAL_IS_NULL(p->id));
|
||||
JS_ASSERT(!JSID_IS_VOID(id));
|
||||
JS_ASSERT(!JSID_IS_VOID(p->id));
|
||||
return id == p->id &&
|
||||
matchesParamsAfterId(p->rawGetter, p->rawSetter, p->slot, p->attrs, p->flags,
|
||||
p->shortid);
|
||||
|
@ -260,7 +259,7 @@ inline bool
|
|||
JSScopeProperty::matchesParamsAfterId(js::PropertyOp agetter, js::PropertyOp asetter, uint32 aslot,
|
||||
uintN aattrs, uintN aflags, intN ashortid) const
|
||||
{
|
||||
JS_ASSERT(!JSVAL_IS_NULL(id));
|
||||
JS_ASSERT(!JSID_IS_VOID(id));
|
||||
return rawGetter == agetter &&
|
||||
rawSetter == asetter &&
|
||||
slot == aslot &&
|
||||
|
|
|
@ -547,7 +547,7 @@ str_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
{
|
||||
JSString *str;
|
||||
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
if (obj->getClass() == &js_StringClass) {
|
||||
/* Follow ECMA-262 by fetching intrinsic length of our string. */
|
||||
str = obj->getPrimitiveThis().asString();
|
||||
|
@ -601,7 +601,7 @@ str_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
|||
JSString *str1 = JSString::getUnitString(cx, str, size_t(slot));
|
||||
if (!str1)
|
||||
return JS_FALSE;
|
||||
if (!obj->defineProperty(cx, INT_TO_JSID(slot), StringTag(str1), NULL, NULL,
|
||||
if (!obj->defineProperty(cx, id, StringTag(str1), NULL, NULL,
|
||||
STRING_ELEMENT_ATTRS)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -1562,7 +1562,7 @@ typedef JSObject **MatchArgType;
|
|||
static bool
|
||||
MatchCallback(JSContext *cx, size_t count, void *p)
|
||||
{
|
||||
JS_ASSERT(count <= JSVAL_INT_MAX); /* by max string length */
|
||||
JS_ASSERT(count <= JSID_INT_MAX); /* by max string length */
|
||||
|
||||
JSObject *&arrayobj = *static_cast<MatchArgType>(p);
|
||||
if (!arrayobj) {
|
||||
|
|
1071
js/src/jstracer.cpp
1071
js/src/jstracer.cpp
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -321,69 +321,18 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 || (defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define USE_TRACE_TYPE_ENUM
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The types of values calculated during tracing, used to specialize operations
|
||||
* to the types of those values. These loosely correspond to the values of the
|
||||
* JSVAL_* language types, but we add a few further divisions to enable further
|
||||
* optimization at execution time. Do not rely on this loose correspondence for
|
||||
* correctness without adding static assertions!
|
||||
*
|
||||
* The ifdefs enforce that this enum occupies only one byte of memory, where
|
||||
* possible. If it doesn't, type maps will occupy more space but should
|
||||
* otherwise work correctly. A static assertion in jstracer.cpp verifies that
|
||||
* this requirement is correctly enforced by these compilers.
|
||||
*/
|
||||
enum TraceType_
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
: int8_t
|
||||
#endif
|
||||
{
|
||||
TT_OBJECT = 0, /* pointer to JSObject whose class is not js_FunctionClass */
|
||||
TT_INT32 = 1, /* 32-bit signed integer */
|
||||
TT_DOUBLE = 2, /* pointer to jsdouble */
|
||||
TT_JSVAL = 3, /* arbitrary jsval */
|
||||
TT_STRING = 4, /* pointer to JSString */
|
||||
TT_NULL = 5, /* null */
|
||||
TT_SPECIAL = 6, /* true, false, hole, or areturn (0, 1, 6, or 8) */
|
||||
TT_VOID = 7, /* undefined (2) */
|
||||
TT_FUNCTION = 8, /* pointer to JSObject whose class is js_FunctionClass */
|
||||
TT_MAGIC = 9, /* a 'magic' value, aka a hole */
|
||||
TT_IGNORE = 10
|
||||
}
|
||||
#if defined(__GNUC__) && defined(USE_TRACE_TYPE_ENUM)
|
||||
__attribute__((packed))
|
||||
#endif
|
||||
;
|
||||
|
||||
#ifdef USE_TRACE_TYPE_ENUM
|
||||
typedef TraceType_ TraceType;
|
||||
#else
|
||||
typedef int8_t TraceType;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This indicates an invalid type or error. Note that it should not be used in typemaps,
|
||||
* because it is the wrong size. It can only be used as a uint32, for example as the
|
||||
* return value from a function that returns a type as a uint32.
|
||||
*/
|
||||
const uint32 TT_INVALID = uint32(-1);
|
||||
|
||||
typedef Queue<uint16> SlotList;
|
||||
|
||||
class TypeMap : public Queue<TraceType> {
|
||||
class TypeMap : public Queue<JSValueType> {
|
||||
public:
|
||||
TypeMap(nanojit::Allocator* alloc) : Queue<TraceType>(alloc) {}
|
||||
TypeMap(nanojit::Allocator* alloc) : Queue<JSValueType>(alloc) {}
|
||||
void set(unsigned stackSlots, unsigned ngslots,
|
||||
const TraceType* stackTypeMap, const TraceType* globalTypeMap);
|
||||
const JSValueType* stackTypeMap, const JSValueType* globalTypeMap);
|
||||
JS_REQUIRES_STACK void captureTypes(JSContext* cx, JSObject* globalObj, SlotList& slots, unsigned callDepth);
|
||||
JS_REQUIRES_STACK void captureMissingGlobalTypes(JSContext* cx, JSObject* globalObj, SlotList& slots,
|
||||
unsigned stackSlots);
|
||||
bool matches(TypeMap& other) const;
|
||||
void fromRaw(TraceType* other, unsigned numSlots);
|
||||
void fromRaw(JSValueType* other, unsigned numSlots);
|
||||
};
|
||||
|
||||
#define JS_TM_EXITCODES(_) \
|
||||
|
@ -461,7 +410,7 @@ struct VMSideExit : public nanojit::SideExit
|
|||
FrameInfo* recursive_down;
|
||||
unsigned hitcount;
|
||||
unsigned slurpFailSlot;
|
||||
TraceType slurpType;
|
||||
JSValueType slurpType;
|
||||
|
||||
/*
|
||||
* Ordinarily 0. If a slow native function is atop the stack, the 1 bit is
|
||||
|
@ -481,20 +430,20 @@ struct VMSideExit : public nanojit::SideExit
|
|||
nativeCalleeWord = uintptr_t(callee) | (constructing ? 1 : 0);
|
||||
}
|
||||
|
||||
inline TraceType* stackTypeMap() {
|
||||
return (TraceType*)(this + 1);
|
||||
inline JSValueType* stackTypeMap() {
|
||||
return (JSValueType*)(this + 1);
|
||||
}
|
||||
|
||||
inline TraceType& stackType(unsigned i) {
|
||||
inline JSValueType& stackType(unsigned i) {
|
||||
JS_ASSERT(i < numStackSlots);
|
||||
return stackTypeMap()[i];
|
||||
}
|
||||
|
||||
inline TraceType* globalTypeMap() {
|
||||
return (TraceType*)(this + 1) + this->numStackSlots;
|
||||
inline JSValueType* globalTypeMap() {
|
||||
return (JSValueType*)(this + 1) + this->numStackSlots;
|
||||
}
|
||||
|
||||
inline TraceType* fullTypeMap() {
|
||||
inline JSValueType* fullTypeMap() {
|
||||
return stackTypeMap();
|
||||
}
|
||||
|
||||
|
@ -637,8 +586,8 @@ struct FrameInfo {
|
|||
bool is_constructing() const { return (argc & CONSTRUCTING_FLAG) != 0; }
|
||||
|
||||
// The typemap just before the callee is called.
|
||||
TraceType* get_typemap() { return (TraceType*) (this+1); }
|
||||
const TraceType* get_typemap() const { return (TraceType*) (this+1); }
|
||||
JSValueType* get_typemap() { return (JSValueType*) (this+1); }
|
||||
const JSValueType* get_typemap() const { return (JSValueType*) (this+1); }
|
||||
};
|
||||
|
||||
struct UnstableExit
|
||||
|
@ -733,10 +682,10 @@ struct TreeFragment : public LinkableFragment
|
|||
inline unsigned nGlobalTypes() {
|
||||
return typeMap.length() - nStackTypes;
|
||||
}
|
||||
inline TraceType* globalTypeMap() {
|
||||
inline JSValueType* globalTypeMap() {
|
||||
return typeMap.data() + nStackTypes;
|
||||
}
|
||||
inline TraceType* stackTypeMap() {
|
||||
inline JSValueType* stackTypeMap() {
|
||||
return typeMap.data();
|
||||
}
|
||||
|
||||
|
@ -767,9 +716,9 @@ struct ArgsPrivateNative {
|
|||
return (ArgsPrivateNative*) new (alloc) char[sizeof(ArgsPrivateNative) + argc];
|
||||
}
|
||||
|
||||
TraceType *typemap()
|
||||
JSValueType *typemap()
|
||||
{
|
||||
return (TraceType*) (this+1);
|
||||
return (JSValueType*) (this+1);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1052,8 +1001,8 @@ class TraceRecorder
|
|||
/* Temporary JSSpecializedNative used to describe non-specialized fast natives. */
|
||||
JSSpecializedNative generatedSpecializedNative;
|
||||
|
||||
/* Temporary TraceType array used to construct temporary typemaps. */
|
||||
js::Vector<TraceType, 256> tempTypeMap;
|
||||
/* Temporary JSValueType array used to construct temporary typemaps. */
|
||||
js::Vector<JSValueType, 256> tempTypeMap;
|
||||
|
||||
/************************************************************* 10 bajillion member functions */
|
||||
|
||||
|
@ -1062,6 +1011,7 @@ class TraceRecorder
|
|||
nanojit::LIns* insImmFun(JSFunction* fun);
|
||||
nanojit::LIns* insImmStr(JSString* str);
|
||||
nanojit::LIns* insImmSprop(JSScopeProperty* sprop);
|
||||
nanojit::LIns* insImmId(jsid id);
|
||||
nanojit::LIns* p2i(nanojit::LIns* ins);
|
||||
|
||||
/*
|
||||
|
@ -1092,7 +1042,7 @@ class TraceRecorder
|
|||
|
||||
JS_REQUIRES_STACK void assertDownFrameIsConsistent(VMSideExit* anchor, FrameInfo* fi);
|
||||
|
||||
JS_REQUIRES_STACK void captureStackTypes(unsigned callDepth, TraceType* typeMap);
|
||||
JS_REQUIRES_STACK void captureStackTypes(unsigned callDepth, JSValueType* typeMap);
|
||||
|
||||
bool isGlobal(const Value* p) const;
|
||||
ptrdiff_t nativeGlobalSlot(const Value *p) const;
|
||||
|
@ -1100,10 +1050,10 @@ class TraceRecorder
|
|||
JS_REQUIRES_STACK ptrdiff_t nativeStackOffset(const Value* p) const;
|
||||
JS_REQUIRES_STACK ptrdiff_t nativeStackSlot(const Value* p) const;
|
||||
JS_REQUIRES_STACK ptrdiff_t nativespOffset(Value* p) const;
|
||||
JS_REQUIRES_STACK void import(nanojit::LIns* base, ptrdiff_t offset, const Value* p, TraceType t,
|
||||
JS_REQUIRES_STACK void import(nanojit::LIns* base, ptrdiff_t offset, const Value* p, JSValueType t,
|
||||
const char *prefix, uintN index, JSStackFrame *fp);
|
||||
JS_REQUIRES_STACK void import(TreeFragment* tree, nanojit::LIns* sp, unsigned stackSlots,
|
||||
unsigned callDepth, unsigned ngslots, TraceType* typeMap);
|
||||
unsigned callDepth, unsigned ngslots, JSValueType* typeMap);
|
||||
void trackNativeStackUse(unsigned slots);
|
||||
|
||||
JS_REQUIRES_STACK bool isValidSlot(JSScope* scope, JSScopeProperty* sprop);
|
||||
|
@ -1115,9 +1065,7 @@ class TraceRecorder
|
|||
JS_REQUIRES_STACK nanojit::LIns* guard_xov(nanojit::LOpcode op, nanojit::LIns* d0,
|
||||
nanojit::LIns* d1, VMSideExit* exit);
|
||||
JS_REQUIRES_STACK nanojit::LIns* slurpTypedSlot(nanojit::LIns* val_ins, ptrdiff_t offset, Value* vp,
|
||||
uint32 mask, VMSideExit* exit);
|
||||
JS_REQUIRES_STACK nanojit::LIns* slurpInt32Slot(nanojit::LIns* val_ins, ptrdiff_t offset, Value* vp,
|
||||
VMSideExit* exit);
|
||||
JSValueTag mask, VMSideExit* exit);
|
||||
JS_REQUIRES_STACK nanojit::LIns* slurpDoubleSlot(nanojit::LIns* val_ins, ptrdiff_t offset, Value* vp,
|
||||
VMSideExit* exit);
|
||||
JS_REQUIRES_STACK nanojit::LIns* slurpSlot(nanojit::LIns* val_ins, ptrdiff_t offset, Value* vp,
|
||||
|
@ -1288,6 +1236,8 @@ class TraceRecorder
|
|||
JS_REQUIRES_STACK AbortableRecordingStatus getProp(Value& v);
|
||||
JS_REQUIRES_STACK RecordingStatus getThis(nanojit::LIns*& this_ins);
|
||||
|
||||
JS_REQUIRES_STACK void storeHole(JSWhyMagic why, nanojit::LIns *addr_ins, ptrdiff_t offset,
|
||||
nanojit::AccSet accSet);
|
||||
JS_REQUIRES_STACK AbortableRecordingStatus unboxNextValue(nanojit::LIns* &v_ins);
|
||||
|
||||
JS_REQUIRES_STACK VMSideExit* enterDeepBailCall();
|
||||
|
@ -1337,12 +1287,16 @@ class TraceRecorder
|
|||
JS_REQUIRES_STACK nanojit::LIns* unbox_string(const Value &v, nanojit::LIns *vaddr_ins,
|
||||
ptrdiff_t offset);
|
||||
JS_REQUIRES_STACK nanojit::LIns* unbox_object(nanojit::LIns *vaddr_ins, ptrdiff_t offset);
|
||||
JS_REQUIRES_STACK nanojit::LIns* is_boxed_int(nanojit::LIns *vaddr_ins);
|
||||
JS_REQUIRES_STACK nanojit::LIns* is_boxed_object(nanojit::LIns *vaddr_ins);
|
||||
JS_REQUIRES_STACK nanojit::LIns* is_boxed_true(nanojit::LIns *vaddr_ins);
|
||||
|
||||
JS_REQUIRES_STACK nanojit::LIns* is_string_id(nanojit::LIns *id_ins);
|
||||
JS_REQUIRES_STACK nanojit::LIns* unbox_string_id(nanojit::LIns *id_ins);
|
||||
JS_REQUIRES_STACK nanojit::LIns* unbox_int_id(nanojit::LIns *id_ins);
|
||||
|
||||
JS_REQUIRES_STACK void box_value(const Value &v, nanojit::LIns* v_ins,
|
||||
nanojit::LIns *dstaddr_ins, ptrdiff_t offset);
|
||||
nanojit::LIns *dstaddr_ins, ptrdiff_t offset,
|
||||
nanojit::AccSet accSet);
|
||||
JS_REQUIRES_STACK nanojit::LIns* box_value(const Value &v, nanojit::LIns* v_ins);
|
||||
|
||||
JS_REQUIRES_STACK void guardClassHelper(bool cond, nanojit::LIns* obj_ins, Class* clasp,
|
||||
|
@ -1403,7 +1357,7 @@ class TraceRecorder
|
|||
|
||||
JS_REQUIRES_STACK jsatomid getFullIndex(ptrdiff_t pcoff = 0);
|
||||
|
||||
JS_REQUIRES_STACK TraceType determineSlotType(Value* vp);
|
||||
JS_REQUIRES_STACK JSValueType determineSlotType(Value* vp);
|
||||
|
||||
JS_REQUIRES_STACK RecordingStatus setUpwardTrackedVar(Value* stackVp, const Value& v,
|
||||
nanojit::LIns* v_ins);
|
||||
|
@ -1418,7 +1372,7 @@ class TraceRecorder
|
|||
JS_REQUIRES_STACK void adjustCallerTypes(TreeFragment* f);
|
||||
JS_REQUIRES_STACK void prepareTreeCall(TreeFragment* inner);
|
||||
JS_REQUIRES_STACK void emitTreeCall(TreeFragment* inner, VMSideExit* exit);
|
||||
JS_REQUIRES_STACK void determineGlobalTypes(TraceType* typeMap);
|
||||
JS_REQUIRES_STACK void determineGlobalTypes(JSValueType* typeMap);
|
||||
JS_REQUIRES_STACK VMSideExit* downSnapshot(FrameInfo* downFrame);
|
||||
JS_REQUIRES_STACK TreeFragment* findNestedCompatiblePeer(TreeFragment* f);
|
||||
JS_REQUIRES_STACK AbortableRecordingStatus attemptTreeCall(TreeFragment* inner,
|
||||
|
@ -1443,7 +1397,7 @@ class TraceRecorder
|
|||
|
||||
JS_REQUIRES_STACK
|
||||
TraceRecorder(JSContext* cx, VMSideExit*, VMFragment*,
|
||||
unsigned stackSlots, unsigned ngslots, TraceType* typeMap,
|
||||
unsigned stackSlots, unsigned ngslots, JSValueType* typeMap,
|
||||
VMSideExit* expectedInnerExit, jsbytecode* outerTree,
|
||||
uint32 outerArgc, RecordReason reason);
|
||||
|
||||
|
@ -1470,7 +1424,7 @@ class TraceRecorder
|
|||
public:
|
||||
static bool JS_REQUIRES_STACK
|
||||
startRecorder(JSContext*, VMSideExit*, VMFragment*,
|
||||
unsigned stackSlots, unsigned ngslots, TraceType* typeMap,
|
||||
unsigned stackSlots, unsigned ngslots, JSValueType* typeMap,
|
||||
VMSideExit* expectedInnerExit, jsbytecode* outerTree,
|
||||
uint32 outerArgc, RecordReason reason);
|
||||
|
||||
|
@ -1569,8 +1523,8 @@ GetBuiltinFunction(JSContext *cx, uintN index);
|
|||
extern void
|
||||
SetMaxCodeCacheBytes(JSContext* cx, uint32 bytes);
|
||||
|
||||
extern bool
|
||||
NativeToValue(JSContext* cx, Value& v, TraceType type, double* slot);
|
||||
extern void
|
||||
ExternNativeToValue(JSContext* cx, Value& v, JSValueType type, double* slot);
|
||||
|
||||
#ifdef MOZ_TRACEVIS
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ TypedArray::obj_trace(JSTracer *trc, JSObject *obj)
|
|||
JSBool
|
||||
TypedArray::obj_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
|
||||
{
|
||||
*attrsp = (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom))
|
||||
*attrsp = (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
|
||||
? JSPROP_PERMANENT | JSPROP_READONLY
|
||||
: JSPROP_PERMANENT | JSPROP_ENUMERATE;
|
||||
return true;
|
||||
|
@ -517,7 +517,7 @@ class TypedArrayTemplate
|
|||
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
||||
JS_ASSERT(tarray);
|
||||
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
vp->setNumber(tarray->length);
|
||||
return true;
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ class TypedArrayTemplate
|
|||
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
||||
JS_ASSERT(tarray);
|
||||
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
vp->setNumber(tarray->length);
|
||||
return true;
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ class TypedArrayTemplate
|
|||
obj_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *v,
|
||||
PropertyOp getter, PropertyOp setter, uintN attrs)
|
||||
{
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom))
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
|
||||
return true;
|
||||
|
||||
Value tmp = *v;
|
||||
|
@ -646,7 +646,7 @@ class TypedArrayTemplate
|
|||
static JSBool
|
||||
obj_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval)
|
||||
{
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
rval->setBoolean(false);
|
||||
return true;
|
||||
}
|
||||
|
@ -1196,10 +1196,7 @@ void
|
|||
TypedArrayTemplate<int32>::copyIndexToValue(JSContext *cx, uint32 index, Value *vp)
|
||||
{
|
||||
int32 val = getIndex(index);
|
||||
if (val <= JSVAL_INT_MAX)
|
||||
vp->setInt32(val);
|
||||
else
|
||||
vp->setDouble(val);
|
||||
vp->setInt32(val);
|
||||
}
|
||||
|
||||
template<>
|
||||
|
@ -1207,10 +1204,7 @@ void
|
|||
TypedArrayTemplate<uint32>::copyIndexToValue(JSContext *cx, uint32 index, Value *vp)
|
||||
{
|
||||
uint32 val = getIndex(index);
|
||||
if (val <= JSVAL_INT_MAX)
|
||||
vp->setInt32(val);
|
||||
else
|
||||
vp->setDouble(val);
|
||||
vp->setNumber(val);
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
149
js/src/jsxml.cpp
149
js/src/jsxml.cpp
|
@ -72,6 +72,7 @@
|
|||
#include "jsstaticcheck.h"
|
||||
#include "jsvector.h"
|
||||
|
||||
#include "jsatominlines.h"
|
||||
#include "jscntxtinlines.h"
|
||||
#include "jsobjinlines.h"
|
||||
|
||||
|
@ -189,7 +190,7 @@ AppendString(JSCharBuffer &cb, JSString *str)
|
|||
|
||||
#define DEFINE_GETTER(name,code) \
|
||||
static JSBool \
|
||||
name(JSContext *cx, JSObject *obj, jsval id, jsval *vp) \
|
||||
name(JSContext *cx, JSObject *obj, jsid id, jsval *vp) \
|
||||
{ \
|
||||
code; \
|
||||
return true; \
|
||||
|
@ -211,12 +212,12 @@ namespace_finalize(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
namespace_equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
namespace_equality(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
|
||||
{
|
||||
JSObject *obj2;
|
||||
|
||||
JS_ASSERT(JSVAL_IS_OBJECT(v));
|
||||
obj2 = JSVAL_TO_OBJECT(v);
|
||||
JS_ASSERT(v->isObjectOrNull());
|
||||
obj2 = v->asObjectOrNull();
|
||||
*bp = (!obj2 || obj2->getClass() != &js_NamespaceClass.base)
|
||||
? JS_FALSE
|
||||
: js_EqualStrings(GetURI(obj), GetURI(obj2));
|
||||
|
@ -232,7 +233,7 @@ JS_FRIEND_DATA(ExtendedClass) js_NamespaceClass = {
|
|||
EnumerateStub, ResolveStub, ConvertStub, namespace_finalize,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL },
|
||||
Valueify(namespace_equality),NULL, NULL, NULL,
|
||||
namespace_equality,NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
|
@ -315,11 +316,11 @@ qname_identity(JSObject *qna, JSObject *qnb)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
qname_equality(JSContext *cx, JSObject *qn, Value v, JSBool *bp)
|
||||
qname_equality(JSContext *cx, JSObject *qn, const Value *v, JSBool *bp)
|
||||
{
|
||||
JSObject *obj2;
|
||||
|
||||
obj2 = v.asObjectOrNull();
|
||||
obj2 = v->asObjectOrNull();
|
||||
*bp = (!obj2 || obj2->getClass() != &js_QNameClass.base)
|
||||
? JS_FALSE
|
||||
: qname_identity(qn, obj2);
|
||||
|
@ -2751,7 +2752,7 @@ IsFunctionQName(JSContext *cx, JSObject *qn, jsid *funidp)
|
|||
js_EqualStrings(uri, ATOM_TO_STRING(atom)))) {
|
||||
return JS_ValueToId(cx, STRING_TO_JSVAL(GetLocalName(qn)), funidp);
|
||||
}
|
||||
*funidp = 0;
|
||||
*funidp = JSID_VOID;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -2760,13 +2761,14 @@ js_IsFunctionQName(JSContext *cx, JSObject *obj, jsid *funidp)
|
|||
{
|
||||
if (obj->getClass() == &js_QNameClass.base)
|
||||
return IsFunctionQName(cx, obj, funidp);
|
||||
*funidp = 0;
|
||||
*funidp = JSID_VOID;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSObject *
|
||||
ToXMLName(JSContext *cx, jsval v, jsid *funidp)
|
||||
{
|
||||
JSAtom *atomizedName;
|
||||
JSString *name;
|
||||
JSObject *obj;
|
||||
Class *clasp;
|
||||
|
@ -2793,6 +2795,10 @@ ToXMLName(JSContext *cx, jsval v, jsid *funidp)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
atomizedName = js_AtomizeString(cx, name, 0);
|
||||
if (!atomizedName)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* ECMA-357 10.6.1 step 1 seems to be incorrect. The spec says:
|
||||
*
|
||||
|
@ -2806,14 +2812,14 @@ ToXMLName(JSContext *cx, jsval v, jsid *funidp)
|
|||
* If the idea is to reject uint32 property names, then the check needs to
|
||||
* be stricter, to exclude hexadecimal and floating point literals.
|
||||
*/
|
||||
if (js_IdIsIndex(STRING_TO_JSVAL(name), &index))
|
||||
if (js_IdIsIndex(ATOM_TO_JSID(atomizedName), &index))
|
||||
goto bad;
|
||||
|
||||
if (*name->chars() == '@') {
|
||||
name = js_NewDependentString(cx, name, 1, name->length() - 1);
|
||||
if (!name)
|
||||
return NULL;
|
||||
*funidp = 0;
|
||||
*funidp = JSID_VOID;
|
||||
return ToAttributeName(cx, STRING_TO_JSVAL(name));
|
||||
}
|
||||
|
||||
|
@ -3180,7 +3186,7 @@ Descendants(JSContext *cx, JSXML *xml, jsval id)
|
|||
if (!listobj)
|
||||
return NULL;
|
||||
list = (JSXML *) listobj->getPrivate();
|
||||
if (funid)
|
||||
if (!JSID_IS_VOID(funid))
|
||||
return list;
|
||||
|
||||
/*
|
||||
|
@ -3420,17 +3426,21 @@ Insert(JSContext *cx, JSXML *xml, uint32 i, jsval v)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
IndexToIdVal(JSContext *cx, uint32 index, jsval *idvp)
|
||||
IndexToId(JSContext *cx, uint32 index, jsid *idp)
|
||||
{
|
||||
JSAtom *atom;
|
||||
JSString *str;
|
||||
|
||||
if (index <= JSVAL_INT_MAX) {
|
||||
*idvp = INT_TO_JSVAL(index);
|
||||
if (index <= JSID_INT_MAX) {
|
||||
*idp = INT_TO_JSID(index);
|
||||
} else {
|
||||
str = js_NumberToString(cx, (jsdouble) index);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
*idvp = STRING_TO_JSVAL(str);
|
||||
atom = js_AtomizeString(cx, str, 0);
|
||||
if (!atom)
|
||||
return JS_FALSE;
|
||||
*idp = ATOM_TO_JSID(atom);
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -3686,10 +3696,10 @@ GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||
/*
|
||||
* ECMA-357 9.2.1.1/9.1.1.1 qname case.
|
||||
*/
|
||||
nameqn = ToXMLName(cx, ID_TO_JSVAL(id), &funid);
|
||||
nameqn = ToXMLName(cx, IdToJsval(id), &funid);
|
||||
if (!nameqn)
|
||||
return false;
|
||||
if (funid)
|
||||
if (!JSID_IS_VOID(funid))
|
||||
return GetXMLFunction(cx, obj, funid, vp);
|
||||
|
||||
jsval roots[2] = { OBJECT_TO_JSVAL(nameqn), JSVAL_NULL };
|
||||
|
@ -3791,14 +3801,14 @@ PutProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||
MUST_FLOW_THROUGH("out");
|
||||
jsval roots[3];
|
||||
roots[OBJ_ROOT] = OBJECT_TO_JSVAL(obj);
|
||||
roots[ID_ROOT] = ID_TO_JSVAL(id);
|
||||
roots[ID_ROOT] = IdToJsval(id);
|
||||
roots[VAL_ROOT] = *vp;
|
||||
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(roots), Valueify(roots));
|
||||
|
||||
if (js_IdIsIndex(id, &index)) {
|
||||
if (xml->xml_class != JSXML_CLASS_LIST) {
|
||||
/* See NOTE in spec: this variation is reserved for future use. */
|
||||
ReportBadXMLName(cx, ID_TO_VALUE(id));
|
||||
ReportBadXMLName(cx, IdToValue(id));
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@ -4092,10 +4102,10 @@ PutProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||
/*
|
||||
* ECMA-357 9.2.1.2/9.1.1.2 qname case.
|
||||
*/
|
||||
nameqn = ToXMLName(cx, ID_TO_JSVAL(id), &funid);
|
||||
nameqn = ToXMLName(cx, IdToJsval(id), &funid);
|
||||
if (!nameqn)
|
||||
goto bad;
|
||||
if (funid) {
|
||||
if (!JSID_IS_VOID(funid)) {
|
||||
ok = js_SetProperty(cx, obj, funid, Valueify(vp));
|
||||
goto out;
|
||||
}
|
||||
|
@ -4272,7 +4282,7 @@ PutProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||
}
|
||||
|
||||
/* 10-11. */
|
||||
id = JSVAL_VOID;
|
||||
id = JSID_VOID;
|
||||
primitiveAssign = !vxml && !IS_STAR(GetLocalName(nameqn));
|
||||
|
||||
/* 12. */
|
||||
|
@ -4386,7 +4396,7 @@ out:
|
|||
type_error:
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_BAD_XMLLIST_PUT,
|
||||
js_ValueToPrintableString(cx, ID_TO_VALUE(id)));
|
||||
js_ValueToPrintableString(cx, IdToValue(id)));
|
||||
bad:
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
|
@ -4544,7 +4554,7 @@ HasFunctionProperty(JSContext *cx, JSObject *obj, jsid funid, JSBool *found)
|
|||
|
||||
/* ECMA-357 9.1.1.6 XML [[HasProperty]] and 9.2.1.5 XMLList [[HasProperty]]. */
|
||||
static JSBool
|
||||
HasProperty(JSContext *cx, JSObject *obj, jsid id, JSBool *found)
|
||||
HasProperty(JSContext *cx, JSObject *obj, jsval id, JSBool *found)
|
||||
{
|
||||
JSXML *xml;
|
||||
uint32 i;
|
||||
|
@ -4552,13 +4562,13 @@ HasProperty(JSContext *cx, JSObject *obj, jsid id, JSBool *found)
|
|||
jsid funid;
|
||||
|
||||
xml = (JSXML *) obj->getPrivate();
|
||||
if (js_IdIsIndex(id, &i)) {
|
||||
if (js_IdValIsIndex(id, &i)) {
|
||||
*found = HasIndexedProperty(xml, i);
|
||||
} else {
|
||||
qn = ToXMLName(cx, ID_TO_JSVAL(id), &funid);
|
||||
qn = ToXMLName(cx, id, &funid);
|
||||
if (!qn)
|
||||
return JS_FALSE;
|
||||
if (funid) {
|
||||
if (!JSID_IS_VOID(funid)) {
|
||||
if (!HasFunctionProperty(cx, obj, funid, found))
|
||||
return JS_FALSE;
|
||||
} else {
|
||||
|
@ -4632,10 +4642,10 @@ xml_lookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
|
|||
if (js_IdIsIndex(id, &i)) {
|
||||
found = HasIndexedProperty(xml, i);
|
||||
} else {
|
||||
qn = ToXMLName(cx, ID_TO_JSVAL(id), &funid);
|
||||
qn = ToXMLName(cx, IdToJsval(id), &funid);
|
||||
if (!qn)
|
||||
return JS_FALSE;
|
||||
if (funid)
|
||||
if (!JSID_IS_VOID(funid))
|
||||
return js_LookupProperty(cx, obj, funid, objp, propp);
|
||||
found = HasNamedProperty(xml, qn);
|
||||
}
|
||||
|
@ -4674,7 +4684,7 @@ xml_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *v,
|
|||
static JSBool
|
||||
xml_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
{
|
||||
if (id == JS_DEFAULT_XML_NAMESPACE_ID) {
|
||||
if (JSID_IS_DEFAULT_XML_NAMESPACE(id)) {
|
||||
vp->setUndefined();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -4692,7 +4702,7 @@ static JSBool
|
|||
xml_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
|
||||
{
|
||||
JSBool found;
|
||||
if (!HasProperty(cx, obj, id, &found))
|
||||
if (!HasProperty(cx, obj, IdToJsval(id), &found))
|
||||
return false;
|
||||
|
||||
*attrsp = found ? JSPROP_ENUMERATE : 0;
|
||||
|
@ -4703,7 +4713,7 @@ static JSBool
|
|||
xml_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
|
||||
{
|
||||
JSBool found;
|
||||
if (!HasProperty(cx, obj, id, &found))
|
||||
if (!HasProperty(cx, obj, IdToJsval(id), &found))
|
||||
return false;
|
||||
|
||||
if (found) {
|
||||
|
@ -4723,12 +4733,12 @@ xml_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval)
|
|||
JSObject *nameqn;
|
||||
jsid funid;
|
||||
|
||||
idval = ID_TO_JSVAL(id);
|
||||
idval = IdToJsval(id);
|
||||
xml = (JSXML *) obj->getPrivate();
|
||||
if (js_IdIsIndex(id, &index)) {
|
||||
if (xml->xml_class != JSXML_CLASS_LIST) {
|
||||
/* See NOTE in spec: this variation is reserved for future use. */
|
||||
ReportBadXMLName(cx, ID_TO_VALUE(id));
|
||||
ReportBadXMLName(cx, IdToValue(id));
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -4738,7 +4748,7 @@ xml_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval)
|
|||
nameqn = ToXMLName(cx, idval, &funid);
|
||||
if (!nameqn)
|
||||
return JS_FALSE;
|
||||
if (funid)
|
||||
if (!JSID_IS_VOID(funid))
|
||||
return js_DeleteProperty(cx, obj, funid, rval);
|
||||
|
||||
DeleteNamedProperty(cx, xml, nameqn,
|
||||
|
@ -4836,7 +4846,7 @@ xml_typeOf(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
xml_hasInstance(JSContext *cx, JSObject *obj, Value, JSBool *bp)
|
||||
xml_hasInstance(JSContext *cx, JSObject *obj, const Value *, JSBool *bp)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -4903,7 +4913,7 @@ js_GetXMLMethod(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
|||
|
||||
if (!js_IsFunctionQName(cx, JSID_TO_OBJECT(id), &funid))
|
||||
return JS_FALSE;
|
||||
if (funid != 0)
|
||||
if (!JSID_IS_VOID(funid))
|
||||
id = funid;
|
||||
}
|
||||
|
||||
|
@ -5173,7 +5183,7 @@ xml_appendChild(JSContext *cx, uintN argc, jsval *vp)
|
|||
vxml = (JSXML *) vobj->getPrivate();
|
||||
JS_ASSERT(vxml->xml_class == JSXML_CLASS_LIST);
|
||||
|
||||
if (!IndexToIdVal(cx, vxml->xml_kids.length, &name))
|
||||
if (!IndexToId(cx, vxml->xml_kids.length, &name))
|
||||
return JS_FALSE;
|
||||
*vp = (argc != 0) ? vp[2] : JSVAL_VOID;
|
||||
|
||||
|
@ -5234,6 +5244,29 @@ xml_list_helper(JSContext *cx, JSXML *xml, jsval *rval)
|
|||
return list;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
ValueToId(JSContext *cx, jsval v, AutoIdRooter *idr)
|
||||
{
|
||||
if (JSVAL_IS_INT(v)) {
|
||||
jsint i = JSVAL_TO_INT(v);
|
||||
if (INT_FITS_IN_JSID(i))
|
||||
*idr->addr() = INT_TO_JSID(i);
|
||||
else if (!js_ValueToStringId(cx, Valueify(v), idr->addr()))
|
||||
return JS_FALSE;
|
||||
} else if (JSVAL_IS_STRING(v)) {
|
||||
JSAtom *atom = js_AtomizeString(cx, JSVAL_TO_STRING(v), 0);
|
||||
if (!atom)
|
||||
return JS_FALSE;
|
||||
*idr->addr() = ATOM_TO_JSID(atom);
|
||||
} else if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||
*idr->addr() = OBJECT_TO_JSID(JSVAL_TO_OBJECT(v));
|
||||
} else {
|
||||
ReportBadXMLName(cx, Valueify(v));
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
xml_child_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval name,
|
||||
jsval *rval)
|
||||
|
@ -5245,7 +5278,7 @@ xml_child_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval name,
|
|||
/* ECMA-357 13.4.4.6 */
|
||||
JS_ASSERT(xml->xml_class != JSXML_CLASS_LIST);
|
||||
|
||||
if (js_IdIsIndex(name, &index)) {
|
||||
if (js_IdValIsIndex(name, &index)) {
|
||||
if (index >= JSXML_LENGTH(xml)) {
|
||||
*rval = JSVAL_VOID;
|
||||
} else {
|
||||
|
@ -5262,11 +5295,11 @@ xml_child_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval name,
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* N.B. name is not actually a jsid: name may contain an non-interned
|
||||
* string. Apparently, PutProperty is cool with this.
|
||||
*/
|
||||
return GetProperty(cx, obj, name, rval);
|
||||
AutoIdRooter idr(cx);
|
||||
if (!ValueToId(cx, name, &idr))
|
||||
return JS_FALSE;
|
||||
|
||||
return GetProperty(cx, obj, idr.id(), rval);
|
||||
}
|
||||
|
||||
/* XML and XMLList */
|
||||
|
@ -5461,13 +5494,7 @@ xml_descendants(JSContext *cx, uintN argc, jsval *vp)
|
|||
JSXML *list;
|
||||
|
||||
XML_METHOD_PROLOG;
|
||||
|
||||
name = argc == 0 ? ATOM_TO_JSVAL(cx->runtime->atomState.starAtom) : vp[2];
|
||||
|
||||
/*
|
||||
* N.B. name is not actually a jsid: name may contain an non-interned
|
||||
* string. Apparently, PutProperty is cool with this.
|
||||
*/
|
||||
list = Descendants(cx, xml, name);
|
||||
if (!list)
|
||||
return JS_FALSE;
|
||||
|
@ -5549,7 +5576,7 @@ xml_elements(JSContext *cx, uintN argc, jsval *vp)
|
|||
return JS_FALSE;
|
||||
vp[2] = OBJECT_TO_JSVAL(nameqn);
|
||||
|
||||
if (funid)
|
||||
if (!JSID_IS_VOID(funid))
|
||||
return xml_list_helper(cx, xml, vp) != NULL;
|
||||
|
||||
return xml_elements_helper(cx, obj, xml, nameqn, vp);
|
||||
|
@ -6105,7 +6132,7 @@ xml_processingInstructions(JSContext *cx, uintN argc, jsval *vp)
|
|||
return JS_FALSE;
|
||||
vp[2] = OBJECT_TO_JSVAL(nameqn);
|
||||
|
||||
if (funid)
|
||||
if (!JSID_IS_VOID(funid))
|
||||
return xml_list_helper(cx, xml, vp) != NULL;
|
||||
|
||||
return xml_processingInstructions_helper(cx, obj, xml, nameqn, vp);
|
||||
|
@ -6130,7 +6157,7 @@ xml_propertyIsEnumerable(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
XML_METHOD_PROLOG;
|
||||
*vp = JSVAL_FALSE;
|
||||
if (argc != 0 && js_IdIsIndex(vp[2], &index)) {
|
||||
if (argc != 0 && js_IdValIsIndex(vp[2], &index)) {
|
||||
if (xml->xml_class == JSXML_CLASS_LIST) {
|
||||
/* 13.5.4.18. */
|
||||
*vp = BOOLEAN_TO_JSVAL(index < xml->xml_kids.length);
|
||||
|
@ -6254,7 +6281,7 @@ xml_replace(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!xml)
|
||||
return JS_FALSE;
|
||||
|
||||
if (argc == 0 || !js_IdIsIndex(vp[2], &index)) {
|
||||
if (argc == 0 || !js_IdValIsIndex(vp[2], &index)) {
|
||||
/*
|
||||
* Call function QName per spec, not ToXMLName, to avoid attribute
|
||||
* names.
|
||||
|
@ -6299,7 +6326,7 @@ xml_setChildren(JSContext *cx, uintN argc, jsval *vp)
|
|||
return JS_FALSE;
|
||||
|
||||
*vp = argc != 0 ? vp[2] : JSVAL_VOID; /* local root */
|
||||
if (!PutProperty(cx, obj, ATOM_TO_JSVAL(cx->runtime->atomState.starAtom), vp))
|
||||
if (!PutProperty(cx, obj, ATOM_TO_JSID(cx->runtime->atomState.starAtom), vp))
|
||||
return JS_FALSE;
|
||||
|
||||
*vp = OBJECT_TO_JSVAL(obj);
|
||||
|
@ -7194,7 +7221,7 @@ js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp)
|
|||
Class *clasp = tmp->getClass();
|
||||
if (clasp == &js_BlockClass || clasp == &js_WithClass)
|
||||
continue;
|
||||
if (!tmp->getProperty(cx, JS_DEFAULT_XML_NAMESPACE_ID, Valueify(&v)))
|
||||
if (!tmp->getProperty(cx, JSID_DEFAULT_XML_NAMESPACE(), Valueify(&v)))
|
||||
return JS_FALSE;
|
||||
if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||
*vp = v;
|
||||
|
@ -7207,7 +7234,7 @@ js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp)
|
|||
if (!ns)
|
||||
return JS_FALSE;
|
||||
v = OBJECT_TO_JSVAL(ns);
|
||||
if (!obj->defineProperty(cx, JS_DEFAULT_XML_NAMESPACE_ID, Valueify(v),
|
||||
if (!obj->defineProperty(cx, JSID_DEFAULT_XML_NAMESPACE(), Valueify(v),
|
||||
PropertyStub, PropertyStub, JSPROP_PERMANENT)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -7230,7 +7257,7 @@ js_SetDefaultXMLNamespace(JSContext *cx, const Value &v)
|
|||
|
||||
fp = js_GetTopStackFrame(cx);
|
||||
varobj = fp->varobj(cx);
|
||||
if (!varobj->defineProperty(cx, JS_DEFAULT_XML_NAMESPACE_ID, NonFunObjTag(*ns),
|
||||
if (!varobj->defineProperty(cx, JSID_DEFAULT_XML_NAMESPACE(), NonFunObjTag(*ns),
|
||||
PropertyStub, PropertyStub,
|
||||
JSPROP_PERMANENT)) {
|
||||
return JS_FALSE;
|
||||
|
@ -7430,7 +7457,7 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *i
|
|||
}
|
||||
|
||||
if (target->isXML()) {
|
||||
if (funid == 0) {
|
||||
if (JSID_IS_VOID(funid)) {
|
||||
xml = (JSXML *) target->getPrivate();
|
||||
found = HasNamedProperty(xml, qn);
|
||||
} else {
|
||||
|
@ -7442,7 +7469,7 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *i
|
|||
*objp = target;
|
||||
return JS_TRUE;
|
||||
}
|
||||
} else if (funid != 0) {
|
||||
} else if (!JSID_IS_VOID(funid)) {
|
||||
if (!target->lookupProperty(cx, funid, &pobj, &prop))
|
||||
return JS_FALSE;
|
||||
if (prop) {
|
||||
|
|
|
@ -268,7 +268,7 @@ js_GetFunctionNamespace(JSContext *cx, js::Value *vp);
|
|||
|
||||
/*
|
||||
* If obj is QName corresponding to function::name, set *funidp to name's id,
|
||||
* otherwise set *funidp to 0.
|
||||
* otherwise set *funidp to void.
|
||||
*/
|
||||
JSBool
|
||||
js_IsFunctionQName(JSContext *cx, JSObject *obj, jsid *funidp);
|
||||
|
|
|
@ -233,6 +233,17 @@ public:
|
|||
}
|
||||
JS_AddNamedStringRoot(cx, &mStr, "Value ToString helper");
|
||||
}
|
||||
ToString(JSContext *aCx, jsid id, JSBool aThrow = JS_FALSE)
|
||||
: cx(aCx)
|
||||
, mThrow(aThrow)
|
||||
{
|
||||
mStr = JS_ValueToString(cx, IdToJsval(id));
|
||||
if (!aThrow && !mStr && JS_IsExceptionPending(cx)) {
|
||||
if (!JS_ReportPendingException(cx))
|
||||
JS_ClearPendingException(cx);
|
||||
}
|
||||
JS_AddNamedStringRoot(cx, &mStr, "Value ToString helper");
|
||||
}
|
||||
~ToString() {
|
||||
JS_RemoveStringRoot(cx, &mStr);
|
||||
}
|
||||
|
@ -2652,7 +2663,7 @@ split_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
if (!JS_NextProperty(cx, iterator, idp))
|
||||
return JS_FALSE;
|
||||
|
||||
if (!JSVAL_IS_VOID(*idp))
|
||||
if (!JSID_IS_VOID(*idp))
|
||||
break;
|
||||
/* Fall through. */
|
||||
|
||||
|
@ -2764,7 +2775,7 @@ split_getObjectOps(JSContext *cx, JSClass *clasp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
split_equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
split_equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
|
||||
|
||||
static JSObject *
|
||||
split_innerObject(JSContext *cx, JSObject *obj)
|
||||
|
@ -2795,13 +2806,13 @@ static JSExtendedClass split_global_class = {
|
|||
};
|
||||
|
||||
static JSBool
|
||||
split_equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
split_equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp)
|
||||
{
|
||||
*bp = JS_FALSE;
|
||||
if (JSVAL_IS_PRIMITIVE(v))
|
||||
if (JSVAL_IS_PRIMITIVE(*v))
|
||||
return JS_TRUE;
|
||||
|
||||
JSObject *obj2 = JSVAL_TO_OBJECT(v);
|
||||
JSObject *obj2 = JSVAL_TO_OBJECT(*v);
|
||||
if (JS_GET_CLASS(cx, obj2) != &split_global_class.base)
|
||||
return JS_TRUE;
|
||||
|
||||
|
@ -4397,7 +4408,7 @@ its_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
if (!JS_NextProperty(cx, iterator, idp))
|
||||
return JS_FALSE;
|
||||
|
||||
if (!JSVAL_IS_VOID(*idp))
|
||||
if (!JSID_IS_VOID(*idp))
|
||||
break;
|
||||
/* Fall through. */
|
||||
|
||||
|
|
|
@ -12,6 +12,6 @@ for each (var i in a)
|
|||
|
||||
checkStats({
|
||||
recorderAborted:0,
|
||||
traceCompleted:1,
|
||||
sideExitIntoInterpreter:1
|
||||
traceCompleted:2,
|
||||
sideExitIntoInterpreter:2
|
||||
});
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
var obj = { a:1, b:1, c:1, d:1, e:1, f:1, g:1 };
|
||||
var sum = 0;
|
||||
for each (var i in obj) {
|
||||
sum += i;
|
||||
delete obj.f;
|
||||
}
|
||||
|
||||
// this isn't even implemented to work yet; just don't crash or iloop
|
|
@ -122,23 +122,23 @@ interface nsIXPCScriptable : nsISupports
|
|||
in JSContextPtr cx, in JSObjectPtr obj);
|
||||
|
||||
PRBool addProperty(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsval id,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
|
||||
in JSValPtr vp);
|
||||
|
||||
PRBool delProperty(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsval id,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
|
||||
in JSValPtr vp);
|
||||
|
||||
// The returnCode should be set to NS_SUCCESS_I_DID_SOMETHING if
|
||||
// this method does something.
|
||||
PRBool getProperty(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsval id,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
|
||||
in JSValPtr vp);
|
||||
|
||||
// The returnCode should be set to NS_SUCCESS_I_DID_SOMETHING if
|
||||
// this method does something.
|
||||
PRBool setProperty(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsval id,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
|
||||
in JSValPtr vp);
|
||||
|
||||
PRBool enumerate(in nsIXPConnectWrappedNative wrapper,
|
||||
|
@ -146,10 +146,10 @@ interface nsIXPCScriptable : nsISupports
|
|||
|
||||
PRBool newEnumerate(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj,
|
||||
in PRUint32 enum_op, in JSValPtr statep, out JSID idp);
|
||||
in PRUint32 enum_op, in JSValPtr statep, out jsid idp);
|
||||
|
||||
PRBool newResolve(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsval id,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
|
||||
in PRUint32 flags, out JSObjectPtr objp);
|
||||
|
||||
PRBool convert(in nsIXPConnectWrappedNative wrapper,
|
||||
|
@ -160,7 +160,7 @@ interface nsIXPCScriptable : nsISupports
|
|||
in JSContextPtr cx, in JSObjectPtr obj);
|
||||
|
||||
PRBool checkAccess(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsval id,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
|
||||
in PRUint32 mode, in JSValPtr vp);
|
||||
|
||||
PRBool call(in nsIXPConnectWrappedNative wrapper,
|
||||
|
|
|
@ -108,6 +108,6 @@ interface nsIXPCSecurityManager : nsISupports
|
|||
in JSObjectPtr aJSObject,
|
||||
in nsISupports aObj,
|
||||
in nsIClassInfo aClassInfo,
|
||||
in jsval aName,
|
||||
in jsid aName,
|
||||
inout voidPtr aPolicy);
|
||||
};
|
||||
|
|
|
@ -59,15 +59,15 @@
|
|||
|
||||
/***************************************************************************/
|
||||
|
||||
// NB: jsval is declared in nsIVariant.idl
|
||||
// NB: jsval and jsid are declared in nsIVariant.idl
|
||||
|
||||
[ptr] native JSContextPtr(JSContext);
|
||||
[ptr] native JSClassPtr(JSClass);
|
||||
[ptr] native JSObjectPtr(JSObject);
|
||||
[ptr] native JSValPtr(jsval);
|
||||
[ptr] native JSValConstPtr(const jsval);
|
||||
native JSPropertyOp(JSPropertyOp);
|
||||
native JSEqualityOp(JSEqualityOp);
|
||||
native JSID(jsid);
|
||||
[ptr] native voidPtrPtr(void*);
|
||||
[ptr] native nsScriptObjectTracerPtr(nsScriptObjectTracer);
|
||||
[ref] native nsCCTraversalCallbackRef(nsCycleCollectionTraversalCallback);
|
||||
|
@ -180,8 +180,8 @@ interface nsIXPConnectWrappedNative : nsIXPConnectJSObjectHolder
|
|||
*/
|
||||
|
||||
readonly attribute nsIXPConnect XPConnect;
|
||||
nsIInterfaceInfo FindInterfaceWithMember(in jsval nameID);
|
||||
nsIInterfaceInfo FindInterfaceWithName(in jsval nameID);
|
||||
nsIInterfaceInfo FindInterfaceWithMember(in jsid nameID);
|
||||
nsIInterfaceInfo FindInterfaceWithName(in jsid nameID);
|
||||
|
||||
void debugDump(in short depth);
|
||||
|
||||
|
|
|
@ -148,22 +148,22 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::PostCreate(nsIXPConnectWrappedNative *wrapper,
|
|||
#endif
|
||||
|
||||
#ifndef XPC_MAP_WANT_ADDPROPERTY
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsval id, jsval * vp, PRBool *_retval)
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsid id, jsval * vp, PRBool *_retval)
|
||||
{NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
|
||||
#endif
|
||||
|
||||
#ifndef XPC_MAP_WANT_DELPROPERTY
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsval id, jsval * vp, PRBool *_retval)
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsid id, jsval * vp, PRBool *_retval)
|
||||
{NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
|
||||
#endif
|
||||
|
||||
#ifndef XPC_MAP_WANT_GETPROPERTY
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsval id, jsval * vp, PRBool *_retval)
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsid id, jsval * vp, PRBool *_retval)
|
||||
{NS_WARNING("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
|
||||
#endif
|
||||
|
||||
#ifndef XPC_MAP_WANT_SETPROPERTY
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsval id, jsval * vp, PRBool *_retval)
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsid id, jsval * vp, PRBool *_retval)
|
||||
{NS_WARNING("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
|
||||
#endif
|
||||
|
||||
|
@ -178,7 +178,7 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::Enumerate(nsIXPConnectWrappedNative *wrapper, J
|
|||
#endif
|
||||
|
||||
#ifndef XPC_MAP_WANT_NEWRESOLVE
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsval id, PRUint32 flags, JSObject * *objp, PRBool *_retval)
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsid id, PRUint32 flags, JSObject * *objp, PRBool *_retval)
|
||||
{NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
|
||||
#endif
|
||||
|
||||
|
@ -193,7 +193,7 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::Finalize(nsIXPConnectWrappedNative *wrapper, JS
|
|||
#endif
|
||||
|
||||
#ifndef XPC_MAP_WANT_CHECKACCESS
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsval id, PRUint32 mode, jsval * vp, PRBool *_retval)
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsid id, PRUint32 mode, jsval * vp, PRBool *_retval)
|
||||
{NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ JSPrincipals *gJSPrincipals = nsnull;
|
|||
nsAutoString *gWorkingDirectory = nsnull;
|
||||
|
||||
static JSBool
|
||||
GetLocationProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
GetLocationProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
#if (!defined(XP_WIN) && !defined(XP_UNIX)) || defined(WINCE)
|
||||
//XXX: your platform should really implement this
|
||||
|
@ -817,7 +817,7 @@ JSClass global_class = {
|
|||
};
|
||||
|
||||
static JSBool
|
||||
env_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
env_setProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
/* XXX porting may be easy, but these don't seem to supply setenv by default */
|
||||
#if !defined XP_BEOS && !defined XP_OS2 && !defined SOLARIS
|
||||
|
@ -825,7 +825,11 @@ env_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
const char *name, *value;
|
||||
int rv;
|
||||
|
||||
idstr = JS_ValueToString(cx, id);
|
||||
jsval idval;
|
||||
if (!JS_IdToValue(cx, id, &idval))
|
||||
return JS_FALSE;
|
||||
|
||||
idstr = JS_ValueToString(cx, idval);
|
||||
valstr = JS_ValueToString(cx, *vp);
|
||||
if (!idstr || !valstr)
|
||||
return JS_FALSE;
|
||||
|
@ -896,7 +900,7 @@ env_enumerate(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
env_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
env_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp)
|
||||
{
|
||||
JSString *idstr, *valstr;
|
||||
|
@ -905,7 +909,11 @@ env_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
|||
if (flags & JSRESOLVE_ASSIGNING)
|
||||
return JS_TRUE;
|
||||
|
||||
idstr = JS_ValueToString(cx, id);
|
||||
jsval idval;
|
||||
if (!JS_IdToValue(cx, id, &idval))
|
||||
return JS_FALSE;
|
||||
|
||||
idstr = JS_ValueToString(cx, idval);
|
||||
if (!idstr)
|
||||
return JS_FALSE;
|
||||
name = JS_GetStringBytes(idstr);
|
||||
|
@ -1328,17 +1336,17 @@ FullTrustSecMan::CanAccess(PRUint32 aAction,
|
|||
nsAXPCNativeCallContext *aCallContext,
|
||||
JSContext * aJSContext, JSObject * aJSObject,
|
||||
nsISupports *aObj, nsIClassInfo *aClassInfo,
|
||||
jsval aName, void * *aPolicy)
|
||||
jsid aName, void * *aPolicy)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] void checkPropertyAccess (in JSContextPtr aJSContext, in JSObjectPtr aJSObject, in string aClassName, in jsval aProperty, in PRUint32 aAction); */
|
||||
/* [noscript] void checkPropertyAccess (in JSContextPtr aJSContext, in JSObjectPtr aJSObject, in string aClassName, in jsid aProperty, in PRUint32 aAction); */
|
||||
NS_IMETHODIMP
|
||||
FullTrustSecMan::CheckPropertyAccess(JSContext * aJSContext,
|
||||
JSObject * aJSObject,
|
||||
const char *aClassName,
|
||||
jsval aProperty, PRUint32 aAction)
|
||||
jsid aProperty, PRUint32 aAction)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -159,10 +159,7 @@ DEFINES += \
|
|||
$(addprefix -D,$(filter AVMPLUS%,$(CONFIG))) \
|
||||
$(NULL)
|
||||
|
||||
# Disable traceable natives because (a) many of them return jsvals, which is
|
||||
# hard to support now, and (b) we can call the basic versions from trace now
|
||||
# anyway.
|
||||
ENABLE_TRACEABLE_FLAGS =
|
||||
ENABLE_TRACEABLE_FLAGS = --enable-traceables
|
||||
|
||||
endif # ENABLE_JIT
|
||||
|
||||
|
|
|
@ -210,33 +210,33 @@ CanTouchProperty(JSContext *cx, JSObject *wrapperObj, jsid id, JSBool isSet,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_COW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_COW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_COW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_COW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_COW_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_COW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_COW_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_COW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_COW_Enumerate(JSContext *cx, JSObject *obj);
|
||||
|
||||
static JSBool
|
||||
XPC_COW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
XPC_COW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp);
|
||||
|
||||
static JSBool
|
||||
XPC_COW_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_COW_CheckAccess(JSContext *cx, JSObject *obj, jsval id, JSAccessMode mode,
|
||||
XPC_COW_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
|
||||
jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_COW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
XPC_COW_Equality(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp);
|
||||
|
||||
static JSObject *
|
||||
XPC_COW_Iterator(JSContext *cx, JSObject *obj, JSBool keysonly);
|
||||
|
@ -473,17 +473,17 @@ RewrapForContent(JSContext *cx, JSObject *wrapperObj, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
CheckSOW(JSContext *cx, JSObject *wrapperObj, jsval idval)
|
||||
CheckSOW(JSContext *cx, JSObject *wrapperObj, jsid id)
|
||||
{
|
||||
jsval flags;
|
||||
JS_GetReservedSlot(cx, wrapperObj, sFlagsSlot, &flags);
|
||||
|
||||
return HAS_FLAGS(flags, FLAG_SOW)
|
||||
? SystemOnlyWrapper::AllowedToAct(cx, idval) : JS_TRUE;
|
||||
? SystemOnlyWrapper::AllowedToAct(cx, id) : JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_COW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_COW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
obj = GetWrapper(obj);
|
||||
jsval flags;
|
||||
|
@ -507,11 +507,9 @@ XPC_COW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx);
|
||||
}
|
||||
|
||||
jsid interned_id;
|
||||
JSPropertyDescriptor desc;
|
||||
|
||||
if (!JS_ValueToId(cx, id, &interned_id) ||
|
||||
!XPCWrapper::GetPropertyAttrs(cx, obj, interned_id, JSRESOLVE_QUALIFIED,
|
||||
if (!XPCWrapper::GetPropertyAttrs(cx, obj, id, JSRESOLVE_QUALIFIED,
|
||||
JS_TRUE, &desc)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -527,12 +525,12 @@ XPC_COW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
return RewrapForChrome(cx, obj, vp) &&
|
||||
JS_DefinePropertyById(cx, wrappedObj, interned_id, *vp,
|
||||
JS_DefinePropertyById(cx, wrappedObj, id, *vp,
|
||||
desc.getter, desc.setter, desc.attrs);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_COW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_COW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
if (!CheckSOW(cx, obj, id)) {
|
||||
return JS_FALSE;
|
||||
|
@ -549,9 +547,7 @@ XPC_COW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
JSBool canTouch;
|
||||
jsid interned_id;
|
||||
if (!JS_ValueToId(cx, id, &interned_id) ||
|
||||
!CanTouchProperty(cx, obj, interned_id, JS_TRUE, &canTouch)) {
|
||||
if (!CanTouchProperty(cx, obj, id, JS_TRUE, &canTouch)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -564,7 +560,7 @@ XPC_COW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_COW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
||||
XPC_COW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
JSBool isSet)
|
||||
{
|
||||
obj = GetWrapper(obj);
|
||||
|
@ -588,19 +584,14 @@ XPC_COW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx);
|
||||
}
|
||||
|
||||
jsid interned_id;
|
||||
if (!JS_ValueToId(cx, id, &interned_id)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (interned_id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_PROTO) ||
|
||||
interned_id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_EXPOSEDPROPS)) {
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_PROTO) ||
|
||||
id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_EXPOSEDPROPS)) {
|
||||
// No getting or setting __proto__ on my object.
|
||||
return ThrowException(NS_ERROR_INVALID_ARG, cx); // XXX better error message
|
||||
}
|
||||
|
||||
JSBool canTouch;
|
||||
if (!CanTouchProperty(cx, obj, interned_id, isSet, &canTouch)) {
|
||||
if (!CanTouchProperty(cx, obj, id, isSet, &canTouch)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -612,9 +603,8 @@ XPC_COW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSBool ok = isSet
|
||||
? JS_SetPropertyById(cx, wrappedObj, interned_id, vp)
|
||||
: JS_GetPropertyById(cx, wrappedObj, interned_id, vp);
|
||||
JSBool ok = isSet ? JS_SetPropertyById(cx, wrappedObj, id, vp)
|
||||
: JS_GetPropertyById(cx, wrappedObj, id, vp);
|
||||
if (!ok) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -623,13 +613,13 @@ XPC_COW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_COW_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_COW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return XPC_COW_GetOrSetProperty(cx, obj, id, vp, JS_FALSE);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_COW_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_COW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return XPC_COW_GetOrSetProperty(cx, obj, id, vp, JS_TRUE);
|
||||
}
|
||||
|
@ -644,7 +634,7 @@ XPC_COW_Enumerate(JSContext *cx, JSObject *obj)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (!CheckSOW(cx, obj, JSVAL_VOID)) {
|
||||
if (!CheckSOW(cx, obj, JSID_VOID)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -657,12 +647,12 @@ XPC_COW_Enumerate(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_COW_NewResolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
||||
XPC_COW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp)
|
||||
{
|
||||
obj = GetWrapper(obj);
|
||||
|
||||
if (!CheckSOW(cx, obj, idval)) {
|
||||
if (!CheckSOW(cx, obj, id)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -678,10 +668,8 @@ XPC_COW_NewResolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
|||
return ThrowException(NS_ERROR_FAILURE, cx);
|
||||
}
|
||||
|
||||
jsid id;
|
||||
JSBool canTouch;
|
||||
if (!JS_ValueToId(cx, idval, &id) ||
|
||||
!CanTouchProperty(cx, obj, id, (flags & JSRESOLVE_ASSIGNING) != 0,
|
||||
if (!CanTouchProperty(cx, obj, id, (flags & JSRESOLVE_ASSIGNING) != 0,
|
||||
&canTouch)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -724,28 +712,26 @@ XPC_COW_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_COW_CheckAccess(JSContext *cx, JSObject *obj, jsval prop, JSAccessMode mode,
|
||||
XPC_COW_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
|
||||
jsval *vp)
|
||||
{
|
||||
// Simply forward checkAccess to our wrapped object. It's already expecting
|
||||
// untrusted things to ask it about accesses.
|
||||
|
||||
uintN junk;
|
||||
jsid id;
|
||||
return JS_ValueToId(cx, prop, &id) &&
|
||||
JS_CheckAccess(cx, GetWrappedObject(cx, obj), id, mode, vp, &junk);
|
||||
return JS_CheckAccess(cx, GetWrappedObject(cx, obj), id, mode, vp, &junk);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_COW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
XPC_COW_Equality(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp)
|
||||
{
|
||||
// Convert both sides to XPCWrappedNative and see if they match.
|
||||
if (JSVAL_IS_PRIMITIVE(v)) {
|
||||
if (JSVAL_IS_PRIMITIVE(*valp)) {
|
||||
*bp = JS_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSObject *test = GetWrappedJSObject(cx, JSVAL_TO_OBJECT(v));
|
||||
JSObject *test = GetWrappedJSObject(cx, JSVAL_TO_OBJECT(*valp));
|
||||
|
||||
obj = GetWrappedObject(cx, obj);
|
||||
if (!obj) {
|
||||
|
@ -761,8 +747,9 @@ XPC_COW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
|||
XPCWrappedNative *me = XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
|
||||
obj = me->GetFlatJSObject();
|
||||
test = other->GetFlatJSObject();
|
||||
jsval testVal = OBJECT_TO_JSVAL(test);
|
||||
return ((JSExtendedClass *)obj->getJSClass())->
|
||||
equality(cx, obj, OBJECT_TO_JSVAL(test), bp);
|
||||
equality(cx, obj, &testVal, bp);
|
||||
}
|
||||
|
||||
static JSObject *
|
||||
|
|
|
@ -49,22 +49,22 @@
|
|||
// accessed safely from across origins.
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_XOW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_XOW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_XOW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_XOW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_Enumerate(JSContext *cx, JSObject *obj);
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
XPC_XOW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp);
|
||||
|
||||
static JSBool
|
||||
|
@ -74,7 +74,7 @@ static void
|
|||
XPC_XOW_Finalize(JSContext *cx, JSObject *obj);
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_CheckAccess(JSContext *cx, JSObject *obj, jsval id, JSAccessMode mode,
|
||||
XPC_XOW_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
|
||||
jsval *vp);
|
||||
|
||||
static JSBool
|
||||
|
@ -85,10 +85,10 @@ XPC_XOW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
jsval *rval);
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
XPC_XOW_HasInstance(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
XPC_XOW_Equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
|
||||
|
||||
static JSObject *
|
||||
XPC_XOW_Iterator(JSContext *cx, JSObject *obj, JSBool keysonly);
|
||||
|
@ -454,7 +454,7 @@ XPC_XOW_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
jsval *rval);
|
||||
|
||||
static JSBool
|
||||
IsValFrame(JSObject *obj, jsval v, XPCWrappedNative *wn)
|
||||
IsValFrame(JSObject *obj, jsid id, XPCWrappedNative *wn)
|
||||
{
|
||||
// Fast path for the common case.
|
||||
if (obj->getClass()->name[0] != 'W') {
|
||||
|
@ -472,11 +472,11 @@ IsValFrame(JSObject *obj, jsval v, XPCWrappedNative *wn)
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(v)) {
|
||||
col->Item(JSVAL_TO_INT(v), getter_AddRefs(domwin));
|
||||
if (JSID_IS_INT(id)) {
|
||||
col->Item(JSID_TO_INT(id), getter_AddRefs(domwin));
|
||||
} else {
|
||||
nsAutoString str(reinterpret_cast<PRUnichar *>
|
||||
(JS_GetStringChars(JSVAL_TO_STRING(v))));
|
||||
(JS_GetStringChars(JSID_TO_STRING(id))));
|
||||
col->NamedItem(str, getter_AddRefs(domwin));
|
||||
}
|
||||
|
||||
|
@ -570,7 +570,7 @@ WrapSameOriginProp(JSContext *cx, JSObject *outerObj, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_XOW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
// All AddProperty needs to do is pass on addProperty requests to
|
||||
// same-origin objects, and throw for all else.
|
||||
|
@ -617,7 +617,7 @@ XPC_XOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_XOW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
JSObject *wrappedObj = GetWrappedObject(cx, obj);
|
||||
if (!wrappedObj) {
|
||||
|
@ -638,10 +638,10 @@ XPC_XOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
||||
XPC_XOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
JSBool isSet)
|
||||
{
|
||||
if (id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -709,22 +709,14 @@ XPC_XOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
|
||||
JSObject *proto = nsnull; // Initialize this to quiet GCC.
|
||||
JSBool checkProto =
|
||||
(isSet && id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_PROTO));
|
||||
(isSet && id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_PROTO));
|
||||
if (checkProto) {
|
||||
proto = wrappedObj->getProto();
|
||||
}
|
||||
|
||||
// Same origin, pass this request along as though nothing interesting
|
||||
// happened.
|
||||
jsid asId;
|
||||
|
||||
if (!JS_ValueToId(cx, id, &asId)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSBool ok = isSet
|
||||
? JS_SetPropertyById(cx, wrappedObj, asId, vp)
|
||||
: JS_GetPropertyById(cx, wrappedObj, asId, vp);
|
||||
? JS_SetPropertyById(cx, wrappedObj, id, vp)
|
||||
: JS_GetPropertyById(cx, wrappedObj, id, vp);
|
||||
if (!ok) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -761,13 +753,13 @@ XPC_XOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_XOW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return XPC_XOW_GetOrSetProperty(cx, obj, id, vp, JS_FALSE);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_XOW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return XPC_XOW_GetOrSetProperty(cx, obj, id, vp, JS_TRUE);
|
||||
}
|
||||
|
@ -861,7 +853,7 @@ GetUXPCObject(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
XPC_XOW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp)
|
||||
{
|
||||
obj = GetWrapper(obj);
|
||||
|
@ -921,7 +913,7 @@ XPC_XOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
jsval oldSlotVal;
|
||||
if (!JS_GetReservedSlot(cx, obj, sFlagsSlot, &oldSlotVal) ||
|
||||
!JS_SetReservedSlot(cx, obj, sFlagsSlot,
|
||||
|
@ -1020,16 +1012,14 @@ XPC_XOW_Finalize(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_CheckAccess(JSContext *cx, JSObject *obj, jsval prop, JSAccessMode mode,
|
||||
XPC_XOW_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
|
||||
jsval *vp)
|
||||
{
|
||||
// Simply forward checkAccess to our wrapped object. It's already expecting
|
||||
// untrusted things to ask it about accesses.
|
||||
|
||||
uintN junk;
|
||||
jsid id;
|
||||
return JS_ValueToId(cx, prop, &id) &&
|
||||
JS_CheckAccess(cx, GetWrappedObject(cx, obj), id, mode, vp, &junk);
|
||||
return JS_CheckAccess(cx, GetWrappedObject(cx, obj), id, mode, vp, &junk);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -1091,7 +1081,7 @@ XPC_XOW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
XPC_XOW_HasInstance(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp)
|
||||
{
|
||||
JSObject *iface = GetWrappedObject(cx, obj);
|
||||
|
||||
|
@ -1117,7 +1107,8 @@ XPC_XOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
|||
}
|
||||
|
||||
// Prematurely unwrap the left hand side.
|
||||
if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||
jsval v = *valp;
|
||||
if (!JSVAL_IS_PRIMITIVE(*valp)) {
|
||||
JSObject *test = JSVAL_TO_OBJECT(v);
|
||||
|
||||
// GetWrappedObject does an instanceof check.
|
||||
|
@ -1127,12 +1118,14 @@ XPC_XOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
|||
}
|
||||
}
|
||||
|
||||
return clasp->hasInstance(cx, iface, v, bp);
|
||||
return clasp->hasInstance(cx, iface, &v, bp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_XOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
XPC_XOW_Equality(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp)
|
||||
{
|
||||
jsval v = *valp;
|
||||
|
||||
// Convert both sides to XPCWrappedNative and see if they match.
|
||||
if (JSVAL_IS_PRIMITIVE(v)) {
|
||||
*bp = JS_FALSE;
|
||||
|
@ -1167,8 +1160,9 @@ XPC_XOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
|||
XPCWrappedNative *me = XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
|
||||
obj = me->GetFlatJSObject();
|
||||
test = other->GetFlatJSObject();
|
||||
jsval testVal = OBJECT_TO_JSVAL(test);
|
||||
return ((JSExtendedClass *)obj->getJSClass())->
|
||||
equality(cx, obj, OBJECT_TO_JSVAL(test), bp);
|
||||
equality(cx, obj, &testVal, bp);
|
||||
}
|
||||
|
||||
static JSObject *
|
||||
|
@ -1259,7 +1253,7 @@ XPC_XOW_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
}
|
||||
rv = ssm->CheckPropertyAccess(cx, wrappedObj,
|
||||
wrappedObj->getClass()->name,
|
||||
GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING),
|
||||
GetRTIdByIndex(cx, XPCJSRuntime::IDX_TO_STRING),
|
||||
nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
|
|
|
@ -211,13 +211,13 @@ PRBool XPCDispInterface::Member::IsParameterizedProperty() const
|
|||
}
|
||||
|
||||
inline
|
||||
jsval XPCDispInterface::Member::GetName() const
|
||||
jsid XPCDispInterface::Member::GetName() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
inline
|
||||
void XPCDispInterface::Member::SetName(jsval name)
|
||||
void XPCDispInterface::Member::SetName(jsid name)
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ void XPCDispInterface::SetJSObject(JSObject* jsobj)
|
|||
}
|
||||
|
||||
inline
|
||||
const XPCDispInterface::Member* XPCDispInterface::FindMember(jsval name) const
|
||||
const XPCDispInterface::Member* XPCDispInterface::FindMember(jsid name) const
|
||||
{
|
||||
// Iterate backwards to save time
|
||||
const Member* member = mMembers + mMemberCount;
|
||||
|
@ -635,17 +635,16 @@ jschar * xpc_JSString2String(JSContext * cx, jsval val, PRUint32 * len = 0)
|
|||
}
|
||||
|
||||
/**
|
||||
* Converts a jsval that is a string to a PRUnichar *
|
||||
* Converts a JSString * to a PRUnichar *
|
||||
* @param cx a JS context
|
||||
* @param val the JS value to vbe converted
|
||||
* @param str the JSString to be converted
|
||||
* @param length optional pointer to a variable to hold the length
|
||||
* @return a PRUnichar buffer (Does not need to be freed)
|
||||
*/
|
||||
inline
|
||||
PRUnichar* xpc_JSString2PRUnichar(XPCCallContext& ccx, jsval val,
|
||||
PRUnichar* xpc_JSString2PRUnichar(XPCCallContext& ccx, JSString* str,
|
||||
size_t* length = nsnull)
|
||||
{
|
||||
JSString* str = JS_ValueToString(ccx, val);
|
||||
if(!str)
|
||||
return nsnull;
|
||||
if(length)
|
||||
|
|
|
@ -190,7 +190,7 @@ PRBool InitializeMember(JSContext * cx, ITypeInfo * pTypeInfo,
|
|||
pInfo = new (pInfo) XPCDispInterface::Member;
|
||||
if(!pInfo)
|
||||
return PR_FALSE;
|
||||
pInfo->SetName(STRING_TO_JSVAL(str));
|
||||
pInfo->SetName(INTERNED_STRING_TO_JSID(str));
|
||||
pInfo->ResetType();
|
||||
ConvertInvokeKind(pFuncDesc->invkind, *pInfo);
|
||||
pInfo->SetTypeInfo(pFuncDesc->memid, pTypeInfo, pFuncDesc);
|
||||
|
@ -283,25 +283,25 @@ PRBool XPCDispInterface::InspectIDispatch(JSContext * cx, ITypeInfo * pTypeInfo,
|
|||
* @param ccx an XPConnect call context
|
||||
* @param lhr the PRUnichar string to be compared
|
||||
* @param lhsLength the length of the PRUnichar string
|
||||
* @param rhs the JS value that is the other string to compare
|
||||
* @param rhs the jsid that is the other string to compare
|
||||
* @return true if the strings are equal
|
||||
*/
|
||||
inline
|
||||
PRBool CaseInsensitiveCompare(XPCCallContext& ccx, const PRUnichar* lhs, size_t lhsLength, jsval rhs)
|
||||
PRBool CaseInsensitiveCompare(XPCCallContext& ccx, const PRUnichar* lhs, size_t lhsLength, jsid rhs)
|
||||
{
|
||||
if(lhsLength == 0)
|
||||
return PR_FALSE;
|
||||
size_t rhsLength;
|
||||
PRUnichar* rhsString = xpc_JSString2PRUnichar(ccx, rhs, &rhsLength);
|
||||
PRUnichar* rhsString = xpc_JSString2PRUnichar(ccx, JSID_TO_STRING(rhs), &rhsLength);
|
||||
return rhsString &&
|
||||
lhsLength == rhsLength &&
|
||||
_wcsnicmp(lhs, rhsString, lhsLength) == 0;
|
||||
}
|
||||
|
||||
const XPCDispInterface::Member* XPCDispInterface::FindMemberCI(XPCCallContext& ccx, jsval name) const
|
||||
const XPCDispInterface::Member* XPCDispInterface::FindMemberCI(XPCCallContext& ccx, jsid name) const
|
||||
{
|
||||
size_t nameLength;
|
||||
PRUnichar* sName = xpc_JSString2PRUnichar(ccx, name, &nameLength);
|
||||
PRUnichar* sName = xpc_JSString2PRUnichar(ccx, JSID_TO_STRING(name), &nameLength);
|
||||
if(!sName)
|
||||
return nsnull;
|
||||
// Iterate backwards over the members array (more efficient)
|
||||
|
@ -357,7 +357,7 @@ JSBool XPCDispInterface::Member::GetValue(XPCCallContext& ccx,
|
|||
}
|
||||
|
||||
JSFunction *fun = JS_NewFunction(cx, callback, argc, flags, nsnull,
|
||||
JS_GetStringBytes(JSVAL_TO_STRING(mName)));
|
||||
JS_GetStringBytes(JSID_TO_STRING(mName)));
|
||||
if(!fun)
|
||||
return JS_FALSE;
|
||||
|
||||
|
|
|
@ -308,7 +308,7 @@ JSBool XPCDispObject::Invoke(XPCCallContext & ccx, CallMode mode)
|
|||
NS_ERROR("bad value");
|
||||
return JS_FALSE;
|
||||
}
|
||||
jsval name = member->GetName();
|
||||
jsid name = member->GetName();
|
||||
|
||||
nsIXPCSecurityManager* sm = xpcc->GetAppropriateSecurityManager(secFlag);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
|
@ -400,12 +400,12 @@ JSBool GetMember(XPCCallContext& ccx, JSObject* funobj, XPCNativeInterface*& ifa
|
|||
jsval val;
|
||||
if(!JS_GetReservedSlot(ccx, funobj, 1, &val))
|
||||
return JS_FALSE;
|
||||
if(!JSVAL_MAY_BE_PRIVATE(val))
|
||||
if(!JSVAL_IS_UNDERLYING_TYPE_OF_PRIVATE(val))
|
||||
return JS_FALSE;
|
||||
iface = reinterpret_cast<XPCNativeInterface*>(JSVAL_TO_PRIVATE(val));
|
||||
if(!JS_GetReservedSlot(ccx, funobj, 0, &val))
|
||||
return JS_FALSE;
|
||||
if(!JSVAL_MAY_BE_PRIVATE(val))
|
||||
if(!JSVAL_IS_UNDERLYING_TYPE_OF_PRIVATE(val))
|
||||
return JS_FALSE;
|
||||
member = reinterpret_cast<XPCDispInterface::Member*>(JSVAL_TO_PRIVATE(val));
|
||||
return JS_TRUE;
|
||||
|
@ -443,7 +443,7 @@ XPC_IDispatch_CallMethod(JSContext* cx, JSObject* obj, uintN argc,
|
|||
{
|
||||
NS_ASSERTION(JS_TypeOfValue(cx, argv[-2]) == JSTYPE_FUNCTION, "bad function");
|
||||
JSObject* funobj = JSVAL_TO_OBJECT(argv[-2]);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, funobj, 0, argc, argv, vp);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, funobj, INT_TO_JSID(0), argc, argv, vp);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
ccx.SetArgsAndResultPtr(argc, argv, vp);
|
||||
|
|
|
@ -786,10 +786,10 @@ public:
|
|||
*/
|
||||
PRBool IsFunction() const;
|
||||
/**
|
||||
* Returns the name of the method as a jsval
|
||||
* @return the name of the method as a jsval
|
||||
* Returns the name of the method as a jsid
|
||||
* @return the name of the method as a jsid
|
||||
*/
|
||||
jsval GetName() const;
|
||||
jsid GetName() const;
|
||||
/**
|
||||
* Returns the function object as a value for the method
|
||||
* @param ccx an XPConnect call context
|
||||
|
@ -822,7 +822,7 @@ public:
|
|||
* Sets the name of the method
|
||||
* @param name the name to assign
|
||||
*/
|
||||
void SetName(jsval name);
|
||||
void SetName(jsid name);
|
||||
/**
|
||||
* Marks the member as a getter.
|
||||
* Both MakeGetter and MakeSetter can be called, making it a setter/getter
|
||||
|
@ -881,7 +881,7 @@ public:
|
|||
};
|
||||
PRUint16 mType;
|
||||
jsval mVal; // Mutable
|
||||
jsval mName; // Mutable
|
||||
jsid mName; // Mutable
|
||||
CComPtr<ITypeInfo> mTypeInfo;
|
||||
FUNCDESC* mFuncDesc; // We own this
|
||||
FUNCDESC* mGetterFuncDesc; // We own this
|
||||
|
@ -915,7 +915,7 @@ public:
|
|||
* @param name the name of the member to be returned
|
||||
* @return pointer to the member found, nsnull if not found
|
||||
*/
|
||||
const Member * FindMember(jsval name) const;
|
||||
const Member * FindMember(jsid name) const;
|
||||
/**
|
||||
* Looksup a member ignoring case
|
||||
* TODO: We should look at performance issues concerning this
|
||||
|
@ -923,7 +923,7 @@ public:
|
|||
* @param name The name of the member
|
||||
* @return A pointer to a member or nsnull if not found
|
||||
*/
|
||||
const Member* FindMemberCI(XPCCallContext& ccx, jsval name) const;
|
||||
const Member* FindMemberCI(XPCCallContext& ccx, jsid name) const;
|
||||
/**
|
||||
* Returns a member via index
|
||||
* @param index the index of the parameter
|
||||
|
@ -1150,7 +1150,7 @@ public:
|
|||
* @param resolved a pointer to a JSBool, set to true if properly resolved
|
||||
*/
|
||||
static JSBool DefineProperty(XPCCallContext & ccx,
|
||||
JSObject *obj, jsval idval,
|
||||
JSObject *obj, jsid id,
|
||||
XPCWrappedNative* wrapperToReflectInterfaceNames,
|
||||
uintN propFlags, JSBool* resolved);
|
||||
/**
|
||||
|
|
|
@ -347,7 +347,7 @@ STDMETHODIMP XPCDispTypeInfo::GetDocumentation(
|
|||
return E_FAIL;
|
||||
|
||||
XPCCallContext ccx(NATIVE_CALLER);
|
||||
PRUnichar * chars = xpc_JSString2PRUnichar(ccx, mIDArray->Item(ccx, index));
|
||||
PRUnichar * chars = xpc_JSString2PRUnichar(ccx, JSVAL_TO_STRING(mIDArray->Item(ccx, index)));
|
||||
if(!chars)
|
||||
{
|
||||
return E_FAIL;
|
||||
|
|
|
@ -43,12 +43,10 @@ static const char* const IDISPATCH_NAME = "IDispatch";
|
|||
PRBool XPCIDispatchExtension::mIsEnabled = PR_TRUE;
|
||||
|
||||
JSBool XPCIDispatchExtension::DefineProperty(XPCCallContext & ccx,
|
||||
JSObject *obj, jsval idval,
|
||||
JSObject *obj, jsid id,
|
||||
XPCWrappedNative* wrapperToReflectInterfaceNames,
|
||||
uintN propFlags, JSBool* resolved)
|
||||
{
|
||||
if(!JSVAL_IS_STRING(idval))
|
||||
return JS_FALSE;
|
||||
// Look up the native interface for IDispatch and then find a tearoff
|
||||
XPCNativeInterface* iface = XPCNativeInterface::GetNewOrUsed(ccx,
|
||||
"IDispatch");
|
||||
|
@ -61,14 +59,14 @@ JSBool XPCIDispatchExtension::DefineProperty(XPCCallContext & ccx,
|
|||
if(to == nsnull)
|
||||
return JS_FALSE;
|
||||
// Look up the member in the interface
|
||||
const XPCDispInterface::Member * member = to->GetIDispatchInfo()->FindMember(idval);
|
||||
const XPCDispInterface::Member * member = to->GetIDispatchInfo()->FindMember(id);
|
||||
if(!member)
|
||||
{
|
||||
// IDispatch is case insensitive, so if we don't find a case sensitive
|
||||
// match, we'll try a more expensive case-insensisitive search
|
||||
// TODO: We need to create cleaner solution that doesn't create
|
||||
// multiple properties of different case on the JS Object
|
||||
member = to->GetIDispatchInfo()->FindMemberCI(ccx, idval);
|
||||
member = to->GetIDispatchInfo()->FindMemberCI(ccx, id);
|
||||
if(!member)
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -82,16 +80,14 @@ JSBool XPCIDispatchExtension::DefineProperty(XPCCallContext & ccx,
|
|||
JSObject* funobj = xpc_CloneJSFunction(ccx, JSVAL_TO_OBJECT(funval), obj);
|
||||
if(!funobj)
|
||||
return JS_FALSE;
|
||||
jsid id;
|
||||
// If this is a function or a parameterized property
|
||||
if(member->IsFunction() || member->IsParameterizedProperty())
|
||||
{
|
||||
// define the function on the object
|
||||
AutoResolveName arn(ccx, idval);
|
||||
AutoResolveName arn(ccx, id);
|
||||
if(resolved)
|
||||
*resolved = JS_TRUE;
|
||||
return JS_ValueToId(ccx, idval, &id) &&
|
||||
JS_DefinePropertyById(ccx, obj, id, OBJECT_TO_JSVAL(funobj),
|
||||
return JS_DefinePropertyById(ccx, obj, id, OBJECT_TO_JSVAL(funobj),
|
||||
nsnull, nsnull, propFlags);
|
||||
}
|
||||
// Define the property on the object
|
||||
|
@ -109,11 +105,10 @@ JSBool XPCIDispatchExtension::DefineProperty(XPCCallContext & ccx,
|
|||
{
|
||||
setter = js_GetterOnlyPropertyStub;
|
||||
}
|
||||
AutoResolveName arn(ccx, idval);
|
||||
AutoResolveName arn(ccx, id);
|
||||
if(resolved)
|
||||
*resolved = JS_TRUE;
|
||||
return JS_ValueToId(ccx, idval, &id) &&
|
||||
JS_DefinePropertyById(ccx, obj, id, JSVAL_VOID, getter, setter,
|
||||
return JS_DefinePropertyById(ccx, obj, id, JSVAL_VOID, getter, setter,
|
||||
propFlags);
|
||||
|
||||
}
|
||||
|
@ -140,7 +135,7 @@ JSBool XPCIDispatchExtension::Enumerate(XPCCallContext& ccx, JSObject* obj,
|
|||
for(PRUint32 index = 0; index < members; ++index)
|
||||
{
|
||||
const XPCDispInterface::Member & member = pInfo->GetMember(index);
|
||||
jsval name = member.GetName();
|
||||
jsid name = member.GetName();
|
||||
if(!xpc_ForcePropertyResolve(ccx, obj, name))
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
|
|
@ -44,22 +44,22 @@
|
|||
#include "jsdbgapi.h"
|
||||
|
||||
static JSBool
|
||||
XPC_NW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_NW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_NW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_NW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_NW_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_NW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_NW_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_NW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_NW_Enumerate(JSContext *cx, JSObject *obj);
|
||||
|
||||
static JSBool
|
||||
XPC_NW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
XPC_NW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp);
|
||||
|
||||
static JSBool
|
||||
|
@ -69,7 +69,7 @@ static void
|
|||
XPC_NW_Finalize(JSContext *cx, JSObject *obj);
|
||||
|
||||
static JSBool
|
||||
XPC_NW_CheckAccess(JSContext *cx, JSObject *obj, jsval id,
|
||||
XPC_NW_CheckAccess(JSContext *cx, JSObject *obj, jsid id,
|
||||
JSAccessMode mode, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
|
@ -81,13 +81,13 @@ XPC_NW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
jsval *rval);
|
||||
|
||||
static JSBool
|
||||
XPC_NW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
XPC_NW_HasInstance(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp);
|
||||
|
||||
static void
|
||||
XPC_NW_Trace(JSTracer *trc, JSObject *obj);
|
||||
|
||||
static JSBool
|
||||
XPC_NW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
XPC_NW_Equality(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp);
|
||||
|
||||
static JSObject *
|
||||
XPC_NW_Iterator(JSContext *cx, JSObject *obj, JSBool keysonly);
|
||||
|
@ -289,7 +289,7 @@ ThrowException(nsresult ex, JSContext *cx)
|
|||
static inline
|
||||
JSBool
|
||||
EnsureLegalActivity(JSContext *cx, JSObject *obj,
|
||||
jsval id = JSVAL_VOID, PRUint32 accessType = 0)
|
||||
jsid id = JSID_VOID, PRUint32 accessType = 0)
|
||||
{
|
||||
nsIScriptSecurityManager *ssm = GetSecurityManager();
|
||||
if (!ssm) {
|
||||
|
@ -336,7 +336,7 @@ EnsureLegalActivity(JSContext *cx, JSObject *obj,
|
|||
}
|
||||
|
||||
JSObject* flatObj;
|
||||
if (!JSVAL_IS_VOID(id) &&
|
||||
if (!JSID_IS_VOID(id) &&
|
||||
(accessType & (sSecMgrSetProp | sSecMgrGetProp)) &&
|
||||
(flatObj = wn->GetFlatJSObject())) {
|
||||
rv = ssm->CheckPropertyAccess(cx, flatObj,
|
||||
|
@ -383,13 +383,11 @@ EnsureLegalActivity(JSContext *cx, JSObject *obj,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_NW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_NW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
jsid idAsId;
|
||||
JSPropertyDescriptor desc;
|
||||
|
||||
if (!JS_ValueToId(cx, id, &idAsId) ||
|
||||
!JS_GetPropertyDescriptorById(cx, obj, idAsId, JSRESOLVE_QUALIFIED,
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, id, JSRESOLVE_QUALIFIED,
|
||||
&desc)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -416,7 +414,7 @@ XPC_NW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_NW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_NW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return EnsureLegalActivity(cx, obj);
|
||||
}
|
||||
|
@ -496,12 +494,12 @@ GetwrappedJSObject(JSContext *cx, JSObject *obj, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_NW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
||||
XPC_NW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
JSBool aIsSet)
|
||||
{
|
||||
// We don't deal with the following properties here.
|
||||
if (id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_PROTOTYPE) ||
|
||||
id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_PROTOTYPE) ||
|
||||
id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -527,7 +525,7 @@ XPC_NW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
JSObject *nativeObj = wrappedNative->GetFlatJSObject();
|
||||
|
||||
if (!aIsSet &&
|
||||
id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_WRAPPED_JSOBJECT)) {
|
||||
id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_WRAPPED_JSOBJECT)) {
|
||||
return GetwrappedJSObject(cx, nativeObj, vp);
|
||||
}
|
||||
|
||||
|
@ -536,13 +534,13 @@ XPC_NW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_NW_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_NW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return XPC_NW_GetOrSetProperty(cx, obj, id, vp, PR_FALSE);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_NW_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_NW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return XPC_NW_GetOrSetProperty(cx, obj, id, vp, PR_TRUE);
|
||||
}
|
||||
|
@ -570,18 +568,18 @@ XPC_NW_Enumerate(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_NW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
XPC_NW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp)
|
||||
{
|
||||
// No need to preserve on sets of wrappedJSObject or toString, since callers
|
||||
// couldn't get at those values anyway. Also, we always deal with
|
||||
// wrappedJSObject and toString before looking at our scriptable hooks, so no
|
||||
// need to mess with our flags yet.
|
||||
if (id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_WRAPPED_JSOBJECT)) {
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_WRAPPED_JSOBJECT)) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
*objp = obj;
|
||||
|
||||
// See the comment in WrapFunction for why we create this function
|
||||
|
@ -646,7 +644,7 @@ XPC_NW_Finalize(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_NW_CheckAccess(JSContext *cx, JSObject *obj, jsval id,
|
||||
XPC_NW_CheckAccess(JSContext *cx, JSObject *obj, jsid id,
|
||||
JSAccessMode mode, jsval *vp)
|
||||
{
|
||||
// Prevent setting __proto__ on an XPCNativeWrapper
|
||||
|
@ -731,7 +729,7 @@ XPC_NW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_NW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
XPC_NW_HasInstance(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -886,7 +884,7 @@ XPC_NW_Trace(JSTracer *trc, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_NW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
XPC_NW_Equality(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp)
|
||||
{
|
||||
NS_ASSERTION(XPCNativeWrapper::IsNativeWrapper(obj),
|
||||
"Uh, we should only ever be called for XPCNativeWrapper "
|
||||
|
@ -896,6 +894,7 @@ XPC_NW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
jsval v = *valp;
|
||||
if (JSVAL_IS_PRIMITIVE(v)) {
|
||||
*bp = JS_FALSE;
|
||||
|
||||
|
@ -965,7 +964,7 @@ XPC_NW_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
}
|
||||
|
||||
if (!EnsureLegalActivity(cx, obj,
|
||||
GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING),
|
||||
GetRTIdByIndex(cx, XPCJSRuntime::IDX_TO_STRING),
|
||||
sSecMgrGetProp)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
|
|
@ -45,22 +45,22 @@
|
|||
#include "nsJSPrincipals.h"
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_SJOW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_SJOW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_SJOW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_SJOW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_Enumerate(JSContext *cx, JSObject *obj);
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
XPC_SJOW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp);
|
||||
|
||||
static JSBool
|
||||
|
@ -70,7 +70,7 @@ static void
|
|||
XPC_SJOW_Finalize(JSContext *cx, JSObject *obj);
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_CheckAccess(JSContext *cx, JSObject *obj, jsval id, JSAccessMode mode,
|
||||
XPC_SJOW_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
|
||||
jsval *vp);
|
||||
|
||||
static JSBool
|
||||
|
@ -86,7 +86,7 @@ XPC_SJOW_Create(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
jsval *rval);
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
XPC_SJOW_Equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
|
||||
|
||||
static JSObject *
|
||||
XPC_SJOW_Iterator(JSContext *cx, JSObject *obj, JSBool keysonly);
|
||||
|
@ -179,7 +179,7 @@ CanCallerAccess(JSContext *cx, JSObject *wrapperObj, JSObject *unsafeObj)
|
|||
jsval flags;
|
||||
JS_GetReservedSlot(cx, wrapperObj, sFlagsSlot, &flags);
|
||||
if (HAS_FLAGS(flags, FLAG_SOW) &&
|
||||
!SystemOnlyWrapper::CheckFilename(cx, JSVAL_VOID, fp)) {
|
||||
!SystemOnlyWrapper::CheckFilename(cx, JSID_VOID, fp)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -470,12 +470,12 @@ WrapJSValue(JSContext *cx, JSObject *obj, jsval val, jsval *rval)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_SJOW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
// The constructor and toString properties needs to live on the safe
|
||||
// wrapper.
|
||||
if (id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_CONSTRUCTOR) ||
|
||||
id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_CONSTRUCTOR) ||
|
||||
id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ XPC_SJOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_SJOW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
JSObject *unsafeObj = GetUnsafeObject(cx, obj);
|
||||
if (!unsafeObj) {
|
||||
|
@ -579,11 +579,11 @@ private:
|
|||
};
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
||||
XPC_SJOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
JSBool aIsSet)
|
||||
{
|
||||
// We resolve toString to a function in our resolve hook.
|
||||
if (id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -607,11 +607,6 @@ XPC_SJOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
jsid interned_id;
|
||||
if (!JS_ValueToId(cx, id, &interned_id)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (aIsSet &&
|
||||
!JSVAL_IS_PRIMITIVE(*vp) &&
|
||||
!RewrapObject(cx, JS_GetGlobalForObject(cx, unsafeObj),
|
||||
|
@ -620,8 +615,8 @@ XPC_SJOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
}
|
||||
|
||||
JSBool ok = aIsSet
|
||||
? JS_SetPropertyById(cx, unsafeObj, interned_id, vp)
|
||||
: JS_GetPropertyById(cx, unsafeObj, interned_id, vp);
|
||||
? JS_SetPropertyById(cx, unsafeObj, id, vp)
|
||||
: JS_GetPropertyById(cx, unsafeObj, id, vp);
|
||||
if (!ok) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -631,13 +626,13 @@ XPC_SJOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_SJOW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return XPC_SJOW_GetOrSetProperty(cx, obj, id, vp, PR_FALSE);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_SJOW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return XPC_SJOW_GetOrSetProperty(cx, obj, id, vp, PR_TRUE);
|
||||
}
|
||||
|
@ -675,7 +670,7 @@ XPC_SJOW_Enumerate(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
XPC_SJOW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp)
|
||||
{
|
||||
obj = FindSafeObject(obj);
|
||||
|
@ -695,7 +690,7 @@ XPC_SJOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
|||
}
|
||||
|
||||
// Resolve toString specially.
|
||||
if (id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
|
||||
*objp = obj;
|
||||
return JS_DefineFunction(cx, obj, "toString",
|
||||
XPC_SJOW_toString, 0, 0) != nsnull;
|
||||
|
@ -725,7 +720,7 @@ XPC_SJOW_Finalize(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_CheckAccess(JSContext *cx, JSObject *obj, jsval id,
|
||||
XPC_SJOW_CheckAccess(JSContext *cx, JSObject *obj, jsid id,
|
||||
JSAccessMode mode, jsval *vp)
|
||||
{
|
||||
// Prevent setting __proto__ on an XPCSafeJSObjectWrapper
|
||||
|
@ -927,14 +922,14 @@ XPC_SJOW_Create(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SJOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
XPC_SJOW_Equality(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp)
|
||||
{
|
||||
if (JSVAL_IS_PRIMITIVE(v)) {
|
||||
if (JSVAL_IS_PRIMITIVE(*valp)) {
|
||||
*bp = JS_FALSE;
|
||||
} else {
|
||||
JSObject *unsafeObj = GetUnsafeObject(cx, obj);
|
||||
|
||||
JSObject *other = JSVAL_TO_OBJECT(v);
|
||||
JSObject *other = JSVAL_TO_OBJECT(*valp);
|
||||
JSObject *otherUnsafe = GetUnsafeObject(cx, other);
|
||||
|
||||
// An object is equal to a SJOW if:
|
||||
|
|
|
@ -48,36 +48,36 @@
|
|||
// be safely injected into untrusted code.
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_SOW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_SOW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_SOW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
XPC_SOW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_Enumerate(JSContext *cx, JSObject *obj);
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
XPC_SOW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp);
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_CheckAccess(JSContext *cx, JSObject *obj, jsval id, JSAccessMode mode,
|
||||
XPC_SOW_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
|
||||
jsval *vp);
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
XPC_SOW_HasInstance(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp);
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
XPC_SOW_Equality(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp);
|
||||
|
||||
static JSObject *
|
||||
XPC_SOW_Iterator(JSContext *cx, JSObject *obj, JSBool keysonly);
|
||||
|
@ -171,7 +171,7 @@ MakeSOW(JSContext *cx, JSObject *obj)
|
|||
|
||||
// If you change this code, change also nsContentUtils::CanAccessNativeAnon()!
|
||||
JSBool
|
||||
AllowedToAct(JSContext *cx, jsval idval)
|
||||
AllowedToAct(JSContext *cx, jsid id)
|
||||
{
|
||||
// TODO bug 508928: Refactor this with the XOW security checking code.
|
||||
nsIScriptSecurityManager *ssm = GetSecurityManager();
|
||||
|
@ -221,12 +221,13 @@ AllowedToAct(JSContext *cx, jsval idval)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_VOID(idval)) {
|
||||
if (JSID_IS_VOID(id)) {
|
||||
ThrowException(NS_ERROR_XPC_SECURITY_MANAGER_VETO, cx);
|
||||
} else {
|
||||
// TODO Localize me?
|
||||
JSString *str = JS_ValueToString(cx, idval);
|
||||
if (str) {
|
||||
jsval idval;
|
||||
JSString *str;
|
||||
if (JS_IdToValue(cx, id, &idval) && (str = JS_ValueToString(cx, idval))) {
|
||||
JS_ReportError(cx, "Permission denied to access property '%hs' from a non-chrome context",
|
||||
JS_GetStringChars(str));
|
||||
}
|
||||
|
@ -236,7 +237,7 @@ AllowedToAct(JSContext *cx, jsval idval)
|
|||
}
|
||||
|
||||
JSBool
|
||||
CheckFilename(JSContext *cx, jsval idval, JSStackFrame *fp)
|
||||
CheckFilename(JSContext *cx, jsid id, JSStackFrame *fp)
|
||||
{
|
||||
const char *filename;
|
||||
if (fp &&
|
||||
|
@ -245,12 +246,12 @@ CheckFilename(JSContext *cx, jsval idval, JSStackFrame *fp)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_VOID(idval)) {
|
||||
if (JSID_IS_VOID(id)) {
|
||||
ThrowException(NS_ERROR_XPC_SECURITY_MANAGER_VETO, cx);
|
||||
} else {
|
||||
// TODO Localize me?
|
||||
JSString *str = JS_ValueToString(cx, idval);
|
||||
if (str) {
|
||||
jsval idval;
|
||||
JSString *str;
|
||||
if (JS_IdToValue(cx, id, &idval) && (str = JS_ValueToString(cx, idval))) {
|
||||
JS_ReportError(cx, "Permission denied to access property '%hs' from a non-chrome context",
|
||||
JS_GetStringChars(str));
|
||||
}
|
||||
|
@ -307,7 +308,7 @@ static JSBool
|
|||
XPC_SOW_FunctionWrapper(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval)
|
||||
{
|
||||
if (!AllowedToAct(cx, JSVAL_VOID)) {
|
||||
if (!AllowedToAct(cx, JSID_VOID)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -428,7 +429,7 @@ XPC_SOW_RewrapValue(JSContext *cx, JSObject *wrapperObj, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_SOW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
NS_ASSERTION(obj->getJSClass() == &SOWClass.base, "Wrong object");
|
||||
|
||||
|
@ -455,7 +456,7 @@ XPC_SOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_SOW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
JSObject *wrappedObj = GetWrappedObject(cx, obj);
|
||||
if (!wrappedObj) {
|
||||
|
@ -470,7 +471,7 @@ XPC_SOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
||||
XPC_SOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
JSBool isSet)
|
||||
{
|
||||
obj = GetWrapper(obj);
|
||||
|
@ -489,19 +490,14 @@ XPC_SOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx);
|
||||
}
|
||||
|
||||
if (isSet && id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_PROTO)) {
|
||||
if (isSet && id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_PROTO)) {
|
||||
// No setting __proto__ on my object.
|
||||
return ThrowException(NS_ERROR_INVALID_ARG, cx); // XXX better error message
|
||||
}
|
||||
|
||||
jsid interned_id;
|
||||
if (!JS_ValueToId(cx, id, &interned_id)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSBool ok = isSet
|
||||
? JS_SetPropertyById(cx, wrappedObj, interned_id, vp)
|
||||
: JS_GetPropertyById(cx, wrappedObj, interned_id, vp);
|
||||
? JS_SetPropertyById(cx, wrappedObj, id, vp)
|
||||
: JS_GetPropertyById(cx, wrappedObj, id, vp);
|
||||
if (!ok) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -510,13 +506,13 @@ XPC_SOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_SOW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return XPC_SOW_GetOrSetProperty(cx, obj, id, vp, JS_FALSE);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
XPC_SOW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return XPC_SOW_GetOrSetProperty(cx, obj, id, vp, JS_TRUE);
|
||||
}
|
||||
|
@ -531,7 +527,7 @@ XPC_SOW_Enumerate(JSContext *cx, JSObject *obj)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (!AllowedToAct(cx, JSVAL_VOID)) {
|
||||
if (!AllowedToAct(cx, JSID_VOID)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -539,7 +535,7 @@ XPC_SOW_Enumerate(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
XPC_SOW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp)
|
||||
{
|
||||
obj = GetWrapper(obj);
|
||||
|
@ -561,7 +557,7 @@ XPC_SOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
|||
static JSBool
|
||||
XPC_SOW_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
||||
{
|
||||
if (!AllowedToAct(cx, JSVAL_VOID)) {
|
||||
if (!AllowedToAct(cx, JSID_VOID)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -582,7 +578,7 @@ XPC_SOW_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_CheckAccess(JSContext *cx, JSObject *obj, jsval prop, JSAccessMode mode,
|
||||
XPC_SOW_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
|
||||
jsval *vp)
|
||||
{
|
||||
// Simply forward checkAccess to our wrapped object. It's already expecting
|
||||
|
@ -595,15 +591,13 @@ XPC_SOW_CheckAccess(JSContext *cx, JSObject *obj, jsval prop, JSAccessMode mode,
|
|||
}
|
||||
|
||||
uintN junk;
|
||||
jsid id;
|
||||
return JS_ValueToId(cx, prop, &id) &&
|
||||
JS_CheckAccess(cx, wrappedObj, id, mode, vp, &junk);
|
||||
return JS_CheckAccess(cx, wrappedObj, id, mode, vp, &junk);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
XPC_SOW_HasInstance(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp)
|
||||
{
|
||||
if (!AllowedToAct(cx, JSVAL_VOID)) {
|
||||
if (!AllowedToAct(cx, JSID_VOID)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -623,6 +617,7 @@ XPC_SOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
|||
// Prematurely unwrap the left hand side. This isn't necessary, but could be
|
||||
// faster than waiting until XPCWrappedNative::GetWrappedNativeOfJSObject to
|
||||
// do it.
|
||||
jsval v = *valp;
|
||||
if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||
JSObject *test = JSVAL_TO_OBJECT(v);
|
||||
|
||||
|
@ -633,13 +628,14 @@ XPC_SOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
|||
}
|
||||
}
|
||||
|
||||
return clasp->hasInstance(cx, iface, v, bp);
|
||||
return clasp->hasInstance(cx, iface, &v, bp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_SOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
XPC_SOW_Equality(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp)
|
||||
{
|
||||
// Delegate to our wrapped object.
|
||||
jsval v = *valp;
|
||||
if (JSVAL_IS_PRIMITIVE(v)) {
|
||||
*bp = JS_FALSE;
|
||||
return JS_TRUE;
|
||||
|
@ -663,7 +659,8 @@ XPC_SOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
|||
if (clasp->flags & JSCLASS_IS_EXTENDED) {
|
||||
JSExtendedClass *xclasp = (JSExtendedClass *) clasp;
|
||||
// NB: JSExtendedClass.equality is a required field.
|
||||
return xclasp->equality(cx, lhs, OBJECT_TO_JSVAL(rhs), bp);
|
||||
jsval rhsVal = OBJECT_TO_JSVAL(rhs);
|
||||
return xclasp->equality(cx, lhs, &rhsVal, bp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -672,7 +669,8 @@ XPC_SOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
|||
if (clasp->flags & JSCLASS_IS_EXTENDED) {
|
||||
JSExtendedClass *xclasp = (JSExtendedClass *) clasp;
|
||||
// NB: JSExtendedClass.equality is a required field.
|
||||
return xclasp->equality(cx, rhs, OBJECT_TO_JSVAL(lhs), bp);
|
||||
jsval lhsVal = OBJECT_TO_JSVAL(lhs);
|
||||
return xclasp->equality(cx, rhs, &lhsVal, bp);
|
||||
}
|
||||
|
||||
*bp = JS_FALSE;
|
||||
|
|
|
@ -427,15 +427,10 @@ CreateSimpleIterator(JSContext *cx, JSObject *scope, JSBool keysonly,
|
|||
|
||||
JSBool
|
||||
AddProperty(JSContext *cx, JSObject *wrapperObj, JSBool wantGetterSetter,
|
||||
JSObject *innerObj, jsval id, jsval *vp)
|
||||
JSObject *innerObj, jsid id, jsval *vp)
|
||||
{
|
||||
jsid interned_id;
|
||||
if (!::JS_ValueToId(cx, id, &interned_id)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSPropertyDescriptor desc;
|
||||
if (!GetPropertyAttrs(cx, wrapperObj, interned_id, JSRESOLVE_QUALIFIED,
|
||||
if (!GetPropertyAttrs(cx, wrapperObj, id, JSRESOLVE_QUALIFIED,
|
||||
wantGetterSetter, &desc)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -443,26 +438,26 @@ AddProperty(JSContext *cx, JSObject *wrapperObj, JSBool wantGetterSetter,
|
|||
NS_ASSERTION(desc.obj == wrapperObj,
|
||||
"What weird wrapper are we using?");
|
||||
|
||||
return JS_DefinePropertyById(cx, innerObj, interned_id, *vp,
|
||||
return JS_DefinePropertyById(cx, innerObj, id, *vp,
|
||||
desc.getter, desc.setter, desc.attrs);
|
||||
}
|
||||
|
||||
JSBool
|
||||
DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
if (JSVAL_IS_STRING(id)) {
|
||||
JSString *str = JSVAL_TO_STRING(id);
|
||||
if (JSID_IS_STRING(id)) {
|
||||
JSString *str = JSID_TO_STRING(id);
|
||||
jschar *chars = ::JS_GetStringChars(str);
|
||||
size_t length = ::JS_GetStringLength(str);
|
||||
|
||||
return ::JS_DeleteUCProperty2(cx, obj, chars, length, vp);
|
||||
}
|
||||
|
||||
if (!JSVAL_IS_INT(id)) {
|
||||
if (!JSID_IS_INT(id)) {
|
||||
return DoThrowException(NS_ERROR_NOT_IMPLEMENTED, cx);
|
||||
}
|
||||
|
||||
return ::JS_DeleteElement2(cx, obj, JSVAL_TO_INT(id), vp);
|
||||
return ::JS_DeleteElement2(cx, obj, JSID_TO_INT(id), vp);
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
@ -514,15 +509,10 @@ Enumerate(JSContext *cx, JSObject *wrapperObj, JSObject *innerObj)
|
|||
|
||||
JSBool
|
||||
NewResolve(JSContext *cx, JSObject *wrapperObj, JSBool wantDetails,
|
||||
JSObject *innerObj, jsval id, uintN flags, JSObject **objp)
|
||||
JSObject *innerObj, jsid id, uintN flags, JSObject **objp)
|
||||
{
|
||||
jsid interned_id;
|
||||
if (!::JS_ValueToId(cx, id, &interned_id)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSPropertyDescriptor desc;
|
||||
if (!GetPropertyAttrs(cx, innerObj, interned_id, flags, wantDetails, &desc)) {
|
||||
if (!GetPropertyAttrs(cx, innerObj, id, flags, wantDetails, &desc)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -541,7 +531,7 @@ NewResolve(JSContext *cx, JSObject *wrapperObj, JSBool wantDetails,
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSBool ok = JS_DefinePropertyById(cx, wrapperObj, interned_id, desc.value,
|
||||
JSBool ok = JS_DefinePropertyById(cx, wrapperObj, id, desc.value,
|
||||
desc.getter, desc.setter, desc.attrs);
|
||||
|
||||
JS_SetReservedSlot(cx, wrapperObj, sFlagsSlot, oldFlags);
|
||||
|
@ -556,7 +546,7 @@ NewResolve(JSContext *cx, JSObject *wrapperObj, JSBool wantDetails,
|
|||
JSBool
|
||||
ResolveNativeProperty(JSContext *cx, JSObject *wrapperObj,
|
||||
JSObject *innerObj, XPCWrappedNative *wn,
|
||||
jsval id, uintN flags, JSObject **objp,
|
||||
jsid id, uintN flags, JSObject **objp,
|
||||
JSBool isNativeWrapper)
|
||||
{
|
||||
// This will do verification and the method lookup for us.
|
||||
|
@ -565,7 +555,7 @@ ResolveNativeProperty(JSContext *cx, JSObject *wrapperObj,
|
|||
// For "constructor" we don't want to call into the resolve hooks on the
|
||||
// wrapped native, since that would give the wrong constructor.
|
||||
if (NATIVE_HAS_FLAG(wn, WantNewResolve) &&
|
||||
id != GetRTStringByIndex(cx, XPCJSRuntime::IDX_CONSTRUCTOR)) {
|
||||
id != GetRTIdByIndex(cx, XPCJSRuntime::IDX_CONSTRUCTOR)) {
|
||||
|
||||
// Mark ourselves as resolving so our AddProperty hook can do the
|
||||
// right thing here.
|
||||
|
@ -628,7 +618,7 @@ ResolveNativeProperty(JSContext *cx, JSObject *wrapperObj,
|
|||
}
|
||||
}
|
||||
|
||||
if (!JSVAL_IS_STRING(id)) {
|
||||
if (!JSID_IS_STRING(id)) {
|
||||
// A non-string id is being resolved. Won't be found here, return
|
||||
// early.
|
||||
|
||||
|
@ -665,7 +655,7 @@ ResolveNativeProperty(JSContext *cx, JSObject *wrapperObj,
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSString *str = JSVAL_TO_STRING(id);
|
||||
JSString *str = JSID_TO_STRING(id);
|
||||
if (!str) {
|
||||
return DoThrowException(NS_ERROR_UNEXPECTED, cx);
|
||||
}
|
||||
|
@ -739,9 +729,7 @@ ResolveNativeProperty(JSContext *cx, JSObject *wrapperObj,
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!::JS_DefineUCProperty(cx, wrapperObj, ::JS_GetStringChars(str),
|
||||
::JS_GetStringLength(str), v, getter, setter,
|
||||
attrs)) {
|
||||
if (!::JS_DefinePropertyById(cx, wrapperObj, id, v, getter, setter, attrs)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -758,7 +746,7 @@ ResolveNativeProperty(JSContext *cx, JSObject *wrapperObj,
|
|||
JSBool
|
||||
GetOrSetNativeProperty(JSContext *cx, JSObject *obj,
|
||||
XPCWrappedNative *wrappedNative,
|
||||
jsval id, jsval *vp, JSBool aIsSet,
|
||||
jsid id, jsval *vp, JSBool aIsSet,
|
||||
JSBool isNativeWrapper)
|
||||
{
|
||||
// This will do verification and the method lookup for us.
|
||||
|
@ -806,7 +794,7 @@ GetOrSetNativeProperty(JSContext *cx, JSObject *obj,
|
|||
}
|
||||
}
|
||||
|
||||
if (!JSVAL_IS_STRING(id)) {
|
||||
if (!JSID_IS_STRING(id)) {
|
||||
// Not going to be found here
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -918,14 +906,10 @@ NativeToString(JSContext *cx, XPCWrappedNative *wrappedNative,
|
|||
XPCJSRuntime *rt = nsXPConnect::GetRuntimeInstance();
|
||||
|
||||
jsid id = rt->GetStringID(XPCJSRuntime::IDX_TO_STRING);
|
||||
jsval idAsVal;
|
||||
if (!::JS_IdToValue(cx, id, &idAsVal)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// Someone is trying to call toString on our wrapped object.
|
||||
JSObject *wn_obj = wrappedNative->GetFlatJSObject();
|
||||
XPCCallContext ccx(JS_CALLER, cx, wn_obj, nsnull, idAsVal);
|
||||
XPCCallContext ccx(JS_CALLER, cx, wn_obj, nsnull, id);
|
||||
if (!ccx.IsValid()) {
|
||||
// Shouldn't really happen.
|
||||
return DoThrowException(NS_ERROR_FAILURE, cx);
|
||||
|
|
|
@ -152,10 +152,10 @@ MakeSOW(JSContext *cx, JSObject *obj);
|
|||
|
||||
// Used by UnwrapSOW below.
|
||||
JSBool
|
||||
AllowedToAct(JSContext *cx, jsval idval);
|
||||
AllowedToAct(JSContext *cx, jsid id);
|
||||
|
||||
JSBool
|
||||
CheckFilename(JSContext *cx, jsval idval, JSStackFrame *fp);
|
||||
CheckFilename(JSContext *cx, jsid id, JSStackFrame *fp);
|
||||
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ UnwrapSOW(JSContext *cx, JSObject *wrapper)
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
if (!SystemOnlyWrapper::AllowedToAct(cx, JSVAL_VOID)) {
|
||||
if (!SystemOnlyWrapper::AllowedToAct(cx, JSID_VOID)) {
|
||||
JS_ClearPendingException(cx);
|
||||
wrapper = nsnull;
|
||||
}
|
||||
|
@ -456,13 +456,13 @@ CreateSimpleIterator(JSContext *cx, JSObject *scope, JSBool keysonly,
|
|||
JSBool
|
||||
AddProperty(JSContext *cx, JSObject *wrapperObj,
|
||||
JSBool wantGetterSetter, JSObject *innerObj,
|
||||
jsval id, jsval *vp);
|
||||
jsid id, jsval *vp);
|
||||
|
||||
/**
|
||||
* Called for the common part of deleting a property from obj.
|
||||
*/
|
||||
JSBool
|
||||
DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
/**
|
||||
* Called to enumerate the properties of |innerObj| onto |wrapperObj|.
|
||||
|
@ -481,7 +481,7 @@ Enumerate(JSContext *cx, JSObject *wrapperObj, JSObject *innerObj);
|
|||
*/
|
||||
JSBool
|
||||
NewResolve(JSContext *cx, JSObject *wrapperObj, JSBool preserveVal,
|
||||
JSObject *innerObj, jsval id, uintN flags, JSObject **objp);
|
||||
JSObject *innerObj, jsid id, uintN flags, JSObject **objp);
|
||||
|
||||
/**
|
||||
* Resolve a native property named id from innerObj onto wrapperObj. The
|
||||
|
@ -491,7 +491,7 @@ NewResolve(JSContext *cx, JSObject *wrapperObj, JSBool preserveVal,
|
|||
JSBool
|
||||
ResolveNativeProperty(JSContext *cx, JSObject *wrapperObj,
|
||||
JSObject *innerObj, XPCWrappedNative *wn,
|
||||
jsval id, uintN flags, JSObject **objp,
|
||||
jsid id, uintN flags, JSObject **objp,
|
||||
JSBool isNativeWrapper);
|
||||
|
||||
/**
|
||||
|
@ -502,7 +502,7 @@ ResolveNativeProperty(JSContext *cx, JSObject *wrapperObj,
|
|||
JSBool
|
||||
GetOrSetNativeProperty(JSContext *cx, JSObject *obj,
|
||||
XPCWrappedNative *wrappedNative,
|
||||
jsval id, jsval *vp, JSBool aIsSet,
|
||||
jsid id, jsval *vp, JSBool aIsSet,
|
||||
JSBool isNativeWrapper);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1121,7 +1121,7 @@ NS_IMETHODIMP nsXPConnect::InitClassesForOuterObject(JSContext * aJSContext, JSO
|
|||
}
|
||||
|
||||
static JSBool
|
||||
TempGlobalResolve(JSContext *aJSContext, JSObject *obj, jsval id)
|
||||
TempGlobalResolve(JSContext *aJSContext, JSObject *obj, jsid id)
|
||||
{
|
||||
JSBool resolved;
|
||||
return JS_ResolveStandardClass(aJSContext, obj, id, &resolved);
|
||||
|
|
|
@ -732,7 +732,7 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
|
|||
signature = "static JSBool\n"
|
||||
if isAttr:
|
||||
# JSPropertyOp signature.
|
||||
signature += "%s(JSContext *cx, JSObject *obj, jsval id,%s jsval *vp)\n"
|
||||
signature += "%s(JSContext *cx, JSObject *obj, jsid id,%s jsval *vp)\n"
|
||||
else:
|
||||
# JSFastNative.
|
||||
signature += "%s(JSContext *cx, uintN argc,%s jsval *vp)\n"
|
||||
|
@ -984,84 +984,92 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
|
|||
if customMethodCall is not None:
|
||||
f.write(callTemplate)
|
||||
|
||||
# Only these types can be returned (note: no strings);
|
||||
# if the type isn't one of these, then traceTypeMap['_default'] is used
|
||||
traceReturnTypeMap = {
|
||||
'void':
|
||||
["jsval ", "JSVAL", "JSVAL_VOID"],
|
||||
'boolean':
|
||||
["JSBool ", "BOOL", "JS_FALSE"],
|
||||
'short':
|
||||
["int32 ", "INT32", "0"],
|
||||
'unsigned short':
|
||||
["uint32 ", "UINT32", "0"],
|
||||
'long':
|
||||
["int32 ", "INT32", "0"],
|
||||
'unsigned long':
|
||||
["uint32 ", "UINT32", "0"],
|
||||
'float':
|
||||
["jsdouble ", "DOUBLE", "0"],
|
||||
'double':
|
||||
["jsdouble ", "DOUBLE", "0"],
|
||||
'octet':
|
||||
["uint32 ", "UINT32", "0"]
|
||||
}
|
||||
|
||||
# This list extends the above list, but includes types that
|
||||
# are valid for arguments only, namely strings. It also
|
||||
# includes the default jsval type.
|
||||
# Maps xpidl types to
|
||||
# [ C type, tracer argument type, tracer return type, default return value ]
|
||||
traceTypeMap = {
|
||||
# FIXME This should return void, not uint32
|
||||
# (waiting for https://bugzilla.mozilla.org/show_bug.cgi?id=572798)
|
||||
'void':
|
||||
["uint32 ", "UINT32", "UINT32", " 0"],
|
||||
'boolean':
|
||||
["JSBool ", "BOOL", "BOOL", " JS_FALSE"],
|
||||
'short':
|
||||
["int32 ", "INT32", "INT32", " 0"],
|
||||
'unsigned short':
|
||||
["uint32 ", "UINT32", "UINT32", " 0"],
|
||||
'long':
|
||||
["int32 ", "INT32", "INT32", " 0"],
|
||||
'unsigned long':
|
||||
["uint32 ", "UINT32", "UINT32", " 0"],
|
||||
'float':
|
||||
["jsdouble ", "DOUBLE", "DOUBLE", " 0"],
|
||||
'double':
|
||||
["jsdouble ", "DOUBLE", "DOUBLE", " 0"],
|
||||
'octet':
|
||||
["uint32 ", "UINT32", "UINT32", " 0"],
|
||||
'[astring]':
|
||||
["JSString *", "STRING", "nsnull"],
|
||||
["JSString *", "STRING", "STRING_OR_NULL", " nsnull"],
|
||||
'[domstring]':
|
||||
["JSString *", "STRING", "nsnull"],
|
||||
["JSString *", "STRING", "STRING_OR_NULL", " nsnull"],
|
||||
'[cstring]':
|
||||
["JSString *", "STRING", "nsnull"],
|
||||
["JSString *", "STRING", "STRING_OR_NULL", " nsnull"],
|
||||
'string':
|
||||
["JSString *", "STRING", "nsnull"],
|
||||
["JSString *", "STRING", "STRING_OR_NULL", " nsnull"],
|
||||
'wstring':
|
||||
["JSString *", "STRING", "nsnull"],
|
||||
|
||||
'_default':
|
||||
["jsval ", "JSVAL", "JSVAL_VOID"]
|
||||
["JSString *", "STRING", "STRING_OR_NULL", " nsnull"],
|
||||
}
|
||||
|
||||
def getTraceType(type):
|
||||
type = getBuiltinOrNativeTypeName(type)
|
||||
traceType = traceReturnTypeMap.get(type) or traceTypeMap.get(type) or traceTypeMap.get("_default")
|
||||
assert traceType
|
||||
return traceType[0]
|
||||
typeName = getBuiltinOrNativeTypeName(type)
|
||||
if typeName is not None:
|
||||
traceType = traceTypeMap.get(typeName)[0]
|
||||
else:
|
||||
assert isInterfaceType(type)
|
||||
traceType = "js::Value *"
|
||||
return traceType
|
||||
|
||||
def getTraceReturnType(type):
|
||||
type = getBuiltinOrNativeTypeName(type)
|
||||
traceType = traceReturnTypeMap.get(type) or traceTypeMap.get("_default")
|
||||
assert traceType
|
||||
return traceType[0]
|
||||
typeName = getBuiltinOrNativeTypeName(type)
|
||||
if typeName is not None:
|
||||
traceType = traceTypeMap.get(typeName)[0]
|
||||
else:
|
||||
assert isInterfaceType(type)
|
||||
traceType = "JSObject *"
|
||||
return traceType
|
||||
|
||||
def getTraceInfoType(type):
|
||||
type = getBuiltinOrNativeTypeName(type)
|
||||
traceType = traceReturnTypeMap.get(type) or traceTypeMap.get(type) or traceTypeMap.get("_default")
|
||||
assert traceType
|
||||
return traceType[1]
|
||||
typeName = getBuiltinOrNativeTypeName(type)
|
||||
if typeName is not None:
|
||||
traceType = traceTypeMap.get(typeName)[1]
|
||||
else:
|
||||
assert isInterfaceType(type)
|
||||
traceType = "VALUEPTR"
|
||||
return traceType
|
||||
|
||||
def getTraceInfoReturnType(type):
|
||||
type = getBuiltinOrNativeTypeName(type)
|
||||
traceType = traceReturnTypeMap.get(type) or traceTypeMap.get("_default")
|
||||
assert traceType
|
||||
return traceType[1]
|
||||
typeName = getBuiltinOrNativeTypeName(type)
|
||||
if typeName is not None:
|
||||
traceType = traceTypeMap.get(typeName)[2]
|
||||
else:
|
||||
assert isInterfaceType(type)
|
||||
traceType = "OBJECT_OR_NULL"
|
||||
return traceType
|
||||
|
||||
def getTraceInfoDefaultReturn(type):
|
||||
type = getBuiltinOrNativeTypeName(type)
|
||||
traceType = traceTypeMap.get(type) or traceTypeMap.get("_default")
|
||||
assert traceType
|
||||
return traceType[2]
|
||||
typeName = getBuiltinOrNativeTypeName(type)
|
||||
if typeName is not None:
|
||||
traceType = traceTypeMap.get(typeName)[3]
|
||||
else:
|
||||
assert isInterfaceType(type)
|
||||
traceType = " nsnull"
|
||||
return traceType
|
||||
|
||||
def getFailureString(retval, indent):
|
||||
assert indent > 0
|
||||
ret = " " * (4 * indent)
|
||||
ret += "js_SetTraceableNativeFailed(cx);\n"
|
||||
ret += " " * (4 * indent)
|
||||
ret += "return %s;\n" % retval
|
||||
ret += "return%s;\n" % retval
|
||||
ret += " " * (4 * (indent - 1))
|
||||
ret += "}\n"
|
||||
return ret
|
||||
|
@ -1125,7 +1133,7 @@ def writeTraceableArgumentConversion(f, member, i, name, type, haveCcx,
|
|||
assert haveCcx
|
||||
template = (
|
||||
" nsCOMPtr<nsIVariant> ${name}(already_AddRefed<nsIVariant>("
|
||||
"XPCVariant::newVariant(ccx, ${argVal})));\n"
|
||||
"XPCVariant::newVariant(ccx, *js::Jsvalify(${argVal}))));\n"
|
||||
" if (!${name}) {\n")
|
||||
f.write(substitute(template, params))
|
||||
writeFailure(f, getTraceInfoDefaultReturn(member.realtype), 2)
|
||||
|
@ -1139,7 +1147,7 @@ def writeTraceableArgumentConversion(f, member, i, name, type, haveCcx,
|
|||
f.write(" %s *%s;\n" % (type.name, name))
|
||||
f.write(" xpc_qsSelfRef %sref;\n" % name)
|
||||
f.write(" rv = xpc_qsUnwrapArg<%s>("
|
||||
"cx, %s, &%s, &%sref.ptr, &vp.array[%d]);\n"
|
||||
"cx, *js::Jsvalify(%s), &%s, &%sref.ptr, &vp.array[%d]);\n"
|
||||
% (type.name, argVal, name, name, 1 + i))
|
||||
f.write(" if (NS_FAILED(rv)) {\n")
|
||||
if haveCcx:
|
||||
|
@ -1159,7 +1167,7 @@ def writeTraceableArgumentConversion(f, member, i, name, type, haveCcx,
|
|||
|
||||
traceableResultConvTemplates = {
|
||||
'void':
|
||||
" return JSVAL_VOID;\n",
|
||||
" return 0;\n",
|
||||
'octet':
|
||||
" return uint32(result);\n",
|
||||
'short':
|
||||
|
@ -1177,15 +1185,15 @@ traceableResultConvTemplates = {
|
|||
'double':
|
||||
" return jsdouble(result);\n",
|
||||
'[domstring]':
|
||||
" jsval rval;\n"
|
||||
" if (!xpc_qsStringToJsval(cx, result, &rval)) {\n"
|
||||
" JSString *rval;\n"
|
||||
" if (!xpc_qsStringToJsstring(cx, result, &rval)) {\n"
|
||||
" JS_ReportOutOfMemory(cx);\n${errorStr}"
|
||||
" return rval;\n",
|
||||
'[astring]':
|
||||
" jsval rval;\n"
|
||||
" if (!xpc_qsStringToJsval(cx, result, &rval)) {\n"
|
||||
" JSString *rval;\n"
|
||||
" if (!xpc_qsStringToJsstring(cx, result, &rval)) {\n"
|
||||
" JS_ReportOutOfMemory(cx);\n${errorStr}"
|
||||
" return rval;\n",
|
||||
" return rval;\n"
|
||||
}
|
||||
|
||||
def writeTraceableResultConv(f, type):
|
||||
|
@ -1209,7 +1217,7 @@ def writeTraceableResultConv(f, type):
|
|||
% (type.name, type.name))
|
||||
f.write(" if (!ok) {\n");
|
||||
writeFailure(f, getTraceInfoDefaultReturn(type), 2)
|
||||
f.write(" return vp.array[0];\n")
|
||||
f.write(" return JSVAL_TO_OBJECT(vp.array[0]);\n")
|
||||
return
|
||||
|
||||
warn("Unable to convert result of type %s" % typeName)
|
||||
|
|
|
@ -43,13 +43,13 @@
|
|||
#include "xpcprivate.h"
|
||||
|
||||
XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
|
||||
JSContext* cx /* = nsnull */,
|
||||
JSObject* obj /* = nsnull */,
|
||||
JSObject* funobj /* = nsnull */,
|
||||
jsval name /* = 0 */,
|
||||
uintN argc /* = NO_ARGS */,
|
||||
jsval *argv /* = nsnull */,
|
||||
jsval *rval /* = nsnull */)
|
||||
JSContext* cx /* = nsnull */,
|
||||
JSObject* obj /* = nsnull */,
|
||||
JSObject* funobj /* = nsnull */,
|
||||
jsid name /* = JSID_VOID */,
|
||||
uintN argc /* = NO_ARGS */,
|
||||
jsval *argv /* = nsnull */,
|
||||
jsval *rval /* = nsnull */)
|
||||
: mState(INIT_FAILED),
|
||||
mXPC(nsXPConnect::GetXPConnect()),
|
||||
mThreadData(nsnull),
|
||||
|
@ -84,7 +84,7 @@ XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
|
|||
mTearOff(tearOff),
|
||||
mCallee(nsnull)
|
||||
{
|
||||
Init(callerLanguage, callBeginRequest, obj, nsnull, JS_FALSE, 0, NO_ARGS,
|
||||
Init(callerLanguage, callBeginRequest, obj, nsnull, JS_FALSE, JSID_VOID, NO_ARGS,
|
||||
nsnull, nsnull);
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
|
|||
JSObject* obj,
|
||||
JSObject* funobj,
|
||||
JSBool getWrappedNative,
|
||||
jsval name,
|
||||
jsid name,
|
||||
uintN argc,
|
||||
jsval *argv,
|
||||
jsval *rval)
|
||||
|
@ -220,7 +220,7 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
|
|||
mFlattenedJSObject = mCurrentJSObject;
|
||||
}
|
||||
|
||||
if(name)
|
||||
if(!JSID_IS_VOID(name))
|
||||
SetName(name);
|
||||
|
||||
if(argc != NO_ARGS)
|
||||
|
@ -230,7 +230,7 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
|
|||
}
|
||||
|
||||
void
|
||||
XPCCallContext::SetName(jsval name)
|
||||
XPCCallContext::SetName(jsid name)
|
||||
{
|
||||
CHECK_STATE(HAVE_OBJECT);
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ nsXPCComponents_Interfaces::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
*statep = PRIVATE_TO_JSVAL(e);
|
||||
if(idp)
|
||||
*idp = JSVAL_ZERO; // indicate that we don't know the count
|
||||
*idp = INT_TO_JSID(0); // indicate that we don't know the count
|
||||
return NS_OK;
|
||||
}
|
||||
case JSENUMERATE_NEXT:
|
||||
|
@ -330,14 +330,14 @@ nsXPCComponents_Interfaces::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
|||
NS_IMETHODIMP
|
||||
nsXPCComponents_Interfaces::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * obj,
|
||||
jsval id, PRUint32 flags,
|
||||
jsid id, PRUint32 flags,
|
||||
JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
const char* name = nsnull;
|
||||
|
||||
if(mManager &&
|
||||
JSVAL_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSVAL_TO_STRING(id))) &&
|
||||
JSID_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSID_TO_STRING(id))) &&
|
||||
name[0] != '{') // we only allow interfaces by name here
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
|
@ -363,11 +363,8 @@ nsXPCComponents_Interfaces::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
JSObject* idobj;
|
||||
if(holder && NS_SUCCEEDED(holder->GetJSObject(&idobj)))
|
||||
{
|
||||
jsid idid;
|
||||
|
||||
*objp = obj;
|
||||
*_retval = JS_ValueToId(cx, id, &idid) &&
|
||||
JS_DefinePropertyById(cx, obj, idid,
|
||||
*_retval = JS_DefinePropertyById(cx, obj, id,
|
||||
OBJECT_TO_JSVAL(idobj),
|
||||
nsnull, nsnull,
|
||||
JSPROP_ENUMERATE |
|
||||
|
@ -604,7 +601,7 @@ nsXPCComponents_InterfacesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
*statep = PRIVATE_TO_JSVAL(e);
|
||||
if(idp)
|
||||
*idp = JSVAL_ZERO; // indicate that we don't know the count
|
||||
*idp = INT_TO_JSID(0); // indicate that we don't know the count
|
||||
return NS_OK;
|
||||
}
|
||||
case JSENUMERATE_NEXT:
|
||||
|
@ -664,15 +661,15 @@ nsXPCComponents_InterfacesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
|||
NS_IMETHODIMP
|
||||
nsXPCComponents_InterfacesByID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * obj,
|
||||
jsval id, PRUint32 flags,
|
||||
jsid id, PRUint32 flags,
|
||||
JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
const jschar* name = nsnull;
|
||||
|
||||
if(mManager &&
|
||||
JSVAL_IS_STRING(id) &&
|
||||
38 == JS_GetStringLength(JSVAL_TO_STRING(id)) &&
|
||||
nsnull != (name = JS_GetStringChars(JSVAL_TO_STRING(id))))
|
||||
JSID_IS_STRING(id) &&
|
||||
38 == JS_GetStringLength(JSID_TO_STRING(id)) &&
|
||||
nsnull != (name = JS_GetStringChars(JSID_TO_STRING(id))))
|
||||
{
|
||||
nsID iid;
|
||||
if (!iid.Parse(NS_ConvertUTF16toUTF8(reinterpret_cast<const PRUnichar*>
|
||||
|
@ -703,11 +700,9 @@ nsXPCComponents_InterfacesByID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
JSObject* idobj;
|
||||
if(holder && NS_SUCCEEDED(holder->GetJSObject(&idobj)))
|
||||
{
|
||||
jsid idid;
|
||||
|
||||
*objp = obj;
|
||||
*_retval = JS_ValueToId(cx, id, &idid) &&
|
||||
JS_DefinePropertyById(cx, obj, idid,
|
||||
*_retval =
|
||||
JS_DefinePropertyById(cx, obj, id,
|
||||
OBJECT_TO_JSVAL(idobj),
|
||||
nsnull, nsnull,
|
||||
JSPROP_ENUMERATE |
|
||||
|
@ -926,7 +921,7 @@ nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
*statep = PRIVATE_TO_JSVAL(e);
|
||||
if(idp)
|
||||
*idp = JSVAL_ZERO; // indicate that we don't know the count
|
||||
*idp = INT_TO_JSID(0); // indicate that we don't know the count
|
||||
return NS_OK;
|
||||
}
|
||||
case JSENUMERATE_NEXT:
|
||||
|
@ -969,14 +964,14 @@ nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
|||
NS_IMETHODIMP
|
||||
nsXPCComponents_Classes::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * obj,
|
||||
jsval id, PRUint32 flags,
|
||||
jsid id, PRUint32 flags,
|
||||
JSObject * *objp, PRBool *_retval)
|
||||
|
||||
{
|
||||
const char* name = nsnull;
|
||||
|
||||
if(JSVAL_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSVAL_TO_STRING(id))) &&
|
||||
if(JSID_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSID_TO_STRING(id))) &&
|
||||
name[0] != '{') // we only allow contractids here
|
||||
{
|
||||
nsCOMPtr<nsIJSCID> nsid =
|
||||
|
@ -996,11 +991,8 @@ nsXPCComponents_Classes::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
JSObject* idobj;
|
||||
if(holder && NS_SUCCEEDED(holder->GetJSObject(&idobj)))
|
||||
{
|
||||
jsid idid;
|
||||
|
||||
*objp = obj;
|
||||
*_retval = JS_ValueToId(cx, id, &idid) &&
|
||||
JS_DefinePropertyById(cx, obj, idid,
|
||||
*_retval = JS_DefinePropertyById(cx, obj, id,
|
||||
OBJECT_TO_JSVAL(idobj),
|
||||
nsnull, nsnull,
|
||||
JSPROP_ENUMERATE |
|
||||
|
@ -1179,7 +1171,7 @@ nsXPCComponents_ClassesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
*statep = PRIVATE_TO_JSVAL(e);
|
||||
if(idp)
|
||||
*idp = JSVAL_ZERO; // indicate that we don't know the count
|
||||
*idp = INT_TO_JSID(0); // indicate that we don't know the count
|
||||
return NS_OK;
|
||||
}
|
||||
case JSENUMERATE_NEXT:
|
||||
|
@ -1240,13 +1232,13 @@ IsRegisteredCLSID(const char* str)
|
|||
NS_IMETHODIMP
|
||||
nsXPCComponents_ClassesByID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * obj,
|
||||
jsval id, PRUint32 flags,
|
||||
jsid id, PRUint32 flags,
|
||||
JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
const char* name = nsnull;
|
||||
|
||||
if(JSVAL_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSVAL_TO_STRING(id))) &&
|
||||
if(JSID_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSID_TO_STRING(id))) &&
|
||||
name[0] == '{' &&
|
||||
IsRegisteredCLSID(name)) // we only allow canonical CLSIDs here
|
||||
{
|
||||
|
@ -1267,11 +1259,8 @@ nsXPCComponents_ClassesByID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
JSObject* idobj;
|
||||
if(holder && NS_SUCCEEDED(holder->GetJSObject(&idobj)))
|
||||
{
|
||||
jsid idid;
|
||||
|
||||
*objp = obj;
|
||||
*_retval = JS_ValueToId(cx, id, &idid) &&
|
||||
JS_DefinePropertyById(cx, obj, idid,
|
||||
*_retval = JS_DefinePropertyById(cx, obj, id,
|
||||
OBJECT_TO_JSVAL(idobj),
|
||||
nsnull, nsnull,
|
||||
JSPROP_ENUMERATE |
|
||||
|
@ -1443,7 +1432,7 @@ nsXPCComponents_Results::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
|||
case JSENUMERATE_INIT:
|
||||
{
|
||||
if(idp)
|
||||
*idp = INT_TO_JSVAL(nsXPCException::GetNSResultCount());
|
||||
*idp = INT_TO_JSID(nsXPCException::GetNSResultCount());
|
||||
|
||||
void** space = (void**) new char[sizeof(void*)];
|
||||
*space = nsnull;
|
||||
|
@ -1477,13 +1466,13 @@ nsXPCComponents_Results::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
|||
NS_IMETHODIMP
|
||||
nsXPCComponents_Results::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * obj,
|
||||
jsval id, PRUint32 flags,
|
||||
jsid id, PRUint32 flags,
|
||||
JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
const char* name = nsnull;
|
||||
|
||||
if(JSVAL_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSVAL_TO_STRING(id))))
|
||||
if(JSID_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSID_TO_STRING(id))))
|
||||
{
|
||||
const char* rv_name;
|
||||
void* iter = nsnull;
|
||||
|
@ -1492,13 +1481,11 @@ nsXPCComponents_Results::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
{
|
||||
if(!strcmp(name, rv_name))
|
||||
{
|
||||
jsid idid;
|
||||
jsval val;
|
||||
|
||||
*objp = obj;
|
||||
if(!JS_NewNumberValue(cx, (jsdouble)rv, &val) ||
|
||||
!JS_ValueToId(cx, id, &idid) ||
|
||||
!JS_DefinePropertyById(cx, obj, idid, val,
|
||||
!JS_DefinePropertyById(cx, obj, id, val,
|
||||
nsnull, nsnull,
|
||||
JSPROP_ENUMERATE |
|
||||
JSPROP_READONLY |
|
||||
|
@ -2834,7 +2821,7 @@ nsXPCComponents_Utils::LookupMethod()
|
|||
// XPCWrappedNative. This means no deep wrapping, unfortunately, but we
|
||||
// can't keep track of both the underlying function and the
|
||||
// XPCNativeWrapper at once in a single parent slot...
|
||||
XPCCallContext inner_cc(JS_CALLER, cx, obj, nsnull, argv[1]);
|
||||
XPCCallContext inner_cc(JS_CALLER, cx, obj, nsnull, name_id);
|
||||
|
||||
// was our jsobject really a wrapped native at all?
|
||||
XPCWrappedNative* wrapper = inner_cc.GetWrapper();
|
||||
|
@ -3093,19 +3080,14 @@ sandbox_enumerate(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
sandbox_getProto(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
||||
sandbox_getProto(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
jsid id;
|
||||
if (!JS_ValueToId(cx, idval, &id)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
uintN attrs;
|
||||
return JS_CheckAccess(cx, obj, id, JSACC_PROTO, vp, &attrs);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
sandbox_setProto(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
sandbox_setProto(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
if (!JSVAL_IS_OBJECT(*vp)) {
|
||||
return JS_TRUE;
|
||||
|
@ -3124,21 +3106,16 @@ sandbox_setProto(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
sandbox_resolve(JSContext *cx, JSObject *obj, jsval idval)
|
||||
sandbox_resolve(JSContext *cx, JSObject *obj, jsid id)
|
||||
{
|
||||
JSBool resolved;
|
||||
if (!JS_ResolveStandardClass(cx, obj, idval, &resolved)) {
|
||||
if (!JS_ResolveStandardClass(cx, obj, id, &resolved)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (resolved) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
jsid id;
|
||||
if (!JS_ValueToId(cx, idval, &id)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_PROTO)) {
|
||||
return JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, sandbox_getProto,
|
||||
sandbox_setProto, JSPROP_SHARED);
|
||||
|
@ -4076,28 +4053,22 @@ nsXPCComponents::GetManager(nsIComponentManager * *aManager)
|
|||
NS_IMETHODIMP
|
||||
nsXPCComponents::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * obj,
|
||||
jsval id, PRUint32 flags,
|
||||
jsid id, PRUint32 flags,
|
||||
JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
|
||||
if(!rt)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
jsid idid;
|
||||
uintN attrs = 0;
|
||||
|
||||
if(id == rt->GetStringJSVal(XPCJSRuntime::IDX_LAST_RESULT))
|
||||
{
|
||||
idid = rt->GetStringID(XPCJSRuntime::IDX_LAST_RESULT);
|
||||
if(id == rt->GetStringID(XPCJSRuntime::IDX_LAST_RESULT))
|
||||
attrs = JSPROP_READONLY;
|
||||
}
|
||||
else if(id == rt->GetStringJSVal(XPCJSRuntime::IDX_RETURN_CODE))
|
||||
idid = rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE);
|
||||
else
|
||||
else if(id != rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE))
|
||||
return NS_OK;
|
||||
|
||||
*objp = obj;
|
||||
*_retval = JS_DefinePropertyById(cx, obj, idid, JSVAL_VOID, nsnull, nsnull,
|
||||
*_retval = JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nsnull, nsnull,
|
||||
JSPROP_ENUMERATE | JSPROP_PERMANENT |
|
||||
attrs);
|
||||
return NS_OK;
|
||||
|
@ -4107,7 +4078,7 @@ nsXPCComponents::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
NS_IMETHODIMP
|
||||
nsXPCComponents::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * obj,
|
||||
jsval id, jsval * vp, PRBool *_retval)
|
||||
jsid id, jsval * vp, PRBool *_retval)
|
||||
{
|
||||
XPCContext* xpcc = XPCContext::GetXPCContext(cx);
|
||||
if(!xpcc)
|
||||
|
@ -4116,12 +4087,12 @@ nsXPCComponents::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
|||
PRBool doResult = JS_FALSE;
|
||||
nsresult res;
|
||||
XPCJSRuntime* rt = xpcc->GetRuntime();
|
||||
if(id == rt->GetStringJSVal(XPCJSRuntime::IDX_LAST_RESULT))
|
||||
if(id == rt->GetStringID(XPCJSRuntime::IDX_LAST_RESULT))
|
||||
{
|
||||
res = xpcc->GetLastResult();
|
||||
doResult = JS_TRUE;
|
||||
}
|
||||
else if(id == rt->GetStringJSVal(XPCJSRuntime::IDX_RETURN_CODE))
|
||||
else if(id == rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE))
|
||||
{
|
||||
res = xpcc->GetPendingResult();
|
||||
doResult = JS_TRUE;
|
||||
|
@ -4138,10 +4109,10 @@ nsXPCComponents::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
|||
return rv;
|
||||
}
|
||||
|
||||
/* PRBool setProperty (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval id, in JSValPtr vp); */
|
||||
/* PRBool setProperty (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsid id, in JSValPtr vp); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents::SetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * obj, jsval id,
|
||||
JSContext * cx, JSObject * obj, jsid id,
|
||||
jsval * vp, PRBool *_retval)
|
||||
{
|
||||
XPCContext* xpcc = XPCContext::GetXPCContext(cx);
|
||||
|
@ -4152,7 +4123,7 @@ nsXPCComponents::SetProperty(nsIXPConnectWrappedNative *wrapper,
|
|||
if(!rt)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if(id == rt->GetStringJSVal(XPCJSRuntime::IDX_RETURN_CODE))
|
||||
if(id == rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE))
|
||||
{
|
||||
nsresult rv;
|
||||
if(JS_ValueToECMAUint32(cx, *vp, (uint32*)&rv))
|
||||
|
|
|
@ -257,7 +257,7 @@ XPCCallContext::HasInterfaceAndMember() const
|
|||
);
|
||||
}
|
||||
|
||||
inline jsval
|
||||
inline jsid
|
||||
XPCCallContext::GetName() const
|
||||
{
|
||||
CHECK_STATE(HAVE_NAME);
|
||||
|
@ -307,15 +307,15 @@ XPCCallContext::SetRetVal(jsval val)
|
|||
*mRetVal = val;
|
||||
}
|
||||
|
||||
inline jsval
|
||||
inline jsid
|
||||
XPCCallContext::GetResolveName() const
|
||||
{
|
||||
CHECK_STATE(HAVE_CONTEXT);
|
||||
return mThreadData->GetResolveName();
|
||||
}
|
||||
|
||||
inline jsval
|
||||
XPCCallContext::SetResolveName(jsval name)
|
||||
inline jsid
|
||||
XPCCallContext::SetResolveName(jsid name)
|
||||
{
|
||||
CHECK_STATE(HAVE_CONTEXT);
|
||||
return mThreadData->SetResolveName(name);
|
||||
|
@ -396,7 +396,7 @@ XPCNativeInterface::GetNameString() const
|
|||
}
|
||||
|
||||
inline XPCNativeMember*
|
||||
XPCNativeInterface::FindMember(jsval name) const
|
||||
XPCNativeInterface::FindMember(jsid name) const
|
||||
{
|
||||
const XPCNativeMember* member = mMembers;
|
||||
for(int i = (int) mMemberCount; i > 0; i--, member++)
|
||||
|
@ -424,7 +424,7 @@ XPCNativeInterface::DealWithDyingGCThings(JSContext* cx, XPCJSRuntime* rt)
|
|||
/***************************************************************************/
|
||||
|
||||
inline JSBool
|
||||
XPCNativeSet::FindMember(jsval name, XPCNativeMember** pMember,
|
||||
XPCNativeSet::FindMember(jsid name, XPCNativeMember** pMember,
|
||||
PRUint16* pInterfaceIndex) const
|
||||
{
|
||||
XPCNativeInterface* const * iface;
|
||||
|
@ -462,7 +462,7 @@ XPCNativeSet::FindMember(jsval name, XPCNativeMember** pMember,
|
|||
}
|
||||
|
||||
inline JSBool
|
||||
XPCNativeSet::FindMember(jsval name, XPCNativeMember** pMember,
|
||||
XPCNativeSet::FindMember(jsid name, XPCNativeMember** pMember,
|
||||
XPCNativeInterface** pInterface) const
|
||||
{
|
||||
PRUint16 index;
|
||||
|
@ -473,7 +473,7 @@ XPCNativeSet::FindMember(jsval name, XPCNativeMember** pMember,
|
|||
}
|
||||
|
||||
inline JSBool
|
||||
XPCNativeSet::FindMember(jsval name,
|
||||
XPCNativeSet::FindMember(jsid name,
|
||||
XPCNativeMember** pMember,
|
||||
XPCNativeInterface** pInterface,
|
||||
XPCNativeSet* protoSet,
|
||||
|
@ -501,7 +501,7 @@ XPCNativeSet::FindMember(jsval name,
|
|||
}
|
||||
|
||||
inline XPCNativeInterface*
|
||||
XPCNativeSet::FindNamedInterface(jsval name) const
|
||||
XPCNativeSet::FindNamedInterface(jsid name) const
|
||||
{
|
||||
XPCNativeInterface* const * pp = mInterfaces;
|
||||
|
||||
|
@ -717,13 +717,11 @@ XPCWrappedNative::SweepTearOffs()
|
|||
/***************************************************************************/
|
||||
|
||||
inline JSBool
|
||||
xpc_ForcePropertyResolve(JSContext* cx, JSObject* obj, jsval idval)
|
||||
xpc_ForcePropertyResolve(JSContext* cx, JSObject* obj, jsid id)
|
||||
{
|
||||
jsval prop;
|
||||
jsid id;
|
||||
|
||||
if(!JS_ValueToId(cx, idval, &id) ||
|
||||
!JS_LookupPropertyById(cx, obj, id, &prop))
|
||||
if(!JS_LookupPropertyById(cx, obj, id, &prop))
|
||||
return JS_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -776,7 +774,7 @@ GetRTIdByIndex(JSContext *cx, uintN index)
|
|||
inline jsval
|
||||
GetRTStringByIndex(JSContext *cx, uintN index)
|
||||
{
|
||||
return ID_TO_JSVAL(GetRTIdByIndex(cx, index));
|
||||
return STRING_TO_JSVAL(JSID_TO_STRING(GetRTIdByIndex(cx, index)));
|
||||
}
|
||||
|
||||
inline
|
||||
|
|
|
@ -474,7 +474,7 @@ nsJSIID::NewID(nsIInterfaceInfo* aInfo)
|
|||
NS_IMETHODIMP
|
||||
nsJSIID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * obj,
|
||||
jsval id, PRUint32 flags,
|
||||
jsid id, PRUint32 flags,
|
||||
JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
XPCCallContext ccx(JS_CALLER, cx);
|
||||
|
@ -496,12 +496,8 @@ nsJSIID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
if(!member->GetConstantValue(ccx, iface, &val))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
jsid idid;
|
||||
if(!JS_ValueToId(cx, id, &idid))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*objp = obj;
|
||||
*_retval = JS_DefinePropertyById(cx, obj, idid, val, nsnull, nsnull,
|
||||
*_retval = JS_DefinePropertyById(cx, obj, id, val, nsnull, nsnull,
|
||||
JSPROP_ENUMERATE | JSPROP_READONLY |
|
||||
JSPROP_PERMANENT);
|
||||
}
|
||||
|
@ -920,7 +916,7 @@ nsJSCID::Construct(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
// 'push' a call context and call on it
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, nsnull,
|
||||
rt->GetStringJSVal(XPCJSRuntime::IDX_CREATE_INSTANCE),
|
||||
rt->GetStringID(XPCJSRuntime::IDX_CREATE_INSTANCE),
|
||||
argc, argv, vp);
|
||||
|
||||
*_retval = XPCWrappedNative::CallMethod(ccx);
|
||||
|
|
|
@ -1074,7 +1074,7 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
|||
DOM_InitInterfaces();
|
||||
|
||||
// these jsids filled in later when we have a JSContext to work with.
|
||||
mStrIDs[0] = 0;
|
||||
mStrIDs[0] = JSID_VOID;
|
||||
|
||||
mJSRuntime = JS_NewRuntime(32L * 1024L * 1024L); // pref ?
|
||||
if(mJSRuntime)
|
||||
|
@ -1146,7 +1146,7 @@ XPCJSRuntime::OnJSContextNew(JSContext *cx)
|
|||
|
||||
// if it is our first context then we need to generate our string ids
|
||||
JSBool ok = JS_TRUE;
|
||||
if(!mStrIDs[0])
|
||||
if(JSID_IS_VOID(mStrIDs[0]))
|
||||
{
|
||||
JS_SetGCParameterForThread(cx, JSGC_MAX_CODE_CACHE_BYTES, 16 * 1024 * 1024);
|
||||
JSAutoRequest ar(cx);
|
||||
|
@ -1155,7 +1155,7 @@ XPCJSRuntime::OnJSContextNew(JSContext *cx)
|
|||
JSString* str = JS_InternString(cx, mStrings[i]);
|
||||
if(!str || !JS_ValueToId(cx, STRING_TO_JSVAL(str), &mStrIDs[i]))
|
||||
{
|
||||
mStrIDs[0] = 0;
|
||||
mStrIDs[0] = JSID_VOID;
|
||||
ok = JS_FALSE;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -950,7 +950,7 @@ public:
|
|||
JSContext* cx = nsnull,
|
||||
JSObject* obj = nsnull,
|
||||
JSObject* funobj = nsnull,
|
||||
jsval id = 0,
|
||||
jsid id = JSID_VOID,
|
||||
uintN argc = NO_ARGS,
|
||||
jsval *argv = nsnull,
|
||||
jsval *rval = nsnull);
|
||||
|
@ -988,7 +988,7 @@ public:
|
|||
inline XPCNativeInterface* GetInterface() const ;
|
||||
inline XPCNativeMember* GetMember() const ;
|
||||
inline JSBool HasInterfaceAndMember() const ;
|
||||
inline jsval GetName() const ;
|
||||
inline jsid GetName() const ;
|
||||
inline JSBool GetStaticMemberIsLocal() const ;
|
||||
inline uintN GetArgc() const ;
|
||||
inline jsval* GetArgv() const ;
|
||||
|
@ -1001,8 +1001,8 @@ public:
|
|||
inline JSBool GetDestroyJSContextInDestructor() const;
|
||||
inline void SetDestroyJSContextInDestructor(JSBool b);
|
||||
|
||||
inline jsval GetResolveName() const;
|
||||
inline jsval SetResolveName(jsval name);
|
||||
inline jsid GetResolveName() const;
|
||||
inline jsid SetResolveName(jsid name);
|
||||
|
||||
inline XPCWrappedNative* GetResolvingWrapper() const;
|
||||
inline XPCWrappedNative* SetResolvingWrapper(XPCWrappedNative* w);
|
||||
|
@ -1012,7 +1012,7 @@ public:
|
|||
inline JSObject* GetCallee() const;
|
||||
inline void SetCallee(JSObject* callee);
|
||||
|
||||
void SetName(jsval name);
|
||||
void SetName(jsid name);
|
||||
void SetArgsAndResultPtr(uintN argc, jsval *argv, jsval *rval);
|
||||
void SetCallInfo(XPCNativeInterface* iface, XPCNativeMember* member,
|
||||
JSBool isSetter);
|
||||
|
@ -1055,7 +1055,7 @@ private:
|
|||
JSObject* obj,
|
||||
JSObject* funobj,
|
||||
JSBool getWrappedNative,
|
||||
jsval name,
|
||||
jsid name,
|
||||
uintN argc,
|
||||
jsval *argv,
|
||||
jsval *rval);
|
||||
|
@ -1110,7 +1110,7 @@ private:
|
|||
XPCNativeInterface* mInterface;
|
||||
XPCNativeMember* mMember;
|
||||
|
||||
jsval mName;
|
||||
jsid mName;
|
||||
JSBool mStaticMemberIsLocal;
|
||||
|
||||
uintN mArgc;
|
||||
|
@ -1284,7 +1284,7 @@ extern JSClass XPC_WN_Tearoff_JSClass;
|
|||
extern JSClass XPC_WN_NoHelper_Proto_JSClass;
|
||||
|
||||
extern JSBool
|
||||
XPC_WN_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
XPC_WN_Equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
|
||||
|
||||
extern JSObjectOps *
|
||||
XPC_WN_Proto_GetObjectOps(JSContext *cx, JSClass *clazz);
|
||||
|
@ -1557,7 +1557,7 @@ public:
|
|||
XPCNativeInterface** pInterface,
|
||||
XPCNativeMember** pMember);
|
||||
|
||||
jsval GetName() const {return mName;}
|
||||
jsid GetName() const {return mName;}
|
||||
|
||||
PRUint16 GetIndex() const {return mIndex;}
|
||||
|
||||
|
@ -1587,7 +1587,7 @@ public:
|
|||
{return IsAttribute() && !IsWritableAttribute();}
|
||||
|
||||
|
||||
void SetName(jsval a) {mName = a;}
|
||||
void SetName(jsid a) {mName = a;}
|
||||
|
||||
void SetMethod(PRUint16 index)
|
||||
{mVal = JSVAL_NULL; mFlags = METHOD; mIndex = index;}
|
||||
|
@ -1624,7 +1624,7 @@ private:
|
|||
|
||||
private:
|
||||
// our only data...
|
||||
jsval mName;
|
||||
jsid mName;
|
||||
jsval mVal;
|
||||
PRUint16 mIndex;
|
||||
PRUint16 mFlags;
|
||||
|
@ -1648,11 +1648,11 @@ public:
|
|||
static XPCNativeInterface* GetISupports(XPCCallContext& ccx);
|
||||
|
||||
inline nsIInterfaceInfo* GetInterfaceInfo() const {return mInfo.get();}
|
||||
inline jsval GetName() const {return mName;}
|
||||
inline jsid GetName() const {return mName;}
|
||||
|
||||
inline const nsIID* GetIID() const;
|
||||
inline const char* GetNameString() const;
|
||||
inline XPCNativeMember* FindMember(jsval name) const;
|
||||
inline XPCNativeMember* FindMember(jsid name) const;
|
||||
|
||||
inline JSBool HasAncestor(const nsIID* iid) const;
|
||||
|
||||
|
@ -1686,7 +1686,7 @@ protected:
|
|||
nsIInterfaceInfo* aInfo);
|
||||
|
||||
XPCNativeInterface(); // not implemented
|
||||
XPCNativeInterface(nsIInterfaceInfo* aInfo, jsval aName)
|
||||
XPCNativeInterface(nsIInterfaceInfo* aInfo, jsid aName)
|
||||
: mInfo(aInfo), mName(aName), mMemberCount(0)
|
||||
{MOZ_COUNT_CTOR(XPCNativeInterface);}
|
||||
~XPCNativeInterface() {MOZ_COUNT_DTOR(XPCNativeInterface);}
|
||||
|
@ -1698,7 +1698,7 @@ protected:
|
|||
|
||||
private:
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
jsval mName;
|
||||
jsid mName;
|
||||
PRUint16 mMemberCount;
|
||||
XPCNativeMember mMembers[1]; // always last - object sized for array
|
||||
};
|
||||
|
@ -1769,13 +1769,13 @@ public:
|
|||
|
||||
static void ClearCacheEntryForClassInfo(nsIClassInfo* classInfo);
|
||||
|
||||
inline JSBool FindMember(jsval name, XPCNativeMember** pMember,
|
||||
inline JSBool FindMember(jsid name, XPCNativeMember** pMember,
|
||||
PRUint16* pInterfaceIndex) const;
|
||||
|
||||
inline JSBool FindMember(jsval name, XPCNativeMember** pMember,
|
||||
inline JSBool FindMember(jsid name, XPCNativeMember** pMember,
|
||||
XPCNativeInterface** pInterface) const;
|
||||
|
||||
inline JSBool FindMember(jsval name,
|
||||
inline JSBool FindMember(jsid name,
|
||||
XPCNativeMember** pMember,
|
||||
XPCNativeInterface** pInterface,
|
||||
XPCNativeSet* protoSet,
|
||||
|
@ -1787,7 +1787,7 @@ public:
|
|||
|
||||
inline XPCNativeInterface* FindInterfaceWithIID(const nsIID& iid) const;
|
||||
|
||||
inline XPCNativeInterface* FindNamedInterface(jsval name) const;
|
||||
inline XPCNativeInterface* FindNamedInterface(jsid name) const;
|
||||
|
||||
PRUint16 GetMemberCount() const {return mMemberCount;}
|
||||
PRUint16 GetInterfaceCount() const
|
||||
|
@ -2543,12 +2543,12 @@ public:
|
|||
HandlePossibleNameCaseError(XPCCallContext& ccx,
|
||||
XPCNativeSet* set,
|
||||
XPCNativeInterface* iface,
|
||||
jsval name);
|
||||
jsid name);
|
||||
static void
|
||||
HandlePossibleNameCaseError(JSContext* cx,
|
||||
XPCNativeSet* set,
|
||||
XPCNativeInterface* iface,
|
||||
jsval name);
|
||||
jsid name);
|
||||
|
||||
#define HANDLE_POSSIBLE_NAME_CASE_ERROR(context, set, iface, name) \
|
||||
XPCWrappedNative::HandlePossibleNameCaseError(context, set, iface, name)
|
||||
|
@ -3514,9 +3514,9 @@ public:
|
|||
XPCCallContext* SetCallContext(XPCCallContext* ccx)
|
||||
{XPCCallContext* old = mCallContext; mCallContext = ccx; return old;}
|
||||
|
||||
jsval GetResolveName() const {return mResolveName;}
|
||||
jsval SetResolveName(jsval name)
|
||||
{jsval old = mResolveName; mResolveName = name; return old;}
|
||||
jsid GetResolveName() const {return mResolveName;}
|
||||
jsid SetResolveName(jsid name)
|
||||
{jsid old = mResolveName; mResolveName = name; return old;}
|
||||
|
||||
XPCWrappedNative* GetResolvingWrapper() const {return mResolvingWrapper;}
|
||||
XPCWrappedNative* SetResolvingWrapper(XPCWrappedNative* w)
|
||||
|
@ -3561,7 +3561,7 @@ private:
|
|||
XPCJSContextStack* mJSContextStack;
|
||||
XPCPerThreadData* mNextThread;
|
||||
XPCCallContext* mCallContext;
|
||||
jsval mResolveName;
|
||||
jsid mResolveName;
|
||||
XPCWrappedNative* mResolvingWrapper;
|
||||
|
||||
nsIExceptionManager* mExceptionManager;
|
||||
|
@ -4007,7 +4007,7 @@ private:
|
|||
class NS_STACK_CLASS AutoResolveName
|
||||
{
|
||||
public:
|
||||
AutoResolveName(XPCCallContext& ccx, jsval name
|
||||
AutoResolveName(XPCCallContext& ccx, jsid name
|
||||
MOZILLA_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mTLS(ccx.GetThreadData()),
|
||||
mOld(mTLS->SetResolveName(name)),
|
||||
|
@ -4017,7 +4017,7 @@ public:
|
|||
~AutoResolveName()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
jsval old =
|
||||
jsid old =
|
||||
#endif
|
||||
mTLS->SetResolveName(mOld);
|
||||
NS_ASSERTION(old == mCheck, "Bad Nesting!");
|
||||
|
@ -4025,8 +4025,8 @@ public:
|
|||
|
||||
private:
|
||||
XPCPerThreadData* mTLS;
|
||||
jsval mOld;
|
||||
jsval mCheck;
|
||||
jsid mOld;
|
||||
jsid mCheck;
|
||||
MOZILLA_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
|
@ -4371,7 +4371,7 @@ xpc_EvalInSandbox(JSContext *cx, JSObject *sandbox, const nsAString& source,
|
|||
// Inlined utilities.
|
||||
|
||||
inline JSBool
|
||||
xpc_ForcePropertyResolve(JSContext* cx, JSObject* obj, jsval idval);
|
||||
xpc_ForcePropertyResolve(JSContext* cx, JSObject* obj, jsid id);
|
||||
|
||||
inline jsid
|
||||
GetRTIdByIndex(JSContext *cx, uintN index);
|
||||
|
|
|
@ -140,8 +140,11 @@ PropertyOpForwarder(JSContext *cx, uintN argc, jsval *vp)
|
|||
return JS_FALSE;
|
||||
|
||||
jsval argval = (argc > 0) ? JS_ARGV(cx, vp)[0] : JSVAL_VOID;
|
||||
jsid id;
|
||||
if (!JS_ValueToId(cx, argval, &id))
|
||||
return JS_FALSE;
|
||||
JS_SET_RVAL(cx, vp, argval);
|
||||
return (*popp)(cx, obj, v, vp);
|
||||
return (*popp)(cx, obj, id, vp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -490,7 +493,7 @@ xpc_qsThrow(JSContext *cx, nsresult rv)
|
|||
*/
|
||||
static void
|
||||
GetMemberInfo(JSObject *obj,
|
||||
jsval memberId,
|
||||
jsid memberId,
|
||||
const char **ifaceName,
|
||||
const char **memberName)
|
||||
{
|
||||
|
@ -527,8 +530,8 @@ GetMemberInfo(JSObject *obj,
|
|||
}
|
||||
}
|
||||
|
||||
*memberName = (JSVAL_IS_STRING(memberId)
|
||||
? JS_GetStringBytes(JSVAL_TO_STRING(memberId))
|
||||
*memberName = (JSID_IS_STRING(memberId)
|
||||
? JS_GetStringBytes(JSID_TO_STRING(memberId))
|
||||
: "unknown");
|
||||
}
|
||||
|
||||
|
@ -542,7 +545,7 @@ GetMethodInfo(JSContext *cx,
|
|||
NS_ASSERTION(JS_ObjectIsFunction(cx, funobj),
|
||||
"JSFastNative callee should be Function object");
|
||||
JSString *str = JS_GetFunctionId((JSFunction *) JS_GetPrivate(cx, funobj));
|
||||
jsval methodId = str ? STRING_TO_JSVAL(str) : JSVAL_NULL;
|
||||
jsid methodId = str ? INTERNED_STRING_TO_JSID(str) : JSID_VOID;
|
||||
|
||||
GetMemberInfo(JSVAL_TO_OBJECT(vp[1]), methodId, ifaceName, memberName);
|
||||
}
|
||||
|
@ -596,7 +599,7 @@ ThrowCallFailed(JSContext *cx, nsresult rv,
|
|||
|
||||
JSBool
|
||||
xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv, JSObject *obj,
|
||||
jsval memberId)
|
||||
jsid memberId)
|
||||
{
|
||||
const char *ifaceName, *memberName;
|
||||
GetMemberInfo(obj, memberId, &ifaceName, &memberName);
|
||||
|
@ -669,7 +672,7 @@ xpc_qsThrowBadArgWithDetails(JSContext *cx, nsresult rv, uintN paramnum,
|
|||
|
||||
void
|
||||
xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv,
|
||||
JSObject *obj, jsval propId)
|
||||
JSObject *obj, jsid propId)
|
||||
{
|
||||
const char *ifaceName, *memberName;
|
||||
GetMemberInfo(obj, propId, &ifaceName, &memberName);
|
||||
|
@ -1065,6 +1068,23 @@ xpc_qsStringToJsval(JSContext *cx, const nsAString &str, jsval *rval)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
xpc_qsStringToJsstring(JSContext *cx, const nsAString &str, JSString **rval)
|
||||
{
|
||||
// From the T_DOMSTRING case in XPCConvert::NativeData2JS.
|
||||
if(str.IsVoid())
|
||||
{
|
||||
*rval = nsnull;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
jsval jsstr = XPCStringConvert::ReadableToJSVal(cx, str);
|
||||
if(!jsstr)
|
||||
return JS_FALSE;
|
||||
*rval = JSVAL_TO_STRING(jsstr);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
xpc_qsXPCOMObjectToJsval(XPCLazyCallContext &lccx, nsISupports *p,
|
||||
nsWrapperCache *cache, const nsIID *iid,
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче