mirror of
https://github.com/boostorg/build.git
synced 2026-02-13 12:22:17 +00:00
New bjam.variable function exposed to Python.
[SVN r39876]
This commit is contained in:
@@ -1744,6 +1744,30 @@ bjam_define_action(PyObject* self, PyObject *args)
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
/* Returns the value of a variable in root Jam module. */
|
||||
PyObject*
|
||||
bjam_variable(PyObject* self, PyObject* args)
|
||||
{
|
||||
char *name;
|
||||
LIST* value;
|
||||
PyObject *result;
|
||||
int i;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", &name))
|
||||
return NULL;
|
||||
|
||||
enter_module(root_module());
|
||||
value = var_get(name);
|
||||
exit_module(root_module());
|
||||
|
||||
result = PyList_New(list_length(value));
|
||||
for (i = 0; value; value = list_next(value), ++i)
|
||||
PyList_SetItem(result, i, PyString_FromString(value->string));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POPEN
|
||||
|
||||
@@ -209,6 +209,9 @@ static void run_unit_tests()
|
||||
|
||||
extern PyObject*
|
||||
bjam_define_action(PyObject* self, PyObject* args);
|
||||
|
||||
extern PyObject*
|
||||
bjam_variable(PyObject* self, PyObject* args);
|
||||
#endif
|
||||
|
||||
int main( int argc, char **argv, char **arg_environ )
|
||||
@@ -344,6 +347,8 @@ int main( int argc, char **argv, char **arg_environ )
|
||||
"Imports Python callable to bjam."},
|
||||
{"define_action", bjam_define_action, METH_VARARGS,
|
||||
"Defines a command line action."},
|
||||
{"variable", bjam_variable, METH_VARARGS,
|
||||
"Obtains a variable from bjam's global module."},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user