Esempio n. 1
0
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;
}
Esempio n. 2
0
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;
}