From 50d9920fa64b438e1ad8ffa7a95d057485898b87 Mon Sep 17 00:00:00 2001 From: Lyon Date: Wed, 3 Jul 2024 13:59:28 +0800 Subject: [PATCH] fix compile issue and flashdb test issue --- examples/flashdb/flashdb_tsdb1.py | 9 ++++++++- port/linux/test/module-test.cpp | 2 ++ port/linux/test/python/flashdb/flashdb_tsdb1.py | 9 ++++++++- src/PikaObj.h | 8 ++++---- src/PikaVersion.h | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/examples/flashdb/flashdb_tsdb1.py b/examples/flashdb/flashdb_tsdb1.py index a187ce771..51cc6cec5 100644 --- a/examples/flashdb/flashdb_tsdb1.py +++ b/examples/flashdb/flashdb_tsdb1.py @@ -17,17 +17,24 @@ toc = time.time() * 1000 assert ret == 0 +sum_by_time = 0 + + def callback(tsl, user_data) -> int: + global sum_by_time # print(tsl.get_time(), tsl.to_blob()) t = tsl.get_time() blob_i = tsl.to_blob() i = struct.unpack('i', blob_i)[0] print(t, i, user_data) + if user_data == 'user_data_by_time': + sum_by_time += i return False # False: continue, True: stop - assert tsdb.tsl_iter(callback, 'user_data') == 0 assert tsdb.tsl_iter_reverse(callback, 'user_data_reverse') == 0 +print('toc - tic', toc - tic) assert tsdb.tsl_iter_by_time(tic, toc, callback, 'user_data_by_time') == 0 +assert sum_by_time == 45 print('PASS') diff --git a/port/linux/test/module-test.cpp b/port/linux/test/module-test.cpp index 510e8eec8..92a1f01d6 100644 --- a/port/linux/test/module-test.cpp +++ b/port/linux/test/module-test.cpp @@ -799,10 +799,12 @@ TEST_RUN_SINGLE_FILE_EXCEPT_OUTPUT(flashdb, "test/python/flashdb/flashdb_kvdb2.py", "PASS\r\n") +#if PIKA_FLOAT_TYPE_DOUBLE TEST_RUN_SINGLE_FILE_EXCEPT_OUTPUT(flashdb, tsdb1, "test/python/flashdb/flashdb_tsdb1.py", "PASS\r\n") +#endif #endif diff --git a/port/linux/test/python/flashdb/flashdb_tsdb1.py b/port/linux/test/python/flashdb/flashdb_tsdb1.py index a187ce771..51cc6cec5 100644 --- a/port/linux/test/python/flashdb/flashdb_tsdb1.py +++ b/port/linux/test/python/flashdb/flashdb_tsdb1.py @@ -17,17 +17,24 @@ toc = time.time() * 1000 assert ret == 0 +sum_by_time = 0 + + def callback(tsl, user_data) -> int: + global sum_by_time # print(tsl.get_time(), tsl.to_blob()) t = tsl.get_time() blob_i = tsl.to_blob() i = struct.unpack('i', blob_i)[0] print(t, i, user_data) + if user_data == 'user_data_by_time': + sum_by_time += i return False # False: continue, True: stop - assert tsdb.tsl_iter(callback, 'user_data') == 0 assert tsdb.tsl_iter_reverse(callback, 'user_data_reverse') == 0 +print('toc - tic', toc - tic) assert tsdb.tsl_iter_by_time(tic, toc, callback, 'user_data_by_time') == 0 +assert sum_by_time == 45 print('PASS') diff --git a/src/PikaObj.h b/src/PikaObj.h index 2e05bac3a..cec064606 100644 --- a/src/PikaObj.h +++ b/src/PikaObj.h @@ -138,9 +138,10 @@ struct PikaVMFrame { pika_bool in_repl; }; +typedef PikaObj* (*NewFun)(Args* args); struct PikaObj { Args* list; - void* constructor; + NewFun constructor; #if PIKA_GC_MARK_SWEEP_ENABLE PikaObj* gcNext; #endif @@ -228,7 +229,6 @@ static inline void obj_clearFlag(PikaObj* self, uint16_t flag) { #endif } -typedef PikaObj* (*NewFun)(Args* args); typedef PikaObj* (*InitFun)(PikaObj* self, Args* args); typedef void (*Method)(PikaObj* self, Args* args); @@ -395,7 +395,7 @@ Arg* obj_runMethodArg2(PikaObj* self, Arg* methodArg, Arg* arg1, Arg* arg2); Arg* obj_runMethod0(PikaObj* self, char* methodName); Arg* obj_runMethod1(PikaObj* self, char* methodName, Arg* arg1); Arg* obj_runMethod2(PikaObj* self, char* methodName, Arg* arg1, Arg* arg2); -PikaObj* New_PikaObj(void); +PikaObj* New_PikaObj(Args* args); PikaObj* New_PikaObj_noGC(void); /* tools */ @@ -745,7 +745,7 @@ const MethodProp floatMethod = { #if defined(_WIN32) || \ - (defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 6000000)) + (defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 6000000)) || defined(__IAR_SYSTEMS_ICC__) #define __BEFORE_MOETHOD_DEF \ { \ ._ = \ diff --git a/src/PikaVersion.h b/src/PikaVersion.h index bc81d954e..87f765771 100644 --- a/src/PikaVersion.h +++ b/src/PikaVersion.h @@ -2,4 +2,4 @@ #define PIKA_VERSION_MINOR 13 #define PIKA_VERSION_MICRO 3 -#define PIKA_EDIT_TIME "2024/07/03 00:31:02" +#define PIKA_EDIT_TIME "2024/07/03 13:59:17"