renaming the field called 'code' to 'result' in nsIXPCException so that we don't conflict with DOM exception's use of the name 'code'. We want these types of exceptions to be compatible and the DOM exception ought to have a 'code' field that is as required by the DOM spec and also a 'result' field that is the nsresult. This avoids the naming conflict.

This commit is contained in:
jband%netscape.com 1999-09-03 02:32:21 +00:00
Родитель 8bbf5abf79
Коммит e19b1fb7da
9 изменённых файлов: 44 добавлений и 43 удалений

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

@ -35,13 +35,13 @@ interface nsIJSStackFrameLocation : nsISupports
interface nsIXPCException : nsISupports
{
readonly attribute string message;
readonly attribute nsresult code;
readonly attribute nsresult result;
readonly attribute string name;
readonly attribute nsIJSStackFrameLocation location;
readonly attribute nsISupports data;
void initialize(in string aMessage,
in nsresult aCode,
in nsresult aResult,
in string aName,
in nsIJSStackFrameLocation aLocation,
in nsISupports aData);

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

@ -1040,18 +1040,18 @@ nsXPCComponents::Create(JSContext *cx, JSObject *obj,
" return '\\nfunction ID() {\\n [JavaScript code]\\n}\\n';\n"
"};\n"
"\n"
"this.Exception = function(str, code, stack, data) {\n"
"this.Exception = function(str, result, stack, data) {\n"
" var clazz = Components.classes['nsXPCException'];\n"
" var iface = Components.interfaces['nsIXPCException'];\n"
" var exception = clazz.createInstance(iface);\n"
" /* all fall through */\n"
" switch(arguments.length){\n"
" case 0: str = 'exception';\n"
" case 1: code = Components.results.NS_ERROR_FAILURE;\n"
" case 1: result = Components.results.NS_ERROR_FAILURE;\n"
" case 2: stack = Components.stack.caller;\n"
" case 3: data = null;\n"
" }\n"
" exception.initialize(str, code, null, stack, data);\n"
" exception.initialize(str, result, null, stack, data);\n"
" return exception;\n"
"};\n"
"\n"

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

@ -86,7 +86,7 @@ NS_IMPL_ISUPPORTS1(nsXPCException, nsIXPCException)
nsXPCException::nsXPCException()
: mMessage(nsnull),
mCode(0),
mResult(0),
mName(nsnull),
mLocation(nsnull),
mData(nsnull),
@ -126,15 +126,15 @@ nsXPCException::GetMessage(char * *aMessage)
XPC_STRING_GETTER_BODY(aMessage, mMessage);
}
/* readonly attribute nsresult code; */
/* readonly attribute nsresult result; */
NS_IMETHODIMP
nsXPCException::GetCode(nsresult *aCode)
nsXPCException::GetResult(nsresult *aResult)
{
if(!aCode)
if(!aResult)
return NS_ERROR_NULL_POINTER;
if(!mInitialized)
return NS_ERROR_NOT_INITIALIZED;
*aCode = mCode;
*aResult = mResult;
return NS_OK;
}
@ -147,7 +147,7 @@ nsXPCException::GetName(char * *aName)
const char* name = mName;
if(!name)
NameAndFormatForNSResult(mCode, &name, nsnull);
NameAndFormatForNSResult(mResult, &name, nsnull);
XPC_STRING_GETTER_BODY(aName, name);
}
@ -178,9 +178,9 @@ nsXPCException::GetData(nsISupports * *aData)
return NS_OK;
}
/* void initialize (in string aMessage, in nsresult aCode, in string aName, in nsIJSStackFrameLocation aLocation, in nsISupports aData); */
/* void initialize (in string aMessage, in nsresult aResult, in string aName, in nsIJSStackFrameLocation aLocation, in nsISupports aData); */
NS_IMETHODIMP
nsXPCException::Initialize(const char *aMessage, nsresult aCode, const char *aName, nsIJSStackFrameLocation *aLocation, nsISupports *aData)
nsXPCException::Initialize(const char *aMessage, nsresult aResult, const char *aName, nsIJSStackFrameLocation *aLocation, nsISupports *aData)
{
if(mInitialized)
return NS_ERROR_ALREADY_INITIALIZED;
@ -201,7 +201,7 @@ nsXPCException::Initialize(const char *aMessage, nsresult aCode, const char *aNa
return NS_ERROR_OUT_OF_MEMORY;
}
mCode = aCode;
mResult = aResult;
if(aLocation)
{
@ -254,11 +254,11 @@ nsXPCException::ToString(char **_retval)
const char* location = indicatedLocation ?
indicatedLocation : defaultLocation;
const char* resultName = mName;
if(!resultName && !NameAndFormatForNSResult(mCode, &resultName, nsnull))
if(!resultName && !NameAndFormatForNSResult(mResult, &resultName, nsnull))
resultName = "<unknown>";
const char* data = mData ? "yes" : "no";
char* temp = JS_smprintf(format, msg, mCode, resultName, location, data);
char* temp = JS_smprintf(format, msg, mResult, resultName, location, data);
if(indicatedLocation)
nsAllocator::Free(indicatedLocation);
@ -277,7 +277,7 @@ nsXPCException::ToString(char **_retval)
// static
nsXPCException*
nsXPCException::NewException(const char *aMessage,
nsresult aCode,
nsresult aResult,
nsIJSStackFrameLocation *aLocation,
nsISupports *aData,
PRInt32 aLeadingFramesToTrim)
@ -319,7 +319,7 @@ nsXPCException::NewException(const char *aMessage,
location = caller;
}
// at this point we have non-null location with one extra addref
rv = e->Initialize(aMessage, aCode, nsnull, location, aData);
rv = e->Initialize(aMessage, aResult, nsnull, location, aData);
NS_RELEASE(location);
if(NS_FAILED(rv))
NS_RELEASE(e);

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

@ -946,7 +946,7 @@ public:
NS_DECL_NSIXPCEXCEPTION
static nsXPCException* NewException(const char *aMessage,
nsresult aCode,
nsresult aResult,
nsIJSStackFrameLocation *aLocation,
nsISupports *aData,
PRInt32 aLeadingFramesToTrim);
@ -965,7 +965,7 @@ protected:
void Reset();
private:
char* mMessage;
nsresult mCode;
nsresult mResult;
char* mName;
nsIJSStackFrameLocation* mLocation;
nsISupports* mData;

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

@ -94,9 +94,9 @@ XPCJSThrower::ThrowBadResultException(nsresult rv,
{
JSBool success = JS_FALSE;
xpc->SetPendingException(nsnull);
nsresult code;
nsresult e_result;
if(NS_SUCCEEDED(e->GetCode(&code)) && code == result)
if(NS_SUCCEEDED(e->GetResult(&e_result)) && e_result == result)
{
if(!ThrowExceptionObject(cx, e))
JS_ReportOutOfMemory(cx);

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

@ -544,18 +544,18 @@ pre_call_clean_up:
{
// Only throw the exception and fail if the JS code threw something
// that does indicate a failure; i.e. 'throw 0' is not really a failure
nsresult e_code;
if(NS_SUCCEEDED(xpc_exception->GetCode(&e_code)) && NS_FAILED(e_code))
nsresult e_result;
if(NS_SUCCEEDED(xpc_exception->GetResult(&e_result)) && NS_FAILED(e_result))
{
xpc->SetPendingException(xpc_exception);
NS_RELEASE(xpc_exception);
mXPCContext->SetException(nsnull);
retval = e_code;
retval = e_result;
success = JS_FALSE;
}
else
{
pending_result = e_code;
pending_result = e_result;
NS_RELEASE(xpc_exception);
}
}

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

@ -1086,9 +1086,10 @@ sm_test_done:
if(NS_SUCCEEDED(rv))
{
PRInt32 count;
if(NS_SUCCEEDED(stack->GetCount(&count)))
printf("\tstack->GetCount() : %s\n",
count == 0 ? "passed" : "failed!");
PRInt32 base_count;
if(NS_SUCCEEDED(stack->GetCount(&base_count)))
printf("\tstack->GetCount() : passed\n");
else
printf("\tstack->GetCount() failed!\n");
@ -1099,7 +1100,7 @@ sm_test_done:
if(NS_SUCCEEDED(stack->GetCount(&count)))
printf("\tstack->GetCount() : %s\n",
count == 1 ? "passed" : "failed!");
count == base_count+1 ? "passed" : "failed!");
else
printf("\tstack->GetCount() failed!\n");
@ -1122,7 +1123,7 @@ sm_test_done:
if(NS_SUCCEEDED(stack->GetCount(&count)))
printf("\tstack->GetCount() : %s\n",
count == 0 ? "passed" : "failed!");
count == base_count ? "passed" : "failed!");
else
printf("\tstack->GetCount() failed!\n");
}

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

@ -255,9 +255,9 @@ try {
all_ok = false;
} catch(e) {
var lastResult = Components.lastResult;
if(e.code != lastResult) {
if(e.result != lastResult) {
all_ok = false;
print("expected: NS_ERROR_NULL_POINTER = "+Components.results.NS_ERROR_NULL_POINTER+" e.code was: "+e.code+" Components.lastResult: "+lastResult);
print("expected: NS_ERROR_NULL_POINTER = "+Components.results.NS_ERROR_NULL_POINTER+" e.result was: "+e.result+" Components.lastResult: "+lastResult);
}
if(Components.results.NS_ERROR_NULL_POINTER != lastResult) {
@ -271,9 +271,9 @@ try {
all_ok = false;
} catch(e) {
var lastResult = Components.lastResult;
if(e.code != lastResult) {
if(e.result != lastResult) {
all_ok = false;
print("expected: NS_ERROR_UNEXPECTED = "+Components.results.NS_ERROR_UNEXPECTED+" e.code was: "+e.code+" Components.lastResult: "+lastResult);
print("expected: NS_ERROR_UNEXPECTED = "+Components.results.NS_ERROR_UNEXPECTED+" e.result was: "+e.result+" Components.lastResult: "+lastResult);
}
if(Components.results.NS_ERROR_UNEXPECTED != lastResult) {
@ -287,9 +287,9 @@ try {
all_ok = false;
} catch(e) {
var lastResult = Components.lastResult;
if(e.code != lastResult) {
if(e.result != lastResult) {
all_ok = false;
print("expected: NS_ERROR_OUT_OF_MEMORY = "+Components.results.NS_ERROR_OUT_OF_MEMORY+" e.code was: "+e.code+" Components.lastResult: "+lastResult);
print("expected: NS_ERROR_OUT_OF_MEMORY = "+Components.results.NS_ERROR_OUT_OF_MEMORY+" e.result was: "+e.result+" Components.lastResult: "+lastResult);
}
if(Components.results.NS_ERROR_OUT_OF_MEMORY != lastResult) {

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

@ -232,9 +232,9 @@ try {
all_ok = false;
} catch(e) {
var lastResult = Components.lastResult;
if(e.code != lastResult) {
if(e.result != lastResult) {
all_ok = false;
print("expected: NS_ERROR_NULL_POINTER = "+Components.results.NS_ERROR_NULL_POINTER+" e.code was: "+e.code+" Components.lastResult: "+lastResult);
print("expected: NS_ERROR_NULL_POINTER = "+Components.results.NS_ERROR_NULL_POINTER+" e.result was: "+e.result+" Components.lastResult: "+lastResult);
}
if(Components.results.NS_ERROR_NULL_POINTER != lastResult) {
@ -248,9 +248,9 @@ try {
all_ok = false;
} catch(e) {
var lastResult = Components.lastResult;
if(e.code != lastResult) {
if(e.result != lastResult) {
all_ok = false;
print("expected: NS_ERROR_UNEXPECTED = "+Components.results.NS_ERROR_UNEXPECTED+" e.code was: "+e.code+" Components.lastResult: "+lastResult);
print("expected: NS_ERROR_UNEXPECTED = "+Components.results.NS_ERROR_UNEXPECTED+" e.result was: "+e.result+" Components.lastResult: "+lastResult);
}
if(Components.results.NS_ERROR_UNEXPECTED != lastResult) {
@ -264,9 +264,9 @@ try {
all_ok = false;
} catch(e) {
var lastResult = Components.lastResult;
if(e.code != lastResult) {
if(e.result != lastResult) {
all_ok = false;
print("expected: NS_ERROR_OUT_OF_MEMORY = "+Components.results.NS_ERROR_OUT_OF_MEMORY+" e.code was: "+e.code+" Components.lastResult: "+lastResult);
print("expected: NS_ERROR_OUT_OF_MEMORY = "+Components.results.NS_ERROR_OUT_OF_MEMORY+" e.result was: "+e.result+" Components.lastResult: "+lastResult);
}
if(Components.results.NS_ERROR_OUT_OF_MEMORY != lastResult) {