Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/elliotchance/c2go into as…
Browse files Browse the repository at this point in the history
…t2json

# Conflicts:
#	c2go.py
  • Loading branch information
elliotchance committed Mar 25, 2017
2 parents d041597 + 472f2ad commit d77e673
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions c2go.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import pprint
import re
import subprocess
import StringIO
import json

try:
import StringIO as io
except ImportError:
import io

function_defs = {
'__istype': ('uint32', ('__darwin_ct_rune_t', 'uint32')),
'__isctype': ('__darwin_ct_rune_t', ('__darwin_ct_rune_t', 'uint32')),
Expand Down Expand Up @@ -485,7 +492,7 @@ def render(out, node, indent=0, return_type=None):
pp = subprocess.Popen(["clang", "-E", c_file_path], stdout=subprocess.PIPE).communicate()[0]

pp_file_path = 'pp.c'
with open(pp_file_path, 'w') as pp_out:
with open(pp_file_path, 'wb') as pp_out:
pp_out.write(pp)

# 3. Generate JSON from AST
Expand All @@ -503,7 +510,7 @@ def render(out, node, indent=0, return_type=None):

go_file_path = '%s.go' % c_file_path.split('/')[-1][:-2]
# go_out = sys.stdout
go_out = StringIO.StringIO()
go_out = io.StringIO()
#with open(go_file_path, 'w') as go_out:
# print_line(go_out, "package main\n", 0)
#print_line(go_out, 'import ("fmt"; "os")\n', 0)
Expand Down

0 comments on commit d77e673

Please sign in to comment.