[PD-dev] getting the classname in an class
Hans-Christoph Steiner
hans at eds.org
Mon Oct 29 18:39:16 CET 2007
We have a winner! :D
static void entry_save(t_gobj *z, t_binbuf *b)
{
t_entry *x = (t_entry *)z;
t_symbol *classname = atom_getsymbol(binbuf_getvec(x-
>x_obj.te_binbuf));
binbuf_addv(b, "ssiisiiss", gensym("#X"),gensym("obj"),
x->x_obj.te_xpix, x->x_obj.te_ypix,
classname, x->x_width, x->x_height,
x->x_bgcolour, x->x_fgcolour);
binbuf_addv(b, ";");
}
.hc
On Oct 29, 2007, at 12:51 PM, Miller Puckette wrote:
> So you can probably just use x->x_obj.ob_binbuf -- that's the text the
> object is "created" with.
>
>
>
> On Mon, Oct 29, 2007 at 12:36:16PM -0400, Hans-Christoph Steiner
> wrote:
>>
>> I want to get the full classname that an object was instantiated
>> with. Basically, lots of GUI objects use gensym("nbx") in the
>> binbuf_addv() in the save function. This means that if they were
>> instantiated with a namespace prefix, i.e. [iemgui/nbx], the "save"
>> function will save it as [nbx].
>>
>> The "new" function gets the correct classname in the t_symbol it's
>> passed. So the question is how to get this from the object's
>> struct. I understand the concepts, just not how the the data
>> structures are organized.
>>
>> .hc
>>
>> On Oct 29, 2007, at 12:28 PM, Miller Puckette wrote:
>>
>>> Hmm, well, the way Pd gets it is looking in the binbuf. But
>>> perhaps you
>>> need to look in the binbuf for the object you're looking at, not
>>> that of
>>> the containing canvas, no? Or, on the other hand. perhaps you're
>>> trying
>>> to get the name of the abstraction the object is part of?
>>>
>>> cheers
>>> M
>>>
>>> On Sun, Oct 28, 2007 at 10:57:52PM -0400, Hans-Christoph Steiner
>>> wrote:
>>>>
>>>> It sounds like this isn't the way to do it then. But somewhere the
>>>> whole classname with the namespace prefix must be stored for every
>>>> single object instantiated, since it will get written out to the
>>>> file. How do I access that?
>>>>
>>>> .hc
>>>>
>>>> On Oct 28, 2007, at 10:50 PM, Miller Puckette wrote:
>>>>
>>>>> I think the binbuf is always present, but in the case of a top-
>>>>> level
>>>>> canvas, it might be empty; binbuf_getnatom() tells you how many
>>>>> atoms
>>>>> there are.
>>>>>
>>>>> cheers
>>>>> Miller
>>>>>
>>>>> On Sun, Oct 28, 2007 at 10:14:48PM -0400, Hans-Christoph Steiner
>>>>> wrote:
>>>>>>
>>>>>> On Oct 28, 2007, at 8:47 PM, Martin Peach wrote:
>>>>>>
>>>>>>> Hans-Christoph Steiner wrote:
>>>>>>>>
>>>>>>>> I tried this in entry_new() and entry_save(), and in both,
>>>>>>>> "binbuf" ends being nothing useful (i.e. segfault):
>>>>>>>>
>>>>>>>> t_glist *glist = (t_glist *) canvas_getcurrent();
>>>>>>>> t_canvas *canvas = (t_canvas*) glist_getcanvas(glist);
>>>>>>>> t_binbuf *binbuf = canvas->gl_obj.te_binbuf;
>>>>>>>> t_atom *ap = binbuf_getvec(binbuf);
>>>>>>>> t_symbol *classname = atom_getsymbol(ap);
>>>>>>>>
>>>>>>>> What's going on here? Am I doing something wrong?
>>>>>>>>
>>>>>>> I don't know what you're trying to do but it's normal to
>>>>>>> check for
>>>>>>> NULL pointers after each of the above statements. That should
>>>>>>> give
>>>>>>> you a clue.
>>>>>>> I suspect that the binbuf doesn't exist if you didn't
>>>>>>> allocate it
>>>>>>> yourself.
>>>>>>
>>>>>> I am just following IOhannes' code, which he says works (I
>>>>>> haven't
>>>>>> tested it...)
>>>>>>
>>>>>> http://pure-data.cvs.sourceforge.net/pure-data/externals/iem/
>>>>>> iemguts/
>>>>>> src/saveargs.c?view=markup
>>>>>>
>>>>>> Somehow, he magically gets a binbuf with contents in it! ;)
>>>>>>
>>>>>> .hc
>>>>>>
>>>>>>
>>>>>> -----------------------------------------------------------------
>>>>>> --
>>>>>> --
>>>>>> ---
>>>>>> ----
>>>>>>
>>>>>> There is no way to peace, peace is the way. -A.J. Muste
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> PD-dev mailing list
>>>>>> PD-dev at iem.at
>>>>>> http://lists.puredata.info/listinfo/pd-dev
>>>>
>>>>
>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> --
>>>> ---
>>>> ----
>>>>
>>>> You can't steal a gift. Bird gave the world his music, and if
>>>> you can
>>>> hear it, you can have it. - Dizzy Gillespie
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> PD-dev mailing list
>>>> PD-dev at iem.at
>>>> http://lists.puredata.info/listinfo/pd-dev
>>
>>
>>
>> ---------------------------------------------------------------------
>> ---
>> ----
>>
>> All information should be free. - the hacker ethic
>>
>>
>>
------------------------------------------------------------------------
----
"[W]e have invented the technology to eliminate scarcity, but we are
deliberately throwing it away to benefit those who profit from
scarcity." -John Gilmore
More information about the Pd-dev
mailing list