Closed pixsperdavid closed 5 years ago
It's true that objects are in extensions have their classes registered but that they are not instantiated.
I haven't tried this (yet) but it seems like you could instantiate an instance after the MIN_EXTERNAL macro call at the bottom of your source file?
Actually, here is the solution I've used in another extension...
class sampler_extension;
static minwrap<sampler_extension>* s_sampler_extension_instance {};
static symbol s_global_sampler { "global_sampler" };
class sampler_extension : public object<sampler_extension>
{
...
private:
message<> maxclass_setup = { this, "maxclass_setup", MIN_FUNCTION {
s_sampler_extension_instance = (minwrap<sampler_extension>*)c74::max::object_new_typed(symbol("nobox"), symbol("sampler.extension"), 0, nullptr);
s_global_sampler = s_sampler_extension_instance->maxobj();
return {};
}};
};
MIN_EXTERNAL(sampler_extension);
Thanks Tim. Looking back at the source code of my old extension objects (using the C API), I was mistaken in thinking the class was being instantiated automatically, I had actually made the instantiation the responsibility of the connecting objects.
Closing the issue as this the behaviour is the same as the previous API.
For context see #128