Exemplo n.º 1
0
IoObject *IoDrawStuff_dsGetViewpoint(IoDrawStuff *self, IoObject *locals, IoMessage *m)
{
    float xyz[3];
    float hpr[3];
    vec3f v1, v2;
    IoSeq *list_xyz = IoMessage_locals_vectorArgAt_(m, locals, 0);
    IoSeq *list_hpr = IoMessage_locals_vectorArgAt_(m, locals, 1);
    dsGetViewpoint(xyz, hpr);
    v1.x = xyz[0]; v1.y = xyz[1]; v1.z = xyz[2];
    v2.x = hpr[0]; v2.y = hpr[1]; v2.z = hpr[2];
    memcpy(IoSeq_rawBytes(list_xyz), &v1, sizeof(vec3f));
    memcpy(IoSeq_rawBytes(list_hpr), &v2, sizeof(vec3f));

    return self;
} 
Exemplo n.º 2
0
IoObject *IoTokyoCabinetPrefixCursor_jump(IoObject *self, IoObject *locals, IoMessage *m)
{
	/*doc TokyoCabinetPrefixCursor jump(key)
	Move cursor to record before key. Returns self
	*/
	
	IoSeq *key = IoMessage_locals_seqArgAt_(m, locals, 0);

	IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");
	return IOBOOL(self, tcbdbcurjump(TokyoCabinetPrefixCursor(self), (const void *)IoSeq_rawBytes(key), (int)IoSeq_rawSizeInBytes(key)));
}
Exemplo n.º 3
0
Arquivo: IoSHA1.c Projeto: ADTSH/io
IoObject *IoSHA1_appendSeq(IoSHA1 *self, IoObject *locals, IoMessage *m)
{
	/*doc SHA1 appendSeq(aSequence)
	Appends aSequence to the hash calculation. Returns self.
	 */

	IoSeq *buffer = IoMessage_locals_seqArgAt_(m, locals, 0);
	IOASSERT(DATA(self)->isDone == 0, "cannot append to an already calculated sha1");
	SHA1Update(&(DATA(self)->context),
			 (unsigned char const *)IoSeq_rawBytes(buffer),
			 IoSeq_rawSize(buffer));
	return self;
}
Exemplo n.º 4
0
IoObject *IoTokyoCabinetPrefixCursor_put(IoObject *self, IoObject *locals, IoMessage *m)
{
	/*doc TokyoCabinetPrefixCursor put(value)
	Sets the value at the current cursor postion. Returns self.
	*/
	
	IoSeq *value = IoMessage_locals_seqArgAt_(m, locals, 0);

	IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");

	IOASSERT(tcbdbcurput(TokyoCabinetPrefixCursor(self), (const char *)IoSeq_rawBytes(value), IoSeq_rawSizeInBytes(value), BDBCPCURRENT), tcbdberrmsg(tcbdbecode(TokyoCabinet(self))));

	return self;
}
Exemplo n.º 5
0
intptr_t marshal(IoDynLib *self, IoObject *arg)
{
	intptr_t n = 0;

	if (ISNUMBER(arg))
	{
		n = IoNumber_asInt(arg);
	}
	else if (ISSYMBOL(arg))
	{
		n = (intptr_t)CSTRING(arg);
	}
	else if (ISLIST(arg))
	{
		int i;
		intptr_t *l = io_calloc(1, IoList_rawSize(arg) * sizeof(intptr_t));
		for (i = 0; i < IoList_rawSize(arg); i ++)
			l[i] = marshal(self, List_rawAt_(IoList_rawList(arg), i));
		n = (intptr_t)l;
	}
	else if (ISBUFFER(arg))
	{
		n = (intptr_t)IoSeq_rawBytes(arg);
	}
	else if (ISBLOCK(arg))
	{
		unsigned char *blk = io_calloc(1, 20), *p = blk;
		// FIXME: need trampoline code for other architectures
		*p++ = 0x68;
		*((intptr_t *)p) = (intptr_t)arg;
		p += sizeof(intptr_t);
		*p++ = 0xb8;
		*((intptr_t *)p) = (intptr_t)bouncer;
		p += sizeof(intptr_t);
		*p++ = 0xff;
		*p++ = 0xd0;
		*p++ = 0x83;
		*p++ = 0xc4;
		*p++ = 0x04;
		*p++ = 0xc3;
		n = (intptr_t)blk;
	}
	else
	{
		n =  (intptr_t)arg; //IONIL(self);
	}

	return n;
}
Exemplo n.º 6
0
Arquivo: IoLinker.c Projeto: ADTSH/io
IoObject *IoLinker_makeCFunction(IoLinker *self, IoObject *locals, IoMessage *m)
{
/*doc Linker makeCFunction(aSeq, slotName, object)
Creates a CFunction which users the beginning address of the data in aSeq as its function pointer and 
adds the CFunction to the given object on slot slotName.
*/
	IoSeq *buffer = IoMessage_locals_seqArgAt_(m, locals, 0);
	IoSeq *slotName = IoMessage_locals_seqArgAt_(m, locals, 1);
	IoObject *object = IoMessage_locals_valueArgAt_(m, locals, 2);
	IoCFunction *f;
	IoUserFunction* fp = (IoUserFunction*)IoSeq_rawBytes(buffer);

	f = IoCFunction_newWithFunctionPointer_tag_name_(IOSTATE, fp, IoObject_tag(object), CSTRING(slotName));
	IoObject_setSlot_to_(f, IOSYMBOL("compiledCode"), buffer);
	return f;
}
Exemplo n.º 7
0
IoObject *IoSeq_drawAsLine(IoSeq *self, IoObject *locals, IoMessage *m)
{
	IoSeq_assertIsVector(self, locals, m);
	{
	size_t i, size = IoSeq_rawSize(self);
	float *values = (float *)IoSeq_rawBytes(self);

	glBegin(GL_LINE_STRIP);

	for (i = 0; i < size; i ++)
	{
		glVertex2f((float)i, values[i]);
	}

	glEnd();
	}
	return self;
}
Exemplo n.º 8
0
IoObject *IoTokyoCabinetPrefixCursor_first(IoObject *self, IoObject *locals, IoMessage *m)
{
	/*doc TokyoCabinetPrefixCursor first
	Move cursor to first record. Returns self
	*/

	IoSeq *prefix = IoObject_getSlot_(self, IOSYMBOL("prefix"));
	IOASSERT(ISSEQ(prefix), "prefix must be a sequence");
	IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");
	
	tcbdbcurjump(TokyoCabinetPrefixCursor(self), (const void *)IoSeq_rawBytes(prefix), (int)IoSeq_rawSizeInBytes(prefix));
	
	if(!IoTokyoCabinetPrefixCursor_keyBeginsWithPrefix_(self, prefix))
	{
		tcbdbcurnext(TokyoCabinetPrefixCursor(self));
	}
	
	return IOBOOL(self, IoTokyoCabinetPrefixCursor_keyBeginsWithPrefix_(self, prefix));
}
Exemplo n.º 9
0
IoObject *IoSeq_drawFilled(IoSeq *self, IoObject *locals, IoMessage *m)
{
	IoSeq_assertIsVector(self, locals, m);
	{
	size_t i, size = IoSeq_rawSize(self);
	float *values = (float *)IoSeq_rawBytes(self);

	glBegin(GL_TRIANGLE_STRIP);

	for (i = 0; i < size; i ++)
	{
		float x = i;
		float y = values[i];

		glVertex2f(x, 0);
		glVertex2f(x, y);
	}

	glEnd();
	}
	return self;
}