|
|
@@ -1,4 +1,5 @@
|
|
|
#include "ctypes_Test.h"
|
|
|
+#include "ctypes_c_buffer.h"
|
|
|
#include "ctypes_c_float.h"
|
|
|
#include "ctypes_c_uint.h"
|
|
|
#include "ctypes_c_wchar_p.h"
|
|
|
@@ -50,3 +51,54 @@ void ctypes_Test_print_rcv(PikaObj* self, PikaObj* rcvbuf) {
|
|
|
__platform_printf("0x%02x", rcv[rcv_size - 1]);
|
|
|
__platform_printf("}\r\n");
|
|
|
}
|
|
|
+
|
|
|
+void ctypes_create_string_buffer___init__(PikaObj* self, int size) {
|
|
|
+ uint8_t* buffer;
|
|
|
+ obj_setBytes(self, "raw", NULL, size);
|
|
|
+ buffer = obj_getBytes(self, "raw");
|
|
|
+ __platform_printf("0x%x", &buffer);
|
|
|
+}
|
|
|
+
|
|
|
+int ctypes_create_string_buffer___get__(PikaObj* self, int __key) {
|
|
|
+ uint8_t* buffer;
|
|
|
+ int i;
|
|
|
+
|
|
|
+ i = __key;
|
|
|
+ buffer = obj_getBytes(self, "raw");
|
|
|
+ return buffer[i];
|
|
|
+}
|
|
|
+
|
|
|
+int ctypes_c_buffer___get__(PikaObj* self, int __key) {
|
|
|
+ int i;
|
|
|
+ uint8_t* buffer;
|
|
|
+
|
|
|
+ i = __key;
|
|
|
+ buffer = obj_getBytes(self, "raw");
|
|
|
+ return buffer[i];
|
|
|
+}
|
|
|
+
|
|
|
+void ctypes_c_buffer___init__(PikaObj* self, int size, Arg* value) {
|
|
|
+ uint8_t* buffer;
|
|
|
+ uint8_t* value_buffer;
|
|
|
+ size_t value_size;
|
|
|
+ ArgType arg_type;
|
|
|
+
|
|
|
+ arg_type = arg_getType(value);
|
|
|
+ if (arg_type == ARG_TYPE_BYTES) {
|
|
|
+ obj_setBytes(self, "raw", NULL, size);
|
|
|
+ buffer = obj_getBytes(self, "raw");
|
|
|
+ value_size = arg_getBytesSize(value);
|
|
|
+ value_buffer = arg_getBytes(value);
|
|
|
+ __platform_memcpy(buffer, value_buffer, value_size);
|
|
|
+ } else if (ARG_TYPE_STRING == arg_type) {
|
|
|
+ obj_setBytes(self, "raw", NULL, size);
|
|
|
+ buffer = obj_getBytes(self, "raw");
|
|
|
+ value_buffer = (uint8_t*)arg_getStr(value);
|
|
|
+ __platform_memcpy(buffer, value_buffer,
|
|
|
+ strGetSize((char*)value_buffer) + 1);
|
|
|
+ } else {
|
|
|
+ __platform_printf("value type is not support!");
|
|
|
+ while (1)
|
|
|
+ ;
|
|
|
+ }
|
|
|
+}
|