$(srcdir)/ply-scan.h
MAINTAINERCLEANFILES = Makefile.in
-CLEANFILES = *.script.string
+CLEANFILES = *.string
EXTRA_DIST = stringify.pl
struct _ply_boot_splash_plugin
{
- ply_event_loop_t *loop;
+ ply_event_loop_t *loop;
ply_boot_splash_mode_t mode;
- ply_frame_buffer_t *frame_buffer;
- ply_window_t *window;
+ ply_frame_buffer_t *frame_buffer;
+ ply_window_t *window;
char *script_filename;
char *image_dir;
- script_state *script_state;
- script_op *script_main_op;
- script_lib_sprite_data_t *script_sprite_lib;
- script_lib_image_data_t *script_image_lib;
- script_lib_plymouth_data_t *script_plymouth_lib;
- script_lib_math_data_t *script_math_lib;
+ script_state_t *script_state;
+ script_op_t *script_main_op;
+ script_lib_sprite_data_t *script_sprite_lib;
+ script_lib_image_data_t *script_image_lib;
+ script_lib_plymouth_data_t *script_plymouth_lib;
+ script_lib_math_data_t *script_math_lib;
uint32_t is_animating : 1;
};
plugin->script_math_lib = script_lib_math_setup (plugin->script_state);
ply_trace ("executing script file");
- script_return ret = script_execute (plugin->script_state,
- plugin->script_main_op);
+ script_return_t ret = script_execute (plugin->script_state,
+ plugin->script_main_op);
script_obj_unref (ret.object);
on_timeout (plugin);
#include "script-execute.h"
#include "script-object.h"
-static script_obj *script_evaluate (script_state *state,
- script_exp *exp);
-static script_return script_execute_function_with_parlist (script_state *state,
- script_function *function,
- ply_list_t *parameter_data);
-
-static script_obj *script_evaluate_apply_function (script_state *state,
- script_exp *exp,
- script_obj *(*function)(script_obj *, script_obj *))
+static script_obj_t *script_evaluate (script_state_t *state,
+ script_exp_t *exp);
+static script_return_t script_execute_function_with_parlist (script_state_t *state,
+ script_function_t *function,
+ ply_list_t *parameter_data);
+
+static script_obj_t *script_evaluate_apply_function (script_state_t *state,
+ script_exp_t *exp,
+ script_obj_t *(*function)(script_obj_t *, script_obj_t *))
{
- script_obj *script_obj_a = script_evaluate (state, exp->data.dual.sub_a);
- script_obj *script_obj_b = script_evaluate (state, exp->data.dual.sub_b);
- script_obj *obj = function (script_obj_a, script_obj_b);
+ script_obj_t *script_obj_a = script_evaluate (state, exp->data.dual.sub_a);
+ script_obj_t *script_obj_b = script_evaluate (state, exp->data.dual.sub_b);
+ script_obj_t *obj = function (script_obj_a, script_obj_b);
script_obj_unref (script_obj_a);
script_obj_unref (script_obj_b);
return obj;
}
-static script_obj *script_evaluate_apply_function_and_assign (script_state *state,
- script_exp *exp,
- script_obj *(*function)(script_obj *, script_obj *))
+static script_obj_t *script_evaluate_apply_function_and_assign (script_state_t *state,
+ script_exp_t *exp,
+ script_obj_t *(*function)(script_obj_t *, script_obj_t *))
{
- script_obj *script_obj_a = script_evaluate (state, exp->data.dual.sub_a);
- script_obj *script_obj_b = script_evaluate (state, exp->data.dual.sub_b);
- script_obj *obj = function (script_obj_a, script_obj_b);
+ script_obj_t *script_obj_a = script_evaluate (state, exp->data.dual.sub_a);
+ script_obj_t *script_obj_b = script_evaluate (state, exp->data.dual.sub_b);
+ script_obj_t *obj = function (script_obj_a, script_obj_b);
script_obj_assign (script_obj_a, obj);
script_obj_unref (script_obj_a);
return obj;
}
-static script_obj *script_evaluate_hash (script_state *state,
- script_exp *exp)
+static script_obj_t *script_evaluate_hash (script_state_t *state,
+ script_exp_t *exp)
{
- script_obj *hash = script_evaluate (state, exp->data.dual.sub_a);
- script_obj *key = script_evaluate (state, exp->data.dual.sub_b);
- script_obj *hash_dereffed = script_obj_deref_direct (hash);
- script_obj *obj;
+ script_obj_t *hash = script_evaluate (state, exp->data.dual.sub_a);
+ script_obj_t *key = script_evaluate (state, exp->data.dual.sub_b);
+ script_obj_t *hash_dereffed = script_obj_deref_direct (hash);
+ script_obj_t *obj;
script_obj_deref (&key);
else
{
script_obj_reset (hash);
- script_obj *newhash = script_obj_new_hash ();
+ script_obj_t *newhash = script_obj_new_hash ();
hash->type = SCRIPT_OBJ_TYPE_REF;
hash->data.obj = newhash;
script_obj_deref (&hash);
}
char *name = script_obj_as_string (key);
- script_vareable *vareable = ply_hashtable_lookup (hash->data.hash, name);
+ script_vareable_t *vareable = ply_hashtable_lookup (hash->data.hash, name);
if (vareable)
{
else
{
obj = script_obj_new_null ();
- vareable = malloc (sizeof (script_vareable));
+ vareable = malloc (sizeof (script_vareable_t));
vareable->name = name;
vareable->object = obj;
ply_hashtable_insert (hash->data.hash, vareable->name, vareable);
return obj;
}
-static script_obj *script_evaluate_var (script_state *state,
- script_exp *exp)
+static script_obj_t *script_evaluate_var (script_state_t *state,
+ script_exp_t *exp)
{
char *name = exp->data.string;
- script_obj *obj;
+ script_obj_t *obj;
script_obj_deref (&state->global);
script_obj_deref (&state->local);
assert (state->global->type == SCRIPT_OBJ_TYPE_HASH);
assert (state->local->type == SCRIPT_OBJ_TYPE_HASH);
- script_vareable *vareable = ply_hashtable_lookup (state->local->data.hash,
- name);
+ script_vareable_t *vareable = ply_hashtable_lookup (state->local->data.hash,
+ name);
if (!vareable)
vareable = ply_hashtable_lookup (state->global->data.hash, name);
if (vareable)
}
obj = script_obj_new_null ();
- vareable = malloc (sizeof (script_vareable));
+ vareable = malloc (sizeof (script_vareable_t));
vareable->name = strdup (name);
vareable->object = obj;
return obj;
}
-static script_obj *script_evaluate_assign (script_state *state,
- script_exp *exp)
+static script_obj_t *script_evaluate_assign (script_state_t *state,
+ script_exp_t *exp)
{
- script_obj *script_obj_a = script_evaluate (state, exp->data.dual.sub_a);
- script_obj *script_obj_b = script_evaluate (state, exp->data.dual.sub_b);
+ script_obj_t *script_obj_a = script_evaluate (state, exp->data.dual.sub_a);
+ script_obj_t *script_obj_b = script_evaluate (state, exp->data.dual.sub_b);
script_obj_deref (&script_obj_b);
script_obj_assign (script_obj_a, script_obj_b);
return script_obj_a;
}
-static script_obj *script_evaluate_cmp (script_state *state,
- script_exp *exp)
+static script_obj_t *script_evaluate_cmp (script_state_t *state,
+ script_exp_t *exp)
{
- script_obj *script_obj_a = script_evaluate (state, exp->data.dual.sub_a);
- script_obj *script_obj_b = script_evaluate (state, exp->data.dual.sub_b);
+ script_obj_t *script_obj_a = script_evaluate (state, exp->data.dual.sub_a);
+ script_obj_t *script_obj_b = script_evaluate (state, exp->data.dual.sub_b);
script_obj_deref (&script_obj_a);
script_obj_deref (&script_obj_b);
return script_obj_new_int (reply);
}
-static script_obj *script_evaluate_logic (script_state *state,
- script_exp *exp)
+static script_obj_t *script_evaluate_logic (script_state_t *state,
+ script_exp_t *exp)
{
- script_obj *obj = script_evaluate (state, exp->data.dual.sub_a);
+ script_obj_t *obj = script_evaluate (state, exp->data.dual.sub_a);
if ((exp->type == SCRIPT_EXP_TYPE_AND) && !script_obj_as_bool (obj))
return obj;
return obj;
}
-static script_obj *script_evaluate_unary (script_state *state,
- script_exp *exp)
+static script_obj_t *script_evaluate_unary (script_state_t *state,
+ script_exp_t *exp)
{
- script_obj *obj = script_evaluate (state, exp->data.sub);
- script_obj *new_obj;
+ script_obj_t *obj = script_evaluate (state, exp->data.sub);
+ script_obj_t *new_obj;
script_obj_deref (&obj);
if (exp->type == SCRIPT_EXP_TYPE_NOT)
return new_obj;
}
-static script_obj *script_evaluate_func (script_state *state,
- script_exp *exp)
+static script_obj_t *script_evaluate_func (script_state_t *state,
+ script_exp_t *exp)
{
- script_obj *func = script_evaluate (state, exp->data.function.name);
- script_obj *obj = NULL;
+ script_obj_t *func = script_evaluate (state, exp->data.function.name);
+ script_obj_t *obj = NULL;
script_obj_deref (&func);
parameter_expressions);
while (node_expression)
{
- script_exp *data_exp = ply_list_node_get_data (node_expression);
- script_obj *data_obj = script_evaluate (state, data_exp);
+ script_exp_t *data_exp = ply_list_node_get_data (node_expression);
+ script_obj_t *data_obj = script_evaluate (state, data_exp);
ply_list_append_data (parameter_data, data_obj);
node_expression = ply_list_get_next_node (parameter_expressions,
node_expression);
}
- script_return reply = script_execute_function_with_parlist (
+ script_return_t reply = script_execute_function_with_parlist (
state,
func->data.
function,
ply_list_node_t *node_data = ply_list_get_first_node (parameter_data);
while (node_data)
{
- script_obj *data_obj = ply_list_node_get_data (node_data);
+ script_obj_t *data_obj = ply_list_node_get_data (node_data);
script_obj_unref (data_obj);
node_data = ply_list_get_next_node (parameter_data, node_data);
}
return obj;
}
-static script_obj *script_evaluate (script_state *state,
- script_exp *exp)
+static script_obj_t *script_evaluate (script_state_t *state,
+ script_exp_t *exp)
{
switch (exp->type)
{
assert (0);
}
-static script_return script_execute_list (script_state *state,
- ply_list_t *op_list) /* FIXME script_execute returns the return obj */
+static script_return_t script_execute_list (script_state_t *state,
+ ply_list_t *op_list) /* FIXME script_execute returns the return obj */
{
- script_return reply = {SCRIPT_RETURN_TYPE_NORMAL, NULL};
+ script_return_t reply = {SCRIPT_RETURN_TYPE_NORMAL, NULL};
ply_list_node_t *node = ply_list_get_first_node (op_list);
for (node = ply_list_get_first_node (op_list);
node;
node = ply_list_get_next_node (op_list, node))
{
- script_op *op = ply_list_node_get_data (node);
+ script_op_t *op = ply_list_node_get_data (node);
reply = script_execute (state, op);
switch (reply.type)
{
}
/* parameter_data list should be freed by caller */
-static script_return script_execute_function_with_parlist (script_state *state,
- script_function *function,
- ply_list_t *parameter_data)
+static script_return_t script_execute_function_with_parlist (script_state_t *state,
+ script_function_t *function,
+ ply_list_t *parameter_data)
{
- script_state *sub_state = script_state_init_sub (state);
+ script_state_t *sub_state = script_state_init_sub (state);
ply_list_t *parameter_names = function->parameters;
ply_list_node_t *node_name = ply_list_get_first_node (parameter_names);
ply_list_node_t *node_data = ply_list_get_first_node (parameter_data);
while (node_name && node_data)
{
- script_obj *data_obj = ply_list_node_get_data (node_data);
+ script_obj_t *data_obj = ply_list_node_get_data (node_data);
char *name = ply_list_node_get_data (node_name);
script_obj_hash_add_element (sub_state->local, data_obj, name);
node_data = ply_list_get_next_node (parameter_data, node_data);
}
- script_return reply;
+ script_return_t reply;
switch (function->type)
{
case SCRIPT_FUNCTION_TYPE_SCRIPT:
{
- script_op *op = function->data.script;
+ script_op_t *op = function->data.script;
reply = script_execute (sub_state, op);
break;
}
return reply;
}
-script_return script_execute_function (script_state *state,
- script_function *function,
- script_obj *first_arg,
- ...)
+script_return_t script_execute_function (script_state_t *state,
+ script_function_t *function,
+ script_obj_t *first_arg,
+ ...)
{
- script_return reply;
+ script_return_t reply;
va_list args;
- script_obj *arg;
+ script_obj_t *arg;
ply_list_t *parameter_data = ply_list_new ();
arg = first_arg;
while (arg)
{
ply_list_append_data (parameter_data, arg);
- arg = va_arg (args, script_obj *);
+ arg = va_arg (args, script_obj_t *);
}
va_end (args);
return reply;
}
-script_return script_execute (script_state *state,
- script_op *op)
+script_return_t script_execute (script_state_t *state,
+ script_op_t *op)
{
- script_return reply = {SCRIPT_RETURN_TYPE_NORMAL, NULL};
+ script_return_t reply = {SCRIPT_RETURN_TYPE_NORMAL, NULL};
if (!op) return reply;
switch (op->type)
{
case SCRIPT_OP_TYPE_EXPRESSION:
{
- script_obj *obj = script_evaluate (state, op->data.exp);
+ script_obj_t *obj = script_evaluate (state, op->data.exp);
script_obj_unref (obj); /* there is always a reply from all expressions (even assigns) which we chuck away */
break;
}
case SCRIPT_OP_TYPE_IF:
{
- script_obj *obj = script_evaluate (state, op->data.cond_op.cond);
+ script_obj_t *obj = script_evaluate (state, op->data.cond_op.cond);
if (script_obj_as_bool (obj))
reply = script_execute (state, op->data.cond_op.op1);
else
case SCRIPT_OP_TYPE_WHILE:
case SCRIPT_OP_TYPE_FOR:
{
- script_obj *obj;
+ script_obj_t *obj;
while (1)
{
obj = script_evaluate (state, op->data.cond_op.cond);
return reply;
case SCRIPT_RETURN_TYPE_BREAK:
- return (script_return) {SCRIPT_RETURN_TYPE_NORMAL, NULL};
+ return (script_return_t) {SCRIPT_RETURN_TYPE_NORMAL, NULL};
case SCRIPT_RETURN_TYPE_CONTINUE:
break;
case SCRIPT_OP_TYPE_FUNCTION_DEF:
{
- script_obj *obj = script_evaluate (state, op->data.function_def.name);
+ script_obj_t *obj = script_evaluate (state, op->data.function_def.name);
script_obj_reset (obj);
obj->type = SCRIPT_OBJ_TYPE_FUNCTION;
obj->data.function = op->data.function_def.function;
case SCRIPT_OP_TYPE_RETURN:
{
- script_obj *obj;
+ script_obj_t *obj;
if (op->data.exp) obj = script_evaluate (state, op->data.exp);
else obj = script_obj_new_null ();
- reply = (script_return) {SCRIPT_RETURN_TYPE_RETURN, obj};
+ reply = (script_return_t) {SCRIPT_RETURN_TYPE_RETURN, obj};
break;
}
case SCRIPT_OP_TYPE_BREAK:
{
- reply = (script_return) {SCRIPT_RETURN_TYPE_BREAK, NULL};
+ reply = (script_return_t) {SCRIPT_RETURN_TYPE_BREAK, NULL};
break;
}
case SCRIPT_OP_TYPE_CONTINUE:
{
- reply = (script_return) {SCRIPT_RETURN_TYPE_CONTINUE, NULL};
+ reply = (script_return_t) {SCRIPT_RETURN_TYPE_CONTINUE, NULL};
break;
}
}
#include "script.h"
-script_return script_execute (script_state *state,
- script_op *op);
-script_return script_execute_function (script_state *state,
- script_function *function,
- script_obj *first_arg,
- ...);
+script_return_t script_execute (script_state_t *state,
+ script_op_t *op);
+script_return_t script_execute_function (script_state_t *state,
+ script_function_t *function,
+ script_obj_t *first_arg,
+ ...);
#endif /* SCRIPT_EXECUTE_H */
#define STRINGIFY_VAR script_lib_image_string
#include "script-lib-image.string"
-static void image_free (script_obj *obj)
+static void image_free (script_obj_t *obj)
{
ply_image_t *image = obj->data.native.object_data;
ply_image_free (image);
}
-static script_return image_new (script_state *state,
- void *user_data)
+static script_return_t image_new (script_state_t *state,
+ void *user_data)
{
script_lib_image_data_t *data = user_data;
- script_obj *reply;
+ script_obj_t *reply;
char *path_filename;
char *filename = script_obj_hash_get_string (state->local, "filename");
char *test_string = filename;
}
free (filename);
free (path_filename);
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN, reply};
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN, reply};
}
-static script_return image_get_width (script_state *state,
- void *user_data)
+static script_return_t image_get_width (script_state_t *state,
+ void *user_data)
{
script_lib_image_data_t *data = user_data;
ply_image_t *image = script_obj_hash_get_native_of_class (state->local,
data->class);
if (image)
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_int (ply_image_get_width (image))};
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_null ()};
}
-static script_return image_get_height (script_state *state,
- void *user_data)
+static script_return_t image_get_height (script_state_t *state,
+ void *user_data)
{
script_lib_image_data_t *data = user_data;
ply_image_t *image = script_obj_hash_get_native_of_class (state->local,
data->class);
if (image)
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_int (ply_image_get_height (image))};
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_null ()};
}
-static script_return image_rotate (script_state *state,
- void *user_data)
+static script_return_t image_rotate (script_state_t *state,
+ void *user_data)
{
script_lib_image_data_t *data = user_data;
ply_image_t *image = script_obj_hash_get_native_of_class (state->local,
if (image)
{
ply_image_t *new_image = ply_image_rotate (image,
- ply_image_get_width (
- image) / 2,
- ply_image_get_height (
- image) / 2,
+ ply_image_get_width (image) / 2,
+ ply_image_get_height (image) / 2,
angle);
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_native (new_image,
data->class)};
}
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_null ()};
}
-static script_return image_scale (script_state *state,
- void *user_data)
+static script_return_t image_scale (script_state_t *state,
+ void *user_data)
{
script_lib_image_data_t *data = user_data;
ply_image_t *image = script_obj_hash_get_native_of_class (state->local,
if (image)
{
ply_image_t *new_image = ply_image_resize (image, width, height);
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_native (new_image,
data->class)};
}
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_null ()};
}
-script_lib_image_data_t *script_lib_image_setup (script_state *state,
+script_lib_image_data_t *script_lib_image_setup (script_state_t *state,
char *image_dir)
{
script_lib_image_data_t *data = malloc (sizeof (script_lib_image_data_t));
NULL);
data->script_main_op = script_parse_string (script_lib_image_string);
- script_return ret = script_execute (state, data->script_main_op);
+ script_return_t ret = script_execute (state, data->script_main_op);
script_obj_unref (ret.object);
return data;
typedef struct
{
- script_obj_native_class *class;
- script_op *script_main_op;
+ script_obj_native_class_t *class;
+ script_op_t *script_main_op;
char *image_dir;
} script_lib_image_data_t;
-script_lib_image_data_t *script_lib_image_setup (script_state *state,
- char *image_dir);
+script_lib_image_data_t *script_lib_image_setup (script_state_t *state,
+ char *image_dir);
void script_lib_image_destroy (script_lib_image_data_t *data);
#endif /* SCRIPT_LIB_IMAGE */
#include "script-lib-math.string"
-static script_return script_lib_math_float_from_float_function (script_state *state,
- void *user_data)
+static script_return_t script_lib_math_float_from_float_function (script_state_t *state,
+ void *user_data)
{
float (*function)(float) = user_data;
float value = script_obj_hash_get_float (state->local, "value");
float reply_float = function (value);
- return (script_return) {
+ return (script_return_t) {
SCRIPT_RETURN_TYPE_RETURN, script_obj_new_float (reply_float)
};
}
-static script_return script_lib_math_int_from_float_function (script_state *state,
- void *user_data)
+static script_return_t script_lib_math_int_from_float_function (script_state_t *state,
+ void *user_data)
{
int (*function)(float) = user_data;
float value = script_obj_hash_get_float (state->local, "value");
int reply_int = function (value);
- return (script_return) {
+ return (script_return_t) {
SCRIPT_RETURN_TYPE_RETURN, script_obj_new_int (reply_int)
};
}
return (int) value;
}
-script_lib_math_data_t *script_lib_math_setup (script_state *state)
+script_lib_math_data_t *script_lib_math_setup (script_state_t *state)
{
script_lib_math_data_t *data = malloc (sizeof (script_lib_math_data_t));
NULL);
data->script_main_op = script_parse_string (script_lib_math_string);
- script_return ret = script_execute (state, data->script_main_op);
+ script_return_t ret = script_execute (state, data->script_main_op);
script_obj_unref (ret.object);
return data;
typedef struct
{
- script_op *script_main_op;
+ script_op_t *script_main_op;
} script_lib_math_data_t;
-script_lib_math_data_t *script_lib_math_setup (script_state *state);
+script_lib_math_data_t *script_lib_math_setup (script_state_t *state);
void script_lib_math_destroy (script_lib_math_data_t *data);
#endif /* SCRIPT_LIB_MATH */
#include "script-lib-plymouth.string"
-static script_return plymouth_set_function (script_state *state,
- void *user_data)
+static script_return_t plymouth_set_function (script_state_t *state,
+ void *user_data)
{
- script_obj **script_func = user_data;
- script_obj *obj = script_obj_hash_get_element (state->local, "function");
+ script_obj_t **script_func = user_data;
+ script_obj_t *obj = script_obj_hash_get_element (state->local, "function");
script_obj_deref (&obj);
script_obj_unref (*script_func);
*script_func = NULL;
script_obj_unref (obj);
}
- return (script_return) {
+ return (script_return_t) {
SCRIPT_RETURN_TYPE_RETURN, script_obj_new_null ()
};
}
-script_lib_plymouth_data_t *script_lib_plymouth_setup (script_state *state)
+script_lib_plymouth_data_t *script_lib_plymouth_setup (script_state_t *state)
{
script_lib_plymouth_data_t *data = malloc (sizeof (script_lib_plymouth_data_t));
"function",
NULL);
data->script_main_op = script_parse_string (script_lib_plymouth_string);
- script_return ret = script_execute (state, data->script_main_op);
+ script_return_t ret = script_execute (state, data->script_main_op);
script_obj_unref (ret.object); /* Throw anything sent back away */
return data;
free (data);
}
-void script_lib_plymouth_on_refresh (script_state *state,
+void script_lib_plymouth_on_refresh (script_state_t *state,
script_lib_plymouth_data_t *data)
{
- script_obj *refresh_func_obj = data->script_refresh_func;
+ script_obj_t *refresh_func_obj = data->script_refresh_func;
if (refresh_func_obj
&& (refresh_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
{
- script_return ret = script_execute_function (state,
+ script_return_t ret = script_execute_function (state,
refresh_func_obj->data.function,
NULL);
script_obj_unref (ret.object);
}
}
-void script_lib_plymouth_on_boot_progress (script_state *state,
+void script_lib_plymouth_on_boot_progress (script_state_t *state,
script_lib_plymouth_data_t *data,
float duration,
float progress)
{
- script_obj *boot_progress_func_obj = data->script_boot_progress_func;
+ script_obj_t *boot_progress_func_obj = data->script_boot_progress_func;
if (boot_progress_func_obj
&& (boot_progress_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
{
- script_obj *duration_obj = script_obj_new_float (duration);
- script_obj *progress_obj = script_obj_new_float (progress);
- script_return ret = script_execute_function (state,
+ script_obj_t *duration_obj = script_obj_new_float (duration);
+ script_obj_t *progress_obj = script_obj_new_float (progress);
+ script_return_t ret = script_execute_function (state,
boot_progress_func_obj->data.function,
duration_obj,
progress_obj,
}
}
-void script_lib_plymouth_on_root_mounted (script_state *state,
+void script_lib_plymouth_on_root_mounted (script_state_t *state,
script_lib_plymouth_data_t *data)
{
- script_obj *root_mounted_func_obj = data->script_root_mounted_func;
+ script_obj_t *root_mounted_func_obj = data->script_root_mounted_func;
if (root_mounted_func_obj
&& (root_mounted_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
{
- script_return ret = script_execute_function (state,
- root_mounted_func_obj->data.function,
- NULL);
+ script_return_t ret = script_execute_function (state,
+ root_mounted_func_obj->data.function,
+ NULL);
script_obj_unref (ret.object);
}
}
-void script_lib_plymouth_on_keyboard_input (script_state *state,
+void script_lib_plymouth_on_keyboard_input (script_state_t *state,
script_lib_plymouth_data_t *data,
const char *keyboard_input)
{
- script_obj *keyboard_input_func_obj = data->script_keyboard_input_func;
+ script_obj_t *keyboard_input_func_obj = data->script_keyboard_input_func;
if (keyboard_input_func_obj
&& (keyboard_input_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
{
- script_obj *keyboard_input_obj = script_obj_new_string (keyboard_input);
- script_return ret = script_execute_function (state,
- keyboard_input_func_obj->data.function,
- keyboard_input_obj,
- NULL);
+ script_obj_t *keyboard_input_obj = script_obj_new_string (keyboard_input);
+ script_return_t ret = script_execute_function (state,
+ keyboard_input_func_obj->data.function,
+ keyboard_input_obj,
+ NULL);
script_obj_unref (keyboard_input_obj);
script_obj_unref (ret.object);
}
}
-void script_lib_plymouth_on_update_status (script_state *state,
+void script_lib_plymouth_on_update_status (script_state_t *state,
script_lib_plymouth_data_t *data,
const char *new_status)
{
- script_obj *update_status_func_obj = data->script_update_status_func;
+ script_obj_t *update_status_func_obj = data->script_update_status_func;
if (update_status_func_obj
&& (update_status_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
{
- script_obj *new_status_obj = script_obj_new_string (new_status);
- script_return ret = script_execute_function (state,
- update_status_func_obj->data.function,
- new_status_obj,
- NULL);
+ script_obj_t *new_status_obj = script_obj_new_string (new_status);
+ script_return_t ret = script_execute_function (state,
+ update_status_func_obj->data.function,
+ new_status_obj,
+ NULL);
script_obj_unref (new_status_obj);
script_obj_unref (ret.object);
}
}
-void script_lib_plymouth_on_display_normal (script_state *state,
+void script_lib_plymouth_on_display_normal (script_state_t *state,
script_lib_plymouth_data_t *data)
{
- script_obj *display_normal_func_obj = data->script_display_normal_func;
+ script_obj_t *display_normal_func_obj = data->script_display_normal_func;
if (display_normal_func_obj
&& (display_normal_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
{
- script_return ret = script_execute_function (state,
- display_normal_func_obj->data.function,
- NULL);
+ script_return_t ret = script_execute_function (state,
+ display_normal_func_obj->data.function,
+ NULL);
script_obj_unref (ret.object);
}
}
-void script_lib_plymouth_on_display_password (script_state *state,
+void script_lib_plymouth_on_display_password (script_state_t *state,
script_lib_plymouth_data_t *data,
const char *prompt,
int bullets)
{
- script_obj *display_password_func_obj = data->script_display_password_func;
+ script_obj_t *display_password_func_obj = data->script_display_password_func;
if (display_password_func_obj
&& (display_password_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
{
- script_obj *prompt_obj = script_obj_new_string (prompt);
- script_obj *bullets_obj = script_obj_new_int (bullets);
- script_return ret = script_execute_function (state,
- display_password_func_obj->data.function,
- prompt_obj,
- bullets_obj,
- NULL);
+ script_obj_t *prompt_obj = script_obj_new_string (prompt);
+ script_obj_t *bullets_obj = script_obj_new_int (bullets);
+ script_return_t ret = script_execute_function (state,
+ display_password_func_obj->data.function,
+ prompt_obj,
+ bullets_obj,
+ NULL);
script_obj_unref (prompt_obj);
script_obj_unref (bullets_obj);
script_obj_unref (ret.object);
}
}
-void script_lib_plymouth_on_display_question (script_state *state,
+void script_lib_plymouth_on_display_question (script_state_t *state,
script_lib_plymouth_data_t *data,
const char *prompt,
const char *entry_text)
{
- script_obj *display_question_func_obj = data->script_display_question_func;
+ script_obj_t *display_question_func_obj = data->script_display_question_func;
if (display_question_func_obj
&& (display_question_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
{
- script_obj *prompt_obj = script_obj_new_string (prompt);
- script_obj *entry_text_obj = script_obj_new_string (entry_text);
- script_return ret = script_execute_function (state,
- display_question_func_obj->data.function,
- prompt_obj,
- entry_text_obj,
- NULL);
+ script_obj_t *prompt_obj = script_obj_new_string (prompt);
+ script_obj_t *entry_text_obj = script_obj_new_string (entry_text);
+ script_return_t ret = script_execute_function (state,
+ display_question_func_obj->data.function,
+ prompt_obj,
+ entry_text_obj,
+ NULL);
script_obj_unref (prompt_obj);
script_obj_unref (entry_text_obj);
script_obj_unref (ret.object);
typedef struct
{
- script_op *script_main_op;
- script_obj *script_refresh_func;
- script_obj *script_boot_progress_func;
- script_obj *script_root_mounted_func;
- script_obj *script_keyboard_input_func;
- script_obj *script_update_status_func;
- script_obj *script_display_normal_func;
- script_obj *script_display_password_func;
- script_obj *script_display_question_func;
+ script_op_t *script_main_op;
+ script_obj_t *script_refresh_func;
+ script_obj_t *script_boot_progress_func;
+ script_obj_t *script_root_mounted_func;
+ script_obj_t *script_keyboard_input_func;
+ script_obj_t *script_update_status_func;
+ script_obj_t *script_display_normal_func;
+ script_obj_t *script_display_password_func;
+ script_obj_t *script_display_question_func;
} script_lib_plymouth_data_t;
-script_lib_plymouth_data_t *script_lib_plymouth_setup (script_state *state);
+script_lib_plymouth_data_t *script_lib_plymouth_setup (script_state_t *state);
void script_lib_plymouth_destroy (script_lib_plymouth_data_t *data);
-void script_lib_plymouth_on_refresh (script_state *state,
+void script_lib_plymouth_on_refresh (script_state_t *state,
script_lib_plymouth_data_t *data);
-void script_lib_plymouth_on_boot_progress (script_state *state,
+void script_lib_plymouth_on_boot_progress (script_state_t *state,
script_lib_plymouth_data_t *data,
float duration,
float progress);
-void script_lib_plymouth_on_root_mounted (script_state *state,
+void script_lib_plymouth_on_root_mounted (script_state_t *state,
script_lib_plymouth_data_t *data);
-void script_lib_plymouth_on_keyboard_input (script_state *state,
+void script_lib_plymouth_on_keyboard_input (script_state_t *state,
script_lib_plymouth_data_t *data,
const char *keyboard_input);
-void script_lib_plymouth_on_update_status (script_state *state,
+void script_lib_plymouth_on_update_status (script_state_t *state,
script_lib_plymouth_data_t *data,
const char *new_status);
-void script_lib_plymouth_on_display_normal (script_state *state,
+void script_lib_plymouth_on_display_normal (script_state_t *state,
script_lib_plymouth_data_t *data);
-void script_lib_plymouth_on_display_password (script_state *state,
+void script_lib_plymouth_on_display_password (script_state_t *state,
script_lib_plymouth_data_t *data,
const char *prompt,
int bullets);
-void script_lib_plymouth_on_display_question (script_state *state,
+void script_lib_plymouth_on_display_question (script_state_t *state,
script_lib_plymouth_data_t *data,
const char *prompt,
const char *entry_text);
int width,
int height);
-static void sprite_free (script_obj *obj)
+static void sprite_free (script_obj_t *obj)
{
sprite_t *sprite = obj->data.native.object_data;
sprite->remove_me = true;
}
-static script_return sprite_new (script_state *state,
- void *user_data)
+static script_return_t sprite_new (script_state_t *state,
+ void *user_data)
{
script_lib_sprite_data_t *data = user_data;
- script_obj *reply;
+ script_obj_t *reply;
sprite_t *sprite = calloc (1, sizeof (sprite_t));
ply_list_append_data (data->sprite_list, sprite);
reply = script_obj_new_native (sprite, data->class);
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN, reply};
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN, reply};
}
-static script_return sprite_set_image (script_state *state,
- void *user_data)
+static script_return_t sprite_set_image (script_state_t *state,
+ void *user_data)
{
script_lib_sprite_data_t *data = user_data;
sprite_t *sprite = script_obj_hash_get_native_of_class (state->local,
"sprite",
data->class);
- script_obj *script_obj_image = script_obj_hash_get_element (state->local,
+ script_obj_t *script_obj_image = script_obj_hash_get_element (state->local,
"image");
script_obj_deref (&script_obj_image);
}
script_obj_unref (script_obj_image);
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_null ()};
}
-static script_return sprite_set_x (script_state *state,
- void *user_data)
+static script_return_t sprite_set_x (script_state_t *state,
+ void *user_data)
{
script_lib_sprite_data_t *data = user_data;
sprite_t *sprite = script_obj_hash_get_native_of_class (state->local,
if (sprite)
sprite->x = script_obj_hash_get_int (state->local, "value");
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_null ()};
}
-static script_return sprite_set_y (script_state *state,
- void *user_data)
+static script_return_t sprite_set_y (script_state_t *state,
+ void *user_data)
{
script_lib_sprite_data_t *data = user_data;
sprite_t *sprite = script_obj_hash_get_native_of_class (state->local,
if (sprite)
sprite->y = script_obj_hash_get_int (state->local, "value");
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_null ()};
}
-static script_return sprite_set_z (script_state *state,
- void *user_data)
+static script_return_t sprite_set_z (script_state_t *state,
+ void *user_data)
{
script_lib_sprite_data_t *data = user_data;
sprite_t *sprite = script_obj_hash_get_native_of_class (state->local,
if (sprite)
sprite->z = script_obj_hash_get_int (state->local, "value");
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_null ()};
}
-static script_return sprite_set_opacity (script_state *state,
- void *user_data)
+static script_return_t sprite_set_opacity (script_state_t *state,
+ void *user_data)
{
script_lib_sprite_data_t *data = user_data;
sprite_t *sprite = script_obj_hash_get_native_of_class (state->local,
if (sprite)
sprite->opacity = script_obj_hash_get_float (state->local, "value");
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_null ()};
}
-static script_return sprite_window_get_width (script_state *state,
- void *user_data)
+static script_return_t sprite_window_get_width (script_state_t *state,
+ void *user_data)
{
script_lib_sprite_data_t *data = user_data;
ply_frame_buffer_t *frame_buffer = ply_window_get_frame_buffer (data->window);
ply_frame_buffer_area_t area;
ply_frame_buffer_get_size (frame_buffer, &area);
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_int (area.width)};
}
-static script_return sprite_window_get_height (script_state *state,
- void *user_data)
+static script_return_t sprite_window_get_height (script_state_t *state,
+ void *user_data)
{
script_lib_sprite_data_t *data = user_data;
ply_frame_buffer_t *frame_buffer = ply_window_get_frame_buffer (data->window);
ply_frame_buffer_area_t area;
ply_frame_buffer_get_size (frame_buffer, &area);
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_int (area.height)};
}
-static uint32_t extract_rgb_color (script_state *state)
+static uint32_t extract_rgb_color (script_state_t *state)
{
uint8_t red = CLAMP (255 * script_obj_hash_get_float (state->local, "red"), 0, 255);
uint8_t green = CLAMP (255 * script_obj_hash_get_float (state->local, "green"), 0, 255);
return (uint32_t) red << 16 | green << 8 | blue;
}
-static script_return sprite_window_set_background_top_color (script_state *state,
- void *user_data)
+static script_return_t sprite_window_set_background_top_color (script_state_t *state,
+ void *user_data)
{
script_lib_sprite_data_t *data = user_data;
data->background_color_start = extract_rgb_color (state);
data->full_refresh = true;
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_null ()};
}
-static script_return sprite_window_set_background_bottom_color (script_state *state,
- void *user_data)
+static script_return_t sprite_window_set_background_bottom_color (script_state_t *state,
+ void *user_data)
{
script_lib_sprite_data_t *data = user_data;
data->background_color_end = extract_rgb_color (state);
data->full_refresh = true;
- return (script_return) {SCRIPT_RETURN_TYPE_RETURN,
+ return (script_return_t) {SCRIPT_RETURN_TYPE_RETURN,
script_obj_new_null ()};
}
ply_frame_buffer_unpause_updates (frame_buffer);
}
-script_lib_sprite_data_t *script_lib_sprite_setup (script_state *state,
- ply_window_t *window)
+script_lib_sprite_data_t *script_lib_sprite_setup (script_state_t *state,
+ ply_window_t *window)
{
script_lib_sprite_data_t *data = malloc (sizeof (script_lib_sprite_data_t));
data->background_color_start = 0x000000;
data->background_color_end = 0x000000;
data->full_refresh = true;
- script_return ret = script_execute (state, data->script_main_op);
+ script_return_t ret = script_execute (state, data->script_main_op);
script_obj_unref (ret.object);
return data;
}
{
ply_window_t *window;
ply_list_t *sprite_list;
- script_obj_native_class *class;
- script_op *script_main_op;
+ script_obj_native_class_t *class;
+ script_op_t *script_main_op;
uint32_t background_color_start;
uint32_t background_color_end;
bool full_refresh;
typedef struct
{
- int x;
- int y;
- int z;
- float opacity;
- int old_x;
- int old_y;
- int old_z;
- int old_width;
- int old_height;
- float old_opacity;
- bool refresh_me;
- bool remove_me;
- ply_image_t *image;
- script_obj *image_obj;
+ int x;
+ int y;
+ int z;
+ float opacity;
+ int old_x;
+ int old_y;
+ int old_z;
+ int old_width;
+ int old_height;
+ float old_opacity;
+ bool refresh_me;
+ bool remove_me;
+ ply_image_t *image;
+ script_obj_t *image_obj;
} sprite_t;
-script_lib_sprite_data_t *script_lib_sprite_setup (script_state *state,
- ply_window_t *window);
+script_lib_sprite_data_t *script_lib_sprite_setup (script_state_t *state,
+ ply_window_t *window);
void script_lib_sprite_refresh (script_lib_sprite_data_t *data);
void script_lib_sprite_destroy (script_lib_sprite_data_t *data);
#include "script.h"
#include "script-object.h"
-char *script_obj_print (script_obj *obj);
-void script_obj_reset (script_obj *obj);
+char *script_obj_print (script_obj_t *obj);
+void script_obj_reset (script_obj_t *obj);
-void script_obj_free (script_obj *obj)
+void script_obj_free (script_obj_t *obj)
{
assert (!obj->refcount);
script_obj_reset (obj);
free (obj);
}
-void script_obj_ref (script_obj *obj)
+void script_obj_ref (script_obj_t *obj)
{
obj->refcount++;
}
-void script_obj_unref (script_obj *obj)
+void script_obj_unref (script_obj_t *obj)
{
if (!obj) return;
assert (obj->refcount > 0);
void *data,
void *user_data)
{
- script_vareable *vareable = data;
+ script_vareable_t *vareable = data;
script_obj_unref (vareable->object);
free (vareable->name);
free (vareable);
}
-void script_obj_reset (script_obj *obj)
+void script_obj_reset (script_obj_t *obj)
{
switch (obj->type)
{
obj->type = SCRIPT_OBJ_TYPE_NULL;
}
-script_obj *script_obj_deref_direct (script_obj *obj)
+script_obj_t *script_obj_deref_direct (script_obj_t *obj)
{
while (obj->type == SCRIPT_OBJ_TYPE_REF)
obj = obj->data.obj;
return obj;
}
-void script_obj_deref (script_obj **obj_ptr)
+void script_obj_deref (script_obj_t **obj_ptr)
{
- script_obj *obj = *obj_ptr;
+ script_obj_t *obj = *obj_ptr;
obj = script_obj_deref_direct (obj);
script_obj_ref (obj);
void *data,
void *user_data)
{
- script_vareable *vareable = data;
+ script_vareable_t *vareable = data;
char *string = script_obj_print (vareable->object);
char *reply;
char *prev = *(char **) user_data;
*(char **) user_data = reply;
}
-char *script_obj_print (script_obj *obj)
+char *script_obj_print (script_obj_t *obj)
{
char *reply;
return NULL;
}
-script_obj *script_obj_new_null (void)
+script_obj_t *script_obj_new_null (void)
{
- script_obj *obj = malloc (sizeof (script_obj));
+ script_obj_t *obj = malloc (sizeof (script_obj_t));
obj->type = SCRIPT_OBJ_TYPE_NULL;
obj->refcount = 1;
return obj;
}
-script_obj *script_obj_new_int (int number)
+script_obj_t *script_obj_new_int (int number)
{
- script_obj *obj = malloc (sizeof (script_obj));
+ script_obj_t *obj = malloc (sizeof (script_obj_t));
obj->type = SCRIPT_OBJ_TYPE_INT;
obj->refcount = 1;
return obj;
}
-script_obj *script_obj_new_float (float number)
+script_obj_t *script_obj_new_float (float number)
{
if (isnan (number)) return script_obj_new_null ();
- script_obj *obj = malloc (sizeof (script_obj));
+ script_obj_t *obj = malloc (sizeof (script_obj_t));
obj->type = SCRIPT_OBJ_TYPE_FLOAT;
obj->refcount = 1;
obj->data.floatpoint = number;
return obj;
}
-script_obj *script_obj_new_string (const char *string)
+script_obj_t *script_obj_new_string (const char *string)
{
if (!string) return script_obj_new_null ();
- script_obj *obj = malloc (sizeof (script_obj));
+ script_obj_t *obj = malloc (sizeof (script_obj_t));
obj->type = SCRIPT_OBJ_TYPE_STRING;
obj->refcount = 1;
obj->data.string = strdup (string);
return obj;
}
-script_obj *script_obj_new_hash (void)
+script_obj_t *script_obj_new_hash (void)
{
- script_obj *obj = malloc (sizeof (script_obj));
+ script_obj_t *obj = malloc (sizeof (script_obj_t));
obj->type = SCRIPT_OBJ_TYPE_HASH;
obj->data.hash = ply_hashtable_new (ply_hashtable_string_hash,
return obj;
}
-script_obj *script_obj_new_function (script_function *function)
+script_obj_t *script_obj_new_function (script_function_t *function)
{
- script_obj *obj = malloc (sizeof (script_obj));
+ script_obj_t *obj = malloc (sizeof (script_obj_t));
obj->type = SCRIPT_OBJ_TYPE_FUNCTION;
obj->data.function = function;
return obj;
}
-script_obj *script_obj_new_ref (script_obj *sub_obj)
+script_obj_t *script_obj_new_ref (script_obj_t *sub_obj)
{
- script_obj *obj = malloc (sizeof (script_obj));
+ script_obj_t *obj = malloc (sizeof (script_obj_t));
obj->type = SCRIPT_OBJ_TYPE_REF;
obj->data.obj = sub_obj;
return obj;
}
-script_obj *script_obj_new_native (void *object_data,
- script_obj_native_class *class)
+script_obj_t *script_obj_new_native (void *object_data,
+ script_obj_native_class_t *class)
{
if (!object_data) return script_obj_new_null ();
- script_obj *obj = malloc (sizeof (script_obj));
+ script_obj_t *obj = malloc (sizeof (script_obj_t));
obj->type = SCRIPT_OBJ_TYPE_NATIVE;
obj->data.native.class = class;
obj->data.native.object_data = object_data;
return obj;
}
-int script_obj_as_int (script_obj *obj)
+int script_obj_as_int (script_obj_t *obj)
{ /* If in then reply contents, otherwise reply 0 */
obj = script_obj_deref_direct (obj);
switch (obj->type)
return 0;
}
-float script_obj_as_float (script_obj *obj)
+float script_obj_as_float (script_obj_t *obj)
{ /* If in then reply contents, otherwise reply 0 */
obj = script_obj_deref_direct (obj);
switch (obj->type)
return NAN;
}
-bool script_obj_as_bool (script_obj *obj)
+bool script_obj_as_bool (script_obj_t *obj)
{ /* False objects are NULL, 0, "" */
obj = script_obj_deref_direct (obj);
switch (obj->type)
return false;
}
-char *script_obj_as_string (script_obj *obj) /* reply is strdupped and may be NULL */
+char *script_obj_as_string (script_obj_t *obj) /* reply is strdupped and may be NULL */
{
obj = script_obj_deref_direct (obj);
char *reply;
return false;
}
-void *script_obj_as_native_of_class (script_obj *obj,
- script_obj_native_class *class)
+void *script_obj_as_native_of_class (script_obj_t *obj,
+ script_obj_native_class_t *class)
{
obj = script_obj_deref_direct (obj);
if (script_obj_is_native_of_class (obj, class))
return NULL;
}
-void *script_obj_as_native_of_class_name (script_obj *obj,
+void *script_obj_as_native_of_class_name (script_obj_t *obj,
const char *class_name)
{
obj = script_obj_deref_direct (obj);
return NULL;
}
-bool script_obj_is_null (script_obj *obj)
+bool script_obj_is_null (script_obj_t *obj)
{
obj = script_obj_deref_direct (obj);
return obj->type == SCRIPT_OBJ_TYPE_NULL;
}
-bool script_obj_is_int (script_obj *obj)
+bool script_obj_is_int (script_obj_t *obj)
{
obj = script_obj_deref_direct (obj);
return obj->type == SCRIPT_OBJ_TYPE_INT;
}
-bool script_obj_is_float (script_obj *obj)
+bool script_obj_is_float (script_obj_t *obj)
{
obj = script_obj_deref_direct (obj);
return obj->type == SCRIPT_OBJ_TYPE_FLOAT;
}
-bool script_obj_is_number (script_obj *obj) /* Float or Int */
+bool script_obj_is_number (script_obj_t *obj) /* Float or Int */
{
obj = script_obj_deref_direct (obj);
return obj->type == SCRIPT_OBJ_TYPE_INT || obj->type == SCRIPT_OBJ_TYPE_FLOAT;
}
-bool script_obj_is_string (script_obj *obj)
+bool script_obj_is_string (script_obj_t *obj)
{
obj = script_obj_deref_direct (obj);
return obj->type == SCRIPT_OBJ_TYPE_STRING;
}
-bool script_obj_is_hash (script_obj *obj)
+bool script_obj_is_hash (script_obj_t *obj)
{
obj = script_obj_deref_direct (obj);
return obj->type == SCRIPT_OBJ_TYPE_HASH;
}
-bool script_obj_is_function (script_obj *obj)
+bool script_obj_is_function (script_obj_t *obj)
{
obj = script_obj_deref_direct (obj);
return obj->type == SCRIPT_OBJ_TYPE_FUNCTION;
}
-bool script_obj_is_native (script_obj *obj)
+bool script_obj_is_native (script_obj_t *obj)
{
obj = script_obj_deref_direct (obj);
return obj->type == SCRIPT_OBJ_TYPE_NATIVE;
}
-bool script_obj_is_native_of_class (script_obj *obj,
- script_obj_native_class *class)
+bool script_obj_is_native_of_class (script_obj_t *obj,
+ script_obj_native_class_t *class)
{
obj = script_obj_deref_direct (obj);
return obj->type == SCRIPT_OBJ_TYPE_NATIVE && obj->data.native.class == class;
}
-bool script_obj_is_native_of_class_name (script_obj *obj,
- const char *class_name)
+bool script_obj_is_native_of_class_name (script_obj_t *obj,
+ const char *class_name)
{
obj = script_obj_deref_direct (obj);
return obj->type == SCRIPT_OBJ_TYPE_NATIVE && !strcmp (
class_name);
}
-void script_obj_assign (script_obj *obj_a,
- script_obj *obj_b)
+void script_obj_assign (script_obj_t *obj_a,
+ script_obj_t *obj_b)
{
obj_b = script_obj_deref_direct (obj_b);
if (obj_a == obj_b) return; /* FIXME triple check this */
}
}
-script_obj *script_obj_hash_get_element (script_obj *hash,
- const char *name)
+script_obj_t *script_obj_hash_get_element (script_obj_t *hash,
+ const char *name)
{
assert (hash->type == SCRIPT_OBJ_TYPE_HASH);
- script_vareable *vareable = ply_hashtable_lookup (hash->data.hash,
- (void *) name);
- script_obj *obj;
+ script_vareable_t *vareable = ply_hashtable_lookup (hash->data.hash,
+ (void *) name);
+ script_obj_t *obj;
if (vareable)
obj = vareable->object;
else
{
obj = script_obj_new_null ();
- vareable = malloc (sizeof (script_vareable));
+ vareable = malloc (sizeof (script_vareable_t));
vareable->name = strdup (name);
vareable->object = obj;
ply_hashtable_insert (hash->data.hash, vareable->name, vareable);
return obj;
}
-int script_obj_hash_get_int (script_obj *hash,
- const char *name)
+int script_obj_hash_get_int (script_obj_t *hash,
+ const char *name)
{
- script_obj *obj = script_obj_hash_get_element (hash, name);
+ script_obj_t *obj = script_obj_hash_get_element (hash, name);
int reply = script_obj_as_int (obj);
script_obj_unref (obj);
return reply;
}
-float script_obj_hash_get_float (script_obj *hash,
- const char *name)
+float script_obj_hash_get_float (script_obj_t *hash,
+ const char *name)
{
- script_obj *obj = script_obj_hash_get_element (hash, name);
+ script_obj_t *obj = script_obj_hash_get_element (hash, name);
float reply = script_obj_as_float (obj);
script_obj_unref (obj);
return reply;
}
-bool script_obj_hash_get_bool (script_obj *hash,
- const char *name)
+bool script_obj_hash_get_bool (script_obj_t *hash,
+ const char *name)
{
- script_obj *obj = script_obj_hash_get_element (hash, name);
+ script_obj_t *obj = script_obj_hash_get_element (hash, name);
bool reply = script_obj_as_bool (obj);
script_obj_unref (obj);
return reply;
}
-char *script_obj_hash_get_string (script_obj *hash,
- const char *name)
+char *script_obj_hash_get_string (script_obj_t *hash,
+ const char *name)
{
- script_obj *obj = script_obj_hash_get_element (hash, name);
+ script_obj_t *obj = script_obj_hash_get_element (hash, name);
char *reply = script_obj_as_string (obj);
script_obj_unref (obj);
return reply;
}
-void *script_obj_hash_get_native_of_class (script_obj *hash,
- const char *name,
- script_obj_native_class *class)
+void *script_obj_hash_get_native_of_class (script_obj_t *hash,
+ const char *name,
+ script_obj_native_class_t *class)
{
- script_obj *obj = script_obj_hash_get_element (hash, name);
+ script_obj_t *obj = script_obj_hash_get_element (hash, name);
void *reply = script_obj_as_native_of_class (obj, class);
script_obj_unref (obj);
return reply;
}
-void *script_obj_hash_get_native_of_class_name (script_obj *hash,
- const char *name,
- const char *class_name)
+void *script_obj_hash_get_native_of_class_name (script_obj_t *hash,
+ const char *name,
+ const char *class_name)
{
- script_obj *obj = script_obj_hash_get_element (hash, name);
+ script_obj_t *obj = script_obj_hash_get_element (hash, name);
void *reply = script_obj_as_native_of_class_name (obj, class_name);
script_obj_unref (obj);
return reply;
}
-void script_obj_hash_add_element (script_obj *hash,
- script_obj *element,
- const char *name)
+void script_obj_hash_add_element (script_obj_t *hash,
+ script_obj_t *element,
+ const char *name)
{
assert (hash->type == SCRIPT_OBJ_TYPE_HASH);
- script_obj *obj = script_obj_hash_get_element (hash, name);
+ script_obj_t *obj = script_obj_hash_get_element (hash, name);
script_obj_assign (obj, element);
script_obj_unref (obj);
}
-script_obj *script_obj_plus (script_obj *script_obj_a,
- script_obj *script_obj_b)
+script_obj_t *script_obj_plus (script_obj_t *script_obj_a,
+ script_obj_t *script_obj_b)
{
if (script_obj_is_string (script_obj_a) || script_obj_is_string (script_obj_b))
{
- script_obj *obj;
+ script_obj_t *obj;
char *string_a = script_obj_as_string (script_obj_a);
char *string_b = script_obj_as_string (script_obj_b);
if (string_a && string_b)
return script_obj_new_null ();
}
-script_obj *script_obj_minus (script_obj *script_obj_a,
- script_obj *script_obj_b)
+script_obj_t *script_obj_minus (script_obj_t *script_obj_a,
+ script_obj_t *script_obj_b)
{
if (script_obj_is_number (script_obj_a) && script_obj_is_number (script_obj_b))
{
return script_obj_new_null ();
}
-script_obj *script_obj_mul (script_obj *script_obj_a,
- script_obj *script_obj_b)
+script_obj_t *script_obj_mul (script_obj_t *script_obj_a,
+ script_obj_t *script_obj_b)
{
if (script_obj_is_number (script_obj_a) && script_obj_is_number (script_obj_b))
{
return script_obj_new_null ();
}
-script_obj *script_obj_div (script_obj *script_obj_a,
- script_obj *script_obj_b)
+script_obj_t *script_obj_div (script_obj_t *script_obj_a,
+ script_obj_t *script_obj_b)
{
if (script_obj_is_number (script_obj_a) && script_obj_is_number (script_obj_b))
{
return script_obj_new_null ();
}
-script_obj *script_obj_mod (script_obj *script_obj_a,
- script_obj *script_obj_b)
+script_obj_t *script_obj_mod (script_obj_t *script_obj_a,
+ script_obj_t *script_obj_b)
{
if (script_obj_is_number (script_obj_a) && script_obj_is_number (script_obj_b))
{
#include "script.h"
-void script_obj_free (script_obj *obj);
-void script_obj_ref (script_obj *obj);
-void script_obj_unref (script_obj *obj);
-void script_obj_reset (script_obj *obj);
-script_obj *script_obj_deref_direct (script_obj *obj);
-void script_obj_deref (script_obj **obj_ptr);
-char *script_obj_print (script_obj *obj);
-script_obj *script_obj_new_int (int number);
-script_obj *script_obj_new_float (float number);
-script_obj *script_obj_new_string (const char *string);
-script_obj *script_obj_new_null (void);
-script_obj *script_obj_new_hash (void);
-script_obj *script_obj_new_function (script_function *function);
-script_obj *script_obj_new_ref (script_obj *sub_obj);
+void script_obj_free (script_obj_t *obj);
+void script_obj_ref (script_obj_t *obj);
+void script_obj_unref (script_obj_t *obj);
+void script_obj_reset (script_obj_t *obj);
+script_obj_t *script_obj_deref_direct (script_obj_t *obj);
+void script_obj_deref (script_obj_t **obj_ptr);
+char *script_obj_print (script_obj_t *obj);
+script_obj_t *script_obj_new_int (int number);
+script_obj_t *script_obj_new_float (float number);
+script_obj_t *script_obj_new_string (const char *string);
+script_obj_t *script_obj_new_null (void);
+script_obj_t *script_obj_new_hash (void);
+script_obj_t *script_obj_new_function (script_function_t *function);
+script_obj_t *script_obj_new_ref (script_obj_t *sub_obj);
-script_obj *script_obj_new_native (void *object_data,
- script_obj_native_class * class );
-int script_obj_as_int (script_obj *obj);
-float script_obj_as_float (script_obj *obj);
-bool script_obj_as_bool (script_obj *obj);
-char *script_obj_as_string (script_obj *obj);
+script_obj_t *script_obj_new_native (void *object_data,
+ script_obj_native_class_t *class );
+int script_obj_as_int (script_obj_t *obj);
+float script_obj_as_float (script_obj_t *obj);
+bool script_obj_as_bool (script_obj_t *obj);
+char *script_obj_as_string (script_obj_t *obj);
-void *script_obj_as_native_of_class (script_obj * obj,
- script_obj_native_class * class );
-void *script_obj_as_native_of_class_name (script_obj *obj,
- const char *class_name);
-bool script_obj_is_null (script_obj *obj);
-bool script_obj_is_int (script_obj *obj);
-bool script_obj_is_float (script_obj *obj);
-bool script_obj_is_string (script_obj *obj);
-bool script_obj_is_hash (script_obj *obj);
-bool script_obj_is_function (script_obj *obj);
-bool script_obj_is_native (script_obj *obj);
+void *script_obj_as_native_of_class (script_obj_t *obj,
+ script_obj_native_class_t *class );
+void *script_obj_as_native_of_class_name (script_obj_t *obj,
+ const char *class_name);
+bool script_obj_is_null (script_obj_t *obj);
+bool script_obj_is_int (script_obj_t *obj);
+bool script_obj_is_float (script_obj_t *obj);
+bool script_obj_is_string (script_obj_t *obj);
+bool script_obj_is_hash (script_obj_t *obj);
+bool script_obj_is_function (script_obj_t *obj);
+bool script_obj_is_native (script_obj_t *obj);
-bool script_obj_is_native_of_class (script_obj * obj,
- script_obj_native_class * class );
-bool script_obj_is_native_of_class_name (script_obj *obj,
- const char *class_name);
-void script_obj_assign (script_obj *obj_a,
- script_obj *obj_b);
-script_obj *script_obj_hash_get_element (script_obj *hash,
- const char *name);
-int script_obj_hash_get_int (script_obj *hash,
- const char *name);
-float script_obj_hash_get_float (script_obj *hash,
- const char *name);
-bool script_obj_hash_get_bool (script_obj *hash,
- const char *name);
-char *script_obj_hash_get_string (script_obj *hash,
- const char *name);
+bool script_obj_is_native_of_class (script_obj_t * obj,
+ script_obj_native_class_t *class );
+bool script_obj_is_native_of_class_name (script_obj_t *obj,
+ const char *class_name);
+void script_obj_assign (script_obj_t *obj_a,
+ script_obj_t *obj_b);
+script_obj_t *script_obj_hash_get_element (script_obj_t *hash,
+ const char *name);
+int script_obj_hash_get_int (script_obj_t *hash,
+ const char *name);
+float script_obj_hash_get_float (script_obj_t *hash,
+ const char *name);
+bool script_obj_hash_get_bool (script_obj_t *hash,
+ const char *name);
+char *script_obj_hash_get_string (script_obj_t *hash,
+ const char *name);
-void *script_obj_hash_get_native_of_class (script_obj * hash,
- const char *name,
- script_obj_native_class * class );
-void *script_obj_hash_get_native_of_class_name (script_obj *hash,
- const char *name,
- const char *class_name);
-void script_obj_hash_add_element (script_obj *hash,
- script_obj *element,
- const char *name);
-script_obj *script_obj_plus (script_obj *script_obj_a_in,
- script_obj *script_obj_b_in);
-script_obj *script_obj_minus (script_obj *script_obj_a_in,
- script_obj *script_obj_b_in);
-script_obj *script_obj_mul (script_obj *script_obj_a_in,
- script_obj *script_obj_b_in);
-script_obj *script_obj_div (script_obj *script_obj_a_in,
- script_obj *script_obj_b_in);
-script_obj *script_obj_mod (script_obj *script_obj_a_in,
- script_obj *script_obj_b_in);
+void *script_obj_hash_get_native_of_class (script_obj_t *hash,
+ const char *name,
+ script_obj_native_class_t *class );
+void *script_obj_hash_get_native_of_class_name (script_obj_t *hash,
+ const char *name,
+ const char *class_name);
+void script_obj_hash_add_element (script_obj_t *hash,
+ script_obj_t *element,
+ const char *name);
+script_obj_t *script_obj_plus (script_obj_t *script_obj_a_in,
+ script_obj_t *script_obj_b_in);
+script_obj_t *script_obj_minus (script_obj_t *script_obj_a_in,
+ script_obj_t *script_obj_b_in);
+script_obj_t *script_obj_mul (script_obj_t *script_obj_a_in,
+ script_obj_t *script_obj_b_in);
+script_obj_t *script_obj_div (script_obj_t *script_obj_a_in,
+ script_obj_t *script_obj_b_in);
+script_obj_t *script_obj_mod (script_obj_t *script_obj_a_in,
+ script_obj_t *script_obj_b_in);
#endif /* SCRIPT_OBJECT */
#define WITH_SEMIES
-static script_op *script_parse_op (ply_scan_t *scan);
-static script_exp *script_parse_exp (ply_scan_t *scan);
+static script_op_t *script_parse_op (ply_scan_t *scan);
+static script_exp_t *script_parse_exp (ply_scan_t *scan);
static ply_list_t *script_parse_op_list (ply_scan_t *scan);
static void script_parse_op_list_free (ply_list_t *op_list);
expected);
}
-static script_exp *script_parse_exp_tm (ply_scan_t *scan)
+static script_exp_t *script_parse_exp_tm (ply_scan_t *scan)
{
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
- script_exp *exp = NULL;
+ script_exp_t *exp = NULL;
if (curtoken->type == PLY_SCAN_TOKEN_TYPE_INTEGER)
{
- exp = malloc (sizeof (script_exp));
+ exp = malloc (sizeof (script_exp_t));
exp->type = SCRIPT_EXP_TYPE_TERM_INT;
exp->data.integer = curtoken->data.integer;
ply_scan_get_next_token (scan);
}
if (curtoken->type == PLY_SCAN_TOKEN_TYPE_FLOAT)
{
- exp = malloc (sizeof (script_exp));
+ exp = malloc (sizeof (script_exp_t));
exp->type = SCRIPT_EXP_TYPE_TERM_FLOAT;
exp->data.floatpoint = curtoken->data.floatpoint;
ply_scan_get_next_token (scan);
}
if (curtoken->type == PLY_SCAN_TOKEN_TYPE_IDENTIFIER)
{
- exp = malloc (sizeof (script_exp));
+ exp = malloc (sizeof (script_exp_t));
if (!strcmp (curtoken->data.string, "NULL"))
exp->type = SCRIPT_EXP_TYPE_TERM_NULL;
else if (!strcmp (curtoken->data.string, "global"))
}
if (curtoken->type == PLY_SCAN_TOKEN_TYPE_STRING)
{
- exp = malloc (sizeof (script_exp));
+ exp = malloc (sizeof (script_exp_t));
exp->type = SCRIPT_EXP_TYPE_TERM_STRING;
exp->data.string = strdup (curtoken->data.string);
ply_scan_get_next_token (scan);
return exp;
}
-static script_exp *script_parse_exp_pi (ply_scan_t *scan)
+static script_exp_t *script_parse_exp_pi (ply_scan_t *scan)
{
- script_exp *exp = script_parse_exp_tm (scan);
+ script_exp_t *exp = script_parse_exp_tm (scan);
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
while (true)
if (curtoken->type != PLY_SCAN_TOKEN_TYPE_SYMBOL) break;
if (curtoken->data.symbol == '(')
{
- script_exp *func = malloc (sizeof (script_exp));
+ script_exp_t *func = malloc (sizeof (script_exp_t));
ply_list_t *parameters = ply_list_new ();
ply_scan_get_next_token (scan);
while (true)
{
if ((curtoken->type == PLY_SCAN_TOKEN_TYPE_SYMBOL)
&& (curtoken->data.symbol == ')')) break;
- script_exp *parameter = script_parse_exp (scan);
+ script_exp_t *parameter = script_parse_exp (scan);
ply_list_append_data (parameters, parameter);
exp->data.function.parameters = parameters;
continue;
}
- script_exp *key;
+ script_exp_t *key;
if (curtoken->data.symbol == '.')
{
ply_scan_get_next_token (scan);
if (curtoken->type == PLY_SCAN_TOKEN_TYPE_IDENTIFIER)
{
- key = malloc (sizeof (script_exp));
+ key = malloc (sizeof (script_exp_t));
key->type = SCRIPT_EXP_TYPE_TERM_STRING;
key->data.string = strdup (curtoken->data.string);
}
else if (curtoken->type == PLY_SCAN_TOKEN_TYPE_INTEGER) /* errrr, integer keys without being [] bracketed */
{
- key = malloc (sizeof (script_exp)); /* This is broken with floats as obj.10.6 is obj[10.6] and not obj[10][6] */
+ key = malloc (sizeof (script_exp_t)); /* This is broken with floats as obj.10.6 is obj[10.6] and not obj[10][6] */
key->type = SCRIPT_EXP_TYPE_TERM_INT;
key->data.integer = curtoken->data.integer;
}
curtoken = ply_scan_get_next_token (scan);
}
else break;
- script_exp *hash = malloc (sizeof (script_exp));
+ script_exp_t *hash = malloc (sizeof (script_exp_t));
hash->type = SCRIPT_EXP_TYPE_HASH;
hash->data.dual.sub_a = exp;
hash->data.dual.sub_b = key;
return exp;
}
-static script_exp *script_parse_exp_pr (ply_scan_t *scan)
+static script_exp_t *script_parse_exp_pr (ply_scan_t *scan)
{
- script_exp_type type;
+ script_exp_type_t type;
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
ply_scan_token_t *peektoken = ply_scan_peek_next_token (scan);
}
else
return script_parse_exp_pi (scan);
- script_exp *exp = malloc (sizeof (script_exp));
+ script_exp_t *exp = malloc (sizeof (script_exp_t));
exp->type = type;
exp->data.sub = script_parse_exp_pr (scan);
return exp;
return script_parse_exp_pi (scan);
}
-static script_exp *script_parse_exp_po (ply_scan_t *scan)
+static script_exp_t *script_parse_exp_po (ply_scan_t *scan)
{
- script_exp *exp = script_parse_exp_pr (scan);
+ script_exp_t *exp = script_parse_exp_pr (scan);
while (true)
{
{
ply_scan_get_next_token (scan);
ply_scan_get_next_token (scan);
- script_exp *new_exp = malloc (sizeof (script_exp));
+ script_exp_t *new_exp = malloc (sizeof (script_exp_t));
new_exp->type = SCRIPT_EXP_TYPE_POST_INC;
new_exp->data.sub = exp;
exp = new_exp;
{
ply_scan_get_next_token (scan);
ply_scan_get_next_token (scan);
- script_exp *new_exp = malloc (sizeof (script_exp));
+ script_exp_t *new_exp = malloc (sizeof (script_exp_t));
new_exp->type = SCRIPT_EXP_TYPE_POST_DEC;
new_exp->data.sub = exp;
exp = new_exp;
return exp;
}
-static script_exp *script_parse_exp_md (ply_scan_t *scan)
+static script_exp_t *script_parse_exp_md (ply_scan_t *scan)
{
- script_exp *sub_a = script_parse_exp_po (scan);
+ script_exp_t *sub_a = script_parse_exp_po (scan);
if (!sub_a) return NULL;
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
&& !(peektoken->type == PLY_SCAN_TOKEN_TYPE_SYMBOL
&& peektoken->data.symbol == '='))
{
- script_exp *exp = malloc (sizeof (script_exp));
+ script_exp_t *exp = malloc (sizeof (script_exp_t));
if (curtoken->data.symbol == '*') exp->type = SCRIPT_EXP_TYPE_MUL;
else if (curtoken->data.symbol == '/') exp->type = SCRIPT_EXP_TYPE_DIV;
else exp->type = SCRIPT_EXP_TYPE_MOD;
return sub_a;
}
-static script_exp *script_parse_exp_pm (ply_scan_t *scan)
+static script_exp_t *script_parse_exp_pm (ply_scan_t *scan)
{
- script_exp *sub_a = script_parse_exp_md (scan);
+ script_exp_t *sub_a = script_parse_exp_md (scan);
if (!sub_a) return NULL;
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
&& !(peektoken->type == PLY_SCAN_TOKEN_TYPE_SYMBOL
&& peektoken->data.symbol == '='))
{
- script_exp *exp = malloc (sizeof (script_exp));
+ script_exp_t *exp = malloc (sizeof (script_exp_t));
if (curtoken->data.symbol == '+') exp->type = SCRIPT_EXP_TYPE_PLUS;
else exp->type = SCRIPT_EXP_TYPE_MINUS;
exp->data.dual.sub_a = sub_a;
return sub_a;
}
-static script_exp *script_parse_exp_gt (ply_scan_t *scan)
+static script_exp_t *script_parse_exp_gt (ply_scan_t *scan)
{
- script_exp *sub_a = script_parse_exp_pm (scan);
+ script_exp_t *sub_a = script_parse_exp_pm (scan);
if (!sub_a) return NULL;
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
eq = 1;
curtoken = ply_scan_get_next_token (scan);
}
- script_exp *exp = malloc (sizeof (script_exp));
+ script_exp_t *exp = malloc (sizeof (script_exp_t));
if (gt && eq) exp->type = SCRIPT_EXP_TYPE_GE;
else if (gt && !eq) exp->type = SCRIPT_EXP_TYPE_GT;
else if (!gt && eq) exp->type = SCRIPT_EXP_TYPE_LE;
return sub_a;
}
-static script_exp *script_parse_exp_eq (ply_scan_t *scan)
+static script_exp_t *script_parse_exp_eq (ply_scan_t *scan)
{
- script_exp *sub_a = script_parse_exp_gt (scan);
+ script_exp_t *sub_a = script_parse_exp_gt (scan);
if (!sub_a) return NULL;
while (1)
ply_scan_get_next_token (scan);
ply_scan_get_next_token (scan);
- script_exp *exp = malloc (sizeof (script_exp));
+ script_exp_t *exp = malloc (sizeof (script_exp_t));
if (ne) exp->type = SCRIPT_EXP_TYPE_NE;
else exp->type = SCRIPT_EXP_TYPE_EQ;
exp->data.dual.sub_a = sub_a;
return sub_a;
}
-static script_exp *script_parse_exp_an (ply_scan_t *scan)
+static script_exp_t *script_parse_exp_an (ply_scan_t *scan)
{
- script_exp *sub_a = script_parse_exp_eq (scan);
+ script_exp_t *sub_a = script_parse_exp_eq (scan);
if (!sub_a) return NULL;
while (1)
ply_scan_get_next_token (scan);
ply_scan_get_next_token (scan);
- script_exp *exp = malloc (sizeof (script_exp));
+ script_exp_t *exp = malloc (sizeof (script_exp_t));
exp->type = SCRIPT_EXP_TYPE_AND;
exp->data.dual.sub_a = sub_a;
exp->data.dual.sub_b = script_parse_exp_eq (scan);
return sub_a;
}
-static script_exp *script_parse_exp_or (ply_scan_t *scan)
+static script_exp_t *script_parse_exp_or (ply_scan_t *scan)
{
- script_exp *sub_a = script_parse_exp_an (scan);
+ script_exp_t *sub_a = script_parse_exp_an (scan);
if (!sub_a) return NULL;
while (1)
ply_scan_get_next_token (scan);
ply_scan_get_next_token (scan);
- script_exp *exp = malloc (sizeof (script_exp));
+ script_exp_t *exp = malloc (sizeof (script_exp_t));
exp->type = SCRIPT_EXP_TYPE_OR;
exp->data.dual.sub_a = sub_a;
exp->data.dual.sub_b = script_parse_exp_an (scan);
return sub_a;
}
-static script_exp *script_parse_exp_as (ply_scan_t *scan)
+static script_exp_t *script_parse_exp_as (ply_scan_t *scan)
{
- script_exp *lhs = script_parse_exp_or (scan);
+ script_exp_t *lhs = script_parse_exp_or (scan);
if (!lhs) return NULL;
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
|| ((curtoken->type == PLY_SCAN_TOKEN_TYPE_SYMBOL)
&& (curtoken->data.symbol == '=')))
{
- script_exp_type type;
+ script_exp_type_t type;
if (modify_assign)
{
switch (curtoken->data.symbol)
else
type = SCRIPT_EXP_TYPE_ASSIGN;
ply_scan_get_next_token (scan);
- script_exp *rhs = script_parse_exp_as (scan);
+ script_exp_t *rhs = script_parse_exp_as (scan);
if (!rhs)
{
script_parse_error (ply_scan_get_current_token (scan),
"An invalid RHS of an expression");
return NULL;
}
- script_exp *exp = malloc (sizeof (script_exp));
+ script_exp_t *exp = malloc (sizeof (script_exp_t));
exp->type = type;
exp->data.dual.sub_a = lhs;
exp->data.dual.sub_b = rhs;
return lhs;
}
-static script_exp *script_parse_exp (ply_scan_t *scan)
+static script_exp_t *script_parse_exp (ply_scan_t *scan)
{
return script_parse_exp_as (scan);
}
-static script_op *script_parse_op_block (ply_scan_t *scan)
+static script_op_t *script_parse_op_block (ply_scan_t *scan)
{
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
}
curtoken = ply_scan_get_next_token (scan);
- script_op *op = malloc (sizeof (script_op));
+ script_op_t *op = malloc (sizeof (script_op_t));
op->type = SCRIPT_OP_TYPE_OP_BLOCK;
op->data.list = sublist;
return op;
}
-static script_op *script_parse_if_while (ply_scan_t *scan)
+static script_op_t *script_parse_if_while (ply_scan_t *scan)
{
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
- script_op_type type;
+ script_op_type_t type;
if (curtoken->type != PLY_SCAN_TOKEN_TYPE_IDENTIFIER)
return NULL;
}
curtoken = ply_scan_get_next_token (scan);
- script_exp *cond = script_parse_exp (scan);
+ script_exp_t *cond = script_parse_exp (scan);
curtoken = ply_scan_get_current_token (scan);
if (!cond)
{
return NULL;
}
ply_scan_get_next_token (scan);
- script_op *cond_op = script_parse_op (scan);
- script_op *else_op = NULL;
+ script_op_t *cond_op = script_parse_op (scan);
+ script_op_t *else_op = NULL;
curtoken = ply_scan_get_current_token (scan);
if ((type == SCRIPT_OP_TYPE_IF)
ply_scan_get_next_token (scan);
else_op = script_parse_op (scan);
}
- script_op *op = malloc (sizeof (script_op));
+ script_op_t *op = malloc (sizeof (script_op_t));
op->type = type;
op->data.cond_op.cond = cond;
op->data.cond_op.op1 = cond_op;
return op;
}
-static script_op *script_parse_for (ply_scan_t *scan)
+static script_op_t *script_parse_for (ply_scan_t *scan)
{
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
}
curtoken = ply_scan_get_next_token (scan);
- script_exp *first = script_parse_exp (scan);
+ script_exp_t *first = script_parse_exp (scan);
if (!first)
{
script_parse_error (curtoken, "Expected a valid first expression");
}
ply_scan_get_next_token (scan);
- script_exp *cond = script_parse_exp (scan);
+ script_exp_t *cond = script_parse_exp (scan);
if (!cond)
{
script_parse_error (curtoken, "Expected a valid condition expression");
}
ply_scan_get_next_token (scan);
- script_exp *last = script_parse_exp (scan);
+ script_exp_t *last = script_parse_exp (scan);
if (!last)
{
script_parse_error (curtoken, "Expected a valid last expression");
return NULL;
}
ply_scan_get_next_token (scan);
- script_op *op_body = script_parse_op (scan);
+ script_op_t *op_body = script_parse_op (scan);
- script_op *op_first = malloc (sizeof (script_op));
+ script_op_t *op_first = malloc (sizeof (script_op_t));
op_first->type = SCRIPT_OP_TYPE_EXPRESSION;
op_first->data.exp = first;
- script_op *op_last = malloc (sizeof (script_op));
+ script_op_t *op_last = malloc (sizeof (script_op_t));
op_last->type = SCRIPT_OP_TYPE_EXPRESSION;
op_last->data.exp = last;
- script_op *op_for = malloc (sizeof (script_op));
+ script_op_t *op_for = malloc (sizeof (script_op_t));
op_for->type = SCRIPT_OP_TYPE_FOR;
op_for->data.cond_op.cond = cond;
op_for->data.cond_op.op1 = op_body;
op_for->data.cond_op.op2 = op_last;
- script_op *op_block = malloc (sizeof (script_op));
+ script_op_t *op_block = malloc (sizeof (script_op_t));
op_block->type = SCRIPT_OP_TYPE_OP_BLOCK;
op_block->data.list = ply_list_new ();
ply_list_append_data (op_block->data.list, op_first);
return op_block;
}
-static script_op *script_parse_function (ply_scan_t *scan)
+static script_op_t *script_parse_function (ply_scan_t *scan)
{
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
"A function declaration requires a valid name");
return NULL;
}
- script_exp *name = malloc (sizeof (script_exp));
+ script_exp_t *name = malloc (sizeof (script_exp_t));
name->type = SCRIPT_EXP_TYPE_TERM_VAR;
name->data.string = strdup (curtoken->data.string);
curtoken = ply_scan_get_next_token (scan);
- script_op *func_op = script_parse_op (scan);
+ script_op_t *func_op = script_parse_op (scan);
- script_op *op = malloc (sizeof (script_op));
+ script_op_t *op = malloc (sizeof (script_op_t));
op->type = SCRIPT_OP_TYPE_FUNCTION_DEF;
op->data.function_def.name = name;
op->data.function_def.function = script_function_script_new (func_op,
return op;
}
-static script_op *script_parse_return (ply_scan_t *scan)
+static script_op_t *script_parse_return (ply_scan_t *scan)
{
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
if (curtoken->type != PLY_SCAN_TOKEN_TYPE_IDENTIFIER)
return NULL;
- script_op_type type;
+ script_op_type_t type;
if (!strcmp (curtoken->data.string, "return")) type = SCRIPT_OP_TYPE_RETURN;
else if (!strcmp (curtoken->data.string, "break")) type = SCRIPT_OP_TYPE_BREAK;
else if (!strcmp (curtoken->data.string, "continue")) type = SCRIPT_OP_TYPE_CONTINUE;
else return NULL;
curtoken = ply_scan_get_next_token (scan);
- script_op *op = malloc (sizeof (script_op));
+ script_op_t *op = malloc (sizeof (script_op_t));
if (type == SCRIPT_OP_TYPE_RETURN)
{
op->data.exp = script_parse_exp (scan); /* May be NULL */
return op;
}
-static script_op *script_parse_op (ply_scan_t *scan)
+static script_op_t *script_parse_op (ply_scan_t *scan)
{
ply_scan_token_t *curtoken = ply_scan_get_current_token (scan);
- script_op *reply = NULL;
+ script_op_t *reply = NULL;
reply = script_parse_op_block (scan);
if (reply) return reply;
/* default is expression */
{
- script_exp *exp = script_parse_exp (scan);
+ script_exp_t *exp = script_parse_exp (scan);
if (!exp) return NULL;
curtoken = ply_scan_get_current_token (scan);
#ifdef WITH_SEMIES
curtoken = ply_scan_get_next_token (scan);
#endif
- script_op *op = malloc (sizeof (script_op));
+ script_op_t *op = malloc (sizeof (script_op_t));
op->type = SCRIPT_OP_TYPE_EXPRESSION;
op->data.exp = exp;
return op;
while (1)
{
- script_op *op = script_parse_op (scan);
+ script_op_t *op = script_parse_op (scan);
if (!op) break;
ply_list_append_data (op_list, op);
}
return op_list;
}
-static void script_parse_exp_free (script_exp *exp)
+static void script_parse_exp_free (script_exp_t *exp)
{
if (!exp) return;
switch (exp->type)
node;
node = ply_list_get_next_node (exp->data.function.parameters, node))
{
- script_exp *sub = ply_list_node_get_data (node);
+ script_exp_t *sub = ply_list_node_get_data (node);
script_parse_exp_free (sub);
}
ply_list_free (exp->data.function.parameters);
free (exp);
}
-void script_parse_op_free (script_op *op)
+void script_parse_op_free (script_op_t *op)
{
if (!op) return;
switch (op->type)
node;
node = ply_list_get_next_node (op_list, node))
{
- script_op *op = ply_list_node_get_data (node);
+ script_op_t *op = ply_list_node_get_data (node);
script_parse_op_free (op);
}
ply_list_free (op_list);
return;
}
-script_op *script_parse_file (const char *filename)
+script_op_t *script_parse_file (const char *filename)
{
ply_scan_t *scan = ply_scan_file (filename);
return NULL;
}
ply_scan_free (scan);
- script_op *op = malloc (sizeof (script_op));
+ script_op_t *op = malloc (sizeof (script_op_t));
op->type = SCRIPT_OP_TYPE_OP_BLOCK;
op->data.list = list;
return op;
}
-script_op *script_parse_string (const char *string)
+script_op_t *script_parse_string (const char *string)
{
ply_scan_t *scan = ply_scan_string (string);
}
ply_list_t *list = script_parse_op_list (scan);
ply_scan_free (scan);
- script_op *op = malloc (sizeof (script_op));
+ script_op_t *op = malloc (sizeof (script_op_t));
op->type = SCRIPT_OP_TYPE_OP_BLOCK;
op->data.list = list;
return op;
#include "script.h"
-script_op *script_parse_file (const char *filename);
-script_op *script_parse_string (const char *string);
-void script_parse_op_free (script_op *op);
+script_op_t *script_parse_file (const char *filename);
+script_op_t *script_parse_string (const char *string);
+void script_parse_op_free (script_op_t *op);
#endif /* SCRIPT_PARSE */
#include "script-parse.h"
#include "script-object.h"
-script_function *script_function_script_new (script_op *script,
- void *user_data,
- ply_list_t *parameter_list)
+script_function_t *script_function_script_new (script_op_t *script,
+ void *user_data,
+ ply_list_t *parameter_list)
{
- script_function *function = malloc (sizeof (script_function));
+ script_function_t *function = malloc (sizeof (script_function_t));
function->type = SCRIPT_FUNCTION_TYPE_SCRIPT;
function->parameters = parameter_list;
return function;
}
-script_function *script_function_native_new (
- script_native_function native_function,
- void *user_data,
- ply_list_t *
- parameter_list)
+script_function_t *script_function_native_new (script_native_function_t native_function,
+ void *user_data,
+ ply_list_t *parameter_list)
{
- script_function *function = malloc (sizeof (script_function));
+ script_function_t *function = malloc (sizeof (script_function_t));
function->type = SCRIPT_FUNCTION_TYPE_NATIVE;
function->parameters = parameter_list;
return function;
}
-void script_add_native_function (script_obj *hash,
- const char *name,
- script_native_function native_function,
- void *user_data,
- const char *first_arg,
+void script_add_native_function (script_obj_t *hash,
+ const char *name,
+ script_native_function_t native_function,
+ void *user_data,
+ const char *first_arg,
...)
{
va_list args;
}
va_end (args);
- script_function *function = script_function_native_new (native_function,
- user_data,
- parameter_list);
- script_obj *obj = script_obj_new_function (function);
+ script_function_t *function = script_function_native_new (native_function,
+ user_data,
+ parameter_list);
+ script_obj_t *obj = script_obj_new_function (function);
script_obj_hash_add_element (hash, obj, name);
script_obj_unref (obj);
}
-script_obj_native_class *script_obj_native_class_new (script_obj_function free_func,
- const char *name,
- void *user_data)
+script_obj_native_class_t *script_obj_native_class_new (script_obj_function_t free_func,
+ const char *name,
+ void *user_data)
{
- script_obj_native_class *class = malloc (sizeof (script_obj_native_class));
+ script_obj_native_class_t *class = malloc (sizeof (script_obj_native_class_t));
class->free_func = free_func;
class->name = strdup (name);
return class;
}
-void script_obj_native_class_destroy (script_obj_native_class *class)
+void script_obj_native_class_destroy (script_obj_native_class_t *class)
{
free (class->name);
free (class);
return;
}
-script_state *script_state_new (void *user_data)
+script_state_t *script_state_new (void *user_data)
{
- script_state *state = malloc (sizeof (script_state));
+ script_state_t *state = malloc (sizeof (script_state_t));
state->global = script_obj_new_hash ();
script_obj_ref (state->global);
return state;
}
-script_state *script_state_init_sub (script_state *oldstate)
+script_state_t *script_state_init_sub (script_state_t *oldstate)
{
- script_state *newstate = malloc (sizeof (script_state));
+ script_state_t *newstate = malloc (sizeof (script_state_t));
newstate->global = oldstate->global;
script_obj_ref (newstate->global);
return newstate;
}
-void script_state_destroy (script_state *state)
+void script_state_destroy (script_state_t *state)
{
script_obj_unref (state->global);
script_obj_unref (state->local);
SCRIPT_RETURN_TYPE_RETURN,
SCRIPT_RETURN_TYPE_BREAK,
SCRIPT_RETURN_TYPE_CONTINUE,
-} script_return_type;
+} script_return_type_t;
-struct script_obj;
+struct script_obj_t;
typedef struct
{
- script_return_type type;
- struct script_obj *object;
-} script_return;
+ script_return_type_t type;
+ struct script_obj_t *object;
+} script_return_t;
typedef struct
{
void *user_data;
- struct script_obj *global;
- struct script_obj *local;
-} script_state;
+ struct script_obj_t *global;
+ struct script_obj_t *local;
+} script_state_t;
typedef enum
{
SCRIPT_FUNCTION_TYPE_SCRIPT,
SCRIPT_FUNCTION_TYPE_NATIVE,
-} script_function_type;
+} script_function_type_t;
-typedef script_return (*script_native_function)(script_state *, void *);
+typedef script_return_t (*script_native_function_t)(script_state_t *, void *);
-typedef struct script_function
+typedef struct script_function_t
{
- script_function_type type;
+ script_function_type_t type;
ply_list_t *parameters; /* list of char* typedef names */
void *user_data;
union
{
- script_native_function native;
- struct script_op *script;
+ script_native_function_t native;
+ struct script_op_t *script;
} data;
bool freeable;
-} script_function;
+} script_function_t;
-typedef void (*script_obj_function)(struct script_obj *);
+typedef void (*script_obj_function_t)(struct script_obj_t *);
typedef struct
{
- script_obj_function free_func;
+ script_obj_function_t free_func;
char *name;
void *user_data;
-} script_obj_native_class;
+} script_obj_native_class_t;
typedef struct
{
void *object_data;
- script_obj_native_class *class;
-} script_obj_native;
+ script_obj_native_class_t *class;
+} script_obj_native_t;
typedef enum
{
SCRIPT_OBJ_TYPE_HASH,
SCRIPT_OBJ_TYPE_FUNCTION,
SCRIPT_OBJ_TYPE_NATIVE,
-} script_obj_type;
+} script_obj_type_t;
-typedef struct script_obj
+typedef struct script_obj_t
{
- script_obj_type type;
+ script_obj_type_t type;
int refcount;
union
{
int integer;
float floatpoint;
char *string;
- struct script_obj *obj;
- script_function *function;
+ struct script_obj_t *obj;
+ script_function_t *function;
ply_hashtable_t *hash;
- script_obj_native native;
+ script_obj_native_t native;
} data;
-} script_obj;
+} script_obj_t;
typedef enum
{
SCRIPT_EXP_TYPE_ASSIGN_MUL,
SCRIPT_EXP_TYPE_ASSIGN_DIV,
SCRIPT_EXP_TYPE_ASSIGN_MOD,
-} script_exp_type;
+} script_exp_type_t;
-typedef struct script_exp
+typedef struct script_exp_t
{
- script_exp_type type;
+ script_exp_type_t type;
union
{
struct
{
- struct script_exp *sub_a;
- struct script_exp *sub_b;
+ struct script_exp_t *sub_a;
+ struct script_exp_t *sub_b;
} dual;
- struct script_exp *sub;
+ struct script_exp_t *sub;
char *string;
int integer;
float floatpoint;
struct
{
- struct script_exp *name;
+ struct script_exp_t *name;
ply_list_t *parameters;
} function;
} data;
-} script_exp;
+} script_exp_t;
typedef enum
{
SCRIPT_OP_TYPE_RETURN,
SCRIPT_OP_TYPE_BREAK,
SCRIPT_OP_TYPE_CONTINUE,
-} script_op_type;
+} script_op_type_t;
-typedef struct script_op
+typedef struct script_op_t
{
- script_op_type type;
+ script_op_type_t type;
union
{
- script_exp *exp;
+ script_exp_t *exp;
ply_list_t *list;
struct
{
- script_exp *cond;
- struct script_op *op1;
- struct script_op *op2;
+ script_exp_t *cond;
+ struct script_op_t *op1;
+ struct script_op_t *op2;
} cond_op;
struct
{
- script_exp *name;
- script_function *function;
+ script_exp_t *name;
+ script_function_t *function;
} function_def;
} data;
-} script_op;
+} script_op_t;
typedef struct
{
char *name;
- script_obj *object;
-} script_vareable;
-
-script_function *script_function_script_new (script_op *script,
- void *user_data,
- ply_list_t *parameter_list);
-script_function *script_function_native_new (
- script_native_function native_function,
- void *user_data,
- ply_list_t *
- parameter_list);
-void script_add_native_function (script_obj *hash,
- const char *name,
- script_native_function native_function,
- void *user_data,
- const char *first_arg,
+ script_obj_t *object;
+} script_vareable_t;
+
+script_function_t *script_function_script_new (script_op_t *script,
+ void *user_data,
+ ply_list_t *parameter_list);
+script_function_t *script_function_native_new (script_native_function_t native_function,
+ void *user_data,
+ ply_list_t *parameter_list);
+void script_add_native_function (script_obj_t *hash,
+ const char *name,
+ script_native_function_t native_function,
+ void *user_data,
+ const char *first_arg,
...);
-script_obj_native_class *script_obj_native_class_new (
- script_obj_function free_func,
- const char *name,
- void *
- user_data);
-
-void script_obj_native_class_destroy (script_obj_native_class * class );
-script_state *script_state_new (void *user_data);
-script_state *script_state_init_sub (script_state *oldstate);
-void script_state_destroy (script_state *state);
+script_obj_native_class_t *script_obj_native_class_new (script_obj_function_t free_func,
+ const char *name,
+ void *user_data);
+
+void script_obj_native_class_destroy (script_obj_native_class_t * class);
+script_state_t *script_state_new (void *user_data);
+script_state_t *script_state_init_sub (script_state_t *oldstate);
+void script_state_destroy (script_state_t *state);
#endif /* SCRIPT_H */
+++ /dev/null
-/* script-lib-plymouth.c - script library for interacting with plymouth
- *
- * Copyright (C) 2009 Charlie Brej <cbrej@cs.man.ac.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
- */
-#define _GNU_SOURCE
-#include "ply-utils.h"
-#include "script.h"
-#include "script-parse.h"
-#include "script-execute.h"
-#include "script-object.h"
-#include "script-lib-plymouth.h"
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "config.h"
-
-#define STRINGIFY_VAR script_lib_plymouth_string
-
-#include "script-lib-plymouth.string"
-
-static script_return plymouth_set_function (script_state *state,
- void *user_data)
-{
- script_obj **script_func = user_data;
- script_obj *obj = script_obj_hash_get_element (state->local, "function");
-
- script_obj_deref (&obj);
- script_obj_unref (*script_func);
-
- if (obj->type == SCRIPT_OBJ_TYPE_FUNCTION)
- *script_func = obj;
- else
- {
- *script_func = NULL;
- script_obj_unref (obj);
- }
- return (script_return) {
- SCRIPT_RETURN_TYPE_RETURN, script_obj_new_null ()
- };
-}
-
-script_lib_plymouth_data_t *script_lib_plymouth_setup (script_state *state)
-{
- script_lib_plymouth_data_t *data = malloc (sizeof (script_lib_plymouth_data_t));
-
- data->script_refresh_func = NULL;
- data->script_boot_progress_func = NULL;
- data->script_root_mounted_func = NULL;
- data->script_keyboard_input_func = NULL;
- data->script_update_status_func = NULL;
- data->script_display_normal_func = NULL;
- data->script_display_password_func = NULL;
- data->script_display_question_func = NULL;
-
- script_add_native_function (state->global,
- "PlymouthSetRefreshFunction",
- plymouth_set_function,
- &data->script_refresh_func,
- "function",
- NULL);
- script_add_native_function (state->global,
- "PlymouthSetBootProgressFunction",
- plymouth_set_function,
- &data->script_boot_progress_func,
- "function",
- NULL);
- script_add_native_function (state->global,
- "PlymouthSetRootMountedFunction",
- plymouth_set_function,
- &data->script_root_mounted_func,
- "function",
- NULL);
- script_add_native_function (state->global,
- "PlymouthSetKeyboardInputFunction",
- plymouth_set_function,
- &data->script_keyboard_input_func,
- "function",
- NULL);
- script_add_native_function (state->global,
- "PlymouthSetUpdateStatusFunction",
- plymouth_set_function,
- &data->script_update_status_func,
- "function",
- NULL);
- script_add_native_function (state->global,
- "PlymouthSetDisplayNormalFunction",
- plymouth_set_function,
- &data->script_display_normal_func,
- "function",
- NULL);
- script_add_native_function (state->global,
- "PlymouthSetDisplayPasswordFunction",
- plymouth_set_function,
- &data->script_display_password_func,
- "function",
- NULL);
- script_add_native_function (state->global,
- "PlymouthSetDisplayQuestionFunction",
- plymouth_set_function,
- &data->script_display_question_func,
- "function",
- NULL);
- data->script_main_op = script_parse_string (script_lib_plymouth_string);
- script_return ret = script_execute (state, data->script_main_op);
- script_obj_unref (ret.object); /* Throw anything sent back away */
-
- return data;
-}
-
-void script_lib_plymouth_destroy (script_lib_plymouth_data_t *data)
-{
- script_parse_op_free (data->script_main_op);
- script_obj_unref (data->script_refresh_func);
- script_obj_unref (data->script_boot_progress_func);
- script_obj_unref (data->script_root_mounted_func);
- script_obj_unref (data->script_keyboard_input_func);
- script_obj_unref (data->script_update_status_func);
- script_obj_unref (data->script_display_normal_func);
- script_obj_unref (data->script_display_password_func);
- script_obj_unref (data->script_display_question_func);
- free (data);
-}
-
-void script_lib_plymouth_on_refresh (script_state *state,
- script_lib_plymouth_data_t *data)
-{
- script_obj *refresh_func_obj = data->script_refresh_func;
-
- if (refresh_func_obj
- && (refresh_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
- {
- script_return ret = script_execute_function (state,
- refresh_func_obj->data.function,
- NULL);
- script_obj_unref (ret.object);
- }
-}
-
-void script_lib_plymouth_on_boot_progress (script_state *state,
- script_lib_plymouth_data_t *data,
- float duration,
- float progress)
-{
- script_obj *boot_progress_func_obj = data->script_boot_progress_func;
-
- if (boot_progress_func_obj
- && (boot_progress_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
- {
- script_obj *duration_obj = script_obj_new_float (duration);
- script_obj *progress_obj = script_obj_new_float (progress);
- script_return ret = script_execute_function (state,
- boot_progress_func_obj->data.function,
- duration_obj,
- progress_obj,
- NULL);
- script_obj_unref (ret.object);
- script_obj_unref (duration_obj);
- script_obj_unref (progress_obj);
- }
-}
-
-void script_lib_plymouth_on_root_mounted (script_state *state,
- script_lib_plymouth_data_t *data)
-{
- script_obj *root_mounted_func_obj = data->script_root_mounted_func;
-
- if (root_mounted_func_obj
- && (root_mounted_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
- {
- script_return ret = script_execute_function (state,
- root_mounted_func_obj->data.function,
- NULL);
- script_obj_unref (ret.object);
- }
-}
-
-void script_lib_plymouth_on_keyboard_input (script_state *state,
- script_lib_plymouth_data_t *data,
- const char *keyboard_input)
-{
- script_obj *keyboard_input_func_obj = data->script_keyboard_input_func;
-
- if (keyboard_input_func_obj
- && (keyboard_input_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
- {
- script_obj *keyboard_input_obj = script_obj_new_string (keyboard_input);
- script_return ret = script_execute_function (state,
- keyboard_input_func_obj->data.function,
- keyboard_input_obj,
- NULL);
- script_obj_unref (keyboard_input_obj);
- script_obj_unref (ret.object);
- }
-}
-
-void script_lib_plymouth_on_update_status (script_state *state,
- script_lib_plymouth_data_t *data,
- const char *new_status)
-{
- script_obj *update_status_func_obj = data->script_update_status_func;
-
- if (update_status_func_obj
- && (update_status_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
- {
- script_obj *new_status_obj = script_obj_new_string (new_status);
- script_return ret = script_execute_function (state,
- update_status_func_obj->data.function,
- new_status_obj,
- NULL);
- script_obj_unref (new_status_obj);
- script_obj_unref (ret.object);
- }
-}
-
-void script_lib_plymouth_on_display_normal (script_state *state,
- script_lib_plymouth_data_t *data)
-{
- script_obj *display_normal_func_obj = data->script_display_normal_func;
-
- if (display_normal_func_obj
- && (display_normal_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
- {
- script_return ret = script_execute_function (state,
- display_normal_func_obj->data.function,
- NULL);
- script_obj_unref (ret.object);
- }
-}
-
-void script_lib_plymouth_on_display_password (script_state *state,
- script_lib_plymouth_data_t *data,
- const char *prompt,
- int bullets)
-{
- script_obj *display_password_func_obj = data->script_display_password_func;
-
- if (display_password_func_obj
- && (display_password_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
- {
- script_obj *prompt_obj = script_obj_new_string (prompt);
- script_obj *bullets_obj = script_obj_new_int (bullets);
- script_return ret = script_execute_function (state,
- display_password_func_obj->data.function,
- prompt_obj,
- bullets_obj,
- NULL);
- script_obj_unref (prompt_obj);
- script_obj_unref (bullets_obj);
- script_obj_unref (ret.object);
- }
-}
-
-void script_lib_plymouth_on_display_question (script_state *state,
- script_lib_plymouth_data_t *data,
- const char *prompt,
- const char *entry_text)
-{
- script_obj *display_question_func_obj = data->script_display_question_func;
-
- if (display_question_func_obj
- && (display_question_func_obj->type == SCRIPT_OBJ_TYPE_FUNCTION))
- {
- script_obj *prompt_obj = script_obj_new_string (prompt);
- script_obj *entry_text_obj = script_obj_new_string (entry_text);
- script_return ret = script_execute_function (state,
- display_question_func_obj->data.function,
- prompt_obj,
- entry_text_obj,
- NULL);
- script_obj_unref (prompt_obj);
- script_obj_unref (entry_text_obj);
- script_obj_unref (ret.object);
- }
-}