Commit 08003774 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

backported Jonathan Wilkes' info classes

parent 7f11fa36
......@@ -555,6 +555,8 @@ EXTERN void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir);
EXTERN void canvas_loadbang(t_canvas *x);
EXTERN int canvas_hitbox(t_canvas *x, t_gobj *y, int xpos, int ypos,
int *x1p, int *y1p, int *x2p, int *y2p);
EXTERN t_gobj *canvas_findhitbox(t_canvas *x, int xpos, int ypos,
int *x1p, int *y1p, int *x2p, int *y2p);
EXTERN int canvas_setdeleting(t_canvas *x, int flag);
/* ---- for parsing @pd_extra and other sys paths in filenames --------------------- */
......
......@@ -2057,7 +2057,7 @@ int canvas_hitbox(t_canvas *x, t_gobj *y, int xpos, int ypos,
}
/* find the last gobj, if any, containing the point. */
static t_gobj *canvas_findhitbox(t_canvas *x, int xpos, int ypos,
t_gobj *canvas_findhitbox(t_canvas *x, int xpos, int ypos,
int *x1p, int *y1p, int *x2p, int *y2p)
{
t_gobj *y, *rval = 0;
......
......@@ -33,6 +33,14 @@ static void pd_defaultlist(t_pd *x, t_symbol *s, int argc, t_atom *argv);
t_pd pd_objectmaker; /* factory for creating "object" boxes */
t_pd pd_canvasmaker; /* factory for creating canvases */
typedef struct _classtable
{
t_class *ct_class;
struct _classtable *ct_next;
} t_classtable;
t_classtable *ct;
static t_symbol *class_extern_dir = &s_;
static void pd_defaultanything(t_pd *x, t_symbol *s, int argc, t_atom *argv)
......@@ -165,6 +173,28 @@ static void pd_defaultlist(t_pd *x, t_symbol *s, int argc, t_atom *argv)
extern void text_save(t_gobj *z, t_binbuf *b);
void classtable_register(t_class *c)
{
t_classtable *t;
for(t = ct; t; t = t->ct_next)
if (t->ct_class == c) post("already registered %s", c->c_name->s_name);
t = (t_classtable *)t_getbytes(sizeof(*t));
t->ct_class = c;
t->ct_next = ct;
ct = t;
}
// todo-- make accessors so m_imp.h isn't needed by x_interface.c
t_class *classtable_findbyname(t_symbol *s)
{
t_classtable *t;
for (t = ct; t; t = t->ct_next)
if (t->ct_class->c_name == s)
return t->ct_class;
return NULL;
}
t_class *class_new(t_symbol *s, t_newmethod newmethod, t_method freemethod,
size_t size, int flags, t_atomtype type1, ...)
{
......@@ -233,6 +263,8 @@ t_class *class_new(t_symbol *s, t_newmethod newmethod, t_method freemethod,
#if 0
post("class: %s", c->c_name->s_name);
#endif
classtable_register(c);
// post("class: %s", c->c_name->s_name);
return (c);
}
......
......@@ -11,7 +11,7 @@ extern "C" {
#define PD_MAJOR_VERSION 0
#define PD_MINOR_VERSION 42
#define PD_BUGFIX_VERSION 7
#define PD_TEST_VERSION "20130724"
#define PD_TEST_VERSION "20130830"
#define PDL2ORK
/* old name for "MSW" flag -- we have to take it for the sake of many old
......
......@@ -813,6 +813,16 @@ void sys_setblocksize(int n)
sys_blocksize = n;
}
void sys_get_audio_devs(char *indevlist, int *nindevs,
char *outdevlist, int *noutdevs, int *canmulti, int *cancallback,
int maxndev, int devdescsize)
{
audio_getdevs(indevlist, nindevs,
outdevlist, noutdevs,
canmulti, cancallback,
maxndev, devdescsize);
}
void sys_set_audio_api(int which)
{
sys_audioapi = which;
......
......@@ -771,3 +771,17 @@ void glob_midi_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
}
}
void sys_get_midi_devs(char *indevlist, int *nindevs,
char *outdevlist, int *noutdevs,
int maxndevs, int devdescsize)
{
#ifdef USEAPI_ALSA
if (sys_midiapi == API_ALSA)
midi_alsa_getdevs(indevlist, nindevs, outdevlist, noutdevs,
maxndevs, devdescsize);
else
#endif /* ALSA */
midi_getdevs(indevlist, nindevs, outdevlist, noutdevs, maxndevs, devdescsize);
}
......@@ -731,4 +731,44 @@ void glob_startup_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
}
}
t_symbol *pd_getdirname(void)
{
char buf[MAXPDSTRING], buf2[MAXPDSTRING];
int len;
#ifdef _WIN32
if ((len = GetModuleFileName(NULL, buf, sizeof(buf))) == 0)
strcpy(buf, ".");
else
buf[len] = '\0';
sys_unbashfilename(buf, buf);
#elif defined(__APPLE__)
len = sizeof(buf);
_NSGetExecutablePath(buf, &len);
if (len != -1) buf[len] = '\0';
#elif defined(__FreeBSD__)
len = (ssize_t)(readlink("/proc/curproc/file", buf, sizeof(buf)-1));
if (len != -1) buf[len] = '\0';
#else
len = (ssize_t)(readlink("/proc/self/exe", buf, sizeof(buf)-1));
if (len != -1) buf[len] = '\0';
#endif
if (len != -1)
{
char *lastslash;
lastslash = strrchr(buf, '/');
if (lastslash)
{
lastslash++;
*lastslash= '\0';
strncpy(buf2, buf, lastslash-buf);
buf2[lastslash-buf] = '\0';
}
else strcpy(buf2, ".");
}
else
{
return 0;
}
t_symbol *foo = gensym(buf2);
return foo;
}
......@@ -94,9 +94,15 @@ void sys_getmeters(t_sample *inmax, t_sample *outmax);
void sys_listdevs(void);
void sys_setblocksize(int n);
EXTERN void sys_get_audio_devs(char *indevlist, int *nindevs,
char *outdevlist, int *noutdevs, int *canmulti, int *cancallback,
int maxndev, int devdescsize);
EXTERN void sys_get_audio_apis(char *buf);
/* s_midi.c */
#define MAXMIDIINDEV 16 /* max. number of input ports */
#define MAXMIDIOUTDEV 16 /* max. number of output ports */
extern int sys_midiapi;
extern int sys_nmidiin;
extern int sys_nmidiout;
extern int sys_midiindevlist[];
......@@ -104,6 +110,11 @@ extern int sys_midioutdevlist[];
void sys_open_midi(int nmidiin, int *midiinvec,
int nmidiout, int *midioutvec, int enable);
EXTERN void sys_get_midi_apis(char *buf);
EXTERN void sys_get_midi_devs(char *indevlist, int *nindevs,
char *outdevlist, int *noutdevs,
int maxndev, int devdescsize);
void sys_get_midi_params(int *pnmidiindev, int *pmidiindev,
int *pnmidioutdev, int *pmidioutdev);
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment