Update of /cvsroot/alsa/alsa-lib/src/alisp
In directory sc8-pr-cvs1:/tmp/cvs-serv29050/src/alisp
Modified Files:
alisp.c alisp_snd.c
Log Message:
More changes to the ordinary mixer API
Index: alisp.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/alisp/alisp.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- alisp.c 9 Sep 2003 19:24:36 -0000 1.10
+++ alisp.c 13 Oct 2003 12:06:45 -0000 1.11
@@ -51,6 +51,7 @@
static void princ_cons(snd_output_t *out, struct alisp_object * p);
static void princ_object(snd_output_t *out, struct alisp_object * p);
static struct alisp_object * eval(struct alisp_instance *instance, struct
alisp_object * p);
+static struct alisp_object * eval_cons1(struct alisp_instance *instance, struct
alisp_object * p1, struct alisp_object * p2);
/* functions */
static struct alisp_object *F_eval(struct alisp_instance *instance, struct
alisp_object *);
@@ -467,7 +468,7 @@
return instance->thistoken;
got_id:
- case '_': case '+': case '*': case '/': case '%':
+ case '!': case '_': case '+': case '*': case '/': case '%':
case '<': case '>': case '=': case '&':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
@@ -479,7 +480,7 @@
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
- /* Identifier: [-/+*%<>=&a-zA-Z_][-/+*%<>=&a-zA-Z_0-9]* */
+ /* Identifier: [!-/+*%<>=&a-zA-Z_][-/+*%<>=&a-zA-Z_0-9]* */
p = instance->token_buffer;
do {
if (p - instance->token_buffer >=
instance->token_buffer_max) {
@@ -489,7 +490,7 @@
}
*p++ = c;
c = xgetc(instance);
- } while (isalnum(c) || strchr("_-+*/%<>=&", c) != NULL);
+ } while (isalnum(c) || strchr("!_-+*/%<>=&", c) != NULL);
xungetc(instance, c);
*p = '\0';
return instance->thistoken = ALISP_IDENTIFIER;
@@ -1326,6 +1327,19 @@
}
/*
+ * Syntax: (!= expr1 expr2)
+ */
+static struct alisp_object * F_numneq(struct alisp_instance *instance, struct
alisp_object * args)
+{
+ struct alisp_object * p;
+
+ p = F_numeq(instance, args);
+ if (p == &alsa_lisp_nil)
+ return &alsa_lisp_t;
+ return &alsa_lisp_nil;
+}
+
+/*
* Syntax: (exfun name)
* Test, if a function exists
*/
@@ -1333,7 +1347,7 @@
{
struct alisp_object * p1, * p2;
- p1 = car(args);
+ p1 = eval(instance, car(args));
if (p1->type != ALISP_OBJ_STRING && p1->type != ALISP_OBJ_IDENTIFIER)
return &alsa_lisp_nil;
p2 = get_object(instance, p1);
@@ -1961,6 +1975,20 @@
}
/*
+ * Syntax: (call function args...)
+ */
+struct alisp_object * F_call(struct alisp_instance *instance, struct alisp_object *
args)
+{
+ struct alisp_object * p = eval(instance, car(args));
+
+ if (p->type != ALISP_OBJ_IDENTIFIER && p->type != ALISP_OBJ_STRING) {
+ lisp_warn(instance, "expected an function name");
+ return &alsa_lisp_nil;
+ }
+ return eval_cons1(instance, p, cdr(args));
+}
+
+/*
* Syntax: (int value)
* 'value' can be integer or float type
*/
@@ -1968,9 +1996,9 @@
{
struct alisp_object * p = eval(instance, car(args));
- if (p->type == ALISP_INTEGER)
+ if (p->type == ALISP_OBJ_INTEGER)
return p;
- if (p->type == ALISP_FLOAT)
+ if (p->type == ALISP_OBJ_FLOAT)
return new_integer(instance, floor(p->value.f));
lisp_warn(instance, "expected an integer or float for integer conversion");
@@ -1985,9 +2013,9 @@
{
struct alisp_object * p = eval(instance, car(args));
- if (p->type == ALISP_FLOAT)
+ if (p->type == ALISP_OBJ_FLOAT)
return p;
- if (p->type == ALISP_INTEGER)
+ if (p->type == ALISP_OBJ_INTEGER)
return new_float(instance, p->value.i);
lisp_warn(instance, "expected an integer or float for integer conversion");
@@ -2002,9 +2030,9 @@
{
struct alisp_object * p = eval(instance, car(args));
- if (p->type == ALISP_STRING)
+ if (p->type == ALISP_OBJ_STRING)
return p;
- if (p->type == ALISP_INTEGER || p->type == ALISP_FLOAT) {
+ if (p->type == ALISP_OBJ_INTEGER || p->type == ALISP_OBJ_FLOAT) {
char buf[64];
if (p->type == ALISP_INTEGER) {
snprintf(buf, sizeof(buf), "%ld", p->value.i);
@@ -2166,6 +2194,7 @@
};
static struct intrinsic intrinsics[] = {
+ { "!=", F_numneq },
{ "%", F_mod },
{ "&dump-memory", F_dump_memory },
{ "&dump-objects", F_dump_objects },
@@ -2183,6 +2212,7 @@
{ "assoc", F_assoc },
{ "assq", F_assq },
{ "atom", F_atom },
+ { "call", F_call },
{ "car", F_car },
{ "cdr", F_cdr },
{ "cond", F_cond },
@@ -2233,33 +2263,41 @@
((struct intrinsic *)p2)->name);
}
-static struct alisp_object * eval_cons(struct alisp_instance *instance, struct
alisp_object * p)
+static struct alisp_object * eval_cons1(struct alisp_instance *instance, struct
alisp_object * p1, struct alisp_object * p2)
{
- struct alisp_object * p1 = car(p), * p2 = cdr(p), * p3;
+ struct alisp_object * p3;
+ struct intrinsic key, *item;
- if (p1 != &alsa_lisp_nil && p1->type == ALISP_OBJ_IDENTIFIER) {
- struct intrinsic key, *item;
+ key.name = p1->value.id;
+ if ((item = bsearch(&key, intrinsics,
+ sizeof intrinsics / sizeof intrinsics[0],
+ sizeof intrinsics[0], compar)) != NULL)
+ return item->func(instance, p2);
- if (!strcmp(p1->value.id, "lambda"))
- return p;
+ if ((item = bsearch(&key, snd_intrinsics,
+ sizeof snd_intrinsics / sizeof snd_intrinsics[0],
+ sizeof snd_intrinsics[0], compar)) != NULL)
+ return item->func(instance, p2);
- auto_garbage_collect(instance);
+ if ((p3 = get_object(instance, p1)) != &alsa_lisp_nil)
+ return eval_func(instance, p3, p2);
+ else
+ lisp_warn(instance, "function `%s' is undefined", p1->value.id);
- key.name = p1->value.id;
- if ((item = bsearch(&key, intrinsics,
- sizeof intrinsics / sizeof intrinsics[0],
- sizeof intrinsics[0], compar)) != NULL)
- return item->func(instance, p2);
+ return &alsa_lisp_nil;
+}
- if ((item = bsearch(&key, snd_intrinsics,
- sizeof snd_intrinsics / sizeof snd_intrinsics[0],
- sizeof snd_intrinsics[0], compar)) != NULL)
- return item->func(instance, p2);
+static inline struct alisp_object * eval_cons(struct alisp_instance *instance, struct
alisp_object * p)
+{
+ struct alisp_object * p1 = car(p);
- if ((p3 = get_object(instance, p1)) != &alsa_lisp_nil)
- return eval_func(instance, p3, p2);
- else
- lisp_warn(instance, "function `%s' is undefined",
p1->value.id);
+ if (p1 != &alsa_lisp_nil && p1->type == ALISP_OBJ_IDENTIFIER) {
+ if (!strcmp(p1->value.id, "lambda"))
+ return p;
+
+ auto_garbage_collect(instance);
+
+ return eval_cons1(instance, p1, cdr(p));
}
return &alsa_lisp_nil;
@@ -2655,8 +2693,8 @@
{
struct alisp_object * p2;
- if (seq->type == ALISP_OBJ_CONS && seq->value.c.cdr->type == ALISP_OBJ_CONS)
- seq = seq->value.c.cdr;
+ if (seq->type == ALISP_OBJ_CONS && seq->value.c.car->type == ALISP_OBJ_CONS)
+ seq = seq->value.c.car;
if (seq->type == ALISP_OBJ_CONS) {
p2 = seq->value.c.car;
if (p2->type != ALISP_OBJ_STRING)
Index: alisp_snd.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/alisp/alisp_snd.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- alisp_snd.c 9 Sep 2003 19:24:36 -0000 1.6
+++ alisp_snd.c 13 Oct 2003 12:06:45 -0000 1.7
@@ -188,11 +188,6 @@
return lexpr;
}
-static inline struct alisp_object * new_result(struct alisp_instance * instance, int
err)
-{
- return new_integer(instance, err);
-}
-
static struct alisp_object * new_result1(struct alisp_instance * instance, int err,
const char *ptr_id, void *ptr)
{
struct alisp_object * lexpr, * p1;
@@ -254,6 +249,7 @@
typedef int (*snd_int_pp_strp_int_t)(void **rctl, const char *name, int mode);
typedef int (*snd_int_pp_p_t)(void **rctl, void *handle);
typedef int (*snd_int_p_t)(void *rctl);
+typedef char * (*snd_str_p_t)(void *rctl);
typedef int (*snd_int_intp_t)(int *val);
typedef int (*snd_int_str_t)(const char *str);
typedef int (*snd_int_int_strp_t)(int val, char **str);
@@ -328,7 +324,18 @@
handle = (void *)get_ptr(args, item->prefix);
if (handle == NULL)
return &alsa_lisp_nil;
- return new_result(instance, ((snd_int_p_t)item->xfunc)(handle));
+ return new_integer(instance, ((snd_int_p_t)item->xfunc)(handle));
+}
+
+static struct alisp_object * FA_str_p(struct alisp_instance * instance, struct
acall_table * item, struct alisp_object * args)
+{
+ void *handle;
+
+ args = eval(instance, car(args));
+ handle = (void *)get_ptr(args, item->prefix);
+ if (handle == NULL)
+ return &alsa_lisp_nil;
+ return new_string(instance, ((snd_str_p_t)item->xfunc)(handle));
}
static struct alisp_object * FA_int_intp(struct alisp_instance * instance, struct
acall_table * item, struct alisp_object * args)
@@ -351,7 +358,7 @@
if (args->type != ALISP_OBJ_STRING && args->type != ALISP_OBJ_IDENTIFIER)
return &alsa_lisp_nil;
err = ((snd_int_str_t)item->xfunc)(args->value.s);
- return new_result(instance, err);
+ return new_integer(instance, err);
}
static struct alisp_object * FA_int_int_strp(struct alisp_instance * instance, struct
acall_table * item, struct alisp_object * args)
@@ -606,7 +613,7 @@
snd_ctl_elem_value_alloca(&value);
err = snd_hctl_elem_info(handle, info);
if (err < 0)
- return new_result(instance, err);
+ return new_integer(instance, err);
type = snd_ctl_elem_info_get_type(info);
count = snd_ctl_elem_info_get_count(info);
if (type == SND_CTL_ELEM_TYPE_IEC958) {
@@ -641,7 +648,7 @@
p1 = cdr(p1);
} while (p1 != &alsa_lisp_nil);
err = snd_hctl_elem_write(handle, value);
- return new_result(instance, err);
+ return new_integer(instance, err);
}
static struct alisp_object * FA_pcm_info(struct alisp_instance * instance, struct
acall_table * item, struct alisp_object * args)
@@ -701,6 +708,7 @@
{ "hctl_open", &FA_int_pp_strp_int, (void *)&snd_hctl_open, "hctl" },
{ "hctl_open_ctl", &FA_int_pp_p, (void *)&snd_hctl_open_ctl, "hctl" },
{ "pcm_info", &FA_pcm_info, NULL, "pcm" },
+ { "pcm_name", &FA_str_p, (void *)&snd_pcm_name, "pcm" },
};
static int acall_compar(const void *p1, const void *p2)
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog