Forums > Dev

obRe: internal external inside my external: newinstance() or obex?

August 13, 2007 | 6:52 pm

Hi,
I’m trying to figure out how can we make a instance of a standard
external (let say [coll]) inside our own externals, send it messages
and receive its oulets results.

I tried with newinstance(). Here’s the result:

// This works!//////////////////////////////////////////////
t_atom arg;
arg.a_type = A_SYM;
arg.a_w.w_sym = gensym("myfile.col");

t_object *my_coll = newinstance(gensym("coll"),1,&argu)
//////////////////////////////////////////////////////////////////////////////////

// This works too///////////////////////////////////////
mess2(my_coll, gensym("open"), 0, 0L);
//////////////////////////////////////////////////////////////////////////////////

/* EXPLANATION
I create an instance of [coll] with a file name as argument.
Then, I ask it to open its window to see its contents. It works great!
*/
//////////////////////////////////////////////////////////////////////////////////

But, my attempts to store data inside my [coll] or call its contents
have failed:

////////////////////////////////////////////////////////////////////////////
// This doesn’t work ("error: coll: bad arguments for message ‘store’)
// Compiler warnings: passing argument 2 of ‘getfn(my_coll, gensym("store"))’
// makes pointer from integer without a cast
//////////////////////////////////////////////////////////////////////////////////
t_atom args[2];
args[0].a_type = A_LONG
args[0].a_w.w_long = 1;
args[1].a_type = A_LONG;
args[1].a_w.w_long = 5;

mess2(my_coll, gensym("store"), 2, &args);
////////////////////////////////////////////////////////////////////////////

I have seen that my internal [coll] would be easier to manage with
obex-style programming.

So I’ve tried this inside a obex-style object with no success. :

////////////////////////////////////////////////////////////////////////////

t_atom args;
args.a_type = A_SYM;
args.a_w.w_sym = gensym("myfile.col");

void *colli = object_new_typed( CLASS_NOBOX, gensym("coll"),1,&args);

object_getmethod(colli,gensym("open"));

/* EXPLANATION
I create an instance of [coll] with a file name as argument.
Then, I ask it to open its window to see its contents. But
the coll’s window don’t pop up.
*/
//////////////////////////////////////////////////////////////////////////////////

I’m quite desesperate right now, so I’m asking for your help. Does
anybody can see what’s the problem inside my code? Does OBEX is a good
move for helping me in this issue? Is there an available example of a
similar project?

Regards
PC


August 17, 2007 | 12:32 am

Well, I’d love to be proved wrong, but I have some kind of vague
memory that this can’t be done (yet?)

On Aug 13, 2007, at 11:52 AM, P C wrote:

> Hi,
> I’m trying to figure out how can we make a instance of a standard
> external (let say [coll]) inside our own externals, send it messages
> and receive its oulets results.
>
> I tried with newinstance(). Here’s the result:
>
> // This works!//////////////////////////////////////////////
> t_atom arg;
> arg.a_type = A_SYM;
> arg.a_w.w_sym = gensym("myfile.col");
>
> t_object *my_coll = newinstance(gensym("coll"),1,&argu)
> //////////////////////////////////////////////////////////////////////
> ////////////
>
>
> // This works too///////////////////////////////////////
> mess2(my_coll, gensym("open"), 0, 0L);
> //////////////////////////////////////////////////////////////////////
> ////////////
>
> /* EXPLANATION
> I create an instance of [coll] with a file name as argument.
> Then, I ask it to open its window to see its contents. It works great!
> */
> //////////////////////////////////////////////////////////////////////
> ////////////
>
>
>
>
>
> But, my attempts to store data inside my [coll] or call its contents
> have failed:
>
>
> //////////////////////////////////////////////////////////////////////
> //////
> // This doesn’t work ("error: coll: bad arguments for message ‘store’)
> // Compiler warnings: passing argument 2 of ‘getfn(my_coll, gensym
> ("store"))’
> // makes pointer from integer without a cast
> //////////////////////////////////////////////////////////////////////
> ////////////
> t_atom args[2];
> args[0].a_type = A_LONG
> args[0].a_w.w_long = 1;
> args[1].a_type = A_LONG;
> args[1].a_w.w_long = 5;
>
> mess2(my_coll, gensym("store"), 2, &args);
> //////////////////////////////////////////////////////////////////////
> //////
>
>
>
> I have seen that my internal [coll] would be easier to manage with
> obex-style programming.
>
>
> So I’ve tried this inside a obex-style object with no success. :
>
> //////////////////////////////////////////////////////////////////////
> //////
>
> t_atom args;
> args.a_type = A_SYM;
> args.a_w.w_sym = gensym("myfile.col");
>
> void *colli = object_new_typed( CLASS_NOBOX, gensym("coll"),1,&args);
>
> object_getmethod(colli,gensym("open"));
>
>
> /* EXPLANATION
> I create an instance of [coll] with a file name as argument.
> Then, I ask it to open its window to see its contents. But
> the coll’s window don’t pop up.
> */
> //////////////////////////////////////////////////////////////////////
> ////////////
>
>
> I’m quite desesperate right now, so I’m asking for your help. Does
> anybody can see what’s the problem inside my code? Does OBEX is a good
> move for helping me in this issue? Is there an available example of a
> similar project?
>
> Regards
> PC

grrr waaa
http://www.grahamwakefield.net


August 17, 2007 | 2:27 pm

Thanks for your reply Graham,
Actually, as seen in my code, newinstance() really creates an instance
of [coll]: when I send it the message "open", its window appears with
its content, proving it knew what to do with the "myfile.col"
argument. Also,I have a vague memory about using [buffer~] inside msp
external code.

However, if somebody can confirm that this can be done or not, please
let us know.

I repeat the goal: create an instance of [coll] inside an external and
communicate with it. Kind of "make a patch in C", inside my
external…

Thank you very much,
PC

On 8/16/07, Graham Wakefield

wrote:
> Well, I’d love to be proved wrong, but I have some kind of vague memory that
> this can’t be done (yet?)
>
>
> On Aug 13, 2007, at 11:52 AM, P C wrote:
>
> Hi,
> I’m trying to figure out how can we make a instance of a standard
> external (let say [coll]) inside our own externals, send it messages
> and receive its oulets results.
>
> I tried with newinstance(). Here’s the result:
>
> // This
> works!//////////////////////////////////////////////
> t_atom arg;
> arg.a_type = A_SYM;
> arg.a_w.w_sym = gensym("myfile.col");
>
> t_object *my_coll = newinstance(gensym("coll"),1,&argu)
> //////////////////////////////////////////////////////////////////////////////////
>
>
> // This works too///////////////////////////////////////
> mess2(my_coll, gensym("open"), 0, 0L);
> //////////////////////////////////////////////////////////////////////////////////
>
> /* EXPLANATION
> I create an instance of [coll] with a file name as argument.
> Then, I ask it to open its window to see its contents. It works great!
> */
> //////////////////////////////////////////////////////////////////////////////////
>
>
>
>
>
> But, my attempts to store data inside my [coll] or call its contents
> have failed:
>
>
> ////////////////////////////////////////////////////////////////////////////
> // This doesn’t work ("error: coll: bad arguments for message ‘store’)
> // Compiler warnings: passing argument 2 of ‘getfn(my_coll,
> gensym("store"))’
> // makes pointer from integer without a cast
> //////////////////////////////////////////////////////////////////////////////////
> t_atom args[2];
> args[0].a_type = A_LONG
> args[0].a_w.w_long = 1;
> args[1].a_type = A_LONG;
> args[1].a_w.w_long = 5;
>
> mess2(my_coll, gensym("store"), 2, &args);
> ////////////////////////////////////////////////////////////////////////////
>
>
>
> I have seen that my internal [coll] would be easier to manage with
> obex-style programming.
>
>
> So I’ve tried this inside a obex-style object with no success. :
>
> ////////////////////////////////////////////////////////////////////////////
>
> t_atom args;
> args.a_type = A_SYM;
> args.a_w.w_sym = gensym("myfile.col");
>
> void *colli = object_new_typed( CLASS_NOBOX, gensym("coll"),1,&args);
>
> object_getmethod(colli,gensym("open"));
>
>
> /* EXPLANATION
> I create an instance of [coll] with a file name as argument.
> Then, I ask it to open its window to see its contents. But
> the coll’s window don’t pop up.
> */
> //////////////////////////////////////////////////////////////////////////////////
>
>
> I’m quite desesperate right now, so I’m asking for your help. Does
> anybody can see what’s the problem inside my code? Does OBEX is a good
> move for helping me in this issue? Is there an available example of a
> similar project?
>
> Regards
> PC
>
> grrr waaa
> http://www.grahamwakefield.net
>
>
>
>
>
>
>


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