Skip to content

Commit

Permalink
First attempt at autogenerating a family of CPython classes for the v…
Browse files Browse the repository at this point in the history
…arious tree nodes
  • Loading branch information
davidmalcolm committed Apr 20, 2011
1 parent 8e26204 commit 9b51459
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 68 deletions.
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -30,6 +30,9 @@ optpass.c: optpass.pyx
tree.c: tree.pyx
cython $^ -o $@

tree.pyx: tree.pyx.in
cpp $(CFLAGS) $^ -o $@

# Hint for debugging: add -v to the gcc options
# to get a command line for invoking individual subprocesses
# Doing so seems to require that paths be absolute, rather than relative
Expand Down
68 changes: 0 additions & 68 deletions tree.pyx

This file was deleted.

46 changes: 46 additions & 0 deletions tree.pyx.in
@@ -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

0 comments on commit 9b51459

Please sign in to comment.