зеркало из https://github.com/mozilla/gecko-dev.git
Browser builds
This commit is contained in:
Родитель
89aa00b5d3
Коммит
c9f3b0c32f
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
@ -3695,7 +3699,7 @@ JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp)
|
|||
sprop = sprop->parent;
|
||||
|
||||
if (!sprop) {
|
||||
*idp = JSID_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 = JSID_VOID();
|
||||
*idp = JSID_VOID;
|
||||
} else {
|
||||
*idp = ida->vector[--i];
|
||||
iterobj->setSlot(JSSLOT_ITER_INDEX, Int32Tag(i));
|
||||
|
@ -4754,6 +4758,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)
|
||||
{
|
||||
|
|
|
@ -288,6 +288,19 @@ JSID_TO_STRING(jsid id)
|
|||
return (JSString *)(JSID_BITS(id));
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_StringHasBeenInterned(JSString *str);
|
||||
|
||||
static JS_ALWAYS_INLINE jsid
|
||||
INTERNED_STRING_TO_JSID(JSString *str)
|
||||
{
|
||||
jsid id;
|
||||
JS_ASSERT(JS_StringHasBeenInterned(str));
|
||||
JS_ASSERT(((size_t)str & JSID_TYPE_MASK) == 0);
|
||||
JSID_BITS(id) = (size_t)str;
|
||||
return id;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSID_IS_INT(jsid id)
|
||||
{
|
||||
|
@ -314,8 +327,8 @@ INT_FITS_IN_JSID(int32 i)
|
|||
static JS_ALWAYS_INLINE jsid
|
||||
INT_TO_JSID(int32 i)
|
||||
{
|
||||
JS_ASSERT(INT_FITS_IN_JSID(i));
|
||||
jsid id;
|
||||
JS_ASSERT(INT_FITS_IN_JSID(i));
|
||||
JSID_BITS(id) = ((i << 1) | JSID_INT_TYPE);
|
||||
return id;
|
||||
}
|
||||
|
@ -336,9 +349,9 @@ JSID_TO_OBJECT(jsid id)
|
|||
static JS_ALWAYS_INLINE jsid
|
||||
OBJECT_TO_JSID(JSObject *obj)
|
||||
{
|
||||
jsid id;
|
||||
JS_ASSERT(obj != NULL);
|
||||
JS_ASSERT(((size_t)obj & JSID_TYPE_MASK) == 0);
|
||||
jsid id;
|
||||
JSID_BITS(id) = ((size_t)obj | JSID_OBJECT_TYPE);
|
||||
return id;
|
||||
}
|
||||
|
@ -389,14 +402,31 @@ JSID_IS_VOID(jsid id)
|
|||
return ((size_t)JSID_BITS(id) == JSID_VOID_TYPE);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE jsid
|
||||
JSID_VOID()
|
||||
/* TODO: explain the debug-only use of struct jsid */
|
||||
#ifdef DEBUG
|
||||
extern JS_PUBLIC_DATA(jsid) JSID_VOID;
|
||||
#else
|
||||
# define JSID_VOID ((jsid)JSID_VOID_TYPE)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG) && defined(__cplusplus)
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
jsid id;
|
||||
JSID_BITS(id) = JSID_VOID_TYPE;
|
||||
return id;
|
||||
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. */
|
||||
|
|
|
@ -301,7 +301,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 = JSID_VOID();
|
||||
*idp = JSID_VOID;
|
||||
return JS_TRUE;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -118,18 +118,6 @@ IdToJsval(jsid id)
|
|||
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if JS_BYTES_PER_WORD == 4
|
||||
# define ATOM_HASH(atom) ((JSHashNumber)(atom) >> 2)
|
||||
#elif JS_BYTES_PER_WORD == 8
|
||||
|
|
|
@ -1340,7 +1340,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 {
|
||||
|
|
|
@ -1333,7 +1333,7 @@ BEGIN_CASE(JSOP_ELEMDEC)
|
|||
* Delay fetching of id until we have the object to ensure the proper
|
||||
* evaluation order. See bug 372331.
|
||||
*/
|
||||
id = JSID_VOID();
|
||||
id = JSID_VOID;
|
||||
i = -2;
|
||||
goto fetch_incop_obj;
|
||||
|
||||
|
@ -3433,7 +3433,7 @@ BEGIN_CASE(JSOP_SETTER)
|
|||
}
|
||||
case JSOP_SETELEM:
|
||||
rval = regs.sp[-1];
|
||||
id = JSID_VOID();
|
||||
id = JSID_VOID;
|
||||
i = -2;
|
||||
gs_pop_lval:
|
||||
FETCH_OBJECT(cx, i - 1, obj);
|
||||
|
@ -3454,7 +3454,7 @@ BEGIN_CASE(JSOP_SETTER)
|
|||
|
||||
JS_ASSERT(regs.sp - fp->base() >= 3);
|
||||
rval = regs.sp[-1];
|
||||
id = JSID_VOID();
|
||||
id = JSID_VOID;
|
||||
i = -2;
|
||||
gs_get_lval:
|
||||
{
|
||||
|
|
|
@ -193,9 +193,14 @@ typedef enum JSValueMask16
|
|||
__attribute__((packed))
|
||||
# endif
|
||||
JSValueMask16;
|
||||
|
||||
#else /* defined(__cplusplus) || !defined(_MSC_VER) */
|
||||
// We need this C API for MSVC, because MSVC doesn't allow us to
|
||||
// make a 16-bit enum in C.
|
||||
|
||||
/*
|
||||
* We need this C API for MSVC, because MSVC doesn't allow us to
|
||||
* make a 16-bit enum in C.
|
||||
*/
|
||||
|
||||
typedef uint16 JSValueMask16;
|
||||
|
||||
#define JSVAL_MASK16_NULL ((uint16)0x0001)
|
||||
|
|
|
@ -623,7 +623,7 @@ struct JSScopeProperty {
|
|||
};
|
||||
|
||||
void insertFree(JSScopeProperty *&list) {
|
||||
id = JSID_VOID();
|
||||
id = JSID_VOID;
|
||||
next = list;
|
||||
prevp = &list;
|
||||
if (list)
|
||||
|
|
|
@ -2752,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 = JSID_VOID();
|
||||
*funidp = JSID_VOID;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -2761,7 +2761,7 @@ js_IsFunctionQName(JSContext *cx, JSObject *obj, jsid *funidp)
|
|||
{
|
||||
if (obj->getClass() == &js_QNameClass.base)
|
||||
return IsFunctionQName(cx, obj, funidp);
|
||||
*funidp = JSID_VOID();
|
||||
*funidp = JSID_VOID;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -2819,7 +2819,7 @@ ToXMLName(JSContext *cx, jsval v, jsid *funidp)
|
|||
name = js_NewDependentString(cx, name, 1, name->length() - 1);
|
||||
if (!name)
|
||||
return NULL;
|
||||
*funidp = JSID_VOID();
|
||||
*funidp = JSID_VOID;
|
||||
return ToAttributeName(cx, STRING_TO_JSVAL(name));
|
||||
}
|
||||
|
||||
|
@ -4282,7 +4282,7 @@ PutProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||
}
|
||||
|
||||
/* 10-11. */
|
||||
id = JSID_VOID();
|
||||
id = JSID_VOID;
|
||||
primitiveAssign = !vxml && !IS_STAR(GetLocalName(nameqn));
|
||||
|
||||
/* 12. */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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,12 @@ 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, idAsId, JSRESOLVE_QUALIFIED,
|
||||
&desc)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -416,7 +415,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 +495,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 +526,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 +535,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 +569,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 +645,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 +730,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 +885,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 +895,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 +965,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"
|
||||
|
|
|
@ -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,7 +4053,7 @@ 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();
|
||||
|
@ -4086,12 +4063,12 @@ nsXPCComponents::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
jsid idid;
|
||||
uintN attrs = 0;
|
||||
|
||||
if(id == rt->GetStringJSVal(XPCJSRuntime::IDX_LAST_RESULT))
|
||||
if(id == rt->GetStringID(XPCJSRuntime::IDX_LAST_RESULT))
|
||||
{
|
||||
idid = rt->GetStringID(XPCJSRuntime::IDX_LAST_RESULT);
|
||||
attrs = JSPROP_READONLY;
|
||||
}
|
||||
else if(id == rt->GetStringJSVal(XPCJSRuntime::IDX_RETURN_CODE))
|
||||
else if(id == rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE))
|
||||
idid = rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE);
|
||||
else
|
||||
return NS_OK;
|
||||
|
@ -4107,7 +4084,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 +4093,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 +4115,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 +4129,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);
|
||||
|
|
|
@ -119,6 +119,18 @@ LookupInterfaceOrAncestor(PRUint32 tableSize, const xpc_qsHashEntry *table,
|
|||
return entry;
|
||||
}
|
||||
|
||||
static inline jsid
|
||||
JSValHoldingJSIdToJSId(jsval v)
|
||||
{
|
||||
if (JSVAL_IS_STRING(v))
|
||||
return INTERNED_STRING_TO_JSID(JSVAL_TO_STRING(v));
|
||||
if (JSVAL_IS_INT(v))
|
||||
return INT_TO_JSID(JSVAL_TO_INT(v));
|
||||
if (JSVAL_IS_VOID(v))
|
||||
return JSID_VOID;
|
||||
return OBJECT_TO_JSID(JSVAL_TO_OBJECT(v));
|
||||
}
|
||||
|
||||
static JSBool
|
||||
PropertyOpForwarder(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
|
@ -141,7 +153,8 @@ PropertyOpForwarder(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
jsval argval = (argc > 0) ? JS_ARGV(cx, vp)[0] : JSVAL_VOID;
|
||||
JS_SET_RVAL(cx, vp, argval);
|
||||
return (*popp)(cx, obj, v, vp);
|
||||
jsid id = JSValHoldingJSIdToJSId(argval);
|
||||
return (*popp)(cx, obj, id, vp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -490,7 +503,7 @@ xpc_qsThrow(JSContext *cx, nsresult rv)
|
|||
*/
|
||||
static void
|
||||
GetMemberInfo(JSObject *obj,
|
||||
jsval memberId,
|
||||
jsid memberId,
|
||||
const char **ifaceName,
|
||||
const char **memberName)
|
||||
{
|
||||
|
@ -527,8 +540,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 +555,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 +609,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 +682,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);
|
||||
|
|
|
@ -100,7 +100,7 @@ xpc_qsThrow(JSContext *cx, nsresult rv);
|
|||
*/
|
||||
JSBool
|
||||
xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv,
|
||||
JSObject *obj, jsval memberId);
|
||||
JSObject *obj, jsid memberId);
|
||||
|
||||
/**
|
||||
* Fail after an XPCOM method returned rv.
|
||||
|
@ -140,7 +140,7 @@ xpc_qsThrowBadArgWithDetails(JSContext *cx, nsresult rv, uintN paramnum,
|
|||
*/
|
||||
void
|
||||
xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv, JSObject *obj,
|
||||
jsval propId);
|
||||
jsid propId);
|
||||
|
||||
|
||||
/* Functions for converting values between COM and JS. */
|
||||
|
|
|
@ -69,7 +69,7 @@ NS_IMPL_THREADSAFE_RELEASE(BackstagePass)
|
|||
NS_IMETHODIMP
|
||||
BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * obj,
|
||||
jsval id, PRUint32 flags,
|
||||
jsid id, PRUint32 flags,
|
||||
JSObject * *objp, PRBool *_retval)
|
||||
{
|
||||
JSBool resolved;
|
||||
|
|
|
@ -189,7 +189,7 @@ XPCJSContextStack::DEBUG_StackHasJSContext(JSContext* aJSContext)
|
|||
#endif
|
||||
|
||||
static JSBool
|
||||
SafeGlobalResolve(JSContext *cx, JSObject *obj, jsval id)
|
||||
SafeGlobalResolve(JSContext *cx, JSObject *obj, jsid id)
|
||||
{
|
||||
JSBool resolved;
|
||||
return JS_ResolveStandardClass(cx, obj, id, &resolved);
|
||||
|
@ -331,7 +331,7 @@ XPCPerThreadData::XPCPerThreadData()
|
|||
: mJSContextStack(new XPCJSContextStack()),
|
||||
mNextThread(nsnull),
|
||||
mCallContext(nsnull),
|
||||
mResolveName(0),
|
||||
mResolveName(JSID_VOID),
|
||||
mResolvingWrapper(nsnull),
|
||||
mExceptionManager(nsnull),
|
||||
mException(nsnull),
|
||||
|
|
|
@ -3043,7 +3043,7 @@ NS_IMETHODIMP XPCWrappedNative::GetXPConnect(nsIXPConnect * *aXPConnect)
|
|||
}
|
||||
|
||||
/* XPCNativeInterface FindInterfaceWithMember (in jsval name); */
|
||||
NS_IMETHODIMP XPCWrappedNative::FindInterfaceWithMember(jsval name, nsIInterfaceInfo * *_retval)
|
||||
NS_IMETHODIMP XPCWrappedNative::FindInterfaceWithMember(jsid name, nsIInterfaceInfo * *_retval)
|
||||
{
|
||||
XPCNativeInterface* iface;
|
||||
XPCNativeMember* member;
|
||||
|
@ -3060,7 +3060,7 @@ NS_IMETHODIMP XPCWrappedNative::FindInterfaceWithMember(jsval name, nsIInterface
|
|||
}
|
||||
|
||||
/* XPCNativeInterface FindInterfaceWithName (in jsval name); */
|
||||
NS_IMETHODIMP XPCWrappedNative::FindInterfaceWithName(jsval name, nsIInterfaceInfo * *_retval)
|
||||
NS_IMETHODIMP XPCWrappedNative::FindInterfaceWithName(jsid name, nsIInterfaceInfo * *_retval)
|
||||
{
|
||||
XPCNativeInterface* iface = GetSet()->FindNamedInterface(name);
|
||||
if(iface)
|
||||
|
@ -3256,7 +3256,7 @@ void
|
|||
XPCWrappedNative::HandlePossibleNameCaseError(JSContext* cx,
|
||||
XPCNativeSet* set,
|
||||
XPCNativeInterface* iface,
|
||||
jsval name)
|
||||
jsid name)
|
||||
{
|
||||
XPCCallContext ccx(JS_CALLER, cx);
|
||||
HandlePossibleNameCaseError(ccx, set, iface, name);
|
||||
|
@ -3267,7 +3267,7 @@ void
|
|||
XPCWrappedNative::HandlePossibleNameCaseError(XPCCallContext& ccx,
|
||||
XPCNativeSet* set,
|
||||
XPCNativeInterface* iface,
|
||||
jsval name)
|
||||
jsid name)
|
||||
{
|
||||
if(!ccx.IsValid())
|
||||
return;
|
||||
|
@ -3280,8 +3280,8 @@ XPCWrappedNative::HandlePossibleNameCaseError(XPCCallContext& ccx,
|
|||
XPCNativeInterface* localIface;
|
||||
|
||||
/* PRUnichar->char->PRUnichar hack is to avoid pulling in i18n code. */
|
||||
if(JSVAL_IS_STRING(name) &&
|
||||
nsnull != (oldJSStr = JSVAL_TO_STRING(name)) &&
|
||||
if(JSID_IS_STRING(name) &&
|
||||
nsnull != (oldJSStr = JSID_TO_STRING(name)) &&
|
||||
nsnull != (oldStr = (PRUnichar*) JS_GetStringChars(oldJSStr)) &&
|
||||
oldStr[0] != 0 &&
|
||||
oldStr[0] >> 8 == 0 &&
|
||||
|
@ -3289,11 +3289,14 @@ XPCWrappedNative::HandlePossibleNameCaseError(XPCCallContext& ccx,
|
|||
nsnull != (newStr = nsCRT::strdup(oldStr)))
|
||||
{
|
||||
newStr[0] = (PRUnichar) nsCRT::ToLower((char)newStr[0]);
|
||||
newJSStr = JS_NewUCStringCopyZ(ccx, (const jschar*)newStr);
|
||||
newJSStr = JS_InternUCString(ccx, (const jschar*)newStr);
|
||||
nsCRT::free(newStr);
|
||||
if(newJSStr && (set ?
|
||||
set->FindMember(STRING_TO_JSVAL(newJSStr), &member, &localIface) :
|
||||
NS_PTR_TO_INT32(iface->FindMember(STRING_TO_JSVAL(newJSStr)))))
|
||||
if (!newJSStr)
|
||||
return;
|
||||
|
||||
jsid id = INTERNED_STRING_TO_JSID(newJSStr);
|
||||
if(set ? set->FindMember(id, &member, &localIface)
|
||||
: NS_PTR_TO_INT32(iface->FindMember(id)))
|
||||
{
|
||||
// found it!
|
||||
const char* ifaceName = set ?
|
||||
|
|
|
@ -368,8 +368,8 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
|
|||
PRUint16 realTotalCount = 0;
|
||||
XPCNativeMember* cur;
|
||||
JSString* str;
|
||||
jsval name;
|
||||
jsval interfaceName;
|
||||
jsid name;
|
||||
jsid interfaceName;
|
||||
|
||||
// XXX Investigate lazy init? This is a problem given the
|
||||
// 'placement new' scheme - we need to at least know how big to make
|
||||
|
@ -433,7 +433,7 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
|
|||
failed = JS_TRUE;
|
||||
break;
|
||||
}
|
||||
name = STRING_TO_JSVAL(str);
|
||||
name = INTERNED_STRING_TO_JSID(str);
|
||||
|
||||
if(info->IsSetter())
|
||||
{
|
||||
|
@ -477,7 +477,7 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
|
|||
failed = JS_TRUE;
|
||||
break;
|
||||
}
|
||||
name = STRING_TO_JSVAL(str);
|
||||
name = INTERNED_STRING_TO_JSID(str);
|
||||
|
||||
// XXX need better way to find dups
|
||||
//NS_ASSERTION(!LookupMemberByID(name),"duplicate method/constant name");
|
||||
|
@ -496,7 +496,7 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
|
|||
{
|
||||
failed = JS_TRUE;
|
||||
}
|
||||
interfaceName = STRING_TO_JSVAL(str);
|
||||
interfaceName = INTERNED_STRING_TO_JSID(str);
|
||||
}
|
||||
|
||||
if(!failed)
|
||||
|
@ -538,7 +538,7 @@ const char*
|
|||
XPCNativeInterface::GetMemberName(XPCCallContext& ccx,
|
||||
const XPCNativeMember* member) const
|
||||
{
|
||||
return JS_GetStringBytes(JSVAL_TO_STRING(member->GetName()));
|
||||
return JS_GetStringBytes(JSID_TO_STRING(member->GetName()));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -73,27 +73,6 @@ static JSBool Throw(uintN errNum, JSContext* cx)
|
|||
return Throw(NS_ERROR_XPC_HAS_BEEN_SHUTDOWN, cx); \
|
||||
PR_END_MACRO
|
||||
|
||||
// We rely on the engine only giving us jsval ids that are actually the
|
||||
// self-same jsvals that are in the atom table (that is, if the id represents
|
||||
// a string). So, we assert by converting the jsval to an id and then back
|
||||
// to a jsval and comparing pointers. If the engine ever breaks this promise
|
||||
// then we will scream.
|
||||
#ifdef DEBUG
|
||||
#define CHECK_IDVAL(cx, idval) \
|
||||
PR_BEGIN_MACRO \
|
||||
if(JSVAL_IS_STRING(idval)) \
|
||||
{ \
|
||||
jsid d_id; \
|
||||
jsval d_val; \
|
||||
NS_ASSERTION(JS_ValueToId(cx, idval, &d_id), "JS_ValueToId failed!");\
|
||||
NS_ASSERTION(JS_IdToValue(cx, d_id, &d_val), "JS_IdToValue failed!");\
|
||||
NS_ASSERTION(d_val == idval, "id differs from id in atom table!"); \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
#else
|
||||
#define CHECK_IDVAL(cx, idval) ((void)0)
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static JSBool
|
||||
|
@ -162,7 +141,7 @@ XPC_WN_Shared_ToString(JSContext *cx, JSObject *obj,
|
|||
}
|
||||
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
ccx.SetName(ccx.GetRuntime()->GetStringJSVal(XPCJSRuntime::IDX_TO_STRING));
|
||||
ccx.SetName(ccx.GetRuntime()->GetStringID(XPCJSRuntime::IDX_TO_STRING));
|
||||
ccx.SetArgsAndResultPtr(argc, argv, vp);
|
||||
return ToStringGuts(ccx);
|
||||
}
|
||||
|
@ -257,8 +236,8 @@ XPC_WN_DoubleWrappedGetter(JSContext *cx, JSObject *obj,
|
|||
|
||||
if(iface)
|
||||
{
|
||||
jsval idval = ccx.GetRuntime()->
|
||||
GetStringJSVal(XPCJSRuntime::IDX_WRAPPED_JSOBJECT);
|
||||
jsid id = ccx.GetRuntime()->
|
||||
GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT);
|
||||
|
||||
ccx.SetCallInfo(iface, iface->GetMemberAt(1), JS_FALSE);
|
||||
if(NS_FAILED(sm->
|
||||
|
@ -266,7 +245,7 @@ XPC_WN_DoubleWrappedGetter(JSContext *cx, JSObject *obj,
|
|||
&ccx, ccx,
|
||||
ccx.GetFlattenedJSObject(),
|
||||
wrapper->GetIdentityObject(),
|
||||
wrapper->GetClassInfo(), idval,
|
||||
wrapper->GetClassInfo(), id,
|
||||
wrapper->GetSecurityInfoAddr())))
|
||||
{
|
||||
// The SecurityManager should have set an exception.
|
||||
|
@ -290,7 +269,7 @@ XPC_WN_DoubleWrappedGetter(JSContext *cx, JSObject *obj,
|
|||
|
||||
static JSBool
|
||||
DefinePropertyIfFound(XPCCallContext& ccx,
|
||||
JSObject *obj, jsval idval,
|
||||
JSObject *obj, jsid id,
|
||||
XPCNativeSet* set,
|
||||
XPCNativeInterface* iface,
|
||||
XPCNativeMember* member,
|
||||
|
@ -305,33 +284,32 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
|||
XPCJSRuntime* rt = ccx.GetRuntime();
|
||||
JSBool found;
|
||||
const char* name;
|
||||
jsid id;
|
||||
|
||||
if(set)
|
||||
{
|
||||
if(iface)
|
||||
found = JS_TRUE;
|
||||
else
|
||||
found = set->FindMember(idval, &member, &iface);
|
||||
found = set->FindMember(id, &member, &iface);
|
||||
}
|
||||
else
|
||||
found = (nsnull != (member = iface->FindMember(idval)));
|
||||
found = (nsnull != (member = iface->FindMember(id)));
|
||||
|
||||
if(!found)
|
||||
{
|
||||
HANDLE_POSSIBLE_NAME_CASE_ERROR(ccx, set, iface, idval);
|
||||
HANDLE_POSSIBLE_NAME_CASE_ERROR(ccx, set, iface, id);
|
||||
|
||||
if(reflectToStringAndToSource)
|
||||
{
|
||||
JSNative call;
|
||||
|
||||
if(idval == rt->GetStringJSVal(XPCJSRuntime::IDX_TO_STRING))
|
||||
if(id == rt->GetStringID(XPCJSRuntime::IDX_TO_STRING))
|
||||
{
|
||||
call = XPC_WN_Shared_ToString;
|
||||
name = rt->GetStringName(XPCJSRuntime::IDX_TO_STRING);
|
||||
id = rt->GetStringID(XPCJSRuntime::IDX_TO_STRING);
|
||||
}
|
||||
else if(idval == rt->GetStringJSVal(XPCJSRuntime::IDX_TO_SOURCE))
|
||||
else if(id == rt->GetStringID(XPCJSRuntime::IDX_TO_SOURCE))
|
||||
{
|
||||
call = XPC_WN_Shared_ToSource;
|
||||
name = rt->GetStringName(XPCJSRuntime::IDX_TO_SOURCE);
|
||||
|
@ -350,7 +328,7 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
AutoResolveName arn(ccx, idval);
|
||||
AutoResolveName arn(ccx, id);
|
||||
if(resolved)
|
||||
*resolved = JS_TRUE;
|
||||
return JS_DefinePropertyById(ccx, obj, id,
|
||||
|
@ -370,19 +348,18 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
|||
XPCWrappedNativeTearOff* to;
|
||||
JSObject* jso;
|
||||
|
||||
if(JSVAL_IS_STRING(idval) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSVAL_TO_STRING(idval))) &&
|
||||
if(JSID_IS_STRING(id) &&
|
||||
nsnull != (name = JS_GetStringBytes(JSID_TO_STRING(id))) &&
|
||||
(iface2 = XPCNativeInterface::GetNewOrUsed(ccx, name), iface2) &&
|
||||
nsnull != (to = wrapperToReflectInterfaceNames->
|
||||
FindTearOff(ccx, iface2, JS_TRUE)) &&
|
||||
nsnull != (jso = to->GetJSObject()))
|
||||
|
||||
{
|
||||
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(jso),
|
||||
return JS_DefinePropertyById(ccx, obj, id, OBJECT_TO_JSVAL(jso),
|
||||
nsnull, nsnull,
|
||||
propFlags & ~JSPROP_ENUMERATE);
|
||||
}
|
||||
|
@ -390,7 +367,7 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
|||
|
||||
// This *might* be a double wrapped JSObject
|
||||
if(wrapperToReflectDoubleWrap &&
|
||||
idval == rt->GetStringJSVal(XPCJSRuntime::IDX_WRAPPED_JSOBJECT) &&
|
||||
id == rt->GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT) &&
|
||||
GetDoubleWrappedJSObject(ccx, wrapperToReflectDoubleWrap))
|
||||
{
|
||||
// We build and add a getter function.
|
||||
|
@ -414,7 +391,7 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
|||
propFlags |= JSPROP_GETTER;
|
||||
propFlags &= ~JSPROP_ENUMERATE;
|
||||
|
||||
AutoResolveName arn(ccx, idval);
|
||||
AutoResolveName arn(ccx, id);
|
||||
if(resolved)
|
||||
*resolved = JS_TRUE;
|
||||
return JS_DefinePropertyById(ccx, obj, id, JSVAL_VOID,
|
||||
|
@ -427,7 +404,7 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
|||
// Check to see if there's an IDispatch tearoff
|
||||
if(wrapperToReflectInterfaceNames &&
|
||||
XPCIDispatchExtension::DefineProperty(ccx, obj,
|
||||
idval, wrapperToReflectInterfaceNames, propFlags, resolved))
|
||||
id, wrapperToReflectInterfaceNames, propFlags, resolved))
|
||||
return JS_TRUE;
|
||||
#endif
|
||||
|
||||
|
@ -449,11 +426,10 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
|||
if(!jso)
|
||||
return JS_FALSE;
|
||||
|
||||
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(jso),
|
||||
return JS_DefinePropertyById(ccx, obj, id, OBJECT_TO_JSVAL(jso),
|
||||
nsnull, nsnull,
|
||||
propFlags & ~JSPROP_ENUMERATE);
|
||||
}
|
||||
|
@ -465,20 +441,19 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
|||
if(member->IsConstant())
|
||||
{
|
||||
jsval val;
|
||||
AutoResolveName arn(ccx, idval);
|
||||
AutoResolveName arn(ccx, id);
|
||||
if(resolved)
|
||||
*resolved = JS_TRUE;
|
||||
return member->GetConstantValue(ccx, iface, &val) &&
|
||||
JS_ValueToId(ccx, idval, &id) &&
|
||||
JS_DefinePropertyById(ccx, obj, id, val, nsnull, nsnull,
|
||||
propFlags);
|
||||
}
|
||||
|
||||
if(idval == rt->GetStringJSVal(XPCJSRuntime::IDX_TO_STRING) ||
|
||||
idval == rt->GetStringJSVal(XPCJSRuntime::IDX_TO_SOURCE) ||
|
||||
if(id == rt->GetStringID(XPCJSRuntime::IDX_TO_STRING) ||
|
||||
id == rt->GetStringID(XPCJSRuntime::IDX_TO_SOURCE) ||
|
||||
(scriptableInfo &&
|
||||
scriptableInfo->GetFlags().DontEnumQueryInterface() &&
|
||||
idval == rt->GetStringJSVal(XPCJSRuntime::IDX_QUERY_INTERFACE)))
|
||||
id == rt->GetStringID(XPCJSRuntime::IDX_QUERY_INTERFACE)))
|
||||
propFlags &= ~JSPROP_ENUMERATE;
|
||||
|
||||
jsval funval;
|
||||
|
@ -498,11 +473,10 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
|||
|
||||
if(member->IsMethod())
|
||||
{
|
||||
AutoResolveName arn(ccx, idval);
|
||||
AutoResolveName arn(ccx, id);
|
||||
if(resolved)
|
||||
*resolved = JS_TRUE;
|
||||
return JS_ValueToId(ccx, idval, &id) &&
|
||||
JS_DefinePropertyById(ccx, obj, id, funval, nsnull, nsnull,
|
||||
return JS_DefinePropertyById(ccx, obj, id, funval, nsnull, nsnull,
|
||||
propFlags);
|
||||
}
|
||||
|
||||
|
@ -525,12 +499,11 @@ DefinePropertyIfFound(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);
|
||||
}
|
||||
|
||||
|
@ -538,25 +511,22 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
|||
/***************************************************************************/
|
||||
|
||||
static JSBool
|
||||
XPC_WN_OnlyIWrite_PropertyStub(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
||||
XPC_WN_OnlyIWrite_PropertyStub(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
CHECK_IDVAL(cx, idval);
|
||||
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, nsnull, idval);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, nsnull, id);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
||||
// Allow only XPConnect to add the property
|
||||
if(ccx.GetResolveName() == idval)
|
||||
if(ccx.GetResolveName() == id)
|
||||
return JS_TRUE;
|
||||
|
||||
return Throw(NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN, cx);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_WN_CannotModifyPropertyStub(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
||||
XPC_WN_CannotModifyPropertyStub(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
CHECK_IDVAL(cx, idval);
|
||||
return Throw(NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN, cx);
|
||||
}
|
||||
|
||||
|
@ -599,7 +569,7 @@ XPC_WN_Shared_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
|||
case JSTYPE_VOID:
|
||||
case JSTYPE_STRING:
|
||||
{
|
||||
ccx.SetName(ccx.GetRuntime()->GetStringJSVal(XPCJSRuntime::IDX_TO_STRING));
|
||||
ccx.SetName(ccx.GetRuntime()->GetStringID(XPCJSRuntime::IDX_TO_STRING));
|
||||
ccx.SetArgsAndResultPtr(0, nsnull, vp);
|
||||
|
||||
XPCNativeMember* member = ccx.GetMember();
|
||||
|
@ -663,7 +633,7 @@ XPC_WN_Shared_Enumerate(JSContext *cx, JSObject *obj)
|
|||
for(PRUint16 k = 0; k < member_count; k++)
|
||||
{
|
||||
XPCNativeMember* member = iface->GetMemberAt(k);
|
||||
jsval name = member->GetName();
|
||||
jsid name = member->GetName();
|
||||
|
||||
// Skip if this member is going to come from the proto.
|
||||
PRUint16 index;
|
||||
|
@ -780,12 +750,10 @@ XPC_WN_Shared_Trace(JSTracer *trc, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_WN_NoHelper_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
||||
XPC_WN_NoHelper_Resolve(JSContext *cx, JSObject *obj, jsid id)
|
||||
{
|
||||
CHECK_IDVAL(cx, idval);
|
||||
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, nsnull, idval);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, nsnull, id);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
||||
|
@ -797,7 +765,7 @@ XPC_WN_NoHelper_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
|||
if(ccx.GetInterface() && !ccx.GetStaticMemberIsLocal())
|
||||
return JS_TRUE;
|
||||
|
||||
return DefinePropertyIfFound(ccx, obj, idval,
|
||||
return DefinePropertyIfFound(ccx, obj, id,
|
||||
set, nsnull, nsnull, wrapper->GetScope(),
|
||||
JS_TRUE, wrapper, wrapper, nsnull,
|
||||
JSPROP_ENUMERATE |
|
||||
|
@ -829,8 +797,9 @@ XPC_GetIdentityObject(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
JSBool
|
||||
XPC_WN_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
XPC_WN_Equality(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp)
|
||||
{
|
||||
jsval v = *valp;
|
||||
*bp = JS_FALSE;
|
||||
|
||||
JSObject *obj2;
|
||||
|
@ -993,10 +962,8 @@ JSExtendedClass XPC_WN_NoHelper_JSClass = {
|
|||
/***************************************************************************/
|
||||
|
||||
static JSBool
|
||||
XPC_WN_MaybeResolvingPropertyStub(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
||||
XPC_WN_MaybeResolvingPropertyStub(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
CHECK_IDVAL(cx, idval);
|
||||
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
|
@ -1038,34 +1005,34 @@ XPC_WN_MaybeResolvingPropertyStub(JSContext *cx, JSObject *obj, jsval idval, jsv
|
|||
return retval;
|
||||
|
||||
static JSBool
|
||||
XPC_WN_Helper_AddProperty(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
||||
XPC_WN_Helper_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
PRE_HELPER_STUB
|
||||
AddProperty(wrapper, cx, obj, idval, vp, &retval);
|
||||
AddProperty(wrapper, cx, obj, id, vp, &retval);
|
||||
POST_HELPER_STUB
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_WN_Helper_DelProperty(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
||||
XPC_WN_Helper_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
PRE_HELPER_STUB
|
||||
DelProperty(wrapper, cx, obj, idval, vp, &retval);
|
||||
DelProperty(wrapper, cx, obj, id, vp, &retval);
|
||||
POST_HELPER_STUB
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_WN_Helper_GetProperty(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
||||
XPC_WN_Helper_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
PRE_HELPER_STUB
|
||||
GetProperty(wrapper, cx, obj, idval, vp, &retval);
|
||||
GetProperty(wrapper, cx, obj, id, vp, &retval);
|
||||
POST_HELPER_STUB
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_WN_Helper_SetProperty(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
||||
XPC_WN_Helper_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
PRE_HELPER_STUB
|
||||
SetProperty(wrapper, cx, obj, idval, vp, &retval);
|
||||
SetProperty(wrapper, cx, obj, id, vp, &retval);
|
||||
POST_HELPER_STUB
|
||||
}
|
||||
|
||||
|
@ -1079,12 +1046,11 @@ XPC_WN_Helper_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_WN_Helper_CheckAccess(JSContext *cx, JSObject *obj, jsval idval,
|
||||
XPC_WN_Helper_CheckAccess(JSContext *cx, JSObject *obj, jsid id,
|
||||
JSAccessMode mode, jsval *vp)
|
||||
{
|
||||
CHECK_IDVAL(cx, idval);
|
||||
PRE_HELPER_STUB
|
||||
CheckAccess(wrapper, cx, obj, idval, mode, vp, &retval);
|
||||
CheckAccess(wrapper, cx, obj, id, mode, vp, &retval);
|
||||
POST_HELPER_STUB
|
||||
}
|
||||
|
||||
|
@ -1119,11 +1085,11 @@ XPC_WN_Helper_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_WN_Helper_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
XPC_WN_Helper_HasInstance(JSContext *cx, JSObject *obj, const jsval *valp, JSBool *bp)
|
||||
{
|
||||
SLIM_LOG_WILL_MORPH(cx, obj);
|
||||
PRE_HELPER_STUB_NO_SLIM
|
||||
HasInstance(wrapper, cx, obj, v, bp, &retval);
|
||||
HasInstance(wrapper, cx, obj, *valp, bp, &retval);
|
||||
POST_HELPER_STUB
|
||||
}
|
||||
|
||||
|
@ -1172,11 +1138,9 @@ XPC_WN_Helper_Trace(JSTracer *trc, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_WN_Helper_NewResolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
||||
XPC_WN_Helper_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp)
|
||||
{
|
||||
CHECK_IDVAL(cx, idval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
JSBool retval = JS_TRUE;
|
||||
JSObject* obj2FromScriptable = nsnull;
|
||||
|
@ -1191,7 +1155,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
|||
!si->GetFlags().AllowPropModsDuringResolve(),
|
||||
"We don't support these flags for slim wrappers!");
|
||||
|
||||
rv = si->GetCallback()->NewResolve(nsnull, cx, obj, idval, flags,
|
||||
rv = si->GetCallback()->NewResolve(nsnull, cx, obj, id, flags,
|
||||
&obj2FromScriptable, &retval);
|
||||
if(NS_FAILED(rv))
|
||||
return Throw(rv, cx);
|
||||
|
@ -1206,7 +1170,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
|||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
||||
jsval old = ccx.SetResolveName(idval);
|
||||
jsid old = ccx.SetResolveName(id);
|
||||
|
||||
XPCNativeScriptableInfo* si = wrapper->GetScriptableInfo();
|
||||
if(si && si->GetFlags().WantNewResolve())
|
||||
|
@ -1217,7 +1181,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
|||
if(allowPropMods)
|
||||
oldResolvingWrapper = ccx.SetResolvingWrapper(wrapper);
|
||||
|
||||
rv = si->GetCallback()->NewResolve(wrapper, cx, obj, idval, flags,
|
||||
rv = si->GetCallback()->NewResolve(wrapper, cx, obj, id, flags,
|
||||
&obj2FromScriptable, &retval);
|
||||
|
||||
if(allowPropMods)
|
||||
|
@ -1225,7 +1189,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
|||
}
|
||||
|
||||
old = ccx.SetResolveName(old);
|
||||
NS_ASSERTION(old == idval, "bad nest");
|
||||
NS_ASSERTION(old == id, "bad nest");
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
|
@ -1248,7 +1212,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
|||
XPCNativeInterface* iface;
|
||||
JSBool IsLocal;
|
||||
|
||||
if(set->FindMember(idval, &member, &iface, protoSet, &IsLocal) &&
|
||||
if(set->FindMember(id, &member, &iface, protoSet, &IsLocal) &&
|
||||
IsLocal)
|
||||
{
|
||||
XPCWrappedNative* oldResolvingWrapper;
|
||||
|
@ -1265,7 +1229,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
|||
|
||||
JSBool resolved;
|
||||
oldResolvingWrapper = ccx.SetResolvingWrapper(wrapper);
|
||||
retval = DefinePropertyIfFound(ccx, obj, idval,
|
||||
retval = DefinePropertyIfFound(ccx, obj, id,
|
||||
set, iface, member,
|
||||
wrapper->GetScope(),
|
||||
JS_FALSE,
|
||||
|
@ -1776,7 +1740,7 @@ XPC_WN_CallMethod(JSContext *cx, JSObject *obj,
|
|||
if(IS_SLIM_WRAPPER(obj) && !MorphSlimWrapper(cx, obj))
|
||||
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
|
||||
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, funobj, 0, argc, argv, vp);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, funobj, JSID_VOID, argc, argv, vp);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
||||
|
@ -1909,10 +1873,8 @@ XPC_WN_Shared_Proto_Trace(JSTracer *trc, JSObject *obj)
|
|||
/*****************************************************/
|
||||
|
||||
static JSBool
|
||||
XPC_WN_ModsAllowed_Proto_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
||||
XPC_WN_ModsAllowed_Proto_Resolve(JSContext *cx, JSObject *obj, jsid id)
|
||||
{
|
||||
CHECK_IDVAL(cx, idval);
|
||||
|
||||
NS_ASSERTION(
|
||||
JS_InstanceOf(cx, obj, &XPC_WN_ModsAllowed_WithCall_Proto_JSClass,
|
||||
nsnull) ||
|
||||
|
@ -1933,7 +1895,7 @@ XPC_WN_ModsAllowed_Proto_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
|||
uintN enumFlag = (si && si->GetFlags().DontEnumStaticProps()) ?
|
||||
0 : JSPROP_ENUMERATE;
|
||||
|
||||
return DefinePropertyIfFound(ccx, obj, idval,
|
||||
return DefinePropertyIfFound(ccx, obj, id,
|
||||
self->GetSet(), nsnull, nsnull,
|
||||
self->GetScope(),
|
||||
JS_TRUE, nsnull, nsnull, si,
|
||||
|
@ -2022,10 +1984,8 @@ JSClass XPC_WN_ModsAllowed_NoCall_Proto_JSClass = {
|
|||
/***************************************************************************/
|
||||
|
||||
static JSBool
|
||||
XPC_WN_OnlyIWrite_Proto_PropertyStub(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
||||
XPC_WN_OnlyIWrite_Proto_PropertyStub(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
CHECK_IDVAL(cx, idval);
|
||||
|
||||
NS_ASSERTION(
|
||||
JS_InstanceOf(cx, obj, &XPC_WN_NoMods_WithCall_Proto_JSClass, nsnull) ||
|
||||
JS_InstanceOf(cx, obj, &XPC_WN_NoMods_NoCall_Proto_JSClass, nsnull),
|
||||
|
@ -2041,17 +2001,15 @@ XPC_WN_OnlyIWrite_Proto_PropertyStub(JSContext *cx, JSObject *obj, jsval idval,
|
|||
return JS_FALSE;
|
||||
|
||||
// Allow XPConnect to add the property only
|
||||
if(ccx.GetResolveName() == idval)
|
||||
if(ccx.GetResolveName() == id)
|
||||
return JS_TRUE;
|
||||
|
||||
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
XPC_WN_NoMods_Proto_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
||||
XPC_WN_NoMods_Proto_Resolve(JSContext *cx, JSObject *obj, jsid id)
|
||||
{
|
||||
CHECK_IDVAL(cx, idval);
|
||||
|
||||
NS_ASSERTION(
|
||||
JS_InstanceOf(cx, obj, &XPC_WN_NoMods_WithCall_Proto_JSClass, nsnull) ||
|
||||
JS_InstanceOf(cx, obj, &XPC_WN_NoMods_NoCall_Proto_JSClass, nsnull),
|
||||
|
@ -2070,7 +2028,7 @@ XPC_WN_NoMods_Proto_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
|||
uintN enumFlag = (si && si->GetFlags().DontEnumStaticProps()) ?
|
||||
0 : JSPROP_ENUMERATE;
|
||||
|
||||
return DefinePropertyIfFound(ccx, obj, idval,
|
||||
return DefinePropertyIfFound(ccx, obj, id,
|
||||
self->GetSet(), nsnull, nsnull,
|
||||
self->GetScope(),
|
||||
JS_TRUE, nsnull, nsnull, si,
|
||||
|
@ -2156,10 +2114,8 @@ XPC_WN_TearOff_Enumerate(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
XPC_WN_TearOff_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
||||
XPC_WN_TearOff_Resolve(JSContext *cx, JSObject *obj, jsid id)
|
||||
{
|
||||
CHECK_IDVAL(cx, idval);
|
||||
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
|
@ -2171,7 +2127,7 @@ XPC_WN_TearOff_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
|||
if(!to || nsnull == (iface = to->GetInterface()))
|
||||
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
|
||||
|
||||
return DefinePropertyIfFound(ccx, obj, idval, nsnull, iface, nsnull,
|
||||
return DefinePropertyIfFound(ccx, obj, id, nsnull, iface, nsnull,
|
||||
wrapper->GetScope(),
|
||||
JS_TRUE, nsnull, nsnull, nsnull,
|
||||
JSPROP_READONLY |
|
||||
|
|
|
@ -283,9 +283,9 @@ MySecMan::CanGetService(JSContext * aJSContext, const nsCID & aCID)
|
|||
}
|
||||
}
|
||||
|
||||
/* void CanAccess (in PRUint32 aAction, in nsIXPCNativeCallContext aCallContext, in JSContextPtr aJSContext, in JSObjectPtr aJSObject, in nsISupports aObj, in nsIClassInfo aClassInfo, in jsval aName, inout voidPtr aPolicy); */
|
||||
/* void CanAccess (in PRUint32 aAction, in nsIXPCNativeCallContext aCallContext, in JSContextPtr aJSContext, in JSObjectPtr aJSObject, in nsISupports aObj, in nsIClassInfo aClassInfo, in jsid aName, inout voidPtr aPolicy); */
|
||||
NS_IMETHODIMP
|
||||
MySecMan::CanAccess(PRUint32 aAction, nsAXPCNativeCallContext *aCallContext, JSContext * aJSContext, JSObject * aJSObject, nsISupports *aObj, nsIClassInfo *aClassInfo, jsval aName, void * *aPolicy)
|
||||
MySecMan::CanAccess(PRUint32 aAction, nsAXPCNativeCallContext *aCallContext, JSContext * aJSContext, JSObject * aJSObject, nsISupports *aObj, nsIClassInfo *aClassInfo, jsid aName, void * *aPolicy)
|
||||
{
|
||||
switch(mMode)
|
||||
{
|
||||
|
|
|
@ -145,23 +145,23 @@ NPClass nsJSObjWrapper::sJSObjWrapperNPClass =
|
|||
};
|
||||
|
||||
static JSBool
|
||||
NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
NPObjWrapper_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
NPObjWrapper_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
NPObjWrapper_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
||||
jsval *statep, jsid *idp);
|
||||
|
||||
static JSBool
|
||||
NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp);
|
||||
|
||||
static JSBool
|
||||
|
@ -180,7 +180,7 @@ NPObjWrapper_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
|
||||
static JSBool
|
||||
CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject *npobj,
|
||||
jsval id, NPVariant* getPropertyResult, jsval *vp);
|
||||
jsid id, NPVariant* getPropertyResult, jsval *vp);
|
||||
|
||||
static JSClass sNPObjectJSWrapperClass =
|
||||
{
|
||||
|
@ -1185,7 +1185,7 @@ GetNPObject(JSContext *cx, JSObject *obj)
|
|||
// Does not actually add a property because this is always followed by a
|
||||
// SetProperty call.
|
||||
static JSBool
|
||||
NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
NPObject *npobj = GetNPObject(cx, obj);
|
||||
|
||||
|
@ -1202,7 +1202,7 @@ NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
|
||||
PluginDestructionGuard pdg(LookupNPP(npobj));
|
||||
|
||||
NPIdentifier identifier = JSValToNPIdentifier(id);
|
||||
NPIdentifier identifier = JSIdToNPIdentifier(id);
|
||||
JSBool hasProperty = npobj->_class->hasProperty(npobj, identifier);
|
||||
if (!ReportExceptionIfPending(cx))
|
||||
return JS_FALSE;
|
||||
|
@ -1226,7 +1226,7 @@ NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
NPObject *npobj = GetNPObject(cx, obj);
|
||||
|
||||
|
@ -1239,7 +1239,7 @@ NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
|
||||
PluginDestructionGuard pdg(LookupNPP(npobj));
|
||||
|
||||
NPIdentifier identifier = JSValToNPIdentifier(id);
|
||||
NPIdentifier identifier = JSIdToNPIdentifier(id);
|
||||
|
||||
if (!NPObjectIsOutOfProcessProxy(npobj)) {
|
||||
JSBool hasProperty = npobj->_class->hasProperty(npobj, identifier);
|
||||
|
@ -1257,7 +1257,7 @@ NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
NPObject *npobj = GetNPObject(cx, obj);
|
||||
|
||||
|
@ -1280,7 +1280,7 @@ NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
|
||||
PluginDestructionGuard pdg(npp);
|
||||
|
||||
NPIdentifier identifier = JSValToNPIdentifier(id);
|
||||
NPIdentifier identifier = JSIdToNPIdentifier(id);
|
||||
|
||||
if (!NPObjectIsOutOfProcessProxy(npobj)) {
|
||||
JSBool hasProperty = npobj->_class->hasProperty(npobj, identifier);
|
||||
|
@ -1316,7 +1316,7 @@ NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
static JSBool
|
||||
NPObjWrapper_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
NPObjWrapper_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
NPObject *npobj = GetNPObject(cx, obj);
|
||||
|
||||
|
@ -1343,7 +1343,7 @@ NPObjWrapper_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
NPVariant npv;
|
||||
VOID_TO_NPVARIANT(npv);
|
||||
|
||||
NPIdentifier identifier = JSValToNPIdentifier(id);
|
||||
NPIdentifier identifier = JSIdToNPIdentifier(id);
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
if (NPObjectIsOutOfProcessProxy(npobj)) {
|
||||
|
@ -1604,7 +1604,7 @@ NPObjWrapper_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
state->index = 0;
|
||||
*statep = PRIVATE_TO_JSVAL(state);
|
||||
if (idp) {
|
||||
*idp = INT_TO_JSVAL(length);
|
||||
*idp = INT_TO_JSID(length);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1614,8 +1614,8 @@ NPObjWrapper_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
enum_value = state->value;
|
||||
length = state->length;
|
||||
if (state->index != length) {
|
||||
jsval val = NPIdentifierToJSVal(enum_value[state->index++]);
|
||||
return ::JS_ValueToId(cx, val, idp);
|
||||
*idp = NPIdentifierToJSId(enum_value[state->index++]);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
// FALL THROUGH
|
||||
|
@ -1634,7 +1634,7 @@ NPObjWrapper_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp)
|
||||
{
|
||||
NPObject *npobj = GetNPObject(cx, obj);
|
||||
|
@ -1648,7 +1648,7 @@ NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
|||
|
||||
PluginDestructionGuard pdg(LookupNPP(npobj));
|
||||
|
||||
NPIdentifier identifier = JSValToNPIdentifier(id);
|
||||
NPIdentifier identifier = JSIdToNPIdentifier(id);
|
||||
|
||||
PRBool hasProperty = npobj->_class->hasProperty(npobj, identifier);
|
||||
if (!ReportExceptionIfPending(cx))
|
||||
|
@ -1657,14 +1657,14 @@ NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
|||
if (hasProperty) {
|
||||
JSBool ok;
|
||||
|
||||
if (JSVAL_IS_STRING(id)) {
|
||||
JSString *str = JSVAL_TO_STRING(id);
|
||||
if (JSID_IS_STRING(id)) {
|
||||
JSString *str = JSID_TO_STRING(id);
|
||||
|
||||
ok = ::JS_DefineUCProperty(cx, obj, ::JS_GetStringChars(str),
|
||||
::JS_GetStringLength(str), JSVAL_VOID, nsnull,
|
||||
nsnull, JSPROP_ENUMERATE);
|
||||
} else {
|
||||
ok = ::JS_DefineElement(cx, obj, JSVAL_TO_INT(id), JSVAL_VOID, nsnull,
|
||||
ok = ::JS_DefineElement(cx, obj, JSID_TO_INT(id), JSVAL_VOID, nsnull,
|
||||
nsnull, JSPROP_ENUMERATE);
|
||||
}
|
||||
|
||||
|
@ -1684,13 +1684,16 @@ NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
|||
if (hasMethod) {
|
||||
JSString *str = nsnull;
|
||||
|
||||
if (JSVAL_IS_STRING(id)) {
|
||||
str = JSVAL_TO_STRING(id);
|
||||
if (JSID_IS_STRING(id)) {
|
||||
str = JSID_TO_STRING(id);
|
||||
} else {
|
||||
NS_ASSERTION(JSVAL_IS_INT(id), "id must be either string or int!\n");
|
||||
NS_ASSERTION(JSID_IS_INT(id), "id must be either string or int!\n");
|
||||
|
||||
str = ::JS_ValueToString(cx, id);
|
||||
jsval idval;
|
||||
if (!JS_IdToValue(cx, id, &idval))
|
||||
return JS_FALSE;
|
||||
|
||||
str = ::JS_ValueToString(cx, idval);
|
||||
if (!str) {
|
||||
// OOM. The JS engine throws exceptions for us in this case.
|
||||
|
||||
|
@ -2117,7 +2120,7 @@ LookupNPP(NPObject *npobj)
|
|||
|
||||
JSBool
|
||||
CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
|
||||
jsval id, NPVariant* getPropertyResult, jsval *vp)
|
||||
jsid id, NPVariant* getPropertyResult, jsval *vp)
|
||||
{
|
||||
NS_ENSURE_TRUE(vp, JS_FALSE);
|
||||
|
||||
|
@ -2148,7 +2151,7 @@ CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
|
|||
|
||||
::JS_SetPrivate(cx, memobj, (void *)memberPrivate);
|
||||
|
||||
NPIdentifier identifier = JSValToNPIdentifier(id);
|
||||
NPIdentifier identifier = JSIdToNPIdentifier(id);
|
||||
|
||||
jsval fieldValue;
|
||||
NPVariant npv;
|
||||
|
|
|
@ -122,122 +122,65 @@ namespace parent {
|
|||
// always be used instead of casting an NPIdentifier to a jsval and using the
|
||||
// jsapi.
|
||||
|
||||
#if JS_BITS_PER_WORD == 64
|
||||
JS_STATIC_ASSERT(sizeof(NPIdentifier) == sizeof(jsid));
|
||||
|
||||
JS_STATIC_ASSERT(sizeof(NPIdentifier) == sizeof(jsval));
|
||||
|
||||
static inline bool
|
||||
NPIdentifierIsString(NPIdentifer id)
|
||||
static inline jsid
|
||||
NPIdentifierToJSId(NPIdentifier id)
|
||||
{
|
||||
return JSVAL_IS_STRING((jsval)id);
|
||||
}
|
||||
|
||||
static inline JSString *
|
||||
NPIdentifierToString(NPIdentifer id)
|
||||
{
|
||||
return JSVAL_TO_STRING((jsval)id);
|
||||
jsid tmp;
|
||||
JSID_BITS(tmp) = (size_t)id;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static inline NPIdentifier
|
||||
StringToNPIdentifier(JSString *str)
|
||||
JSIdToNPIdentifier(jsid id)
|
||||
{
|
||||
return (NPIdentifier)STRING_TO_JSVAL(str);
|
||||
return (NPIdentifier)JSID_BITS(id);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
NPIdentifierIsInt(NPIdentifer id)
|
||||
{
|
||||
return JSVAL_IS_INT((jsval)id);
|
||||
}
|
||||
|
||||
static inline jsint
|
||||
NPIdentifierToInt(NPIdentifer id)
|
||||
{
|
||||
return JSVAL_TO_INT((jsval)id);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
IntToNPIdentifier(JSContext *, jsint i, NPIdentifier *pid)
|
||||
{
|
||||
*pid = (NPIdentifier)INT_TO_JSVAL(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
NPIdentifierIsVoid(NPIdentifier id)
|
||||
{
|
||||
return JSVAL_IS_VOID((NPIdentifier)id);
|
||||
}
|
||||
|
||||
static const NPIdentifier NPIdentifier_VOID = (NPIdentifier)JSVAL_VOID;
|
||||
|
||||
#else /* JS_BITS_PER_WORD == 32 */
|
||||
|
||||
static inline bool
|
||||
NPIdentifierIsString(NPIdentifier id)
|
||||
{
|
||||
return ((size_t)id & 0x3) == 0;
|
||||
return JSID_IS_STRING(NPIdentifierToJSId(id));
|
||||
}
|
||||
|
||||
static inline JSString *
|
||||
NPIdentifierToString(NPIdentifier id)
|
||||
{
|
||||
NS_ASSERTION(NPIdentifierIsString(id), "id must be string");
|
||||
return (JSString *)id;
|
||||
return JSID_TO_STRING(NPIdentifierToJSId(id));
|
||||
}
|
||||
|
||||
static inline NPIdentifier
|
||||
StringToNPIdentifier(JSString *str)
|
||||
{
|
||||
NS_ASSERTION(((size_t)str & 3) == 0, "Strings are assumed to be at least 4-byte aligned");
|
||||
return (NPIdentifier)str;
|
||||
return JSIdToNPIdentifier(INTERNED_STRING_TO_JSID(str));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
NPIdentifierIsInt(NPIdentifier id)
|
||||
{
|
||||
return ((size_t)id & 1) != 0;
|
||||
return JSID_IS_INT(NPIdentifierToJSId(id));
|
||||
}
|
||||
|
||||
static inline jsint
|
||||
NPIdentifierToInt(NPIdentifier id)
|
||||
{
|
||||
NS_ASSERTION(NPIdentifierIsInt(id), "id must be int");
|
||||
return (jsint)id >> 1;
|
||||
return JSID_TO_INT(NPIdentifierToJSId(id));
|
||||
}
|
||||
|
||||
static inline NPIdentifier
|
||||
IntToNPIdentifier(jsint i)
|
||||
{
|
||||
NS_ASSERTION(i < (1 << 30) - 1, "integer id is too big, will be truncated");
|
||||
return (NPIdentifier)((i << 1) | 0x1);
|
||||
return JSIdToNPIdentifier(INT_TO_JSID(i));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
NPIdentifierIsVoid(NPIdentifier id)
|
||||
{
|
||||
return (size_t)id == 0x2;
|
||||
return JSID_IS_VOID(NPIdentifierToJSId(id));
|
||||
}
|
||||
|
||||
static const NPIdentifier NPIdentifier_VOID = (NPIdentifier)0x2;
|
||||
|
||||
#endif
|
||||
|
||||
static inline jsval
|
||||
NPIdentifierToJSVal(NPIdentifier id)
|
||||
{
|
||||
if (NPIdentifierIsString(id))
|
||||
return STRING_TO_JSVAL(NPIdentifierToString(id));
|
||||
return INT_TO_JSVAL(NPIdentifierToInt(id));
|
||||
}
|
||||
|
||||
static inline NPIdentifier
|
||||
JSValToNPIdentifier(jsval val)
|
||||
{
|
||||
if (JSVAL_IS_STRING(val))
|
||||
return StringToNPIdentifier(JSVAL_TO_STRING(val));
|
||||
return IntToNPIdentifier(JSVAL_TO_INT(val));
|
||||
}
|
||||
#define NPIdentifier_VOID (JSIdToNPIdentifier(JSID_VOID))
|
||||
|
||||
NPObject* NP_CALLBACK
|
||||
_getwindowobject(NPP npp);
|
||||
|
|
|
@ -116,11 +116,11 @@ NS_IMETHODIMP
|
|||
AsyncStatementJSHelper::GetProperty(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
jsval *_result,
|
||||
PRBool *_retval)
|
||||
{
|
||||
if (!JSVAL_IS_STRING(aId))
|
||||
if (!JSID_IS_STRING(aId))
|
||||
return NS_OK;
|
||||
|
||||
// Cast to async via mozI* since direct from nsISupports is ambiguous.
|
||||
|
@ -136,7 +136,7 @@ AsyncStatementJSHelper::GetProperty(nsIXPConnectWrappedNative *aWrapper,
|
|||
}
|
||||
#endif
|
||||
|
||||
const char *propName = ::JS_GetStringBytes(JSVAL_TO_STRING(aId));
|
||||
const char *propName = ::JS_GetStringBytes(JSID_TO_STRING(aId));
|
||||
if (::strcmp(propName, "params") == 0)
|
||||
return getParams(stmt, aCtx, aScopeObj, _result);
|
||||
|
||||
|
|
|
@ -80,23 +80,23 @@ AsyncStatementParams::SetProperty(
|
|||
nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
jsval *_vp,
|
||||
PRBool *_retval
|
||||
)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStatement, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (JSVAL_IS_INT(aId)) {
|
||||
int idx = JSVAL_TO_INT(aId);
|
||||
if (JSID_IS_INT(aId)) {
|
||||
int idx = JSID_TO_INT(aId);
|
||||
|
||||
nsCOMPtr<nsIVariant> variant(convertJSValToVariant(aCtx, *_vp));
|
||||
NS_ENSURE_TRUE(variant, NS_ERROR_UNEXPECTED);
|
||||
nsresult rv = mStatement->BindByIndex(idx, variant);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else if (JSVAL_IS_STRING(aId)) {
|
||||
JSString *str = JSVAL_TO_STRING(aId);
|
||||
else if (JSID_IS_STRING(aId)) {
|
||||
JSString *str = JSID_TO_STRING(aId);
|
||||
NS_ConvertUTF16toUTF8 name(reinterpret_cast<const PRUnichar *>
|
||||
(::JS_GetStringChars(str)),
|
||||
::JS_GetStringLength(str));
|
||||
|
@ -119,7 +119,7 @@ AsyncStatementParams::NewResolve(
|
|||
nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
PRUint32 aFlags,
|
||||
JSObject **_objp,
|
||||
PRBool *_retval
|
||||
|
@ -131,16 +131,16 @@ AsyncStatementParams::NewResolve(
|
|||
|
||||
bool resolved = false;
|
||||
PRBool ok = PR_TRUE;
|
||||
if (JSVAL_IS_INT(aId)) {
|
||||
PRUint32 idx = JSVAL_TO_INT(aId);
|
||||
if (JSID_IS_INT(aId)) {
|
||||
PRUint32 idx = JSID_TO_INT(aId);
|
||||
// All indexes are good because we don't know how many parameters there
|
||||
// really are.
|
||||
ok = ::JS_DefineElement(aCtx, aScopeObj, idx, JSVAL_VOID, nsnull,
|
||||
nsnull, 0);
|
||||
resolved = true;
|
||||
}
|
||||
else if (JSVAL_IS_STRING(aId)) {
|
||||
JSString *str = JSVAL_TO_STRING(aId);
|
||||
else if (JSID_IS_STRING(aId)) {
|
||||
JSString *str = JSID_TO_STRING(aId);
|
||||
jschar *nameChars = ::JS_GetStringChars(str);
|
||||
size_t nameLength = ::JS_GetStringLength(str);
|
||||
|
||||
|
|
|
@ -205,11 +205,11 @@ NS_IMETHODIMP
|
|||
StatementJSHelper::GetProperty(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
jsval *_result,
|
||||
PRBool *_retval)
|
||||
{
|
||||
if (!JSVAL_IS_STRING(aId))
|
||||
if (!JSID_IS_STRING(aId))
|
||||
return NS_OK;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -224,7 +224,7 @@ StatementJSHelper::GetProperty(nsIXPConnectWrappedNative *aWrapper,
|
|||
static_cast<mozIStorageStatement *>(aWrapper->Native())
|
||||
);
|
||||
|
||||
const char *propName = ::JS_GetStringBytes(JSVAL_TO_STRING(aId));
|
||||
const char *propName = ::JS_GetStringBytes(JSID_TO_STRING(aId));
|
||||
if (::strcmp(propName, "row") == 0)
|
||||
return getRow(stmt, aCtx, aScopeObj, _result);
|
||||
|
||||
|
@ -239,15 +239,15 @@ NS_IMETHODIMP
|
|||
StatementJSHelper::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
PRUint32 aFlags,
|
||||
JSObject **_objp,
|
||||
PRBool *_retval)
|
||||
{
|
||||
if (!JSVAL_IS_STRING(aId))
|
||||
if (!JSID_IS_STRING(aId))
|
||||
return NS_OK;
|
||||
|
||||
const char *name = ::JS_GetStringBytes(JSVAL_TO_STRING(aId));
|
||||
const char *name = ::JS_GetStringBytes(JSID_TO_STRING(aId));
|
||||
if (::strcmp(name, "step") == 0) {
|
||||
*_retval = ::JS_DefineFunction(aCtx, aScopeObj, "step", (JSNative)stepFunc,
|
||||
0, JSFUN_FAST_NATIVE) != nsnull;
|
||||
|
|
|
@ -79,22 +79,22 @@ NS_IMETHODIMP
|
|||
StatementParams::SetProperty(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
jsval *_vp,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStatement, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (JSVAL_IS_INT(aId)) {
|
||||
int idx = JSVAL_TO_INT(aId);
|
||||
if (JSID_IS_INT(aId)) {
|
||||
int idx = JSID_TO_INT(aId);
|
||||
|
||||
nsCOMPtr<nsIVariant> variant(convertJSValToVariant(aCtx, *_vp));
|
||||
NS_ENSURE_TRUE(variant, NS_ERROR_UNEXPECTED);
|
||||
nsresult rv = mStatement->BindByIndex(idx, variant);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else if (JSVAL_IS_STRING(aId)) {
|
||||
JSString *str = JSVAL_TO_STRING(aId);
|
||||
else if (JSID_IS_STRING(aId)) {
|
||||
JSString *str = JSID_TO_STRING(aId);
|
||||
NS_ConvertUTF16toUTF8 name(reinterpret_cast<const PRUnichar *>
|
||||
(::JS_GetStringChars(str)),
|
||||
::JS_GetStringLength(str));
|
||||
|
@ -132,7 +132,7 @@ StatementParams::NewEnumerate(nsIXPConnectWrappedNative *aWrapper,
|
|||
|
||||
// And set our length, if needed.
|
||||
if (_idp)
|
||||
*_idp = INT_TO_JSVAL(mParamCount);
|
||||
*_idp = INT_TO_JSID(mParamCount);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ NS_IMETHODIMP
|
|||
StatementParams::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
PRUint32 aFlags,
|
||||
JSObject **_objp,
|
||||
PRBool *_retval)
|
||||
|
@ -196,8 +196,8 @@ StatementParams::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
|||
|
||||
bool resolved = false;
|
||||
PRBool ok = PR_TRUE;
|
||||
if (JSVAL_IS_INT(aId)) {
|
||||
PRUint32 idx = JSVAL_TO_INT(aId);
|
||||
if (JSID_IS_INT(aId)) {
|
||||
PRUint32 idx = JSID_TO_INT(aId);
|
||||
|
||||
// Ensure that our index is within range. We do not care about the
|
||||
// prototype chain being checked here.
|
||||
|
@ -208,8 +208,8 @@ StatementParams::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
|||
nsnull, 0);
|
||||
resolved = true;
|
||||
}
|
||||
else if (JSVAL_IS_STRING(aId)) {
|
||||
JSString *str = JSVAL_TO_STRING(aId);
|
||||
else if (JSID_IS_STRING(aId)) {
|
||||
JSString *str = JSID_TO_STRING(aId);
|
||||
jschar *nameChars = ::JS_GetStringChars(str);
|
||||
size_t nameLength = ::JS_GetStringLength(str);
|
||||
|
||||
|
|
|
@ -78,14 +78,14 @@ NS_IMETHODIMP
|
|||
StatementRow::GetProperty(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
jsval *_vp,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStatement, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
if (JSVAL_IS_STRING(aId)) {
|
||||
nsDependentCString jsid(::JS_GetStringBytes(JSVAL_TO_STRING(aId)));
|
||||
if (JSID_IS_STRING(aId)) {
|
||||
nsDependentCString jsid(::JS_GetStringBytes(JSID_TO_STRING(aId)));
|
||||
|
||||
PRUint32 idx;
|
||||
nsresult rv = mStatement->GetColumnIndex(jsid, &idx);
|
||||
|
@ -152,7 +152,7 @@ NS_IMETHODIMP
|
|||
StatementRow::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsval aId,
|
||||
jsid aId,
|
||||
PRUint32 aFlags,
|
||||
JSObject **_objp,
|
||||
PRBool *_retval)
|
||||
|
@ -161,8 +161,8 @@ StatementRow::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
|||
// We do not throw at any point after this because we want to allow the
|
||||
// prototype chain to be checked for the property.
|
||||
|
||||
if (JSVAL_IS_STRING(aId)) {
|
||||
JSString *str = JSVAL_TO_STRING(aId);
|
||||
if (JSID_IS_STRING(aId)) {
|
||||
JSString *str = JSID_TO_STRING(aId);
|
||||
nsDependentCString name(::JS_GetStringBytes(str));
|
||||
|
||||
PRUint32 idx;
|
||||
|
|
|
@ -121,6 +121,7 @@ typedef unsigned long size_t;
|
|||
[ptr, astring] native AStringPtr(ignored);
|
||||
|
||||
native jsval(jsval);
|
||||
native jsid(jsid);
|
||||
|
||||
%{C++
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче