Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First attempt at autogenerating a family of CPython classes for the v…
…arious tree nodes
- Loading branch information
1 parent
8e26204
commit 9b51459
Showing
3 changed files
with
49 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import sys | ||
|
||
cdef extern from "config.h": | ||
pass | ||
|
||
cdef extern from "system.h": | ||
pass | ||
|
||
cdef extern from "coretypes.h": | ||
cdef union tree_node: | ||
pass | ||
ctypedef tree_node *tree | ||
|
||
cdef extern from "tree.h": | ||
pass | ||
|
||
cdef extern from "gcc-python-wrappers.h": | ||
pass | ||
|
||
cdef class Tree: | ||
cdef tree t | ||
|
||
def __init__(self): | ||
self.t = NULL | ||
|
||
cdef __set_ptr(self, tree t): | ||
self.t = t | ||
|
||
cdef __get_ptr(self, tree t): | ||
self.t = t | ||
|
||
def __repr__(self): | ||
return 'tree.Tree(%r)' % 'foo' | ||
|
||
|
||
#define DEFTREECODE(SYM, STRING, TYPE, NARGS) \ | ||
cdef class SYM(Tree): \ | ||
pass | ||
#define END_OF_BASE_TREE_CODES | ||
#include "all-tree.def" | ||
#undef DEFTREECODE | ||
|
||
cdef extern gcc_python_make_wrapper_tree(tree t): | ||
obj = Tree() | ||
obj.__set_ptr(t) | ||
return obj |