mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
use compare_to and get_class_type instead of compareTo and getClassType
This commit is contained in:
parent
088df4a3d2
commit
4944d7cd7b
@ -25,9 +25,9 @@ TypeHandle TypeHandle::_none;
|
||||
// Access: Published
|
||||
// Description: This special method allows coercion to a TypeHandle
|
||||
// from a Python class object or instance. It simply
|
||||
// attempts to call classobj.getClassType(), and returns
|
||||
// that value (or raises an exception if that method
|
||||
// doesn't work).
|
||||
// attempts to call classobj.get_class_type(), and
|
||||
// returns that value (or raises an exception if that
|
||||
// method doesn't work).
|
||||
//
|
||||
// This method allows a Python class object to be used
|
||||
// anywhere a TypeHandle is expected by the C++
|
||||
@ -35,7 +35,7 @@ TypeHandle TypeHandle::_none;
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PyObject *TypeHandle::
|
||||
make(PyObject *classobj) {
|
||||
return PyObject_CallMethod(classobj, (char *)"getClassType", (char *)"");
|
||||
return PyObject_CallMethod(classobj, (char *)"get_class_type", (char *)"");
|
||||
}
|
||||
#endif // HAVE_PYTHON
|
||||
|
||||
|
@ -390,7 +390,7 @@ int DTool_PyInit_Finalize(PyObject *self, void *local_this, Dtool_PyTypedObject
|
||||
// at code generation time because of multiple generation passes in interrogate..
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) {
|
||||
void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) {
|
||||
for (; in->ml_name != NULL; in++) {
|
||||
if (themap.find(in->ml_name) == themap.end()) {
|
||||
themap[in->ml_name] = in;
|
||||
@ -406,7 +406,7 @@ void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) {
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
RegisterRuntimeClass(Dtool_PyTypedObject * otype, int class_id) {
|
||||
RegisterRuntimeClass(Dtool_PyTypedObject *otype, int class_id) {
|
||||
if (class_id == 0) {
|
||||
interrogatedb_cat.warning()
|
||||
<< "Class " << otype->_name
|
||||
@ -546,12 +546,13 @@ PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args) {
|
||||
}
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
inline long DTool_HashKey(PyObject * inst)
|
||||
{
|
||||
long outcome = (long)inst;
|
||||
PyObject * func = PyObject_GetAttrString(inst, "__hash__");
|
||||
PyObject *func = PyObject_GetAttrString(inst, "__hash__");
|
||||
if (func == NULL)
|
||||
{
|
||||
if (DtoolCanThisBeAPandaInstance(inst))
|
||||
@ -592,7 +593,7 @@ inline long DTool_HashKey(PyObject * inst)
|
||||
|
||||
int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2) {
|
||||
// First try compareTo function..
|
||||
PyObject * func = PyObject_GetAttrString(v1, "compareTo");
|
||||
PyObject * func = PyObject_GetAttrString(v1, "compare_to");
|
||||
if (func == NULL) {
|
||||
PyErr_Clear();
|
||||
} else {
|
||||
@ -636,25 +637,28 @@ int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2) {
|
||||
#endif
|
||||
Py_DECREF(res);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// try this compare
|
||||
void *v1_this = DTOOL_Call_GetPointerThis(v1);
|
||||
void *v2_this = DTOOL_Call_GetPointerThis(v2);
|
||||
if (v1_this != NULL && v2_this != NULL) { // both are our types...
|
||||
if (v1_this < v2_this)
|
||||
if (v1_this < v2_this) {
|
||||
return -1;
|
||||
|
||||
if (v1_this > v2_this)
|
||||
}
|
||||
if (v1_this > v2_this) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ok self compare...
|
||||
if (v1 < v2)
|
||||
return -1;
|
||||
if (v1 > v2)
|
||||
return 1;
|
||||
if (v1 < v2) {
|
||||
return -1;
|
||||
}
|
||||
if (v1 > v2) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -716,7 +720,7 @@ PyObject *make_list_for_item(PyObject *self, const char *num_name,
|
||||
// __copy__() method from a C++ make_copy() method.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PyObject *copy_from_make_copy(PyObject *self) {
|
||||
return PyObject_CallMethod(self, (char *)"makeCopy", (char *)"()");
|
||||
return PyObject_CallMethod(self, (char *)"make_copy", (char *)"()");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user