PLearn 0.1
Static Public Member Functions
PLearn::ConvertToPyObject< VMField > Struct Template Reference

#include <PythonObjectWrapper.h>

List of all members.

Static Public Member Functions

static PyObject * newPyObject (const VMField &)

Detailed Description

template<>
struct PLearn::ConvertToPyObject< VMField >

Definition at line 720 of file PythonObjectWrapper.h.


Member Function Documentation

PyObject * PLearn::ConvertToPyObject< VMField >::newPyObject ( const VMField vmf) [static]

Definition at line 941 of file PythonObjectWrapper.cc.

References PLearn::PythonObjectWrapper::as(), PLearn::VMField::fieldtype, PLearn::VMField::name, PLERROR, and PLearn::tostring().

{
    string pycode = "\nfrom plearn.pybridge.wrapped_plearn_object import VMField\n";
    pycode += string("\nresult = VMField(name='") + vmf.name + "', " + "fieldtype=" + tostring(vmf.fieldtype) + ")\n";

    PyObject* env = PyDict_New();
    if (0 != PyDict_SetItemString(env, "__builtins__", PyEval_GetBuiltins()))
        PLERROR("In ConvertToPyObject<VMField>::newPyObject : cannot insert builtins in env.");
    PyObject* res = PyRun_String(pycode.c_str(), Py_file_input, env, env);
    if (!res)
    {
        Py_DECREF(env);
        if (PyErr_Occurred()) PyErr_Print();
        PLERROR("In ConvertToPyObject<VMField>::newPyObject : cannot convert to a VMField.");
    }
    Py_DECREF(res);
    PyObject* py_vmf = PythonObjectWrapper(env).as<std::map<string, PyObject*> >()["result"];
    Py_INCREF(py_vmf);
    Py_DECREF(env);
    return py_vmf;
}

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