Commit 826f6453 authored by Claude Heiland-Allen's avatar Claude Heiland-Allen Committed by IOhannes m zmölnig
Browse files

AUTO_REGISTER now adds to a list called by Gem_setup().

This prevents initialization before main() when Gem is statically linked.
parent bdd46949
......@@ -220,3 +220,5 @@ void CPPExtern::beforeDeletion(void)
{
//post("CPPExtern to be deleted");
}
struct register_class_setup *gem_register_class_setup_list = 0;
......@@ -332,6 +332,12 @@ static void obj_setupCallback(t_class *classPtr);
// (registering the class with pd)
// a static copy of this class is created at runtime, to actually do the setup-call
///////////////////////////////////////////////////////////////////////////////
struct register_class_setup {
struct register_class_setup *next;
void (*setup)(void);
};
extern struct register_class_setup *gem_register_class_setup_list;
#ifdef NO_AUTO_REGISTER_CLASS
// if NO_AUTO_REGISTER_CLASS is defined, we will not register the class
# define AUTO_REGISTER_CLASS(NEW_CLASS) \
......@@ -344,9 +350,10 @@ static void obj_setupCallback(t_class *classPtr);
# define POST_AUTOREGISTER(NEW_CLASS)
# endif
# define AUTO_REGISTER_CLASS(NEW_CLASS) \
static struct register_class_setup NEW_CLASS ## _register = { 0, NEW_CLASS ## _setup }; \
class NEW_CLASS ## _cppclass { \
public: \
NEW_CLASS ## _cppclass(void) {POST_AUTOREGISTER(NEW_CLASS); NEW_CLASS ## _setup(); } \
NEW_CLASS ## _cppclass(void) {POST_AUTOREGISTER(NEW_CLASS); NEW_CLASS ## _register.next = gem_register_class_setup_list; gem_register_class_setup_list = & NEW_CLASS ## _register; } \
}; \
static NEW_CLASS ## _cppclass NEW_CLASS ## _instance
#endif
......
......@@ -37,6 +37,7 @@
#include "Gem/Manager.h"
#include "Gem/Version.h"
#include "Gem/Files.h"
#include "Base/CPPExtern.h"
#include <stdio.h>
......@@ -240,6 +241,13 @@ void setup()
verbose(-1,
"GEM: \tmailing-list https://lists.puredata.info/listinfo/gem-dev/");
struct register_class_setup *l = gem_register_class_setup_list;
while (l)
{
l->setup();
l = l->next;
}
gem::Settings::init();
addownpath("Gem-meta.pd");
GemMan::initGem();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment