Skip to content
Snippets Groups Projects
Commit a0f9075d authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

overloading for indices() and values() added

Rev: src/object.c:1.12
parent 14dae9ea
Branches
Tags
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
||| See the files COPYING and DISCLAIMER for more information. ||| See the files COPYING and DISCLAIMER for more information.
\*/ \*/
#include "global.h" #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 "object.h"
#include "dynamic_buffer.h" #include "dynamic_buffer.h"
#include "interpret.h" #include "interpret.h"
...@@ -709,6 +709,8 @@ struct array *object_indices(struct object *o) ...@@ -709,6 +709,8 @@ struct array *object_indices(struct object *o)
if(!p) if(!p)
error("indices() on destructed object.\n"); error("indices() on destructed object.\n");
if(p->lfuns[LFUN__INDICES]==-1)
{
a=allocate_array_no_init(p->num_identifier_indexes,0); a=allocate_array_no_init(p->num_identifier_indexes,0);
for(e=0;e<(int)p->num_identifier_indexes;e++) for(e=0;e<(int)p->num_identifier_indexes;e++)
{ {
...@@ -716,6 +718,13 @@ struct array *object_indices(struct object *o) ...@@ -716,6 +718,13 @@ struct array *object_indices(struct object *o)
ID_FROM_INT(p,p->identifier_index[e])->name); ID_FROM_INT(p,p->identifier_index[e])->name);
ITEM(a)[e].type=T_STRING; 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; return a;
} }
...@@ -729,11 +738,20 @@ struct array *object_values(struct object *o) ...@@ -729,11 +738,20 @@ struct array *object_values(struct object *o)
if(!p) if(!p)
error("values() on destructed object.\n"); error("values() on destructed object.\n");
if(p->lfuns[LFUN__INDICES]==-1)
{
a=allocate_array_no_init(p->num_identifier_indexes,0); a=allocate_array_no_init(p->num_identifier_indexes,0);
for(e=0;e<(int)p->num_identifier_indexes;e++) for(e=0;e<(int)p->num_identifier_indexes;e++)
{ {
low_object_index_no_free(ITEM(a)+e, o, p->identifier_index[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; return a;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment