summaryrefslogtreecommitdiff
path: root/navit/command.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2013-04-26 22:26:56 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2013-04-26 22:26:56 +0000
commitdc24113ce1e30e97810ea8b00c0601fa86429459 (patch)
tree0ce7a8511c50aa5e77bc7794e1f86378a4cbd8b4 /navit/command.c
parentf2f181d702f77ee7a0d9796b6ec6307818843b6d (diff)
downloadnavit-dc24113ce1e30e97810ea8b00c0601fa86429459.tar.gz
Add:Core:Allow new on primitive types in command interpreter
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5448 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/command.c')
-rw-r--r--navit/command.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/navit/command.c b/navit/command.c
index 0aece848a..fe63a8e5e 100644
--- a/navit/command.c
+++ b/navit/command.c
@@ -649,7 +649,23 @@ command_call_function(struct context *ctx, struct result *res)
} else if (!strncmp(function,"new ",4)) {
enum attr_type attr_type=attr_from_name(function+4);
result_free(res);
- if (attr_type != attr_none) {
+ if (ATTR_IS_INT(attr_type)) {
+ if (list && list[0] && ATTR_IS_INT(list[0]->type)) {
+ res->attr.type=attr_type;
+ res->attr.u.num=list[0]->u.num;
+ res->allocated=0;
+ } else {
+ dbg(0,"don't know how to create int of args\n");
+ }
+ } else if (ATTR_IS_STRING(attr_type)) {
+ if (list && list[0] && ATTR_IS_STRING(list[0]->type)) {
+ res->attr.type=attr_type;
+ res->attr.u.str=g_strdup(list[0]->u.str);
+ res->allocated=1;
+ } else {
+ dbg(0,"don't know how to create string of args\n");
+ }
+ } else if (ATTR_IS_OBJECT(attr_type)) {
struct object_func *func=object_func_lookup(attr_type);
if (func && func->create) {
res->attr.type=attr_type;
@@ -658,6 +674,8 @@ command_call_function(struct context *ctx, struct result *res)
So created persistent objects should be stored with set_attr_var command. */
res->allocated=1;
}
+ } else {
+ dbg(0,"don't know how to create %s (%s)\n",attr_to_name(attr_type),function+4);
}
} else if (!strcmp(function,"add_attr")) {
command_object_add_attr(ctx, &res->attr, list[0]);