mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
add ctypes package
This commit is contained in:
parent
2d5a5c3f3e
commit
32cc9d20bd
16
package/ctypes/ctypes.c
Normal file
16
package/ctypes/ctypes.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include "ctypes_Test.h"
|
||||
#include "ctypes_cUint.h"
|
||||
#include "ctypes_cWcharP.h"
|
||||
void ctypes_cUint___init__(PikaObj* self, int value) {
|
||||
obj_setInt(self, "value", value);
|
||||
}
|
||||
|
||||
void ctypes_cWcharP___init__(PikaObj* self, char* value) {
|
||||
obj_setStr(self, "value", value);
|
||||
}
|
||||
|
||||
int ctypes_Test_add(PikaObj* self, void* c_uint1, void* c_uint2) {
|
||||
PikaObj* c_uint1_obj = c_uint1;
|
||||
PikaObj* c_uint2_obj = c_uint2;
|
||||
return obj_getInt(c_uint1_obj, "value") + obj_getInt(c_uint2_obj, "value");
|
||||
}
|
13
package/ctypes/ctypes.py
Normal file
13
package/ctypes/ctypes.py
Normal file
@ -0,0 +1,13 @@
|
||||
from PikaObj import *
|
||||
|
||||
class cUint(TinyObj):
|
||||
def __init__(self, value:int):
|
||||
pass
|
||||
|
||||
class cWcharP(TinyObj):
|
||||
def __init__(self, value:str):
|
||||
pass
|
||||
|
||||
class Test(TinyObj):
|
||||
def add(self, c_uint1:pointer, c_uint2:pointer)->int:
|
||||
pass
|
4
port/linux/.vscode/settings.json
vendored
4
port/linux/.vscode/settings.json
vendored
@ -50,7 +50,9 @@
|
||||
"PikaParser.H": "cpp",
|
||||
"pikastddata_list.h": "c",
|
||||
"pikastddevice_spi.h": "c",
|
||||
"pikastddevice_can.h": "c"
|
||||
"pikastddevice_can.h": "c",
|
||||
"ctypes.h": "c",
|
||||
"ctypes_test.h": "c"
|
||||
},
|
||||
"python.formatting.provider": "autopep8"
|
||||
}
|
13
port/linux/package/pikascript/ctypes.py
Normal file
13
port/linux/package/pikascript/ctypes.py
Normal file
@ -0,0 +1,13 @@
|
||||
from PikaObj import *
|
||||
|
||||
class cUint(TinyObj):
|
||||
def __init__(self, value:int):
|
||||
pass
|
||||
|
||||
class cWcharP(TinyObj):
|
||||
def __init__(self, value:str):
|
||||
pass
|
||||
|
||||
class Test(TinyObj):
|
||||
def add(self, c_uint1:pointer, c_uint2:pointer)->int:
|
||||
pass
|
@ -4,7 +4,7 @@ import GTestTask
|
||||
import PikaMath
|
||||
import PikaStdDevice
|
||||
import PikaDebug
|
||||
import ctypes
|
||||
import PikaStdData
|
||||
from package.pikascript.PikaObj import printNoEnd
|
||||
|
||||
mem = PikaStdLib.MemChecker()
|
||||
|
16
port/linux/package/pikascript/pikascript-lib/ctypes/ctypes.c
Normal file
16
port/linux/package/pikascript/pikascript-lib/ctypes/ctypes.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include "ctypes_Test.h"
|
||||
#include "ctypes_cUint.h"
|
||||
#include "ctypes_cWcharP.h"
|
||||
void ctypes_cUint___init__(PikaObj* self, int value) {
|
||||
obj_setInt(self, "value", value);
|
||||
}
|
||||
|
||||
void ctypes_cWcharP___init__(PikaObj* self, char* value) {
|
||||
obj_setStr(self, "value", value);
|
||||
}
|
||||
|
||||
int ctypes_Test_add(PikaObj* self, void* c_uint1, void* c_uint2) {
|
||||
PikaObj* c_uint1_obj = c_uint1;
|
||||
PikaObj* c_uint2_obj = c_uint2;
|
||||
return obj_getInt(c_uint1_obj, "value") + obj_getInt(c_uint2_obj, "value");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user