From: <bh...@us...> - 2008-05-06 16:17:10
|
Revision: 10422 http://swig.svn.sourceforge.net/swig/?rev=10422&view=rev Author: bhy Date: 2008-05-06 09:04:55 -0700 (Tue, 06 May 2008) Log Message: ----------- Solving PyInstance_NewRaw() Modified Paths: -------------- branches/gsoc2008-bhy/Lib/python/pyhead.swg branches/gsoc2008-bhy/Lib/python/pyrun.swg Modified: branches/gsoc2008-bhy/Lib/python/pyhead.swg =================================================================== --- branches/gsoc2008-bhy/Lib/python/pyhead.swg 2008-05-05 17:00:21 UTC (rev 10421) +++ branches/gsoc2008-bhy/Lib/python/pyhead.swg 2008-05-06 16:04:55 UTC (rev 10422) @@ -8,18 +8,42 @@ #define PyInt_FromLong(x) PyLong_FromLong(x) #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) - -PyObject* PyInstance_NewRaw(PyObject *cls, PyObject *dict) +/* +PyObject* PyInstance_NewRaw(PyObject *klass, PyObject *dict) { - PyObject* obj = ((PyTypeObject *)cls)->tp_alloc((PyTypeObject *)cls, 0); - PyObject** dict_ptr = _PyObject_GetDictPtr(obj); - Py_DECREF(*dict_ptr); - Py_INCREF(dict); - *dict_ptr = dict; - printf("PyInstance_NewRaw calling...\n"); - return obj; + PyTypeObject *inst; + printf("Entering PyInstance_NewRaw...\n"); + if (!PyClass_Check(klass)) { + PyErr_BadInternalCall(); + return NULL; + } + if (dict == NULL) { + dict = PyDict_New(); + if (dict == NULL) + return NULL; + } + else { + if (!PyDict_Check(dict)) { + PyErr_BadInternalCall(); + return NULL; + } + Py_INCREF(dict); + } + inst = PyObject_GC_New(PyTypeObject,(PyTypeObject*)klass);// PyBaseObject_Type); + if (inst == NULL) { + Py_DECREF(dict); + return NULL; + } + //inst->tp_weaklist = NULL; + Py_INCREF(klass); + //inst->in_class = (PyClassObject *)klass; + Py_TYPE(inst)->tp_dict = dict; + //Py_TYPE(inst) = (PyTypeObject *)klass; + _PyObject_GC_TRACK(inst); + printf("PyInstance_NewRaw calling succ...\n"); + return (PyObject *)inst; } - +*/ #endif /* Add PyOS_snprintf for old Pythons */ Modified: branches/gsoc2008-bhy/Lib/python/pyrun.swg =================================================================== --- branches/gsoc2008-bhy/Lib/python/pyrun.swg 2008-05-05 17:00:21 UTC (rev 10421) +++ branches/gsoc2008-bhy/Lib/python/pyrun.swg 2008-05-06 16:04:55 UTC (rev 10422) @@ -1010,7 +1010,13 @@ } } #else +//#if PY_VERSION_HEX >= 0x03000000 + //printf("TRYING GET THIS FROM: %s\n", Py_TYPE(pyobj)->tp_name); +// obj = PyDict_GetItem(Py_TYPE(pyobj)->tp_dict, SWIG_This()); + //if(obj) printf("%s\n", Py_TYPE(obj)->tp_name); +//#else obj = PyObject_GetAttr(pyobj,SWIG_This()); +//#endif if (obj) { Py_DECREF(obj); } else { @@ -1215,10 +1221,17 @@ #endif } } else { +#if PY_VERSION_HEX >= 0x03000000 + inst = PyObject_New(PyObject, (PyTypeObject*) data->newargs); + //PyObject_SetAttr(inst, SWIG_This(), swig_this); + PyDict_SetItem(Py_TYPE(inst)->tp_dict, SWIG_This(), swig_this); + +#else PyObject *dict = PyDict_New(); PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); +#endif } return inst; #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |