Forums > Dev

Max 5 obex

November 16, 2008 | 2:46 am

Hello,

When using Attributes, is it no longer in Max 5 (or was it never really) necessary to have a:

void *obex;

in our object struct, and call:

class_obexoffset_set(myclass, calcoffset(myobject, obex));

in main()

?

I think I’ve looked at all the new examples as none seem to use this. Although I see the t_jbox struct contains a field which is called "obex".


November 16, 2008 | 3:47 am

Hi Martin,

Very observant. It is correct that you no longer need to define an
obex explicitly. Now one will be allocated automatically in a top
secret location the first time you need one. If you don’t want to
change your code, or if you still want access to it for some reason in
the older way, caching it in your object struct, it is perfectly fine
as well. So no need to change it if you’ve already written your object
in this way, and no need to add it if you haven’t. Simply use
object_obex_lookup/store() as usual, and the magic is handled for you.

-Joshua


November 16, 2008 | 4:11 am

On Nov 16, 2008, at 4:47 AM, Joshua Kit Clayton wrote:

> So no need to change it if you’ve already written your object in
> this way, and no need to add it if you haven’t. Simply use
> object_obex_lookup/store() as usual, and the magic is handled for you.

Sorry, there is one reason you might want to still use void *obex in
your object struct, and call class_obexoffset_set(myclass,
calcoffset(myobject, obex)); If you want your object to work in Max 4
and Max5 and have attributes. Max 4 doesn’t implicitly create this
resource behind the scenes when necessary, and it needs the storage in
your object.

-Joshua


November 16, 2008 | 3:20 pm

Thanks Joshua,

I just wanted to clarify – as I’ll be teaching this to others.


Viewing 4 posts - 1 through 4 (of 4 total)