From a0f9075df0917b7b86a7aa712bc6461b8731a09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Sun, 26 Jan 1997 17:22:56 -0800 Subject: [PATCH] overloading for indices() and values() added Rev: src/object.c:1.12 --- src/object.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/object.c b/src/object.c index 07c1a9650b..a3c9d31c69 100644 --- a/src/object.c +++ b/src/object.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: object.c,v 1.11 1997/01/19 09:08:02 hubbe Exp $"); +RCSID("$Id: object.c,v 1.12 1997/01/27 01:22:56 hubbe Exp $"); #include "object.h" #include "dynamic_buffer.h" #include "interpret.h" @@ -709,12 +709,21 @@ struct array *object_indices(struct object *o) if(!p) error("indices() on destructed object.\n"); - a=allocate_array_no_init(p->num_identifier_indexes,0); - for(e=0;e<(int)p->num_identifier_indexes;e++) + if(p->lfuns[LFUN__INDICES]==-1) { - copy_shared_string(ITEM(a)[e].u.string, - ID_FROM_INT(p,p->identifier_index[e])->name); - ITEM(a)[e].type=T_STRING; + a=allocate_array_no_init(p->num_identifier_indexes,0); + for(e=0;e<(int)p->num_identifier_indexes;e++) + { + copy_shared_string(ITEM(a)[e].u.string, + ID_FROM_INT(p,p->identifier_index[e])->name); + ITEM(a)[e].type=T_STRING; + } + }else{ + apply_lfun(o, LFUN__INDICES, 0); + if(sp[-1].type != T_ARRAY) + error("Bad return type from o->_indices()\n"); + a=sp[-1].u.array; + sp--; } return a; } @@ -729,10 +738,19 @@ struct array *object_values(struct object *o) if(!p) error("values() on destructed object.\n"); - a=allocate_array_no_init(p->num_identifier_indexes,0); - for(e=0;e<(int)p->num_identifier_indexes;e++) + if(p->lfuns[LFUN__INDICES]==-1) { - low_object_index_no_free(ITEM(a)+e, o, p->identifier_index[e]); + a=allocate_array_no_init(p->num_identifier_indexes,0); + for(e=0;e<(int)p->num_identifier_indexes;e++) + { + low_object_index_no_free(ITEM(a)+e, o, p->identifier_index[e]); + } + }else{ + apply_lfun(o, LFUN__VALUES, 0); + if(sp[-1].type != T_ARRAY) + error("Bad return type from o->_values()\n"); + a=sp[-1].u.array; + sp--; } return a; } -- GitLab