On 26 June 2012 20:01, David Malcolm <dmalcolm(a)redhat.com> wrote:
On Tue, 2012-06-26 at 18:44 +0100, Philip Herron wrote:
> Hey
>
> I just been needing to get access to certain attributes of functions
> like DECL_EXTERNAL or DECL_STATIC etc would e quite nice to have. And
> i see i add in:
>
> // generate-tree-c.py
>
> add_simple_getter('external',
>
> 'gcc_python_make_wrapper_tree(DECL_EXTERNAL(self->t))',
> "The decl_external value")
>
> But these attributes return an unsigned char:1 so just a simple True
> and False. I dont know what function i should be using to wrap a
> simple value for this i feel quite lost in the code.
PyBool_FromLong() will give you a new reference to Python's True or
False boolean singleton as appropriate:
http://docs.python.org/c-api/bool.html#PyBool_FromLong
so if you pass in your C value to it you should get the required python
value.
Thanks for the help was finding it a little difficult to see what to
code between generated code etc.
--Phil