Skip to content

object_method implementation doesn't support decorator objects #22

@robtherich

Description

@robtherich

https://cycling74.com/forums/matrix_calc-documentation-wrong-several-sdk-examples-of-matrix-mop-fail

quoth JKC:

The limitation is that the Max-API headers, rather than calling object_method_imp() like the Max SDK does, uses c++ style function overloading, and specifically calls object_getmethod() to establish which method to call. With Jitter MOP IO objects, there is an esoteric feature of our object system called decorators, which enable one object to be added to an existing object to provide an additional set of methods. object_getmethod() does not support retrieving the correct "getinfo" methods from the objects they decorate. object_method() and object_method_imp() from the standard SDK on the other hand correctly resolves them.

This is an oversight in the object_getmethod() implementation, which will be corrected in a future version of Max. However, that doesn't help your legacy context if you still are determined to use the Max-API. For that, the better solution is to change the Max-API implementation to call object_method_imp() rather than calling the results of object_getmethod(). For example the following and all similar
inline void* object_method(t_object* target_object, t_symbol* method_name) {
method m = object_getmethod(target_object, method_name);
if (m)
return m(target_object);
else
return nullptr;
}
Should be changed to
inline void* object_method(t_object* target_object, t_symbol* method_name) {
return object_method_imp(target_object, method_name, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions