diff options
author | eli.bendersky <devnull@localhost> | 2011-05-09 18:22:33 +0300 |
---|---|---|
committer | eli.bendersky <devnull@localhost> | 2011-05-09 18:22:33 +0300 |
commit | 6ed80a61c326a580f3192f01d9e531c7bd940efa (patch) | |
tree | 5dd44be8aa8ff6ff494756e1001f8a0204477b6c | |
parent | 15cb2705e4dc5c75d72bff97c2dca3d8b0fd4c22 (diff) | |
download | pycparser-6ed80a61c326a580f3192f01d9e531c7bd940efa.tar.gz |
Issue 33: fix c-to-c.py generation of casts
-rw-r--r-- | examples/c-to-c.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/examples/c-to-c.py b/examples/c-to-c.py index a292c36..fed92aa 100644 --- a/examples/c-to-c.py +++ b/examples/c-to-c.py @@ -116,7 +116,7 @@ class CGenerator(object): return s def visit_Cast(self, n): - s = '(' + self.visit(n.to_type) + ')' + s = '(' + self._generate_type(n.to_type) + ')' return s + ' ' + self.visit(n.expr) def visit_ExprList(self, n): @@ -348,8 +348,10 @@ class CGenerator(object): nstr = '*' + nstr s += ' ' + nstr return s - elif typ in (c_ast.Typename, c_ast.Decl): + elif typ == c_ast.Decl: return self._generate_decl(n.type) + elif typ == c_ast.Typename: + return self._generate_type(n.type) elif typ == c_ast.IdentifierType: return ' '.join(n.names) + ' ' elif typ in (c_ast.ArrayDecl, c_ast.PtrDecl, c_ast.FuncDecl): @@ -389,13 +391,10 @@ def translate_to_c(filename): def zz_test_translate(): # internal use src = r''' - void v(void) - { - int poa = {5, 6}; - int ka = {.ko[4] = 8, [5] = 3}; - joker[2][4]; - **ptr; - } + int main(int** k, float ar[5][2]) { + int a, *b; + b = (int *) a; + } ''' parser = c_parser.CParser() ast = parser.parse(src) @@ -406,6 +405,7 @@ def zz_test_translate(): #------------------------------------------------------------------------------ if __name__ == "__main__": + zz_test_translate() if len(sys.argv) > 1: translate_to_c(sys.argv[1]) else: |