Don't try to duplicate the jsval typedef. Bug 312003, r+sr=brendan

This commit is contained in:
bzbarsky%mit.edu 2005-10-12 20:16:35 +00:00
parent e7a9f323b4
commit d86be43444
6 changed files with 19 additions and 13 deletions

View File

@ -83,7 +83,7 @@ public:
virtual JSObject *GetGlobalJSObject();
virtual void OnFinalize(JSObject *aObject);
virtual void SetScriptsEnabled(PRBool aEnabled, PRBool aFireTimeouts);
virtual nsresult SetNewArguments(PRUint32 aArgc, jsval* aArgv);
virtual nsresult SetNewArguments(PRUint32 aArgc, void* aArgv);
// nsIScriptObjectPrincipal methods
virtual nsIPrincipal* GetPrincipal();
@ -308,7 +308,7 @@ nsXBLDocGlobalObject::SetScriptsEnabled(PRBool aEnabled, PRBool aFireTimeouts)
}
nsresult
nsXBLDocGlobalObject::SetNewArguments(PRUint32 aArgc, jsval* aArgv)
nsXBLDocGlobalObject::SetNewArguments(PRUint32 aArgc, void* aArgv)
{
NS_NOTREACHED("waaah!");
return NS_ERROR_UNEXPECTED;

View File

@ -105,7 +105,7 @@ public:
virtual JSObject *GetGlobalJSObject();
virtual void OnFinalize(JSObject *aObject);
virtual void SetScriptsEnabled(PRBool aEnabled, PRBool aFireTimeouts);
virtual nsresult SetNewArguments(PRUint32 aArgc, jsval* aArgv);
virtual nsresult SetNewArguments(PRUint32 aArgc, void* aArgv);
// nsIScriptObjectPrincipal methods
virtual nsIPrincipal* GetPrincipal();
@ -934,7 +934,7 @@ nsXULPDGlobalObject::SetScriptsEnabled(PRBool aEnabled, PRBool aFireTimeouts)
}
nsresult
nsXULPDGlobalObject::SetNewArguments(PRUint32 aArgc, jsval* aArgv)
nsXULPDGlobalObject::SetNewArguments(PRUint32 aArgc, void* aArgv)
{
NS_NOTREACHED("waaah!");
return NS_ERROR_UNEXPECTED;

View File

@ -50,11 +50,10 @@ class nsIDocShell;
class nsIDOMWindowInternal;
class nsIScriptGlobalObjectOwner;
struct JSObject;
typedef long jsval;
#define NS_ISCRIPTGLOBALOBJECT_IID \
{ 0xd0db67fc, 0x50f7, 0x4573, \
{ 0x87, 0x3e, 0x5b, 0x33, 0x0b, 0x13, 0x21, 0x81 } }
{ 0xd326a211, 0xdc31, 0x45c6, \
{ 0x98, 0x97, 0x22, 0x11, 0xea, 0xbc, 0xd0, 0x1c } }
/**
* The JavaScript specific global object. This often used to store
@ -116,8 +115,13 @@ public:
* the window right away (if there's an existing document) and it
* will also be installed on the window when the next document is
* loaded. If argc is nonzero, argv must be non-null.
*
* @param aArgc the number of args
* @param aArgv the pointer to the args. This may be cast to jsval* and the
* args are found at
* ((jsval*)aArgv)[0], ..., ((jsval*)aArgv)[aArgc - 1]
*/
virtual nsresult SetNewArguments(PRUint32 aArgc, jsval* aArgv) = 0;
virtual nsresult SetNewArguments(PRUint32 aArgc, void* aArgv) = 0;
};
#endif

View File

@ -1659,7 +1659,7 @@ nsGlobalWindow::SetScriptsEnabled(PRBool aEnabled, PRBool aFireTimeouts)
}
nsresult
nsGlobalWindow::SetNewArguments(PRUint32 aArgc, jsval* aArgv)
nsGlobalWindow::SetNewArguments(PRUint32 aArgc, void* aArgv)
{
FORWARD_TO_OUTER(SetNewArguments, (aArgc, aArgv), NS_ERROR_NOT_INITIALIZED);
@ -1677,14 +1677,16 @@ nsGlobalWindow::SetNewArguments(PRUint32 aArgc, jsval* aArgv)
return NS_OK;
}
NS_ASSERTION(aArgv, "Must have argv!");
jsval* argv = NS_STATIC_CAST(jsval*, aArgv);
NS_ASSERTION(argv, "Must have argv!");
// Freeze the outer here so that we don't create a bogus new inner
// just because we're trying to resolve the Array class on cx.
// Resolving it for window.arguments on the outer window should be
// fine, I think.
Freeze();
JSObject *argArray = ::JS_NewArrayObject(cx, aArgc, aArgv);
JSObject *argArray = ::JS_NewArrayObject(cx, aArgc, argv);
Thaw();
NS_ENSURE_TRUE(argArray, NS_ERROR_OUT_OF_MEMORY);

View File

@ -169,7 +169,7 @@ public:
virtual JSObject *GetGlobalJSObject();
virtual void OnFinalize(JSObject *aJSObject);
virtual void SetScriptsEnabled(PRBool aEnabled, PRBool aFireTimeouts);
virtual nsresult SetNewArguments(PRUint32 aArgc, jsval* aArgv);
virtual nsresult SetNewArguments(PRUint32 aArgc, void* aArgv);
// nsIScriptObjectPrincipal
virtual nsIPrincipal* GetPrincipal();

View File

@ -1748,7 +1748,7 @@ nsWindowWatcher::AttachArguments(nsIDOMWindow *aWindow,
NS_ENSURE_TRUE(scriptGlobal, NS_ERROR_UNEXPECTED);
// Just ask the global to attach the args for us
return scriptGlobal->SetNewArguments(argc, argv);
return scriptGlobal->SetNewArguments(argc, NS_STATIC_CAST(void*, argv));
}
nsresult