Skip to content

Commit 5caf385

Browse files
author
Yihao Wu
committed
Add stub for types
There are times we want to know where the structure is defined or sth. Signed-off-by: Yihao Wu <[email protected]>
1 parent e9b9384 commit 5caf385

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

gcc-python-tree.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,11 @@ PyGcc_GetMethods(struct PyGccTree *self)
11031103
#endif
11041104
}
11051105

1106+
PyObject * PyGcc_GetStubDecl(struct PyGccTree *self)
1107+
{
1108+
return PyGccTree_New(gcc_private_make_tree(TYPE_STUB_DECL(self->t.inner)));
1109+
}
1110+
11061111
/*
11071112
GCC's debug_tree is implemented in:
11081113
gcc/print-tree.c

gcc-python-wrappers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ PyGcc_GetFields(struct PyGccTree *self);
355355
PyObject *
356356
PyGcc_GetMethods(struct PyGccTree *self);
357357

358+
PyObject *
359+
PyGcc_GetStubDecl(struct PyGccTree *self);
360+
358361
/* gcc-python-gimple.c: */
359362
extern gcc_gimple_asm
360363
PyGccGimple_as_gcc_gimple_asm(struct PyGccGimple *self);

generate-tree-c.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,17 @@ def add_complex_getter(name, doc):
484484
add_simple_getter('methods',
485485
'PyGcc_GetMethods(self)',
486486
"The methods of this type")
487+
add_simple_getter('stub',
488+
'PyGcc_GetStubDecl(self)',
489+
"The stub decl of this type")
487490

488491
if tree_type.SYM == 'ENUMERAL_TYPE':
489492
add_simple_getter('values',
490493
'PyGcc_TreeMakeListOfPairsFromTreeListChain(TYPE_VALUES(self->t.inner))',
491494
"The values of this type")
495+
add_simple_getter('stub',
496+
'PyGcc_GetStubDecl(self)',
497+
"The stub decl of this type")
492498

493499
if tree_type.SYM == 'IDENTIFIER_NODE':
494500
add_simple_getter('name',

0 commit comments

Comments
 (0)