From 289176cb4c0108ad2ceab57b9a5a60ce4cc0b10e Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Thu, 17 Mar 2022 05:31:57 +0100 Subject: [PATCH] Allow building core LK engine without wxWidgets --- include/lk/absyn.h | 29 +++++++++++++++++++++++++++++ include/lk/stdlib.h | 5 +++++ src/stdlib.cpp | 2 ++ 3 files changed, 36 insertions(+) diff --git a/include/lk/absyn.h b/include/lk/absyn.h index 4db7e6f..7ef5aff 100644 --- a/include/lk/absyn.h +++ b/include/lk/absyn.h @@ -54,6 +54,7 @@ typedef wxStringEqual lk_string_equal; #else #include +#include typedef std::string::value_type lk_char; typedef std::string lk_string; @@ -61,6 +62,34 @@ typedef std::string lk_string; typedef std::hash lk_string_hash; typedef std::equal_to lk_string_equal; +inline lk_string& operator << (lk_string& a, const lk_string& lstr) +{ + a += lstr; + return a; +} + +inline lk_string& operator << (lk_string& a, const char* s) +{ + a += s; + return a; +} + +inline lk_string& operator << (lk_string& a, int i) +{ + std::stringstream sstr; + sstr << i; + a += sstr.str(); + return a; +} + +inline lk_string& operator << (lk_string& a, size_t i) +{ + std::stringstream sstr; + sstr << i; + a += sstr.str(); + return a; +} + #endif #define lk_tr(s) lk::get_translation(s) diff --git a/include/lk/stdlib.h b/include/lk/stdlib.h index 4678866..803a502 100644 --- a/include/lk/stdlib.h +++ b/include/lk/stdlib.h @@ -25,7 +25,9 @@ #ifndef __lk_stdlib_h #define __lk_stdlib_h +#ifdef LK_USE_WXWIDGETS #include +#endif #include @@ -162,6 +164,8 @@ namespace lk { double erfc(double x); }; +#ifdef LK_USE_WXWIDGETS + class MyMessageDialog : public wxDialog { public: MyMessageDialog(wxWindow *parent, @@ -254,5 +258,6 @@ DECLARE_EVENT_TABLE(); }; wxWindow *GetCurrentTopLevelWindow(); +#endif #endif diff --git a/src/stdlib.cpp b/src/stdlib.cpp index 702708c..0ee036f 100644 --- a/src/stdlib.cpp +++ b/src/stdlib.cpp @@ -4100,6 +4100,7 @@ double lk::erfc(double x) { return x < 0.0 ? 1.0 + gammp(0.5, x * x) : gammq(0.5, x * x); } +#ifdef LK_USE_WXWIDGETS wxWindow *GetCurrentTopLevelWindow() { wxWindowList &wl = ::wxTopLevelWindows; for (wxWindowList::iterator it = wl.begin(); it != wl.end(); ++it) @@ -4109,6 +4110,7 @@ wxWindow *GetCurrentTopLevelWindow() { return 0; } +#endif #ifdef WIN32