Skip to content

Commit 3011112

Browse files
committed
glist_findrtext -> glist_getrtext
closes #75
1 parent 4301f74 commit 3011112

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

pdlua.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@
5959

6060
#include "pdlua_gfx.h"
6161

62-
typedef void (*t_signal_setmultiout)(t_signal **, int);
63-
static t_signal_setmultiout g_signal_setmultiout;
62+
// function pointer type for signal_setmultiout (added with Pd 0.54)
63+
typedef void (*t_signal_setmultiout_fn)(t_signal **, int);
64+
static t_signal_setmultiout_fn g_signal_setmultiout;
65+
66+
// function pointer type for glist_getrtext/glist_findrtext (changes with Pd 0.55-3)
67+
typedef t_rtext *(*t_glist_rtext_fn)(t_glist *, t_text *);
68+
static t_glist_rtext_fn g_glist_getrtext = NULL;
6469

6570
// This used to be in s_stuff.h, but not anymore since 0.55.1test1.
6671
int sys_trytoopenone(const char *dir, const char *name, const char* ext,
@@ -1315,7 +1320,7 @@ static int pdlua_set_arguments(lua_State *L)
13151320
if (redraw) {
13161321
// update the text in the object box; this makes sure that
13171322
// the arguments in the display are what we just set
1318-
t_rtext *y = glist_findrtext(o->canvas, x);
1323+
t_rtext *y = g_glist_getrtext(o->canvas, x);
13191324
rtext_retext(y);
13201325
// redraw the object and its iolets (including incident
13211326
// cord lines), in case the object box size has changed
@@ -3042,21 +3047,29 @@ void pdlua_setup(void)
30423047
#endif
30433048
post(luaversionStr);
30443049

3045-
// multichannel handling copied from https://github.com/Spacechild1/vstplugin/blob/3f0ed8a800ea238bf204a2ead940b2d1324ac909/pd/src/vstplugin~.cpp#L4122-L4136
3050+
// compatibility handling copied from https://github.com/Spacechild1/vstplugin/blob/3f0ed8a800ea238bf204a2ead940b2d1324ac909/pd/src/vstplugin~.cpp#L4122-L4136
30463051
#ifdef _WIN32
30473052
// get a handle to the module containing the Pd API functions.
30483053
// NB: GetModuleHandle("pd.dll") does not cover all cases.
30493054
HMODULE module;
30503055
if (GetModuleHandleEx(
30513056
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
30523057
(LPCSTR)&pd_typedmess, &module)) {
3053-
g_signal_setmultiout = (t_signal_setmultiout)(void *)GetProcAddress(
3058+
g_signal_setmultiout = (t_signal_setmultiout_fn)(void *)GetProcAddress(
30543059
module, "signal_setmultiout");
3060+
g_glist_getrtext = (t_glist_rtext_fn)GetProcAddress(module, "glist_getrtext");
3061+
if (!g_glist_getrtext)
3062+
g_glist_getrtext = (t_glist_rtext_fn)GetProcAddress(module, "glist_findrtext");
30553063
}
30563064
#else
30573065
// search recursively, starting from the main program
3058-
g_signal_setmultiout = (t_signal_setmultiout)dlsym(
3066+
g_signal_setmultiout = (t_signal_setmultiout_fn)dlsym(
30593067
dlopen(NULL, RTLD_NOW), "signal_setmultiout");
3068+
g_glist_getrtext = (t_glist_rtext_fn)dlsym(
3069+
dlopen(NULL, RTLD_NOW), "glist_getrtext");
3070+
if (!g_glist_getrtext)
3071+
g_glist_getrtext = (t_glist_rtext_fn)dlsym(
3072+
dlopen(NULL, RTLD_NOW), "glist_findrtext");
30603073
#endif
30613074

30623075
pdlua_proxyinlet_setup();

pdlua_gfx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,8 @@ static int start_paint(lua_State* L) {
831831

832832
#ifdef PURR_DATA
833833
if (gfx->object_tag[0] == '*') {
834-
// late initialization, deferred until glist_findrtext will work
835-
t_rtext *y = glist_findrtext(obj->canvas, (t_text*)obj);
834+
// late initialization, deferred until glist_getrtext will work
835+
t_rtext *y = glist_getrtext(obj->canvas, (t_text*)obj);
836836
if (y) {
837837
const char *s = rtext_gettag(y);
838838
strcpy(gfx->object_tag, s);

0 commit comments

Comments
 (0)