Ink_Object *InkNative_Object_Index(Ink_InterpreteEngine *engine, Ink_ContextChain *context, Ink_ArgcType argc, Ink_Object **argv, Ink_Object *this_p) { Ink_Object *base = context->searchSlot(engine, "base"); if (!checkArgument(engine, argc, argv, 1, INK_STRING)) { return NULL_OBJ; } if (!base->getSlotMapping(engine, as<Ink_String>(argv[0])->getValue().c_str())) { string *tmp = new string(as<Ink_String>(argv[0])->getValue()); return getSlotWithProto(engine, context, base, tmp->c_str(), tmp); } return getSlotWithProto(engine, context, base, as<Ink_String>(argv[0])->getValue().c_str()); }
Ink_Object *InkNative_Object_New(Ink_InterpreteEngine *engine, Ink_ContextChain *context, Ink_ArgcType argc, Ink_Object **argv, Ink_Object *this_p) { Ink_Object *base = context->searchSlot(engine, "base"); Ink_Object *new_obj = new Ink_Object(engine); Ink_HashTable *prototype_hash = base->getSlotMapping(engine, "prototype"); if (prototype_hash) { new_obj->setSlot("prototype", prototype_hash->getValue()); } if (base->type == INK_FUNCTION) { return base->call(engine, context, argc, argv, new_obj); } return new_obj; }
Ink_Object *InkNative_Object_SetSetter(Ink_InterpreteEngine *engine, Ink_ContextChain *context, Ink_ArgcType argc, Ink_Object **argv, Ink_Object *this_p) { Ink_Object *base = context->searchSlot(engine, "base"); Ink_HashTable *hash; const char *tmp; if (!checkArgument(engine, argc, argv, 1, INK_STRING)) { return NULL_OBJ; } tmp = as<Ink_String>(argv[0])->getValue().c_str(); if (!(hash = base->getSlotMapping(engine, tmp))) { string *tmp_p = new string(tmp); hash = base->setSlot(tmp_p->c_str(), NULL, tmp_p); } hash->setter = argc > 1 ? argv[1] : NULL; return NULL_OBJ; }