void InkMod_Loader(Ink_InterpreteEngine *engine, Ink_ContextChain *context) { Ink_Object *tmp; Ink_TypeTag *type_p = NULL; if (!engine->getEngineComAs<Ink_TypeTag>(ink_native_file_mod_id)) { type_p = (Ink_TypeTag *)malloc(sizeof(Ink_TypeTag) * 2); type_p[0] = (Ink_TypeTag)engine->registerType("io.file.File"); type_p[1] = (Ink_TypeTag)engine->registerType("io.direct.Directory"); engine->addEngineCom(ink_native_file_mod_id, type_p); engine->addDestructor(Ink_EngineDestructor(InkNative_IO_EngineComCleaner, new com_cleaner_arg(ink_native_file_mod_id))); context->getGlobal()->context->setSlot("$io.file.File", tmp = new Ink_FilePointer(engine)); tmp->derivedMethodInit(engine); context->getGlobal()->context->setSlot("$io.direct.Directory", tmp = new Ink_DirectPointer(engine)); tmp->derivedMethodInit(engine); } Ink_Object *io_pkg = addPackage(engine, context, "io", new Ink_FunctionObject(engine, InkMod_IO_Loader)); Ink_Object *io_file_pkg = addPackage(engine, io_pkg, "file", new Ink_FunctionObject(engine, InkMod_File_Loader)); Ink_Object *io_direct_pkg = addPackage(engine, io_pkg, "direct", new Ink_FunctionObject(engine, InkMod_Direct_Loader)); InkMod_IO_bondTo(engine, io_pkg); InkMod_File_bondTo(engine, io_file_pkg); InkMod_Direct_bondTo(engine, io_direct_pkg); }
void InkMod_Bignum_bondType(Ink_InterpreteEngine *engine, Ink_ContextChain *context) { Ink_Object *tmp; com_struct *com = NULL; Ink_Object *obj_proto = engine->getTypePrototype(INK_OBJECT); if (!(com = engine->getEngineComAs<com_struct>(ink_native_bignum_mod_id))) { com = new com_struct(); engine->addEngineCom(ink_native_bignum_mod_id, com); engine->addDestructor(Ink_EngineDestructor(InkMod_Bignum_EngineComCleaner, new com_cleaner_arg(ink_native_bignum_mod_id))); } else if (com->bignum_type != (Ink_TypeTag)-1) /* has registered */ return; com->bignum_type = engine->registerType("bignum"); context->getGlobal()->setSlot_c("$bignum", tmp = new Ink_BigNumeric(engine, "0")); engine->setTypePrototype(com->bignum_type, tmp); tmp->setProto(obj_proto); tmp->derivedMethodInit(engine); return; }