add other ctypes_type, add c_float

This commit is contained in:
lyon1998 2022-04-18 14:16:55 +08:00
parent bf50bde599
commit be4caeee45
5 changed files with 68 additions and 19 deletions

View File

@ -1,6 +1,7 @@
#include "ctypes_Test.h"
#include "ctypes_c_uint.h"
#include "ctypes_c_wchar_p.h"
#include "ctypes_c_float.h"
#include "ctypes_utils.h"
void ctypes_c_uint___init__(PikaObj* self, int value) {
@ -11,6 +12,10 @@ void ctypes_c_wchar_p___init__(PikaObj* self, char* value) {
ctypesUtils_setStr(self, value);
}
void ctypes_c_float___init__(PikaObj *self, float value){
ctypesUtils_setFloat(self, value);
}
int ctypes_Test_add(PikaObj* self, PikaObj* c_uint1, PikaObj* c_uint2) {
return ctypesUtils_getInt(c_uint1) + ctypesUtils_getInt(c_uint2);
}

View File

@ -1,16 +1,35 @@
from ctypes import c_byte
from PikaObj import *
class c_uint(TinyObj):
def __init__(self, value:int):
pass
def __init__(self, value:int):...
class c_byte(c_uint):...
class c_ubyte(c_uint):...
class c_short(c_uint):...
class c_int(c_uint):...
class c_long(c_uint):...
class c_ulong(c_uint):...
class c_longlong(c_uint):...
class c_ulonglong(c_uint):...
class c_size_t(c_uint):...
class c_ssize_t(c_uint):...
class c_bool(c_uint):...
class c_float(TinyObj):
def __init__(self, value:float):...
class c_double(c_float):...
class c_longdouble(c_float):...
class c_wchar_p(TinyObj):
def __init__(self, value:str):
pass
def __init__(self, value:str):...
class c_char(c_wchar_p):...
class c_wchar(c_wchar_p):...
class c_char_p(c_wchar_p):...
class Test(TinyObj):
def add(self, c_uint1:c_uint, c_uint2:c_uint)->int:
pass
def dc_cpuapdu_hex(self, slen:int, sendbuf:str, rlen:c_uint, rcvbuf:c_wchar_p) -> int:
pass
def add(self, c_uint1:c_uint, c_uint2:c_uint)->int:...
def dc_cpuapdu_hex(self, slen:int, sendbuf:str, rlen:c_uint, rcvbuf:c_wchar_p) -> int:...

View File

@ -54,7 +54,8 @@
"ctypes.h": "c",
"ctypes_test.h": "c",
"ctypes_c_uint.h": "c",
"ctypes_utils.h": "c"
"ctypes_utils.h": "c",
"ctypes_c_float.h": "c"
},
"python.formatting.provider": "autopep8"
}

View File

@ -1,16 +1,35 @@
from ctypes import c_byte
from PikaObj import *
class c_uint(TinyObj):
def __init__(self, value:int):
pass
def __init__(self, value:int):...
class c_byte(c_uint):...
class c_ubyte(c_uint):...
class c_short(c_uint):...
class c_int(c_uint):...
class c_long(c_uint):...
class c_ulong(c_uint):...
class c_longlong(c_uint):...
class c_ulonglong(c_uint):...
class c_size_t(c_uint):...
class c_ssize_t(c_uint):...
class c_bool(c_uint):...
class c_float(TinyObj):
def __init__(self, value:float):...
class c_double(c_float):...
class c_longdouble(c_float):...
class c_wchar_p(TinyObj):
def __init__(self, value:str):
pass
def __init__(self, value:str):...
class c_char(c_wchar_p):...
class c_wchar(c_wchar_p):...
class c_char_p(c_wchar_p):...
class Test(TinyObj):
def add(self, c_uint1:c_uint, c_uint2:c_uint)->int:
pass
def dc_cpuapdu_hex(self, slen:int, sendbuf:str, rlen:c_uint, rcvbuf:c_wchar_p) -> int:
pass
def add(self, c_uint1:c_uint, c_uint2:c_uint)->int:...
def dc_cpuapdu_hex(self, slen:int, sendbuf:str, rlen:c_uint, rcvbuf:c_wchar_p) -> int:...

View File

@ -1,6 +1,7 @@
#include "ctypes_Test.h"
#include "ctypes_c_uint.h"
#include "ctypes_c_wchar_p.h"
#include "ctypes_c_float.h"
#include "ctypes_utils.h"
void ctypes_c_uint___init__(PikaObj* self, int value) {
@ -11,6 +12,10 @@ void ctypes_c_wchar_p___init__(PikaObj* self, char* value) {
ctypesUtils_setStr(self, value);
}
void ctypes_c_float___init__(PikaObj *self, float value){
ctypesUtils_setFloat(self, value);
}
int ctypes_Test_add(PikaObj* self, PikaObj* c_uint1, PikaObj* c_uint2) {
return ctypesUtils_getInt(c_uint1) + ctypesUtils_getInt(c_uint2);
}