void IoMessage_free(IoMessage *self) { IoMessageData *d = (IoMessageData *)IoObject_dataPointer(self); if (DATA(self)->args) { List_free(DATA(self)->args); } io_free(IoObject_dataPointer(self)); }
//inline void IoObject_freeData(IoObject *self) { IoTagFreeFunc *func = IoTag_freeFunc(IoObject_tag(self)); if (func) { (*func)(self); } else if (IoObject_dataPointer(self)) { io_free(IoObject_dataPointer(self)); } IoObject_setDataPointer_(self, NULL); }
IoObject *IoTheoraDecodeContext_setup(IoTheoraDecodeContext *self, IoObject *locals, IoMessage *m) { /*doc IoTheoraDecodeContext setup(info, setup) Initialize for decoding using the information obtained from reading the Theora headers. */ IoTheoraInfo *info = IoMessage_locals_theoraInfoArgAt_(m, locals, 0); IoTheoraSetupInfo *setup = IoMessage_locals_theoraSetupInfoArgAt_(m, locals, 1); th_dec_ctx* ctx = th_decode_alloc((th_info*)(IoObject_dataPointer(info)), *((th_setup_info**)(IoObject_dataPointer(setup)))); IOASSERT(ctx, "th_decode_alloc failed"); DATA(self)->ctx = ctx; return self; }
IoObject* IoBlock::activate(IoMessage* m) const { if (!io_block) throw std::logic_error("io_block is null!"); if (!io_target) throw std::logic_error("io_target is null!"); if (!m) throw std::logic_error("message is null!"); IoBlockData* blockData = (IoBlockData *)IoObject_dataPointer(io_block); if (!blockData) throw std::logic_error("block data is null!"); // Apparently Io doesn't export IoBlock_activate, but hopefully IoObject_activate works just as well. //IoObject* result = IoObject_activate(io_block, io_target, io_target, m, io_target); // Unfortunately IoObject_activate is NOT the same; need IoBlock_activate to be exported. IoObject* result = IoBlock_activate(io_block, io_target, io_target, m, io_target); { if (iovm->last_exception) { iovm->last_exception = 0; throw std::logic_error("LikeMagic IoBlock activate: Caught Io exception while running an Io block."); } } if (!result) throw std::logic_error("Error in IoBlock: activating the block returned null (may be caused by an error in script)."); return result; }
IoObject *IoTheoraDecodeContext_headerin(IoTheoraDecodeContext *self, IoObject *locals, IoMessage *m) { /*doc TheoraDecodecontext headerin(info, comment, setup, packet) Try to decode a theora header from the packet. */ IoTheoraInfo *info = IoMessage_locals_theoraInfoArgAt_(m, locals, 0); IoTheoraComment *comment = IoMessage_locals_theoraCommentArgAt_(m, locals, 1); IoTheoraSetupInfo *setup = IoMessage_locals_theoraSetupInfoArgAt_(m, locals, 2); IoOggPacket *packet = IoMessage_locals_oggPacketArgAt_(m, locals, 3); int ret = th_decode_headerin(((th_info*)(IoObject_dataPointer(info))), ((th_comment*)(IoObject_dataPointer(comment))), ((th_setup_info**)(IoObject_dataPointer(setup))), ((ogg_packet*)(IoObject_dataPointer(packet)))); return IONUMBER(ret); }
intptr_t bouncer(IoBlock *self, intptr_t ret, intptr_t a, intptr_t b, intptr_t c, intptr_t d, intptr_t e) { IoObject *lobby = IoState_lobby(IOSTATE); IoNumber *n; static IoMessage *m = NULL; List *argNames = ((IoBlockData*)IoObject_dataPointer(self))->argNames; if (m == NULL) m = IoMessage_new(IOSTATE); if (0 < argNames->size) IoMessage_setCachedArg_toInt_(m, 0, (int)a); if (1 < argNames->size) IoMessage_setCachedArg_toInt_(m, 1, (int)b); if (2 < argNames->size) IoMessage_setCachedArg_toInt_(m, 2, (int)c); if (3 < argNames->size) IoMessage_setCachedArg_toInt_(m, 3, (int)d); if (4 < argNames->size) IoMessage_setCachedArg_toInt_(m, 4, (int)e); n = IoBlock_activate(self, lobby, lobby, m, lobby); if (ISNUMBER(n)) { return (intptr_t)IoNumber_asInt(n); } return 0; }
void IoFile_free(IoFile *self) { if (NULL == IoObject_dataPointer(self)) { return; } IoFile_justClose(self); if (DATA(self)->info) { io_free(DATA(self)->info); } io_free(IoObject_dataPointer(self)); }
void IoSandbox_free(IoSandbox *self) { if (IoObject_dataPointer(self)) { IoState_free(IoSandbox_boxState(self)); } }
IoSQLite *IoSQLite_rawClone(IoSQLite *proto) { IoObject *self = IoObject_rawClonePrimitive(proto); IoObject_setDataPointer_(self, cpalloc(IoObject_dataPointer(proto), sizeof(IoSQLiteData))); DATA(self)->error = NULL; IoSQLite_error_(self, ""); return self; }
IoCall *IoCall_rawClone(IoCall *proto) { IoObject *self = IoObject_rawClonePrimitive(proto); IoObject_setDataPointer_(self, cpalloc(IoObject_dataPointer(proto), sizeof(IoCallData))); //printf("IoCall_rawClone() %p|%p\n", (void *)self, IoObject_dataPointer(self)); IoCall_initSlots(self); return self; }
IoFont *IoFont_rawClone(IoFont *proto) { IoObject *self = IoObject_rawClonePrimitive(proto); IoObject_setDataPointer_(self, cpalloc(IoObject_dataPointer(proto), sizeof(IoFontData))); DATA(self)->font = GLFont_new(); DATA(self)->isProto = 0; return self; }
IoImage *IoImage_rawClone(IoImage *proto) { IoObject *self = IoObject_rawClonePrimitive(proto); IoObject_setDataPointer_(self, cpalloc(IoObject_dataPointer(proto), sizeof(IoImageData))); DATA(self)->buffer = IOCLONE(DATA(proto)->buffer); DATA(self)->image = Image_copyWithUArray_(DATA(proto)->image, IoSeq_rawUArray(DATA(self)->buffer)); return self; }
IoList *IoList_newWithList_(void *state, List *list) { IoList *self = IoList_new(state); //printf("IoList_newWithList_ %p %p\n", (void *)self, (void *)list); List_free(IoObject_dataPointer(self)); IoObject_setDataPointer_(self, list); return self; }
Address *IoSocket_rawAddressFrom_(IoObject *addr) { Address *self = NULL; if(ISIPADDRESS(addr)) { IPAddress *ipAddr = (IPAddress *)IoObject_dataPointer(addr); self = ipAddr->addr; } #if !defined(_WIN32) || defined(__CYGWIN__) else if(ISUNIXPATH(addr)) { UnixPath *unixPath = (UnixPath *)IoObject_dataPointer(addr); self = unixPath->addr; } #endif return self; }
void IoEditLine_free(IoEditLine *self) { if (IoObject_dataPointer(self)) { el_end(DATA(self)->editline); history_end(DATA(self)->history); } }
IoGLScissor *IoGLScissor_rawClone(IoGLScissor *proto) { IoObject *self = IoObject_rawClonePrimitive(proto); IoObject_setDataPointer_(self, cpalloc(IoObject_dataPointer(proto), sizeof(IoGLScissorData))); DATA(self)->rect = IOCLONE(DATA(proto)->rect); DATA(self)->tmpRect = IOCLONE(DATA(proto)->tmpRect); return self; }
IoFile *IoFile_rawClone(IoFile *proto) { IoObject *self = IoObject_rawClonePrimitive(proto); IoObject_setDataPointer_(self, cpalloc(IoObject_dataPointer(proto), sizeof(IoFileData))); DATA(self)->info = NULL; DATA(self)->stream = (FILE *)NULL; DATA(self)->flags = IOFILE_FLAGS_NONE; return self; }
void IoEventManager_free(IoEventManager *self) { // we don't free libevent since it's global and there // may be other stuff (possibly other IoStates) in the process // using it List_free(DATA(self)->activeEvents); free(IoObject_dataPointer(self)); }
void IoODEJoint_free(IoODEJoint *self) { if(JOINTID && JOINTGROUP) { IoODEJointGroup_removeJoint(JOINTGROUP, self); dJointDestroy(JOINTID); } free(IoObject_dataPointer(self)); }
void IoODEBody_free(IoODEBody *self) { if(BODYID && WORLD) { IoODEWorld_removeBody(WORLD, self); dBodyDestroy(BODYID); } free(IoObject_dataPointer(self)); }
IoFnmatch *IoFnmatch_rawClone(IoFnmatch *proto) { IoFnmatch *self = IoObject_rawClonePrimitive(proto); IoObject_setDataPointer_(self, cpalloc(IoObject_dataPointer(proto), sizeof(IoFnmatchData))); /* DATA(self)->pattern = DATA(proto)->pattern; DATA(self)->string = DATA(proto)->string; */ return self; }
void IoODEPlane_free(IoODEPlane *self) { if(GEOMID) { dGeomDestroy(GEOMID); GEOMID = 0; } free(IoObject_dataPointer(self)); }
IoCairoPathElement *IoCairoPathElement_newWithPath_dataOffset_(void *state, IoObject *path, int offset) { IoCairoPathElement *self = IOCLONE(IoState_protoWithInitFunction_(state, IoCairoPathElement_proto)); cairo_path_t *rawPath = ((IoCairoPathData *)IoObject_dataPointer(path))->path; IoObject_setDataPointer_(self, malloc(sizeof(IoCairoPathElementData))); DATA(self)->path = path; PATH_DATA(self) = rawPath->data + offset; return self; }
IoObject *IoVorbisBlock_synthesis(IoVorbisDspState *self, IoObject *locals, IoMessage *m) { /*doc VorbisBlock synthesis(packet) Decode the vorbis data from the packet, storing it in the block. */ IoOggPacket *packet = IoMessage_locals_oggPacketArgAt_(m, locals, 0); int ret = vorbis_synthesis(DATA(self), ((ogg_packet*)(IoObject_dataPointer(packet)))); return IONUMBER(ret); }
//inline void IoObject_freeData(IoObject *self) { IoTagFreeFunc *func = IoTag_freeFunc(IoObject_tag(self)); if (func) { //if(func == free) { //printf("Tag func is free\n"); //if (IoObject_name(self)) printf("free %s\n", IoObject_name(self)); } (*func)(self); } else if (IoObject_dataPointer(self)) { io_free(IoObject_dataPointer(self)); } IoObject_setDataPointer_(self, NULL); }
IoObject *IoTheoraDecodeContext_packetin(IoTheoraDecodeContext *self, IoObject *locals, IoMessage *m) { /*doc TheoraDecodecontext packetin(packet) Try to decode a theora frame from the packet. */ IoOggPacket *packet = IoMessage_locals_oggPacketArgAt_(m, locals, 3); int ret = th_decode_packetin(DATA(self)->ctx, ((ogg_packet*)(IoObject_dataPointer(packet))), &(DATA(self)->granulepos)); return IONUMBER(ret); }
IoObject *IoVorbisBlock_setup(IoVorbisDspState *self, IoObject *locals, IoMessage *m) { /*doc VorbisBlock setup Initialize for decoding using the information obtained from reading the Vorbis headers. */ IoVorbisDspState *dsp = IoMessage_locals_vorbisDspStateArgAt_(m, locals, 0); int ret = vorbis_block_init(((vorbis_dsp_state*)(IoObject_dataPointer(dsp))), DATA(self)); IOASSERT(ret == 0, "vorbis_synthesis_init returned non-zero value"); return self; }
IoObject *IoEvDNSRequest_resolveIPv4(IoEvDNSRequest *self, IoObject *locals, IoMessage *m) { IoSeq *host = IoObject_seqGetSlot_(self, IOSYMBOL("host")); IoEvDNS *evDns = IoObject_getSlot_(self, IOSYMBOL("evDns")); IOASSERT(ISEVDNS(evDns), "evDns slot not set properly"); struct evdns_base *dnsBase = IoObject_dataPointer(evDns); struct evdns_request *req = evdns_base_resolve_ipv4(dnsBase, CSTRING(host), DNS_QUERY_NO_SEARCH, (EvDNSRequest_callback_type)EvDNSRequest_callback, (void *)self ); IoObject_setDataPointer_(self, req); return self; }
void IoCall_free(IoCall *self) { io_free(IoObject_dataPointer(self)); }
IoMessage *IoMessage_proto(void *state) { IoMethodTable methodTable[] = { {"clone", IoMessage_clone}, {"name", IoMessage_protoName}, {"setName", IoMessage_protoSetName}, {"next", IoMessage_next}, {"setNext", IoMessage_setNext}, {"isEndOfLine", IoMessage_isEOL}, {"nextIgnoreEndOfLines", IoMessage_nextIgnoreEOLs}, {"last", IoMessage_last}, {"lastBeforeEndOfLine", IoMessage_lastBeforeEOL}, {"argAt", IoMessage_argAt}, {"arguments", IoMessage_arguments}, {"setArguments", IoMessage_setArguments}, {"appendArg", IoMessage_appendArg}, {"appendCachedArg", IoMessage_appendCachedArg}, {"argCount", IoMessage_argCount_}, {"cachedResult", IoMessage_cachedResult}, {"setCachedResult", IoMessage_setCachedResult}, {"removeCachedResult", IoMessage_removeCachedResult}, {"hasCachedResult", IoMessage_hasCachedResult}, {"lineNumber", IoMessage_lineNumber}, {"setLineNumber", IoMessage_setLineNumber}, {"characterNumber", IoMessage_characterNumber}, {"setCharacterNumber", IoMessage_setCharacterNumber}, {"label", IoMessage_label}, {"setLabel", IoMessage_setLabel}, {"code", IoMessage_descriptionString}, {"doInContext", IoMessage_doInContext}, {"fromString", IoMessage_fromString}, {"argsEvaluatedIn", IoMessage_argsEvaluatedIn}, {"asString", IoMessage_asString}, {"asMessageWithEvaluatedArgs", IoMessage_asMessageWithEvaluatedArgs}, {"opShuffle", IoMessage_opShuffle}, {"opShuffleC", IoMessage_opShuffle}, #ifdef IOMESSAGE_HASPREV {"previous", IoMessage_previous}, #endif {NULL, NULL}, }; IoObject *self = IoObject_new(state); IoMessageData *d; IoObject_setDataPointer_(self, io_calloc(1, sizeof(IoMessageData))); d = IoObject_dataPointer(self); IoObject_tag_(self, IoMessage_newTag(state)); d->args = List_new(); d->name = IOSYMBOL("[unnamed]"); d->label = IOSYMBOL("[unlabeled]"); //d->charNumber = -1; d->lineNumber = -1; IoState_registerProtoWithFunc_((IoState *)state, self, protoId); IoObject_addMethodTable_(self, methodTable); return self; }