Skip to content
Snippets Groups Projects
Commit 7abf7dbc authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

replace patch_name external with a simple abstraction

parent e8f23c32
No related branches found
No related tags found
Loading
NAME=patch_name
SYM=patch_name
# If you want to use a customized Pd, then define a $PD_PATH variable.
# Otherwise, the Pd must be installed on the system
PD_PATH=../../pd
######################################################
# You shouldn't need to change anything beyond here! #
######################################################
ifdef PD_PATH
PD_INCLUDE := -I$(PD_PATH)/src
PD_EXTRA_PATH := $(PD_PATH)/extra
PD_DOC_PATH := $(PD_PATH)/doc
else
PD_INCLUDE := -I/usr/local/include
PD_EXTRA_PATH := /usr/local/lib/pd/extra
PD_DOC_PATH := /usr/local/lib/pd/doc
endif
# we just use the cwiid that comes with ubuntu/hardy
# although the code still uses the cwiid_internal.h from the
# supplied source
LIBS =
current: pd_linux
##### LINUX:
pd_linux: $(NAME).pd_linux
.SUFFIXES: .pd_linux
LINUXCFLAGS = -DPD -g -funroll-loops -fomit-frame-pointer \
-Wall -Wshadow -Wstrict-prototypes -fPIC
.c.pd_linux:
cc $(LINUXCFLAGS) $(PD_INCLUDE) $(CWIID_INCLUDE) -o $*.o -c $*.c
ld --export-dynamic -shared -o $*.pd_linux $*.o $(LIBS) -lc -lm
#strip --strip-unneeded $*.pd_linux
rm -f $*.o
install:
ifdef ASCAPE_INSTALLED
-cp *help*.pd $(ASCAPE_PATH)/ss_engine/pd/help/.
ifeq ($(findstring Linux,$(ASCAPE_OS)),Linux)
-cp *.pd_linux $(ASCAPE_PATH)/ss_engine/pd/externs/$(ASCAPE_OS)$(ASCAPE_ARCH)/.
endif
ifeq ($(findstring Darwin,$(SS_OS)),Darwin)
-cp *.pd_darwin $(ASCAPE_PATH)/ss_engine/pd/externs/$(ASCAPE_OS)$(ASCAPE_ARCH)/.
endif
endif
-cp *.pd_linux $(PD_EXTRA_PATH)/.
-cp *help*.pd $(PD_DOC_PATH)/.
clean:
-rm -f *.o *.pd_* so_locations
#include <stdio.h>
#include <string.h>
#include <m_pd.h>
#include "g_canvas.h"
#define DEBUG(x)
static t_class *patch_name_class;
static t_canvas *canvas;
typedef struct _patch_name
{
t_object x_obj;
t_atom x_atom;
t_canvas *x_canvas;
t_symbol *x_patch_name;
t_symbol *x_patch_path;
t_symbol *x_remote_name;
t_outlet *x_outlet_path;
t_outlet *x_outlet_name;
} t_patch_name;
static void patch_name_bang(t_patch_name *x)
{
char buf[MAXPDSTRING];
snprintf(buf, MAXPDSTRING, "%s", x->x_canvas->gl_name->s_name);
x->x_patch_name = gensym(buf);
snprintf(buf, MAXPDSTRING, "%s", canvas_getdir(x->x_canvas)->s_name);
x->x_patch_path = gensym(buf);
outlet_symbol(x->x_outlet_name, x->x_patch_name);
outlet_symbol(x->x_outlet_path,x->x_patch_path);
}
static void *patch_name_new(t_symbol *s, int argc, t_atom *argv)
{
t_atom a;
if (argc == 0)
{
argc = 1;
SETFLOAT(&a, 0);
argv = &a;
}
t_patch_name *x = (t_patch_name *)pd_new(patch_name_class);
x->x_atom = *argv;
t_glist *glist=(t_glist *)canvas_getcurrent();
x->x_canvas=(t_canvas *)glist_getcanvas(glist);
if (argv->a_type == A_FLOAT)
{
int depth=(int)atom_getint(&x->x_atom);
if(depth<0)depth=0;
while(depth && x->x_canvas->gl_owner) {
x->x_canvas=x->x_canvas->gl_owner;
depth--;
}
}
else
{
x->x_remote_name = (t_symbol *)atom_getsymbol(&x->x_atom);
}
x->x_outlet_path = outlet_new(&x->x_obj, &s_symbol);
x->x_outlet_name = outlet_new(&x->x_obj, &s_symbol);
return(x);
}
void patch_name_setup(void)
{
patch_name_class = class_new(gensym("patch_name"),
(t_newmethod)patch_name_new, NULL,
sizeof(t_patch_name), 0, A_GIMME, 0);
class_addbang(patch_name_class, (t_method)patch_name_bang);
}
#N canvas 381 136 399 196 10;
#X obj 68 39 inlet;
#X obj 68 119 canvasinfo 1;
#X obj 167 119 canvasinfo 1;
#X obj 68 61 trigger bang bang;
#X msg 167 91 filename;
#X msg 68 91 dir;
#X obj 68 141 outlet;
#X obj 167 141 outlet;
#X text 209 30 2016 Jonathan Wilkes;
#X connect 0 0 3 0;
#X connect 1 0 6 0;
#X connect 2 0 7 0;
#X connect 3 0 5 0;
#X connect 3 1 4 0;
#X connect 4 0 2 0;
#X connect 5 0 1 0;
......@@ -273,9 +273,7 @@ then
mkdir -p ../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra/images
# patch_name
cd ../../l2ork_addons/patch_name
make clean
make
cp -f patch_name.pd_linux ../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra
cp -f patch_name.pd ../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra
cp -f patch_name-help.pd ../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra
# disis_wiimote
cd ../disis_wiimote
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment