summaryrefslogtreecommitdiff
path: root/efl/utils
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2014-04-05 03:13:15 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2014-04-05 03:13:15 +0300
commitadf70fa26fcae845b0bc55c6eebcaeafadc4d1c7 (patch)
treec5bf8953e6b6081bb6542eb5372295875151df02 /efl/utils
parent1149c6ed91a5dcb6e23998ba112d9e3d20a5ceb9 (diff)
Remove const hacks
They were a workaround for limitations in Cython <0.18
Diffstat (limited to 'efl/utils')
-rw-r--r--efl/utils/conversions.pyx24
-rw-r--r--efl/utils/logger.pyx11
2 files changed, 17 insertions, 18 deletions
diff --git a/efl/utils/conversions.pyx b/efl/utils/conversions.pyx
index 44eaeec..173768b 100644
--- a/efl/utils/conversions.pyx
+++ b/efl/utils/conversions.pyx
@@ -32,10 +32,10 @@ cdef unicode _touni(char* s):
32 return s.decode('UTF-8', 'strict') if s else None 32 return s.decode('UTF-8', 'strict') if s else None
33 33
34 34
35cdef unicode _ctouni(const_char *s): 35cdef unicode _ctouni(const char *s):
36 """ 36 """
37 37
38 Converts a const_char * to a python string object 38 Converts a const char * to a python string object
39 39
40 """ 40 """
41 return s.decode('UTF-8', 'strict') if s else None 41 return s.decode('UTF-8', 'strict') if s else None
@@ -58,7 +58,7 @@ cdef list array_of_strings_to_python_list(char **array, int array_length):
58 return ret 58 return ret
59 59
60 60
61cdef const_char ** python_list_strings_to_array_of_strings(list strings) except NULL: 61cdef const char ** python_list_strings_to_array_of_strings(list strings) except NULL:
62 """ 62 """
63 63
64 Converts a python list to an array of strings. 64 Converts a python list to an array of strings.
@@ -67,27 +67,27 @@ cdef const_char ** python_list_strings_to_array_of_strings(list strings) except
67 67
68 """ 68 """
69 cdef: 69 cdef:
70 const_char **array = NULL 70 const char **array = NULL
71 const_char *string 71 const char *string
72 unsigned int str_len, i 72 unsigned int str_len, i
73 unsigned int arr_len = len(strings) 73 unsigned int arr_len = len(strings)
74 74
75 # TODO: Should we just return NULL in this case? 75 # TODO: Should we just return NULL in this case?
76 if arr_len == 0: 76 if arr_len == 0:
77 array = <const_char **>malloc(sizeof(const_char*)) 77 array = <const char **>malloc(sizeof(const char*))
78 if not array: 78 if not array:
79 raise MemoryError() 79 raise MemoryError()
80 array[0] = NULL 80 array[0] = NULL
81 return array 81 return array
82 82
83 array = <const_char **>malloc(arr_len * sizeof(const_char*)) 83 array = <const char **>malloc(arr_len * sizeof(const char*))
84 if not array: 84 if not array:
85 raise MemoryError() 85 raise MemoryError()
86 86
87 for i in range(arr_len): 87 for i in range(arr_len):
88 s = strings[i] 88 s = strings[i]
89 if isinstance(s, unicode): s = PyUnicode_AsUTF8String(s) 89 if isinstance(s, unicode): s = PyUnicode_AsUTF8String(s)
90 array[i] = <const_char *>strdup(s) 90 array[i] = <const char *>strdup(s)
91 91
92 return array 92 return array
93 93
@@ -135,13 +135,13 @@ cdef int * python_list_ints_to_array_of_ints(list ints) except NULL:
135 135
136 return array 136 return array
137 137
138cdef list eina_list_strings_to_python_list(const_Eina_List *lst): 138cdef list eina_list_strings_to_python_list(const Eina_List *lst):
139 cdef: 139 cdef:
140 const_char *s 140 const char *s
141 list ret = [] 141 list ret = []
142 Eina_List *itr = <Eina_List *>lst 142 Eina_List *itr = <Eina_List *>lst
143 while itr: 143 while itr:
144 s = <const_char *>itr.data 144 s = <const char *>itr.data
145 ret.append(_ctouni(s)) 145 ret.append(_ctouni(s))
146 itr = itr.next 146 itr = itr.next
147 return ret 147 return ret
@@ -155,7 +155,7 @@ cdef Eina_List *python_list_strings_to_eina_list(list strings):
155 return lst 155 return lst
156 156
157 157
158cdef list eina_list_objects_to_python_list(const_Eina_List *lst): 158cdef list eina_list_objects_to_python_list(const Eina_List *lst):
159 cdef list ret = list() 159 cdef list ret = list()
160 while lst: 160 while lst:
161 ret.append(object_from_instance(<cEo *>lst.data)) 161 ret.append(object_from_instance(<cEo *>lst.data))
diff --git a/efl/utils/logger.pyx b/efl/utils/logger.pyx
index 3057c12..11ad1a5 100644
--- a/efl/utils/logger.pyx
+++ b/efl/utils/logger.pyx
@@ -15,8 +15,7 @@
15# You should have received a copy of the GNU Lesser General Public License 15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>. 16# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
17 17
18from libc.string cimport const_char 18from efl.eina cimport Eina_Log_Domain, Eina_Log_Level, \
19from efl.eina cimport Eina_Log_Domain, const_Eina_Log_Domain, Eina_Log_Level, \
20 eina_log_print_cb_set, eina_log_domain_register, eina_log_level_set, \ 19 eina_log_print_cb_set, eina_log_domain_register, eina_log_level_set, \
21 eina_log_level_get, eina_log_domain_level_get, eina_log_domain_level_set, \ 20 eina_log_level_get, eina_log_domain_level_get, eina_log_domain_level_set, \
22 eina_log_print, EINA_LOG_DOM_DBG, EINA_LOG_DOM_INFO, EINA_LOG_DOM_WARN, \ 21 eina_log_print, EINA_LOG_DOM_DBG, EINA_LOG_DOM_INFO, EINA_LOG_DOM_WARN, \
@@ -31,7 +30,7 @@ cdef extern from "stdarg.h":
31 pass 30 pass
32 31
33cdef extern from "stdio.h": 32cdef extern from "stdio.h":
34 int vsprintf(char *, const_char *fmt, va_list args) 33 int vsprintf(char *, const char *fmt, va_list args)
35 34
36cdef extern from "Python.h": 35cdef extern from "Python.h":
37 void PyEval_InitThreads() 36 void PyEval_InitThreads()
@@ -51,9 +50,9 @@ cdef char log_buf[1024]
51 50
52PyEval_InitThreads() 51PyEval_InitThreads()
53 52
54cdef void py_eina_log_print_cb(const_Eina_Log_Domain *d, Eina_Log_Level level, 53cdef void py_eina_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level,
55 const_char *file, const_char *fnc, int line, 54 const char *file, const char *fnc, int line,
56 const_char *fmt, void *data, va_list args) with gil: 55 const char *fmt, void *data, va_list args) with gil:
57 56
58 cdef: 57 cdef:
59 unicode msg, name 58 unicode msg, name