|
PLearn 0.1
|
#include <PythonObjectWrapper.h>
Static Public Member Functions | |
| static VMField | convert (PyObject *, bool print_traceback) |
Definition at line 469 of file PythonObjectWrapper.h.
| VMField PLearn::ConvertFromPyObject< VMField >::convert | ( | PyObject * | pyobj, |
| bool | print_traceback | ||
| ) | [static] |
Definition at line 382 of file PythonObjectWrapper.cc.
References PLASSERT, and PLearn::PLPythonConversionError().
{
PLASSERT(pyobj);
PyObject* py_name = PyObject_GetAttrString(pyobj, const_cast<char*>("name"));
if (!py_name)
PLPythonConversionError("ConvertFromPyObject<VMField>: not a VMField (no 'name' attr.)",
pyobj, print_traceback);
string name = ConvertFromPyObject<string>::convert(py_name, print_traceback);
Py_DECREF(py_name);
PyObject* py_fieldtype = PyObject_GetAttrString(pyobj, const_cast<char*>("fieldtype"));
if(!py_fieldtype)
PLPythonConversionError("ConvertFromPyObject<VMField>: not a VMField (no 'fieldtype' attr.)",
pyobj, print_traceback);
VMField::FieldType fieldtype = (VMField::FieldType)ConvertFromPyObject<int>::convert(py_fieldtype, print_traceback);
Py_DECREF(py_fieldtype);
return VMField(name, fieldtype);
}

1.7.4