Forums > Dev

A_GIMMEBACK routine appears in quickref menu

October 30, 2010 | 12:18 pm

Hi,

I’ve implemented a method that should only ever be called by other objects behind the scenes that has a return value. The method is declared as taking A_GIMMEBACK. Everything works, but the method turns up in the quickref, which I’d rather it didn’t. Have I done this the right way, or is there a better one, or should I just live with it?

Thanks

Alex


October 30, 2010 | 1:01 pm

You can make a method disappear from the quickref menu using the undocumented keyword.

CLASS_METHOD_ATTR_PARSE(c, "mymethod", "undocumented", gensym("long"), 0L, "1");


October 30, 2010 | 1:41 pm

Thanks ej. ILooks like this is viable only for the Max 5 SDK – is that right? No big deal either way, just still interested in Max 4.6 support as far as possible….


October 30, 2010 | 5:01 pm

You could just use A_CANT, and call using object_method() instead of object_method_typed(). You’ll need to double the symbol arg in such a case, since object_method() pops the symbol and passes on any following arguments blindly.

Hope this helps.

Joshua


October 31, 2010 | 10:09 am

Thanks Joshua. That looks straightforward enough. It’s a minor issue – just trying to make some stuff look neat and tidy for release!

A.


November 7, 2010 | 10:57 am

Hi Joshua. I’ve implemented as a CANT and that works fine.

I’m not sure what you mean about doubling the symbol argument. My function has no arguments and here is what I’m doing. Is this safe / correct ?

// Declaring the method

class_addmethod (this_class, (method)ibuffer_valid, "valid", A_CANT, 0);

// The function

void *ibuffer_valid (t_ibuffer *x, t_symbol *s)
{
return (void *) &x->valid;
}

// How I’m calling it from another object

valid_val = (long *) object_method(current_buffer, ps_valid);

Thanks for your help.

Alex


November 7, 2010 | 11:38 pm

You don’t need to worry about what I recommended then. Your method is technically not A_GIMMEBACK, and should have always been defined as A_CANT.

A_GIMMEBACK is for typed messages of the form:

t_max_err mymethod(t_object *x, t_symbol *s, long argc, t_atom *argv, t_atom *returnvalue);

This is a required signature for returning values to JS, Java, Lua, etc. via the language bindings.

In the case of calling such methods you would need to call it like this:

object_method_typed(x,gensym("foo"),argc, argv, &rv);

Or as untyped with:

object_method(x,gensym("foo"),gensym("foo",argc,argv,&rv));

Note the double symbol since object_method does not pass the symbolic message selector on to the method it is calling. It pushes anything following it onto the stack, so places which expect to receive the symbolic message selector such as A_GIMME, or A_GIMMEBACK functions require supplying the symbolic message selector twice. The reason for this can be demonstrated by the following untyped method calling of a function which, if typed, would have the signature A_LONG:

object_method(x,gensym("bar"),27);

would be used to call the following function with an argument of 27, (no symbol)

mybar(t_object *x, long x);

I know that this might be a little confusing, and I don’t have time to discuss in more detail, but I hope this helps. A related thread is here:

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

-Joshua


November 8, 2010 | 7:59 am

OK – got it – not confusing at all – thanks Joshua. Now I understand what is going on and looks like I can actually define the function:

void *ibuffer_valid (t_ibuffer *x)
{
return (void *) &x->valid;
}

I think I originally tried implementing as a CANT but couldn’t get it to work for some reason I forget so tried A_GIMMEBACK. Now I will know what to do in future in either case. Thanks again for your time.

A.


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