learning C++

This commit is contained in:
rusefi 2019-04-12 19:56:34 -04:00
parent 6241d11ec9
commit 91ac74c1c9
6 changed files with 6 additions and 24 deletions

View File

@ -32,18 +32,13 @@ void SingleWave::setState(int switchIndex, pin_state_t state) {
pinStates[switchIndex] = state; pinStates[switchIndex] = state;
} }
void MultiWave::baseConstructor() { MultiWave::MultiWave() {
channels = NULL; channels = NULL;
switchTimes = NULL; switchTimes = NULL;
reset(); reset();
} }
MultiWave::MultiWave() { MultiWave::MultiWave(float *switchTimes, SingleWave *waves) : MultiWave(){
baseConstructor();
}
MultiWave::MultiWave(float *switchTimes, SingleWave *waves) {
baseConstructor();
init(switchTimes, waves); init(switchTimes, waves);
} }

View File

@ -61,7 +61,6 @@ public:
*/ */
class MultiWave { class MultiWave {
public: public:
void baseConstructor();
MultiWave(); MultiWave();
MultiWave(float *switchTimes, SingleWave *waves); MultiWave(float *switchTimes, SingleWave *waves);
void init(float *switchTimes, SingleWave *waves); void init(float *switchTimes, SingleWave *waves);

View File

@ -32,7 +32,7 @@ SimplePwm::SimplePwm(const char *name) : SimplePwm() {
this->name = name; this->name = name;
} }
void PwmConfig::baseConstructor() { PwmConfig::PwmConfig() {
memset((void*)&scheduling, 0, sizeof(scheduling)); memset((void*)&scheduling, 0, sizeof(scheduling));
memset((void*)&safe, 0, sizeof(safe)); memset((void*)&safe, 0, sizeof(safe));
dbgNestingLevel = 0; dbgNestingLevel = 0;
@ -46,12 +46,7 @@ void PwmConfig::baseConstructor() {
name = "[noname]"; name = "[noname]";
} }
PwmConfig::PwmConfig() { PwmConfig::PwmConfig(float *st, SingleWave *waves) : PwmConfig() {
baseConstructor();
}
PwmConfig::PwmConfig(float *st, SingleWave *waves) {
baseConstructor();
multiWave.init(st, waves); multiWave.init(st, waves);
} }

View File

@ -53,7 +53,6 @@ class PwmConfig {
public: public:
PwmConfig(); PwmConfig();
PwmConfig(float *switchTimes, SingleWave *waves); PwmConfig(float *switchTimes, SingleWave *waves);
void baseConstructor();
void init(float *switchTimes, SingleWave *waves); void init(float *switchTimes, SingleWave *waves);
void weComplexInit(const char *msg, void weComplexInit(const char *msg,

View File

@ -295,7 +295,7 @@ void Logging::appendPrintf(const char *fmt, ...) {
#endif /* ! EFI_UNIT_TEST */ #endif /* ! EFI_UNIT_TEST */
void Logging::baseConstructor() { Logging::Logging() {
name = NULL; name = NULL;
buffer = NULL; buffer = NULL;
linePointer = NULL; linePointer = NULL;
@ -303,12 +303,7 @@ void Logging::baseConstructor() {
isInitialized = false; isInitialized = false;
} }
Logging::Logging() { Logging::Logging(char const *name, char *buffer, int bufferSize) : Logging(){
baseConstructor();
}
Logging::Logging(char const *name, char *buffer, int bufferSize) {
baseConstructor();
#if ! EFI_UNIT_TEST #if ! EFI_UNIT_TEST
initLoggingExt(name, buffer, bufferSize); initLoggingExt(name, buffer, bufferSize);
#else #else

View File

@ -18,7 +18,6 @@
// size of buffers? // size of buffers?
class Logging { class Logging {
public: public:
void baseConstructor();
Logging(); Logging();
Logging(const char *name, char *buffer, int bufferSize); Logging(const char *name, char *buffer, int bufferSize);
void initLoggingExt(const char *name, char *buffer, int bufferSize); void initLoggingExt(const char *name, char *buffer, int bufferSize);