add addModule() macro helper to the python interface of Application

This commit is contained in:
jriegel 2013-06-09 16:24:07 +02:00
parent 8735f4b8a6
commit e189c0b336
2 changed files with 13 additions and 0 deletions

View File

@ -232,6 +232,7 @@ public:
PYFUNCDEF_S(sGetDocument); PYFUNCDEF_S(sGetDocument);
PYFUNCDEF_S(sDoCommand); PYFUNCDEF_S(sDoCommand);
PYFUNCDEF_S(sAddModule);
static PyMethodDef Methods[]; static PyMethodDef Methods[];

View File

@ -131,6 +131,9 @@ PyMethodDef Application::Methods[] = {
{"doCommand", (PyCFunction) Application::sDoCommand, 1, {"doCommand", (PyCFunction) Application::sDoCommand, 1,
"doCommand(string) -> None\n\n" "doCommand(string) -> None\n\n"
"Prints the given string in the python console and runs it"}, "Prints the given string in the python console and runs it"},
{"addModule", (PyCFunction) Application::sAddModule, 1,
"addModule(string) -> None\n\n"
"Prints the given module import only once in the macro recording"},
{NULL, NULL} /* Sentinel */ {NULL, NULL} /* Sentinel */
}; };
@ -795,3 +798,12 @@ PyObject* Application::sDoCommand(PyObject * /*self*/, PyObject *args,PyObject *
Command::doCommand(Command::Doc,pstr); Command::doCommand(Command::Doc,pstr);
return Py_None; return Py_None;
} }
PyObject* Application::sAddModule(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
char *pstr=0;
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
return NULL; // NULL triggers exception
Command::addModule(Command::Doc,pstr);
return Py_None;
}