diff --git a/include/endApp.h b/include/endApp.h new file mode 100644 index 0000000..87c51ca --- /dev/null +++ b/include/endApp.h @@ -0,0 +1,10 @@ +#include "Archimedes.h" + +#ifdef APP_TYPE + +inline Archimedes::App* MakeApp() { + return new APP_TYPE(); +} + +#undef APP_TYPE +#endif diff --git a/include/endModule.h b/include/endModule.h new file mode 100644 index 0000000..5ca5705 --- /dev/null +++ b/include/endModule.h @@ -0,0 +1,12 @@ +#include "Archimedes.h" + +#ifdef MODULE_TYPE + +extern "C" { + Archimedes::Module* create(void* handle, Archimedes::App* app) { + return new MODULE_TYPE(handle, app); + } +} + +#undef MODULE_TYPE +#endif diff --git a/modules/DependsOnPrint/src/DependsOnPrint.h b/modules/DependsOnPrint/src/DependsOnPrint.h index 3fe295f..fd418e4 100644 --- a/modules/DependsOnPrint/src/DependsOnPrint.h +++ b/modules/DependsOnPrint/src/DependsOnPrint.h @@ -10,8 +10,7 @@ class DependsOnPrint : public Archimedes::Module { }; -extern "C" { - Archimedes::Module* create(void* handle, Archimedes::App* app) { - return new DependsOnPrint(handle, app); - } -} +#ifndef DEPENDSONPRINT_STATIC +#define MODULE_TYPE DependsOnPrint +#include "endModule.h" +#endif diff --git a/modules/DependsOnPrintStatic/src/DependsOnPrintStatic.h b/modules/DependsOnPrintStatic/src/DependsOnPrintStatic.h index e2157a3..1861187 100644 --- a/modules/DependsOnPrintStatic/src/DependsOnPrintStatic.h +++ b/modules/DependsOnPrintStatic/src/DependsOnPrintStatic.h @@ -11,11 +11,6 @@ class DependsOnPrintStatic : public Archimedes::Module { }; #ifndef DEPENDSONPRINTSTATIC_STATIC - -extern "C" { - Archimedes::Module* create(void* handle, Archimedes::App* app) { - return new DependsOnPrintStatic(handle, app); - } -} - +#define MODULE_TYPE DependsOnPrintStatic +#include "endModule.h" #endif diff --git a/modules/GUImodules/TestImgui/src/TestImgui.h b/modules/GUImodules/TestImgui/src/TestImgui.h index 4c00762..028f618 100644 --- a/modules/GUImodules/TestImgui/src/TestImgui.h +++ b/modules/GUImodules/TestImgui/src/TestImgui.h @@ -22,11 +22,6 @@ class TestImgui : public Archimedes::GuiModule { }; #ifndef TESTIMGUI_STATIC - -extern "C" { - Archimedes::Module* create(void* handle, Archimedes::App* app) { - return (Archimedes::Module*) new TestImgui(handle, app); - } -} - +#define MODULE_TYPE TestImgui +#include "endModule.h" #endif diff --git a/modules/Print/src/Print.h b/modules/Print/src/Print.h index 682f490..25de182 100644 --- a/modules/Print/src/Print.h +++ b/modules/Print/src/Print.h @@ -11,11 +11,6 @@ class Print : public Archimedes::Module { }; #ifndef PRINT_STATIC - -extern "C" { - Archimedes::Module* create(void* handle, Archimedes::App* app) { - return new Print(handle, app); - } -} - +#define MODULE_TYPE Print +#include "endModule.h" #endif diff --git a/src/example_apps/ImguiEmbed/ImguiEmbed.h b/src/example_apps/ImguiEmbed/ImguiEmbed.h index ca25032..d1fc08e 100644 --- a/src/example_apps/ImguiEmbed/ImguiEmbed.h +++ b/src/example_apps/ImguiEmbed/ImguiEmbed.h @@ -27,4 +27,5 @@ class ImguiEmbed : public Archimedes::App { }; -Archimedes::App* MakeApp() { return (Archimedes::App*) new ImguiEmbed(); } +#define APP_TYPE ImguiEmbed +#include "endApp.h" diff --git a/src/example_apps/MinimalApp/MinimalApp.h b/src/example_apps/MinimalApp/MinimalApp.h index da21719..9e07aed 100644 --- a/src/example_apps/MinimalApp/MinimalApp.h +++ b/src/example_apps/MinimalApp/MinimalApp.h @@ -29,4 +29,5 @@ class MinimalApp : public Archimedes::App { }; -Archimedes::App* MakeApp() { return new MinimalApp(); } +#define APP_TYPE MinimalApp +#include "endApp.h"