Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapper: add readdump message #439

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions source/include/FluidMaxWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,18 @@ class FluidMaxWrapper

makeReferable();

// Register messages for object
m.template iterate<SetupMessage>();
// If valid read() and dump() messages were found, SetupMessage also
// registered A_CANT methods of the direct doRead /doDump, so we can setup a
// readdump() without needing to know about any template woowoo:
method doRead = class_method(getClass(), gensym("doRead"));
method doDump = class_method(getClass(), gensym("doDump"));
if(doRead && doDump)
{
class_addmethod(getClass(), (method) deferReadDump, "readdump", A_DEFSYM,
0);
}

class_addmethod(getClass(), (method) doVersion, "version", 0);
// Change for MSVC, which didn't like the macro version
Expand Down Expand Up @@ -1998,6 +2009,9 @@ class FluidMaxWrapper
class_addmethod(getClass(),
(method) deferDump<decltype(M)::value>,
lowerCase(message.name).c_str(), A_GIMME, 0);
class_addmethod(getClass(),
(method) doDump<decltype(M)::value>,
"doDump", A_CANT, 0);
});
return;
}
Expand Down Expand Up @@ -2028,6 +2042,9 @@ class FluidMaxWrapper
class_addmethod(getClass(),
(method) deferRead<decltype(M)::value>,
lowerCase(message.name).c_str(), A_DEFSYM, 0);
class_addmethod(getClass(),
(method) doRead<decltype(M)::value>,
"doRead", A_CANT, 0);
});
return;
}
Expand Down Expand Up @@ -2204,6 +2221,25 @@ class FluidMaxWrapper
object_obex_dumpout(x, gensym("dump"), 2, a);
}

static void deferReadDump(FluidMaxWrapper* x, t_symbol* s, long, t_atom*)
{
defer_low(x, (method) doReadDump, s, 0, nullptr);
}

static void doReadDump(FluidMaxWrapper* x, t_symbol* s, long, t_atom*)
{
using ReadSig = void (*)(FluidMaxWrapper*, t_symbol*);
using DumpSig = void (*)(FluidMaxWrapper*, t_symbol*, long, t_atom*);

ReadSig fRead = (ReadSig) (object_method_direct_getmethod(
(t_object*) x, gensym("doRead")));
DumpSig fDump = (DumpSig) (object_method_direct_getmethod(
(t_object*) x, gensym("doDump")));

fRead(x, s);
fDump(x, nullptr, 0, nullptr);
}

template <size_t N>
static void deferPrint(FluidMaxWrapper* x, t_symbol*, long, t_atom*)
{
Expand Down