graham wakefield maxcpp, REGISTER_METHOD issues

Dec 24, 2011 at 2:59pm

graham wakefield maxcpp, REGISTER_METHOD issues

Hello,
I’m trying to use the c++ wrapper maxcpp and i have some problem with register methods.
With example.cpp and example~.cpp the only working register method is REGISTER_METHOD(Example, bang);

The other ones (REGISTER_METHOD_FLOAT, REGISTER_METHOD_INT) , don’t do anything at runtime.

In my patch two strange things occurs.
I can’t plug a float or an int on the leftmost inlet.
When i plug a float on the second inlet and change the value i have the following message:
Example~doesn’t understand “float”
(same problem with int and every other messages other than bang)

Any ideas ?

Configuration:
OSX 10.6.7
XCode 3.2.6
MAX/MSP SDK 5.1.7
Last version of maxcpp

Thx
Julien

#60843
Apr 2, 2012 at 11:09am

Hi Julien,

int and float are types and reserved words.
Replace the #METHOD in both macros like here below

#define INLET_LONG(CLASS, METHOD) class_addmethod(
(t_class *)CLASS::m_class,
(method)CLASS::InletLong< &CLASS::METHOD>::call,
“int”,
A_LONG,
0);
#define INLET_FLOAT(CLASS, METHOD) class_addmethod(
(t_class *)CLASS::m_class,
(method)CLASS::InletFloat< &CLASS::METHOD>::call,
“float”,
A_FLOAT,
0);

Functor in maxCppBase are defined like this

typedef void (T::*inletlong)(long inlet, long v);
template struct InletLong {
static void call(T * x, long v) { ((x)->*F)(proxy_getinlet((t_object *)x), v); }
};
typedef void (T::*inletfloat)(long inlet, double v);
template struct InletFloat {
static void call(T * x, double v) { ((x)->*F)(proxy_getinlet((t_object*)x), v); }
};

In your (derived) object, declare your method like in “main”:
INLET_FLOAT(fdscales, float_inlet); // float is c++ reserved so REGISTER_METHOD_FLOAT is typed with “float”
INLET_LONG(fdscales, int_inlet); // int is c++ reserved so REGISTER_METHOD_LONG is typed with “int”

Your object method will look like :
void int_inlet(long inlet, long v) {
switch (inlet) {
case 0:
post(“inlet 0 %ld”,v);
break;
case 1:
break;
post(“inlet 1 : %ld”,v);
default:
break;
}

}

void float_inlet(long inlet, double v) {
/*
your code
*/
}

The int and float boxes will then be accepted by your object.

I have a ticket open on jdataview, if you can help …

http://cycling74.com/forums/topic.php?id=39039

#219069
Apr 7, 2014 at 10:07am

Hi,
I’ve the same problem as Julien. I’m not an expert in C++ template. I think there are Macros to update in the Maxcpp6.h .

Could you update your code to have more explanation ???

I try to archive this.
void testfloatplus2(long inlet, double v) {
outlet_float(m_outlet[0], v+2);
}
should have N+2 as output in the max environment.

#285934

You must be logged in to reply to this topic.