Hi.
I'm starting to dwelve into pd's C side of things. I'm having a really hard time figuring stuff out. (i have mainly experience with more high-level languages like Java, etc)
I'm trying to experiment with some editor features and i've been wandering:
why the _inlet and _outlet structures are defined in m_obj.c instead of m_pd.h ?
This way i can't access the structure members. I'm trying to traverse an t_object's t_outlets linked list but
t_outlet *o = selected_object->te_outlet; o = o->o_next; but this throws me an "dereferencing incomplete type" error since there is no definition for t_outlet inside m_pd.
The same goes for accessing members of t_outconnect for example, but there are two methods that allows you to traverse the connections linked list obj_starttraverseoutlet() (m_imp.h)(m_obj.c) obj_nexttraverseoutlet() (m_imp.h)(m_obj.c) But i couldn't find any method to traverse an t_object's linked list of t_outlets. The only three methods that seems to return t_outlets pointers are
t_outlet *outlet_new(t_object *owner, t_symbol *s) (m_obj.c) t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s) (g_graph.c) and t_outlet *voutlet_getit(t_pd *x) (g_io.c) which i currently do not understand but doesn't seem to be what i'm looking for.
How could i traverse from, lets say the g_editor.c file, all the t_inlets and t_outlets of an t_object?
Btw, on a second question, what exactly are vinlets and voutlets?
Cheers, Henri.
Hi Henri -
This is a reflection of Pd's extremely data-hiding programming style - the idea is to keep the structures hidden so that if they are changed it doesn't break stuff.
And yes, it gets awkward in spots - especially because ugen sorting and the like have to have accessor functions that count inlets/outlets and so on.
The way Pd's internal code finds out about connections (in order to draw them for instance) can be seen in the function canvas_drawlines() for example - which uses the functions linetraverser_start() and linetraverser_next() to find them.
cheers Miller
On Tue, Nov 20, 2018 at 04:37:03PM +0000, Henri Augusto Bisognini wrote:
Hi.
I'm starting to dwelve into pd's C side of things. I'm having a really hard time figuring stuff out. (i have mainly experience with more high-level languages like Java, etc)
I'm trying to experiment with some editor features and i've been wandering:
why the _inlet and _outlet structures are defined in m_obj.c instead of m_pd.h ?
This way i can't access the structure members. I'm trying to traverse an t_object's t_outlets linked list but
t_outlet *o = selected_object->te_outlet; o = o->o_next; but this throws me an "dereferencing incomplete type" error since there is no definition for t_outlet inside m_pd.
The same goes for accessing members of t_outconnect for example, but there are two methods that allows you to traverse the connections linked list obj_starttraverseoutlet() (m_imp.h)(m_obj.c) obj_nexttraverseoutlet() (m_imp.h)(m_obj.c) But i couldn't find any method to traverse an t_object's linked list of t_outlets. The only three methods that seems to return t_outlets pointers are
t_outlet *outlet_new(t_object *owner, t_symbol *s) (m_obj.c) t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s) (g_graph.c) and t_outlet *voutlet_getit(t_pd *x) (g_io.c) which i currently do not understand but doesn't seem to be what i'm looking for.
How could i traverse from, lets say the g_editor.c file, all the t_inlets and t_outlets of an t_object?
Btw, on a second question, what exactly are vinlets and voutlets?
Cheers, Henri.
Pd-dev mailing list Pd-dev@lists.iem.at https://lists.puredata.info/listinfo/pd-dev
Hi, you can actually use obj_starttraverseoutlet() to traverse the outlets like this:
// x is your object t_outlet *outlet; int nout = obj_noutlets(x); for (int i = 0; i < nout; ++i){ obj_starttraverseoutlet(x, &outlet, i); // do something with outlet }
obj_starttraverseoutlet returns the connections from this outlet to other ojects (which you can traverse with obj_nexttraverseoutlet), but it also gives you the outlet via the second parameter (a t_outlet** so it can change your t_outlet* to point to the right outlet).
note that those functions are not part of the public API, so use with caution.
Christof
Gesendet: Dienstag, 20. November 2018 um 17:37 Uhr Von: "Henri Augusto Bisognini" msndohenri@hotmail.com An: "pd-dev@lists.iem.at" pd-dev@lists.iem.at Betreff: [PD-dev] why some structs are defined in m_obj.c? + what are vinlets and voutlets?
Hi. I'm starting to dwelve into pd's C side of things. I'm having a really hard time figuring stuff out. (i have mainly experience with more high-level languages like Java, etc) I'm trying to experiment with some editor features and i've been wandering: why the _inlet and _outlet structures are defined in m_obj.c instead of m_pd.h ? This way i can't access the structure members. I'm trying to traverse an t_object's t_outlets linked list but t_outlet *o = selected_object->te_outlet; o = o->o_next; but this throws me an "dereferencing incomplete type" error since there is no definition for t_outlet inside m_pd. The same goes for accessing members of t_outconnect for example, but there are two methods that allows you to traverse the connections linked list obj_starttraverseoutlet() (m_imp.h)(m_obj.c) obj_nexttraverseoutlet() (m_imp.h)(m_obj.c)
But i couldn't find any method to traverse an t_object's linked list of t_outlets. The only three methods that seems to return t_outlets pointers are t_outlet *outlet_new(t_object *owner, t_symbol *s) (m_obj.c) t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s) (g_graph.c) and t_outlet *voutlet_getit(t_pd *x) (g_io.c) which i currently do not understand but doesn't seem to be what i'm looking for. How could i traverse from, lets say the g_editor.c file, all the t_inlets and t_outlets of an t_object? Btw, on a second question, what exactly are vinlets and voutlets? Cheers, Henri._______________________________________________ Pd-dev mailing list Pd-dev@lists.iem.at https://lists.puredata.info/listinfo/pd-dev
Thanks a lot for the info Christof, IOhannes and Miller. Everything is starting to make sense :)
Is there any kind of document containing development guidelines or an explanation of the inner workings of PD?
The closest i could find is the ChangeLog.txt (which contained precious information that really helped me get started) in the "original source notes" section . https://github.com/pure-data/pure-data/blob/master/src/CHANGELOG.txt#L135
Cheers, Henri.
________________________________ De: Christof Ressi christof.ressi@gmx.at Enviado: terça-feira, 20 de novembro de 2018 15:29 Para: Henri Augusto Bisognini Cc: pd-dev@lists.iem.at Assunto: Aw: [PD-dev] why some structs are defined in m_obj.c? + what are vinlets and voutlets?
Hi,
you can actually use obj_starttraverseoutlet() to traverse the outlets like this:
// x is your object t_outlet *outlet; int nout = obj_noutlets(x); for (int i = 0; i < nout; ++i){ obj_starttraverseoutlet(x, &outlet, i); // do something with outlet }
obj_starttraverseoutlet returns the connections from this outlet to other ojects (which you can traverse with obj_nexttraverseoutlet), but it also gives you the outlet via the second parameter (a t_outlet** so it can change your t_outlet* to point to the right outlet).
note that those functions are not part of the public API, so use with caution.
Christof
Gesendet: Dienstag, 20. November 2018 um 17:37 Uhr Von: "Henri Augusto Bisognini" msndohenri@hotmail.com An: "pd-dev@lists.iem.at" pd-dev@lists.iem.at Betreff: [PD-dev] why some structs are defined in m_obj.c? + what are vinlets and voutlets?
Hi.
I'm starting to dwelve into pd's C side of things. I'm having a really hard time figuring stuff out. (i have mainly experience with more high-level languages like Java, etc)
I'm trying to experiment with some editor features and i've been wandering:
why the _inlet and _outlet structures are defined in m_obj.c instead of m_pd.h ?
This way i can't access the structure members. I'm trying to traverse an t_object's t_outlets linked list but
t_outlet *o = selected_object->te_outlet; o = o->o_next; but this throws me an "dereferencing incomplete type" error since there is no definition for t_outlet inside m_pd.
The same goes for accessing members of t_outconnect for example, but there are two methods that allows you to traverse the connections linked list obj_starttraverseoutlet() (m_imp.h)(m_obj.c) obj_nexttraverseoutlet() (m_imp.h)(m_obj.c)
But i couldn't find any method to traverse an t_object's linked list of t_outlets. The only three methods that seems to return t_outlets pointers are
t_outlet *outlet_new(t_object *owner, t_symbol *s) (m_obj.c) t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s) (g_graph.c) and t_outlet *voutlet_getit(t_pd *x) (g_io.c) which i currently do not understand but doesn't seem to be what i'm looking for.
How could i traverse from, lets say the g_editor.c file, all the t_inlets and t_outlets of an t_object?
Btw, on a second question, what exactly are vinlets and voutlets?
Cheers, Henri._______________________________________________ Pd-dev mailing list Pd-dev@lists.iem.at https://lists.puredata.info/listinfo/pd-dev
On 11/20/18 5:37 PM, Henri Augusto Bisognini wrote:
why the _inlet and _outlet structures are defined in m_obj.c instead of m_pd.h ?
because that makes them "private" (as opposed to bein part of a public-API (m_pd.h) or a semi-public API (the other header files).
This way i can't access the structure members.
exactly. that was the point of the exercise.
of course it is sometimes disappointing to not have direct access to the data structures you (think you) need. but for the overall API stability of Pd as a whole, private data structures are a very good thing. i wish, more structs would be private.
gfmdsr IOhannes