aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-12-23 01:28:49 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-12-23 01:28:49 +0000
commit49f21b3d329eaa81ffce2940255757298f1bee42 (patch)
tree5814272cab488416f12699ffdbf62d6c471179c6
parent63112f3fc14f0395677b40d071b7e5204ed419e8 (diff)
- first working version, called proxy_inlet_setup() function, and fixed proxy
inlet ID assignment. - left inlet is now properly hot - cleaned out debug post()s svn path=/trunk/externals/hcs/; revision=9104
-rw-r--r--sql_query-help.pd18
-rw-r--r--sql_query.c58
2 files changed, 40 insertions, 36 deletions
diff --git a/sql_query-help.pd b/sql_query-help.pd
index 46acb7d..284cf5c 100644
--- a/sql_query-help.pd
+++ b/sql_query-help.pd
@@ -1,6 +1,6 @@
#N canvas 238 82 613 618 10;
#X obj 362 244 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
--1 -1 0 1;
+-1 -1 4800 1;
#X floatatom 420 276 5 0 0 0 - - -;
#X text 395 223 age;
#N canvas 402 387 450 300 sql 0;
@@ -26,6 +26,14 @@
#X obj 118 105 sql_query this is a test? more ? ? ? ?;
#X msg 39 235 bang;
#X msg 177 268 234;
+#X msg 480 275 symbol twenty;
+#X msg 116 76 fred;
+#X msg 174 77 one;
+#X msg 234 78 2;
+#X msg 287 78 3;
+#X msg 345 78 4;
+#X obj 117 155 pddp/print;
+#X obj 344 131 pddp/print;
#X connect 0 0 11 1;
#X connect 1 0 11 1;
#X connect 3 0 4 0;
@@ -36,5 +44,13 @@
#X connect 10 0 11 0;
#X connect 11 0 3 0;
#X connect 11 1 3 1;
+#X connect 12 0 21 0;
+#X connect 12 1 22 0;
#X connect 13 0 11 0;
#X connect 14 0 11 0;
+#X connect 15 0 11 1;
+#X connect 16 0 12 0;
+#X connect 17 0 12 1;
+#X connect 18 0 12 2;
+#X connect 19 0 12 3;
+#X connect 20 0 12 4;
diff --git a/sql_query.c b/sql_query.c
index 37242bb..49c7bbe 100644
--- a/sql_query.c
+++ b/sql_query.c
@@ -34,8 +34,8 @@
#include <string.h>
-//#define DEBUG(x)
-#define DEBUG(x) x
+#define DEBUG(x)
+//#define DEBUG(x) x
#define PLACEHOLDER '?'
@@ -59,7 +59,7 @@ typedef struct _sql_query
t_binbuf* x_query_binbuf; // binbuf for converting args to string
- struct _proxy_inlet*inlets; // pointer to array of _proxy_inlets
+ t_proxy_inlet* inlets; // pointer to array of _proxy_inlets
t_atom* atoms; // pointer to array of atoms
unsigned int placeholder_count;// number of items in above arrays
@@ -71,7 +71,8 @@ typedef struct _sql_query
/*------------------------------------------------------------------------------
* FUNCTION PROTOTYPES
*/
-static void sql_query_set_atom(t_sql_query *x, int atom_num, t_symbol *s, t_atom *atom);
+static void sql_query_set_atom(t_sql_query *x, int atom_num, t_symbol *s,
+ int argc, t_atom *a);
/*------------------------------------------------------------------------------
* PROXY INLET FUNCTIONS
@@ -79,19 +80,17 @@ static void sql_query_set_atom(t_sql_query *x, int atom_num, t_symbol *s, t_atom
static void proxy_inlet_new(t_proxy_inlet *p, t_object *owner, unsigned int id)
{
+ DEBUG(post("proxy_inlet_new"););
p->pd = proxy_inlet_class;
p->owner = owner;
p->id = id;
inlet_new(owner, &p->pd, 0, 0);
}
-
-
-
static void proxy_inlet_anything(t_proxy_inlet *p, t_symbol *s, int argc, t_atom *argv)
{
- post("proxy_inlet_anything: %s %d", s->s_name, argc);
- sql_query_set_atom(p->owner, p->id, s, argv);
+ DEBUG(post("proxy_inlet_anything"););
+ sql_query_set_atom(p->owner, p->id, s, argc, argv);
}
static void proxy_inlet_setup(void)
@@ -111,26 +110,14 @@ static void proxy_inlet_setup(void)
* STANDARD CLASS FUNCTIONS
*/
-static void sql_query_set_atom(t_sql_query *x, int atom_num, t_symbol *s, t_atom *a)
+static void sql_query_set_atom(t_sql_query *x, int atom_num, t_symbol *s,
+ int argc, t_atom *a)
{
DEBUG(post("sql_query_set_atom"););
if( (s == &s_symbol) || (s == &s_list) || (s == &s_float) )
- {
- char buf[MAXPDSTRING];
- atom_string(a, &buf, MAXPDSTRING);
x->atoms[atom_num] = *a;
- post("symbol/list set %s", buf);
- }
else
- {
SETSYMBOL(&x->atoms[atom_num], s);
- post("selector set %s", s->s_name);
- }
-}
-
-static void sql_query_anything(t_sql_query *x, t_symbol *s, int argc, t_atom *argv)
-{
- sql_query_set_atom(x, 0, s, argv);
}
static void sql_query_output(t_sql_query *x)
@@ -142,6 +129,12 @@ static void sql_query_output(t_sql_query *x)
outlet_list(x->x_data_outlet, &s_list, x->placeholder_count, x->atoms);
}
+static void sql_query_anything(t_sql_query *x, t_symbol *s, int argc, t_atom *argv)
+{
+ sql_query_set_atom(x, 0, s, argc, argv);
+ sql_query_output(x);
+}
+
static void sql_query_free(t_sql_query *x)
{
binbuf_free(x->x_query_binbuf);
@@ -156,6 +149,8 @@ static void *sql_query_new(t_symbol *s, int argc, t_atom *argv)
char *current = NULL;
t_sql_query *x = (t_sql_query *)pd_new(sql_query_class);
+ proxy_inlet_setup();
+
x->x_query_binbuf = binbuf_new();
binbuf_add(x->x_query_binbuf, argc, argv);
binbuf_gettext(x->x_query_binbuf, &buf, &bufsize);
@@ -165,23 +160,17 @@ static void *sql_query_new(t_symbol *s, int argc, t_atom *argv)
current = strchr(buf, PLACEHOLDER);
while (current != NULL)
{
- post("found placeholder %c", PLACEHOLDER);
x->placeholder_count++;
current = strchr(current + 1, PLACEHOLDER);
}
- post("creating %d inlets", x->placeholder_count);
+
x->inlets = getbytes(x->placeholder_count * sizeof(t_proxy_inlet));
- for(i=1; i< x->placeholder_count; ++i)
- {
- proxy_inlet_new(&x->inlets[i], (t_object *)x, x->placeholder_count);
- post("\tinlet %d", i);
- }
-
+ for(i = 1; i < x->placeholder_count; ++i)
+ proxy_inlet_new(&x->inlets[i], (t_object *)x, i);
+
x->atoms = getbytes(x->placeholder_count * sizeof(t_atom));
- for(i=0; i< x->placeholder_count; ++i)
- {
+ for(i = 0; i < x->placeholder_count; ++i)
SETSYMBOL(&x->atoms[i], &s_);
- }
x->x_data_outlet = outlet_new(&x->x_obj, 0);
x->x_query_outlet = outlet_new(&x->x_obj, 0);
@@ -191,7 +180,6 @@ static void *sql_query_new(t_symbol *s, int argc, t_atom *argv)
void sql_query_setup(void)
{
- DEBUG(post("sql_query_setup"););
sql_query_class = class_new(gensym("sql_query"),
(t_newmethod)sql_query_new,
(t_method)sql_query_free,