add -fastquery and fix SWIG_Python_GetSwigThis, avoid to call GetAttr

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8963 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2006-03-05 06:43:16 +00:00
commit e914e7dd6a
3 changed files with 92 additions and 26 deletions

View file

@ -236,7 +236,6 @@ SWIG_Py_Void(void)
return none;
}
/* PySwigClientData */
typedef struct {
@ -921,14 +920,13 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
if (dictptr != NULL) {
PyObject *dict = *dictptr;
obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
}
} else {
#ifdef PyWeakref_CheckProxy
else if (PyWeakref_CheckProxy(pyobj)) {
PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
}
if (PyWeakref_CheckProxy(pyobj)) {
PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
}
#endif
if (!obj) {
obj = PyObject_GetAttr(pyobj,SWIG_This());
if (obj) {
Py_DECREF(obj);
@ -956,7 +954,6 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
}
}
/* Acquire a pointer value */
SWIGRUNTIME int
@ -1325,6 +1322,29 @@ SWIG_Python_SetModule(swig_module_info *swig_module) {
}
}
/* The python cached type query */
SWIGRUNTIME swig_type_info *
SWIG_Python_TypeQuery(const char *type)
{
static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
PyObject *key = PyString_FromString(type);
PyObject *obj = PyDict_GetItem(cache, key);
swig_type_info *descriptor;
if (obj) {
descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
} else {
swig_module_info *swig_module = SWIG_Python_GetModule();
descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
if (descriptor) {
obj = PyCObject_FromVoidPtr(descriptor, NULL);
PyDict_SetItem(cache, key, obj);
Py_DECREF(obj);
}
}
Py_DECREF(key);
return descriptor;
}
/*
For backward compatibility only