Browse Source

update for mozilla 18 code base
http://bugs.activestate.com/show_bug.cgi?id=96844

toddw 11 years ago
parent
commit
a4c57f8789

+ 5 - 5
xpcom/src/PyGBase.cpp

@@ -583,7 +583,7 @@ nsresult PyG_Base::HandleNativeGatewayError(const char *szMethodName)
 			;
 		} else if (PyInt_Check(err_result)) {
 			// The exception handler has given us the nresult.
-			rc = PyInt_AsLong(err_result);
+			rc = (nsresult)PyInt_AsLong(err_result);
 			bProcessMainError = false;
 		} else if (PyLong_Check(err_result)) {
 			// The exception handler has given us the nresult.
@@ -757,10 +757,10 @@ PyG_Base *GetDefaultGateway(PyObject *policy)
 	if (ob_existing_weak != NULL) {
 		bool ok = true;
 		nsCOMPtr<nsIWeakReference> pWeakRef;
-		ok = NS_SUCCEEDED(Py_nsISupports::InterfaceFromPyObject(ob_existing_weak, 
+		ok = Py_nsISupports::InterfaceFromPyObject(ob_existing_weak,
 		                                       NS_GET_IID(nsIWeakReference), 
 		                                       getter_AddRefs(pWeakRef),
-		                                       false));
+		                                       false);
 		Py_DECREF(ob_existing_weak);
 		nsISupports *pip;
 		if (ok) {
@@ -787,10 +787,10 @@ bool CheckDefaultGateway(PyObject *real_inst, REFNSIID iid, nsISupports **ret_ga
 		// may no longer be valid.  Check it.
 		bool ok = true;
 		nsCOMPtr<nsIWeakReference> pWeakRef;
-		ok = NS_SUCCEEDED(Py_nsISupports::InterfaceFromPyObject(ob_existing_weak, 
+		ok = Py_nsISupports::InterfaceFromPyObject(ob_existing_weak,
 		                                       NS_GET_IID(nsIWeakReference), 
 		                                       getter_AddRefs(pWeakRef), 
-		                                       false));
+		                                       false);
 		Py_DECREF(ob_existing_weak);
 		if (ok) {
 			Py_BEGIN_ALLOW_THREADS;

+ 3 - 1
xpcom/src/PyGModule.cpp

@@ -90,7 +90,9 @@ PyG_nsIModule::GetClassObject(nsIComponentManager *aCompMgr,
 	Py_XDECREF(iid);
 	Py_XDECREF(clsid);
 	if (NS_SUCCEEDED(nr)) {
-		nr = Py_nsISupports::InterfaceFromPyObject(ret, aIID, (nsISupports **)r_classObj, false);
+		if (!Py_nsISupports::InterfaceFromPyObject(ret, aIID, (nsISupports **)r_classObj, false)) {
+			nr = NS_ERROR_FAILURE;
+		}
 		if (PyErr_Occurred())
 			nr = HandleNativeGatewayError(methodName);
 	}

+ 1 - 1
xpcom/src/PyGStub.cpp

@@ -193,7 +193,7 @@ done:
 			;
 		} else if (PyInt_Check(err_result)) {
 			// The exception handler has given us the nresult.
-			rc = PyInt_AsLong(err_result);
+			rc = (nsresult) PyInt_AsLong(err_result);
 			bProcessMainError = false;
 		} else if (PyLong_Check(err_result)) {
 			// The exception handler has given us the nresult.

+ 1 - 1
xpcom/src/PyIEnumerator.cpp

@@ -158,7 +158,7 @@ static PyObject *PyFetchBlock(PyObject *self, PyObject *args)
 		nsISupports *pNew;
 		r = pI->CurrentItem(&pNew);
 		if (NS_FAILED(r)) {
-			r = 0; // Normal enum end
+			r = NS_OK; // Normal enum end
 			break;
 		}
 		if (obIID) {

+ 1 - 1
xpcom/src/VariantUtils.cpp

@@ -3256,7 +3256,7 @@ nsresult PyXPCOM_GatewayVariantHelper::ProcessPythonResult(PyObject *ret_ob)
 	// (ie, the policy is expected to return (NS_OK, user_retval),
 	// but can also return (say), NS_ERROR_FAILURE
 	if (PyInt_Check(ret_ob))
-		return PyInt_AsLong(ret_ob);
+		return (nsresult) PyInt_AsLong(ret_ob);
 	// Now it must be the tuple.
 	if (!PyTuple_Check(ret_ob) ||
 	    PyTuple_Size(ret_ob)!=2 ||

+ 1 - 1
xpcom/src/loader/pyloader.cpp

@@ -98,7 +98,7 @@ nsPythonModuleLoader::Init()
     if (func==NULL) goto done;
     mPyLoader = PyEval_CallObject(func, NULL);
 done:
-    nsresult nr = (mPyLoader != NULL);
+    nsresult nr = (mPyLoader != NULL) ? NS_OK : NS_ERROR_FAILURE;
     if (PyErr_Occurred()) {
             PyXPCOM_LogError("Obtaining the module object from Python failed.\n");
             nr = PyXPCOM_SetCOMErrorFromPyException();