PLearn 0.1
Static Public Member Functions
PLearn::ConvertFromPyObject< Object * > Struct Template Reference

#include <PythonObjectWrapper.h>

List of all members.

Static Public Member Functions

static Objectconvert (PyObject *, bool print_traceback)

Detailed Description

template<>
struct PLearn::ConvertFromPyObject< Object * >

Definition at line 334 of file PythonObjectWrapper.h.


Member Function Documentation

Object * PLearn::ConvertFromPyObject< Object * >::convert ( PyObject *  pyobj,
bool  print_traceback 
) [static]

Definition at line 196 of file PythonObjectWrapper.cc.

References PLASSERT, PLERROR, and PLearn::PLPythonConversionError().

{
//     DBG_MODULE_LOG << "ConvertFromPyObject<Object*>::convert("
//                    << (void*)pyobj << ' ' << PythonObjectWrapper(pyobj)
//                    << ')' << endl;
    PLASSERT(pyobj);
    if(pyobj == Py_None)
        return 0;

    if(!PyObject_HasAttrString(pyobj, const_cast<char*>("_cptr")))
    {
        PLERROR("in ConvertFromPyObject<Object*>::convert : "
                "python object has no attribute '_cptr'");
        return 0;
    }
    PyObject* cptr= PyObject_GetAttrString(pyobj, const_cast<char*>("_cptr"));

    if (! PyCObject_Check(cptr))
        PLPythonConversionError("ConvertFromPyObject<Object*>", pyobj,
                                print_traceback);
    Object* obj= static_cast<Object*>(PyCObject_AsVoidPtr(cptr));

    Py_DECREF(cptr);
//     DBG_MODULE_LOG << "EXITING ConvertFromPyObject<Object*>::convert("
//                    << (void*)pyobj << ' ' << PythonObjectWrapper(pyobj)
//                    << ')' << " => " << (void*)obj << ' ' << obj->asString() << endl;
    return obj;
}

Here is the call graph for this function:


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines