add TypeHandle::make()

This commit is contained in:
David Rose 2009-08-15 00:56:34 +00:00
parent a4f2f54cd4
commit fc74ddace3
2 changed files with 28 additions and 0 deletions

View File

@ -19,6 +19,26 @@
// This is initialized to zero by static initialization.
TypeHandle TypeHandle::_none;
#ifdef HAVE_PYTHON
////////////////////////////////////////////////////////////////////
// Function: TypeHandle::make
// 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).
//
// This method allows a Python class object to be used
// anywhere a TypeHandle is expected by the C++
// interface.
////////////////////////////////////////////////////////////////////
PyObject *TypeHandle::
make(PyObject *classobj) {
return PyObject_CallMethod(classobj, (char *)"getClassType", (char *)"");
}
#endif // HAVE_PYTHON
#ifdef DO_MEMORY_USAGE
////////////////////////////////////////////////////////////////////
// Function: TypeHandle::get_memory_usage

View File

@ -65,6 +65,10 @@
class TypedObject;
#ifdef HAVE_PYTHON
#include "Python.h"
#endif
////////////////////////////////////////////////////////////////////
// Class : TypeHandle
// Description : TypeHandle is the identifier used to differentiate
@ -98,6 +102,10 @@ PUBLISHED:
INLINE TypeHandle();
INLINE TypeHandle(const TypeHandle &copy);
#ifdef HAVE_PYTHON
static PyObject *make(PyObject *classobj);
#endif // HAVE_PYTHON
INLINE bool operator == (const TypeHandle &other) const;
INLINE bool operator != (const TypeHandle &other) const;
INLINE bool operator < (const TypeHandle &other) const;