Commits

Anonymous committed 0ee1cfa

more py3/py2 compatibility

Comments (0)

Files changed (2)

pyclang/cindex.py

     fd.flush()
     return
 
-if sys.version_info.major == 2:
+if sys.version_info[0] == 2:
     def _to_cstring(x): 
         return x
 else:
 import pyclang.cindex as clang
 
 def myprint(*args):
-    import sys
-    sys.stderr.write(' '.join(args) + '\n')
+    clang.println(' '.join(str(a) for a in args))
     
 def get_diag_info(diag):
     return { 'severity' : diag.severity,
 from pprint import pprint
 
 index = clang.Index.create()
-tu = index.parse(None, ("t1.h",))
+tu = index.parse(None, ("multi.cxx",))
+#tu = index.parse(None, ("t1.h",))
 #tu = index.parse(None, ("tt.hh",))
 #tu = index.parse(None, ("/usr/include/cblas.h",))
 diags = map(get_diag_info, tu.diagnostics)
 pprint(nodes)
 
 for idx,c in enumerate(my_cursors):
-    myprint("---",idx,c.spelling)
-    myprint("\t\t",c.type.kind,c.type.spelling,c.type.kind.value,c.access_specifier.name)
+    myprint("---",idx,c.spelling,
+            "\n\t\t",c.type.kind,c.type.spelling,c.type.kind.value,c.access_specifier.name)
 
-cc = my_cursors[ 2]
-c0 = my_cursors[ 9]
-c1 = my_cursors[10]
+#cc = my_cursors[ 2]
+#c0 = my_cursors[ 9]
+#c1 = my_cursors[10]
 #c2 = my_cursors[11]
 #print "canonical type:", c2.type.canonical_type.kind