Bug 688012 - Add space between keyword and paren for: if, for, while, and switch. r=mrbkap

xpcfix -spuc `find | grep -P "cpp$|h$" | perl -pe 's/\n/ /'`

git diff -w is empty here as well.
This commit is contained in:
Bobby Holley 2011-10-14 10:52:48 -07:00
Родитель b9fef5e5b7
Коммит 75a8f804ad
38 изменённых файлов: 3017 добавлений и 3017 удалений

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

@ -531,7 +531,7 @@ DumpXPC(JSContext *cx, uintN argc, jsval *vp)
}
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
if(xpc)
if (xpc)
xpc->DebugDump((int16)depth);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
@ -1034,8 +1034,8 @@ ProcessFile(JSContext *cx, JSObject *obj, const char *filename, FILE *file,
*/
int ch = fgetc(file);
if (ch == '#') {
while((ch = fgetc(file)) != EOF) {
if(ch == '\n' || ch == '\r')
while ((ch = fgetc(file)) != EOF) {
if (ch == '\n' || ch == '\r')
break;
}
}
@ -1925,7 +1925,7 @@ main(int argc, char **argv, char **envp)
return 1;
}
if(NS_FAILED(cxstack->Push(cx))) {
if (NS_FAILED(cxstack->Push(cx))) {
printf("failed to push the current JSContext on the nsThreadJSContextStack!\n");
return 1;
}

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

@ -98,18 +98,18 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
jsval *argv,
jsval *rval)
{
if(!mXPC)
if (!mXPC)
return;
mThreadData = XPCPerThreadData::GetData(mJSContext);
if(!mThreadData)
if (!mThreadData)
return;
XPCJSContextStack* stack = mThreadData->GetJSContextStack();
JSContext* topJSContext;
if(!stack || NS_FAILED(stack->Peek(&topJSContext)))
if (!stack || NS_FAILED(stack->Peek(&topJSContext)))
{
// If we don't have a stack we're probably in shutdown.
NS_ASSERTION(!stack, "Bad, Peek failed!");
@ -117,7 +117,7 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
return;
}
if(!mJSContext)
if (!mJSContext)
{
// This is slightly questionable. If called without an explicit
// JSContext (generally a call to a wrappedJS) we will use the JSContext
@ -127,15 +127,15 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
// have JS stack 'continuity' for purposes of stack traces etc.
// Note: this *is* what the pre-XPCCallContext xpconnect did too.
if(topJSContext)
if (topJSContext)
mJSContext = topJSContext;
else if(NS_FAILED(stack->GetSafeJSContext(&mJSContext)) || !mJSContext)
else if (NS_FAILED(stack->GetSafeJSContext(&mJSContext)) || !mJSContext)
return;
}
if(topJSContext != mJSContext)
if (topJSContext != mJSContext)
{
if(NS_FAILED(stack->Push(mJSContext)))
if (NS_FAILED(stack->Push(mJSContext)))
{
NS_ERROR("bad!");
return;
@ -148,7 +148,7 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
NS_ASSERTION(!callBeginRequest || mCallerLanguage == NATIVE_CALLER,
"Don't call JS_BeginRequest unless the caller is native.");
if(callBeginRequest)
if (callBeginRequest)
JS_BeginRequest(mJSContext);
mXPCContext = XPCContext::GetXPCContext(mJSContext);
@ -159,12 +159,12 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
// We only need to addref xpconnect once so only do it if this is the first
// context in the chain.
if(!mPrevCallContext)
if (!mPrevCallContext)
NS_ADDREF(mXPC);
mState = HAVE_CONTEXT;
if(!obj)
if (!obj)
return;
mScopeForNewJSObjects = obj;
@ -176,19 +176,19 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
mState = HAVE_OBJECT;
mTearOff = nsnull;
if(wrapperInitOptions == INIT_SHOULD_LOOKUP_WRAPPER)
if (wrapperInitOptions == INIT_SHOULD_LOOKUP_WRAPPER)
{
mWrapper = XPCWrappedNative::GetWrappedNativeOfJSObject(mJSContext, obj,
funobj,
&mFlattenedJSObject,
&mTearOff);
if(mWrapper)
if (mWrapper)
{
DEBUG_CheckWrapperThreadSafety(mWrapper);
mFlattenedJSObject = mWrapper->GetFlatJSObject();
if(mTearOff)
if (mTearOff)
mScriptableInfo = nsnull;
else
mScriptableInfo = mWrapper->GetScriptableInfo();
@ -200,10 +200,10 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
}
}
if(!JSID_IS_VOID(name))
if (!JSID_IS_VOID(name))
SetName(name);
if(argc != NO_ARGS)
if (argc != NO_ARGS)
SetArgsAndResultPtr(argc, argv, rval);
CHECK_STATE(HAVE_OBJECT);
@ -216,27 +216,27 @@ XPCCallContext::SetName(jsid name)
mName = name;
if(mTearOff)
if (mTearOff)
{
mSet = nsnull;
mInterface = mTearOff->GetInterface();
mMember = mInterface->FindMember(name);
mStaticMemberIsLocal = JS_TRUE;
if(mMember && !mMember->IsConstant())
if (mMember && !mMember->IsConstant())
mMethodIndex = mMember->GetIndex();
}
else
{
mSet = mWrapper ? mWrapper->GetSet() : nsnull;
if(mSet &&
mSet->FindMember(name, &mMember, &mInterface,
mWrapper->HasProto() ?
mWrapper->GetProto()->GetSet() :
nsnull,
&mStaticMemberIsLocal))
if (mSet &&
mSet->FindMember(name, &mMember, &mInterface,
mWrapper->HasProto() ?
mWrapper->GetProto()->GetSet() :
nsnull,
&mStaticMemberIsLocal))
{
if(mMember && !mMember->IsConstant())
if (mMember && !mMember->IsConstant())
mMethodIndex = mMember->GetIndex();
}
else
@ -260,7 +260,7 @@ XPCCallContext::SetCallInfo(XPCNativeInterface* iface, XPCNativeMember* member,
// by id.
// don't be tricked if method is called with wrong 'this'
if(mTearOff && mTearOff->GetInterface() != iface)
if (mTearOff && mTearOff->GetInterface() != iface)
mTearOff = nsnull;
mSet = nsnull;
@ -269,7 +269,7 @@ XPCCallContext::SetCallInfo(XPCNativeInterface* iface, XPCNativeMember* member,
mMethodIndex = mMember->GetIndex() + (isSetter ? 1 : 0);
mName = mMember->GetName();
if(mState < HAVE_NAME)
if (mState < HAVE_NAME)
mState = HAVE_NAME;
}
@ -280,7 +280,7 @@ XPCCallContext::SetArgsAndResultPtr(uintN argc,
{
CHECK_STATE(HAVE_OBJECT);
if(mState < HAVE_NAME)
if (mState < HAVE_NAME)
{
mSet = nsnull;
mInterface = nsnull;
@ -301,15 +301,15 @@ XPCCallContext::CanCallNow()
{
nsresult rv;
if(!HasInterfaceAndMember())
if (!HasInterfaceAndMember())
return NS_ERROR_UNEXPECTED;
if(mState < HAVE_ARGS)
if (mState < HAVE_ARGS)
return NS_ERROR_UNEXPECTED;
if(!mTearOff)
if (!mTearOff)
{
mTearOff = mWrapper->FindTearOff(*this, mInterface, JS_FALSE, &rv);
if(!mTearOff || mTearOff->GetInterface() != mInterface)
if (!mTearOff || mTearOff->GetInterface() != mInterface)
{
mTearOff = nsnull;
return NS_FAILED(rv) ? rv : NS_ERROR_UNEXPECTED;
@ -333,7 +333,7 @@ XPCCallContext::SystemIsBeingShutDown()
mThreadData = nsnull;
mXPCContext = nsnull;
mState = SYSTEM_SHUTDOWN;
if(mPrevCallContext)
if (mPrevCallContext)
mPrevCallContext->SystemIsBeingShutDown();
}
@ -343,7 +343,7 @@ XPCCallContext::~XPCCallContext()
bool shouldReleaseXPC = false;
if(mXPCContext)
if (mXPCContext)
{
mXPCContext->SetCallingLangType(mPrevCallerLanguage);
@ -358,14 +358,14 @@ XPCCallContext::~XPCCallContext()
}
// NB: Needs to happen before the context stack pop.
if(mJSContext && mCallerLanguage == NATIVE_CALLER)
if (mJSContext && mCallerLanguage == NATIVE_CALLER)
JS_EndRequest(mJSContext);
if(mContextPopRequired)
if (mContextPopRequired)
{
XPCJSContextStack* stack = mThreadData->GetJSContextStack();
NS_ASSERTION(stack, "bad!");
if(stack)
if (stack)
{
#ifdef DEBUG
JSContext* poppedCX;
@ -377,9 +377,9 @@ XPCCallContext::~XPCCallContext()
}
}
if(mJSContext)
if (mJSContext)
{
if(mDestroyJSContextInDestructor)
if (mDestroyJSContextInDestructor)
{
#ifdef DEBUG_xpc_hacker
printf("!xpc - doing deferred destruction of JSContext @ %p\n",
@ -395,24 +395,24 @@ XPCCallContext::~XPCCallContext()
}
#ifdef DEBUG
for(PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i)
for (PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i)
{
NS_ASSERTION(!mScratchStrings[i].mInUse, "Uh, string wrapper still in use!");
}
#endif
if(shouldReleaseXPC && mXPC)
if (shouldReleaseXPC && mXPC)
NS_RELEASE(mXPC);
}
XPCReadableJSStringWrapper *
XPCCallContext::NewStringWrapper(const PRUnichar *str, PRUint32 len)
{
for(PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i)
for (PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i)
{
StringWrapperEntry& ent = mScratchStrings[i];
if(!ent.mInUse)
if (!ent.mInUse)
{
ent.mInUse = PR_TRUE;
@ -430,10 +430,10 @@ XPCCallContext::NewStringWrapper(const PRUnichar *str, PRUint32 len)
void
XPCCallContext::DeleteString(nsAString *string)
{
for(PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i)
for (PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i)
{
StringWrapperEntry& ent = mScratchStrings[i];
if(string == ent.mString.addr())
if (string == ent.mString.addr())
{
// One of our internal strings is no longer in use, mark
// it as such and destroy the string.

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -72,9 +72,9 @@ XPCContext::~XPCContext()
NS_IF_RELEASE(mSecurityManager);
// Iterate over our scopes and tell them that we have been destroyed
for(PRCList *scopeptr = PR_NEXT_LINK(&mScopes);
scopeptr != &mScopes;
scopeptr = PR_NEXT_LINK(scopeptr))
for (PRCList *scopeptr = PR_NEXT_LINK(&mScopes);
scopeptr != &mScopes;
scopeptr = PR_NEXT_LINK(scopeptr))
{
XPCWrappedNativeScope *scope = (XPCWrappedNativeScope *)scopeptr;
scope->SetContext(nsnull);
@ -99,7 +99,7 @@ XPCContext::DebugDump(PRInt16 depth)
XPC_LOG_ALWAYS(("mSecurityManagerFlags of %x", mSecurityManagerFlags));
XPC_LOG_ALWAYS(("mException @ %x", mException));
if(depth && mException)
if (depth && mException)
{
// XXX show the exception here...
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -51,16 +51,16 @@ static const char* JSVAL2String(JSContext* cx, jsval val, JSBool* isString,
JSAutoRequest ar(cx);
const char* value = nsnull;
JSString* value_str = JS_ValueToString(cx, val);
if(value_str)
if (value_str)
value = bytes->encode(cx, value_str);
if(value)
if (value)
{
const char* found = strstr(value, "function ");
if(found && (value == found || value+1 == found || value+2 == found))
if (found && (value == found || value+1 == found || value+2 == found))
value = "[function]";
}
if(isString)
if (isString)
*isString = JSVAL_IS_STRING(val);
return value;
}
@ -90,22 +90,22 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
JSAutoRequest ar(cx);
JSAutoEnterCompartment ac;
if(!ac.enter(cx, JS_GetGlobalForFrame(fp)))
if (!ac.enter(cx, JS_GetGlobalForFrame(fp)))
return buf;
if(script && pc)
if (script && pc)
{
filename = JS_GetScriptFilename(cx, script);
lineno = (PRInt32) JS_PCToLineNumber(cx, script, pc);
fun = JS_GetFrameFunction(cx, fp);
if(fun)
if (fun)
funname = JS_GetFunctionId(fun);
if(showArgs || showLocals)
if (showArgs || showLocals)
{
callObj = JS_GetFrameCallObject(cx, fp);
if(callObj)
if(!JS_GetPropertyDescArray(cx, callObj, &callProps))
if (callObj)
if (!JS_GetPropertyDescArray(cx, callObj, &callProps))
callProps.array = nsnull; // just to be sure
}
@ -122,26 +122,26 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
// print the frame number and function name
if(funname)
if (funname)
buf = JS_sprintf_append(buf, "%d %s(", num, funbytes.encode(cx, funname));
else if(fun)
else if (fun)
buf = JS_sprintf_append(buf, "%d anonymous(", num);
else
buf = JS_sprintf_append(buf, "%d <TOP LEVEL>", num);
if(!buf) goto out;
if (!buf) goto out;
// print the function arguments
if(showArgs && callObj)
if (showArgs && callObj)
{
for(uint32 i = 0; i < callProps.length; i++)
for (uint32 i = 0; i < callProps.length; i++)
{
JSPropertyDesc* desc = &callProps.array[i];
if(desc->flags & JSPD_ARGUMENT)
if (desc->flags & JSPD_ARGUMENT)
{
JSAutoByteString nameBytes;
const char* name = JSVAL2String(cx, desc->id, &isString, &nameBytes);
if(!isString)
if (!isString)
name = nsnull;
JSAutoByteString valueBytes;
const char* value = JSVAL2String(cx, desc->value, &isString, &valueBytes);
@ -153,28 +153,28 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
isString ? "\"" : "",
value ? value : "?unknown?",
isString ? "\"" : "");
if(!buf) goto out;
if (!buf) goto out;
namedArgCount++;
}
}
// print any unnamed trailing args (found in 'arguments' object)
if(JS_GetProperty(cx, callObj, "arguments", &val) &&
JSVAL_IS_OBJECT(val))
if (JS_GetProperty(cx, callObj, "arguments", &val) &&
JSVAL_IS_OBJECT(val))
{
uint32 argCount;
JSObject* argsObj = JSVAL_TO_OBJECT(val);
if(JS_GetProperty(cx, argsObj, "length", &val) &&
JS_ValueToECMAUint32(cx, val, &argCount) &&
argCount > namedArgCount)
if (JS_GetProperty(cx, argsObj, "length", &val) &&
JS_ValueToECMAUint32(cx, val, &argCount) &&
argCount > namedArgCount)
{
for(uint32 k = namedArgCount; k < argCount; k++)
for (uint32 k = namedArgCount; k < argCount; k++)
{
char number[8];
JS_snprintf(number, 8, "%d", (int) k);
if(JS_GetProperty(cx, argsObj, number, &val))
if (JS_GetProperty(cx, argsObj, number, &val))
{
JSAutoByteString valueBytes;
const char *value = JSVAL2String(cx, val, &isString, &valueBytes);
@ -183,7 +183,7 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
isString ? "\"" : "",
value ? value : "?unknown?",
isString ? "\"" : "");
if(!buf) goto out;
if (!buf) goto out;
}
}
}
@ -196,30 +196,30 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
fun ? ")" : "",
filename ? filename : "<unknown>",
lineno);
if(!buf) goto out;
if (!buf) goto out;
// print local variables
if(showLocals && callProps.array)
if (showLocals && callProps.array)
{
for(uint32 i = 0; i < callProps.length; i++)
for (uint32 i = 0; i < callProps.length; i++)
{
JSPropertyDesc* desc = &callProps.array[i];
if(desc->flags & JSPD_VARIABLE)
if (desc->flags & JSPD_VARIABLE)
{
JSAutoByteString nameBytes;
JSAutoByteString valueBytes;
const char *name = JSVAL2String(cx, desc->id, nsnull, &nameBytes);
const char *value = JSVAL2String(cx, desc->value, &isString, &valueBytes);
if(name && value)
if (name && value)
{
buf = JS_sprintf_append(buf, TAB "%s = %s%s%s\n",
name,
isString ? "\"" : "",
value,
isString ? "\"" : "");
if(!buf) goto out;
if (!buf) goto out;
}
}
}
@ -227,18 +227,18 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
// print the value of 'this'
if(showLocals)
if (showLocals)
{
if(gotThisVal)
if (gotThisVal)
{
JSString* thisValStr;
JSAutoByteString thisValBytes;
if(nsnull != (thisValStr = JS_ValueToString(cx, thisVal)) &&
thisValBytes.encode(cx, thisValStr))
if (nsnull != (thisValStr = JS_ValueToString(cx, thisVal)) &&
thisValBytes.encode(cx, thisValStr))
{
buf = JS_sprintf_append(buf, TAB "this = %s\n", thisValBytes.ptr());
if(!buf) goto out;
if (!buf) goto out;
}
}
else
@ -247,35 +247,35 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
// print the properties of 'this', if it is an object
if(showThisProps && thisProps.array)
if (showThisProps && thisProps.array)
{
for(uint32 i = 0; i < thisProps.length; i++)
for (uint32 i = 0; i < thisProps.length; i++)
{
JSPropertyDesc* desc = &thisProps.array[i];
if(desc->flags & JSPD_ENUMERATE)
if (desc->flags & JSPD_ENUMERATE)
{
JSAutoByteString nameBytes;
JSAutoByteString valueBytes;
const char *name = JSVAL2String(cx, desc->id, nsnull, &nameBytes);
const char *value = JSVAL2String(cx, desc->value, &isString, &valueBytes);
if(name && value)
if (name && value)
{
buf = JS_sprintf_append(buf, TAB "this.%s = %s%s%s\n",
name,
isString ? "\"" : "",
value,
isString ? "\"" : "");
if(!buf) goto out;
if (!buf) goto out;
}
}
}
}
out:
if(callProps.array)
if (callProps.array)
JS_PutPropertyDescArray(cx, &callProps);
if(thisProps.array)
if (thisProps.array)
JS_PutPropertyDescArray(cx, &thisProps);
return buf;
}
@ -288,13 +288,13 @@ static char* FormatJSStackDump(JSContext* cx, char* buf,
JSStackFrame* iter = nsnull;
int num = 0;
while(nsnull != (fp = JS_FrameIterator(cx, &iter)))
while (nsnull != (fp = JS_FrameIterator(cx, &iter)))
{
buf = FormatJSFrame(cx, fp, buf, num, showArgs, showLocals, showThisProps);
num++;
}
if(!num)
if (!num)
buf = JS_sprintf_append(buf, "JavaScript stack is empty\n");
return buf;
@ -303,7 +303,7 @@ static char* FormatJSStackDump(JSContext* cx, char* buf,
JSBool
xpc_DumpJSStack(JSContext* cx, JSBool showArgs, JSBool showLocals, JSBool showThisProps)
{
if(char* buf = xpc_PrintJSStack(cx, showArgs, showLocals, showThisProps))
if (char* buf = xpc_PrintJSStack(cx, showArgs, showLocals, showThisProps))
{
fputs(buf, stdout);
JS_smprintf_free(buf);
@ -317,13 +317,13 @@ xpc_PrintJSStack(JSContext* cx, JSBool showArgs, JSBool showLocals,
{
char* buf;
JSExceptionState *state = JS_SaveExceptionState(cx);
if(!state)
if (!state)
puts("Call to a debug function modifying state!");
JS_ClearPendingException(cx);
buf = FormatJSStackDump(cx, nsnull, showArgs, showLocals, showThisProps);
if(!buf)
if (!buf)
puts("Failed to format JavaScript stack for dump");
JS_RestoreExceptionState(cx, state);
@ -346,7 +346,7 @@ xpc_DumpEvalInJSStackFrame(JSContext* cx, JSUint32 frameno, const char* text)
JSStackFrame* iter = nsnull;
JSUint32 num = 0;
if(!cx || !text)
if (!cx || !text)
{
puts("invalid params passed to xpc_DumpEvalInJSStackFrame!");
return JS_FALSE;
@ -354,14 +354,14 @@ xpc_DumpEvalInJSStackFrame(JSContext* cx, JSUint32 frameno, const char* text)
printf("js[%d]> %s\n", frameno, text);
while(nsnull != (fp = JS_FrameIterator(cx, &iter)))
while (nsnull != (fp = JS_FrameIterator(cx, &iter)))
{
if(num == frameno)
if (num == frameno)
break;
num++;
}
if(!fp)
if (!fp)
{
puts("invalid frame number!");
return JS_FALSE;
@ -375,9 +375,9 @@ xpc_DumpEvalInJSStackFrame(JSContext* cx, JSUint32 frameno, const char* text)
jsval rval;
JSString* str;
JSAutoByteString bytes;
if(JS_EvaluateInStackFrame(cx, fp, text, strlen(text), "eval", 1, &rval) &&
nsnull != (str = JS_ValueToString(cx, rval)) &&
bytes.encode(cx, str))
if (JS_EvaluateInStackFrame(cx, fp, text, strlen(text), "eval", 1, &rval) &&
nsnull != (str = JS_ValueToString(cx, rval)) &&
bytes.encode(cx, str))
{
printf("%s\n", bytes.ptr());
}
@ -423,10 +423,10 @@ public:
result Visit(JSObject* obj)
{
if(member_count == max_count)
if (member_count == max_count)
return overflow;
for(int i = 0; i < member_count; i++)
if(array[i] == obj)
for (int i = 0; i < member_count; i++)
if (array[i] == obj)
return seen;
array[member_count++] = obj;
return primary;
@ -457,7 +457,7 @@ static void PrintObject(JSObject* obj, int depth, ObjectPile* pile)
{
PrintObjectBasics(obj);
switch(pile->Visit(obj))
switch (pile->Visit(obj))
{
case ObjectPile::primary:
puts("");
@ -470,19 +470,19 @@ static void PrintObject(JSObject* obj, int depth, ObjectPile* pile)
return;
}
if(!JS_IsNative(obj))
if (!JS_IsNative(obj))
return;
JSObject* parent = js::GetObjectParent(obj);
JSObject* proto = js::GetObjectProto(obj);
printf("%*sparent: ", INDENT(depth+1));
if(parent)
if (parent)
PrintObject(parent, depth+1, pile);
else
puts("null");
printf("%*sproto: ", INDENT(depth+1));
if(proto)
if (proto)
PrintObject(proto, depth+1, pile);
else
puts("null");
@ -499,7 +499,7 @@ xpc_DumpJSObject(JSObject* obj)
puts(" proto: (JSObject*)(obj->fslots[0])");
puts("");
if(obj)
if (obj)
PrintObject(obj, 0, &pile);
else
puts("xpc_DumpJSObject passed null!");

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

@ -73,12 +73,12 @@ nsXPCException::NameAndFormatForNSResult(nsresult rv,
const char** format)
{
for(ResultMap* p = map; p->name; p++)
for (ResultMap* p = map; p->name; p++)
{
if(rv == p->rv)
if (rv == p->rv)
{
if(name) *name = p->name;
if(format) *format = p->format;
if (name) *name = p->name;
if (format) *format = p->format;
return JS_TRUE;
}
}
@ -93,19 +93,19 @@ nsXPCException::IterateNSResults(nsresult* rv,
void** iterp)
{
ResultMap* p = (ResultMap*) *iterp;
if(!p)
if (!p)
p = map;
else
p++;
if(!p->name)
if (!p->name)
p = nsnull;
else
{
if(rv)
if (rv)
*rv = p->rv;
if(name)
if (name)
*name = p->name;
if(format)
if (format)
*format = p->format;
}
*iterp = p;
@ -159,7 +159,7 @@ nsXPCException::~nsXPCException()
NS_IMETHODIMP
nsXPCException::StealJSVal(jsval *vp NS_OUTPARAM)
{
if(mThrownJSVal.IsHeld())
if (mThrownJSVal.IsHeld())
{
*vp = mThrownJSVal.Release();
return NS_OK;
@ -171,7 +171,7 @@ nsXPCException::StealJSVal(jsval *vp NS_OUTPARAM)
NS_IMETHODIMP
nsXPCException::StowJSVal(JSContext* cx, jsval v)
{
if(mThrownJSVal.Hold(cx))
if (mThrownJSVal.Hold(cx))
{
mThrownJSVal = v;
return NS_OK;
@ -182,17 +182,17 @@ nsXPCException::StowJSVal(JSContext* cx, jsval v)
void
nsXPCException::Reset()
{
if(mMessage)
if (mMessage)
{
nsMemory::Free(mMessage);
mMessage = nsnull;
}
if(mName)
if (mName)
{
nsMemory::Free(mName);
mName = nsnull;
}
if(mFilename)
if (mFilename)
{
nsMemory::Free(mFilename);
mFilename = nsnull;
@ -207,7 +207,7 @@ nsXPCException::Reset()
NS_IMETHODIMP
nsXPCException::GetMessageMoz(char * *aMessage)
{
if(!mInitialized)
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
XPC_STRING_GETTER_BODY(aMessage, mMessage);
}
@ -216,9 +216,9 @@ nsXPCException::GetMessageMoz(char * *aMessage)
NS_IMETHODIMP
nsXPCException::GetResult(nsresult *aResult)
{
if(!aResult)
if (!aResult)
return NS_ERROR_NULL_POINTER;
if(!mInitialized)
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
*aResult = mResult;
return NS_OK;
@ -228,11 +228,11 @@ nsXPCException::GetResult(nsresult *aResult)
NS_IMETHODIMP
nsXPCException::GetName(char * *aName)
{
if(!mInitialized)
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
const char* name = mName;
if(!name)
if (!name)
NameAndFormatForNSResult(mResult, &name, nsnull);
XPC_STRING_GETTER_BODY(aName, name);
@ -241,7 +241,7 @@ nsXPCException::GetName(char * *aName)
/* readonly attribute string filename; */
NS_IMETHODIMP nsXPCException::GetFilename(char * *aFilename)
{
if(!mInitialized)
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
XPC_STRING_GETTER_BODY(aFilename, mFilename);
}
@ -249,9 +249,9 @@ NS_IMETHODIMP nsXPCException::GetFilename(char * *aFilename)
/* readonly attribute PRUint32 lineNumber; */
NS_IMETHODIMP nsXPCException::GetLineNumber(PRUint32 *aLineNumber)
{
if(!aLineNumber)
if (!aLineNumber)
return NS_ERROR_NULL_POINTER;
if(!mInitialized)
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
*aLineNumber = mLineNumber;
return NS_OK;
@ -261,7 +261,7 @@ NS_IMETHODIMP nsXPCException::GetLineNumber(PRUint32 *aLineNumber)
NS_IMETHODIMP nsXPCException::GetColumnNumber(PRUint32 *aColumnNumber)
{
NS_ENSURE_ARG_POINTER(aColumnNumber);
if(!mInitialized)
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
*aColumnNumber = 0;
return NS_OK;
@ -271,9 +271,9 @@ NS_IMETHODIMP nsXPCException::GetColumnNumber(PRUint32 *aColumnNumber)
NS_IMETHODIMP
nsXPCException::GetLocation(nsIStackFrame * *aLocation)
{
if(!aLocation)
if (!aLocation)
return NS_ERROR_NULL_POINTER;
if(!mInitialized)
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
*aLocation = mLocation;
NS_IF_ADDREF(mLocation);
@ -284,9 +284,9 @@ nsXPCException::GetLocation(nsIStackFrame * *aLocation)
NS_IMETHODIMP
nsXPCException::GetData(nsISupports * *aData)
{
if(!aData)
if (!aData)
return NS_ERROR_NULL_POINTER;
if(!mInitialized)
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
*aData = mData;
NS_IF_ADDREF(mData);
@ -297,9 +297,9 @@ nsXPCException::GetData(nsISupports * *aData)
NS_IMETHODIMP
nsXPCException::GetInner(nsIException* *aException)
{
if(!aException)
if (!aException)
return NS_ERROR_NULL_POINTER;
if(!mInitialized)
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
*aException = mInner;
NS_IF_ADDREF(mInner);
@ -310,56 +310,56 @@ nsXPCException::GetInner(nsIException* *aException)
NS_IMETHODIMP
nsXPCException::Initialize(const char *aMessage, nsresult aResult, const char *aName, nsIStackFrame *aLocation, nsISupports *aData, nsIException *aInner)
{
if(mInitialized)
if (mInitialized)
return NS_ERROR_ALREADY_INITIALIZED;
Reset();
if(aMessage)
if (aMessage)
{
if(!(mMessage = (char*) nsMemory::Clone(aMessage,
sizeof(char)*(strlen(aMessage)+1))))
if (!(mMessage = (char*) nsMemory::Clone(aMessage,
sizeof(char)*(strlen(aMessage)+1))))
return NS_ERROR_OUT_OF_MEMORY;
}
if(aName)
if (aName)
{
if(!(mName = (char*) nsMemory::Clone(aName,
sizeof(char)*(strlen(aName)+1))))
if (!(mName = (char*) nsMemory::Clone(aName,
sizeof(char)*(strlen(aName)+1))))
return NS_ERROR_OUT_OF_MEMORY;
}
mResult = aResult;
if(aLocation)
if (aLocation)
{
mLocation = aLocation;
NS_ADDREF(mLocation);
// For now, fill in our location details from our stack frame.
// Later we may allow other locations?
nsresult rc;
if(NS_FAILED(rc = aLocation->GetFilename(&mFilename)))
if (NS_FAILED(rc = aLocation->GetFilename(&mFilename)))
return rc;
if(NS_FAILED(rc = aLocation->GetLineNumber(&mLineNumber)))
if (NS_FAILED(rc = aLocation->GetLineNumber(&mLineNumber)))
return rc;
}
else
{
nsresult rv;
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
if(!xpc)
if (!xpc)
return NS_ERROR_FAILURE;
rv = xpc->GetCurrentJSStack(&mLocation);
if(NS_FAILED(rv))
if (NS_FAILED(rv))
return rv;
}
if(aData)
if (aData)
{
mData = aData;
NS_ADDREF(mData);
}
if(aInner)
if (aInner)
{
mInner = aInner;
NS_ADDREF(mInner);
@ -373,9 +373,9 @@ nsXPCException::Initialize(const char *aMessage, nsresult aResult, const char *a
NS_IMETHODIMP
nsXPCException::ToString(char **_retval)
{
if(!_retval)
if (!_retval)
return NS_ERROR_NULL_POINTER;
if(!mInitialized)
if (!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
static const char defaultMsg[] = "<no message>";
@ -385,11 +385,11 @@ nsXPCException::ToString(char **_retval)
char* indicatedLocation = nsnull;
if(mLocation)
if (mLocation)
{
// we need to free this if it does not fail
nsresult rv = mLocation->ToString(&indicatedLocation);
if(NS_FAILED(rv))
if (NS_FAILED(rv))
return rv;
}
@ -397,21 +397,21 @@ nsXPCException::ToString(char **_retval)
const char* location = indicatedLocation ?
indicatedLocation : defaultLocation;
const char* resultName = mName;
if(!resultName && !NameAndFormatForNSResult(mResult, &resultName,
(!msg) ? &msg : nsnull))
if (!resultName && !NameAndFormatForNSResult(mResult, &resultName,
(!msg) ? &msg : nsnull))
{
if(!msg)
if (!msg)
msg = defaultMsg;
resultName = "<unknown>";
}
const char* data = mData ? "yes" : "no";
char* temp = JS_smprintf(format, msg, mResult, resultName, location, data);
if(indicatedLocation)
if (indicatedLocation)
nsMemory::Free(indicatedLocation);
char* final = nsnull;
if(temp)
if (temp)
{
final = (char*) nsMemory::Clone(temp, sizeof(char)*(strlen(temp)+1));
JS_smprintf_free(temp);
@ -438,7 +438,7 @@ nsXPCException::NewException(const char *aMessage,
// This is bad because it means that wrapped exceptions will never have a
// shared prototype. So... We force one to be created via the factory
// *once* and then go about our business.
if(!sEverMadeOneFromFactory)
if (!sEverMadeOneFromFactory)
{
nsCOMPtr<nsIXPCException> e =
do_CreateInstance(XPC_EXCEPTION_CONTRACTID);
@ -447,12 +447,12 @@ nsXPCException::NewException(const char *aMessage,
nsresult rv;
nsXPCException* e = new nsXPCException();
if(e)
if (e)
{
NS_ADDREF(e);
nsIStackFrame* location;
if(aLocation)
if (aLocation)
{
location = aLocation;
NS_ADDREF(location);
@ -460,13 +460,13 @@ nsXPCException::NewException(const char *aMessage,
else
{
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
if(!xpc)
if (!xpc)
{
NS_RELEASE(e);
return NS_ERROR_FAILURE;
}
rv = xpc->GetCurrentJSStack(&location);
if(NS_FAILED(rv))
if (NS_FAILED(rv))
{
NS_RELEASE(e);
return NS_ERROR_FAILURE;
@ -478,20 +478,20 @@ nsXPCException::NewException(const char *aMessage,
// components are implemented in JS.
}
// We want to trim off any leading native 'dataless' frames
if(location)
while(1)
if (location)
while (1)
{
PRUint32 language;
PRInt32 lineNumber;
if(NS_FAILED(location->GetLanguage(&language)) ||
language == nsIProgrammingLanguage::JAVASCRIPT ||
NS_FAILED(location->GetLineNumber(&lineNumber)) ||
lineNumber)
if (NS_FAILED(location->GetLanguage(&language)) ||
language == nsIProgrammingLanguage::JAVASCRIPT ||
NS_FAILED(location->GetLineNumber(&lineNumber)) ||
lineNumber)
{
break;
}
nsCOMPtr<nsIStackFrame> caller;
if(NS_FAILED(location->GetCaller(getter_AddRefs(caller))) || !caller)
if (NS_FAILED(location->GetCaller(getter_AddRefs(caller))) || !caller)
break;
NS_RELEASE(location);
caller->QueryInterface(NS_GET_IID(nsIStackFrame), (void **)&location);
@ -500,11 +500,11 @@ nsXPCException::NewException(const char *aMessage,
// or no location at all
rv = e->Initialize(aMessage, aResult, nsnull, location, aData, nsnull);
NS_IF_RELEASE(location);
if(NS_FAILED(rv))
if (NS_FAILED(rv))
NS_RELEASE(e);
}
if(!e)
if (!e)
return NS_ERROR_FAILURE;
*exceptn = static_cast<nsIXPCException*>(e);

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

@ -50,13 +50,13 @@
bool
xpc::PtrAndPrincipalHashKey::KeyEquals(const PtrAndPrincipalHashKey* aKey) const
{
if(aKey->mPtr != mPtr)
if (aKey->mPtr != mPtr)
return PR_FALSE;
if(aKey->mPrincipal == mPrincipal)
if (aKey->mPrincipal == mPrincipal)
return PR_TRUE;
bool equals;
if(NS_FAILED(mPrincipal->EqualsIgnoringDomain(aKey->mPrincipal, &equals)))
if (NS_FAILED(mPrincipal->EqualsIgnoringDomain(aKey->mPrincipal, &equals)))
{
NS_ERROR("we failed, guessing!");
return PR_FALSE;
@ -181,7 +181,7 @@ inline nsISupports*
XPCCallContext::GetIdentityObject() const
{
CHECK_STATE(HAVE_OBJECT);
if(mWrapper)
if (mWrapper)
return mWrapper->GetIdentityObject();
return mFlattenedJSObject ?
static_cast<nsISupports*>(xpc_GetJSPrivate(mFlattenedJSObject)) :
@ -191,7 +191,7 @@ XPCCallContext::GetIdentityObject() const
inline XPCWrappedNative*
XPCCallContext::GetWrapper() const
{
if(mState == INIT_FAILED)
if (mState == INIT_FAILED)
return nsnull;
CHECK_STATE(HAVE_OBJECT);
@ -202,7 +202,7 @@ inline XPCWrappedNativeProto*
XPCCallContext::GetProto() const
{
CHECK_STATE(HAVE_OBJECT);
if(mWrapper)
if (mWrapper)
return mWrapper->GetProto();
return mFlattenedJSObject ? GetSlimWrapperProto(mFlattenedJSObject) : nsnull;
}
@ -312,7 +312,7 @@ inline void
XPCCallContext::SetRetVal(jsval val)
{
CHECK_STATE(HAVE_ARGS);
if(mRetVal)
if (mRetVal)
*mRetVal = val;
}
@ -392,8 +392,8 @@ inline XPCNativeMember*
XPCNativeInterface::FindMember(jsid name) const
{
const XPCNativeMember* member = mMembers;
for(int i = (int) mMemberCount; i > 0; i--, member++)
if(member->GetName() == name)
for (int i = (int) mMemberCount; i > 0; i--, member++)
if (member->GetName() == name)
return const_cast<XPCNativeMember*>(member);
return nsnull;
}
@ -418,27 +418,27 @@ XPCNativeSet::FindMember(jsid name, XPCNativeMember** pMember,
// look for interface names first
for(i = 0, iface = mInterfaces; i < count; i++, iface++)
for (i = 0, iface = mInterfaces; i < count; i++, iface++)
{
if(name == (*iface)->GetName())
if (name == (*iface)->GetName())
{
if(pMember)
if (pMember)
*pMember = nsnull;
if(pInterfaceIndex)
if (pInterfaceIndex)
*pInterfaceIndex = (PRUint16) i;
return JS_TRUE;
}
}
// look for method names
for(i = 0, iface = mInterfaces; i < count; i++, iface++)
for (i = 0, iface = mInterfaces; i < count; i++, iface++)
{
XPCNativeMember* member = (*iface)->FindMember(name);
if(member)
if (member)
{
if(pMember)
if (pMember)
*pMember = member;
if(pInterfaceIndex)
if (pInterfaceIndex)
*pInterfaceIndex = (PRUint16) i;
return JS_TRUE;
}
@ -451,7 +451,7 @@ XPCNativeSet::FindMember(jsid name, XPCNativeMember** pMember,
XPCNativeInterface** pInterface) const
{
PRUint16 index;
if(!FindMember(name, pMember, &index))
if (!FindMember(name, pMember, &index))
return JS_FALSE;
*pInterface = mInterfaces[index];
return JS_TRUE;
@ -468,7 +468,7 @@ XPCNativeSet::FindMember(jsid name,
XPCNativeInterface* Interface;
XPCNativeMember* protoMember;
if(!FindMember(name, &Member, &Interface))
if (!FindMember(name, &Member, &Interface))
return JS_FALSE;
*pMember = Member;
@ -490,11 +490,11 @@ XPCNativeSet::FindNamedInterface(jsid name) const
{
XPCNativeInterface* const * pp = mInterfaces;
for(int i = (int) mInterfaceCount; i > 0; i--, pp++)
for (int i = (int) mInterfaceCount; i > 0; i--, pp++)
{
XPCNativeInterface* iface = *pp;
if(name == iface->GetName())
if (name == iface->GetName())
return iface;
}
return nsnull;
@ -505,11 +505,11 @@ XPCNativeSet::FindInterfaceWithIID(const nsIID& iid) const
{
XPCNativeInterface* const * pp = mInterfaces;
for(int i = (int) mInterfaceCount; i > 0; i--, pp++)
for (int i = (int) mInterfaceCount; i > 0; i--, pp++)
{
XPCNativeInterface* iface = *pp;
if(iface->GetIID()->Equals(iid))
if (iface->GetIID()->Equals(iid))
return iface;
}
return nsnull;
@ -520,9 +520,9 @@ XPCNativeSet::HasInterface(XPCNativeInterface* aInterface) const
{
XPCNativeInterface* const * pp = mInterfaces;
for(int i = (int) mInterfaceCount; i > 0; i--, pp++)
for (int i = (int) mInterfaceCount; i > 0; i--, pp++)
{
if(aInterface == *pp)
if (aInterface == *pp)
return JS_TRUE;
}
return JS_FALSE;
@ -539,12 +539,12 @@ XPCNativeSet::HasInterfaceWithAncestor(const nsIID* iid) const
{
// We can safely skip the first interface which is *always* nsISupports.
XPCNativeInterface* const * pp = mInterfaces+1;
for(int i = (int) mInterfaceCount; i > 1; i--, pp++)
if((*pp)->HasAncestor(iid))
for (int i = (int) mInterfaceCount; i > 1; i--, pp++)
if ((*pp)->HasAncestor(iid))
return JS_TRUE;
// This is rare, so check last.
if(iid == &NS_GET_IID(nsISupports))
if (iid == &NS_GET_IID(nsISupports))
return PR_TRUE;
return JS_FALSE;
@ -559,12 +559,12 @@ XPCNativeSet::MatchesSetUpToInterface(const XPCNativeSet* other,
XPCNativeInterface* const * pp1 = mInterfaces;
XPCNativeInterface* const * pp2 = other->mInterfaces;
for(int i = (int) count; i > 0; i--, pp1++, pp2++)
for (int i = (int) count; i > 0; i--, pp1++, pp2++)
{
XPCNativeInterface* cur = (*pp1);
if(cur != (*pp2))
if (cur != (*pp2))
return JS_FALSE;
if(cur == iface)
if (cur == iface)
return JS_TRUE;
}
return JS_FALSE;
@ -572,12 +572,12 @@ XPCNativeSet::MatchesSetUpToInterface(const XPCNativeSet* other,
inline void XPCNativeSet::Mark()
{
if(IsMarked())
if (IsMarked())
return;
XPCNativeInterface* const * pp = mInterfaces;
for(int i = (int) mInterfaceCount; i > 0; i--, pp++)
for (int i = (int) mInterfaceCount; i > 0; i--, pp++)
(*pp)->Mark();
MarkSelfOnly();
@ -590,7 +590,7 @@ inline void XPCNativeSet::ASSERT_NotMarked()
XPCNativeInterface* const * pp = mInterfaces;
for(int i = (int) mInterfaceCount; i > 0; i--, pp++)
for (int i = (int) mInterfaceCount; i > 0; i--, pp++)
NS_ASSERTION(!(*pp)->IsMarked(), "bad");
}
#endif
@ -627,22 +627,22 @@ inline void
XPCWrappedNative::SweepTearOffs()
{
XPCWrappedNativeTearOffChunk* chunk;
for(chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk)
for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk)
{
XPCWrappedNativeTearOff* to = chunk->mTearOffs;
for(int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK; i > 0; i--, to++)
for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK; i > 0; i--, to++)
{
JSBool marked = to->IsMarked();
to->Unmark();
if(marked)
if (marked)
continue;
// If this tearoff does not have a live dedicated JSObject,
// then let's recycle it.
if(!to->GetJSObject())
if (!to->GetJSObject())
{
nsISupports* obj = to->GetNative();
if(obj)
if (obj)
{
obj->Release();
to->SetNative(nsnull);
@ -660,7 +660,7 @@ xpc_ForcePropertyResolve(JSContext* cx, JSObject* obj, jsid id)
{
jsval prop;
if(!JS_LookupPropertyById(cx, obj, id, &prop))
if (!JS_LookupPropertyById(cx, obj, id, &prop))
return JS_FALSE;
return JS_TRUE;
}
@ -719,7 +719,7 @@ XPCLazyCallContext::SetWrapper(XPCWrappedNative* wrapper,
{
mWrapper = wrapper;
mTearOff = tearoff;
if(mTearOff)
if (mTearOff)
mFlattenedJSObject = mTearOff->GetJSObject();
else
mFlattenedJSObject = mWrapper->GetFlatJSObject();

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

@ -57,9 +57,9 @@ nsJSID::nsJSID()
nsJSID::~nsJSID()
{
if(mNumber && mNumber != gNoString)
if (mNumber && mNumber != gNoString)
NS_Free(mNumber);
if(mName && mName != gNoString)
if (mName && mName != gNoString)
NS_Free(mName);
}
@ -67,9 +67,9 @@ void nsJSID::Reset()
{
mID = GetInvalidIID();
if(mNumber && mNumber != gNoString)
if (mNumber && mNumber != gNoString)
NS_Free(mNumber);
if(mName && mName != gNoString)
if (mName && mName != gNoString)
NS_Free(mName);
mNumber = mName = nsnull;
@ -87,10 +87,10 @@ nsJSID::SetName(const char* name)
NS_IMETHODIMP
nsJSID::GetName(char * *aName)
{
if(!aName)
if (!aName)
return NS_ERROR_NULL_POINTER;
if(!NameIsSet())
if (!NameIsSet())
SetNameToNoString();
NS_ASSERTION(mName, "name not set");
*aName = NS_strdup(mName);
@ -100,12 +100,12 @@ nsJSID::GetName(char * *aName)
NS_IMETHODIMP
nsJSID::GetNumber(char * *aNumber)
{
if(!aNumber)
if (!aNumber)
return NS_ERROR_NULL_POINTER;
if(!mNumber)
if (!mNumber)
{
if(!(mNumber = mID.ToString()))
if (!(mNumber = mID.ToString()))
mNumber = gNoString;
}
@ -122,7 +122,7 @@ nsJSID::GetID()
NS_IMETHODIMP
nsJSID::GetValid(bool *aValid)
{
if(!aValid)
if (!aValid)
return NS_ERROR_NULL_POINTER;
*aValid = IsValid();
@ -132,10 +132,10 @@ nsJSID::GetValid(bool *aValid)
NS_IMETHODIMP
nsJSID::Equals(nsIJSID *other, bool *_retval)
{
if(!_retval)
if (!_retval)
return NS_ERROR_NULL_POINTER;
if(!other || mID.Equals(GetInvalidIID()))
if (!other || mID.Equals(GetInvalidIID()))
{
*_retval = PR_FALSE;
return NS_OK;
@ -148,16 +148,16 @@ nsJSID::Equals(nsIJSID *other, bool *_retval)
NS_IMETHODIMP
nsJSID::Initialize(const char *idString)
{
if(!idString)
if (!idString)
return NS_ERROR_NULL_POINTER;
if(*idString != '\0' && mID.Equals(GetInvalidIID()))
if (*idString != '\0' && mID.Equals(GetInvalidIID()))
{
Reset();
if(idString[0] == '{')
if (idString[0] == '{')
{
if(mID.Parse(idString))
if (mID.Parse(idString))
{
return NS_OK;
}
@ -182,7 +182,7 @@ nsJSID::InitWithName(const nsID& id, const char *nameString)
NS_IMETHODIMP
nsJSID::ToString(char **_retval)
{
if(mName && mName != gNoString)
if (mName && mName != gNoString)
return GetName(_retval);
return GetNumber(_retval);
@ -201,17 +201,17 @@ nsJSID::GetInvalidIID() const
nsJSID*
nsJSID::NewID(const char* str)
{
if(!str)
if (!str)
{
NS_ERROR("no string");
return nsnull;
}
nsJSID* idObj = new nsJSID();
if(idObj)
if (idObj)
{
NS_ADDREF(idObj);
if(NS_FAILED(idObj->Initialize(str)))
if (NS_FAILED(idObj->Initialize(str)))
NS_RELEASE(idObj);
}
return idObj;
@ -222,7 +222,7 @@ nsJSID*
nsJSID::NewID(const nsID& id)
{
nsJSID* idObj = new nsJSID();
if(idObj)
if (idObj)
{
NS_ADDREF(idObj);
idObj->mID = id;
@ -272,7 +272,7 @@ static nsIXPCScriptable* gSharedScriptableHelperForJSIID;
NS_METHOD GetSharedScriptableHelperForJSIID(PRUint32 language,
nsISupports **helper)
{
if(language == nsIProgrammingLanguage::JAVASCRIPT)
if (language == nsIProgrammingLanguage::JAVASCRIPT)
{
NS_IF_ADDREF(gSharedScriptableHelperForJSIID);
*helper = gSharedScriptableHelperForJSIID;
@ -299,7 +299,7 @@ NS_IMPL_CLASSINFO(nsJSCID, NULL, nsIClassInfo::THREADSAFE, NULL_CID)
void xpc_InitJSxIDClassObjects()
{
if(!gClassObjectsWereInited) {
if (!gClassObjectsWereInited) {
gSharedScriptableHelperForJSIID = new SharedScriptableHelperForJSIID();
NS_ADDREF(gSharedScriptableHelperForJSIID);
}
@ -380,10 +380,10 @@ NS_IMETHODIMP nsJSIID::GetValid(bool *aValid)
NS_IMETHODIMP nsJSIID::Equals(nsIJSID *other, bool *_retval)
{
if(!_retval)
if (!_retval)
return NS_ERROR_NULL_POINTER;
if(!other)
if (!other)
{
*_retval = PR_FALSE;
return NS_OK;
@ -407,14 +407,14 @@ NS_IMETHODIMP nsJSIID::ToString(char **_retval)
nsJSIID*
nsJSIID::NewID(nsIInterfaceInfo* aInfo)
{
if(!aInfo)
if (!aInfo)
{
NS_ERROR("no info");
return nsnull;
}
bool canScript;
if(NS_FAILED(aInfo->IsScriptable(&canScript)) || !canScript)
if (NS_FAILED(aInfo->IsScriptable(&canScript)) || !canScript)
return nsnull;
nsJSIID* idObj = new nsJSIID(aInfo);
@ -439,14 +439,14 @@ nsJSIID::NewResolve(nsIXPConnectWrappedNative *wrapper,
iface = XPCNativeInterface::GetNewOrUsed(ccx, iid);
if(!iface)
if (!iface)
return NS_OK;
XPCNativeMember* member = iface->FindMember(id);
if(member && member->IsConstant())
if (member && member->IsConstant())
{
jsval val;
if(!member->GetConstantValue(ccx, iface, &val))
if (!member->GetConstantValue(ccx, iface, &val))
return NS_ERROR_OUT_OF_MEMORY;
*objp = obj;
@ -474,15 +474,15 @@ nsJSIID::Enumerate(nsIXPConnectWrappedNative *wrapper,
iface = XPCNativeInterface::GetNewOrUsed(ccx, iid);
if(!iface)
if (!iface)
return NS_OK;
PRUint16 count = iface->GetMemberCount();
for(PRUint16 i = 0; i < count; i++)
for (PRUint16 i = 0; i < count; i++)
{
XPCNativeMember* member = iface->GetMemberAt(i);
if(member && member->IsConstant() &&
!xpc_ForcePropertyResolve(cx, obj, member->GetName()))
if (member && member->IsConstant() &&
!xpc_ForcePropertyResolve(cx, obj, member->GetName()))
{
return NS_ERROR_UNEXPECTED;
}
@ -499,7 +499,7 @@ nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
*bp = JS_FALSE;
nsresult rv = NS_OK;
if(!JSVAL_IS_PRIMITIVE(val))
if (!JSVAL_IS_PRIMITIVE(val))
{
// we have a JSObject
JSObject* obj = JSVAL_TO_OBJECT(val);
@ -510,10 +510,10 @@ nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
const nsIID* iid;
mInfo->GetIIDShared(&iid);
if(IS_SLIM_WRAPPER(obj))
if (IS_SLIM_WRAPPER(obj))
{
XPCWrappedNativeProto* proto = GetSlimWrapperProto(obj);
if(proto->GetSet()->HasInterfaceWithAncestor(iid))
if (proto->GetSet()->HasInterfaceWithAncestor(iid))
{
*bp = JS_TRUE;
return NS_OK;
@ -524,7 +524,7 @@ nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
iid->ToProvidedString(foo);
SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, foo);
#endif
if(!MorphSlimWrapper(cx, obj))
if (!MorphSlimWrapper(cx, obj))
return NS_ERROR_FAILURE;
}
@ -538,7 +538,7 @@ nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
AutoMarkingNativeSetPtr set(ccx);
set = XPCNativeSet::GetNewOrUsed(ccx, ci);
if(!set)
if (!set)
return NS_ERROR_FAILURE;
*bp = set->HasInterfaceWithAncestor(iid);
return NS_OK;
@ -547,13 +547,13 @@ nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
XPCWrappedNative* other_wrapper =
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
if(!other_wrapper)
if (!other_wrapper)
return NS_OK;
// We'll trust the interface set of the wrapper if this is known
// to be an interface that the objects *expects* to be able to
// handle.
if(other_wrapper->HasInterfaceNoQI(*iid))
if (other_wrapper->HasInterfaceNoQI(*iid))
{
*bp = JS_TRUE;
return NS_OK;
@ -566,7 +566,7 @@ nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
iface = XPCNativeInterface::GetNewOrUsed(ccx, iid);
nsresult findResult = NS_OK;
if(iface && other_wrapper->FindTearOff(ccx, iface, JS_FALSE, &findResult))
if (iface && other_wrapper->FindTearOff(ccx, iface, JS_FALSE, &findResult))
*bp = JS_TRUE;
if (NS_FAILED(findResult) && findResult != NS_ERROR_NO_INTERFACE)
rv = findResult;
@ -660,7 +660,7 @@ NS_IMETHODIMP nsJSCID::ToString(char **_retval)
void
nsJSCID::ResolveName()
{
if(!mDetails.NameIsSet())
if (!mDetails.NameIsSet())
mDetails.SetNameToNoString();
}
@ -668,21 +668,21 @@ nsJSCID::ResolveName()
nsJSCID*
nsJSCID::NewID(const char* str)
{
if(!str)
if (!str)
{
NS_ERROR("no string");
return nsnull;
}
nsJSCID* idObj = new nsJSCID();
if(idObj)
if (idObj)
{
bool success = false;
NS_ADDREF(idObj);
if(str[0] == '{')
if (str[0] == '{')
{
if(NS_SUCCEEDED(idObj->Initialize(str)))
if (NS_SUCCEEDED(idObj->Initialize(str)))
success = PR_TRUE;
}
else
@ -692,14 +692,14 @@ nsJSCID::NewID(const char* str)
if (registrar)
{
nsCID *cid;
if(NS_SUCCEEDED(registrar->ContractIDToCID(str, &cid)))
if (NS_SUCCEEDED(registrar->ContractIDToCID(str, &cid)))
{
success = idObj->mDetails.InitWithName(*cid, str);
nsMemory::Free(cid);
}
}
}
if(!success)
if (!success)
NS_RELEASE(idObj);
}
return idObj;
@ -711,13 +711,13 @@ GetIIDArg(PRUint32 argc, jsval* argv, JSContext* cx)
const nsID* iid;
// If an IID was passed in then use it
if(argc)
if (argc)
{
JSObject* iidobj;
jsval val = *argv;
if(JSVAL_IS_PRIMITIVE(val) ||
!(iidobj = JSVAL_TO_OBJECT(val)) ||
!(iid = xpc_JSObjectToID(cx, iidobj)))
if (JSVAL_IS_PRIMITIVE(val) ||
!(iidobj = JSVAL_TO_OBJECT(val)) ||
!(iid = xpc_JSObjectToID(cx, iidobj)))
{
return nsnull;
}
@ -732,16 +732,16 @@ GetIIDArg(PRUint32 argc, jsval* argv, JSContext* cx)
NS_IMETHODIMP
nsJSCID::CreateInstance(nsISupports **_retval)
{
if(!mDetails.IsValid())
if (!mDetails.IsValid())
return NS_ERROR_XPC_BAD_CID;
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
if(!xpc)
if (!xpc)
return NS_ERROR_UNEXPECTED;
nsAXPCNativeCallContext *ccxp = nsnull;
xpc->GetCurrentNativeCallContext(&ccxp);
if(!ccxp)
if (!ccxp)
return NS_ERROR_UNEXPECTED;
PRUint32 argc;
@ -765,7 +765,7 @@ nsJSCID::CreateInstance(nsISupports **_retval)
nsIXPCSecurityManager* sm;
sm = xpcc->GetAppropriateSecurityManager(nsIXPCSecurityManager::HOOK_CREATE_INSTANCE);
if(sm && NS_FAILED(sm->CanCreateInstance(cx, mDetails.ID())))
if (sm && NS_FAILED(sm->CanCreateInstance(cx, mDetails.ID())))
{
NS_ERROR("how are we not being called from chrome here?");
return NS_OK;
@ -785,11 +785,11 @@ nsJSCID::CreateInstance(nsISupports **_retval)
rv = compMgr->CreateInstance(mDetails.ID(), nsnull, *iid, getter_AddRefs(inst));
NS_ASSERTION(NS_FAILED(rv) || inst, "component manager returned success, but instance is null!");
if(NS_FAILED(rv) || !inst)
if (NS_FAILED(rv) || !inst)
return NS_ERROR_XPC_CI_RETURNED_FAILURE;
rv = xpc->WrapNativeToJSVal(cx, obj, inst, nsnull, iid, PR_TRUE, vp, nsnull);
if(NS_FAILED(rv) || JSVAL_IS_PRIMITIVE(*vp))
if (NS_FAILED(rv) || JSVAL_IS_PRIMITIVE(*vp))
return NS_ERROR_XPC_CANT_CREATE_WN;
ccxp->SetReturnValueWasSet(JS_TRUE);
return NS_OK;
@ -799,16 +799,16 @@ nsJSCID::CreateInstance(nsISupports **_retval)
NS_IMETHODIMP
nsJSCID::GetService(nsISupports **_retval)
{
if(!mDetails.IsValid())
if (!mDetails.IsValid())
return NS_ERROR_XPC_BAD_CID;
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
if(!xpc)
if (!xpc)
return NS_ERROR_UNEXPECTED;
nsAXPCNativeCallContext *ccxp = nsnull;
xpc->GetCurrentNativeCallContext(&ccxp);
if(!ccxp)
if (!ccxp)
return NS_ERROR_UNEXPECTED;
PRUint32 argc;
@ -832,7 +832,7 @@ nsJSCID::GetService(nsISupports **_retval)
nsIXPCSecurityManager* sm;
sm = xpcc->GetAppropriateSecurityManager(nsIXPCSecurityManager::HOOK_GET_SERVICE);
if(sm && NS_FAILED(sm->CanCreateInstance(cx, mDetails.ID())))
if (sm && NS_FAILED(sm->CanCreateInstance(cx, mDetails.ID())))
{
NS_ASSERTION(JS_IsExceptionPending(cx),
"security manager vetoed GetService without setting exception");
@ -852,13 +852,13 @@ nsJSCID::GetService(nsISupports **_retval)
nsCOMPtr<nsISupports> srvc;
rv = svcMgr->GetService(mDetails.ID(), *iid, getter_AddRefs(srvc));
NS_ASSERTION(NS_FAILED(rv) || srvc, "service manager returned success, but service is null!");
if(NS_FAILED(rv) || !srvc)
if (NS_FAILED(rv) || !srvc)
return NS_ERROR_XPC_GS_RETURNED_FAILURE;
JSObject* instJSObj;
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->WrapNative(cx, obj, srvc, *iid, getter_AddRefs(holder));
if(NS_FAILED(rv) || !holder || NS_FAILED(holder->GetJSObject(&instJSObj)))
if (NS_FAILED(rv) || !holder || NS_FAILED(holder->GetJSObject(&instJSObj)))
return NS_ERROR_XPC_CANT_CREATE_WN;
*vp = OBJECT_TO_JSVAL(instJSObj);
@ -874,7 +874,7 @@ nsJSCID::Construct(nsIXPConnectWrappedNative *wrapper,
bool *_retval)
{
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
if(!rt)
if (!rt)
return NS_ERROR_FAILURE;
// 'push' a call context and call on it
@ -895,7 +895,7 @@ nsJSCID::HasInstance(nsIXPConnectWrappedNative *wrapper,
*bp = JS_FALSE;
nsresult rv = NS_OK;
if(!JSVAL_IS_PRIMITIVE(val))
if (!JSVAL_IS_PRIMITIVE(val))
{
// we have a JSObject
JSObject* obj = JSVAL_TO_OBJECT(val);
@ -907,7 +907,7 @@ nsJSCID::HasInstance(nsIXPConnectWrappedNative *wrapper,
XPCWrappedNative* other_wrapper =
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj, nsnull, &obj2);
if(!other_wrapper && !obj2)
if (!other_wrapper && !obj2)
return NS_OK;
nsIClassInfo* ci = other_wrapper ?
@ -916,10 +916,10 @@ nsJSCID::HasInstance(nsIXPConnectWrappedNative *wrapper,
// We consider CID equality to be the thing that matters here.
// This is perhaps debatable.
if(ci)
if (ci)
{
nsID cid;
if(NS_SUCCEEDED(ci->GetClassIDNoAlloc(&cid)))
if (NS_SUCCEEDED(ci->GetClassIDNoAlloc(&cid)))
*bp = cid.Equals(mDetails.ID());
}
}
@ -936,17 +936,17 @@ xpc_NewIDObject(JSContext *cx, JSObject* jsobj, const nsID& aID)
nsCOMPtr<nsIJSID> iid =
dont_AddRef(static_cast<nsIJSID*>(nsJSID::NewID(aID)));
if(iid)
if (iid)
{
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
if(xpc)
if (xpc)
{
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
nsresult rv = xpc->WrapNative(cx, jsobj,
static_cast<nsISupports*>(iid),
NS_GET_IID(nsIJSID),
getter_AddRefs(holder));
if(NS_SUCCEEDED(rv) && holder)
if (NS_SUCCEEDED(rv) && holder)
{
holder->GetJSObject(&obj);
}
@ -959,16 +959,16 @@ xpc_NewIDObject(JSContext *cx, JSObject* jsobj, const nsID& aID)
const nsID*
xpc_JSObjectToID(JSContext *cx, JSObject* obj)
{
if(!cx || !obj)
if (!cx || !obj)
return nsnull;
// NOTE: this call does NOT addref
XPCWrappedNative* wrapper =
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
if(wrapper &&
(wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSID)) ||
wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSIID)) ||
wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSCID))))
if (wrapper &&
(wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSID)) ||
wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSIID)) ||
wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSCID))))
{
return ((nsIJSID*)wrapper->GetIdentityObject())->GetID();
}

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

@ -106,14 +106,14 @@ WrappedJSDyingJSObjectFinder(JSDHashTable *table, JSDHashEntryHdr *hdr,
NS_ASSERTION(wrapper, "found a null JS wrapper!");
// walk the wrapper chain and find any whose JSObject is to be finalized
while(wrapper)
while (wrapper)
{
if(wrapper->IsSubjectToFinalization())
if (wrapper->IsSubjectToFinalization())
{
js::AutoSwitchCompartment sc(data->cx,
wrapper->GetJSObjectPreserveColor());
if(JS_IsAboutToBeFinalized(data->cx,
wrapper->GetJSObjectPreserveColor()))
if (JS_IsAboutToBeFinalized(data->cx,
wrapper->GetJSObjectPreserveColor()))
data->array->AppendElement(wrapper);
}
wrapper = wrapper->GetNextWrapper();
@ -132,7 +132,7 @@ NativeInterfaceSweeper(JSDHashTable *table, JSDHashEntryHdr *hdr,
uint32 number, void *arg)
{
XPCNativeInterface* iface = ((IID2NativeInterfaceMap::Entry*)hdr)->value;
if(iface->IsMarked())
if (iface->IsMarked())
{
iface->Unmark();
return JS_DHASH_NEXT;
@ -158,7 +158,7 @@ NativeUnMarkedSetRemover(JSDHashTable *table, JSDHashEntryHdr *hdr,
uint32 number, void *arg)
{
XPCNativeSet* set = ((ClassInfo2NativeSetMap::Entry*)hdr)->value;
if(set->IsMarked())
if (set->IsMarked())
return JS_DHASH_NEXT;
return JS_DHASH_REMOVE;
}
@ -168,7 +168,7 @@ NativeSetSweeper(JSDHashTable *table, JSDHashEntryHdr *hdr,
uint32 number, void *arg)
{
XPCNativeSet* set = ((NativeSetMap::Entry*)hdr)->key_value;
if(set->IsMarked())
if (set->IsMarked())
{
set->Unmark();
return JS_DHASH_NEXT;
@ -177,7 +177,7 @@ NativeSetSweeper(JSDHashTable *table, JSDHashEntryHdr *hdr,
#ifdef XPC_REPORT_NATIVE_INTERFACE_AND_SET_FLUSHING
printf("- Destroying XPCNativeSet for:\n");
PRUint16 count = set->GetInterfaceCount();
for(PRUint16 k = 0; k < count; k++)
for (PRUint16 k = 0; k < count; k++)
{
XPCNativeInterface* iface = set->GetInterfaceAt(k);
fputs(" ", stdout);
@ -196,7 +196,7 @@ JSClassSweeper(JSDHashTable *table, JSDHashEntryHdr *hdr,
{
XPCNativeScriptableShared* shared =
((XPCNativeScriptableSharedMap::Entry*) hdr)->key;
if(shared->IsMarked())
if (shared->IsMarked())
{
#ifdef off_XPC_REPORT_JSCLASS_FLUSHING
printf("+ Marked XPCNativeScriptableShared for: %s @ %x\n",
@ -243,14 +243,14 @@ static JSBool
ContextCallback(JSContext *cx, uintN operation)
{
XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance();
if(self)
if (self)
{
if(operation == JSCONTEXT_NEW)
if (operation == JSCONTEXT_NEW)
{
if(!self->OnJSContextNew(cx))
if (!self->OnJSContextNew(cx))
return JS_FALSE;
}
else if(operation == JSCONTEXT_DESTROY)
else if (operation == JSCONTEXT_DESTROY)
{
delete XPCContext::GetXPCContext(cx);
}
@ -269,14 +269,14 @@ CompartmentCallback(JSContext *cx, JSCompartment *compartment, uintN op)
JS_ASSERT(op == JSCOMPARTMENT_DESTROY);
XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance();
if(!self)
if (!self)
return JS_TRUE;
nsAutoPtr<xpc::CompartmentPrivate> priv(static_cast<xpc::CompartmentPrivate*>(JS_SetCompartmentPrivate(cx, compartment, nsnull)));
if(!priv)
if (!priv)
return JS_TRUE;
if(xpc::PtrAndPrincipalHashKey *key = priv->key)
if (xpc::PtrAndPrincipalHashKey *key = priv->key)
{
XPCCompartmentMap &map = self->GetCompartmentMap();
#ifdef DEBUG
@ -314,14 +314,14 @@ struct ObjectHolder : public JSDHashEntryHdr
nsresult
XPCJSRuntime::AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer)
{
if(!mJSHolders.ops)
if (!mJSHolders.ops)
return NS_ERROR_OUT_OF_MEMORY;
ObjectHolder *entry =
reinterpret_cast<ObjectHolder*>(JS_DHashTableOperate(&mJSHolders,
aHolder,
JS_DHASH_ADD));
if(!entry)
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;
entry->holder = aHolder;
@ -333,7 +333,7 @@ XPCJSRuntime::AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer)
nsresult
XPCJSRuntime::RemoveJSHolder(void* aHolder)
{
if(!mJSHolders.ops)
if (!mJSHolders.ops)
return NS_ERROR_OUT_OF_MEMORY;
JS_DHashTableOperate(&mJSHolders, aHolder, JS_DHASH_REMOVE);
@ -348,18 +348,18 @@ void XPCJSRuntime::TraceBlackJS(JSTracer* trc, void* data)
// Skip this part if XPConnect is shutting down. We get into
// bad locking problems with the thread iteration otherwise.
if(!self->GetXPConnect()->IsShuttingDown())
if (!self->GetXPConnect()->IsShuttingDown())
{
Mutex* threadLock = XPCPerThreadData::GetLock();
if(threadLock)
if (threadLock)
{ // scoped lock
MutexAutoLock lock(*threadLock);
XPCPerThreadData* iterp = nsnull;
XPCPerThreadData* thread;
while(nsnull != (thread =
XPCPerThreadData::IterateThreads(&iterp)))
while (nsnull != (thread =
XPCPerThreadData::IterateThreads(&iterp)))
{
// Trace those AutoMarkingPtr lists!
thread->TraceJS(trc);
@ -373,7 +373,7 @@ void XPCJSRuntime::TraceBlackJS(JSTracer* trc, void* data)
// XPCJSObjectHolders don't participate in cycle collection, so always
// trace them here.
XPCRootSetElem *e;
for(e = self->mObjectHolderRoots; e; e = e->GetNextRoot())
for (e = self->mObjectHolderRoots; e; e = e->GetNextRoot())
static_cast<XPCJSObjectHolder*>(e)->TraceJS(trc);
}
}
@ -391,7 +391,7 @@ static void
TraceJSObject(PRUint32 aLangID, void *aScriptThing, const char *name,
void *aClosure)
{
if(aLangID == nsIProgrammingLanguage::JAVASCRIPT)
if (aLangID == nsIProgrammingLanguage::JAVASCRIPT)
{
JS_CALL_TRACER(static_cast<JSTracer*>(aClosure), aScriptThing,
js_GetGCThingTraceKind(aScriptThing), name);
@ -418,7 +418,7 @@ struct ClearedGlobalObject : public JSDHashEntryHdr
static PLDHashOperator
TraceExpandos(XPCWrappedNative *wn, JSObject *&expando, void *aClosure)
{
if(wn->IsWrapperExpired())
if (wn->IsWrapperExpired())
return PL_DHASH_REMOVE;
JS_CALL_OBJECT_TRACER(static_cast<JSTracer *>(aClosure), expando, "expando object");
return PL_DHASH_NEXT;
@ -457,13 +457,13 @@ void XPCJSRuntime::TraceXPConnectRoots(JSTracer *trc)
XPCWrappedNativeScope::TraceJS(trc, this);
for(XPCRootSetElem *e = mVariantRoots; e ; e = e->GetNextRoot())
for (XPCRootSetElem *e = mVariantRoots; e ; e = e->GetNextRoot())
static_cast<XPCTraceableVariant*>(e)->TraceJS(trc);
for(XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot())
for (XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot())
static_cast<nsXPCWrappedJS*>(e)->TraceJS(trc);
if(mJSHolders.ops)
if (mJSHolders.ops)
JS_DHashTableEnumerate(&mJSHolders, TraceJSHolder, trc);
// Trace compartments.
@ -483,9 +483,9 @@ CheckParticipatesInCycleCollection(PRUint32 aLangID, void *aThing,
{
Closure *closure = static_cast<Closure*>(aClosure);
if(!closure->cycleCollectionEnabled &&
aLangID == nsIProgrammingLanguage::JAVASCRIPT &&
js_GetGCThingTraceKind(aThing) == JSTRACE_OBJECT)
if (!closure->cycleCollectionEnabled &&
aLangID == nsIProgrammingLanguage::JAVASCRIPT &&
js_GetGCThingTraceKind(aThing) == JSTRACE_OBJECT)
{
closure->cycleCollectionEnabled =
xpc::ParticipatesInCycleCollection(closure->cx,
@ -503,7 +503,7 @@ NoteJSHolder(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 number,
closure->cycleCollectionEnabled = PR_FALSE;
entry->tracer->Trace(entry->holder, CheckParticipatesInCycleCollection,
closure);
if(!closure->cycleCollectionEnabled)
if (!closure->cycleCollectionEnabled)
return JS_DHASH_NEXT;
closure->cb->NoteRoot(nsIProgrammingLanguage::CPLUSPLUS, entry->holder,
@ -517,7 +517,7 @@ void
XPCJSRuntime::SuspectWrappedNative(JSContext *cx, XPCWrappedNative *wrapper,
nsCycleCollectionTraversalCallback &cb)
{
if(!wrapper->IsValid() || wrapper->IsWrapperExpired())
if (!wrapper->IsValid() || wrapper->IsWrapperExpired())
return;
NS_ASSERTION(NS_IsMainThread() || NS_IsCycleCollectorThread(),
@ -526,12 +526,12 @@ XPCJSRuntime::SuspectWrappedNative(JSContext *cx, XPCWrappedNative *wrapper,
// Only suspect wrappedJSObjects that are in a compartment that
// participates in cycle collection.
JSObject* obj = wrapper->GetFlatJSObjectPreserveColor();
if(!xpc::ParticipatesInCycleCollection(cx, obj))
if (!xpc::ParticipatesInCycleCollection(cx, obj))
return;
// Only record objects that might be part of a cycle as roots, unless
// the callback wants all traces (a debug feature).
if(xpc_IsGrayGCThing(obj) || cb.WantAllTraces())
if (xpc_IsGrayGCThing(obj) || cb.WantAllTraces())
cb.NoteRoot(nsIProgrammingLanguage::JAVASCRIPT, obj,
nsXPConnect::GetXPConnect());
}
@ -579,13 +579,13 @@ XPCJSRuntime::AddXPConnectRoots(JSContext* cx,
// collector.
JSContext *iter = nsnull, *acx;
while((acx = JS_ContextIterator(GetJSRuntime(), &iter)))
while ((acx = JS_ContextIterator(GetJSRuntime(), &iter)))
{
// Only skip JSContexts with outstanding requests if the
// callback does not want all traces (a debug feature).
// Otherwise, we do want to know about all JSContexts to get
// better graphs and explanations.
if(!cb.WantAllTraces() && nsXPConnect::GetXPConnect()->GetOutstandingRequests(acx))
if (!cb.WantAllTraces() && nsXPConnect::GetXPConnect()->GetOutstandingRequests(acx))
continue;
cb.NoteRoot(nsIProgrammingLanguage::CPLUSPLUS, acx,
nsXPConnect::JSContextParticipant());
@ -595,24 +595,24 @@ XPCJSRuntime::AddXPConnectRoots(JSContext* cx,
XPCWrappedNativeScope::SuspectAllWrappers(this, cx, cb);
for(XPCRootSetElem *e = mVariantRoots; e ; e = e->GetNextRoot())
for (XPCRootSetElem *e = mVariantRoots; e ; e = e->GetNextRoot())
cb.NoteXPCOMRoot(static_cast<XPCTraceableVariant*>(e));
for(XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot())
for (XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot())
{
nsXPCWrappedJS *wrappedJS = static_cast<nsXPCWrappedJS*>(e);
JSObject *obj = wrappedJS->GetJSObjectPreserveColor();
// Only suspect wrappedJSObjects that are in a compartment that
// participates in cycle collection.
if(!xpc::ParticipatesInCycleCollection(cx, obj))
if (!xpc::ParticipatesInCycleCollection(cx, obj))
continue;
cb.NoteXPCOMRoot(static_cast<nsIXPConnectWrappedJS *>(wrappedJS));
}
Closure closure = { cx, PR_TRUE, &cb };
if(mJSHolders.ops)
if (mJSHolders.ops)
{
JS_DHashTableEnumerate(&mJSHolders, NoteJSHolder, &closure);
}
@ -624,10 +624,10 @@ XPCJSRuntime::AddXPConnectRoots(JSContext* cx,
template<class T> static void
DoDeferredRelease(nsTArray<T> &array)
{
while(1)
while (1)
{
PRUint32 count = array.Length();
if(!count)
if (!count)
{
array.Compact();
break;
@ -646,7 +646,7 @@ SweepWaiverWrappers(JSDHashTable *table, JSDHashEntryHdr *hdr,
JSObject *key = ((JSObject2JSObjectMap::Entry *)hdr)->key;
JSObject *value = ((JSObject2JSObjectMap::Entry *)hdr)->value;
if(JS_IsAboutToBeFinalized(cx, key) || JS_IsAboutToBeFinalized(cx, value))
if (JS_IsAboutToBeFinalized(cx, key) || JS_IsAboutToBeFinalized(cx, value))
return JS_DHASH_REMOVE;
return JS_DHASH_NEXT;
}
@ -676,14 +676,14 @@ SweepCompartment(nsCStringHashKey& aKey, JSCompartment *compartment, void *aClos
JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status)
{
XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance();
if(!self)
if (!self)
return JS_TRUE;
switch(status)
switch (status)
{
case JSGC_BEGIN:
{
if(!NS_IsMainThread())
if (!NS_IsMainThread())
{
return JS_FALSE;
}
@ -692,7 +692,7 @@ JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status)
// here. FIXME: bug 584495.
JSContext *iter = nsnull, *acx;
while((acx = JS_ContextIterator(cx->runtime, &iter))) {
while ((acx = JS_ContextIterator(cx->runtime, &iter))) {
if (!acx->hasRunOption(JSOPTION_UNROOTED_GLOBAL))
JS_ToggleOptions(acx, JSOPTION_UNROOTED_GLOBAL);
}
@ -770,39 +770,39 @@ JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status)
// Skip this part if XPConnect is shutting down. We get into
// bad locking problems with the thread iteration otherwise.
if(!self->GetXPConnect()->IsShuttingDown())
if (!self->GetXPConnect()->IsShuttingDown())
{
Mutex* threadLock = XPCPerThreadData::GetLock();
if(threadLock)
if (threadLock)
{ // scoped lock
MutexAutoLock lock(*threadLock);
XPCPerThreadData* iterp = nsnull;
XPCPerThreadData* thread;
while(nsnull != (thread =
XPCPerThreadData::IterateThreads(&iterp)))
while (nsnull != (thread =
XPCPerThreadData::IterateThreads(&iterp)))
{
// Mark those AutoMarkingPtr lists!
thread->MarkAutoRootsAfterJSFinalize();
XPCCallContext* ccxp = thread->GetCallContext();
while(ccxp)
while (ccxp)
{
// Deal with the strictness of callcontext that
// complains if you ask for a set when
// it is in a state where the set could not
// possibly be valid.
if(ccxp->CanGetSet())
if (ccxp->CanGetSet())
{
XPCNativeSet* set = ccxp->GetSet();
if(set)
if (set)
set->Mark();
}
if(ccxp->CanGetInterface())
if (ccxp->CanGetInterface())
{
XPCNativeInterface* iface = ccxp->GetInterface();
if(iface)
if (iface)
iface->Mark();
}
ccxp = ccxp->GetPrevCallContext();
@ -816,7 +816,7 @@ JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status)
// We don't want to sweep the JSClasses at shutdown time.
// At this point there may be JSObjects using them that have
// been removed from the other maps.
if(!self->GetXPConnect()->IsShuttingDown())
if (!self->GetXPConnect()->IsShuttingDown())
{
self->mNativeScriptableSharedMap->
Enumerate(JSClassSweeper, nsnull);
@ -864,10 +864,10 @@ JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status)
// Skip this part if XPConnect is shutting down. We get into
// bad locking problems with the thread iteration otherwise.
if(!self->GetXPConnect()->IsShuttingDown())
if (!self->GetXPConnect()->IsShuttingDown())
{
Mutex* threadLock = XPCPerThreadData::GetLock();
if(threadLock)
if (threadLock)
{
// Do the marking...
@ -877,21 +877,21 @@ JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status)
XPCPerThreadData* iterp = nsnull;
XPCPerThreadData* thread;
while(nsnull != (thread =
XPCPerThreadData::IterateThreads(&iterp)))
while (nsnull != (thread =
XPCPerThreadData::IterateThreads(&iterp)))
{
XPCCallContext* ccxp = thread->GetCallContext();
while(ccxp)
while (ccxp)
{
// Deal with the strictness of callcontext that
// complains if you ask for a tearoff when
// it is in a state where the tearoff could not
// possibly be valid.
if(ccxp->CanGetTearOff())
if (ccxp->CanGetTearOff())
{
XPCWrappedNativeTearOff* to =
ccxp->GetTearOff();
if(to)
if (to)
to->Mark();
}
ccxp = ccxp->GetPrevCallContext();
@ -1003,7 +1003,7 @@ XPCJSRuntime::WatchdogMain(void *arg)
PR_WaitCondVar(self->mWatchdogWakeup, sleepInterval);
JS_ASSERT(status == PR_SUCCESS);
JSContext* cx = nsnull;
while((cx = js_NextActiveContext(self->mJSRuntime, cx)))
while ((cx = js_NextActiveContext(self->mJSRuntime, cx)))
{
js::TriggerOperationCallback(cx);
}
@ -1072,7 +1072,7 @@ void XPCJSRuntime::SystemIsBeingShutDown(JSContext* cx)
{
DOM_ClearInterfaces();
if(mDetachedWrappedNativeProtoMap)
if (mDetachedWrappedNativeProtoMap)
mDetachedWrappedNativeProtoMap->
Enumerate(DetachedWrappedNativeProtoShutdownMarker, cx);
}
@ -1080,9 +1080,9 @@ void XPCJSRuntime::SystemIsBeingShutDown(JSContext* cx)
JSContext *
XPCJSRuntime::GetJSCycleCollectionContext()
{
if(!mJSCycleCollectionContext) {
if (!mJSCycleCollectionContext) {
mJSCycleCollectionContext = JS_NewContext(mJSRuntime, 0);
if(!mJSCycleCollectionContext)
if (!mJSCycleCollectionContext)
return nsnull;
JS_ClearContextThread(mJSCycleCollectionContext);
}
@ -1109,7 +1109,7 @@ XPCJSRuntime::~XPCJSRuntime()
mWatchdogWakeup = nsnull;
}
if(mJSCycleCollectionContext)
if (mJSCycleCollectionContext)
{
JS_SetContextThread(mJSCycleCollectionContext);
JS_DestroyContextNoGC(mJSCycleCollectionContext);
@ -1120,125 +1120,125 @@ XPCJSRuntime::~XPCJSRuntime()
// count the total JSContexts in use
JSContext* iter = nsnull;
int count = 0;
while(JS_ContextIterator(mJSRuntime, &iter))
while (JS_ContextIterator(mJSRuntime, &iter))
count ++;
if(count)
if (count)
printf("deleting XPCJSRuntime with %d live JSContexts\n", count);
}
#endif
// clean up and destroy maps...
if(mWrappedJSMap)
if (mWrappedJSMap)
{
#ifdef XPC_DUMP_AT_SHUTDOWN
uint32 count = mWrappedJSMap->Count();
if(count)
if (count)
printf("deleting XPCJSRuntime with %d live wrapped JSObject\n", (int)count);
#endif
mWrappedJSMap->Enumerate(WrappedJSShutdownMarker, mJSRuntime);
delete mWrappedJSMap;
}
if(mWrappedJSClassMap)
if (mWrappedJSClassMap)
{
#ifdef XPC_DUMP_AT_SHUTDOWN
uint32 count = mWrappedJSClassMap->Count();
if(count)
if (count)
printf("deleting XPCJSRuntime with %d live nsXPCWrappedJSClass\n", (int)count);
#endif
delete mWrappedJSClassMap;
}
if(mIID2NativeInterfaceMap)
if (mIID2NativeInterfaceMap)
{
#ifdef XPC_DUMP_AT_SHUTDOWN
uint32 count = mIID2NativeInterfaceMap->Count();
if(count)
if (count)
printf("deleting XPCJSRuntime with %d live XPCNativeInterfaces\n", (int)count);
#endif
delete mIID2NativeInterfaceMap;
}
if(mClassInfo2NativeSetMap)
if (mClassInfo2NativeSetMap)
{
#ifdef XPC_DUMP_AT_SHUTDOWN
uint32 count = mClassInfo2NativeSetMap->Count();
if(count)
if (count)
printf("deleting XPCJSRuntime with %d live XPCNativeSets\n", (int)count);
#endif
delete mClassInfo2NativeSetMap;
}
if(mNativeSetMap)
if (mNativeSetMap)
{
#ifdef XPC_DUMP_AT_SHUTDOWN
uint32 count = mNativeSetMap->Count();
if(count)
if (count)
printf("deleting XPCJSRuntime with %d live XPCNativeSets\n", (int)count);
#endif
delete mNativeSetMap;
}
if(mMapLock)
if (mMapLock)
XPCAutoLock::DestroyLock(mMapLock);
if(mThisTranslatorMap)
if (mThisTranslatorMap)
{
#ifdef XPC_DUMP_AT_SHUTDOWN
uint32 count = mThisTranslatorMap->Count();
if(count)
if (count)
printf("deleting XPCJSRuntime with %d live ThisTranslator\n", (int)count);
#endif
delete mThisTranslatorMap;
}
#ifdef XPC_CHECK_WRAPPERS_AT_SHUTDOWN
if(DEBUG_WrappedNativeHashtable)
if (DEBUG_WrappedNativeHashtable)
{
int LiveWrapperCount = 0;
JS_DHashTableEnumerate(DEBUG_WrappedNativeHashtable,
DEBUG_WrapperChecker, &LiveWrapperCount);
if(LiveWrapperCount)
if (LiveWrapperCount)
printf("deleting XPCJSRuntime with %d live XPCWrappedNative (found in wrapper check)\n", (int)LiveWrapperCount);
JS_DHashTableDestroy(DEBUG_WrappedNativeHashtable);
}
#endif
if(mNativeScriptableSharedMap)
if (mNativeScriptableSharedMap)
{
#ifdef XPC_DUMP_AT_SHUTDOWN
uint32 count = mNativeScriptableSharedMap->Count();
if(count)
if (count)
printf("deleting XPCJSRuntime with %d live XPCNativeScriptableShared\n", (int)count);
#endif
delete mNativeScriptableSharedMap;
}
if(mDyingWrappedNativeProtoMap)
if (mDyingWrappedNativeProtoMap)
{
#ifdef XPC_DUMP_AT_SHUTDOWN
uint32 count = mDyingWrappedNativeProtoMap->Count();
if(count)
if (count)
printf("deleting XPCJSRuntime with %d live but dying XPCWrappedNativeProto\n", (int)count);
#endif
delete mDyingWrappedNativeProtoMap;
}
if(mDetachedWrappedNativeProtoMap)
if (mDetachedWrappedNativeProtoMap)
{
#ifdef XPC_DUMP_AT_SHUTDOWN
uint32 count = mDetachedWrappedNativeProtoMap->Count();
if(count)
if (count)
printf("deleting XPCJSRuntime with %d live detached XPCWrappedNativeProto\n", (int)count);
#endif
delete mDetachedWrappedNativeProtoMap;
}
if(mExplicitNativeWrapperMap)
if (mExplicitNativeWrapperMap)
{
#ifdef XPC_DUMP_AT_SHUTDOWN
uint32 count = mExplicitNativeWrapperMap->Count();
if(count)
if (count)
printf("deleting XPCJSRuntime with %d live explicit XPCNativeWrapper\n", (int)count);
#endif
delete mExplicitNativeWrapperMap;
@ -1249,13 +1249,13 @@ XPCJSRuntime::~XPCJSRuntime()
XPCConvert::RemoveXPCOMUCStringFinalizer();
if(mJSHolders.ops)
if (mJSHolders.ops)
{
JS_DHashTableFinish(&mJSHolders);
mJSHolders.ops = nsnull;
}
if(mJSRuntime)
if (mJSRuntime)
{
JS_DestroyRuntime(mJSRuntime);
JS_ShutDown();
@ -1274,7 +1274,7 @@ namespace {
PRInt64
GetCompartmentTjitCodeSize(JSCompartment *c)
{
if(c->hasTraceMonitor())
if (c->hasTraceMonitor())
{
size_t total, frag_size, free_size;
c->traceMonitor()->getCodeAllocStats(total, frag_size, free_size);
@ -1433,7 +1433,7 @@ ReportMemoryBytes0(const nsCString &path, PRInt32 kind, PRInt64 amount,
nsIMemoryMultiReporterCallback *callback,
nsISupports *closure)
{
if(amount)
if (amount)
ReportMemoryBytes(path, kind, amount, desc, callback, closure);
}
@ -1541,20 +1541,20 @@ CompartmentStats::CompartmentStats(JSContext *cx, JSCompartment *c)
{
memset(this, 0, sizeof(*this));
if(c == cx->runtime->atomsCompartment)
if (c == cx->runtime->atomsCompartment)
{
name.AssignLiteral("atoms");
}
else if(c->principals)
else if (c->principals)
{
if(c->principals->codebase)
if (c->principals->codebase)
{
name.Assign(c->principals->codebase);
// If it's the system compartment, append the address.
// This means that multiple system compartments (and there
// can be many) can be distinguished.
if(c->isSystemCompartment)
if (c->isSystemCompartment)
{
if (c->data &&
!((xpc::CompartmentPrivate*)c->data)->location.IsEmpty())
@ -1589,7 +1589,7 @@ JSBool
CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data)
{
JSContext *cx = JS_NewContext(rt, 0);
if(!cx)
if (!cx)
{
NS_ERROR("couldn't create context for memory tracing");
return false;
@ -1610,7 +1610,7 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data)
js::IterateCompartmentsArenasCells(cx, data, CompartmentCallback,
ArenaCallback, CellCallback);
for(js::ThreadDataIter i(rt); !i.empty(); i.popFront())
for (js::ThreadDataIter i(rt); !i.empty(); i.popFront())
data->stackSize += i.threadData()->stackSpace.committedSize();
size_t usable = moz_malloc_usable_size(rt);
@ -1630,9 +1630,9 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data)
data->gcHeapChunkCleanUnused;
data->gcHeapArenaUnused = 0;
for(PRUint32 index = 0;
index < data->compartmentStatsVector.Length();
index++)
for (PRUint32 index = 0;
index < data->compartmentStatsVector.Length();
index++)
{
CompartmentStats &stats = data->compartmentStatsVector[index];
@ -1890,9 +1890,9 @@ ReportJSRuntimeStats(const IterateData &data, const nsACString &pathPrefix,
nsIMemoryMultiReporterCallback *callback,
nsISupports *closure)
{
for(PRUint32 index = 0;
index < data.compartmentStatsVector.Length();
index++)
for (PRUint32 index = 0;
index < data.compartmentStatsVector.Length();
index++)
{
ReportCompartmentStats(data.compartmentStatsVector[index], pathPrefix,
callback, closure);
@ -1958,7 +1958,7 @@ public:
// callback may be a JS function, and executing JS while getting these
// stats seems like a bad idea.
IterateData data;
if(!CollectCompartmentStatsForRuntime(rt, &data))
if (!CollectCompartmentStatsForRuntime(rt, &data))
return NS_ERROR_FAILURE;
NS_NAMED_LITERAL_CSTRING(pathPrefix, "explicit/js/");
@ -2117,8 +2117,8 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
NS_RegisterMemoryMultiReporter(new XPConnectJSCompartmentsMultiReporter);
}
if(!JS_DHashTableInit(&mJSHolders, JS_DHashGetStubOps(), nsnull,
sizeof(ObjectHolder), 512))
if (!JS_DHashTableInit(&mJSHolders, JS_DHashGetStubOps(), nsnull,
sizeof(ObjectHolder), 512))
mJSHolders.ops = nsnull;
mCompartmentMap.Init();
@ -2126,7 +2126,7 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
// Install a JavaScript 'debugger' keyword handler in debug builds only
#ifdef DEBUG
if(mJSRuntime && !JS_GetGlobalDebugHooks(mJSRuntime)->debuggerHandler)
if (mJSRuntime && !JS_GetGlobalDebugHooks(mJSRuntime)->debuggerHandler)
xpc_InstallJSDebuggerKeywordHandler(mJSRuntime);
#endif
@ -2149,19 +2149,19 @@ XPCJSRuntime::newXPCJSRuntime(nsXPConnect* aXPConnect)
XPCJSRuntime* self = new XPCJSRuntime(aXPConnect);
if(self &&
self->GetJSRuntime() &&
self->GetWrappedJSMap() &&
self->GetWrappedJSClassMap() &&
self->GetIID2NativeInterfaceMap() &&
self->GetClassInfo2NativeSetMap() &&
self->GetNativeSetMap() &&
self->GetThisTranslatorMap() &&
self->GetNativeScriptableSharedMap() &&
self->GetDyingWrappedNativeProtoMap() &&
self->GetExplicitNativeWrapperMap() &&
self->GetMapLock() &&
self->mWatchdogThread)
if (self &&
self->GetJSRuntime() &&
self->GetWrappedJSMap() &&
self->GetWrappedJSClassMap() &&
self->GetIID2NativeInterfaceMap() &&
self->GetClassInfo2NativeSetMap() &&
self->GetNativeSetMap() &&
self->GetThisTranslatorMap() &&
self->GetNativeScriptableSharedMap() &&
self->GetDyingWrappedNativeProtoMap() &&
self->GetExplicitNativeWrapperMap() &&
self->GetMapLock() &&
self->mWatchdogThread)
{
return self;
}
@ -2179,17 +2179,17 @@ XPCJSRuntime::OnJSContextNew(JSContext *cx)
// if it is our first context then we need to generate our string ids
JSBool ok = JS_TRUE;
if(JSID_IS_VOID(mStrIDs[0]))
if (JSID_IS_VOID(mStrIDs[0]))
{
JS_SetGCParameterForThread(cx, JSGC_MAX_CODE_CACHE_BYTES, 16 * 1024 * 1024);
{
// Scope the JSAutoRequest so it goes out of scope before calling
// mozilla::dom::binding::DefineStaticJSVals.
JSAutoRequest ar(cx);
for(uintN i = 0; i < IDX_TOTAL_COUNT; i++)
for (uintN i = 0; i < IDX_TOTAL_COUNT; i++)
{
JSString* str = JS_InternString(cx, mStrings[i]);
if(!str || !JS_ValueToId(cx, STRING_TO_JSVAL(str), &mStrIDs[i]))
if (!str || !JS_ValueToId(cx, STRING_TO_JSVAL(str), &mStrIDs[i]))
{
mStrIDs[0] = JSID_VOID;
ok = JS_FALSE;
@ -2205,7 +2205,7 @@ XPCJSRuntime::OnJSContextNew(JSContext *cx)
return JS_FALSE;
XPCPerThreadData* tls = XPCPerThreadData::GetData(cx);
if(!tls)
if (!tls)
return JS_FALSE;
XPCContext* xpc = new XPCContext(this, cx);
@ -2225,7 +2225,7 @@ XPCJSRuntime::DeferredRelease(nsISupports* obj)
{
NS_ASSERTION(obj, "bad param");
if(mNativesToReleaseArray.IsEmpty())
if (mNativesToReleaseArray.IsEmpty())
{
// This array sometimes has 1000's
// of entries, and usually has 50-200 entries. Avoid lots
@ -2278,12 +2278,12 @@ XPCJSRuntime::DebugDump(PRInt16 depth)
int cxCount = 0;
JSContext* iter = nsnull;
while(JS_ContextIterator(mJSRuntime, &iter))
while (JS_ContextIterator(mJSRuntime, &iter))
++cxCount;
XPC_LOG_ALWAYS(("%d JS context(s)", cxCount));
iter = nsnull;
while(JS_ContextIterator(mJSRuntime, &iter))
while (JS_ContextIterator(mJSRuntime, &iter))
{
XPCContext *xpc = XPCContext::GetXPCContext(iter);
XPC_LOG_INDENT();
@ -2295,7 +2295,7 @@ XPCJSRuntime::DebugDump(PRInt16 depth)
mWrappedJSClassMap, mWrappedJSClassMap ? \
mWrappedJSClassMap->Count() : 0));
// iterate wrappersclasses...
if(depth && mWrappedJSClassMap && mWrappedJSClassMap->Count())
if (depth && mWrappedJSClassMap && mWrappedJSClassMap->Count())
{
XPC_LOG_INDENT();
mWrappedJSClassMap->Enumerate(WrappedJSClassMapDumpEnumerator, &depth);
@ -2305,7 +2305,7 @@ XPCJSRuntime::DebugDump(PRInt16 depth)
mWrappedJSMap, mWrappedJSMap ? \
mWrappedJSMap->Count() : 0));
// iterate wrappers...
if(depth && mWrappedJSMap && mWrappedJSMap->Count())
if (depth && mWrappedJSMap && mWrappedJSMap->Count())
{
XPC_LOG_INDENT();
mWrappedJSMap->Enumerate(WrappedJSMapDumpEnumerator, &depth);
@ -2329,7 +2329,7 @@ XPCJSRuntime::DebugDump(PRInt16 depth)
mNativeSetMap->Count() : 0));
// iterate sets...
if(depth && mNativeSetMap && mNativeSetMap->Count())
if (depth && mNativeSetMap && mNativeSetMap->Count())
{
XPC_LOG_INDENT();
mNativeSetMap->Enumerate(NativeSetDumpEnumerator, &depth);
@ -2351,7 +2351,7 @@ XPCRootSetElem::AddToRootSet(XPCLock *lock, XPCRootSetElem **listHead)
mSelfp = listHead;
mNext = *listHead;
if(mNext)
if (mNext)
{
NS_ASSERTION(mNext->mSelfp == listHead, "Must be list start");
mNext->mSelfp = &mNext;
@ -2368,7 +2368,7 @@ XPCRootSetElem::RemoveFromRootSet(XPCLock *lock)
NS_ASSERTION(*mSelfp == this, "Link invariant");
*mSelfp = mNext;
if(mNext)
if (mNext)
mNext->mSelfp = mSelfp;
#ifdef DEBUG
mSelfp = nsnull;

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

@ -60,7 +60,7 @@ static bool Init()
{
g_LogMod = PR_NewLogModule("xpclog");
g_Spaces = new char[SPACE_COUNT+1];
if(!g_LogMod || !g_Spaces || !PR_LOG_TEST(g_LogMod,1))
if (!g_LogMod || !g_Spaces || !PR_LOG_TEST(g_LogMod,1))
{
g_InitState = 1;
XPC_Log_Finish();
@ -75,7 +75,7 @@ static bool Init()
void
XPC_Log_Finish()
{
if(g_InitState == 1)
if (g_InitState == 1)
{
delete [] g_Spaces;
// we'd like to properly cleanup the LogModule, but nspr owns that
@ -93,7 +93,7 @@ XPC_Log_print(const char *fmt, ...)
va_start(ap, fmt);
PR_vsnprintf(line, sizeof(line)-1, fmt, ap);
va_end(ap);
if(g_Indent)
if (g_Indent)
PR_LogPrint("%s%s",g_Spaces+SPACE_COUNT-(INDENT_FACTOR*g_Indent),line);
else
PR_LogPrint("%s",line);
@ -108,14 +108,14 @@ XPC_Log_Check(int i)
void
XPC_Log_Indent()
{
if(INDENT_FACTOR*(++g_Indent) > SPACE_COUNT)
if (INDENT_FACTOR*(++g_Indent) > SPACE_COUNT)
g_Indent-- ;
}
void
XPC_Log_Outdent()
{
if(--g_Indent < 0)
if (--g_Indent < 0)
g_Indent++;
}
@ -132,13 +132,13 @@ void
LogSlimWrapperWillMorph(JSContext *cx, JSObject *obj, const char *propname,
const char *functionName)
{
if(obj && IS_SLIM_WRAPPER(obj))
if (obj && IS_SLIM_WRAPPER(obj))
{
XPCNativeScriptableInfo *si =
GetSlimWrapperProto(obj)->GetScriptableInfo();
printf("***** morphing %s from %s", si->GetJSClass()->name,
functionName);
if(propname)
if (propname)
printf(" for %s", propname);
printf(" (%p, %p)\n", obj,
static_cast<nsISupports*>(xpc_GetJSPrivate(obj)));
@ -151,11 +151,11 @@ LogSlimWrapperNotCreated(JSContext *cx, nsISupports *obj, const char *reason)
{
char* className = nsnull;
nsCOMPtr<nsIClassInfo> ci = do_QueryInterface(obj);
if(ci)
if (ci)
ci->GetClassDescription(&className);
printf("***** refusing to create slim wrapper%s%s, reason: %s (%p)\n",
className ? " for " : "", className ? className : "", reason, obj);
if(className)
if (className)
PR_Free(className);
JSAutoRequest autoRequest(cx);
xpc_DumpJSStack(cx, JS_FALSE, JS_FALSE, JS_FALSE);

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

@ -62,7 +62,7 @@
#ifdef DEBUG
#define XPC_LOG_INTERNAL(number,_args) \
do{if(XPC_Log_Check(number)){XPC_Log_print _args;}}while(0)
do{if (XPC_Log_Check(number)){XPC_Log_print _args;}}while (0)
#define XPC_LOG_ALWAYS(_args) XPC_LOG_INTERNAL(1,_args)
#define XPC_LOG_ERROR(_args) XPC_LOG_INTERNAL(2,_args)

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

@ -74,7 +74,7 @@ HashNativeKey(JSDHashTable *table, const void *key)
XPCNativeInterface* Addition;
PRUint16 Position;
if(Key->IsAKey())
if (Key->IsAKey())
{
Set = Key->GetBaseSet();
Addition = Key->GetAddition();
@ -87,7 +87,7 @@ HashNativeKey(JSDHashTable *table, const void *key)
Position = 0;
}
if(!Set)
if (!Set)
{
NS_ASSERTION(Addition, "bad key");
// This would be an XOR like below.
@ -98,12 +98,12 @@ HashNativeKey(JSDHashTable *table, const void *key)
{
XPCNativeInterface** Current = Set->GetInterfaceArray();
PRUint16 count = Set->GetInterfaceCount();
if(Addition)
if (Addition)
{
count++;
for(PRUint16 i = 0; i < count; i++)
for (PRUint16 i = 0; i < count; i++)
{
if(i == Position)
if (i == Position)
h ^= (JSHashNumber) NS_PTR_TO_INT32(Addition) >> 2;
else
h ^= (JSHashNumber) NS_PTR_TO_INT32(*(Current++)) >> 2;
@ -111,7 +111,7 @@ HashNativeKey(JSDHashTable *table, const void *key)
}
else
{
for(PRUint16 i = 0; i < count; i++)
for (PRUint16 i = 0; i < count; i++)
h ^= (JSHashNumber) NS_PTR_TO_INT32(*(Current++)) >> 2;
}
}
@ -127,7 +127,7 @@ JSObject2WrappedJSMap*
JSObject2WrappedJSMap::newMap(int size)
{
JSObject2WrappedJSMap* map = new JSObject2WrappedJSMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -141,7 +141,7 @@ JSObject2WrappedJSMap::JSObject2WrappedJSMap(int size)
JSObject2WrappedJSMap::~JSObject2WrappedJSMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -153,7 +153,7 @@ Native2WrappedNativeMap*
Native2WrappedNativeMap::newMap(int size)
{
Native2WrappedNativeMap* map = new Native2WrappedNativeMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -167,7 +167,7 @@ Native2WrappedNativeMap::Native2WrappedNativeMap(int size)
Native2WrappedNativeMap::~Native2WrappedNativeMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -190,7 +190,7 @@ IID2WrappedJSClassMap*
IID2WrappedJSClassMap::newMap(int size)
{
IID2WrappedJSClassMap* map = new IID2WrappedJSClassMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -203,7 +203,7 @@ IID2WrappedJSClassMap::IID2WrappedJSClassMap(int size)
IID2WrappedJSClassMap::~IID2WrappedJSClassMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -227,7 +227,7 @@ IID2NativeInterfaceMap*
IID2NativeInterfaceMap::newMap(int size)
{
IID2NativeInterfaceMap* map = new IID2NativeInterfaceMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -240,7 +240,7 @@ IID2NativeInterfaceMap::IID2NativeInterfaceMap(int size)
IID2NativeInterfaceMap::~IID2NativeInterfaceMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -252,7 +252,7 @@ ClassInfo2NativeSetMap*
ClassInfo2NativeSetMap::newMap(int size)
{
ClassInfo2NativeSetMap* map = new ClassInfo2NativeSetMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -266,7 +266,7 @@ ClassInfo2NativeSetMap::ClassInfo2NativeSetMap(int size)
ClassInfo2NativeSetMap::~ClassInfo2NativeSetMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -278,7 +278,7 @@ ClassInfo2WrappedNativeProtoMap*
ClassInfo2WrappedNativeProtoMap::newMap(int size)
{
ClassInfo2WrappedNativeProtoMap* map = new ClassInfo2WrappedNativeProtoMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -292,7 +292,7 @@ ClassInfo2WrappedNativeProtoMap::ClassInfo2WrappedNativeProtoMap(int size)
ClassInfo2WrappedNativeProtoMap::~ClassInfo2WrappedNativeProtoMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -307,23 +307,23 @@ NativeSetMap::Entry::Match(JSDHashTable *table,
XPCNativeSetKey* Key = (XPCNativeSetKey*) key;
// See the comment in the XPCNativeSetKey declaration in xpcprivate.h.
if(!Key->IsAKey())
if (!Key->IsAKey())
{
XPCNativeSet* Set1 = (XPCNativeSet*) key;
XPCNativeSet* Set2 = ((Entry*)entry)->key_value;
if(Set1 == Set2)
if (Set1 == Set2)
return JS_TRUE;
PRUint16 count = Set1->GetInterfaceCount();
if(count != Set2->GetInterfaceCount())
if (count != Set2->GetInterfaceCount())
return JS_FALSE;
XPCNativeInterface** Current1 = Set1->GetInterfaceArray();
XPCNativeInterface** Current2 = Set2->GetInterfaceArray();
for(PRUint16 i = 0; i < count; i++)
for (PRUint16 i = 0; i < count; i++)
{
if(*(Current1++) != *(Current2++))
if (*(Current1++) != *(Current2++))
return JS_FALSE;
}
@ -334,7 +334,7 @@ NativeSetMap::Entry::Match(JSDHashTable *table,
XPCNativeSet* Set = Key->GetBaseSet();
XPCNativeInterface* Addition = Key->GetAddition();
if(!Set)
if (!Set)
{
// This is a special case to deal with the invariant that says:
// "All sets have exactly one nsISupports interface and it comes first."
@ -351,26 +351,26 @@ NativeSetMap::Entry::Match(JSDHashTable *table,
SetInTable->GetInterfaceAt(1) == Addition));
}
if(!Addition && Set == SetInTable)
if (!Addition && Set == SetInTable)
return JS_TRUE;
PRUint16 count = Set->GetInterfaceCount() + (Addition ? 1 : 0);
if(count != SetInTable->GetInterfaceCount())
if (count != SetInTable->GetInterfaceCount())
return JS_FALSE;
PRUint16 Position = Key->GetPosition();
XPCNativeInterface** CurrentInTable = SetInTable->GetInterfaceArray();
XPCNativeInterface** Current = Set->GetInterfaceArray();
for(PRUint16 i = 0; i < count; i++)
for (PRUint16 i = 0; i < count; i++)
{
if(Addition && i == Position)
if (Addition && i == Position)
{
if(Addition != *(CurrentInTable++))
if (Addition != *(CurrentInTable++))
return JS_FALSE;
}
else
{
if(*(Current++) != *(CurrentInTable++))
if (*(Current++) != *(CurrentInTable++))
return JS_FALSE;
}
}
@ -394,7 +394,7 @@ NativeSetMap*
NativeSetMap::newMap(int size)
{
NativeSetMap* map = new NativeSetMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -407,7 +407,7 @@ NativeSetMap::NativeSetMap(int size)
NativeSetMap::~NativeSetMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -445,7 +445,7 @@ IID2ThisTranslatorMap*
IID2ThisTranslatorMap::newMap(int size)
{
IID2ThisTranslatorMap* map = new IID2ThisTranslatorMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -458,7 +458,7 @@ IID2ThisTranslatorMap::IID2ThisTranslatorMap(int size)
IID2ThisTranslatorMap::~IID2ThisTranslatorMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -496,14 +496,14 @@ XPCNativeScriptableSharedMap::Entry::Match(JSDHashTable *table,
// match the flags, the classname string and the interfaces bitmap
if(obj1->GetFlags() != obj2->GetFlags() ||
obj1->GetInterfacesBitmap() != obj2->GetInterfacesBitmap())
if (obj1->GetFlags() != obj2->GetFlags() ||
obj1->GetInterfacesBitmap() != obj2->GetInterfacesBitmap())
return JS_FALSE;
const char* name1 = obj1->GetJSClass()->name;
const char* name2 = obj2->GetJSClass()->name;
if(!name1 || !name2)
if (!name1 || !name2)
return name1 == name2;
return 0 == strcmp(name1, name2);
@ -526,7 +526,7 @@ XPCNativeScriptableSharedMap::newMap(int size)
{
XPCNativeScriptableSharedMap* map =
new XPCNativeScriptableSharedMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -539,7 +539,7 @@ XPCNativeScriptableSharedMap::XPCNativeScriptableSharedMap(int size)
XPCNativeScriptableSharedMap::~XPCNativeScriptableSharedMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -556,17 +556,17 @@ XPCNativeScriptableSharedMap::GetNewOrUsed(JSUint32 flags,
XPCNativeScriptableShared key(flags, name, interfacesBitmap);
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, &key, JS_DHASH_ADD);
if(!entry)
if (!entry)
return JS_FALSE;
XPCNativeScriptableShared* shared = entry->key;
if(!shared)
if (!shared)
{
entry->key = shared =
new XPCNativeScriptableShared(flags, key.TransferNameOwnership(),
interfacesBitmap);
if(!shared)
if (!shared)
return JS_FALSE;
shared->PopulateJSClass(isGlobal);
}
@ -582,7 +582,7 @@ XPCWrappedNativeProtoMap*
XPCWrappedNativeProtoMap::newMap(int size)
{
XPCWrappedNativeProtoMap* map = new XPCWrappedNativeProtoMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -596,7 +596,7 @@ XPCWrappedNativeProtoMap::XPCWrappedNativeProtoMap(int size)
XPCWrappedNativeProtoMap::~XPCWrappedNativeProtoMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -608,7 +608,7 @@ XPCNativeWrapperMap*
XPCNativeWrapperMap::newMap(int size)
{
XPCNativeWrapperMap* map = new XPCNativeWrapperMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -622,7 +622,7 @@ XPCNativeWrapperMap::XPCNativeWrapperMap(int size)
XPCNativeWrapperMap::~XPCNativeWrapperMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -664,7 +664,7 @@ WrappedNative2WrapperMap::MoveLink(JSDHashTable* table,
newEntry->key = oldEntry->key;
// Now update the list.
if(PR_CLIST_IS_EMPTY(&oldEntry->value))
if (PR_CLIST_IS_EMPTY(&oldEntry->value))
{
PR_INIT_CLIST(&newEntry->value);
newEntry->value.obj = oldEntry->value.obj;
@ -682,7 +682,7 @@ WrappedNative2WrapperMap*
WrappedNative2WrapperMap::newMap(int size)
{
WrappedNative2WrapperMap* map = new WrappedNative2WrapperMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -695,7 +695,7 @@ WrappedNative2WrapperMap::WrappedNative2WrapperMap(int size)
WrappedNative2WrapperMap::~WrappedNative2WrapperMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}
@ -707,7 +707,7 @@ WrappedNative2WrapperMap::Add(WrappedNative2WrapperMap* head,
NS_PRECONDITION(wrappedObject,"bad param");
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, wrappedObject, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
NS_ASSERTION(!entry->key || this == head, "dangling pointer?");
entry->key = wrappedObject;
@ -715,7 +715,7 @@ WrappedNative2WrapperMap::Add(WrappedNative2WrapperMap* head,
NS_ASSERTION(!l->obj, "Uh, how'd this happen?");
if(!l->next)
if (!l->next)
{
// Initialize the circular list. This case only happens when
// this == head.
@ -724,10 +724,10 @@ WrappedNative2WrapperMap::Add(WrappedNative2WrapperMap* head,
l->obj = wrapper;
if(this != head)
if (this != head)
{
Link* headLink = head->FindLink(wrappedObject);
if(!headLink)
if (!headLink)
{
Entry* dummy = (Entry*)
JS_DHashTableOperate(head->mTable, wrappedObject, JS_DHASH_ADD);
@ -748,7 +748,7 @@ WrappedNative2WrapperMap::AddLink(JSObject* wrappedObject, Link* oldLink)
{
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, wrappedObject, JS_DHASH_ADD);
if(!entry)
if (!entry)
return PR_FALSE;
NS_ASSERTION(!entry->key, "Eh? What's happening?");
entry->key = wrappedObject;

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

@ -71,7 +71,7 @@ public:
NS_PRECONDITION(Obj,"bad param");
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, Obj, JS_DHASH_LOOKUP);
if(JS_DHASH_ENTRY_IS_FREE(entry))
if (JS_DHASH_ENTRY_IS_FREE(entry))
return nsnull;
return entry->value;
}
@ -82,9 +82,9 @@ public:
JSObject* obj = wrapper->GetJSObjectPreserveColor();
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, obj, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
if(entry->key)
if (entry->key)
return entry->value;
entry->key = obj;
entry->value = wrapper;
@ -128,7 +128,7 @@ public:
NS_PRECONDITION(Obj,"bad param");
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, Obj, JS_DHASH_LOOKUP);
if(JS_DHASH_ENTRY_IS_FREE(entry))
if (JS_DHASH_ENTRY_IS_FREE(entry))
return nsnull;
return entry->value;
}
@ -139,9 +139,9 @@ public:
nsISupports* obj = wrapper->GetIdentityObject();
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, obj, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
if(entry->key)
if (entry->key)
return entry->value;
entry->key = obj;
entry->value = wrapper;
@ -192,7 +192,7 @@ public:
{
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, &iid, JS_DHASH_LOOKUP);
if(JS_DHASH_ENTRY_IS_FREE(entry))
if (JS_DHASH_ENTRY_IS_FREE(entry))
return nsnull;
return entry->value;
}
@ -203,9 +203,9 @@ public:
const nsIID* iid = &clazz->GetIID();
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, iid, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
if(entry->key)
if (entry->key)
return entry->value;
entry->key = iid;
entry->value = clazz;
@ -249,7 +249,7 @@ public:
{
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, &iid, JS_DHASH_LOOKUP);
if(JS_DHASH_ENTRY_IS_FREE(entry))
if (JS_DHASH_ENTRY_IS_FREE(entry))
return nsnull;
return entry->value;
}
@ -260,9 +260,9 @@ public:
const nsIID* iid = iface->GetIID();
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, iid, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
if(entry->key)
if (entry->key)
return entry->value;
entry->key = iid;
entry->value = iface;
@ -304,7 +304,7 @@ public:
{
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, info, JS_DHASH_LOOKUP);
if(JS_DHASH_ENTRY_IS_FREE(entry))
if (JS_DHASH_ENTRY_IS_FREE(entry))
return nsnull;
return entry->value;
}
@ -314,9 +314,9 @@ public:
NS_PRECONDITION(info,"bad param");
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, info, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
if(entry->key)
if (entry->key)
return entry->value;
entry->key = info;
entry->value = set;
@ -358,7 +358,7 @@ public:
{
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, info, JS_DHASH_LOOKUP);
if(JS_DHASH_ENTRY_IS_FREE(entry))
if (JS_DHASH_ENTRY_IS_FREE(entry))
return nsnull;
return entry->value;
}
@ -368,9 +368,9 @@ public:
NS_PRECONDITION(info,"bad param");
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, info, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
if(entry->key)
if (entry->key)
return entry->value;
entry->key = info;
entry->value = proto;
@ -418,7 +418,7 @@ public:
{
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, key, JS_DHASH_LOOKUP);
if(JS_DHASH_ENTRY_IS_FREE(entry))
if (JS_DHASH_ENTRY_IS_FREE(entry))
return nsnull;
return entry->key_value;
}
@ -429,9 +429,9 @@ public:
NS_PRECONDITION(set,"bad param");
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, key, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
if(entry->key_value)
if (entry->key_value)
return entry->key_value;
entry->key_value = set;
return set;
@ -490,7 +490,7 @@ public:
{
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, &iid, JS_DHASH_LOOKUP);
if(JS_DHASH_ENTRY_IS_FREE(entry))
if (JS_DHASH_ENTRY_IS_FREE(entry))
return nsnull;
return entry->value;
}
@ -501,7 +501,7 @@ public:
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, &iid, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
NS_IF_ADDREF(obj);
NS_IF_RELEASE(entry->value);
@ -576,9 +576,9 @@ public:
NS_PRECONDITION(proto,"bad param");
JSDHashEntryStub* entry = (JSDHashEntryStub*)
JS_DHashTableOperate(mTable, proto, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
if(entry->key)
if (entry->key)
return (XPCWrappedNativeProto*) entry->key;
entry->key = proto;
return proto;
@ -612,9 +612,9 @@ public:
NS_PRECONDITION(nw,"bad param");
JSDHashEntryStub* entry = (JSDHashEntryStub*)
JS_DHashTableOperate(mTable, nw, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
if(entry->key)
if (entry->key)
return (JSObject*) entry->key;
entry->key = nw;
return nw;
@ -666,7 +666,7 @@ public:
NS_PRECONDITION(wrapper, "bad param");
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, wrapper, JS_DHASH_LOOKUP);
if(JS_DHASH_ENTRY_IS_FREE(entry))
if (JS_DHASH_ENTRY_IS_FREE(entry))
return nsnull;
return entry->value.obj;
}
@ -682,7 +682,7 @@ public:
{
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, wrappedObject, JS_DHASH_LOOKUP);
if(JS_DHASH_ENTRY_IS_BUSY(entry))
if (JS_DHASH_ENTRY_IS_BUSY(entry))
return &entry->value;
return nsnull;
}
@ -725,7 +725,7 @@ public:
static JSObject2JSObjectMap* newMap(int size)
{
JSObject2JSObjectMap* map = new JSObject2JSObjectMap(size);
if(map && map->mTable)
if (map && map->mTable)
return map;
delete map;
return nsnull;
@ -736,7 +736,7 @@ public:
NS_PRECONDITION(key, "bad param");
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, key, JS_DHASH_LOOKUP);
if(JS_DHASH_ENTRY_IS_FREE(entry))
if (JS_DHASH_ENTRY_IS_FREE(entry))
return nsnull;
return entry->value;
}
@ -747,9 +747,9 @@ public:
NS_PRECONDITION(key,"bad param");
Entry* entry = (Entry*)
JS_DHashTableOperate(mTable, key, JS_DHASH_ADD);
if(!entry)
if (!entry)
return nsnull;
if(entry->key)
if (entry->key)
return entry->value;
entry->key = key;
entry->value = value;
@ -771,7 +771,7 @@ public:
~JSObject2JSObjectMap()
{
if(mTable)
if (mTable)
JS_DHashTableDestroy(mTable);
}

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

@ -49,7 +49,7 @@ static inline QITableEntry *
GetOffsets(nsISupports *identity, XPCWrappedNativeProto* proto)
{
QITableEntry* offsets = proto ? proto->GetOffsets() : nsnull;
if(!offsets)
if (!offsets)
{
static NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID);
identity->QueryInterface(kThisPtrOffsetsSID, (void**)&offsets);
@ -75,10 +75,10 @@ LookupEntry(PRUint32 tableSize, const xpc_qsHashEntry *table, const nsID &iid)
do
{
p = table + i;
if(p->iid.Equals(iid))
if (p->iid.Equals(iid))
return p;
i = p->chain;
} while(i != XPC_QS_NULL_INDEX);
} while (i != XPC_QS_NULL_INDEX);
return nsnull;
}
@ -87,28 +87,28 @@ LookupInterfaceOrAncestor(PRUint32 tableSize, const xpc_qsHashEntry *table,
const nsID &iid)
{
const xpc_qsHashEntry *entry = LookupEntry(tableSize, table, iid);
if(!entry)
if (!entry)
{
/*
* On a miss, we have to search for every interface the object
* supports, including ancestors.
*/
nsCOMPtr<nsIInterfaceInfo> info;
if(NS_FAILED(nsXPConnect::GetXPConnect()->GetInfoForIID(&iid, getter_AddRefs(info))))
if (NS_FAILED(nsXPConnect::GetXPConnect()->GetInfoForIID(&iid, getter_AddRefs(info))))
return nsnull;
const nsIID *piid;
for(;;)
for (;;)
{
nsCOMPtr<nsIInterfaceInfo> parent;
if(NS_FAILED(info->GetParent(getter_AddRefs(parent))) ||
!parent ||
NS_FAILED(parent->GetIIDShared(&piid)))
if (NS_FAILED(info->GetParent(getter_AddRefs(parent))) ||
!parent ||
NS_FAILED(parent->GetIIDShared(&piid)))
{
break;
}
entry = LookupEntry(tableSize, table, *piid);
if(entry)
if (entry)
break;
info.swap(parent);
}
@ -150,12 +150,12 @@ PropertyOpForwarder(JSContext *cx, uintN argc, jsval *vp)
return JS_FALSE;
jsval v;
if(!JS_GetReservedSlot(cx, callee, 0, &v))
if (!JS_GetReservedSlot(cx, callee, 0, &v))
return JS_FALSE;
JSObject *ptrobj = JSVAL_TO_OBJECT(v);
Op *popp = static_cast<Op *>(JS_GetPrivate(cx, ptrobj));
if(!JS_GetReservedSlot(cx, callee, 1, &v))
if (!JS_GetReservedSlot(cx, callee, 1, &v))
return JS_FALSE;
jsval argval = (argc > 0) ? JS_ARGV(cx, vp)[0] : JSVAL_VOID;
@ -189,7 +189,7 @@ GeneratePropertyOp(JSContext *cx, JSObject *obj, jsid id, uintN argc, Op pop)
// XPConnect to use. Use them to stick the necessary info here.
JSFunction *fun =
JS_NewFunctionById(cx, PropertyOpForwarder<Op>, argc, 0, obj, id);
if(!fun)
if (!fun)
return JS_FALSE;
JSObject *funobj = JS_GetFunctionObject(fun);
@ -199,10 +199,10 @@ GeneratePropertyOp(JSContext *cx, JSObject *obj, jsid id, uintN argc, Op pop)
// Unfortunately, we cannot guarantee that Op is aligned. Use a
// second object to work around this.
JSObject *ptrobj = JS_NewObject(cx, &PointerHolderClass, nsnull, funobj);
if(!ptrobj)
if (!ptrobj)
return JS_FALSE;
Op *popp = new Op;
if(!popp)
if (!popp)
return JS_FALSE;
*popp = pop;
JS_SetPrivate(cx, ptrobj, popp);
@ -223,10 +223,10 @@ ReifyPropertyOps(JSContext *cx, JSObject *obj, jsid id, uintN orig_attrs,
uintN attrs = JSPROP_SHARED | (orig_attrs & JSPROP_ENUMERATE);
JSObject *getterobj;
if(getter)
if (getter)
{
getterobj = GeneratePropertyOp(cx, obj, id, 0, getter);
if(!getterobj)
if (!getterobj)
return JS_FALSE;
roots[0] = OBJECT_TO_JSVAL(getterobj);
attrs |= JSPROP_GETTER;
@ -238,7 +238,7 @@ ReifyPropertyOps(JSContext *cx, JSObject *obj, jsid id, uintN orig_attrs,
if (setter)
{
setterobj = GeneratePropertyOp(cx, obj, id, 1, setter);
if(!setterobj)
if (!setterobj)
return JS_FALSE;
roots[1] = OBJECT_TO_JSVAL(setterobj);
attrs |= JSPROP_SETTER;
@ -246,9 +246,9 @@ ReifyPropertyOps(JSContext *cx, JSObject *obj, jsid id, uintN orig_attrs,
else
setterobj = nsnull;
if(getterobjp)
if (getterobjp)
*getterobjp = getterobj;
if(setterobjp)
if (setterobjp)
*setterobjp = setterobj;
return JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
JS_DATA_TO_FUNC_PTR(JSPropertyOp, getterobj),
@ -261,34 +261,34 @@ LookupGetterOrSetter(JSContext *cx, JSBool wantGetter, uintN argc, jsval *vp)
{
XPC_QS_ASSERT_CONTEXT_OK(cx);
if(argc == 0)
if (argc == 0)
{
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JSObject *obj = JS_THIS_OBJECT(cx, vp);
if(!obj)
if (!obj)
return JS_FALSE;
jsval idval = JS_ARGV(cx, vp)[0];
jsid id;
JSPropertyDescriptor desc;
if(!JS_ValueToId(cx, idval, &id) ||
!JS_GetPropertyDescriptorById(cx, obj, id, JSRESOLVE_QUALIFIED, &desc))
if (!JS_ValueToId(cx, idval, &id) ||
!JS_GetPropertyDescriptorById(cx, obj, id, JSRESOLVE_QUALIFIED, &desc))
return JS_FALSE;
// No property at all means no getters or setters possible.
if(!desc.obj)
if (!desc.obj)
{
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
// Inline obj_lookup[GS]etter here.
if(wantGetter)
if (wantGetter)
{
if(desc.attrs & JSPROP_GETTER)
if (desc.attrs & JSPROP_GETTER)
{
JS_SET_RVAL(cx, vp,
OBJECT_TO_JSVAL(JS_FUNC_TO_DATA_PTR(JSObject *, desc.getter)));
@ -297,7 +297,7 @@ LookupGetterOrSetter(JSContext *cx, JSBool wantGetter, uintN argc, jsval *vp)
}
else
{
if(desc.attrs & JSPROP_SETTER)
if (desc.attrs & JSPROP_SETTER)
{
JS_SET_RVAL(cx, vp,
OBJECT_TO_JSVAL(JS_FUNC_TO_DATA_PTR(JSObject *, desc.setter)));
@ -310,19 +310,19 @@ LookupGetterOrSetter(JSContext *cx, JSBool wantGetter, uintN argc, jsval *vp)
// we are only going to expose quickstubbed properties to script.
// Also be careful not to overwrite existing properties!
if(!JSID_IS_STRING(id) ||
!IS_PROTO_CLASS(js::GetObjectClass(desc.obj)) ||
(desc.attrs & (JSPROP_GETTER | JSPROP_SETTER)) ||
!(desc.getter || desc.setter) ||
desc.setter == js::GetObjectJSClass(desc.obj)->setProperty)
if (!JSID_IS_STRING(id) ||
!IS_PROTO_CLASS(js::GetObjectClass(desc.obj)) ||
(desc.attrs & (JSPROP_GETTER | JSPROP_SETTER)) ||
!(desc.getter || desc.setter) ||
desc.setter == js::GetObjectJSClass(desc.obj)->setProperty)
{
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JSObject *getterobj, *setterobj;
if(!ReifyPropertyOps(cx, desc.obj, id, desc.attrs, desc.getter, desc.setter,
&getterobj, &setterobj))
if (!ReifyPropertyOps(cx, desc.obj, id, desc.attrs, desc.getter, desc.setter,
&getterobj, &setterobj))
{
return JS_FALSE;
}
@ -362,27 +362,27 @@ DefineGetterOrSetter(JSContext *cx, uintN argc, JSBool wantGetter, jsval *vp)
return JS_FALSE;
JSNative forward = wantGetter ? js::obj_defineGetter : js::obj_defineSetter;
jsval idval = (argc >= 1) ? JS_ARGV(cx, vp)[0] : JSVAL_VOID;
if(!JSVAL_IS_STRING(idval))
if (!JSVAL_IS_STRING(idval))
return forward(cx, argc, vp);
if(!JS_ValueToId(cx, idval, &id) ||
!JS_LookupPropertyWithFlagsById(cx, obj, id,
JSRESOLVE_QUALIFIED, &obj2, &v) ||
(obj2 &&
!JS_GetPropertyAttrsGetterAndSetterById(cx, obj2, id, &attrs,
&found, &getter, &setter)))
if (!JS_ValueToId(cx, idval, &id) ||
!JS_LookupPropertyWithFlagsById(cx, obj, id,
JSRESOLVE_QUALIFIED, &obj2, &v) ||
(obj2 &&
!JS_GetPropertyAttrsGetterAndSetterById(cx, obj2, id, &attrs,
&found, &getter, &setter)))
return JS_FALSE;
// The property didn't exist, already has a getter or setter, or is not
// our property, then just forward now.
if(!obj2 ||
(attrs & (JSPROP_GETTER | JSPROP_SETTER)) ||
!(getter || setter) ||
!IS_PROTO_CLASS(js::GetObjectClass(obj2)))
if (!obj2 ||
(attrs & (JSPROP_GETTER | JSPROP_SETTER)) ||
!(getter || setter) ||
!IS_PROTO_CLASS(js::GetObjectClass(obj2)))
return forward(cx, argc, vp);
// Reify the getter and setter...
if(!ReifyPropertyOps(cx, obj2, id, attrs, getter, setter, nsnull, nsnull))
if (!ReifyPropertyOps(cx, obj2, id, attrs, getter, setter, nsnull, nsnull))
return JS_FALSE;
return forward(cx, argc, vp);
@ -415,57 +415,57 @@ xpc_qsDefineQuickStubs(JSContext *cx, JSObject *proto, uintN flags,
* front of 'interfaces' overwrite those toward the back.
*/
bool definedProperty = false;
for(uint32 i = ifacec; i-- != 0;)
for (uint32 i = ifacec; i-- != 0;)
{
const nsID &iid = *interfaces[i];
const xpc_qsHashEntry *entry =
LookupInterfaceOrAncestor(tableSize, table, iid);
if(entry)
if (entry)
{
for(;;)
for (;;)
{
// Define quick stubs for attributes.
const xpc_qsPropertySpec *ps = entry->properties;
if(ps)
if (ps)
{
for(; ps->name; ps++)
for (; ps->name; ps++)
{
definedProperty = PR_TRUE;
if(!JS_DefineProperty(cx, proto, ps->name, JSVAL_VOID,
ps->getter, ps->setter,
flags | JSPROP_SHARED))
if (!JS_DefineProperty(cx, proto, ps->name, JSVAL_VOID,
ps->getter, ps->setter,
flags | JSPROP_SHARED))
return JS_FALSE;
}
}
// Define quick stubs for methods.
const xpc_qsFunctionSpec *fs = entry->functions;
if(fs)
if (fs)
{
for(; fs->name; fs++)
for (; fs->name; fs++)
{
if(!JS_DefineFunction(cx, proto, fs->name,
reinterpret_cast<JSNative>(fs->native),
fs->arity, flags))
if (!JS_DefineFunction(cx, proto, fs->name,
reinterpret_cast<JSNative>(fs->native),
fs->arity, flags))
return JS_FALSE;
}
}
const xpc_qsTraceableSpec *ts = entry->traceables;
if(ts)
if (ts)
{
for(; ts->name; ts++)
for (; ts->name; ts++)
{
if(!JS_DefineFunction(cx, proto, ts->name, ts->native, ts->arity,
flags | JSFUN_STUB_GSOPS | JSFUN_TRCINFO))
if (!JS_DefineFunction(cx, proto, ts->name, ts->native, ts->arity,
flags | JSFUN_STUB_GSOPS | JSFUN_TRCINFO))
return JS_FALSE;
}
}
// Next.
size_t j = entry->parentInterface;
if(j == XPC_QS_NULL_INDEX)
if (j == XPC_QS_NULL_INDEX)
break;
entry = table + j;
}
@ -480,7 +480,7 @@ xpc_qsDefineQuickStubs(JSContext *cx, JSObject *proto, uintN flags,
JS_FS_END
};
if(definedProperty && !JS_DefineFunctions(cx, proto, getterfns))
if (definedProperty && !JS_DefineFunctions(cx, proto, getterfns))
return JS_FALSE;
return JS_TRUE;
@ -516,7 +516,7 @@ GetMemberInfo(JSObject *obj, jsid memberId, const char **ifaceName)
js::GetObjectClass(obj) == &XPC_WN_Tearoff_JSClass,
"obj must be a wrapper");
XPCWrappedNativeProto *proto;
if(IS_SLIM_WRAPPER(obj))
if (IS_SLIM_WRAPPER(obj))
{
proto = GetSlimWrapperProto(obj);
}
@ -525,15 +525,15 @@ GetMemberInfo(JSObject *obj, jsid memberId, const char **ifaceName)
XPCWrappedNative *wrapper = (XPCWrappedNative *) js::GetObjectPrivate(obj);
proto = wrapper->GetProto();
}
if(proto)
if (proto)
{
XPCNativeSet *set = proto->GetSet();
if(set)
if (set)
{
XPCNativeMember *member;
XPCNativeInterface *iface;
if(set->FindMember(memberId, &member, &iface))
if (set->FindMember(memberId, &member, &iface))
*ifaceName = iface->GetNameString();
}
}
@ -569,13 +569,13 @@ ThrowCallFailed(JSContext *cx, nsresult rv,
* the native call may be passing through an error from a previous JS
* call. So we'll just throw that exception into our JS.
*/
if(XPCThrower::CheckForPendingException(rv, cx))
if (XPCThrower::CheckForPendingException(rv, cx))
return JS_FALSE;
// else...
if(!nsXPCException::NameAndFormatForNSResult(NS_ERROR_XPC_NATIVE_RETURNED_FAILURE, nsnull, &format) ||
!format)
if (!nsXPCException::NameAndFormatForNSResult(NS_ERROR_XPC_NATIVE_RETURNED_FAILURE, nsnull, &format) ||
!format)
{
format = "";
}
@ -586,8 +586,8 @@ ThrowCallFailed(JSContext *cx, nsresult rv,
? memberNameBytes.encode(cx, JSID_TO_STRING(memberId))
: "unknown";
}
if(nsXPCException::NameAndFormatForNSResult(rv, &name, nsnull)
&& name)
if (nsXPCException::NameAndFormatForNSResult(rv, &name, nsnull)
&& name)
{
sz = JS_smprintf("%s 0x%x (%s) [%s.%s]",
format, rv, name, ifaceName, memberName);
@ -600,7 +600,7 @@ ThrowCallFailed(JSContext *cx, nsresult rv,
XPCThrower::BuildAndThrowException(cx, rv, sz);
if(sz)
if (sz)
JS_smprintf_free(sz);
return JS_FALSE;
@ -650,7 +650,7 @@ ThrowBadArg(JSContext *cx, nsresult rv, const char *ifaceName,
char* sz;
const char* format;
if(!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format))
if (!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format))
format = "";
JSAutoByteString memberNameBytes;
@ -664,7 +664,7 @@ ThrowBadArg(JSContext *cx, nsresult rv, const char *ifaceName,
XPCThrower::BuildAndThrowException(cx, rv, sz);
if(sz)
if (sz)
JS_smprintf_free(sz);
}
@ -743,14 +743,14 @@ xpc_qsACString::xpc_qsACString(JSContext *cx, jsval v, jsval *pval,
return;
size_t len = JS_GetStringEncodingLength(cx, s);
if(len == size_t(-1))
if (len == size_t(-1))
{
mValid = JS_FALSE;
return;
}
JSAutoByteString bytes(cx, s);
if(!bytes)
if (!bytes)
{
mValid = JS_FALSE;
return;
@ -789,11 +789,11 @@ getNative(nsISupports *idobj,
jsval *vp)
{
// Try using the QITableEntry to avoid the extra AddRef and Release.
if(entries)
if (entries)
{
for(QITableEntry* e = entries; e->iid; e++)
for (QITableEntry* e = entries; e->iid; e++)
{
if(e->iid->Equals(iid))
if (e->iid->Equals(iid))
{
*ppThis = (char*) idobj + e->offset - entries[0].offset;
*vp = OBJECT_TO_JSVAL(obj);
@ -805,7 +805,7 @@ getNative(nsISupports *idobj,
nsresult rv = idobj->QueryInterface(iid, ppThis);
*pThisRef = static_cast<nsISupports*>(*ppThis);
if(NS_SUCCEEDED(rv))
if (NS_SUCCEEDED(rv))
*vp = OBJECT_TO_JSVAL(obj);
return rv;
}
@ -831,8 +831,8 @@ getWrapper(JSContext *cx,
JSObject **cur,
XPCWrappedNativeTearOff **tearoff)
{
if(XPCWrapper::IsSecurityWrapper(obj) &&
!(obj = XPCWrapper::Unwrap(cx, obj)))
if (XPCWrapper::IsSecurityWrapper(obj) &&
!(obj = XPCWrapper::Unwrap(cx, obj)))
{
return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
}
@ -858,22 +858,22 @@ castNative(JSContext *cx,
jsval *vp,
XPCLazyCallContext *lccx)
{
if(wrapper)
if (wrapper)
{
nsresult rv = getNativeFromWrapper(cx,wrapper, iid, ppThis, pThisRef,
vp);
if(lccx && NS_SUCCEEDED(rv))
if (lccx && NS_SUCCEEDED(rv))
lccx->SetWrapper(wrapper, tearoff);
if(rv != NS_ERROR_NO_INTERFACE)
if (rv != NS_ERROR_NO_INTERFACE)
return rv;
}
else if(cur)
else if (cur)
{
nsISupports *native;
QITableEntry *entries;
if(IS_SLIM_WRAPPER(cur))
if (IS_SLIM_WRAPPER(cur))
{
native = static_cast<nsISupports*>(xpc_GetJSPrivate(cur));
entries = GetOffsetsFromSlimWrapper(cur);
@ -886,9 +886,9 @@ castNative(JSContext *cx,
entries = nsnull;
}
if(NS_SUCCEEDED(getNative(native, entries, cur, iid, ppThis, pThisRef, vp)))
if (NS_SUCCEEDED(getNative(native, entries, cur, iid, ppThis, pThisRef, vp)))
{
if(lccx)
if (lccx)
{
// This only matters for unwrapping of this objects, so we
// shouldn't end up here for the new DOM bindings.
@ -913,13 +913,13 @@ xpc_qsUnwrapThisFromCcxImpl(XPCCallContext &ccx,
jsval *vp)
{
nsISupports *native = ccx.GetIdentityObject();
if(!native)
if (!native)
return xpc_qsThrow(ccx.GetJSContext(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
nsresult rv = getNative(native, GetOffsets(native, ccx.GetProto()),
ccx.GetFlattenedJSObject(), iid, ppThis, pThisRef,
vp);
if(NS_FAILED(rv))
if (NS_FAILED(rv))
return xpc_qsThrow(ccx.GetJSContext(), rv);
return JS_TRUE;
}
@ -927,14 +927,14 @@ xpc_qsUnwrapThisFromCcxImpl(XPCCallContext &ccx,
JSObject*
xpc_qsUnwrapObj(jsval v, nsISupports **ppArgRef, nsresult *rv)
{
if(JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))
if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))
{
*ppArgRef = nsnull;
*rv = NS_OK;
return nsnull;
}
if(!JSVAL_IS_OBJECT(v))
if (!JSVAL_IS_OBJECT(v))
{
*ppArgRef = nsnull;
*rv = ((JSVAL_IS_INT(v) && JSVAL_TO_INT(v) == 0)
@ -957,7 +957,7 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
{
nsresult rv;
JSObject *src = xpc_qsUnwrapObj(v, ppArgRef, &rv);
if(!src)
if (!src)
{
*ppArg = nsnull;
@ -967,7 +967,7 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
XPCWrappedNative *wrapper;
XPCWrappedNativeTearOff *tearoff;
JSObject *obj2;
if(mozilla::dom::binding::instanceIsProxy(src))
if (mozilla::dom::binding::instanceIsProxy(src))
{
wrapper = nsnull;
obj2 = src;
@ -978,10 +978,10 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
NS_ENSURE_SUCCESS(rv, rv);
}
if(wrapper || obj2)
if (wrapper || obj2)
{
if(NS_FAILED(castNative(cx, wrapper, obj2, tearoff, iid, ppArg,
ppArgRef, vp, nsnull)))
if (NS_FAILED(castNative(cx, wrapper, obj2, tearoff, iid, ppArg,
ppArgRef, vp, nsnull)))
return NS_ERROR_XPC_BAD_CONVERT_JS;
return NS_OK;
}
@ -991,7 +991,7 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
// XXX E4X breaks the world. Don't try wrapping E4X objects!
// This hack can be removed (or changed accordingly) when the
// DOM <-> E4X bindings are complete, see bug 270553
if(JS_TypeOfValue(cx, OBJECT_TO_JSVAL(src)) == JSTYPE_XML)
if (JS_TypeOfValue(cx, OBJECT_TO_JSVAL(src)) == JSTYPE_XML)
{
*ppArgRef = nsnull;
return NS_ERROR_XPC_BAD_CONVERT_JS;
@ -999,9 +999,9 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
// Try to unwrap a slim wrapper.
nsISupports *iface;
if(XPCConvert::GetISupportsFromJSObject(src, &iface))
if (XPCConvert::GetISupportsFromJSObject(src, &iface))
{
if(!iface || NS_FAILED(iface->QueryInterface(iid, ppArg)))
if (!iface || NS_FAILED(iface->QueryInterface(iid, ppArg)))
{
*ppArgRef = nsnull;
return NS_ERROR_XPC_BAD_CONVERT_JS;
@ -1013,7 +1013,7 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
// Create the ccx needed for quick stubs.
XPCCallContext ccx(JS_CALLER, cx);
if(!ccx.IsValid())
if (!ccx.IsValid())
{
*ppArgRef = nsnull;
return NS_ERROR_XPC_BAD_CONVERT_JS;
@ -1022,7 +1022,7 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
nsRefPtr<nsXPCWrappedJS> wrappedJS;
rv = nsXPCWrappedJS::GetNewOrUsed(ccx, src, iid, nsnull,
getter_AddRefs(wrappedJS));
if(NS_FAILED(rv) || !wrappedJS)
if (NS_FAILED(rv) || !wrappedJS)
{
*ppArgRef = nsnull;
return rv;
@ -1033,7 +1033,7 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
// nsIPropertyBag. We must use AggregatedQueryInterface in cases where
// there is an outer to avoid nasty recursion.
rv = wrappedJS->QueryInterface(iid, ppArg);
if(NS_SUCCEEDED(rv))
if (NS_SUCCEEDED(rv))
{
*ppArgRef = static_cast<nsISupports*>(*ppArg);
*vp = OBJECT_TO_JSVAL(wrappedJS->GetJSObject());
@ -1047,17 +1047,17 @@ xpc_qsJsvalToCharStr(JSContext *cx, jsval v, JSAutoByteString *bytes)
JSString *str;
JS_ASSERT(!bytes->ptr());
if(JSVAL_IS_STRING(v))
if (JSVAL_IS_STRING(v))
{
str = JSVAL_TO_STRING(v);
}
else if(JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))
else if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))
{
return true;
}
else
{
if(!(str = JS_ValueToString(cx, v)))
if (!(str = JS_ValueToString(cx, v)))
return false;
}
return !!bytes->encode(cx, str);
@ -1068,18 +1068,18 @@ xpc_qsJsvalToWcharStr(JSContext *cx, jsval v, jsval *pval, PRUnichar **pstr)
{
JSString *str;
if(JSVAL_IS_STRING(v))
if (JSVAL_IS_STRING(v))
{
str = JSVAL_TO_STRING(v);
}
else if(JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))
else if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))
{
*pstr = NULL;
return JS_TRUE;
}
else
{
if(!(str = JS_ValueToString(cx, v)))
if (!(str = JS_ValueToString(cx, v)))
return JS_FALSE;
*pval = STRING_TO_JSVAL(str); // Root the new string.
}
@ -1097,7 +1097,7 @@ JSBool
xpc_qsStringToJsval(JSContext *cx, nsString &str, jsval *rval)
{
// From the T_DOMSTRING case in XPCConvert::NativeData2JS.
if(str.IsVoid())
if (str.IsVoid())
{
*rval = JSVAL_NULL;
return JS_TRUE;
@ -1121,7 +1121,7 @@ JSBool
xpc_qsStringToJsstring(JSContext *cx, nsString &str, JSString **rval)
{
// From the T_DOMSTRING case in XPCConvert::NativeData2JS.
if(str.IsVoid())
if (str.IsVoid())
{
*rval = nsnull;
return JS_TRUE;
@ -1129,7 +1129,7 @@ xpc_qsStringToJsstring(JSContext *cx, nsString &str, JSString **rval)
nsStringBuffer* sharedBuffer;
jsval jsstr = XPCStringConvert::ReadableToJSVal(cx, str, &sharedBuffer);
if(JSVAL_IS_NULL(jsstr))
if (JSVAL_IS_NULL(jsstr))
return JS_FALSE;
*rval = JSVAL_TO_STRING(jsstr);
if (sharedBuffer)
@ -1160,21 +1160,21 @@ xpc_qsXPCOMObjectToJsval(XPCLazyCallContext &lccx, qsObjectHelper &aHelper,
// creating a new XPCNativeScriptableShared.
nsresult rv;
if(!XPCConvert::NativeInterface2JSObject(lccx, rval, nsnull,
aHelper, iid, iface,
PR_TRUE, OBJ_IS_NOT_GLOBAL, &rv))
if (!XPCConvert::NativeInterface2JSObject(lccx, rval, nsnull,
aHelper, iid, iface,
PR_TRUE, OBJ_IS_NOT_GLOBAL, &rv))
{
// I can't tell if NativeInterface2JSObject throws JS exceptions
// or not. This is a sloppy stab at the right semantics; the
// method really ought to be fixed to behave consistently.
if(!JS_IsExceptionPending(cx))
if (!JS_IsExceptionPending(cx))
xpc_qsThrow(cx, NS_FAILED(rv) ? rv : NS_ERROR_UNEXPECTED);
return JS_FALSE;
}
#ifdef DEBUG
JSObject* jsobj = JSVAL_TO_OBJECT(*rval);
if(jsobj && !js::GetObjectParent(jsobj))
if (jsobj && !js::GetObjectParent(jsobj))
NS_ASSERTION(js::GetObjectClass(jsobj)->flags & JSCLASS_IS_GLOBAL,
"Why did we recreate this wrapper?");
#endif
@ -1189,7 +1189,7 @@ xpc_qsVariantToJsval(XPCLazyCallContext &lccx,
{
// From the T_INTERFACE case in XPCConvert::NativeData2JS.
// Error handling is in XPCWrappedNative::CallMethod.
if(p)
if (p)
{
nsresult rv;
JSBool ok = XPCVariant::VariantDataToJS(lccx, p, &rv, rval);

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

@ -243,7 +243,7 @@ xpc_qsInt32ToJsval(JSContext *cx, PRInt32 i, jsval *rv)
inline JSBool
xpc_qsUint32ToJsval(JSContext *cx, PRUint32 u, jsval *rv)
{
if(u <= JSVAL_INT_MAX)
if (u <= JSVAL_INT_MAX)
*rv = INT_TO_JSVAL(u);
else
*rv = DOUBLE_TO_JSVAL(u);
@ -355,18 +355,18 @@ protected:
StringificationBehavior nullBehavior,
StringificationBehavior undefinedBehavior) {
JSString *s;
if(JSVAL_IS_STRING(v))
if (JSVAL_IS_STRING(v))
{
s = JSVAL_TO_STRING(v);
}
else
{
StringificationBehavior behavior = eStringify;
if(JSVAL_IS_NULL(v))
if (JSVAL_IS_NULL(v))
{
behavior = nullBehavior;
}
else if(JSVAL_IS_VOID(v))
else if (JSVAL_IS_VOID(v))
{
behavior = undefinedBehavior;
}
@ -385,7 +385,7 @@ protected:
}
s = JS_ValueToString(cx, v);
if(!s)
if (!s)
{
mValid = JS_FALSE;
return nsnull;
@ -540,7 +540,7 @@ xpc_qsUnwrapThis(JSContext *cx,
XPCWrappedNative *wrapper;
XPCWrappedNativeTearOff *tearoff;
nsresult rv = getWrapper(cx, obj, callee, &wrapper, &obj, &tearoff);
if(NS_SUCCEEDED(rv))
if (NS_SUCCEEDED(rv))
rv = castNative(cx, wrapper, obj, tearoff, NS_GET_TEMPLATE_IID(T),
reinterpret_cast<void **>(ppThis), pThisRef, pThisVal,
lccx);
@ -567,7 +567,7 @@ castNativeFromWrapper(JSContext *cx,
XPCWrappedNativeTearOff *tearoff;
JSObject *cur;
if(!callee && IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
if (!callee && IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
{
cur = obj;
wrapper = IS_WN_WRAPPER_OBJECT(cur) ?
@ -583,7 +583,7 @@ castNativeFromWrapper(JSContext *cx,
}
nsISupports *native;
if(wrapper)
if (wrapper)
{
native = wrapper->GetIdentityObject();
cur = wrapper->GetFlatJSObject();
@ -597,22 +597,22 @@ castNativeFromWrapper(JSContext *cx,
*rv = NS_ERROR_XPC_BAD_CONVERT_JS;
if(!native)
if (!native)
return nsnull;
NS_ASSERTION(IS_WRAPPER_CLASS(js::GetObjectClass(cur)), "Not a wrapper?");
XPCNativeScriptableSharedJSClass *clasp =
(XPCNativeScriptableSharedJSClass*)js::GetObjectClass(cur);
if(!(clasp->interfacesBitmap & (1 << interfaceBit)))
if (!(clasp->interfacesBitmap & (1 << interfaceBit)))
return nsnull;
*pRef = nsnull;
*pVal = OBJECT_TO_JSVAL(cur);
if(lccx)
if (lccx)
{
if(wrapper)
if (wrapper)
lccx->SetWrapper(wrapper, tearoff);
else
lccx->SetWrapper(cur);
@ -674,7 +674,7 @@ castNativeArgFromWrapper(JSContext *cx,
nsresult *rv NS_OUTPARAM)
{
JSObject *src = xpc_qsUnwrapObj(v, pArgRef, rv);
if(!src)
if (!src)
return nsnull;
return castNativeFromWrapper(cx, src, nsnull, bit, pArgRef, vp, nsnull, rv);

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

@ -76,10 +76,10 @@ BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper,
JSBool resolved;
*_retval = !!JS_ResolveStandardClass(cx, obj, id, &resolved);
if(!*_retval)
if (!*_retval)
return NS_OK;
if(resolved)
if (resolved)
{
*objp = obj;
return NS_OK;
@ -99,7 +99,7 @@ BackstagePass::GetInterfaces(PRUint32 *aCount, nsIID * **aArray)
*aCount = count;
nsIID **array;
*aArray = array = static_cast<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
if(!array)
if (!array)
return NS_ERROR_OUT_OF_MEMORY;
PRUint32 index = 0;

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

@ -80,11 +80,11 @@ private:
nsresult
XPCJSStack::CreateStack(JSContext* cx, nsIStackFrame** stack)
{
if(!cx)
if (!cx)
return NS_ERROR_FAILURE;
JSStackFrame *fp = NULL;
if(!JS_FrameIterator(cx, &fp))
if (!JS_FrameIterator(cx, &fp))
return NS_ERROR_FAILURE;
return XPCJSStackFrame::CreateStack(cx, fp, (XPCJSStackFrame**) stack);
}
@ -119,9 +119,9 @@ XPCJSStackFrame::XPCJSStackFrame()
XPCJSStackFrame::~XPCJSStackFrame()
{
if(mFilename)
if (mFilename)
nsMemory::Free(mFilename);
if(mFunname)
if (mFunname)
nsMemory::Free(mFunname);
}
@ -136,9 +136,9 @@ XPCJSStackFrame::CreateStack(JSContext* cx, JSStackFrame* fp,
nsRefPtr<XPCJSStackFrame> first = new XPCJSStackFrame();
nsRefPtr<XPCJSStackFrame> self = first;
while(fp && self)
while (fp && self)
{
if(!JS_IsScriptFrame(cx, fp))
if (!JS_IsScriptFrame(cx, fp))
{
self->mLanguage = nsIProgrammingLanguage::CPLUSPLUS;
}
@ -147,13 +147,13 @@ XPCJSStackFrame::CreateStack(JSContext* cx, JSStackFrame* fp,
self->mLanguage = nsIProgrammingLanguage::JAVASCRIPT;
JSScript* script = JS_GetFrameScript(cx, fp);
jsbytecode* pc = JS_GetFramePC(cx, fp);
if(script && pc)
if (script && pc)
{
JS::AutoEnterFrameCompartment ac;
if(ac.enter(cx, fp))
if (ac.enter(cx, fp))
{
const char* filename = JS_GetScriptFilename(cx, script);
if(filename)
if (filename)
{
self->mFilename = (char*)
nsMemory::Clone(filename,
@ -163,16 +163,16 @@ XPCJSStackFrame::CreateStack(JSContext* cx, JSStackFrame* fp,
self->mLineno = (PRInt32) JS_PCToLineNumber(cx, script, pc);
JSFunction* fun = JS_GetFrameFunction(cx, fp);
if(fun)
if (fun)
{
JSString *funid = JS_GetFunctionId(fun);
if(funid)
if (funid)
{
size_t length = JS_GetStringEncodingLength(cx, funid);
if(length != size_t(-1))
if (length != size_t(-1))
{
self->mFunname = static_cast<char *>(nsMemory::Alloc(length + 1));
if(self->mFunname)
if (self->mFunname)
{
JS_EncodeStringToBuffer(funid, self->mFunname, length);
self->mFunname[length] = '\0';
@ -192,7 +192,7 @@ XPCJSStackFrame::CreateStack(JSContext* cx, JSStackFrame* fp,
{
fp = NULL;
}
else if(JS_FrameIterator(cx, &fp))
else if (JS_FrameIterator(cx, &fp))
{
XPCJSStackFrame* frame = new XPCJSStackFrame();
self->mCaller = frame;
@ -215,41 +215,41 @@ XPCJSStackFrame::CreateStackFrameLocation(PRUint32 aLanguage,
{
JSBool failed = JS_FALSE;
XPCJSStackFrame* self = new XPCJSStackFrame();
if(self)
if (self)
NS_ADDREF(self);
else
failed = JS_TRUE;
if(!failed)
if (!failed)
{
self->mLanguage = aLanguage;
self->mLineno = aLineNumber;
}
if(!failed && aFilename)
if (!failed && aFilename)
{
self->mFilename = (char*)
nsMemory::Clone(aFilename,
sizeof(char)*(strlen(aFilename)+1));
if(!self->mFilename)
if (!self->mFilename)
failed = JS_TRUE;
}
if(!failed && aFunctionName)
if (!failed && aFunctionName)
{
self->mFunname = (char*)
nsMemory::Clone(aFunctionName,
sizeof(char)*(strlen(aFunctionName)+1));
if(!self->mFunname)
if (!self->mFunname)
failed = JS_TRUE;
}
if(!failed && aCaller)
if (!failed && aCaller)
{
self->mCaller = aCaller;
}
if(failed && self)
if (failed && self)
{
NS_RELEASE(self); // sets self to nsnull
}
@ -272,7 +272,7 @@ NS_IMETHODIMP XPCJSStackFrame::GetLanguageName(char * *aLanguageName)
static const char cpp[] = "C++";
char* temp;
if(IsJSFrame())
if (IsJSFrame())
*aLanguageName = temp = (char*) nsMemory::Clone(js, sizeof(js));
else
*aLanguageName = temp = (char*) nsMemory::Clone(cpp, sizeof(cpp));
@ -325,7 +325,7 @@ NS_IMETHODIMP XPCJSStackFrame::ToString(char **_retval)
sizeof(format) + 6 /* space for lineno */;
char* buf = (char*) nsMemory::Alloc(len);
if(!buf)
if (!buf)
return NS_ERROR_OUT_OF_MEMORY;
JS_snprintf(buf, len, format, frametype, filename, funname, mLineno);

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

@ -62,7 +62,7 @@ XPCJSContextStack::XPCJSContextStack()
XPCJSContextStack::~XPCJSContextStack()
{
if(mOwnSafeJSContext)
if (mOwnSafeJSContext)
{
JS_SetContextThread(mOwnSafeJSContext);
JS_DestroyContext(mOwnSafeJSContext);
@ -94,25 +94,25 @@ XPCJSContextStack::Pop(JSContext * *_retval)
PRUint32 idx = mStack.Length() - 1; // The thing we're popping
if(_retval)
if (_retval)
*_retval = mStack[idx].cx;
mStack.RemoveElementAt(idx);
if(idx > 0)
if (idx > 0)
{
--idx; // Advance to new top of the stack
XPCJSContextInfo & e = mStack[idx];
NS_ASSERTION(!e.suspendDepth || e.cx, "Shouldn't have suspendDepth without a cx!");
if(e.cx)
if (e.cx)
{
if(e.suspendDepth)
if (e.suspendDepth)
{
JS_ResumeRequest(e.cx, e.suspendDepth);
e.suspendDepth = 0;
}
if(e.savedFrameChain)
if (e.savedFrameChain)
{
// Pop() can be called outside any request for e.cx.
JSAutoRequest ar(e.cx);
@ -128,10 +128,10 @@ static nsIPrincipal*
GetPrincipalFromCx(JSContext *cx)
{
nsIScriptContextPrincipal* scp = GetScriptContextPrincipalFromJSContext(cx);
if(scp)
if (scp)
{
nsIScriptObjectPrincipal* globalData = scp->GetObjectPrincipal();
if(globalData)
if (globalData)
return globalData->GetPrincipal();
}
return nsnull;
@ -142,22 +142,22 @@ NS_IMETHODIMP
XPCJSContextStack::Push(JSContext * cx)
{
JS_ASSERT_IF(cx, JS_GetContextThread(cx));
if(mStack.Length() > 0)
if (mStack.Length() > 0)
{
XPCJSContextInfo & e = mStack[mStack.Length() - 1];
if(e.cx)
if (e.cx)
{
if(e.cx == cx)
if (e.cx == cx)
{
nsIScriptSecurityManager* ssm = XPCWrapper::GetSecurityManager();
if(ssm)
if (ssm)
{
if(nsIPrincipal* globalObjectPrincipal = GetPrincipalFromCx(cx))
if (nsIPrincipal* globalObjectPrincipal = GetPrincipalFromCx(cx))
{
nsIPrincipal* subjectPrincipal = ssm->GetCxSubjectPrincipal(cx);
bool equals = false;
globalObjectPrincipal->Equals(subjectPrincipal, &equals);
if(equals)
if (equals)
{
goto append;
}
@ -168,18 +168,18 @@ XPCJSContextStack::Push(JSContext * cx)
{
// Push() can be called outside any request for e.cx.
JSAutoRequest ar(e.cx);
if(!JS_SaveFrameChain(e.cx))
if (!JS_SaveFrameChain(e.cx))
return NS_ERROR_OUT_OF_MEMORY;
e.savedFrameChain = true;
}
if(!cx)
if (!cx)
e.suspendDepth = JS_SuspendRequest(e.cx);
}
}
append:
if(!mStack.AppendElement(cx))
if (!mStack.AppendElement(cx))
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
@ -188,8 +188,8 @@ XPCJSContextStack::Push(JSContext * cx)
JSBool
XPCJSContextStack::DEBUG_StackHasJSContext(JSContext* aJSContext)
{
for(PRUint32 i = 0; i < mStack.Length(); i++)
if(aJSContext == mStack[i].cx)
for (PRUint32 i = 0; i < mStack.Length(); i++)
if (aJSContext == mStack[i].cx)
return JS_TRUE;
return JS_FALSE;
}
@ -222,19 +222,19 @@ static JSClass global_class = {
NS_IMETHODIMP
XPCJSContextStack::GetSafeJSContext(JSContext * *aSafeJSContext)
{
if(!mSafeJSContext)
if (!mSafeJSContext)
{
// Start by getting the principal holder and principal for this
// context. If we can't manage that, don't bother with the rest.
nsRefPtr<nsNullPrincipal> principal = new nsNullPrincipal();
nsCOMPtr<nsIScriptObjectPrincipal> sop;
if(principal)
if (principal)
{
nsresult rv = principal->Init();
if(NS_SUCCEEDED(rv))
if (NS_SUCCEEDED(rv))
sop = new PrincipalHolder(principal);
}
if(!sop)
if (!sop)
{
*aSafeJSContext = nsnull;
return NS_ERROR_FAILURE;
@ -246,11 +246,11 @@ XPCJSContextStack::GetSafeJSContext(JSContext * *aSafeJSContext)
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
nsCOMPtr<nsIXPConnect> xpcholder(static_cast<nsIXPConnect*>(xpc));
if(xpc && (xpcrt = xpc->GetRuntime()) && (rt = xpcrt->GetJSRuntime()))
if (xpc && (xpcrt = xpc->GetRuntime()) && (rt = xpcrt->GetJSRuntime()))
{
JSObject *glob;
mSafeJSContext = JS_NewContext(rt, 8192);
if(mSafeJSContext)
if (mSafeJSContext)
{
// scoped JS Request
JSAutoRequest req(mSafeJSContext);
@ -262,10 +262,10 @@ XPCJSContextStack::GetSafeJSContext(JSContext * *aSafeJSContext)
&global_class,
principal, &glob,
&compartment);
if(NS_FAILED(rv))
if (NS_FAILED(rv))
glob = nsnull;
if(glob)
if (glob)
{
// Make sure the context is associated with a proper compartment
// and not the default compartment.
@ -275,7 +275,7 @@ XPCJSContextStack::GetSafeJSContext(JSContext * *aSafeJSContext)
// InitClasses
nsIScriptObjectPrincipal* priv = nsnull;
sop.swap(priv);
if(!JS_SetPrivate(mSafeJSContext, glob, priv))
if (!JS_SetPrivate(mSafeJSContext, glob, priv))
{
// Drop the whole thing
NS_RELEASE(priv);
@ -287,13 +287,13 @@ XPCJSContextStack::GetSafeJSContext(JSContext * *aSafeJSContext)
// nsIScriptObjectPrincipal ownership is either handled by the
// nsCOMPtr or dealt with, or we'll release in the finalize
// hook.
if(glob && NS_FAILED(xpc->InitClasses(mSafeJSContext, glob)))
if (glob && NS_FAILED(xpc->InitClasses(mSafeJSContext, glob)))
{
glob = nsnull;
}
}
if(mSafeJSContext && !glob)
if (mSafeJSContext && !glob)
{
// Destroy the context outside the scope of JSAutoRequest that
// uses the context in its destructor.
@ -332,7 +332,7 @@ XPCPerThreadData::XPCPerThreadData()
#endif
{
MOZ_COUNT_CTOR(xpcPerThreadData);
if(gLock)
if (gLock)
{
MutexAutoLock lock(*gLock);
mNextThread = gThreads;
@ -343,14 +343,14 @@ XPCPerThreadData::XPCPerThreadData()
void
XPCPerThreadData::Cleanup()
{
while(mAutoRoots)
while (mAutoRoots)
mAutoRoots->Unlink();
NS_IF_RELEASE(mExceptionManager);
NS_IF_RELEASE(mException);
delete mJSContextStack;
mJSContextStack = nsnull;
if(mCallContext)
if (mCallContext)
mCallContext->SystemIsBeingShutDown();
}
@ -366,17 +366,17 @@ XPCPerThreadData::~XPCPerThreadData()
Cleanup();
// Unlink 'this' from the list of threads.
if(gLock)
if (gLock)
{
MutexAutoLock lock(*gLock);
if(gThreads == this)
if (gThreads == this)
gThreads = mNextThread;
else
{
XPCPerThreadData* cur = gThreads;
while(cur)
while (cur)
{
if(cur->mNextThread == this)
if (cur->mNextThread == this)
{
cur->mNextThread = mNextThread;
break;
@ -388,7 +388,7 @@ XPCPerThreadData::~XPCPerThreadData()
doDestroyLock = PR_TRUE;
}
if(gLock && doDestroyLock)
if (gLock && doDestroyLock)
{
delete gLock;
gLock = nsnull;
@ -408,22 +408,22 @@ void XPCPerThreadData::TraceJS(JSTracer *trc)
{
static int maxLength = 0;
int length = 0;
for(AutoMarkingPtr* p = mAutoRoots; p; p = p->GetNext())
for (AutoMarkingPtr* p = mAutoRoots; p; p = p->GetNext())
length++;
if(length > maxLength)
if (length > maxLength)
maxLength = length;
printf("XPC gc on thread %x with %d AutoMarkingPtrs (%d max so far)\n",
this, length, maxLength);
}
#endif
if(mAutoRoots)
if (mAutoRoots)
mAutoRoots->TraceJS(trc);
}
void XPCPerThreadData::MarkAutoRootsAfterJSFinalize()
{
if(mAutoRoots)
if (mAutoRoots)
mAutoRoots->MarkAfterJSFinalize();
}
@ -433,19 +433,19 @@ XPCPerThreadData::GetDataImpl(JSContext *cx)
{
XPCPerThreadData* data;
if(!gLock)
if (!gLock)
{
gLock = new Mutex("XPCPerThreadData.gLock");
}
if(gTLSIndex == BAD_TLS_INDEX)
if (gTLSIndex == BAD_TLS_INDEX)
{
MutexAutoLock lock(*gLock);
// check again now that we have the lock...
if(gTLSIndex == BAD_TLS_INDEX)
if (gTLSIndex == BAD_TLS_INDEX)
{
if(PR_FAILURE ==
PR_NewThreadPrivateIndex(&gTLSIndex, xpc_ThreadDataDtorCB))
if (PR_FAILURE ==
PR_NewThreadPrivateIndex(&gTLSIndex, xpc_ThreadDataDtorCB))
{
NS_ERROR("PR_NewThreadPrivateIndex failed!");
gTLSIndex = BAD_TLS_INDEX;
@ -455,16 +455,16 @@ XPCPerThreadData::GetDataImpl(JSContext *cx)
}
data = (XPCPerThreadData*) PR_GetThreadPrivate(gTLSIndex);
if(!data)
if (!data)
{
data = new XPCPerThreadData();
if(!data || !data->IsValid())
if (!data || !data->IsValid())
{
NS_ERROR("new XPCPerThreadData() failed!");
delete data;
return nsnull;
}
if(PR_FAILURE == PR_SetThreadPrivate(gTLSIndex, data))
if (PR_FAILURE == PR_SetThreadPrivate(gTLSIndex, data))
{
NS_ERROR("PR_SetThreadPrivate failed!");
delete data;
@ -472,7 +472,7 @@ XPCPerThreadData::GetDataImpl(JSContext *cx)
}
}
if(cx && !sMainJSThread && NS_IsMainThread())
if (cx && !sMainJSThread && NS_IsMainThread())
{
sMainJSThread = cx->thread();
@ -498,18 +498,18 @@ XPCPerThreadData::CleanupAllThreads()
int count = 0;
int i;
if(gLock)
if (gLock)
{
MutexAutoLock lock(*gLock);
for(XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread)
for (XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread)
count++;
stacks = (XPCJSContextStack**) new XPCJSContextStack*[count] ;
if(stacks)
if (stacks)
{
i = 0;
for(XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread)
for (XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread)
{
stacks[i++] = cur->mJSContextStack;
cur->mJSContextStack = nsnull;
@ -518,14 +518,14 @@ XPCPerThreadData::CleanupAllThreads()
}
}
if(stacks)
if (stacks)
{
for(i = 0; i < count; i++)
for (i = 0; i < count; i++)
delete stacks[i];
delete [] stacks;
}
if(gTLSIndex != BAD_TLS_INDEX)
if (gTLSIndex != BAD_TLS_INDEX)
PR_SetThreadPrivate(gTLSIndex, nsnull);
}
@ -545,10 +545,10 @@ nsXPCJSContextStackIterator::Reset(nsIJSContextStack *aStack)
NS_ASSERTION(aStack == nsXPConnect::GetXPConnect(),
"aStack must be implemented by XPConnect singleton");
XPCPerThreadData* data = XPCPerThreadData::GetData(nsnull);
if(!data)
if (!data)
return NS_ERROR_FAILURE;
mStack = data->GetJSContextStack()->GetStack();
if(mStack->IsEmpty())
if (mStack->IsEmpty())
mStack = nsnull;
else
mPosition = mStack->Length() - 1;
@ -566,12 +566,12 @@ nsXPCJSContextStackIterator::Done(bool *aDone)
NS_IMETHODIMP
nsXPCJSContextStackIterator::Prev(JSContext **aContext)
{
if(!mStack)
if (!mStack)
return NS_ERROR_NOT_INITIALIZED;
*aContext = mStack->ElementAt(mPosition).cx;
if(mPosition == 0)
if (mPosition == 0)
mStack = nsnull;
else
--mPosition;

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

@ -50,9 +50,9 @@ void
XPCThrower::Throw(nsresult rv, JSContext* cx)
{
const char* format;
if(JS_IsExceptionPending(cx))
if (JS_IsExceptionPending(cx))
return;
if(!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format))
if (!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format))
format = "";
BuildAndThrowException(cx, rv, format);
}
@ -67,20 +67,20 @@ JSBool
XPCThrower::CheckForPendingException(nsresult result, JSContext *cx)
{
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
if(!xpc)
if (!xpc)
return JS_FALSE;
nsCOMPtr<nsIException> e;
xpc->GetPendingException(getter_AddRefs(e));
if(!e)
if (!e)
return JS_FALSE;
xpc->SetPendingException(nsnull);
nsresult e_result;
if(NS_FAILED(e->GetResult(&e_result)) || e_result != result)
if (NS_FAILED(e->GetResult(&e_result)) || e_result != result)
return JS_FALSE;
if(!ThrowExceptionObject(cx, e))
if (!ThrowExceptionObject(cx, e))
JS_ReportOutOfMemory(cx);
return JS_TRUE;
}
@ -92,20 +92,20 @@ XPCThrower::Throw(nsresult rv, XPCCallContext& ccx)
char* sz;
const char* format;
if(CheckForPendingException(rv, ccx))
if (CheckForPendingException(rv, ccx))
return;
if(!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format))
if (!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format))
format = "";
sz = (char*) format;
if(sz && sVerbose)
if (sz && sVerbose)
Verbosify(ccx, &sz, PR_FALSE);
BuildAndThrowException(ccx, rv, sz);
if(sz && sz != format)
if (sz && sz != format)
JS_smprintf_free(sz);
}
@ -125,25 +125,25 @@ XPCThrower::ThrowBadResult(nsresult rv, nsresult result, XPCCallContext& ccx)
* call. So we'll just throw that exception into our JS.
*/
if(CheckForPendingException(result, ccx))
if (CheckForPendingException(result, ccx))
return;
// else...
if(!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format) || !format)
if (!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format) || !format)
format = "";
if(nsXPCException::NameAndFormatForNSResult(result, &name, nsnull) && name)
if (nsXPCException::NameAndFormatForNSResult(result, &name, nsnull) && name)
sz = JS_smprintf("%s 0x%x (%s)", format, result, name);
else
sz = JS_smprintf("%s 0x%x", format, result);
if(sz && sVerbose)
if (sz && sVerbose)
Verbosify(ccx, &sz, PR_TRUE);
BuildAndThrowException(ccx, result, sz);
if(sz)
if (sz)
JS_smprintf_free(sz);
}
@ -154,17 +154,17 @@ XPCThrower::ThrowBadParam(nsresult rv, uintN paramNum, XPCCallContext& ccx)
char* sz;
const char* format;
if(!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format))
if (!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format))
format = "";
sz = JS_smprintf("%s arg %d", format, paramNum);
if(sz && sVerbose)
if (sz && sVerbose)
Verbosify(ccx, &sz, PR_TRUE);
BuildAndThrowException(ccx, rv, sz);
if(sz)
if (sz)
JS_smprintf_free(sz);
}
@ -176,22 +176,22 @@ XPCThrower::Verbosify(XPCCallContext& ccx,
{
char* sz = nsnull;
if(ccx.HasInterfaceAndMember())
if (ccx.HasInterfaceAndMember())
{
XPCNativeInterface* iface = ccx.GetInterface();
jsid id = ccx.GetMember()->GetName();
JSAutoByteString bytes;
const char *name = JSID_IS_VOID(id) ? "Unknown" : bytes.encode(ccx, JSID_TO_STRING(id));
if(!name)
if (!name)
{
name = "";
}
sz = JS_smprintf("%s [%s.%s]", *psz, iface->GetNameString(), name);
}
if(sz)
if (sz)
{
if(own)
if (own)
JS_smprintf_free(*psz);
*psz = sz;
}
@ -204,16 +204,16 @@ XPCThrower::BuildAndThrowException(JSContext* cx, nsresult rv, const char* sz)
JSBool success = JS_FALSE;
/* no need to set an expection if the security manager already has */
if(rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO && JS_IsExceptionPending(cx))
if (rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO && JS_IsExceptionPending(cx))
return;
nsCOMPtr<nsIException> finalException;
nsCOMPtr<nsIException> defaultException;
nsXPCException::NewException(sz, rv, nsnull, nsnull, getter_AddRefs(defaultException));
XPCPerThreadData* tls = XPCPerThreadData::GetData(cx);
if(tls)
if (tls)
{
nsIExceptionManager * exceptionManager = tls->GetExceptionManager();
if(exceptionManager)
if (exceptionManager)
{
// Ask the provider for the exception, if there is no provider
// we expect it to set e to null
@ -222,7 +222,7 @@ XPCThrower::BuildAndThrowException(JSContext* cx, nsresult rv, const char* sz)
getter_AddRefs(finalException));
// We should get at least the defaultException back,
// but just in case
if(finalException == nsnull)
if (finalException == nsnull)
{
finalException = defaultException;
}
@ -230,11 +230,11 @@ XPCThrower::BuildAndThrowException(JSContext* cx, nsresult rv, const char* sz)
}
// XXX Should we put the following test and call to JS_ReportOutOfMemory
// inside this test?
if(finalException)
if (finalException)
success = ThrowExceptionObject(cx, finalException);
// If we weren't able to build or throw an exception we're
// most likely out of memory
if(!success)
if (!success)
JS_ReportOutOfMemory(cx);
}
@ -244,27 +244,27 @@ IsCallerChrome(JSContext* cx)
nsresult rv;
nsCOMPtr<nsIScriptSecurityManager> secMan;
if(XPCPerThreadData::IsMainThread(cx))
if (XPCPerThreadData::IsMainThread(cx))
{
secMan = XPCWrapper::GetSecurityManager();
}
else
{
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
if(!xpc)
if (!xpc)
return PR_FALSE;
nsCOMPtr<nsIXPCSecurityManager> xpcSecMan;
PRUint16 flags = 0;
rv = xpc->GetSecurityManagerForJSContext(cx, getter_AddRefs(xpcSecMan),
&flags);
if(NS_FAILED(rv) || !xpcSecMan)
if (NS_FAILED(rv) || !xpcSecMan)
return PR_FALSE;
secMan = do_QueryInterface(xpcSecMan);
}
if(!secMan)
if (!secMan)
return PR_FALSE;
bool isChrome;
@ -277,7 +277,7 @@ JSBool
XPCThrower::ThrowExceptionObject(JSContext* cx, nsIException* e)
{
JSBool success = JS_FALSE;
if(e)
if (e)
{
nsCOMPtr<nsIXPCException> xpcEx;
jsval thrown;
@ -286,29 +286,29 @@ XPCThrower::ThrowExceptionObject(JSContext* cx, nsIException* e)
// If we stored the original thrown JS value in the exception
// (see XPCConvert::ConstructException) and we are in a web
// context (i.e., not chrome), rethrow the original value.
if(!IsCallerChrome(cx) &&
(xpcEx = do_QueryInterface(e)) &&
NS_SUCCEEDED(xpcEx->StealJSVal(&thrown)))
if (!IsCallerChrome(cx) &&
(xpcEx = do_QueryInterface(e)) &&
NS_SUCCEEDED(xpcEx->StealJSVal(&thrown)))
{
if (!JS_WrapValue(cx, &thrown))
return JS_FALSE;
JS_SetPendingException(cx, thrown);
success = JS_TRUE;
}
else if((xpc = nsXPConnect::GetXPConnect()))
else if ((xpc = nsXPConnect::GetXPConnect()))
{
JSObject* glob = JS_GetGlobalForScopeChain(cx);
if(!glob)
if (!glob)
return JS_FALSE;
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
nsresult rv = xpc->WrapNative(cx, glob, e,
NS_GET_IID(nsIException),
getter_AddRefs(holder));
if(NS_SUCCEEDED(rv) && holder)
if (NS_SUCCEEDED(rv) && holder)
{
JSObject* obj;
if(NS_SUCCEEDED(holder->GetJSObject(&obj)))
if (NS_SUCCEEDED(holder->GetJSObject(&obj)))
{
JS_SetPendingException(cx, OBJECT_TO_JSVAL(obj));
success = JS_TRUE;

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

@ -61,7 +61,7 @@ XPCVariant::XPCVariant(XPCCallContext& ccx, jsval aJSVal)
: mJSVal(aJSVal)
{
nsVariant::Initialize(&mData);
if(!JSVAL_IS_PRIMITIVE(mJSVal))
if (!JSVAL_IS_PRIMITIVE(mJSVal))
{
JSObject *obj = JS_ObjectToInnerObject(ccx, JSVAL_TO_OBJECT(mJSVal));
@ -91,7 +91,7 @@ XPCTraceableVariant::~XPCTraceableVariant()
// If val is JSVAL_STRING, we don't need to clean anything up; simply
// removing the string from the root set is good.
if(!JSVAL_IS_STRING(val))
if (!JSVAL_IS_STRING(val))
nsVariant::Cleanup(&mData);
if (!JSVAL_IS_NULL(val))
@ -118,7 +118,7 @@ XPCTraceableVariant::PrintTraceName(JSTracer* trc, char *buf, size_t bufsize)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(XPCVariant)
jsval val = tmp->GetJSValPreserveColor();
if(JSVAL_IS_OBJECT(val))
if (JSVAL_IS_OBJECT(val))
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT,
JSVAL_TO_OBJECT(val));
@ -130,11 +130,11 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(XPCVariant)
// We're sharing val's buffer, clear the pointer to it so Cleanup() won't
// try to delete it
if(JSVAL_IS_STRING(val))
if (JSVAL_IS_STRING(val))
tmp->mData.u.wstr.mWStringValue = nsnull;
nsVariant::Cleanup(&tmp->mData);
if(JSVAL_IS_TRACEABLE(val))
if (JSVAL_IS_TRACEABLE(val))
{
XPCTraceableVariant *v = static_cast<XPCTraceableVariant*>(tmp);
v->RemoveFromRootSet(nsXPConnect::GetRuntimeInstance()->GetMapLock());
@ -147,16 +147,16 @@ XPCVariant* XPCVariant::newVariant(XPCCallContext& ccx, jsval aJSVal)
{
XPCVariant* variant;
if(!JSVAL_IS_TRACEABLE(aJSVal))
if (!JSVAL_IS_TRACEABLE(aJSVal))
variant = new XPCVariant(ccx, aJSVal);
else
variant = new XPCTraceableVariant(ccx, aJSVal);
if(!variant)
if (!variant)
return nsnull;
NS_ADDREF(variant);
if(!variant->InitializeData(ccx))
if (!variant->InitializeData(ccx))
NS_RELEASE(variant); // Also sets variant to nsnull.
return variant;
@ -220,34 +220,34 @@ XPCArrayHomogenizer::GetTypeForArray(XPCCallContext& ccx, JSObject* array,
Type state = tUnk;
Type type;
for(jsuint i = 0; i < length; i++)
for (jsuint i = 0; i < length; i++)
{
jsval val;
if(!JS_GetElement(ccx, array, i, &val))
if (!JS_GetElement(ccx, array, i, &val))
return JS_FALSE;
if(JSVAL_IS_INT(val))
if (JSVAL_IS_INT(val))
type = tInt;
else if(JSVAL_IS_DOUBLE(val))
else if (JSVAL_IS_DOUBLE(val))
type = tDbl;
else if(JSVAL_IS_BOOLEAN(val))
else if (JSVAL_IS_BOOLEAN(val))
type = tBool;
else if(JSVAL_IS_VOID(val))
else if (JSVAL_IS_VOID(val))
{
state = tVar;
break;
}
else if(JSVAL_IS_NULL(val))
else if (JSVAL_IS_NULL(val))
type = tNull;
else if(JSVAL_IS_STRING(val))
else if (JSVAL_IS_STRING(val))
type = tStr;
else
{
NS_ASSERTION(JSVAL_IS_OBJECT(val), "invalid type of jsval!");
JSObject* jsobj = JSVAL_TO_OBJECT(val);
if(JS_IsArrayObject(ccx, jsobj))
if (JS_IsArrayObject(ccx, jsobj))
type = tArr;
else if(xpc_JSObjectIsID(ccx, jsobj))
else if (xpc_JSObjectIsID(ccx, jsobj))
type = tID;
else
type = tISup;
@ -263,11 +263,11 @@ XPCArrayHomogenizer::GetTypeForArray(XPCCallContext& ccx, JSObject* array,
NS_ASSERTION(state != tErr, "bad state table!");
NS_ASSERTION(state != tUnk, "bad state table!");
if(state == tVar)
if (state == tVar)
break;
}
switch(state)
switch (state)
{
case tInt :
*resultType = nsXPTType((uint8)TD_INT32);
@ -313,24 +313,24 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
jsval val = GetJSVal();
if(JSVAL_IS_INT(val))
if (JSVAL_IS_INT(val))
return NS_SUCCEEDED(nsVariant::SetFromInt32(&mData, JSVAL_TO_INT(val)));
if(JSVAL_IS_DOUBLE(val))
if (JSVAL_IS_DOUBLE(val))
return NS_SUCCEEDED(nsVariant::SetFromDouble(&mData,
JSVAL_TO_DOUBLE(val)));
if(JSVAL_IS_BOOLEAN(val))
if (JSVAL_IS_BOOLEAN(val))
return NS_SUCCEEDED(nsVariant::SetFromBool(&mData,
JSVAL_TO_BOOLEAN(val)));
if(JSVAL_IS_VOID(val))
if (JSVAL_IS_VOID(val))
return NS_SUCCEEDED(nsVariant::SetToVoid(&mData));
if(JSVAL_IS_NULL(val))
if (JSVAL_IS_NULL(val))
return NS_SUCCEEDED(nsVariant::SetToEmpty(&mData));
if(JSVAL_IS_STRING(val))
if (JSVAL_IS_STRING(val))
{
// Make our string immutable. This will also ensure null-termination,
// which nsVariant assumes for its PRUnichar* stuff.
JSString* str = JSVAL_TO_STRING(val);
if(!JS_MakeStringImmutable(ccx, str))
if (!JS_MakeStringImmutable(ccx, str))
return JS_FALSE;
// Don't use nsVariant::SetFromWStringWithSize, because that will copy
@ -363,16 +363,16 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
// Let's see if it is a xpcJSID.
const nsID* id = xpc_JSObjectToID(ccx, jsobj);
if(id)
if (id)
return NS_SUCCEEDED(nsVariant::SetFromID(&mData, *id));
// Let's see if it is a js array object.
jsuint len;
if(JS_IsArrayObject(ccx, jsobj) && JS_GetArrayLength(ccx, jsobj, &len))
if (JS_IsArrayObject(ccx, jsobj) && JS_GetArrayLength(ccx, jsobj, &len))
{
if(!len)
if (!len)
{
// Zero length array
nsVariant::SetToEmptyArray(&mData);
@ -382,16 +382,16 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
nsXPTType type;
nsID id;
if(!XPCArrayHomogenizer::GetTypeForArray(ccx, jsobj, len, &type, &id))
if (!XPCArrayHomogenizer::GetTypeForArray(ccx, jsobj, len, &type, &id))
return JS_FALSE;
if(!XPCConvert::JSArray2Native(ccx, &mData.u.array.mArrayValue,
val, len, len,
type, &id, nsnull))
if (!XPCConvert::JSArray2Native(ccx, &mData.u.array.mArrayValue,
val, len, len,
type, &id, nsnull))
return JS_FALSE;
mData.mType = nsIDataType::VTYPE_ARRAY;
if(type.IsInterfacePointer())
if (type.IsInterfacePointer())
mData.u.array.mArrayInterfaceID = id;
mData.u.array.mArrayCount = len;
mData.u.array.mArrayType = type.TagPart();
@ -433,28 +433,28 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
jsval realVal;
nsresult rv = variant->GetAsJSVal(&realVal);
if(NS_SUCCEEDED(rv) &&
(JSVAL_IS_PRIMITIVE(realVal) ||
type == nsIDataType::VTYPE_ARRAY ||
type == nsIDataType::VTYPE_EMPTY_ARRAY ||
type == nsIDataType::VTYPE_ID))
if (NS_SUCCEEDED(rv) &&
(JSVAL_IS_PRIMITIVE(realVal) ||
type == nsIDataType::VTYPE_ARRAY ||
type == nsIDataType::VTYPE_EMPTY_ARRAY ||
type == nsIDataType::VTYPE_ID))
{
JSContext *cx = lccx.GetJSContext();
if(!JS_WrapValue(cx, &realVal))
if (!JS_WrapValue(cx, &realVal))
return JS_FALSE;
*pJSVal = realVal;
return JS_TRUE;
}
nsCOMPtr<XPCVariant> xpcvariant = do_QueryInterface(variant);
if(xpcvariant && xpcvariant->mReturnRawObject)
if (xpcvariant && xpcvariant->mReturnRawObject)
{
NS_ASSERTION(type == nsIDataType::VTYPE_INTERFACE ||
type == nsIDataType::VTYPE_INTERFACE_IS,
"Weird variant");
JSContext *cx = lccx.GetJSContext();
if(!JS_WrapValue(cx, &realVal))
if (!JS_WrapValue(cx, &realVal))
return JS_FALSE;
*pJSVal = realVal;
return JS_TRUE;
@ -483,7 +483,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
NS_ABORT_IF_FALSE(js::GetObjectCompartment(lccx.GetScopeForNewJSObjects()) == cx->compartment,
"bad scope for new JSObjects");
switch(type)
switch (type)
{
case nsIDataType::VTYPE_INT8:
case nsIDataType::VTYPE_INT16:
@ -497,80 +497,80 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
case nsIDataType::VTYPE_DOUBLE:
{
// Easy. Handle inline.
if(NS_FAILED(variant->GetAsDouble(&xpctvar.val.d)))
if (NS_FAILED(variant->GetAsDouble(&xpctvar.val.d)))
return JS_FALSE;
return JS_NewNumberValue(cx, xpctvar.val.d, pJSVal);
}
case nsIDataType::VTYPE_BOOL:
{
// Easy. Handle inline.
if(NS_FAILED(variant->GetAsBool(&xpctvar.val.b)))
if (NS_FAILED(variant->GetAsBool(&xpctvar.val.b)))
return JS_FALSE;
*pJSVal = BOOLEAN_TO_JSVAL(xpctvar.val.b);
return JS_TRUE;
}
case nsIDataType::VTYPE_CHAR:
if(NS_FAILED(variant->GetAsChar(&xpctvar.val.c)))
if (NS_FAILED(variant->GetAsChar(&xpctvar.val.c)))
return JS_FALSE;
xpctvar.type = (uint8)TD_CHAR;
break;
case nsIDataType::VTYPE_WCHAR:
if(NS_FAILED(variant->GetAsWChar(&xpctvar.val.wc)))
if (NS_FAILED(variant->GetAsWChar(&xpctvar.val.wc)))
return JS_FALSE;
xpctvar.type = (uint8)TD_WCHAR;
break;
case nsIDataType::VTYPE_ID:
if(NS_FAILED(variant->GetAsID(&iid)))
if (NS_FAILED(variant->GetAsID(&iid)))
return JS_FALSE;
xpctvar.type = (uint8)(TD_PNSIID | XPT_TDP_POINTER);
xpctvar.val.p = &iid;
break;
case nsIDataType::VTYPE_ASTRING:
if(NS_FAILED(variant->GetAsAString(astring)))
if (NS_FAILED(variant->GetAsAString(astring)))
return JS_FALSE;
xpctvar.type = (uint8)(TD_ASTRING | XPT_TDP_POINTER);
xpctvar.val.p = &astring;
break;
case nsIDataType::VTYPE_DOMSTRING:
if(NS_FAILED(variant->GetAsAString(astring)))
if (NS_FAILED(variant->GetAsAString(astring)))
return JS_FALSE;
xpctvar.type = (uint8)(TD_DOMSTRING | XPT_TDP_POINTER);
xpctvar.val.p = &astring;
break;
case nsIDataType::VTYPE_CSTRING:
if(NS_FAILED(variant->GetAsACString(cString)))
if (NS_FAILED(variant->GetAsACString(cString)))
return JS_FALSE;
xpctvar.type = (uint8)(TD_CSTRING | XPT_TDP_POINTER);
xpctvar.val.p = &cString;
break;
case nsIDataType::VTYPE_UTF8STRING:
if(NS_FAILED(variant->GetAsAUTF8String(utf8String)))
if (NS_FAILED(variant->GetAsAUTF8String(utf8String)))
return JS_FALSE;
xpctvar.type = (uint8)(TD_UTF8STRING | XPT_TDP_POINTER);
xpctvar.val.p = &utf8String;
break;
case nsIDataType::VTYPE_CHAR_STR:
if(NS_FAILED(variant->GetAsString((char**)&xpctvar.val.p)))
if (NS_FAILED(variant->GetAsString((char**)&xpctvar.val.p)))
return JS_FALSE;
xpctvar.type = (uint8)(TD_PSTRING | XPT_TDP_POINTER);
xpctvar.SetValNeedsCleanup();
break;
case nsIDataType::VTYPE_STRING_SIZE_IS:
if(NS_FAILED(variant->GetAsStringWithSize(&size,
(char**)&xpctvar.val.p)))
if (NS_FAILED(variant->GetAsStringWithSize(&size,
(char**)&xpctvar.val.p)))
return JS_FALSE;
xpctvar.type = (uint8)(TD_PSTRING_SIZE_IS | XPT_TDP_POINTER);
xpctvar.SetValNeedsCleanup();
break;
case nsIDataType::VTYPE_WCHAR_STR:
if(NS_FAILED(variant->GetAsWString((PRUnichar**)&xpctvar.val.p)))
if (NS_FAILED(variant->GetAsWString((PRUnichar**)&xpctvar.val.p)))
return JS_FALSE;
xpctvar.type = (uint8)(TD_PWSTRING | XPT_TDP_POINTER);
xpctvar.SetValNeedsCleanup();
break;
case nsIDataType::VTYPE_WSTRING_SIZE_IS:
if(NS_FAILED(variant->GetAsWStringWithSize(&size,
(PRUnichar**)&xpctvar.val.p)))
if (NS_FAILED(variant->GetAsWStringWithSize(&size,
(PRUnichar**)&xpctvar.val.p)))
return JS_FALSE;
xpctvar.type = (uint8)(TD_PWSTRING_SIZE_IS | XPT_TDP_POINTER);
xpctvar.SetValNeedsCleanup();
@ -579,14 +579,14 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
case nsIDataType::VTYPE_INTERFACE_IS:
{
nsID* piid;
if(NS_FAILED(variant->GetAsInterface(&piid, &xpctvar.val.p)))
if (NS_FAILED(variant->GetAsInterface(&piid, &xpctvar.val.p)))
return JS_FALSE;
iid = *piid;
nsMemory::Free((char*)piid);
xpctvar.type = (uint8)(TD_INTERFACE_IS_TYPE | XPT_TDP_POINTER);
if(xpctvar.val.p)
if (xpctvar.val.p)
xpctvar.SetValNeedsCleanup();
break;
}
@ -600,7 +600,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
&du.u.array.mArrayInterfaceID,
&du.u.array.mArrayCount,
&du.u.array.mArrayValue);
if(NS_FAILED(rv))
if (NS_FAILED(rv))
return JS_FALSE;
// must exit via VARIANT_DONE from here on...
@ -611,7 +611,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
PRUint16 elementType = du.u.array.mArrayType;
const nsID* pid = nsnull;
switch(elementType)
switch (elementType)
{
case nsIDataType::VTYPE_INT8:
case nsIDataType::VTYPE_INT16:
@ -674,7 +674,7 @@ VARIANT_DONE:
case nsIDataType::VTYPE_EMPTY_ARRAY:
{
JSObject* array = JS_NewArrayObject(cx, 0, nsnull);
if(!array)
if (!array)
return JS_FALSE;
*pJSVal = OBJECT_TO_JSVAL(array);
return JS_TRUE;
@ -692,8 +692,8 @@ VARIANT_DONE:
// If we are here then we need to convert the data in the xpctvar.
if(xpctvar.type.TagPart() == TD_PSTRING_SIZE_IS ||
xpctvar.type.TagPart() == TD_PWSTRING_SIZE_IS)
if (xpctvar.type.TagPart() == TD_PSTRING_SIZE_IS ||
xpctvar.type.TagPart() == TD_PWSTRING_SIZE_IS)
{
success = XPCConvert::NativeStringWithSize2JS(cx, pJSVal,
(const void*)&xpctvar.val,

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

@ -76,14 +76,14 @@ NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Traverse
// comment above nsXPCWrappedJS::AddRef.
cb.NoteXPCOMChild(s);
if(refcnt > 1)
if (refcnt > 1)
// nsXPCWrappedJS roots its mJSObj when its refcount is > 1, see
// the comment above nsXPCWrappedJS::AddRef.
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT,
tmp->GetJSObjectPreserveColor());
nsXPCWrappedJS* root = tmp->GetRootWrapper();
if(root == tmp)
if (root == tmp)
// The root wrapper keeps the aggregated native object alive.
cb.NoteXPCOMChild(tmp->GetAggregatedNativeObject());
else
@ -102,14 +102,14 @@ nsXPCWrappedJS::AggregatedQueryInterface(REFNSIID aIID, void** aInstancePtr)
{
NS_ASSERTION(IsAggregatedToNative(), "bad AggregatedQueryInterface call");
if(!IsValid())
if (!IsValid())
return NS_ERROR_UNEXPECTED;
// Put this here rather that in DelegatedQueryInterface because it needs
// to be in QueryInterface before the possible delegation to 'outer', but
// we don't want to do this check twice in one call in the normal case:
// once in QueryInterface and once in DelegatedQueryInterface.
if(aIID.Equals(NS_GET_IID(nsIXPConnectWrappedJS)))
if (aIID.Equals(NS_GET_IID(nsIXPConnectWrappedJS)))
{
NS_ADDREF(this);
*aInstancePtr = (void*) static_cast<nsIXPConnectWrappedJS*>(this);
@ -122,7 +122,7 @@ nsXPCWrappedJS::AggregatedQueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_IMETHODIMP
nsXPCWrappedJS::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if(nsnull == aInstancePtr)
if (nsnull == aInstancePtr)
{
NS_PRECONDITION(0, "null pointer");
return NS_ERROR_NULL_POINTER;
@ -133,19 +133,19 @@ nsXPCWrappedJS::QueryInterface(REFNSIID aIID, void** aInstancePtr)
return NS_OK;
}
if(aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)))
if (aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)))
{
*aInstancePtr =
NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Upcast(this);
return NS_OK;
}
if(!IsValid())
if (!IsValid())
return NS_ERROR_UNEXPECTED;
// Always check for this first so that our 'outer' can get this interface
// from us without recurring into a call to the outer's QI!
if(aIID.Equals(NS_GET_IID(nsIXPConnectWrappedJS)))
if (aIID.Equals(NS_GET_IID(nsIXPConnectWrappedJS)))
{
NS_ADDREF(this);
*aInstancePtr = (void*) static_cast<nsIXPConnectWrappedJS*>(this);
@ -153,7 +153,7 @@ nsXPCWrappedJS::QueryInterface(REFNSIID aIID, void** aInstancePtr)
}
nsISupports* outer = GetAggregatedNativeObject();
if(outer)
if (outer)
return outer->QueryInterface(aIID, aInstancePtr);
// else...
@ -187,7 +187,7 @@ nsXPCWrappedJS::AddRef(void)
nsrefcnt cnt = NS_AtomicIncrementRefcnt(mRefCnt);
NS_LOG_ADDREF(this, cnt, "nsXPCWrappedJS", sizeof(*this));
if(2 == cnt && IsValid())
if (2 == cnt && IsValid())
{
XPCJSRuntime* rt = mClass->GetRuntime();
rt->AddWrappedJSRoot(this);
@ -211,21 +211,21 @@ do_decrement:
nsrefcnt cnt = NS_AtomicDecrementRefcnt(mRefCnt);
NS_LOG_RELEASE(this, cnt, "nsXPCWrappedJS");
if(0 == cnt)
if (0 == cnt)
{
delete this; // also unlinks us from chain
return 0;
}
if(1 == cnt)
if (1 == cnt)
{
if(IsValid())
if (IsValid())
RemoveFromRootSet(rt->GetMapLock());
// If we are not the root wrapper or if we are not being used from a
// weak reference, then this extra ref is not needed and we can let
// ourself be deleted.
// Note: HasWeakReferences() could only return true for the root.
if(!HasWeakReferences())
if (!HasWeakReferences())
goto do_decrement;
}
return cnt;
@ -254,7 +254,7 @@ nsXPCWrappedJS::PrintTraceName(JSTracer* trc, char *buf, size_t bufsize)
NS_IMETHODIMP
nsXPCWrappedJS::GetWeakReference(nsIWeakReference** aInstancePtr)
{
if(mRoot != this)
if (mRoot != this)
return mRoot->GetWeakReference(aInstancePtr);
return nsSupportsWeakReference::GetWeakReference(aInstancePtr);
@ -266,7 +266,7 @@ nsXPCWrappedJS::GetJSObject(JSObject** aJSObj)
NS_PRECONDITION(aJSObj, "bad param");
NS_PRECONDITION(IsValid(), "bad wrapper");
if(!(*aJSObj = GetJSObject()))
if (!(*aJSObj = GetJSObject()))
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
@ -288,20 +288,20 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
JSBool release_root = JS_FALSE;
map = rt->GetWrappedJSMap();
if(!map)
if (!map)
{
NS_ASSERTION(map,"bad map");
return NS_ERROR_FAILURE;
}
nsXPCWrappedJSClass::GetNewOrUsed(ccx, aIID, &clazz);
if(!clazz)
if (!clazz)
return NS_ERROR_FAILURE;
// from here on we need to return through 'return_wrapper'
// always find the root JSObject
rootJSObj = clazz->GetRootJSObject(ccx, aJSObj);
if(!rootJSObj)
if (!rootJSObj)
goto return_wrapper;
// look for the root wrapper, and if found, hold the map lock until
@ -310,10 +310,10 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
root = map->Find(rootJSObj);
if(root)
if (root)
{
if((nsnull != (wrapper = root->Find(aIID))) ||
(nsnull != (wrapper = root->FindInherited(aIID))))
if ((nsnull != (wrapper = root->Find(aIID))) ||
(nsnull != (wrapper = root->FindInherited(aIID))))
{
NS_ADDREF(wrapper);
goto return_wrapper;
@ -321,15 +321,15 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
}
}
if(!root)
if (!root)
{
// build the root wrapper
if(rootJSObj == aJSObj)
if (rootJSObj == aJSObj)
{
// the root will do double duty as the interface wrapper
wrapper = root = new nsXPCWrappedJS(ccx, aJSObj, clazz, nsnull,
aOuter);
if(root)
if (root)
{ // scoped lock
#if DEBUG_xpc_leaks
printf("Created nsXPCWrappedJS %p, JSObject is %p\n",
@ -346,13 +346,13 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
nsXPCWrappedJSClass* rootClazz = nsnull;
nsXPCWrappedJSClass::GetNewOrUsed(ccx, NS_GET_IID(nsISupports),
&rootClazz);
if(!rootClazz)
if (!rootClazz)
goto return_wrapper;
root = new nsXPCWrappedJS(ccx, rootJSObj, rootClazz, nsnull, aOuter);
NS_RELEASE(rootClazz);
if(!root)
if (!root)
goto return_wrapper;
release_root = JS_TRUE;
@ -372,10 +372,10 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
NS_ASSERTION(root,"bad root");
NS_ASSERTION(clazz,"bad clazz");
if(!wrapper)
if (!wrapper)
{
wrapper = new nsXPCWrappedJS(ccx, aJSObj, clazz, root, aOuter);
if(!wrapper)
if (!wrapper)
goto return_wrapper;
#if DEBUG_xpc_leaks
printf("Created nsXPCWrappedJS %p, JSObject is %p\n",
@ -387,13 +387,13 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
root->mNext = wrapper;
return_wrapper:
if(clazz)
if (clazz)
NS_RELEASE(clazz);
if(release_root)
if (release_root)
NS_RELEASE(root);
if(!wrapper)
if (!wrapper)
return NS_ERROR_FAILURE;
*wrapperResult = wrapper;
@ -415,7 +415,7 @@ nsXPCWrappedJS::nsXPCWrappedJS(XPCCallContext& ccx,
#ifdef DEBUG_stats_jband
static int count = 0;
static const int interval = 10;
if(0 == (++count % interval))
if (0 == (++count % interval))
printf("//////// %d instances of nsXPCWrappedJS created\n", count);
#endif
@ -427,7 +427,7 @@ nsXPCWrappedJS::nsXPCWrappedJS(XPCCallContext& ccx,
NS_ADDREF(aClass);
NS_IF_ADDREF(mOuter);
if(mRoot != this)
if (mRoot != this)
NS_ADDREF(mRoot);
}
@ -436,12 +436,12 @@ nsXPCWrappedJS::~nsXPCWrappedJS()
{
NS_PRECONDITION(0 == mRefCnt, "refcounting error");
if(mRoot == this)
if (mRoot == this)
{
// Remove this root wrapper from the map
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
JSObject2WrappedJSMap* map = rt->GetWrappedJSMap();
if(map)
if (map)
{
XPCAutoLock lock(rt->GetMapLock());
map->Remove(this);
@ -453,40 +453,40 @@ nsXPCWrappedJS::~nsXPCWrappedJS()
void
nsXPCWrappedJS::Unlink()
{
if(IsValid())
if (IsValid())
{
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
if(rt)
if (rt)
{
if(mRoot == this)
if (mRoot == this)
{
// remove this root wrapper from the map
JSObject2WrappedJSMap* map = rt->GetWrappedJSMap();
if(map)
if (map)
{
XPCAutoLock lock(rt->GetMapLock());
map->Remove(this);
}
}
if(mRefCnt > 1)
if (mRefCnt > 1)
RemoveFromRootSet(rt->GetMapLock());
}
mJSObj = nsnull;
}
if(mRoot == this)
if (mRoot == this)
{
ClearWeakReferences();
}
else if(mRoot)
else if (mRoot)
{
// unlink this wrapper
nsXPCWrappedJS* cur = mRoot;
while(1)
while (1)
{
if(cur->mNext == this)
if (cur->mNext == this)
{
cur->mNext = mNext;
break;
@ -517,12 +517,12 @@ nsXPCWrappedJS::Unlink()
nsXPCWrappedJS*
nsXPCWrappedJS::Find(REFNSIID aIID)
{
if(aIID.Equals(NS_GET_IID(nsISupports)))
if (aIID.Equals(NS_GET_IID(nsISupports)))
return mRoot;
for(nsXPCWrappedJS* cur = mRoot; cur; cur = cur->mNext)
for (nsXPCWrappedJS* cur = mRoot; cur; cur = cur->mNext)
{
if(aIID.Equals(cur->GetIID()))
if (aIID.Equals(cur->GetIID()))
return cur;
}
@ -535,11 +535,11 @@ nsXPCWrappedJS::FindInherited(REFNSIID aIID)
{
NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsISupports)), "bad call sequence");
for(nsXPCWrappedJS* cur = mRoot; cur; cur = cur->mNext)
for (nsXPCWrappedJS* cur = mRoot; cur; cur = cur->mNext)
{
bool found;
if(NS_SUCCEEDED(cur->GetClass()->GetInterfaceInfo()->
HasAncestor(&aIID, &found)) && found)
if (NS_SUCCEEDED(cur->GetClass()->GetInterfaceInfo()->
HasAncestor(&aIID, &found)) && found)
return cur;
}
@ -555,7 +555,7 @@ nsXPCWrappedJS::GetInterfaceInfo(nsIInterfaceInfo** info)
// Since failing to get this info will crash some platforms(!), we keep
// mClass valid at shutdown time.
if(!(*info = GetClass()->GetInterfaceInfo()))
if (!(*info = GetClass()->GetInterfaceInfo()))
return NS_ERROR_UNEXPECTED;
NS_ADDREF(*info);
return NS_OK;
@ -566,7 +566,7 @@ nsXPCWrappedJS::CallMethod(PRUint16 methodIndex,
const XPTMethodDescriptor* info,
nsXPTCMiniVariant* params)
{
if(!IsValid())
if (!IsValid())
return NS_ERROR_UNEXPECTED;
if (NS_IsMainThread() != mMainThread) {
NS_NAMED_LITERAL_STRING(kFmt, "Attempt to use JS function on a different thread calling %s.%s. JS objects may not be shared across threads.");
@ -610,7 +610,7 @@ nsXPCWrappedJS::SystemIsBeingShutDown(JSRuntime* rt)
mJSObj = nsnull;
// Notify other wrappers in the chain.
if(mNext)
if (mNext)
mNext->SystemIsBeingShutDown(rt);
}
@ -621,7 +621,7 @@ NS_IMETHODIMP
nsXPCWrappedJS::GetEnumerator(nsISimpleEnumerator * *aEnumerate)
{
XPCCallContext ccx(NATIVE_CALLER);
if(!ccx.IsValid())
if (!ccx.IsValid())
return NS_ERROR_UNEXPECTED;
return nsXPCWrappedJSClass::BuildPropertyEnumerator(ccx, GetJSObject(),
@ -633,14 +633,14 @@ NS_IMETHODIMP
nsXPCWrappedJS::GetProperty(const nsAString & name, nsIVariant **_retval)
{
XPCCallContext ccx(NATIVE_CALLER);
if(!ccx.IsValid())
if (!ccx.IsValid())
return NS_ERROR_UNEXPECTED;
nsStringBuffer* buf;
jsval jsstr = XPCStringConvert::ReadableToJSVal(ccx, name, &buf);
if(JSVAL_IS_NULL(jsstr))
if (JSVAL_IS_NULL(jsstr))
return NS_ERROR_OUT_OF_MEMORY;
if(buf)
if (buf)
buf->AddRef();
return nsXPCWrappedJSClass::
@ -662,28 +662,28 @@ nsXPCWrappedJS::DebugDump(PRInt16 depth)
char* name;
GetClass()->GetInterfaceInfo()->GetName(&name);
XPC_LOG_ALWAYS(("interface name is %s", name));
if(name)
if (name)
nsMemory::Free(name);
char * iid = GetClass()->GetIID().ToString();
XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid"));
if(iid)
if (iid)
NS_Free(iid);
XPC_LOG_ALWAYS(("nsXPCWrappedJSClass @ %x", mClass));
if(!isRoot)
if (!isRoot)
XPC_LOG_OUTDENT();
if(mNext)
if (mNext)
{
if(isRoot)
if (isRoot)
{
XPC_LOG_ALWAYS(("Additional wrappers for this object..."));
XPC_LOG_INDENT();
}
mNext->DebugDump(depth);
if(isRoot)
if (isRoot)
XPC_LOG_OUTDENT();
}
if(isRoot)
if (isRoot)
XPC_LOG_OUTDENT();
#endif
return NS_OK;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -54,7 +54,7 @@ JSObject *
xpc_CloneJSFunction(XPCCallContext &ccx, JSObject *funobj, JSObject *parent)
{
JSObject *clone = JS_CloneFunctionObject(ccx, funobj, parent);
if(!clone)
if (!clone)
return nsnull;
AUTO_MARK_JSVAL(ccx, OBJECT_TO_JSVAL(clone));
@ -73,12 +73,12 @@ xpc_CloneJSFunction(XPCCallContext &ccx, JSObject *funobj, JSObject *parent)
// Copy the reserved slots to the clone.
jsval ifaceVal, memberVal;
if(!JS_GetReservedSlot(ccx, funobj, 0, &ifaceVal) ||
!JS_GetReservedSlot(ccx, funobj, 1, &memberVal))
if (!JS_GetReservedSlot(ccx, funobj, 0, &ifaceVal) ||
!JS_GetReservedSlot(ccx, funobj, 1, &memberVal))
return nsnull;
if(!JS_SetReservedSlot(ccx, clone, 0, ifaceVal) ||
!JS_SetReservedSlot(ccx, clone, 1, memberVal))
if (!JS_SetReservedSlot(ccx, clone, 0, ifaceVal) ||
!JS_SetReservedSlot(ccx, clone, 1, memberVal))
return nsnull;
return clone;
@ -118,10 +118,10 @@ JSBool
XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface,
JSObject *parent, jsval *vp)
{
if(IsConstant())
if (IsConstant())
{
const nsXPTConstant* constant;
if(NS_FAILED(iface->GetInterfaceInfo()->GetConstant(mIndex, &constant)))
if (NS_FAILED(iface->GetInterfaceInfo()->GetConstant(mIndex, &constant)))
return JS_FALSE;
const nsXPTCMiniVariant& mv = *constant->GetValue();
@ -134,8 +134,8 @@ XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface,
jsval resultVal;
if(!XPCConvert::NativeData2JS(ccx, &resultVal, &v.val, v.type,
nsnull, nsnull))
if (!XPCConvert::NativeData2JS(ccx, &resultVal, &v.val, v.type,
nsnull, nsnull))
return JS_FALSE;
*vp = resultVal;
@ -149,15 +149,15 @@ XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface,
intN argc;
JSNative callback;
if(IsMethod())
if (IsMethod())
{
const nsXPTMethodInfo* info;
if(NS_FAILED(iface->GetInterfaceInfo()->GetMethodInfo(mIndex, &info)))
if (NS_FAILED(iface->GetInterfaceInfo()->GetMethodInfo(mIndex, &info)))
return JS_FALSE;
// Note: ASSUMES that retval is last arg.
argc = (intN) info->GetParamCount();
if(argc && info->GetParam((uint8)(argc-1)).IsRetval())
if (argc && info->GetParam((uint8)(argc-1)).IsRetval())
argc-- ;
callback = XPC_WN_CallMethod;
@ -169,15 +169,15 @@ XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface,
}
JSFunction *fun = JS_NewFunctionById(ccx, callback, argc, 0, parent, GetName());
if(!fun)
if (!fun)
return JS_FALSE;
JSObject* funobj = JS_GetFunctionObject(fun);
if(!funobj)
if (!funobj)
return JS_FALSE;
if(!JS_SetReservedSlot(ccx, funobj, 0, PRIVATE_TO_JSVAL(iface))||
!JS_SetReservedSlot(ccx, funobj, 1, PRIVATE_TO_JSVAL(this)))
if (!JS_SetReservedSlot(ccx, funobj, 0, PRIVATE_TO_JSVAL(iface))||
!JS_SetReservedSlot(ccx, funobj, 1, PRIVATE_TO_JSVAL(this)))
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(funobj);
@ -196,7 +196,7 @@ XPCNativeInterface::GetNewOrUsed(XPCCallContext& ccx, const nsIID* iid)
XPCJSRuntime* rt = ccx.GetRuntime();
IID2NativeInterfaceMap* map = rt->GetIID2NativeInterfaceMap();
if(!map)
if (!map)
return nsnull;
{ // scoped lock
@ -204,28 +204,28 @@ XPCNativeInterface::GetNewOrUsed(XPCCallContext& ccx, const nsIID* iid)
iface = map->Find(*iid);
}
if(iface)
if (iface)
return iface;
nsCOMPtr<nsIInterfaceInfo> info;
ccx.GetXPConnect()->GetInfoForIID(iid, getter_AddRefs(info));
if(!info)
if (!info)
return nsnull;
iface = NewInstance(ccx, info);
if(!iface)
if (!iface)
return nsnull;
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
XPCNativeInterface* iface2 = map->Add(iface);
if(!iface2)
if (!iface2)
{
NS_ERROR("failed to add our interface!");
DestroyInstance(iface);
iface = nsnull;
}
else if(iface2 != iface)
else if (iface2 != iface)
{
DestroyInstance(iface);
iface = iface2;
@ -242,13 +242,13 @@ XPCNativeInterface::GetNewOrUsed(XPCCallContext& ccx, nsIInterfaceInfo* info)
AutoMarkingNativeInterfacePtr iface(ccx);
const nsIID* iid;
if(NS_FAILED(info->GetIIDShared(&iid)) || !iid)
if (NS_FAILED(info->GetIIDShared(&iid)) || !iid)
return nsnull;
XPCJSRuntime* rt = ccx.GetRuntime();
IID2NativeInterfaceMap* map = rt->GetIID2NativeInterfaceMap();
if(!map)
if (!map)
return nsnull;
{ // scoped lock
@ -256,23 +256,23 @@ XPCNativeInterface::GetNewOrUsed(XPCCallContext& ccx, nsIInterfaceInfo* info)
iface = map->Find(*iid);
}
if(iface)
if (iface)
return iface;
iface = NewInstance(ccx, info);
if(!iface)
if (!iface)
return nsnull;
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
XPCNativeInterface* iface2 = map->Add(iface);
if(!iface2)
if (!iface2)
{
NS_ERROR("failed to add our interface!");
DestroyInstance(iface);
iface = nsnull;
}
else if(iface2 != iface)
else if (iface2 != iface)
{
DestroyInstance(iface);
iface = iface2;
@ -328,11 +328,11 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
// (or using) the members.
bool canScript;
if(NS_FAILED(aInfo->IsScriptable(&canScript)) || !canScript)
if (NS_FAILED(aInfo->IsScriptable(&canScript)) || !canScript)
return nsnull;
if(NS_FAILED(aInfo->GetMethodCount(&methodCount)) ||
NS_FAILED(aInfo->GetConstantCount(&constCount)))
if (NS_FAILED(aInfo->GetMethodCount(&methodCount)) ||
NS_FAILED(aInfo->GetConstantCount(&constCount)))
return nsnull;
// If the interface does not have nsISupports in its inheritance chain
@ -340,15 +340,15 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
// are used just to reflect constants are declared this way. We need to
// go ahead and build the thing. But, we'll ignore whatever methods it may
// have.
if(!nsXPConnect::IsISupportsDescendant(aInfo))
if (!nsXPConnect::IsISupportsDescendant(aInfo))
methodCount = 0;
totalCount = methodCount + constCount;
if(totalCount > MAX_LOCAL_MEMBER_COUNT)
if (totalCount > MAX_LOCAL_MEMBER_COUNT)
{
members = new XPCNativeMember[totalCount];
if(!members)
if (!members)
return nsnull;
}
else
@ -359,24 +359,24 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
// NOTE: since getters and setters share a member, we might not use all
// of the member objects.
for(i = 0; i < methodCount; i++)
for (i = 0; i < methodCount; i++)
{
const nsXPTMethodInfo* info;
if(NS_FAILED(aInfo->GetMethodInfo(i, &info)))
if (NS_FAILED(aInfo->GetMethodInfo(i, &info)))
{
failed = JS_TRUE;
break;
}
// don't reflect Addref or Release
if(i == 1 || i == 2)
if (i == 1 || i == 2)
continue;
if(!XPCConvert::IsMethodReflectable(*info))
if (!XPCConvert::IsMethodReflectable(*info))
continue;
str = JS_InternString(ccx, info->GetName());
if(!str)
if (!str)
{
NS_ERROR("bad method name");
failed = JS_TRUE;
@ -384,7 +384,7 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
}
name = INTERNED_STRING_TO_JSID(ccx, str);
if(info->IsSetter())
if (info->IsSetter())
{
NS_ASSERTION(realTotalCount,"bad setter");
// Note: ASSUMES Getter/Setter pairs are next to each other
@ -401,26 +401,26 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
// NS_ASSERTION(!LookupMemberByID(name),"duplicate method name");
cur = &members[realTotalCount++];
cur->SetName(name);
if(info->IsGetter())
if (info->IsGetter())
cur->SetReadOnlyAttribute(i);
else
cur->SetMethod(i);
}
}
if(!failed)
if (!failed)
{
for(i = 0; i < constCount; i++)
for (i = 0; i < constCount; i++)
{
const nsXPTConstant* constant;
if(NS_FAILED(aInfo->GetConstant(i, &constant)))
if (NS_FAILED(aInfo->GetConstant(i, &constant)))
{
failed = JS_TRUE;
break;
}
str = JS_InternString(ccx, constant->GetName());
if(!str)
if (!str)
{
NS_ERROR("bad constant name");
failed = JS_TRUE;
@ -437,39 +437,39 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
}
}
if(!failed)
if (!failed)
{
const char* bytes;
if(NS_FAILED(aInfo->GetNameShared(&bytes)) || !bytes ||
nsnull == (str = JS_InternString(ccx, bytes)))
if (NS_FAILED(aInfo->GetNameShared(&bytes)) || !bytes ||
nsnull == (str = JS_InternString(ccx, bytes)))
{
failed = JS_TRUE;
}
interfaceName = INTERNED_STRING_TO_JSID(ccx, str);
}
if(!failed)
if (!failed)
{
// Use placement new to create an object with the right amount of space
// to hold the members array
int size = sizeof(XPCNativeInterface);
if(realTotalCount > 1)
if (realTotalCount > 1)
size += (realTotalCount - 1) * sizeof(XPCNativeMember);
void* place = new char[size];
if(place)
if (place)
obj = new(place) XPCNativeInterface(aInfo, interfaceName);
if(obj)
if (obj)
{
obj->mMemberCount = realTotalCount;
// copy valid members
if(realTotalCount)
if (realTotalCount)
memcpy(obj->mMembers, members,
realTotalCount * sizeof(XPCNativeMember));
}
}
if(members && members != local_members)
if (members && members != local_members)
delete [] members;
return obj;
@ -508,14 +508,14 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, const nsIID* iid)
AutoMarkingNativeInterfacePtr iface(ccx);
iface = XPCNativeInterface::GetNewOrUsed(ccx, iid);
if(!iface)
if (!iface)
return nsnull;
XPCNativeSetKey key(nsnull, iface, 0);
XPCJSRuntime* rt = ccx.GetRuntime();
NativeSetMap* map = rt->GetNativeSetMap();
if(!map)
if (!map)
return nsnull;
{ // scoped lock
@ -523,25 +523,25 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, const nsIID* iid)
set = map->Find(&key);
}
if(set)
if (set)
return set;
// hacky way to get a XPCNativeInterface** using the AutoPtr
XPCNativeInterface* temp[] = {iface};
set = NewInstance(ccx, temp, 1);
if(!set)
if (!set)
return nsnull;
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
XPCNativeSet* set2 = map->Add(&key, set);
if(!set2)
if (!set2)
{
NS_ERROR("failed to add our set!");
DestroyInstance(set);
set = nsnull;
}
else if(set2 != set)
else if (set2 != set)
{
DestroyInstance(set);
set = set2;
@ -559,7 +559,7 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo)
XPCJSRuntime* rt = ccx.GetRuntime();
ClassInfo2NativeSetMap* map = rt->GetClassInfo2NativeSetMap();
if(!map)
if (!map)
return nsnull;
{ // scoped lock
@ -567,14 +567,14 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo)
set = map->Find(classInfo);
}
if(set)
if (set)
return set;
nsIID** iidArray = nsnull;
AutoMarkingNativeInterfacePtrArrayPtr interfaceArray(ccx);
PRUint32 iidCount = 0;
if(NS_FAILED(classInfo->GetInterfaces(&iidCount, &iidArray)))
if (NS_FAILED(classInfo->GetInterfaces(&iidCount, &iidArray)))
{
// Note: I'm making it OK for this call to fail so that one can add
// nsIClassInfo to classes implemented in script without requiring this
@ -589,7 +589,7 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo)
// !!! from here on we only exit through the 'out' label !!!
if(iidCount)
if (iidCount)
{
AutoMarkingNativeInterfacePtrArrayPtr
arr(ccx, new XPCNativeInterface*[iidCount], iidCount, PR_TRUE);
@ -602,7 +602,7 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo)
nsIID** currentIID = iidArray;
PRUint16 interfaceCount = 0;
for(PRUint32 i = 0; i < iidCount; i++)
for (PRUint32 i = 0; i < iidCount; i++)
{
nsIID* iid = *(currentIID++);
if (!iid) {
@ -613,7 +613,7 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo)
XPCNativeInterface* iface =
XPCNativeInterface::GetNewOrUsed(ccx, iid);
if(!iface)
if (!iface)
{
// XXX warn here
continue;
@ -623,13 +623,13 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo)
interfaceCount++;
}
if(interfaceCount)
if (interfaceCount)
{
set = NewInstance(ccx, interfaceArray, interfaceCount);
if(set)
if (set)
{
NativeSetMap* map2 = rt->GetNativeSetMap();
if(!map2)
if (!map2)
goto out;
XPCNativeSetKey key(set, nsnull, 0);
@ -637,14 +637,14 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo)
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
XPCNativeSet* set2 = map2->Add(&key, set);
if(!set2)
if (!set2)
{
NS_ERROR("failed to add our set!");
DestroyInstance(set);
set = nsnull;
goto out;
}
if(set2 != set)
if (set2 != set)
{
DestroyInstance(set);
set = set2;
@ -658,7 +658,7 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo)
else
set = GetNewOrUsed(ccx, &NS_GET_IID(nsISupports));
if(set)
if (set)
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
@ -671,9 +671,9 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo)
}
out:
if(iidArray)
if (iidArray)
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(iidCount, iidArray);
if(interfaceArray)
if (interfaceArray)
delete [] interfaceArray.get();
return set;
@ -685,7 +685,7 @@ XPCNativeSet::ClearCacheEntryForClassInfo(nsIClassInfo* classInfo)
{
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
ClassInfo2NativeSetMap* map = rt->GetClassInfo2NativeSetMap();
if(map)
if (map)
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
map->Remove(classInfo);
@ -702,7 +702,7 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx,
AutoMarkingNativeSetPtr set(ccx);
XPCJSRuntime* rt = ccx.GetRuntime();
NativeSetMap* map = rt->GetNativeSetMap();
if(!map)
if (!map)
return nsnull;
XPCNativeSetKey key(otherSet, newInterface, position);
@ -712,27 +712,27 @@ XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx,
set = map->Find(&key);
}
if(set)
if (set)
return set;
if(otherSet)
if (otherSet)
set = NewInstanceMutate(otherSet, newInterface, position);
else
set = NewInstance(ccx, &newInterface, 1);
if(!set)
if (!set)
return nsnull;
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
XPCNativeSet* set2 = map->Add(&key, set);
if(!set2)
if (!set2)
{
NS_ERROR("failed to add our set!");
DestroyInstance(set);
set = nsnull;
}
else if(set2 != set)
else if (set2 != set)
{
DestroyInstance(set);
set = set2;
@ -750,7 +750,7 @@ XPCNativeSet::NewInstance(XPCCallContext& ccx,
{
XPCNativeSet* obj = nsnull;
if(!array || !count)
if (!array || !count)
return nsnull;
// We impose the invariant:
@ -764,22 +764,22 @@ XPCNativeSet::NewInstance(XPCCallContext& ccx,
PRUint16 i;
XPCNativeInterface** pcur;
for(i = 0, pcur = array; i < count; i++, pcur++)
for (i = 0, pcur = array; i < count; i++, pcur++)
{
if(*pcur == isup)
if (*pcur == isup)
slots--;
}
// Use placement new to create an object with the right amount of space
// to hold the members array
int size = sizeof(XPCNativeSet);
if(slots > 1)
if (slots > 1)
size += (slots - 1) * sizeof(XPCNativeInterface*);
void* place = new char[size];
if(place)
if (place)
obj = new(place) XPCNativeSet();
if(obj)
if (obj)
{
// Stick the nsISupports in front and skip additional nsISupport(s)
XPCNativeInterface** inp = array;
@ -788,11 +788,11 @@ XPCNativeSet::NewInstance(XPCCallContext& ccx,
*(outp++) = isup;
for(i = 0; i < count; i++)
for (i = 0; i < count; i++)
{
XPCNativeInterface* cur;
if(isup == (cur = *(inp++)))
if (isup == (cur = *(inp++)))
continue;
*(outp++) = cur;
memberCount += cur->GetMemberCount();
@ -812,23 +812,23 @@ XPCNativeSet::NewInstanceMutate(XPCNativeSet* otherSet,
{
XPCNativeSet* obj = nsnull;
if(!newInterface)
if (!newInterface)
return nsnull;
if(otherSet && position > otherSet->mInterfaceCount)
if (otherSet && position > otherSet->mInterfaceCount)
return nsnull;
// Use placement new to create an object with the right amount of space
// to hold the members array
int size = sizeof(XPCNativeSet);
if(otherSet)
if (otherSet)
size += otherSet->mInterfaceCount * sizeof(XPCNativeInterface*);
void* place = new char[size];
if(place)
if (place)
obj = new(place) XPCNativeSet();
if(obj)
if (obj)
{
if(otherSet)
if (otherSet)
{
obj->mMemberCount = otherSet->GetMemberCount() +
newInterface->GetMemberCount();
@ -836,9 +836,9 @@ XPCNativeSet::NewInstanceMutate(XPCNativeSet* otherSet,
XPCNativeInterface** src = otherSet->mInterfaces;
XPCNativeInterface** dest = obj->mInterfaces;
for(PRUint16 i = 0; i < obj->mInterfaceCount; i++)
for (PRUint16 i = 0; i < obj->mInterfaceCount; i++)
{
if(i == position)
if (i == position)
*dest++ = newInterface;
else
*dest++ = *src++;
@ -872,9 +872,9 @@ XPCNativeSet::DebugDump(PRInt16 depth)
XPC_LOG_INDENT();
XPC_LOG_ALWAYS(("mInterfaceCount of %d", mInterfaceCount));
if(depth)
if (depth)
{
for(PRUint16 i = 0; i < mInterfaceCount; i++)
for (PRUint16 i = 0; i < mInterfaceCount; i++)
mInterfaces[i]->DebugDump(depth);
}
XPC_LOG_ALWAYS(("mMemberCount of %d", mMemberCount));

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -95,22 +95,22 @@ XPCWrappedNativeProto::Init(XPCCallContext& ccx,
nsIXPCScriptable *callback = scriptableCreateInfo ?
scriptableCreateInfo->GetCallback() :
nsnull;
if(callback)
if (callback)
{
mScriptableInfo =
XPCNativeScriptableInfo::Construct(ccx, isGlobal, scriptableCreateInfo);
if(!mScriptableInfo)
if (!mScriptableInfo)
return JS_FALSE;
}
js::Class* jsclazz;
if(mScriptableInfo)
if (mScriptableInfo)
{
const XPCNativeScriptableFlags& flags(mScriptableInfo->GetFlags());
if(flags.AllowPropModsToPrototype())
if (flags.AllowPropModsToPrototype())
{
jsclazz = flags.WantCall() ?
&XPC_WN_ModsAllowed_WithCall_Proto_JSClass :
@ -137,10 +137,10 @@ XPCWrappedNativeProto::Init(XPCCallContext& ccx,
JSBool ok = mJSProtoObject && JS_SetPrivate(ccx, mJSProtoObject, this);
if(ok && callback)
if (ok && callback)
{
nsresult rv = callback->PostCreatePrototype(ccx, mJSProtoObject);
if(NS_FAILED(rv))
if (NS_FAILED(rv))
{
JS_SetPrivate(ccx, mJSProtoObject, nsnull);
mJSProtoObject = nsnull;
@ -161,12 +161,12 @@ XPCWrappedNativeProto::JSProtoObjectFinalized(JSContext *cx, JSObject *obj)
// Map locking is not necessary since we are running gc.
if(IsShared())
if (IsShared())
{
// Only remove this proto from the map if it is the one in the map.
ClassInfo2WrappedNativeProtoMap* map =
GetScope()->GetWrappedNativeProtoMap(ClassIsMainThreadOnly());
if(map->Find(mClassInfo) == this)
if (map->Find(mClassInfo) == this)
map->Remove(mClassInfo);
}
@ -184,7 +184,7 @@ XPCWrappedNativeProto::SystemIsBeingShutDown(JSContext* cx)
#ifdef XPC_TRACK_PROTO_STATS
static bool DEBUG_DumpedStats = false;
if(!DEBUG_DumpedStats)
if (!DEBUG_DumpedStats)
{
printf("%d XPCWrappedNativeProto(s) alive at shutdown\n",
gDEBUG_LiveProtoCount);
@ -192,7 +192,7 @@ XPCWrappedNativeProto::SystemIsBeingShutDown(JSContext* cx)
}
#endif
if(mJSProtoObject)
if (mJSProtoObject)
{
// short circuit future finalization
JS_SetPrivate(cx, mJSProtoObject, nsnull);
@ -219,18 +219,18 @@ XPCWrappedNativeProto::GetNewOrUsed(XPCCallContext& ccx,
JSBool shared;
JSUint32 ciFlags;
if(NS_FAILED(ClassInfo->GetFlags(&ciFlags)))
if (NS_FAILED(ClassInfo->GetFlags(&ciFlags)))
ciFlags = 0;
if(ciFlags & XPC_PROTO_DONT_SHARE)
if (ciFlags & XPC_PROTO_DONT_SHARE)
{
NS_ERROR("reserved flag set!");
ciFlags &= ~XPC_PROTO_DONT_SHARE;
}
if(ForceNoSharing || (ciFlags & nsIClassInfo::PLUGIN_OBJECT) ||
(ScriptableCreateInfo &&
ScriptableCreateInfo->GetFlags().DontSharePrototype()))
if (ForceNoSharing || (ciFlags & nsIClassInfo::PLUGIN_OBJECT) ||
(ScriptableCreateInfo &&
ScriptableCreateInfo->GetFlags().DontSharePrototype()))
{
ciFlags |= XPC_PROTO_DONT_SHARE;
shared = JS_FALSE;
@ -240,7 +240,7 @@ XPCWrappedNativeProto::GetNewOrUsed(XPCCallContext& ccx,
shared = JS_TRUE;
}
if(shared)
if (shared)
{
JSBool mainThreadOnly = !!(ciFlags & nsIClassInfo::MAIN_THREAD_ONLY);
map = Scope->GetWrappedNativeProtoMap(mainThreadOnly);
@ -248,25 +248,25 @@ XPCWrappedNativeProto::GetNewOrUsed(XPCCallContext& ccx,
{ // scoped lock
XPCAutoLock al(lock);
proto = map->Find(ClassInfo);
if(proto)
if (proto)
return proto;
}
}
AutoMarkingNativeSetPtr set(ccx);
set = XPCNativeSet::GetNewOrUsed(ccx, ClassInfo);
if(!set)
if (!set)
return nsnull;
proto = new XPCWrappedNativeProto(Scope, ClassInfo, ciFlags, set, offsets);
if(!proto || !proto->Init(ccx, isGlobal, ScriptableCreateInfo))
if (!proto || !proto->Init(ccx, isGlobal, ScriptableCreateInfo))
{
delete proto.get();
return nsnull;
}
if(shared)
if (shared)
{ // scoped lock
XPCAutoLock al(lock);
map->Add(ClassInfo, proto);
@ -288,7 +288,7 @@ XPCWrappedNativeProto::DebugDump(PRInt16 depth)
XPC_LOG_ALWAYS(("mSet @ %x", mSet));
XPC_LOG_ALWAYS(("mSecurityInfo of %x", mSecurityInfo));
XPC_LOG_ALWAYS(("mScriptableInfo @ %x", mScriptableInfo));
if(depth && mScriptableInfo)
if (depth && mScriptableInfo)
{
XPC_LOG_INDENT();
XPC_LOG_ALWAYS(("mScriptable @ %x", mScriptableInfo->GetCallback()));

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

@ -60,7 +60,7 @@ static void DEBUG_TrackNewScope(XPCWrappedNativeScope* scope)
#ifdef XPC_TRACK_SCOPE_STATS
DEBUG_TotalScopeCount++;
DEBUG_TotalLiveScopeCount++;
if(DEBUG_TotalMaxScopeCount < DEBUG_TotalLiveScopeCount)
if (DEBUG_TotalMaxScopeCount < DEBUG_TotalLiveScopeCount)
DEBUG_TotalMaxScopeCount = DEBUG_TotalLiveScopeCount;
#endif
}
@ -82,7 +82,7 @@ static void DEBUG_TrackScopeTraversal()
static void DEBUG_TrackScopeShutdown()
{
#ifdef XPC_TRACK_SCOPE_STATS
if(!DEBUG_DumpedStats)
if (!DEBUG_DumpedStats)
{
DEBUG_DumpedStats = PR_TRUE;
printf("%d XPCWrappedNativeScope(s) were constructed.\n",
@ -117,7 +117,7 @@ XPCWrappedNativeScope::GetNewOrUsed(XPCCallContext& ccx, JSObject* aGlobal)
{
XPCWrappedNativeScope* scope = FindInJSObjectScope(ccx, aGlobal, JS_TRUE);
if(!scope)
if (!scope)
scope = new XPCWrappedNativeScope(ccx, aGlobal);
else
{
@ -129,7 +129,7 @@ XPCWrappedNativeScope::GetNewOrUsed(XPCCallContext& ccx, JSObject* aGlobal)
// called by nsXPConnect::InitClasses.
scope->SetGlobal(ccx, aGlobal);
}
if(js::GetObjectClass(aGlobal)->flags & JSCLASS_XPCONNECT_GLOBAL)
if (js::GetObjectClass(aGlobal)->flags & JSCLASS_XPCONNECT_GLOBAL)
JS_ALWAYS_TRUE(JS_SetReservedSlot(ccx, aGlobal,
JSCLASS_GLOBAL_SLOT_COUNT,
PRIVATE_TO_JSVAL(scope)));
@ -156,7 +156,7 @@ XPCWrappedNativeScope::XPCWrappedNativeScope(XPCCallContext& ccx,
XPCAutoLock lock(mRuntime->GetMapLock());
#ifdef DEBUG
for(XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
NS_ASSERTION(aGlobal != cur->GetGlobalJSObject(), "dup object");
#endif
@ -168,7 +168,7 @@ XPCWrappedNativeScope::XPCWrappedNativeScope(XPCCallContext& ccx,
mContext->AddScope(this);
}
if(aGlobal)
if (aGlobal)
SetGlobal(ccx, aGlobal);
DEBUG_TrackNewScope(this);
@ -179,9 +179,9 @@ XPCWrappedNativeScope::XPCWrappedNativeScope(XPCCallContext& ccx,
JSBool
XPCWrappedNativeScope::IsDyingScope(XPCWrappedNativeScope *scope)
{
for(XPCWrappedNativeScope *cur = gDyingScopes; cur; cur = cur->mNext)
for (XPCWrappedNativeScope *cur = gDyingScopes; cur; cur = cur->mNext)
{
if(scope == cur)
if (scope == cur)
return JS_TRUE;
}
return JS_FALSE;
@ -243,8 +243,8 @@ XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal)
// Now init our script object principal, if the new global has one
const JSClass* jsClass = js::GetObjectJSClass(aGlobal);
if(!(~jsClass->flags & (JSCLASS_HAS_PRIVATE |
JSCLASS_PRIVATE_IS_NSISUPPORTS)))
if (!(~jsClass->flags & (JSCLASS_HAS_PRIVATE |
JSCLASS_PRIVATE_IS_NSISUPPORTS)))
{
// Our global has an nsISupports native pointer. Let's
// see whether it's what we want.
@ -252,11 +252,11 @@ XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal)
nsCOMPtr<nsIXPConnectWrappedNative> native =
do_QueryInterface(priv);
nsCOMPtr<nsIScriptObjectPrincipal> sop;
if(native)
if (native)
{
sop = do_QueryWrappedNative(native);
}
if(!sop)
if (!sop)
{
sop = do_QueryInterface(priv);
}
@ -272,10 +272,10 @@ XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal)
jsid idFun = mRuntime->GetStringID(XPCJSRuntime::IDX_FUNCTION);
jsid idProto = mRuntime->GetStringID(XPCJSRuntime::IDX_PROTOTYPE);
if(JS_GetPropertyById(ccx, aGlobal, idObj, &val) &&
!JSVAL_IS_PRIMITIVE(val) &&
JS_GetPropertyById(ccx, JSVAL_TO_OBJECT(val), idProto, &val) &&
!JSVAL_IS_PRIMITIVE(val))
if (JS_GetPropertyById(ccx, aGlobal, idObj, &val) &&
!JSVAL_IS_PRIMITIVE(val) &&
JS_GetPropertyById(ccx, JSVAL_TO_OBJECT(val), idProto, &val) &&
!JSVAL_IS_PRIMITIVE(val))
{
mPrototypeJSObject = JSVAL_TO_OBJECT(val);
}
@ -284,10 +284,10 @@ XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal)
NS_ERROR("Can't get globalObject.Object.prototype");
}
if(JS_GetPropertyById(ccx, aGlobal, idFun, &val) &&
!JSVAL_IS_PRIMITIVE(val) &&
JS_GetPropertyById(ccx, JSVAL_TO_OBJECT(val), idProto, &val) &&
!JSVAL_IS_PRIMITIVE(val))
if (JS_GetPropertyById(ccx, aGlobal, idFun, &val) &&
!JSVAL_IS_PRIMITIVE(val) &&
JS_GetPropertyById(ccx, JSVAL_TO_OBJECT(val), idProto, &val) &&
!JSVAL_IS_PRIMITIVE(val))
{
mPrototypeJSFunction = JSVAL_TO_OBJECT(val);
}
@ -309,25 +309,25 @@ XPCWrappedNativeScope::~XPCWrappedNativeScope()
// We can do additional cleanup assertions here...
if(mWrappedNativeMap)
if (mWrappedNativeMap)
{
NS_ASSERTION(0 == mWrappedNativeMap->Count(), "scope has non-empty map");
delete mWrappedNativeMap;
}
if(mWrappedNativeProtoMap)
if (mWrappedNativeProtoMap)
{
NS_ASSERTION(0 == mWrappedNativeProtoMap->Count(), "scope has non-empty map");
delete mWrappedNativeProtoMap;
}
if(mMainThreadWrappedNativeProtoMap)
if (mMainThreadWrappedNativeProtoMap)
{
NS_ASSERTION(0 == mMainThreadWrappedNativeProtoMap->Count(), "scope has non-empty map");
delete mMainThreadWrappedNativeProtoMap;
}
if(mContext)
if (mContext)
mContext->RemoveScope(this);
// XXX we should assert that we are dead or that xpconnect has shutdown
@ -341,7 +341,7 @@ XPCWrappedNativeScope::GetPrototypeNoHelper(XPCCallContext& ccx)
// We could create this prototype in SetGlobal(), but all scopes
// don't need one, so we save ourselves a bit of space if we
// create these when they're needed.
if(!mPrototypeNoHelper)
if (!mPrototypeNoHelper)
{
mPrototypeNoHelper =
xpc_NewSystemInheritingJSObject(ccx,
@ -361,7 +361,7 @@ WrappedNativeJSGCThingTracer(JSDHashTable *table, JSDHashEntryHdr *hdr,
uint32 number, void *arg)
{
XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
if(wrapper->HasExternalReference() && !wrapper->IsWrapperExpired())
if (wrapper->HasExternalReference() && !wrapper->IsWrapperExpired())
{
JSTracer* trc = (JSTracer *)arg;
JS_CALL_OBJECT_TRACER(trc, wrapper->GetFlatJSObjectPreserveColor(),
@ -380,7 +380,7 @@ XPCWrappedNativeScope::TraceJS(JSTracer* trc, XPCJSRuntime* rt)
XPCAutoLock lock(rt->GetMapLock());
// Do JS_CallTracer for all wrapped natives with external references.
for(XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
{
cur->mWrappedNativeMap->Enumerate(WrappedNativeJSGCThingTracer, trc);
}
@ -403,7 +403,7 @@ WrappedNativeSuspecter(JSDHashTable *table, JSDHashEntryHdr *hdr,
{
XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
if(wrapper->HasExternalReference())
if (wrapper->HasExternalReference())
{
SuspectClosure* closure = static_cast<SuspectClosure*>(arg);
XPCJSRuntime::SuspectWrappedNative(closure->cx, wrapper, closure->cb);
@ -420,7 +420,7 @@ XPCWrappedNativeScope::SuspectAllWrappers(XPCJSRuntime* rt, JSContext* cx,
XPCAutoLock lock(rt->GetMapLock());
SuspectClosure closure(cx, cb);
for(XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
{
cur->mWrappedNativeMap->Enumerate(WrappedNativeSuspecter, &closure);
}
@ -443,21 +443,21 @@ XPCWrappedNativeScope::FinishedMarkPhaseOfGC(JSContext* cx, XPCJSRuntime* rt)
XPCWrappedNativeScope* prev = nsnull;
XPCWrappedNativeScope* cur = gScopes;
while(cur)
while (cur)
{
XPCWrappedNativeScope* next = cur->mNext;
js::AutoSwitchCompartment sc(cx, cur->mGlobalJSObject);
if(cur->mGlobalJSObject &&
JS_IsAboutToBeFinalized(cx, cur->mGlobalJSObject))
if (cur->mGlobalJSObject &&
JS_IsAboutToBeFinalized(cx, cur->mGlobalJSObject))
{
cur->mGlobalJSObject = nsnull;
cur->mScriptObjectPrincipal = nsnull;
if(cur->GetCachedDOMPrototypes().IsInitialized())
if (cur->GetCachedDOMPrototypes().IsInitialized())
cur->GetCachedDOMPrototypes().Clear();
// Move this scope from the live list to the dying list.
if(prev)
if (prev)
prev->mNext = next;
else
gScopes = next;
@ -467,23 +467,23 @@ XPCWrappedNativeScope::FinishedMarkPhaseOfGC(JSContext* cx, XPCJSRuntime* rt)
}
else
{
if(cur->mPrototypeJSObject &&
JS_IsAboutToBeFinalized(cx, cur->mPrototypeJSObject))
if (cur->mPrototypeJSObject &&
JS_IsAboutToBeFinalized(cx, cur->mPrototypeJSObject))
{
cur->mPrototypeJSObject = nsnull;
}
if(cur->mPrototypeJSFunction &&
JS_IsAboutToBeFinalized(cx, cur->mPrototypeJSFunction))
if (cur->mPrototypeJSFunction &&
JS_IsAboutToBeFinalized(cx, cur->mPrototypeJSFunction))
{
cur->mPrototypeJSFunction = nsnull;
}
if(cur->mPrototypeNoHelper &&
JS_IsAboutToBeFinalized(cx, cur->mPrototypeNoHelper))
if (cur->mPrototypeNoHelper &&
JS_IsAboutToBeFinalized(cx, cur->mPrototypeNoHelper))
{
cur->mPrototypeNoHelper = nsnull;
}
}
if(cur)
if (cur)
prev = cur;
cur = next;
}
@ -524,7 +524,7 @@ WrappedNativeProtoMarker(JSDHashTable *table, JSDHashEntryHdr *hdr,
void
XPCWrappedNativeScope::MarkAllWrappedNativesAndProtos()
{
for(XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
{
cur->mWrappedNativeMap->Enumerate(WrappedNativeMarker, nsnull);
cur->mWrappedNativeProtoMap->Enumerate(WrappedNativeProtoMarker, nsnull);
@ -555,7 +555,7 @@ ASSERT_WrappedNativeProtoSetNotMarked(JSDHashTable *table, JSDHashEntryHdr *hdr,
void
XPCWrappedNativeScope::ASSERT_NoInterfaceSetsAreMarked()
{
for(XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
{
cur->mWrappedNativeMap->Enumerate(ASSERT_WrappedNativeSetNotMarked, nsnull);
cur->mWrappedNativeProtoMap->Enumerate(ASSERT_WrappedNativeProtoSetNotMarked, nsnull);
@ -576,7 +576,7 @@ WrappedNativeTearoffSweeper(JSDHashTable *table, JSDHashEntryHdr *hdr,
void
XPCWrappedNativeScope::SweepAllWrappedNativeTearOffs()
{
for(XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
cur->mWrappedNativeMap->Enumerate(WrappedNativeTearoffSweeper, nsnull);
DEBUG_TrackScopeTraversal();
@ -588,7 +588,7 @@ XPCWrappedNativeScope::KillDyingScopes()
{
// always called inside the lock!
XPCWrappedNativeScope* cur = gDyingScopes;
while(cur)
while (cur)
{
XPCWrappedNativeScope* next = cur->mNext;
delete cur;
@ -615,9 +615,9 @@ WrappedNativeShutdownEnumerator(JSDHashTable *table, JSDHashEntryHdr *hdr,
ShutdownData* data = (ShutdownData*) arg;
XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
if(wrapper->IsValid())
if (wrapper->IsValid())
{
if(wrapper->HasProto() && !wrapper->HasSharedProto())
if (wrapper->HasProto() && !wrapper->HasSharedProto())
data->nonSharedProtoCount++;
wrapper->SystemIsBeingShutDown(data->cx);
data->wrapperCount++;
@ -652,7 +652,7 @@ XPCWrappedNativeScope::SystemIsBeingShutDown(JSContext* cx)
// First move all the scopes to the dying list.
cur = gScopes;
while(cur)
while (cur)
{
XPCWrappedNativeScope* next = cur->mNext;
cur->mNext = gDyingScopes;
@ -664,10 +664,10 @@ XPCWrappedNativeScope::SystemIsBeingShutDown(JSContext* cx)
// Walk the unified dying list and call shutdown on all wrappers and protos
for(cur = gDyingScopes; cur; cur = cur->mNext)
for (cur = gDyingScopes; cur; cur = cur->mNext)
{
// Give the Components object a chance to try to clean up.
if(cur->mComponents)
if (cur->mComponents)
cur->mComponents->SystemIsBeingShutDown();
JSAutoEnterCompartment ac;
@ -690,14 +690,14 @@ XPCWrappedNativeScope::SystemIsBeingShutDown(JSContext* cx)
KillDyingScopes();
#ifdef XPC_DUMP_AT_SHUTDOWN
if(data.wrapperCount)
if (data.wrapperCount)
printf("deleting nsXPConnect with %d live XPCWrappedNatives\n",
data.wrapperCount);
if(data.sharedProtoCount + data.nonSharedProtoCount)
if (data.sharedProtoCount + data.nonSharedProtoCount)
printf("deleting nsXPConnect with %d live XPCWrappedNativeProtos (%d shared)\n",
data.sharedProtoCount + data.nonSharedProtoCount,
data.sharedProtoCount);
if(liveScopeCount)
if (liveScopeCount)
printf("deleting nsXPConnect with %d live XPCWrappedNativeScopes\n",
liveScopeCount);
#endif
@ -714,10 +714,10 @@ GetScopeOfObject(JSObject* obj)
js::Class* clazz = js::GetObjectClass(obj);
JSBool isWrapper = IS_WRAPPER_CLASS(clazz);
if(isWrapper && IS_SLIM_WRAPPER_OBJECT(obj))
if (isWrapper && IS_SLIM_WRAPPER_OBJECT(obj))
return GetSlimWrapperProto(obj)->GetScope();
if(!isWrapper || !(supports = (nsISupports*) xpc_GetJSPrivate(obj)))
if (!isWrapper || !(supports = (nsISupports*) xpc_GetJSPrivate(obj)))
return nsnull;
#ifdef DEBUG
@ -739,15 +739,15 @@ void DEBUG_CheckForComponentsInScope(JSContext* cx, JSObject* obj,
JSBool OKIfNotInitialized,
XPCJSRuntime* runtime)
{
if(OKIfNotInitialized)
if (OKIfNotInitialized)
return;
if(!(JS_GetOptions(cx) & JSOPTION_PRIVATE_IS_NSISUPPORTS))
if (!(JS_GetOptions(cx) & JSOPTION_PRIVATE_IS_NSISUPPORTS))
return;
const char* name = runtime->GetStringName(XPCJSRuntime::IDX_COMPONENTS);
jsval prop;
if(JS_LookupProperty(cx, obj, name, &prop) && !JSVAL_IS_PRIMITIVE(prop))
if (JS_LookupProperty(cx, obj, name, &prop) && !JSVAL_IS_PRIMITIVE(prop))
return;
// This is pretty much always bad. It usually means that native code is
@ -764,10 +764,10 @@ void DEBUG_CheckForComponentsInScope(JSContext* cx, JSObject* obj,
js_DumpObject(startingObj);
JSObject *p = startingObj;
while(js::IsWrapper(p))
while (js::IsWrapper(p))
{
p = js::GetProxyPrivate(p).toObjectOrNull();
if(!p)
if (!p)
break;
printf("which is a wrapper for:\n");
js_DumpObject(p);
@ -786,14 +786,14 @@ XPCWrappedNativeScope::FindInJSObjectScope(JSContext* cx, JSObject* obj,
{
XPCWrappedNativeScope* scope;
if(!obj)
if (!obj)
return nsnull;
// If this object is itself a wrapped native then we can get the
// scope directly.
scope = GetScopeOfObject(obj);
if(scope)
if (scope)
return scope;
// Else we'll have to look up the parent chain to get the scope
@ -807,14 +807,14 @@ XPCWrappedNativeScope::FindInJSObjectScope(JSContext* cx, JSObject* obj,
obj = JS_GetGlobalForObject(cx, obj);
if(js::GetObjectClass(obj)->flags & JSCLASS_XPCONNECT_GLOBAL)
if (js::GetObjectClass(obj)->flags & JSCLASS_XPCONNECT_GLOBAL)
{
scope = XPCWrappedNativeScope::GetNativeScope(cx, obj);
if(scope)
if (scope)
return scope;
}
if(!runtime)
if (!runtime)
{
runtime = nsXPConnect::GetRuntimeInstance();
NS_ASSERTION(runtime, "This should never be null!");
@ -828,9 +828,9 @@ XPCWrappedNativeScope::FindInJSObjectScope(JSContext* cx, JSObject* obj,
DEBUG_TrackScopeTraversal();
for(XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
{
if(obj == cur->GetGlobalJSObject())
if (obj == cur->GetGlobalJSObject())
{
found = cur;
break;
@ -838,7 +838,7 @@ XPCWrappedNativeScope::FindInJSObjectScope(JSContext* cx, JSObject* obj,
}
}
if(found) {
if (found) {
// This cannot be called within the map lock!
DEBUG_CheckForComponentsInScope(cx, obj, startingObj,
OKIfNotInitialized, runtime);
@ -869,7 +869,7 @@ WNSecPolicyClearer(JSDHashTable *table, JSDHashEntryHdr *hdr,
uint32 number, void *arg)
{
XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
if(wrapper->HasProto() && !wrapper->HasSharedProto())
if (wrapper->HasProto() && !wrapper->HasSharedProto())
*(wrapper->GetProto()->GetSecurityInfoAddr()) = nsnull;
return JS_DHASH_NEXT;
}
@ -881,7 +881,7 @@ XPCWrappedNativeScope::ClearAllWrappedNativeSecurityPolicies(XPCCallContext& ccx
// Hold the lock throughout.
XPCAutoLock lock(ccx.GetRuntime()->GetMapLock());
for(XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
{
cur->mWrappedNativeProtoMap->Enumerate(WNProtoSecPolicyClearer, nsnull);
cur->mMainThreadWrappedNativeProtoMap->Enumerate(WNProtoSecPolicyClearer, nsnull);
@ -929,7 +929,7 @@ TraceDOMPrototype(const char* aKey, JSObject* aData, void* aClosure)
void
XPCWrappedNativeScope::TraceDOMPrototypes(JSTracer *trc)
{
if(mCachedDOMPrototypes.IsInitialized()) {
if (mCachedDOMPrototypes.IsInitialized()) {
mCachedDOMPrototypes.EnumerateRead(TraceDOMPrototype, trc);
}
}
@ -946,14 +946,14 @@ XPCWrappedNativeScope::DebugDumpAllScopes(PRInt16 depth)
// get scope count.
int count = 0;
XPCWrappedNativeScope* cur;
for(cur = gScopes; cur; cur = cur->mNext)
for (cur = gScopes; cur; cur = cur->mNext)
count++ ;
XPC_LOG_ALWAYS(("chain of %d XPCWrappedNativeScope(s)", count));
XPC_LOG_INDENT();
XPC_LOG_ALWAYS(("gDyingScopes @ %x", gDyingScopes));
if(depth)
for(cur = gScopes; cur; cur = cur->mNext)
if (depth)
for (cur = gScopes; cur; cur = cur->mNext)
cur->DebugDump(depth);
XPC_LOG_OUTDENT();
#endif
@ -995,7 +995,7 @@ XPCWrappedNativeScope::DebugDump(PRInt16 depth)
mWrappedNativeMap, \
mWrappedNativeMap ? mWrappedNativeMap->Count() : 0));
// iterate contexts...
if(depth && mWrappedNativeMap && mWrappedNativeMap->Count())
if (depth && mWrappedNativeMap && mWrappedNativeMap->Count())
{
XPC_LOG_INDENT();
mWrappedNativeMap->Enumerate(WrappedNativeMapDumpEnumerator, &depth);
@ -1006,7 +1006,7 @@ XPCWrappedNativeScope::DebugDump(PRInt16 depth)
mWrappedNativeProtoMap, \
mWrappedNativeProtoMap ? mWrappedNativeProtoMap->Count() : 0));
// iterate contexts...
if(depth && mWrappedNativeProtoMap && mWrappedNativeProtoMap->Count())
if (depth && mWrappedNativeProtoMap && mWrappedNativeProtoMap->Count())
{
XPC_LOG_INDENT();
mWrappedNativeProtoMap->Enumerate(WrappedNativeProtoMapDumpEnumerator, &depth);
@ -1017,7 +1017,7 @@ XPCWrappedNativeScope::DebugDump(PRInt16 depth)
mMainThreadWrappedNativeProtoMap, \
mMainThreadWrappedNativeProtoMap ? mMainThreadWrappedNativeProtoMap->Count() : 0));
// iterate contexts...
if(depth && mMainThreadWrappedNativeProtoMap && mMainThreadWrappedNativeProtoMap->Count())
if (depth && mMainThreadWrappedNativeProtoMap && mMainThreadWrappedNativeProtoMap->Count())
{
XPC_LOG_INDENT();
mMainThreadWrappedNativeProtoMap->Enumerate(WrappedNativeProtoMapDumpEnumerator, &depth);

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

@ -390,7 +390,7 @@ template<class LC>
JSObject *
ListBase<LC>::getPrototype(JSContext *cx, XPCWrappedNativeScope *scope, bool *enabled)
{
if(!scope->NewDOMBindingsEnabled()) {
if (!scope->NewDOMBindingsEnabled()) {
*enabled = false;
return NULL;
}

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

@ -55,7 +55,7 @@ xpc_qsUnwrapThis<_interface>(JSContext *cx, \
nsISupports *native = castNativeFromWrapper(cx, obj, callee, _bit, \
pThisRef, pThisVal, lccx, \
&rv); \
if(failureFatal && !native) \
if (failureFatal && !native) \
return xpc_qsThrow(cx, rv); \
*ppThis = static_cast<_interface*>(static_cast<_base*>(native)); \
return JS_TRUE; \
@ -72,7 +72,7 @@ xpc_qsUnwrapArg<_interface>(JSContext *cx, \
nsresult rv; \
nsISupports *native = castNativeArgFromWrapper(cx, v, _bit, ppArgRef, vp, \
&rv); \
if(NS_SUCCEEDED(rv)) \
if (NS_SUCCEEDED(rv)) \
*ppArg = static_cast<_interface*>(static_cast<_base*>(native)); \
return rv; \
}
@ -96,7 +96,7 @@ inline JSBool
castToElement(nsIContent *content, jsval val, nsGenericElement **ppInterface,
jsval *pVal)
{
if(!content->IsElement())
if (!content->IsElement())
return JS_FALSE;
*ppInterface = static_cast<nsGenericElement*>(content->AsElement());
*pVal = val;
@ -119,15 +119,15 @@ xpc_qsUnwrapThis<nsGenericElement>(JSContext *cx,
JSBool ok = xpc_qsUnwrapThis<nsIContent>(cx, obj, callee, &content,
pThisRef, &val, lccx,
failureFatal);
if(ok)
if (ok)
{
if(failureFatal || content)
if (failureFatal || content)
ok = castToElement(content, val, ppThis, pThisVal);
if(failureFatal && !ok)
if (failureFatal && !ok)
xpc_qsThrow(cx, NS_ERROR_XPC_BAD_OP_ON_WN_PROTO);
}
if(!failureFatal && (!ok || !content))
if (!failureFatal && (!ok || !content))
{
ok = JS_TRUE;
*ppThis = nsnull;
@ -147,7 +147,7 @@ xpc_qsUnwrapArg<nsGenericElement>(JSContext *cx,
nsIContent *content;
jsval val;
nsresult rv = xpc_qsUnwrapArg<nsIContent>(cx, v, &content, ppArgRef, &val);
if(NS_SUCCEEDED(rv) && !castToElement(content, val, ppArg, vp))
if (NS_SUCCEEDED(rv) && !castToElement(content, val, ppArg, vp))
rv = NS_ERROR_XPC_BAD_CONVERT_JS;
return rv;
}

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

@ -158,12 +158,12 @@ nsScriptError::InitWithWindowID(const PRUnichar *message,
mTimeStamp = PR_Now() / 1000;
mInnerWindowID = aInnerWindowID;
if(aInnerWindowID) {
if (aInnerWindowID) {
nsGlobalWindow* window =
nsGlobalWindow::GetInnerWindowWithId(aInnerWindowID);
if(window) {
if (window) {
nsPIDOMWindow* outer = window->GetOuterWindow();
if(outer)
if (outer)
mOuterWindowID = outer->WindowID();
}
}
@ -191,14 +191,14 @@ nsScriptError::ToString(nsACString& /*UTF8*/ aResult)
char* tempSourceName = nsnull;
char* tempSourceLine = nsnull;
if(!mMessage.IsEmpty())
if (!mMessage.IsEmpty())
tempMessage = ToNewUTF8String(mMessage);
if(!mSourceName.IsEmpty())
if (!mSourceName.IsEmpty())
tempSourceName = ToNewUTF8String(mSourceName);
if(!mSourceLine.IsEmpty())
if (!mSourceLine.IsEmpty())
tempSourceLine = ToNewUTF8String(mSourceLine);
if(nsnull != tempSourceName && nsnull != tempSourceLine)
if (nsnull != tempSourceName && nsnull != tempSourceLine)
temp = JS_smprintf(format0,
severity,
tempMessage,
@ -206,7 +206,7 @@ nsScriptError::ToString(nsACString& /*UTF8*/ aResult)
mLineNumber,
mColumnNumber,
tempSourceLine);
else if(!mSourceName.IsEmpty())
else if (!mSourceName.IsEmpty())
temp = JS_smprintf(format1,
severity,
tempMessage,
@ -217,11 +217,11 @@ nsScriptError::ToString(nsACString& /*UTF8*/ aResult)
severity,
tempMessage);
if(nsnull != tempMessage)
if (nsnull != tempMessage)
nsMemory::Free(tempMessage);
if(nsnull != tempSourceName)
if (nsnull != tempSourceName)
nsMemory::Free(tempSourceName);
if(nsnull != tempSourceLine)
if (nsnull != tempSourceLine)
nsMemory::Free(tempSourceLine);
if (!temp)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -295,7 +295,7 @@ class PtrAndPrincipalHashKey : public PLDHashEntryHdr
// NB: nsDataHashtableMT is usually not very useful as all it does is lock
// around each individual operation performed on it. That would imply, that
// the pattern: if(!map.Get(key)) map.Put(key, value); is not safe as another
// the pattern: if (!map.Get(key)) map.Put(key, value); is not safe as another
// thread could race to insert key into map. However, in our case, only one
// thread at any time could attempt to insert |key| into |map|, so it works
// well enough for our uses.
@ -310,7 +310,7 @@ typedef nsDataHashtable<xpc::PtrAndPrincipalHashKey, JSCompartment *> XPCCompart
#define XPC_STRING_GETTER_BODY(dest, src) \
NS_ENSURE_ARG_POINTER(dest); \
char* result; \
if(src) \
if (src) \
result = (char*) nsMemory::Clone(src, \
sizeof(char)*(strlen(src)+1)); \
else \
@ -367,13 +367,13 @@ public:
: mLock(lock)
{
MOZILLA_GUARD_OBJECT_NOTIFIER_INIT;
if(mLock)
if (mLock)
mLock->Enter();
}
~XPCAutoLock()
{
if(mLock)
if (mLock)
{
mLock->Exit();
}
@ -407,7 +407,7 @@ public:
: mLock(lock)
{
MOZILLA_GUARD_OBJECT_NOTIFIER_INIT;
if(mLock)
if (mLock)
{
mLock->Exit();
}
@ -415,7 +415,7 @@ public:
~XPCAutoUnlock()
{
if(mLock)
if (mLock)
mLock->Enter();
}
@ -778,7 +778,7 @@ public:
JSDHashEntryHdr *entry =
JS_DHashTableOperate(DEBUG_WrappedNativeHashtable,
wrapper, JS_DHASH_ADD);
if(entry) ((JSDHashEntryStub *)entry)->key = wrapper;}
if (entry) ((JSDHashEntryStub *)entry)->key = wrapper;}
void DEBUG_RemoveWrappedNative(nsIXPConnectWrappedNative* wrapper)
{XPCAutoLock lock(GetMapLock());
@ -921,11 +921,11 @@ public:
nsIXPCSecurityManager* GetAppropriateSecurityManager(PRUint16 flags) const
{
NS_ASSERTION(CallerTypeIsKnown(),"missing caller type set somewhere");
if(!CallerTypeIsJavaScript())
if (!CallerTypeIsJavaScript())
return nsnull;
if(mSecurityManager)
if (mSecurityManager)
{
if(flags & mSecurityManagerFlags)
if (flags & mSecurityManagerFlags)
return mSecurityManager;
}
else
@ -933,7 +933,7 @@ public:
nsIXPCSecurityManager* mgr;
nsXPConnect* xpc = mRuntime->GetXPConnect();
mgr = xpc->GetDefaultSecurityManager();
if(mgr && (flags & xpc->GetDefaultSecurityManagerFlags()))
if (mgr && (flags & xpc->GetDefaultSecurityManagerFlags()))
return mgr;
}
return nsnull;
@ -1266,9 +1266,9 @@ public:
}
~XPCLazyCallContext()
{
if(mCcxToDestroy)
if (mCcxToDestroy)
mCcxToDestroy->~XPCCallContext();
else if(mCallBeginRequest == CALLED_BEGINREQUEST)
else if (mCallBeginRequest == CALLED_BEGINREQUEST)
JS_EndRequest(mCx);
}
void SetWrapper(XPCWrappedNative* wrapper,
@ -1277,10 +1277,10 @@ public:
JSContext *GetJSContext()
{
if(mCcx)
if (mCcx)
return mCcx->GetJSContext();
if(mCallBeginRequest == CALL_BEGINREQUEST) {
if (mCallBeginRequest == CALL_BEGINREQUEST) {
JS_BeginRequest(mCx);
mCallBeginRequest = CALLED_BEGINREQUEST;
}
@ -1289,14 +1289,14 @@ public:
}
JSObject *GetScopeForNewJSObjects() const
{
if(mCcx)
if (mCcx)
return mCcx->GetScopeForNewJSObjects();
return mObj;
}
void SetScopeForNewJSObjects(JSObject *obj)
{
if(mCcx) {
if (mCcx) {
mCcx->SetScopeForNewJSObjects(obj);
return;
}
@ -1305,14 +1305,14 @@ public:
}
JSObject *GetFlattenedJSObject() const
{
if(mCcx)
if (mCcx)
return mCcx->GetFlattenedJSObject();
return mFlattenedJSObject;
}
XPCCallContext &GetXPCCallContext()
{
if(!mCcx)
if (!mCcx)
{
mCcxToDestroy = mCcx =
new (mData) XPCCallContext(mCallerLanguage, mCx,
@ -1320,7 +1320,7 @@ public:
mObj,
mFlattenedJSObject, mWrapper,
mTearOff);
if(!mCcx->IsValid())
if (!mCcx->IsValid())
{
NS_ERROR("This is not supposed to fail!");
}
@ -2059,7 +2059,7 @@ public:
JSClass* GetJSClass()
{return Jsvalify(&mJSClass.base);}
JSClass* GetSlimJSClass()
{if(mCanBeSlim) return GetJSClass(); return nsnull;}
{if (mCanBeSlim) return GetJSClass(); return nsnull;}
XPCNativeScriptableShared(JSUint32 aFlags, char* aName,
PRUint32 interfacesBitmap)
@ -2071,7 +2071,7 @@ public:
MOZ_COUNT_CTOR(XPCNativeScriptableShared);}
~XPCNativeScriptableShared()
{if(mJSClass.base.name)nsMemory::Free((void*)mJSClass.base.name);
{if (mJSClass.base.name)nsMemory::Free((void*)mJSClass.base.name);
MOZ_COUNT_DTOR(XPCNativeScriptableShared);}
char* TransferNameOwnership()
@ -2127,7 +2127,7 @@ public:
void
SetScriptableShared(XPCNativeScriptableShared* shared) {mShared = shared;}
void Mark() {if(mShared) mShared->Mark();}
void Mark() {if (mShared) mShared->Mark();}
protected:
XPCNativeScriptableInfo(nsIXPCScriptable* scriptable = nsnull,
@ -2254,7 +2254,7 @@ public:
static NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID);
#ifdef DEBUG
if(InitedOffsets() && mOffsets)
if (InitedOffsets() && mOffsets)
{
QITableEntry* offsets;
identity->QueryInterface(kThisPtrOffsetsSID, (void**)&offsets);
@ -2264,9 +2264,9 @@ public:
}
#endif
if(!InitedOffsets())
if (!InitedOffsets())
{
if(mClassInfoFlags & nsIClassInfo::CONTENT_NODE)
if (mClassInfoFlags & nsIClassInfo::CONTENT_NODE)
{
identity->QueryInterface(kThisPtrOffsetsSID, (void**)&mOffsets);
}
@ -2309,12 +2309,12 @@ public:
void TraceJS(JSTracer* trc)
{
if(mJSProtoObject)
if (mJSProtoObject)
{
JS_CALL_OBJECT_TRACER(trc, mJSProtoObject,
"XPCWrappedNativeProto::mJSProtoObject");
}
if(mScriptableInfo && JS_IsGCMarkingTracer(trc))
if (mScriptableInfo && JS_IsGCMarkingTracer(trc))
mScriptableInfo->Mark();
}
@ -2324,7 +2324,7 @@ public:
// Yes, we *do* need to mark the mScriptableInfo in both cases.
void Mark() const
{mSet->Mark();
if(mScriptableInfo) mScriptableInfo->Mark();}
if (mScriptableInfo) mScriptableInfo->Mark();}
#ifdef DEBUG
void ASSERT_SetNotMarked() const {mSet->ASSERT_NotMarked();}
@ -2539,7 +2539,7 @@ public:
*/
JSObject*
GetFlatJSObject() const
{if(mFlatJSObject != INVALID_OBJECT)
{if (mFlatJSObject != INVALID_OBJECT)
xpc_UnmarkGrayObject(mFlatJSObject);
return mFlatJSObject;}
@ -2637,7 +2637,7 @@ public:
JSObject *obj2 = nsnull;
XPCWrappedNative* wrapper =
GetWrappedNativeOfJSObject(cx, obj, nsnull, &obj2);
if(wrapper || !obj2)
if (wrapper || !obj2)
return wrapper;
NS_ASSERTION(IS_SLIM_WRAPPER(obj2),
@ -2682,21 +2682,21 @@ public:
void Mark() const
{
mSet->Mark();
if(mScriptableInfo) mScriptableInfo->Mark();
if(HasProto()) GetProto()->Mark();
if (mScriptableInfo) mScriptableInfo->Mark();
if (HasProto()) GetProto()->Mark();
}
// Yes, we *do* need to mark the mScriptableInfo in both cases.
inline void TraceJS(JSTracer* trc)
{
if(mScriptableInfo && JS_IsGCMarkingTracer(trc))
if (mScriptableInfo && JS_IsGCMarkingTracer(trc))
mScriptableInfo->Mark();
if(HasProto()) GetProto()->TraceJS(trc);
if (HasProto()) GetProto()->TraceJS(trc);
JSObject* wrapper = GetWrapperPreserveColor();
if(wrapper)
if (wrapper)
JS_CALL_OBJECT_TRACER(trc, wrapper, "XPCWrappedNative::mWrapper");
if(mScriptableInfo &&
(mScriptableInfo->GetJSClass()->flags & JSCLASS_XPCONNECT_GLOBAL))
if (mScriptableInfo &&
(mScriptableInfo->GetJSClass()->flags & JSCLASS_XPCONNECT_GLOBAL))
GetScope()->TraceDOMPrototypes(trc);
}
@ -2707,7 +2707,7 @@ public:
// This is the only time we should be tracing our mFlatJSObject,
// normally somebody else is doing that. Be careful not to trace the
// bogus INVALID_OBJECT value we can have during init, though.
if(mFlatJSObject && mFlatJSObject != INVALID_OBJECT)
if (mFlatJSObject && mFlatJSObject != INVALID_OBJECT)
{
JS_CALL_OBJECT_TRACER(trc, mFlatJSObject,
"XPCWrappedNative::mFlatJSObject");
@ -2717,11 +2717,11 @@ public:
#ifdef DEBUG
void ASSERT_SetsNotMarked() const
{mSet->ASSERT_NotMarked();
if(HasProto()){GetProto()->ASSERT_SetNotMarked();}}
if (HasProto()){GetProto()->ASSERT_SetNotMarked();}}
int DEBUG_CountOfTearoffChunks() const
{int i = 0; const XPCWrappedNativeTearOffChunk* to;
for(to = &mFirstChunk; to; to = to->mNextChunk) {i++;} return i;}
for (to = &mFirstChunk; to; to = to->mNextChunk) {i++;} return i;}
#endif
inline void SweepTearOffs();
@ -2746,7 +2746,7 @@ public:
JSObject* GetWrapper()
{
JSObject* wrapper = GetWrapperPreserveColor();
if(wrapper)
if (wrapper)
{
xpc_UnmarkGrayObject(wrapper);
// Call this to unmark mFlatJSObject.
@ -2767,12 +2767,12 @@ public:
QITableEntry* GetOffsets()
{
if(!HasProto() || !GetProto()->ClassIsDOMObject())
if (!HasProto() || !GetProto()->ClassIsDOMObject())
return nsnull;
XPCWrappedNativeProto* proto = GetProto();
QITableEntry* offsets = proto->GetOffsets();
if(!offsets)
if (!offsets)
{
static NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID);
mIdentity->QueryInterface(kThisPtrOffsetsSID, (void**)&offsets);
@ -2932,7 +2932,7 @@ private:
JSBool IsReflectable(uint16 i) const
{return (JSBool)(mDescriptors[i/32] & (1 << (i%32)));}
void SetReflectable(uint16 i, JSBool b)
{if(b) mDescriptors[i/32] |= (1 << (i%32));
{if (b) mDescriptors[i/32] |= (1 << (i%32));
else mDescriptors[i/32] &= ~(1 << (i%32));}
enum SizeMode {GET_SIZE, GET_LENGTH};
@ -3136,9 +3136,9 @@ public:
mCache(aCache),
mIsNode(PR_FALSE)
{
if(!mCache)
if (!mCache)
{
if(aObject)
if (aObject)
CallQueryInterface(aObject, &mCache);
else
mCache = nsnull;
@ -3171,17 +3171,17 @@ public:
nsIClassInfo *GetClassInfo()
{
if(mXPCClassInfo)
if (mXPCClassInfo)
return mXPCClassInfo;
if(!mClassInfo)
if (!mClassInfo)
mClassInfo = do_QueryInterface(mObject);
return mClassInfo;
}
nsXPCClassInfo *GetXPCClassInfo()
{
if(!mXPCClassInfo)
if (!mXPCClassInfo)
{
if(mIsNode)
if (mIsNode)
mXPCClassInfo = static_cast<nsINode*>(GetCanonical())->GetClassInfo();
else
CallQueryInterface(mObject, getter_AddRefs(mXPCClassInfo));
@ -3209,7 +3209,7 @@ protected:
mCache(aCache),
mIsNode(aIsNode)
{
if(!mCache && aObject)
if (!mCache && aObject)
CallQueryInterface(aObject, &mCache);
}
@ -3656,14 +3656,14 @@ public:
// Get the instance of this object for the current thread
static inline XPCPerThreadData* GetData(JSContext *cx)
{
if(cx)
if (cx)
{
NS_ASSERTION(cx->thread(), "Uh, JS context w/o a thread?");
if(cx->thread() == sMainJSThread)
if (cx->thread() == sMainJSThread)
return sMainThreadData;
}
else if(sMainThreadData && sMainThreadData->mThread == PR_GetCurrentThread())
else if (sMainThreadData && sMainThreadData->mThread == PR_GetCurrentThread())
{
return sMainThreadData;
}
@ -3677,7 +3677,7 @@ public:
nsresult GetException(nsIException** aException)
{
if(EnsureExceptionManager())
if (EnsureExceptionManager())
return mExceptionManager->GetCurrentException(aException);
NS_IF_ADDREF(mException);
@ -3687,7 +3687,7 @@ public:
nsresult SetException(nsIException* aException)
{
if(EnsureExceptionManager())
if (EnsureExceptionManager())
return mExceptionManager->SetCurrentException(aException);
NS_IF_ADDREF(aException);
@ -3698,24 +3698,24 @@ public:
nsIExceptionManager* GetExceptionManager()
{
if(EnsureExceptionManager())
if (EnsureExceptionManager())
return mExceptionManager;
return nsnull;
}
JSBool EnsureExceptionManager()
{
if(mExceptionManager)
if (mExceptionManager)
return JS_TRUE;
if(mExceptionManagerNotAvailable)
if (mExceptionManagerNotAvailable)
return JS_FALSE;
nsCOMPtr<nsIExceptionService> xs =
do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
if(xs)
if (xs)
xs->GetCurrentExceptionManager(&mExceptionManager);
if(mExceptionManager)
if (mExceptionManager)
return JS_TRUE;
mExceptionManagerNotAvailable = JS_TRUE;
@ -4093,14 +4093,14 @@ public:
Link();}
void Link()
{if(!mTLS) return;
{if (!mTLS) return;
AutoMarkingPtr** list = mTLS->GetAutoRootsAdr();
mNext = *list; *list = this;}
void Unlink()
{if(!mTLS) return;
{if (!mTLS) return;
AutoMarkingPtr** cur = mTLS->GetAutoRootsAdr();
while(*cur != this) {
while (*cur != this) {
NS_ASSERTION(*cur, "This object not in list!");
cur = &(*cur)->mNext;
}
@ -4131,15 +4131,15 @@ public: \
virtual ~ class_ () {} \
\
virtual void TraceJS(JSTracer* trc) \
{if(mPtr) { \
{if (mPtr) { \
mPtr->TraceJS(trc); \
mPtr->AutoTrace(trc); \
} \
if(mNext) mNext->TraceJS(trc);} \
if (mNext) mNext->TraceJS(trc);} \
\
virtual void MarkAfterJSFinalize() \
{if(mPtr) mPtr->Mark(); \
if(mNext) mNext->MarkAfterJSFinalize();} \
{if (mPtr) mPtr->Mark(); \
if (mNext) mNext->MarkAfterJSFinalize();} \
\
type_ * get() const {return mPtr;} \
operator type_ *() const {return mPtr;} \
@ -4172,34 +4172,34 @@ public: \
bool aClear = false) \
: AutoMarkingPtr(ccx), mPtr(aPtr), mCount(aCount) \
{ \
if(!mPtr) mCount = 0; \
else if(aClear) memset(mPtr, 0, mCount*sizeof(type_*)); \
if (!mPtr) mCount = 0; \
else if (aClear) memset(mPtr, 0, mCount*sizeof(type_*)); \
} \
virtual ~ class_ () {} \
\
virtual void TraceJS(JSTracer* trc) \
{ \
for(PRUint32 i = 0; i < mCount; ++i) \
for (PRUint32 i = 0; i < mCount; ++i) \
{ \
type_* cur = mPtr[i]; \
if(cur) \
if (cur) \
{ \
cur->TraceJS(trc); \
cur->AutoTrace(trc); \
} \
} \
if(mNext) mNext->TraceJS(trc); \
if (mNext) mNext->TraceJS(trc); \
} \
\
virtual void MarkAfterJSFinalize() \
{ \
for(PRUint32 i = 0; i < mCount; ++i) \
for (PRUint32 i = 0; i < mCount; ++i) \
{ \
type_* cur = mPtr[i]; \
if(cur) \
if (cur) \
cur->Mark(); \
} \
if(mNext) mNext->MarkAfterJSFinalize(); \
if (mNext) mNext->MarkAfterJSFinalize(); \
} \
\
type_ ** get() const {return mPtr;} \
@ -4276,7 +4276,7 @@ public:
* kept alive past the next CC.
*/
jsval GetJSVal() const
{if(!JSVAL_IS_PRIMITIVE(mJSVal))
{if (!JSVAL_IS_PRIMITIVE(mJSVal))
xpc_UnmarkGrayObject(JSVAL_TO_OBJECT(mJSVal));
return mJSVal;}
@ -4500,7 +4500,7 @@ struct CompartmentPrivate
bool RegisterDOMExpandoObject(JSObject *expando) {
if (!domExpandoMap) {
domExpandoMap = new nsTHashtable<nsPtrHashKey<JSObject> >();
if(!domExpandoMap->Init(8)) {
if (!domExpandoMap->Init(8)) {
domExpandoMap = nsnull;
return false;
}
@ -4508,7 +4508,7 @@ struct CompartmentPrivate
return domExpandoMap->PutEntry(expando);
}
void RemoveDOMExpandoObject(JSObject *expando) {
if(domExpandoMap)
if (domExpandoMap)
domExpandoMap->RemoveEntry(expando);
}
};

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

@ -115,7 +115,7 @@ DebugCheckWrapperClass(JSObject* obj)
inline JSObject *
xpc_GetGlobalForObject(JSObject *obj)
{
while(JSObject *parent = js::GetObjectParent(obj))
while (JSObject *parent = js::GetObjectParent(obj))
obj = parent;
return obj;
}
@ -178,7 +178,7 @@ xpc_UnmarkGrayObjectRecursive(JSObject* obj);
inline void
xpc_UnmarkGrayObject(JSObject *obj)
{
if(obj && xpc_IsGrayGCThing(obj))
if (obj && xpc_IsGrayGCThing(obj))
xpc_UnmarkGrayObjectRecursive(obj);
}

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

@ -53,7 +53,7 @@ xpcTestObjectReadOnly :: xpcTestObjectReadOnly() {
NS_IMETHODIMP xpcTestObjectReadOnly :: GetStrReadOnly(char * *aStrReadOnly){
char aString[] = "XPConnect Read-Only String";
if(!aStrReadOnly)
if (!aStrReadOnly)
return NS_ERROR_NULL_POINTER;
*aStrReadOnly = (char*) nsMemory::Clone(aString,
sizeof(char)*(strlen(aString)+1));
@ -99,7 +99,7 @@ xpcTestObjectReadWrite :: ~xpcTestObjectReadWrite()
}
NS_IMETHODIMP xpcTestObjectReadWrite :: GetStringProperty(char * *aStringProperty) {
if(!aStringProperty)
if (!aStringProperty)
return NS_ERROR_NULL_POINTER;
*aStringProperty = (char*) nsMemory::Clone(stringProperty,
sizeof(char)*(strlen(stringProperty)+1));

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

@ -135,7 +135,7 @@ IsPermitted(const char *name, JSFlatString *prop, bool set)
const jschar *propChars = JS_GetInternedStringCharsAndLength(prop, &propLength);
if (!propLength)
return false;
switch(name[0]) {
switch (name[0]) {
NAME('D', "DOMException",
PROP('c', RW("code"))
PROP('m', RW("message"))
@ -405,7 +405,7 @@ AccessCheck::isScriptAccessOnly(JSContext *cx, JSObject *wrapper)
// In addition, chrome objects can explicitly opt-in by setting .scriptOnly to true.
if (js::GetProxyHandler(wrapper) ==
&FilteringWrapper<CrossCompartmentSecurityWrapper,
CrossOriginAccessiblePropertiesOnly>::singleton) {
CrossOriginAccessiblePropertiesOnly>::singleton) {
jsid scriptOnlyId = GetRTIdByIndex(cx, XPCJSRuntime::IDX_SCRIPTONLY);
jsval scriptOnly;
if (JS_LookupPropertyById(cx, obj, scriptOnlyId, &scriptOnly) &&

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

@ -73,7 +73,7 @@ CrossOriginWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid
bool
CrossOriginWrapper::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
bool set, js::PropertyDescriptor *desc)
bool set, js::PropertyDescriptor *desc)
{
return CrossCompartmentWrapper::getOwnPropertyDescriptor(cx, wrapper, id, set, desc) &&
WrapperFactory::WaiveXrayAndWrap(cx, &desc->value);

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

@ -458,7 +458,7 @@ WrapperFactory::WrapSOWObject(JSContext *cx, JSObject *obj)
JSObject *wrapperObj =
Wrapper::New(cx, obj, JS_GetPrototype(cx, obj), JS_GetGlobalForObject(cx, obj),
&FilteringWrapper<SameCompartmentSecurityWrapper,
OnlyIfSubjectIsSystem>::singleton);
OnlyIfSubjectIsSystem>::singleton);
return wrapperObj;
}