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):
232
232
return ctypes .c_int16
233
233
elif arg == i8 :
234
234
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
235
243
elif arg == CPtr :
236
244
return ctypes .c_void_p
237
245
elif arg == str :
@@ -264,11 +272,16 @@ def convert_numpy_dtype_to_ctype(arg):
264
272
return ctypes .c_int32
265
273
elif arg == np .int16 :
266
274
return ctypes .c_int16
267
- elif arg == np .uint16 :
268
- # TODO: once LPython supports unsigned, change this to unsigned:
269
- return ctypes .c_int16
270
275
elif arg == np .int8 :
271
276
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
272
285
elif arg == np .void :
273
286
return ctypes .c_void_p
274
287
elif arg is None :
@@ -431,12 +444,30 @@ def pointer(x, type_=None):
431
444
if isinstance (x , ndarray ):
432
445
return x .ctypes .data_as (ctypes .POINTER (convert_numpy_dtype_to_ctype (x .dtype )))
433
446
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 :
435
454
return ctypes .cast (ctypes .pointer (ctypes .c_int32 (x )),
436
455
ctypes .c_void_p )
437
456
elif type_ == i64 :
438
457
return ctypes .cast (ctypes .pointer (ctypes .c_int64 (x )),
439
458
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 )
440
471
elif type_ == f32 :
441
472
return ctypes .cast (ctypes .pointer (ctypes .c_float (x )),
442
473
ctypes .c_void_p )
You can’t perform that action at this time.
0 commit comments