Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Record and Enumeral Types #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion gcc-python-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,14 @@ PyGccFunction_TypeObj_get_argument_types(struct PyGccTree * self, void *closure)
}

/* "size" should now be the length of the chain */

/* When a function with no input arguments is passed ( ex int foo())
the previous code crashed. */
if(size == 0)
size = 1;

/* The last element in the list is a VOID_TYPE; don't add this;
see dump_function_declaration() in gcc/tree-pretty-print.c */
assert(size>0);
size--;

result = PyTuple_New(size);
Expand Down
18 changes: 17 additions & 1 deletion generate-tree-c.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,29 @@ def add_complex_getter(name, doc):
'PyGccTree_New(gcc_private_make_tree(TREE_OPERAND(self->t.inner, 2)))',
"The position of the first referenced bit, as a gcc.IntegerCst")

if tree_type.SYM in ('RECORD_TYPE', 'UNION_TYPE', 'QUAL_UNION_TYPE'):
if tree_type.SYM in ( 'UNION_TYPE', 'QUAL_UNION_TYPE'):
add_simple_getter('fields',
'PyGcc_TreeListFromChain(TYPE_FIELDS(self->t.inner))',
"The fields of this type")
add_simple_getter('methods',
'PyGcc_TreeListFromChain(TYPE_METHODS(self->t.inner))',
"The methods of this type")

if tree_type.SYM in ('RECORD_TYPE'):
add_simple_getter('fields',
'PyGcc_TreeListFromChain(TYPE_FIELDS(self->t.inner))',
"The fields of this type")
add_simple_getter('methods',
'PyGcc_TreeListFromChain(TYPE_METHODS(self->t.inner))',
"The methods of this type")
add_simple_getter('context',
'PyGcc_TreeListFromChain(TYPE_CONTEXT(self->t.inner))',
"The context of this type")

if tree_type.SYM == 'ENUMERAL_TYPE':
add_simple_getter('values',
'PyGcc_TreeListFromChain(TYPE_VALUES(self->t.inner))',
"The values of this type")

if tree_type.SYM == 'IDENTIFIER_NODE':
add_simple_getter('name',
Expand Down