Thanks for the insight into more pd internals, although I think I prefer an approach that does not heavily rely on public pointers floating around, like pd_newest (it is funny that it is declared in m_pd.h, but then there is a comment above its implementation that it is a hack, maybe be removed or redesigned). I chose to use glob_evalfile because it is the closest method I can find to opening a patch in the 'normal' way. By the way, if I call pd_newest after glob_evalfile(), will it give me a reference to the patch? I'd try it out, but I don't have my dev machine at the moment.
On Sun, 20 Mar 2011, Rich E wrote:In the meanwhile, a simple workaround is to access the canvas_list global variable and walk the linked list of canvases to figure out what has been added. Sounds like a hack but is much faster than instantiating an object from the linked-list of at least two hundred or thousand names in pd_objectmaker.
Dynamic patch loading/unloading (not dynamic patching) could also be done directly in a pd external, provided the following small patch is accepted (: http://sourceforge.net/tracker/?func=detail&aid=3189135&group_id=55736&atid=478072
Besides, loading a patch with glob_evalfile is not the only way to load a patch. You can also load it through pd_objectmaker by pretending that it is an abstraction. Then you pick up the pointer using pd_newest(). In that case, however, don't bother looking in canvas_list, it's not there.
Once you have a canvas pointer, you can find the $0 easily. It involves using a private interface that you can have by copying a struct definition from pd's source code in the same manner that several externals already use. Right after that, ce_dollarzero is yours.I'm not sure I understand. What are the problems with [namecanvas] ?
Lastly, the $0 value that libpd recovers lets you send signals or messages to a unique patch, without the need of [namecanvas] - a method that causes a bag full of problems in itself when it comes to dynamic patch loading/unloading.
_______________________________________________________________________
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC