|
Boost-Commit : |
From: ghost_at_[hidden]
Date: 2007-10-10 04:25:27
Author: vladimir_prus
Date: 2007-10-10 04:25:27 EDT (Wed, 10 Oct 2007)
New Revision: 39876
URL: http://svn.boost.org/trac/boost/changeset/39876
Log:
New bjam.variable function exposed to Python.
Text files modified:
trunk/tools/jam/src/builtins.c | 24 ++++++++++++++++++++++++
trunk/tools/jam/src/jam.c | 5 +++++
2 files changed, 29 insertions(+), 0 deletions(-)
Modified: trunk/tools/jam/src/builtins.c
==============================================================================
--- trunk/tools/jam/src/builtins.c (original)
+++ trunk/tools/jam/src/builtins.c 2007-10-10 04:25:27 EDT (Wed, 10 Oct 2007)
@@ -1744,6 +1744,30 @@
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
Modified: trunk/tools/jam/src/jam.c
==============================================================================
--- trunk/tools/jam/src/jam.c (original)
+++ trunk/tools/jam/src/jam.c 2007-10-10 04:25:27 EDT (Wed, 10 Oct 2007)
@@ -209,6 +209,9 @@
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 @@
"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}
};
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk