File tree Expand file tree Collapse file tree 1 file changed +35
-4
lines changed Expand file tree Collapse file tree 1 file changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,14 @@ def convert_type_to_ctype(arg):
232232 return ctypes .c_int16
233233 elif arg == i8 :
234234 return ctypes .c_int8
235+ elif arg == u64 :
236+ return ctypes .c_uint64
237+ elif arg == u32 :
238+ return ctypes .c_uint32
239+ elif arg == u16 :
240+ return ctypes .c_uint16
241+ elif arg == u8 :
242+ return ctypes .c_uint8
235243 elif arg == CPtr :
236244 return ctypes .c_void_p
237245 elif arg == str :
@@ -264,11 +272,16 @@ def convert_numpy_dtype_to_ctype(arg):
264272 return ctypes .c_int32
265273 elif arg == np .int16 :
266274 return ctypes .c_int16
267- elif arg == np .uint16 :
268- # TODO: once LPython supports unsigned, change this to unsigned:
269- return ctypes .c_int16
270275 elif arg == np .int8 :
271276 return ctypes .c_int8
277+ elif arg == np .uint64 :
278+ return ctypes .c_uint64
279+ elif arg == np .uint32 :
280+ return ctypes .c_uint32
281+ elif arg == np .uint16 :
282+ return ctypes .c_uint16
283+ elif arg == np .uint8 :
284+ return ctypes .c_uint8
272285 elif arg == np .void :
273286 return ctypes .c_void_p
274287 elif arg is None :
@@ -431,12 +444,30 @@ def pointer(x, type_=None):
431444 if isinstance (x , ndarray ):
432445 return x .ctypes .data_as (ctypes .POINTER (convert_numpy_dtype_to_ctype (x .dtype )))
433446 else :
434- if type_ == i32 :
447+ if type_ == i8 :
448+ return ctypes .cast (ctypes .pointer (ctypes .c_int8 (x )),
449+ ctypes .c_void_p )
450+ elif type_ == i16 :
451+ return ctypes .cast (ctypes .pointer (ctypes .c_int16 (x )),
452+ ctypes .c_void_p )
453+ elif type_ == i32 :
435454 return ctypes .cast (ctypes .pointer (ctypes .c_int32 (x )),
436455 ctypes .c_void_p )
437456 elif type_ == i64 :
438457 return ctypes .cast (ctypes .pointer (ctypes .c_int64 (x )),
439458 ctypes .c_void_p )
459+ elif type_ == u8 :
460+ return ctypes .cast (ctypes .pointer (ctypes .c_uint8 (x )),
461+ ctypes .c_void_p )
462+ elif type_ == u16 :
463+ return ctypes .cast (ctypes .pointer (ctypes .c_uint16 (x )),
464+ ctypes .c_void_p )
465+ elif type_ == u32 :
466+ return ctypes .cast (ctypes .pointer (ctypes .c_uint32 (x )),
467+ ctypes .c_void_p )
468+ elif type_ == u64 :
469+ return ctypes .cast (ctypes .pointer (ctypes .c_uint64 (x )),
470+ ctypes .c_void_p )
440471 elif type_ == f32 :
441472 return ctypes .cast (ctypes .pointer (ctypes .c_float (x )),
442473 ctypes .c_void_p )
You can’t perform that action at this time.
0 commit comments