From: Darren S. <ds...@us...> - 2005-04-25 22:02:27
|
Update of /cvsroot/xine/gnome-xine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18037/src Modified Files: script_engine.c script_engine.h Log Message: Implement property access callback code, assignment & dynamic reading. Now we can access XINE_PARAM_* and [untested] config items via Javascript, given a few objects. Index: script_engine.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/script_engine.c,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- script_engine.c 21 Apr 2005 19:16:44 -0000 1.45 +++ script_engine.c 25 Apr 2005 22:02:02 -0000 1.46 @@ -86,12 +86,36 @@ return JS_GetStringBytes (se->str); } -int se_result_num (se_t *se, JSInt32 *num) { +int se_result_num (se_t *se, JSInt32 *num) +{ + if (JSVAL_IS_INT (se->rval)) + return JS_ValueToInt32 (se->cx, se->rval, num); - if (!JSVAL_IS_INT (se->rval)) - return 0; + if (JSVAL_IS_DOUBLE (se->rval)) + { + JSFloat64 f; + JS_ValueToNumber (se->cx, se->rval, &f); + *num = floor (f); + return 1; + } + + return 0; +} + +int se_result_double (se_t *se, JSFloat64 *num) +{ + if (JSVAL_IS_DOUBLE (se->rval)) + return JS_ValueToNumber (se->cx, se->rval, num); + + if (JSVAL_IS_INT (se->rval)) + { + JSInt32 i; + JS_ValueToInt32 (se->cx, se->rval, &i); + *num = i; + return 1; + } - return JS_ValueToInt32 (se->cx, se->rval, num); + return 0; } /* @@ -315,59 +339,124 @@ return JS_TRUE; } -static jsval get_prop_jsval (se_t *se, se_o_t *o, se_prop_t *p) { - +static int get_prop_int (se_t *se, se_o_t *o, se_prop_t *p) +{ + int n; + + if (p->reader) + { + se_prop_read_t v; + p->reader (p, &v); + return v.i; + } + + if (sscanf (p->value, "%d", &n) == 1) + { + logprintf ("script_engine: this is a simple integer %d\n", n); + return n; + } + if (!strncasecmp (p->value, "jscript:", 8)) + { + char *script = p->value + 8; + logprintf ("script_engine: this is a jscript => evaluating '%s'...\n", + script); + se_eval (se, script, o, NULL, NULL); + if (se_result_num (se, &n)) + { + logprintf ("script_engine: result: %d\n", n); + return n; + } + printf ("script_engine: error, non-numeric result in %s=='%s'\n", + p->id, p->value); + } else + printf ("script_engine: error, non-numeric property %s=='%s'\n", + p->id, p->value); + + return 0; +} + +static double get_prop_double (se_t *se, se_o_t *o, se_prop_t *p) +{ + double n; + + if (p->reader) + { + se_prop_read_t v; + p->reader (p, &v); + return v.d; + } + + if (sscanf (p->value, "%lf", &n) == 1) + { + logprintf ("script_engine: this is a simple float %lf\n", n); + return n; + } + if (!strncasecmp (p->value, "jscript:", 8)) + { + char *script = p->value + 8; + logprintf ("script_engine: this is a jscript => evaluating '%s'...\n", + script); + se_eval (se, script, o, NULL, NULL); + if (se_result_double (se, &n)) + { + logprintf ("script_engine: result: %lf\n", n); + return n; + } + printf ("script_engine: error, non-numeric result in %s=='%s'\n", + p->id, p->value); + } else + printf ("script_engine: error, non-numeric property %s=='%s'\n", + p->id, p->value); + + return 0; +} + +static int get_prop_bool (se_t *se, se_o_t *o, se_prop_t *p) +{ int n; + if (p->reader) + { + se_prop_read_t v; + p->reader (p, &v); + return v.i; + } + + if (sscanf (p->value, "%d", &n) == 1) + { + n = !!n; + logprintf ("script_engine: this is a simple boolean %d\n", n); + return BOOLEAN_TO_JSVAL (n); + } + return strcasecmp (p->value, "false") ? JSVAL_TRUE : JSVAL_FALSE; +} + +static jsval get_prop_jsval (se_t *se, se_o_t *o, se_prop_t *p) +{ logprintf ("script_engine: getting value of %s=='%s'\n", p->id, p->value); - switch (p->se_type) { + switch (p->se_type) + { case SE_TYPE_INT: - - if (sscanf (p->value, "%d", &n) == 1) { - logprintf ("script_engine: this is a simple integer %d\n", n); + { + int n = get_prop_int (se, o, p); return INT_TO_JSVAL (n); - } else { - - if (!strncasecmp (p->value, "jscript:", 8)) { - - char *script; - - script = p->value+8; - - logprintf ("script_engine: this is a jscript => evaluating '%s'...\n", - script); - - se_eval (se, script, o, NULL, NULL); - - if (se_result_num (se, &n) ) { - logprintf ("script_engine: result: %d\n", n); - return INT_TO_JSVAL (n); - } else - printf ("script_engine: error, non-numeric result in %s=='%s'\n", - p->id, p->value); - } else { - printf ("script_engine: error, non-numeric int property %s=='%s'\n", - p->id, p->value); - } } - return INT_TO_JSVAL (0); - - break; - + + case SE_TYPE_DOUBLE: + { + double d = get_prop_int (se, o, p); + return DOUBLE_TO_JSVAL (d); + } + case SE_TYPE_BOOL: - if (sscanf (p->value, "%d", &n) == 1) { - logprintf ("script_engine: this is a simple boolean %d\n", n); + { + int n = get_prop_bool (se, o, p); return BOOLEAN_TO_JSVAL (n); - } else if (!strcasecmp (p->value, "false")) { - return BOOLEAN_TO_JSVAL (0); - } else - return BOOLEAN_TO_JSVAL (1); - break; + } case SE_TYPE_STRING: { - JSString *jstr; char *bytes; int len; @@ -379,13 +468,10 @@ memcpy (bytes, p->value, len); jstr = JS_NewString (se->cx, bytes, len); - return STRING_TO_JSVAL(jstr); } - - break; + default: - printf ("script_engine: error, property %s has unknown type %d\n", p->id, p->se_type); } @@ -393,6 +479,46 @@ return BOOLEAN_TO_JSVAL (0); } + +static void set_prop_jsval (se_t *se, se_o_t *o, se_prop_t *p, const jsval *v) +{ + logprintf ("script_engine: setting value of %s\n", p->id); + + switch (p->se_type) + { + case SE_TYPE_INT: + if (JSVAL_IS_NUMBER(*v)) + se_prop_set_int (se, o, p->id, JSVAL_TO_INT(*v)); + else + se->print_cb (se->print_cb_data, _("\n%s.%s: value must be numeric\n"), + o->id, p->id); + return; + + case SE_TYPE_DOUBLE: + if (JSVAL_IS_NUMBER(*v)) + se_prop_set_double (se, o, p->id, *JSVAL_TO_DOUBLE(*v)); + else + se->print_cb (se->print_cb_data, _("\n%s.%s: value must be numeric\n"), + o->id, p->id); + return; + + case SE_TYPE_BOOL: + if (JSVAL_IS_BOOLEAN(*v)) + se_prop_set_bool (se, o, p->id, JSVAL_TO_BOOLEAN(*v)); + else + se->print_cb (se->print_cb_data, _("\n%s.%s: value must be boolean\n"), + o->id, p->id); + return; + + case SE_TYPE_STRING: + se_prop_set (se, o, p->id, JSVAL_TO_STRING(*v)); + return; + + default: + printf ("script_engine: error, property %s has unknown type %d\n", + p->id, p->se_type); + } +} /* @@ -409,12 +535,9 @@ o = JS_GetPrivate (cx, obj); if (JSVAL_IS_STRING (id)) { - JSString *str; - char *prop; + JSString *str = JS_ValueToString (cx, id); + char *prop = JS_GetStringBytes (str); GList *n; - - str = JS_ValueToString (cx, id); - prop = JS_GetStringBytes (str); logprintf ("script_engine: looking for generic property '%s' in '%s'\n", prop, o->id); @@ -423,9 +546,7 @@ n = g_list_first (o->properties); while (n) { - se_prop_t *p; - - p = (se_prop_t *) n->data; + se_prop_t *p = (se_prop_t *) n->data; if (!strcasecmp (p->id, prop)) { *vp = get_prop_jsval (se, o, p); @@ -435,24 +556,6 @@ n = g_list_next (n); } - /* maybe an object ? */ - - n = g_list_first (o->children); - while (n) { - se_o_t *c; - - c = (se_o_t *) n->data; - - if (!strcasecmp (c->id, prop)) { - - *vp = OBJECT_TO_JSVAL (c->obj); - return JS_TRUE; - - } - - n = g_list_next (n); - } - if (o->parent) return generic_JSGetProperty (cx, o->parent->obj, id, vp); @@ -465,8 +568,46 @@ } -JSBool generic_JSSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { +JSBool generic_JSSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + se_t *se = (se_t *) JS_GetContextPrivate(cx); + se_o_t *o; + se_log_fncall ("generic set property"); + + o = JS_GetPrivate (cx, obj); + + if (JSVAL_IS_STRING (id)) { + JSString *str = JS_ValueToString (cx, id); + char *prop = JS_GetStringBytes (str); + GList *n; + + logprintf ("script_engine: looking for generic property '%s' in '%s'\n", + prop, o->id); + + /* look through properties */ + + n = g_list_first (o->properties); + while (n) { + se_prop_t *p = (se_prop_t *) n->data; + + if (!strcasecmp (p->id, prop)) { + if (!p->constant) + set_prop_jsval (se, o, p, vp); + return JS_TRUE; + } + + n = g_list_next (n); + } + + if (o->parent) + return generic_JSSetProperty (cx, o->parent->obj, id, vp); + + return JS_TRUE; + } + + *vp = JSVAL_VOID; + return JS_TRUE; } @@ -553,7 +694,122 @@ return NULL; } + +static void se_prop_listeners (se_t *se, se_o_t *o, se_prop_t *p, se_prop_read_t r) +{ + GList *node = p->listeners; + while (node) + { + const se_prop_listener_t *l = node->data; + l->cb (l->user_data, se, o, p, r); + node = g_list_next (node); + } +} +void se_prop_set (se_t *se, se_o_t *o, const char *id, const char *value) +{ + se_prop_t *p; + + if (!o) + o = se->g; + + p = se_prop_find (se, o, id); + if (p) + { + se_prop_read_t v; + if (p->reader && p->se_type != SE_TYPE_STRING) + { + printf ("script_engine: se_prop_set%s: can't change type of property %s.%s\n", + "_int", o->id, id); + return; + } + free (p->value); + v.s = p->value = strdup (value); + p->se_type = SE_TYPE_STRING; + se_prop_listeners (se, o, p, v); + } + else + se_prop_create (se, o, id, value, NULL, 0, SE_TYPE_STRING, FALSE); +} + +void se_prop_set_int (se_t *se, se_o_t *o, const char *id, int value) +{ + se_prop_t *p; + + if (!o) + o = se->g; + + p = se_prop_find (se, o, id); + if (p) + { + se_prop_read_t v; + if (p->reader && p->se_type != SE_TYPE_INT) + { + printf ("script_engine: se_prop_set%s: can't change type of property %s.%s\n", + "_int", o->id, id); + return; + } + free (p->value); + p->value = g_strdup_printf ("%d", v.i = value); + p->se_type = SE_TYPE_INT; + se_prop_listeners (se, o, p, v); + } + else + se_prop_create_int (se, o, id, value, FALSE); +} + +void se_prop_set_double (se_t *se, se_o_t *o, const char *id, double value) +{ + se_prop_t *p; + + if (!o) + o = se->g; + + p = se_prop_find (se, o, id); + if (p) + { + se_prop_read_t v; + if (p->reader && p->se_type != SE_TYPE_DOUBLE) + { + printf ("script_engine: se_prop_set%s: can't change type of property %s.%s\n", + "_int", o->id, id); + return; + } + free (p->value); + p->value = g_strdup_printf ("%la", v.d = value); + p->se_type = SE_TYPE_DOUBLE; + se_prop_listeners (se, o, p, v); + } + else + se_prop_create_double (se, o, id, value, FALSE); +} + +void se_prop_set_bool (se_t *se, se_o_t *o, const char *id, int value) +{ + se_prop_t *p; + + if (!o) + o = se->g; + + p = se_prop_find (se, o, id); + if (p) + { + se_prop_read_t v; + if (p->reader && p->se_type != SE_TYPE_BOOL) + { + printf ("script_engine: se_prop_set%s: can't change type of property %s.%s\n", + "_int", o->id, id); + return; + } + free (p->value); + p->value = g_strdup_printf ("%d", v.i = !!value); + p->se_type = SE_TYPE_BOOL; + se_prop_listeners (se, o, p, v); + } + else + se_prop_create_bool (se, o, id, value, FALSE); +} + char *se_prop_get (se_t *se, se_o_t *o, const char *id) { se_prop_t *p; @@ -564,79 +820,147 @@ p = se_prop_find (se, o, id); if (!p) { - printf ("script_engine: se_prop_get error, property %s.%s doesn't exist\n", - o->id, id); + printf ("script_engine: se_prop_get%s error, property %s.%s doesn't exist\n", + "", o->id, id); return NULL; } + if (p->reader) + { + se_prop_read_t v; + p->reader (p, &v); + switch (p->se_type) + { + case SE_TYPE_INT: + case SE_TYPE_BOOL: + free (p->value); + return p->value = g_strdup_printf ("%d", v.i); + case SE_TYPE_DOUBLE: + free (p->value); + return p->value = g_strdup_printf ("%la", v.d); + case SE_TYPE_STRING: + free (p->value); + return p->value = strdup (v.s); + default:; + } + } + return p->value; } -int se_prop_get_int (se_t *se, se_o_t *o, const char *id) { +int se_prop_get_int (se_t *se, se_o_t *o, const char *id) +{ + se_prop_t *p; + jsval n; + + if (!o) + o = se->g; + + p = se_prop_find (se, o, id); + if (!p) { + printf ("script_engine: se_prop_get%s error, property %s.%s doesn't exist\n", + "_int", o->id, id); + return 0; + } + + logprintf ("script_engine: getting value of %s.%s=='%s'\n", + o->id, p->id, p->value); + + switch (p->se_type) + { + case SE_TYPE_INT: + return get_prop_int (se, o, p); + + case SE_TYPE_DOUBLE: + return floor (get_prop_double (se, o, p)); + + case SE_TYPE_BOOL: + return get_prop_bool (se, o, p); + + default: + printf ("script_engine: se_get_prop%s error, %s.%s is not numeric\n", + "_int", o->id, id); + } + return 0; +} +double se_prop_get_double (se_t *se, se_o_t *o, const char *id) +{ se_prop_t *p; - int n; + jsval n; if (!o) o = se->g; p = se_prop_find (se, o, id); if (!p) { - printf ("script_engine: se_prop_get_int error, property %s.%s doesn't exist\n", - o->id, id); + printf ("script_engine: se_prop_get%s error, property %s.%s doesn't exist\n", + "_double", o->id, id); return 0; } logprintf ("script_engine: getting value of %s.%s=='%s'\n", o->id, p->id, p->value); - switch (p->se_type) { + switch (p->se_type) + { case SE_TYPE_INT: - - if (sscanf (p->value, "%d", &n) == 1) { - logprintf ("script_engine: this is a simple integer %d\n", n); - return n; - - } else { - - if (!strncasecmp (p->value, "jscript:", 8)) { + return 0.0 + get_prop_int (se, o, p); + + case SE_TYPE_DOUBLE: + return get_prop_double (se, o, p); - char *script = p->value+8; - logprintf ("script_engine: this is a jscript => evaluating '%s'...\n", - script); - se_eval (se, script, o, NULL, NULL); - if (se_result_num (se, &n) ) { - logprintf ("script_engine: result: %d\n", n); - return n; - } else - printf ("script_engine: error, non-numeric result for %s.%s\n", - o->id, id); - } else { - printf ("script_engine: error, non-numeric property %s.%s='%s'\n", - o->id, id, p->value); - } - } - break; case SE_TYPE_BOOL: - if (sscanf (p->value, "%d", &n) == 1) { - logprintf ("script_engine: this is a simple integer %d\n", n); - return n; - } else if (!strcasecmp (p->value, "false")) { - return 0; - } else { - return 1; - } - break; + return 0.0 + get_prop_bool (se, o, p); + + default: + printf ("script_engine: se_get_prop%s error, %s.%s is not numeric\n", + "_double", o->id, id); + } + return 0; +} + +int se_prop_get_bool (se_t *se, se_o_t *o, const char *id) +{ + se_prop_t *p; + jsval n; + + if (!o) + o = se->g; + + p = se_prop_find (se, o, id); + if (!p) { + printf ("script_engine: se_prop_get%s error, property %s.%s doesn't exist\n", + "_bool", o->id, id); + return 0; + } + + logprintf ("script_engine: getting value of %s.%s=='%s'\n", + o->id, p->id, p->value); + switch (p->se_type) + { + case SE_TYPE_INT: + return get_prop_int (se, o, p) ? JSVAL_TRUE : JSVAL_FALSE; + + case SE_TYPE_DOUBLE: + return (get_prop_double (se, o, p) != 0) ? JSVAL_TRUE : JSVAL_FALSE; + + case SE_TYPE_BOOL: + return get_prop_bool (se, o, p); + default: - printf ("script_engine: error in se_get_prop_int, %s.%s is not an integer or bool\n", o->id, id); + printf ("script_engine: se_get_prop%s error, %s.%s is not numeric\n", + "_bool", o->id, id); } return 0; } void se_prop_create (se_t *se, se_o_t *o, const char *id, const char *value, - int se_type) { + const char *xine_id, int xine_param, + se_prop_type_t se_type, gboolean constant) +{ se_prop_t *p; if (!o) @@ -650,27 +974,145 @@ p = malloc (sizeof (se_prop_t)); p->id = strdup (id); p->value = strdup (value); + p->xine_id = xine_id ? strdup (xine_id) : NULL; + p->xine_param = xine_param; p->listeners = NULL; o->properties = g_list_append (o->properties, p); } p->se_type = se_type; + p->constant = constant; } -void se_prop_create_int (se_t *se, se_o_t *o, - const char *id, int value) { +void se_prop_create_int (se_t *se, se_o_t *o, const char *id, int value, + gboolean constant) +{ char str[24]; snprintf (str, sizeof (str), "%d", value); - se_prop_create (se, o, id, str, SE_TYPE_INT); + se_prop_create (se, o, id, str, NULL, 0, SE_TYPE_INT, constant); } -void se_prop_create_bool (se_t *se, se_o_t *o, - const char *id, int value) { +void se_prop_create_double (se_t *se, se_o_t *o, const char *id, double value, + gboolean constant) +{ char str[24]; - snprintf (str, sizeof (str), "%d", value); - se_prop_create (se, o, id, str, SE_TYPE_BOOL); + snprintf (str, sizeof (str), "%la", value); /* C99 hex float */ + se_prop_create (se, o, id, str, NULL, 0, SE_TYPE_DOUBLE, constant); +} + +void se_prop_create_bool (se_t *se, se_o_t *o, const char *id, int value, + gboolean constant) +{ + char str[24]; + snprintf (str, sizeof (str), "%d", !!value); + se_prop_create (se, o, id, str, NULL, 0, SE_TYPE_BOOL, constant); +} + +static void se_prop_read_xine_id_int (se_prop_t *prop, se_prop_read_t *value) +{ + xine_cfg_entry_t entry; + if (xine_config_lookup_entry (xine, prop->xine_id, &entry)) + value->i = entry.num_value; + else + value->i = 0; +} + +static void se_prop_read_xine_id_string (se_prop_t *prop, se_prop_read_t *value) +{ + xine_cfg_entry_t entry; + if (xine_config_lookup_entry (xine, prop->xine_id, &entry)) + value->s = entry.str_value; + else + value->s = ""; } +void se_prop_create_xine_id (se_t *se, se_o_t *o, + const char *id, const char *xine_id) +{ + xine_cfg_entry_t entry = { NULL }; + xine_config_lookup_entry (xine, xine_id, &entry); + switch (entry.type) + { + case XINE_CONFIG_TYPE_RANGE: + case XINE_CONFIG_TYPE_NUM: + se_prop_create (se, o, id, "", xine_id, 0, SE_TYPE_INT, FALSE); + se_prop_set_reader_func (se, o, id, se_prop_read_xine_id_int); + return; + case XINE_CONFIG_TYPE_ENUM: + puts ("script_engine: can't create property for xine config enum type"); + return; + case XINE_CONFIG_TYPE_STRING: + se_prop_create (se, o, id, "", xine_id, 0, SE_TYPE_STRING, FALSE); + se_prop_set_reader_func (se, o, id, se_prop_read_xine_id_string); + return; + case XINE_CONFIG_TYPE_BOOL: + se_prop_create (se, o, id, "", xine_id, 0, SE_TYPE_BOOL, FALSE); + se_prop_set_reader_func (se, o, id, se_prop_read_xine_id_int); + return; + default: + puts ("script_engine: can't create property for xine config unknown type"); + } +} + +static void se_prop_read_xine_param (se_prop_t *prop, se_prop_read_t *value) +{ + value->i = xine_get_param (stream, prop->xine_param); +} + +void se_prop_create_xine_param (se_t *se, se_o_t *o, + const char *id, int xine_param, + se_prop_type_t type) +{ + switch (type) + { + case SE_TYPE_BOOL: + case SE_TYPE_INT: + se_prop_create (se, o, id, "", NULL, xine_param, type, FALSE); + se_prop_set_reader_func (se, o, id, se_prop_read_xine_param); + return; + default: + puts ("script_engine: can't create property for xine param non-int type"); + } +} + +void se_prop_add_listener (se_t *se, se_o_t *o, const char *id, + se_prop_cb_t prop_cb, void *user_data) +{ + se_prop_t *p; + + if (!o) + o = se->g; + + logprintf ("script_engine: adding listener to %s.%s\n", o->id, id); + + p = se_prop_find (se, o, id); + if (!p) + printf ("script_engine: error in se_prop_add_listener: property %s.%s not found\n", o->id, id); + else + { + se_prop_listener_t *listener = malloc (sizeof (se_prop_listener_t)); + listener->cb = prop_cb; + listener->user_data = user_data; + p->listeners = g_list_append (p->listeners, listener); + } +} + +void se_prop_set_reader_func (se_t *se, se_o_t *o, const char *id, + se_prop_reader_t reader) +{ + se_prop_t *p; + + if (!o) + o = se->g; + + logprintf ("script_engine: setting reader for %s.%s\n", o->id, id); + + p = se_prop_find (se, o, id); + if (!p) + printf ("script_engine: error in se_prop_set_reader_func: property %s.%s not found\n", o->id, id); + else + p->reader = reader; +} static void error_reporter (JSContext *cx, const char *message, JSErrorReport *report) { Index: script_engine.h =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/script_engine.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- script_engine.h 21 Apr 2005 19:16:44 -0000 1.15 +++ script_engine.h 25 Apr 2005 22:02:02 -0000 1.16 @@ -80,18 +80,35 @@ const char *funchelp; } se_f_t; -#define SE_TYPE_STRING 0 -#define SE_TYPE_BOOL 1 -#define SE_TYPE_INT 2 - -typedef struct { +typedef enum { + SE_TYPE_STRING, + SE_TYPE_BOOL, + SE_TYPE_INT, + SE_TYPE_DOUBLE, +} se_prop_type_t; + +typedef union { + char *s; + int i; + double d; +} se_prop_read_t; + +struct se_prop_s; +typedef void (*se_prop_reader_t) (struct se_prop_s *, se_prop_read_t *); + +struct se_prop_s { char *id; char *value; + char *xine_id; + int xine_param; + se_prop_reader_t reader; GList *listeners; - int se_type; -} se_prop_t; + se_prop_type_t se_type; + gboolean constant; +}; +typedef struct se_prop_s se_prop_t; -typedef int (*se_prop_cb_t) (void *user_data, se_prop_t *prop); +typedef int (*se_prop_cb_t) (void *, se_t *, se_o_t *, se_prop_t *, se_prop_read_t r); typedef struct { @@ -132,6 +149,7 @@ gchar *se_result_str (se_t *se) ; int se_result_num (se_t *se, JSInt32 *num); +int se_result_double (se_t *se, JSFloat64 *num); /* * create a script engine object (in javascript name space) @@ -165,23 +183,38 @@ /* does nothing if property already exists */ void se_prop_create (se_t *se, se_o_t *o, const char *id, const char *value, - int se_type); + const char *xine_id, int xine_param, + se_prop_type_t se_type, gboolean constant); void se_prop_create_int (se_t *se, se_o_t *o, - const char *id, int value); + const char *id, int value, gboolean constant); +void se_prop_create_double (se_t *se, se_o_t *o, + const char *id, double value, gboolean constant); void se_prop_create_bool (se_t *se, se_o_t *o, - const char *id, int value); + const char *id, int value, gboolean constant); +/* the following two automatically set the reader function */ +void se_prop_create_xine_id (se_t *se, se_o_t *o, + const char *id, const char *xine_id); +void se_prop_create_xine_param (se_t *se, se_o_t *o, + const char *id, int param, + se_prop_type_t se_type); + +void se_prop_set_reader_func (se_t *se, se_o_t *o, + const char *id, se_prop_reader_t); /* creates property if it doesn't exist */ void se_prop_set_int (se_t *se, se_o_t *o, const char *id, int value); +void se_prop_set_double (se_t *se, se_o_t *o, + const char *id, double value); void se_prop_set_bool (se_t *se, se_o_t *o, const char *id, int value); void se_prop_set (se_t *se, se_o_t *o, - const char *id, const char *value, - int se_type); + const char *id, const char *value); char *se_prop_get (se_t *se, se_o_t *o, const char *id); int se_prop_get_int (se_t *se, se_o_t *o, const char *id); +double se_prop_get_double (se_t *se, se_o_t *o, const char *id); +int se_prop_get_bool (se_t *se, se_o_t *o, const char *id); /* add a property observer (callback will be called whenever the * properties value changes |