29
29
30
30
# -----------------------------------------
31
31
32
- def evaluate_c_type_string_to_ctype_type (c_type_string ):
33
- cStringToCtypesString = {
32
+ def evaluate_c_type_string_to_ctypes_type (c_type_string ):
33
+ c_string_to_ctypes_string = {
34
34
'bool' : ctypes .c_bool , # C type: _Bool Python type: bool (1)
35
35
'char' : ctypes .c_char , # C type: char Python type: 1-character bytes object
36
36
'wchar_t' : ctypes .c_wchar , # C type: wchar_t Python type: 1-character string
@@ -68,11 +68,11 @@ def evaluate_c_type_string_to_ctype_type(c_type_string):
68
68
array_size = int (c_type_string .split ('[' )[1 ][:- 1 ])
69
69
type_of_array_without_pointers_string = type_of_array_string .replace ('*' , '' )
70
70
71
- if type_of_array_string in cStringToCtypesString : # basic type pointer (int*, char*, float*, ...)
72
- return cStringToCtypesString [type_of_array_string ] * array_size
71
+ if type_of_array_string in c_string_to_ctypes_string : # basic type pointer (int*, char*, float*, ...)
72
+ return c_string_to_ctypes_string [type_of_array_string ] * array_size
73
73
74
- if type_of_array_without_pointers_string in cStringToCtypesString : # basic type pointer(probably double+ pointer level) (int**, char**, float**, ...)
75
- type_of_array_end = cStringToCtypesString [type_of_array_without_pointers_string ]
74
+ if type_of_array_without_pointers_string in c_string_to_ctypes_string : # basic type pointer(probably double+ pointer level) (int**, char**, float**, ...)
75
+ type_of_array_end = c_string_to_ctypes_string [type_of_array_without_pointers_string ]
76
76
for i in range (pointer_level ):
77
77
type_of_array_end = ctypes .POINTER (type_of_array_end )
78
78
return type_of_array_end * array_size
@@ -89,22 +89,22 @@ def evaluate_c_type_string_to_ctype_type(c_type_string):
89
89
type_of_array_string = c_type_string .split ('[' )[0 ]
90
90
array_size = int (c_type_string .split ('[' )[1 ][:- 1 ])
91
91
92
- if type_of_array_string in cStringToCtypesString : # basic type array (int, char, float, ...)
93
- return cStringToCtypesString [type_of_array_string ] * array_size
92
+ if type_of_array_string in c_string_to_ctypes_string : # basic type array (int, char, float, ...)
93
+ return c_string_to_ctypes_string [type_of_array_string ] * array_size
94
94
95
95
if type_of_array_string in raypyc .structures .__structs : # a struct array
96
96
return raypyc .structures .__structs [type_of_array_string ] * array_size
97
97
98
98
raise TypeError (f"can wrapped this string, the string: { c_type_string } " )
99
99
100
100
elif pointer_level > 0 :
101
- if c_type_string in cStringToCtypesString : # basic type pointer (int**, char*, float*, ...)
102
- return cStringToCtypesString [c_type_string ]
101
+ if c_type_string in c_string_to_ctypes_string : # basic type pointer (int**, char*, float*, ...)
102
+ return c_string_to_ctypes_string [c_type_string ]
103
103
104
104
type_without_pointers_string = c_type_string .replace ('*' , '' )
105
105
106
- if type_without_pointers_string in cStringToCtypesString : # basic type pointer(probably double+ pointer level) (int**, char**, float**, ...)
107
- type_of_pointer_end = cStringToCtypesString [type_without_pointers_string ]
106
+ if type_without_pointers_string in c_string_to_ctypes_string : # basic type pointer(probably double+ pointer level) (int**, char**, float**, ...)
107
+ type_of_pointer_end = c_string_to_ctypes_string [type_without_pointers_string ]
108
108
for i in range (pointer_level ):
109
109
type_of_pointer_end = ctypes .POINTER (type_of_pointer_end )
110
110
return type_of_pointer_end
@@ -117,8 +117,8 @@ def evaluate_c_type_string_to_ctype_type(c_type_string):
117
117
118
118
raise TypeError (f"can wrapped this string, the string: { c_type_string } " )
119
119
120
- if c_type_string in cStringToCtypesString : # "regular" value not a pointer or an array
121
- return cStringToCtypesString [c_type_string ]
120
+ if c_type_string in c_string_to_ctypes_string : # "regular" value not a pointer or an array
121
+ return c_string_to_ctypes_string [c_type_string ]
122
122
123
123
if c_type_string in raypyc .structures .__structs : # a struct
124
124
return raypyc .structures .__structs [c_type_string ]
@@ -168,7 +168,7 @@ def check_for_functions_that_can_wrap(functions_set):
168
168
function_param_processed = function_param_processed .split ('[' )[0 ]
169
169
170
170
try :
171
- evaluate_c_type_string_to_ctype_type (function_param ["type" ])
171
+ evaluate_c_type_string_to_ctypes_type (function_param ["type" ])
172
172
except :
173
173
do_wrapper_this_function = False
174
174
@@ -182,7 +182,7 @@ def check_for_functions_that_can_wrap(functions_set):
182
182
function_returnType_processed = function_returnType_processed .split ('[' )[0 ]
183
183
184
184
try :
185
- evaluate_c_type_string_to_ctype_type (function ["returnType" ])
185
+ evaluate_c_type_string_to_ctypes_type (function ["returnType" ])
186
186
except :
187
187
do_wrapper_this_function = False
188
188
@@ -208,8 +208,8 @@ def wrap_functions_to_ctypes_functions_add_function_to_this_module(functions_to_
208
208
if 'params' in function_to_wrap .keys ():
209
209
for function_param in function_to_wrap ['params' ]:
210
210
if function_param ['type' ] != "..." :
211
- function_to_wrap_ctype ['parametersTypes' ].append (evaluate_c_type_string_to_ctype_type (function_param ['type' ]))
212
- function_to_wrap_ctype ['returnType' ] = evaluate_c_type_string_to_ctype_type (function_to_wrap ['returnType'<
67E6
/span>])
211
+ function_to_wrap_ctype ['parametersTypes' ].append (evaluate_c_type_string_to_ctypes_type (function_param ['type' ]))
212
+ function_to_wrap_ctype ['returnType' ] = evaluate_c_type_string_to_ctypes_type (function_to_wrap ['returnType' ])
213
213
214
214
f = wrap_function (function_to_wrap_ctype ['name' ], function_to_wrap_ctype ['parametersTypes' ], function_to_wrap_ctype ['returnType' ])
215
215
add_function_to_module (current_module , name_of_function , f )
0 commit comments