Bug 683802 - Add jsval to the XPTCMiniVariant union for type safety. r=mrbkap

This commit is contained in:
Bobby Holley 2011-09-25 15:38:01 +01:00
Родитель 4764ad32ea
Коммит 85a6b92ebd
2 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -2848,12 +2848,9 @@ CallMethodHelper::ConvertIndependentParam(uint8 i)
// indirectly, regardless of in/out-ness.
if(type_tag == nsXPTType::T_JSVAL)
{
// Assign the value
JS_STATIC_ASSERT(sizeof(jsval) <= sizeof(dp->val));
jsval *rootp = (jsval *)&dp->val;
dp->ptr = rootp;
*rootp = JSVAL_VOID;
if(!JS_AddValueRoot(mCallContext, rootp))
// Root the value.
dp->val.j = JSVAL_VOID;
if (!JS_AddValueRoot(mCallContext, &dp->val.j))
return JS_FALSE;
dp->SetValIsJSRoot();
}

Просмотреть файл

@ -52,6 +52,7 @@
#include "nsISupports.h"
#include "xpt_struct.h"
#include "xptinfo.h"
#include "jsapi.h"
struct nsXPTCMiniVariant
{
@ -73,6 +74,11 @@ struct nsXPTCMiniVariant
char c;
PRUnichar wc;
void* p;
// Types below here are unknown to the assembly implementations, and
// therefore _must_ be passed with indirect semantics. We put them in
// the union here for type safety, so that we can avoid void* tricks.
jsval j;
} val;
};