• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revision48ff443161947e2146f270c72f6230fd9a453fbe (tree)
Time2018-07-12 04:25:06
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[STATE] .

Change Summary

Incremental Difference

--- a/source/src/qt/emuutils/CMakeLists.txt
+++ b/source/src/qt/emuutils/CMakeLists.txt
@@ -15,7 +15,7 @@ set(s_qt_emuutils_srcs
1515
1616 QT5_WRAP_CPP(s_qt_emuutils_headers_MOC ${s_qt_emuutils_headers})
1717
18-SET(THIS_LIB_VERSION 2.11.7)
18+SET(THIS_LIB_VERSION 2.11.8)
1919
2020 if(WIN32)
2121 include (GenerateExportHeader)
--- a/source/src/state_data.h
+++ b/source/src/state_data.h
@@ -27,6 +27,9 @@ public:
2727 int save_and_change_byteorder_be(uint32_t *sum, void *val, int bytes = 4, int rep = 1);
2828 int load_and_change_byteorder_be(uint32_t *sum, void *val, int bytes = 4, int rep = 1);
2929
30+ void put_char(char val, uint32_t *sumseed = NULL, bool *__stat = NULL);
31+ char get_char(uint32_t *sumseed = NULL, bool *__stat = NULL);
32+
3033 void put_byte(uint8_t val, uint32_t *sumseed = NULL, bool *__stat = NULL);
3134 uint8_t get_byte(uint32_t *sumseed = NULL, bool *__stat = NULL);
3235
--- a/source/src/statesub.cpp
+++ b/source/src/statesub.cpp
@@ -199,6 +199,43 @@ int csp_state_data_saver::load_and_change_byteorder_be(uint32_t *sum, void *val,
199199 return members;
200200 }
201201
202+
203+void csp_state_data_saver::put_char(char val, uint32_t *sumseed, bool *__stat)
204+{
205+
206+ if(fio != NULL) {
207+ if(fio->IsOpened()) {
208+ if(fio->Fputc(val) != EOF) {
209+ if(sumseed != NULL) {
210+ *sumseed = calc_crc32(*sumseed, &val, 1);
211+ }
212+ if(__stat != NULL) *__stat = true;
213+ return;
214+ }
215+ }
216+ }
217+ if(__stat != NULL) *__stat = false;
218+ return;
219+}
220+
221+char csp_state_data_saver::get_char(uint32_t *sumseed, bool *__stat)
222+{
223+ if(fio != NULL) {
224+ if(fio->IsOpened()) {
225+ char val = fio->Fgetc();
226+ if(val != EOF) {
227+ if(sumseed != NULL) {
228+ *sumseed = calc_crc32(*sumseed, &val, 1);
229+ }
230+ if(__stat != NULL) *__stat = true;
231+ return val;
232+ }
233+ }
234+ }
235+ if(__stat != NULL) *__stat = false;
236+ return 0x00000000;
237+}
238+
202239 void csp_state_data_saver::put_byte(uint8_t val, uint32_t *sumseed, bool *__stat)
203240 {
204241
@@ -1114,6 +1151,8 @@ void csp_state_utils::add_entry_vararray(const _TCHAR *__name, T **p, void *data
11141151 // void csp_state_utils::add_entry(const _TCHAR *__name, T *p, int _len = 1, int __num = -1, bool is_const = false, int stride = 0);
11151152
11161153 template
1154+ void csp_state_utils::add_entry<char>(const _TCHAR *__name, char *p, int _len = 1, int __num = -1, bool is_const = false, int stride = 0);
1155+template
11171156 void csp_state_utils::add_entry<float>(const _TCHAR *__name, float *p, int _len = 1, int __num = -1, bool is_const = false, int stride = 0);
11181157 template
11191158 void csp_state_utils::add_entry<double>(const _TCHAR *__name, double *p, int _len = 1, int __num = -1, bool is_const = false, int stride = 0);
@@ -1392,6 +1431,35 @@ void csp_state_utils::add_entry_scrntype_t(const _TCHAR *__name, scrntype_t *p,
13921431
13931432 }
13941433
1434+int csp_state_utils::save_sub_char(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride)
1435+{
1436+ int retval = 0;
1437+ char *px = (char *)pp;
1438+ if(_stat != NULL) {
1439+ *_stat = false;
1440+ }
1441+ for(int i = 0; i < _len; i++) {
1442+ fio->put_char(*px, crc_value, _stat);
1443+ if(_stride > sizeof(char)) {
1444+ px = (char *)((uint8_t *)px + _stride);
1445+ } else {
1446+ px++;
1447+ }
1448+ if(_stat != NULL) {
1449+ if(!(*_stat)) {
1450+ return -1;
1451+ }
1452+ }
1453+ retval++;
1454+ }
1455+ if(_stat != NULL) {
1456+ if(!(*_stat)) {
1457+ retval = -1;
1458+ }
1459+ }
1460+ return retval;
1461+}
1462+
13951463 int csp_state_utils::save_sub_float(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride)
13961464 {
13971465 int retval = 0;
@@ -2095,6 +2163,9 @@ void csp_state_utils::save_state(FILEIO *__fio, uint32_t *pcrc)
20952163 if((pp != NULL) && (_len > 0)) {
20962164 int64_t tval;
20972165 switch(_tid) {
2166+ case csp_saver_entry_char:
2167+ retval = save_sub_char(&crc_value, &_stat, pp, _len, _stride);
2168+ break;
20982169 case csp_saver_entry_float:
20992170 retval = save_sub_float(&crc_value, &_stat, pp, _len, _stride);
21002171 break;
@@ -2192,6 +2263,36 @@ void csp_state_utils::save_state(FILEIO *__fio, uint32_t *pcrc)
21922263 return;
21932264 }
21942265
2266+int csp_state_utils::load_sub_char(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride)
2267+{
2268+ int retval = 0;
2269+ char *px = (char *)pp;
2270+ if(_stat != NULL) {
2271+ *_stat = false;
2272+ }
2273+ for(int i = 0; i < _len; i++) {
2274+ *px = fio->get_char(crc_value, _stat);
2275+ if(_stride > sizeof(char)) {
2276+ px = (char *)((uint8_t *)px + _stride);
2277+ } else {
2278+ px++;
2279+ }
2280+ if(_stat != NULL) {
2281+ if(!(*_stat)) {
2282+ return -1;
2283+ }
2284+ }
2285+ retval++;
2286+ }
2287+ if(_stat != NULL) {
2288+ //out_debug_log("NAME=%s CHAR: LEN=%d STAT=%d HEAD=%08x", _name.c_str(), _len, (_stat) ? 1 : 0, pp);
2289+ if(!(*_stat)) {
2290+ return -1;
2291+ }
2292+ }
2293+ return retval;
2294+}
2295+
21952296 int csp_state_utils::load_sub_float(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride)
21962297 {
21972298 int retval = 0;
@@ -2905,6 +3006,9 @@ bool csp_state_utils::load_state(FILEIO *__fio, uint32_t *pcrc)
29053006 //printf("%s\n", (*p).name);
29063007 if((pp != NULL) && (_len > 0)) {
29073008 switch(_tid) {
3009+ case csp_saver_entry_char:
3010+ retval = load_sub_char(&crc_value, &_stat, pp, _len, _stride);
3011+ break;
29083012 case csp_saver_entry_float:
29093013 retval = load_sub_float(&crc_value, &_stat, pp, _len, _stride);
29103014 break;
--- a/source/src/statesub.h
+++ b/source/src/statesub.h
@@ -52,6 +52,7 @@ typedef enum csp_saver_type_t {
5252 csp_saver_entry_uint64,
5353 csp_saver_entry_int64,
5454 csp_saver_entry_bool,
55+ csp_saver_entry_char,
5556 csp_saver_entry_tchar,
5657 csp_saver_entry_pair,
5758 csp_saver_entry_float,
@@ -133,6 +134,7 @@ protected:
133134
134135 void out_debug_log(const char *fmt, ...);
135136
137+ int save_sub_char(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride);
136138 int save_sub_float(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride);
137139 int save_sub_double(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride);
138140 int save_sub_long_double(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride);
@@ -157,6 +159,7 @@ protected:
157159 int save_sub_byte_array(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride, int _atomsize);
158160 int save_sub_cmt_recording(uint32_t *crc_value, bool *_stat, void *pp, FILEIO **ffp, int _len, int _stride);
159161
162+ int load_sub_char(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride);
160163 int load_sub_float(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride);
161164 int load_sub_double(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride);
162165 int load_sub_long_double(uint32_t *crc_value, bool *_stat, void *pp, int _len, int _stride);
@@ -195,6 +198,7 @@ protected:
195198 { typeid(uint32_t), csp_saver_entry_uint32 },
196199 { typeid(int64_t), csp_saver_entry_int64 },
197200 { typeid(uint64_t), csp_saver_entry_uint64 },
201+ { typeid(char), csp_saver_entry_char },
198202 { typeid(bool), csp_saver_entry_bool },
199203 { typeid(void), csp_saver_entry_void },
200204 { typeid(FIFO), csp_saver_entry_fifo },
Show on old repository browser