]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/mac/html_wrap.cpp
reSWIGged
[wxWidgets.git] / wxPython / src / mac / html_wrap.cpp
index 541d2e2ca608124caa3799cab6a2104d03ceacad..429e2e1c76a088a6bee84a5c1566be2a6fd5f8fd 100644 (file)
@@ -358,7 +358,15 @@ SWIG_CheckLongInRange(long value, const char* type,
 SWIGSTATICINLINE(long)
 SWIG_AsLong(PyObject * obj)
 {
 SWIGSTATICINLINE(long)
 SWIG_AsLong(PyObject * obj)
 {
-  return PyInt_Check(obj) ? PyInt_AsLong(obj) : PyLong_AsLong(obj);
+    if (PyNumber_Check(obj))
+        return PyInt_AsLong(obj);
+    else {
+        PyObject* errmsg = PyString_FromFormat("Expected number, got %s",
+                                               obj->ob_type->tp_name);
+        PyErr_SetObject(PyExc_TypeError, errmsg);
+        Py_DECREF(errmsg);
+        return 0;
+    }
 }
 
 
 }
 
 
@@ -565,9 +573,9 @@ SWIG_AsUnsignedLong(PyObject * obj)
   if (PyLong_Check(obj)) {
     return PyLong_AsUnsignedLong(obj);
   } else {
   if (PyLong_Check(obj)) {
     return PyLong_AsUnsignedLong(obj);
   } else {
-    long i = PyInt_AsLong(obj);
+    long i = SWIG_AsLong(obj);
     if ( !PyErr_Occurred() && (i < 0)) {
     if ( !PyErr_Occurred() && (i < 0)) {
-      PyErr_SetString(PyExc_TypeError, "negative value for unsigned type");
+      PyErr_SetString(PyExc_TypeError, "negative value received for unsigned type");
     }
     return i;
   }
     }
     return i;
   }
@@ -804,17 +812,15 @@ SWIG_FloatCast(double value)
 SWIGSTATICINLINE(double)
 SWIG_AsDouble(PyObject *obj)
 {
 SWIGSTATICINLINE(double)
 SWIG_AsDouble(PyObject *obj)
 {
-  double val = (PyFloat_Check(obj)) ? PyFloat_AsDouble(obj) :
-#if HAVE_LONG_LONG
-    ((PyInt_Check(obj)) ? PyInt_AsLong(obj) : PyLong_AsLongLong(obj));
-#else
-    ((PyInt_Check(obj)) ? PyInt_AsLong(obj) : PyLong_AsLong(obj));
-#endif
-  if (PyErr_Occurred()) {
-    PyErr_Clear();
-    PyErr_SetString(PyExc_TypeError, "a double is expected");
-  }
-  return val;
+    if (PyNumber_Check(obj))
+        return PyFloat_AsDouble(obj);
+    else {
+        PyObject* errmsg = PyString_FromFormat("Expected number, got %s",
+                                               obj->ob_type->tp_name);
+        PyErr_SetObject(PyExc_TypeError, errmsg);
+        Py_DECREF(errmsg);
+        return 0;
+    }
 }
 
 
 }