summaryrefslogtreecommitdiff
path: root/efl/eo
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2013-04-04 11:28:09 +0000
committerKai Huuhko <kai.huuhko@gmail.com>2013-04-04 11:31:24 +0000
commitf1972f6a6e49a9d81e0c5211472e8cc5cbc9a110 (patch)
tree4a0313785f8ca22f0afff26c1a1eb2ebc39e97c3 /efl/eo
parent7c6afeb25f5e8a434e5e37cbdd823d38277547bf (diff)
Place the remnants of _cfruni and _fruni under six feet of soil.
Fix a braino in the py list to string array conversion function.
Diffstat (limited to 'efl/eo')
-rw-r--r--efl/eo/efl.eo.pyx60
1 files changed, 4 insertions, 56 deletions
diff --git a/efl/eo/efl.eo.pyx b/efl/eo/efl.eo.pyx
index 50a4d5b..81ecbb4 100644
--- a/efl/eo/efl.eo.pyx
+++ b/efl/eo/efl.eo.pyx
@@ -69,58 +69,6 @@ cdef unicode _ctouni(const_char *s):
69 return s.decode('UTF-8', 'strict') if s else None 69 return s.decode('UTF-8', 'strict') if s else None
70 70
71 71
72cdef char *_fruni(object s):
73 """
74
75 Converts a python string object to a char *
76
77 """
78 cdef:
79 char *c_string
80 bytes string
81 unicode unistr
82
83 if s is None:
84 return NULL
85
86 if isinstance(s, unicode):
87 unistr = s
88 string = unistr.encode('UTF-8')
89 c_string = string
90 return c_string
91 elif isinstance(s, str):
92 c_string = s
93 return c_string
94 else:
95 raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
96
97
98cdef const_char *_cfruni(object s):
99 """
100
101 Converts a python string object to a const_char *
102
103 """
104 cdef:
105 const_char *c_string
106 bytes string
107 unicode unistr
108
109 if s is None:
110 return NULL
111
112 if isinstance(s, unicode):
113 unistr = s
114 string = unistr.encode('UTF-8')
115 c_string = string
116 return c_string
117 elif isinstance(s, str):
118 c_string = s
119 return c_string
120 else:
121 raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
122
123
124cdef list convert_array_of_strings_to_python_list(char **array, int array_length): 72cdef list convert_array_of_strings_to_python_list(char **array, int array_length):
125 """ 73 """
126 74
@@ -147,10 +95,9 @@ cdef const_char ** convert_python_list_strings_to_array_of_strings(list strings)
147 """ 95 """
148 cdef: 96 cdef:
149 const_char **array = NULL 97 const_char **array = NULL
150 unsigned int arr_len = len(strings)
151 const_char *string 98 const_char *string
152 unsigned int str_len 99 unsigned int str_len, i
153 unsigned int i 100 unsigned int arr_len = len(strings)
154 101
155 # TODO: Should we just return NULL in this case? 102 # TODO: Should we just return NULL in this case?
156 if len(strings) is 0: 103 if len(strings) is 0:
@@ -165,7 +112,8 @@ cdef const_char ** convert_python_list_strings_to_array_of_strings(list strings)
165 raise MemoryError() 112 raise MemoryError()
166 113
167 for i in range(arr_len): 114 for i in range(arr_len):
168 if isinstance(strings[i], unicode): s = strings[i].encode("UTF-8") 115 s = strings[i]
116 if isinstance(s, unicode): s = s.encode("UTF-8")
169 array[i] = <const_char *>strdup(s) 117 array[i] = <const_char *>strdup(s)
170 118
171 return array 119 return array