This exposes the GCC 'inform' function as gcc.inform.
Tom
diff --git a/docs/basics.rst b/docs/basics.rst index d51947b..2c9b344 100644 --- a/docs/basics.rst +++ b/docs/basics.rst @@ -429,6 +429,25 @@ Generating custom errors and warnings
Returns True if the warning was actually printed, False otherwise
+.. py:function:: gcc.inform(loc, str) + + This is a wrapper around GCC's `inform` function. + + Expects an instance of :py:class:`gcc.Location` (not None) and a string + + Emit an informational message at that location. + + For example:: + + gcc.inform(stmt.loc, 'this is where X was defined') + + would lead to this informational message being printed: + + .. code-block:: bash + + $ ./gcc-with-python script.py input.c + input.c:23:3: note: this is where X was defined + Global data access ==================
diff --git a/gcc-python.c b/gcc-python.c index 4e35456..79262ab 100644 --- a/gcc-python.c +++ b/gcc-python.c @@ -373,6 +373,27 @@ gcc_python_warning(PyObject *self, PyObject *args, PyObject *kwargs) }
static PyObject * +gcc_python_inform(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyGccLocation *loc_obj; + const char *msg; + char *keywords[] = {"location", + "message", + NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O!s:inform", keywords, + &gcc_LocationType, &loc_obj, + &msg)) { + return NULL; + } + + inform(loc_obj->loc, "%s", msg); + + Py_RETURN_NONE; +} + +static PyObject * gcc_python_get_option_list(PyObject *self, PyObject *args) { PyObject *result; @@ -533,6 +554,11 @@ static PyMethodDef GccMethods[] = { (METH_VARARGS | METH_KEYWORDS), ("Report a warning\n" "FIXME\n")}, + {"inform", + (PyCFunction)gcc_python_inform, + (METH_VARARGS | METH_KEYWORDS), + ("Report an information message\n" + "FIXME\n")},
/* Options: */ {"get_option_list",
On Thu, 2011-06-30 at 11:51 -0600, Tom Tromey wrote:
This exposes the GCC 'inform' function as gcc.inform.
Looks good.
I pushed this as: http://git.fedorahosted.org/git?p=gcc-python-plugin.git;a=commit;h=9ca8982eb...
and added test coverage for it (to an existing test) here: http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=commit;h=d3ef6775...
I also tweaked the docs to make it clear that the output goes to stderr (this surprised me at first).
Thanks Dave
David> and added test coverage for it (to an existing test) here: David> http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=commit;h=d3ef6775...
Thanks. I will write test patches in the future.
Tom
gcc-python-plugin@lists.stg.fedorahosted.org