]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_core_api.i
blind compilation fix for 64 bit systems after last commit
[wxWidgets.git] / wxPython / src / _core_api.i
index 41387580000499e2ee768ff69a7c69b9dab83277..1761c488133dfdbb6ca1962145818bca305d3b9f 100644 (file)
 // located here so they know about the SWIG types and functions declared
 // in the wrapper code.
 
+static
+swig_type_info* wxPyFindSwigType(const wxChar* className);
+%}
+
+
+#if SWIG_VERSION < 0x010328
+%{
+// Make a SWIGified pointer object suitable for a .this attribute
+PyObject* wxPyMakeSwigPtr(void* ptr, const wxChar* className) {
+    
+    PyObject* robj = NULL;
+
+    swig_type_info* swigType = wxPyFindSwigType(className);
+    wxCHECK_MSG(swigType != NULL, NULL, wxT("Unknown type in wxPyMakeSwigPtr"));
+
+#ifdef SWIG_COBJECT_TYPES
+    robj = PySwigObject_FromVoidPtrAndDesc((void *) ptr, (char *)swigType->name);
+#else
+    {
+        char result[1024];
+        robj = SWIG_PackVoidPtr(result, ptr, swigType->name, sizeof(result)) ?
+            PyString_FromString(result) : 0;
+    }
+#endif
+    return robj;
+}
+%}
+
+#else // SWIG_VERSION >= 1.3.28
+%{
+// Make a SWIGified pointer object suitable for a .this attribute
+PyObject* wxPyMakeSwigPtr(void* ptr, const wxChar* className) {
+    
+    PyObject* robj = NULL;
+
+    swig_type_info* swigType = wxPyFindSwigType(className);
+    wxCHECK_MSG(swigType != NULL, NULL, wxT("Unknown type in wxPyMakeSwigPtr"));
+
+    robj = PySwigObject_New(ptr, swigType, 0);
+    return robj;
+}
+%}
+#endif
+
+
+
+
+%{    
 #include <wx/hashmap.h>
 WX_DECLARE_STRING_HASH_MAP( swig_type_info*, wxPyTypeInfoHashMap );
 
@@ -42,7 +91,7 @@ swig_type_info* wxPyFindSwigType(const wxChar* className) {
     if (! swigType) {
         // it wasn't in the cache, so look it up from SWIG
         name.Append(wxT(" *"));
-        swigType = SWIG_Python_TypeQuery(name.mb_str());
+        swigType = SWIG_TypeQuery(name.mb_str());
         
         // if it still wasn't found, try looking for a mapped name
         if (!swigType) {
@@ -53,7 +102,7 @@ swig_type_info* wxPyFindSwigType(const wxChar* className) {
                                (char*)(const char*)name.mbc_str())) != NULL) {
                 name = wxString(PyString_AsString(item), *wxConvCurrent);
                 name.Append(wxT(" *"));
-                swigType = SWIG_Python_TypeQuery(name.mb_str());
+                swigType = SWIG_TypeQuery(name.mb_str());
             }
         }
         if (swigType) {
@@ -100,57 +149,42 @@ bool wxPyConvertSwigPtr(PyObject* obj, void **ptr,
 }
 
 
-// Make a SWIGified pointer object suitable for a .this attribute
-PyObject* wxPyMakeSwigPtr(void* ptr, const wxChar* className) {
-    
-    PyObject* robj = NULL;
-
-    swig_type_info* swigType = wxPyFindSwigType(className);
-    wxCHECK_MSG(swigType != NULL, NULL, wxT("Unknown type in wxPyConvertSwigPtr"));
 
-#ifdef SWIG_COBJECT_TYPES
-    robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) swigType->name, NULL);
-#else
-    {
-        char result[1024];
-        char *r = result;
-        *(r++) = '_';
-        r = SWIG_Python_PackData(r, &ptr, sizeof(void *));
-        strcpy(r, swigType->name);
-        robj = PyString_FromString(result);
-    }     
-#endif
 
-    return robj;
+// Python's PyInstance_Check does not return True for instances of new-style
+// classes.  This should get close enough for both new and old classes but I
+// should re-evaluate the need for doing instance checks...
+bool wxPyInstance_Check(PyObject* obj) {
+    return PyObject_HasAttrString(obj, "__class__") != 0;
 }
 
 
 
+// This one checks if the object is an instance of a SWIG proxy class (it has
+// a .this attribute, and the .this attribute is a PySwigObject.)
+bool wxPySwigInstance_Check(PyObject* obj) {
+    static PyObject* this_str = NULL;
+    if (this_str == NULL)
+        this_str = PyString_FromString("this");
+    
+    PyObject* this_attr = PyObject_GetAttr(obj, this_str);
+    if (this_attr) {
+        bool retval = (PySwigObject_Check(this_attr) != 0);
+        Py_DECREF(this_attr);
+        return retval;
+    }
+
+    PyErr_Clear();
+    return false;
+}
+
 
 // Export a C API in a struct.  Other modules will be able to load this from
 // the wx._core_ module and will then have safe access to these functions,
 // even if they are located in another shared library.
 static wxPyCoreAPI API = {
 
-    (p_SWIG_Python_TypeRegister_t)SWIG_Python_TypeRegister,
-    (p_SWIG_Python_TypeCheck_t)SWIG_Python_TypeCheck,
-    (p_SWIG_Python_TypeCast_t)SWIG_Python_TypeCast,
-    (p_SWIG_Python_TypeDynamicCast_t)SWIG_Python_TypeDynamicCast,
-    (p_SWIG_Python_TypeName_t)SWIG_Python_TypeName,
-    (p_SWIG_Python_TypePrettyName_t)SWIG_Python_TypePrettyName,
-    (p_SWIG_Python_TypeQuery_t)SWIG_Python_TypeQuery,
-    (p_SWIG_Python_TypeClientData_t)SWIG_Python_TypeClientData,
-    (p_SWIG_Python_newvarlink_t)SWIG_Python_newvarlink,
-    (p_SWIG_Python_addvarlink_t)SWIG_Python_addvarlink,
-    (p_SWIG_Python_ConvertPtr_t)SWIG_Python_ConvertPtr,
-    (p_SWIG_Python_ConvertPacked_t)SWIG_Python_ConvertPacked,
-    (p_SWIG_Python_PackData_t)SWIG_Python_PackData,
-    (p_SWIG_Python_UnpackData_t)SWIG_Python_UnpackData,
-    (p_SWIG_Python_NewPointerObj_t)SWIG_Python_NewPointerObj,
-    (p_SWIG_Python_NewPackedObj_t)SWIG_Python_NewPackedObj,
-    (p_SWIG_Python_InstallConstants_t)SWIG_Python_InstallConstants,
-    (p_SWIG_Python_MustGetPtr_t)SWIG_Python_MustGetPtr,
-
     wxPyCheckSwigType,
     wxPyConstructObject,
     wxPyConvertSwigPtr,
@@ -205,7 +239,8 @@ static wxPyCoreAPI API = {
     wxPyOORClientData_dtor,
                                              
     wxPyCBInputStream_create,
-
+    wxPyCBInputStream_copy,
+    
     wxPyInstance_Check,
     wxPySwigInstance_Check,