pointless OOP

This commit is contained in:
rusefi 2018-08-31 21:38:14 -04:00
parent 351d36f9c0
commit 61d3eb177c
3 changed files with 21 additions and 8 deletions

View File

@ -141,7 +141,7 @@ WaveChart::WaveChart() {
} }
void WaveChart::init() { void WaveChart::init() {
initLoggingExt(&logging, "wave chart", WAVE_LOGGING_BUFFER, sizeof(WAVE_LOGGING_BUFFER)); logging.initLoggingExt("wave chart", WAVE_LOGGING_BUFFER, sizeof(WAVE_LOGGING_BUFFER));
isInitialized = true; isInitialized = true;
reset(); reset();
} }

View File

@ -115,6 +115,7 @@ static void vappendPrintf(Logging *logging, const char *fmt, va_list arg) {
} }
} }
// todo: replace with logging->appendPrintf
void appendPrintf(Logging *logging, const char *fmt, ...) { void appendPrintf(Logging *logging, const char *fmt, ...) {
efiAssertVoid(CUSTOM_ERR_6607, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#4"); efiAssertVoid(CUSTOM_ERR_6607, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#4");
va_list ap; va_list ap;
@ -123,12 +124,20 @@ void appendPrintf(Logging *logging, const char *fmt, ...) {
va_end(ap); va_end(ap);
} }
void initLoggingExt(Logging *logging, const char *name, char *buffer, int bufferSize) { void Logging::appendPrintf(const char *fmt, ...) {
logging->name = name; efiAssertVoid(CUSTOM_ERR_6607, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#4");
logging->buffer = buffer; va_list ap;
logging->bufferSize = bufferSize; va_start(ap, fmt);
resetLogging(logging); vappendPrintf(this, fmt, ap);
logging->isInitialized = true; va_end(ap);
}
void Logging::initLoggingExt(const char *name, char *buffer, int bufferSize) {
this->name = name;
this->buffer = buffer;
this->bufferSize = bufferSize;
resetLogging(this);
this->isInitialized = true;
} }
int isInitialized(Logging *logging) { int isInitialized(Logging *logging) {
@ -303,7 +312,7 @@ Logging::Logging() {
Logging::Logging(char const *name, char *buffer, int bufferSize) { Logging::Logging(char const *name, char *buffer, int bufferSize) {
baseConstructor(); baseConstructor();
#if ! EFI_UNIT_TEST #if ! EFI_UNIT_TEST
initLoggingExt(this, name, buffer, bufferSize); initLoggingExt(name, buffer, bufferSize);
#endif /* ! EFI_UNIT_TEST */ #endif /* ! EFI_UNIT_TEST */
} }

View File

@ -21,6 +21,10 @@ public:
void baseConstructor(); 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 append(const char *text);
void appendFast(const char *text);
void appendPrintf(const char *fmt, ...);
const char *name; const char *name;
char SMALL_BUFFER[40]; char SMALL_BUFFER[40];
/** /**