From 8926fe2f69a713cc64ff11a9723441d0c15a6577 Mon Sep 17 00:00:00 2001 From: peri4 Date: Fri, 10 Dec 2010 23:42:53 +0300 Subject: [PATCH] 10.12.2010 - light modifies in headers --- piconsole.cpp | 6 +++--- piconsole.h | 8 +++----- pikbdlistener.cpp | 2 +- pikbdlistener.h | 4 ++-- piprotocol.cpp | 4 ++-- pistring.h | 2 +- pitimer.cpp | 2 +- pitimer.h | 2 +- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/piconsole.cpp b/piconsole.cpp index bd9f6b68..3303867a 100644 --- a/piconsole.cpp +++ b/piconsole.cpp @@ -1,7 +1,7 @@ #include "piconsole.h" -PIConsole::PIConsole(bool startNow, KeyFunc slot): PIThread() { +PIConsole::PIConsole(bool startNow, KBFunc slot): PIThread() { setPriority(piLow); needLockRun(true); ret_func = slot; @@ -110,7 +110,7 @@ bool PIConsole::setTabBindKey(PIString name, char bind_key) { } -void PIConsole::key_event(void * t, char key) { +void PIConsole::key_event(char key, void * t) { PIConsole * p = (PIConsole * )t; for (uint i = 0; i < p->tabsCount(); ++i) { if (p->tabs[i].key == key) { @@ -118,7 +118,7 @@ void PIConsole::key_event(void * t, char key) { return; } } - if (p->ret_func != 0) p->ret_func(t, key); + if (p->ret_func != 0) p->ret_func(key, t); } diff --git a/piconsole.h b/piconsole.h index a4f0078a..ace72614 100644 --- a/piconsole.h +++ b/piconsole.h @@ -8,12 +8,10 @@ #include #endif -typedef void (*KeyFunc)(void * , char); - class PIConsole: public PIThread { public: - PIConsole(bool startNow = true, KeyFunc slot = 0); + PIConsole(bool startNow = true, KBFunc slot = 0); ~PIConsole(); enum Format {Normal = 0x01, @@ -120,7 +118,7 @@ private: inline int printValue(const uint value, Flags format = PIConsole::Normal); inline int printValue(const ulong value, Flags format = PIConsole::Normal); inline int printValue(const ullong value, Flags format = PIConsole::Normal); - static void key_event(void * t, char key); + static void key_event(char key, void * t); struct Variable { PIString name; @@ -188,7 +186,7 @@ private: vector tabs; Variable tv; PIKbdListener * listener; - KeyFunc ret_func; + KBFunc ret_func; int width, height, ret, col_wid, num_format; uint my; uint cur_tab, col_cnt; diff --git a/pikbdlistener.cpp b/pikbdlistener.cpp index d9e8e33b..1f36eb69 100644 --- a/pikbdlistener.cpp +++ b/pikbdlistener.cpp @@ -34,6 +34,6 @@ void PIKbdListener::run() { #else ret = read(0, &rc, 1); #endif - if (ret_func != 0 && ret > 0) ret_func(data, rc); + if (ret_func != 0 && ret > 0) ret_func(rc, data); } diff --git a/pikbdlistener.h b/pikbdlistener.h index f4da00bd..de3589c5 100644 --- a/pikbdlistener.h +++ b/pikbdlistener.h @@ -6,11 +6,11 @@ #include #endif -typedef void (*KBFunc)(void * , char); +typedef void (*KBFunc)(char, void * ); class PIKbdListener: public PIThread { public: - // slot is any function format "void (void * , char)" + // slot is any function format "void (char, void * )" PIKbdListener(KBFunc slot = 0, void * data = 0); ~PIKbdListener(); diff --git a/piprotocol.cpp b/piprotocol.cpp index b7437666..00b26b6e 100644 --- a/piprotocol.cpp +++ b/piprotocol.cpp @@ -39,7 +39,7 @@ void PIProtocol::init() { net_diag = PIProtocol::Unknown; cur_pckt = 0; timer = 0; - sendtimer = new PITimer(this, run); + sendtimer = new PITimer(run, this); wrong_count = receive_count = send_count = 0; immediateFreq = integralFreq = 0.f; headerPtr = dataPtr = sendDataPtr = 0; @@ -68,7 +68,7 @@ void PIProtocol::setExpectedFrequency(float frequency) if (exp_freq < 3.33) pckt_cnt_max = 10; else pckt_cnt_max = 3 * (int)exp_freq; last_packets.resize(pckt_cnt_max); - timer = new PITimer(this, diag_event); + timer = new PITimer(diag_event, this); timer->start(1000. / exp_freq); timer->reset(); } diff --git a/pistring.h b/pistring.h index 6d9dd84d..54bf69c3 100644 --- a/pistring.h +++ b/pistring.h @@ -11,7 +11,7 @@ public: PIString(const char * str) {*this += str;} PIString(const string & str) {*this += str;} PIString(const PIString & str) {*this += str;} - PIString(const int len, const char c = ' ') {for (uint i = 0; i < len; ++i) push_back(c);} + PIString(const int len, const char c = ' ') {for (int i = 0; i < len; ++i) push_back(c);} operator const char*() {return data();} operator const string() {return (size() == 0) ? string() : string(&at(0), size());} diff --git a/pitimer.cpp b/pitimer.cpp index c2e06569..39cad182 100644 --- a/pitimer.cpp +++ b/pitimer.cpp @@ -1,7 +1,7 @@ #include "pitimer.h" -PITimer::PITimer(void * data_, TimerEvent slot) { +PITimer::PITimer(TimerEvent slot, void * data_) { ret_func = slot; data = data_; #ifndef __WIN32__ diff --git a/pitimer.h b/pitimer.h index 6b8dfdad..169be8f6 100644 --- a/pitimer.h +++ b/pitimer.h @@ -25,7 +25,7 @@ class PITimer #endif { public: - PITimer(void * data = 0, TimerEvent slot = 0); + PITimer(TimerEvent slot = 0, void * data = 0); ~PITimer() {stop();} #ifdef __WIN32__ void reset() {t_st = GetCurrentTime();}