[gnome-code-assistance] [backends/c] Some more python3 fixes for clang
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-code-assistance] [backends/c] Some more python3 fixes for clang
- Date: Mon, 11 Nov 2013 08:43:47 +0000 (UTC)
commit c5e52feaf531af5c31a65fe14def5023bfce6acd
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Sun Nov 10 16:05:45 2013 +0100
[backends/c] Some more python3 fixes for clang
backends/c/clang/cindex.py | 30 ++++++++++++++++++++++++------
1 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/backends/c/clang/cindex.py b/backends/c/clang/cindex.py
index fae706d..7f647c2 100644
--- a/backends/c/clang/cindex.py
+++ b/backends/c/clang/cindex.py
@@ -1950,22 +1950,28 @@ class TranslationUnit(ClangObject):
for arg in args]
args_array = (c_char_p * len(args))(* args)
- unsaved_array = None
+ unsaved_files_array = 0
if len(unsaved_files) > 0:
- unsaved_array = (_CXUnsavedFile * len(unsaved_files))()
+ unsaved_files_array = (_CXUnsavedFile * len(unsaved_files))()
for i, (name, contents) in enumerate(unsaved_files):
if hasattr(contents, "read"):
contents = contents.read()
- unsaved_array[i].name = name
- unsaved_array[i].contents = contents
- unsaved_array[i].length = len(contents)
+ if isinstance(contents, str):
+ contents = contents.encode('utf-8')
+
+ if isinstance(name, str):
+ name = name.encode('utf-8')
+
+ unsaved_files_array[i].name = name
+ unsaved_files_array[i].contents = contents
+ unsaved_files_array[i].length = len(contents)
if isinstance(filename, str):
filename = filename.encode('utf-8')
ptr = conf.lib.clang_parseTranslationUnit(index, filename, args_array,
- len(args), unsaved_array,
+ len(args), unsaved_files_array,
len(unsaved_files), options)
if ptr is None:
@@ -2138,6 +2144,12 @@ class TranslationUnit(ClangObject):
if hasattr(contents, "read"):
contents = contents.read()
+ if isinstance(contents, str):
+ contents = contents.encode('utf-8')
+
+ if isinstance(name, str):
+ name = name.encode('utf-8')
+
unsaved_files_array[i].name = name
unsaved_files_array[i].contents = contents
unsaved_files_array[i].length = len(contents)
@@ -2199,6 +2211,12 @@ class TranslationUnit(ClangObject):
if hasattr(contents, "read"):
contents = contents.read()
+ if isinstance(contents, str):
+ contents = contents.encode('utf-8')
+
+ if isinstance(name, str):
+ name = name.encode('utf-8')
+
unsaved_files_array[i].name = name
unsaved_files_array[i].contents = contents
unsaved_files_array[i].length = len(contents)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]