Example #1
0
IoObject *IoMessage_locals_listArgAt_(IoMessage *self, IoObject *locals, int n)
{
	IoObject *v = IoMessage_locals_valueArgAt_(self, locals, n);
	if (!ISLIST(v)) IoMessage_locals_numberArgAt_errorForType_(self, locals, n, "List");
	return v;
}
Example #2
0
IoObject *IoMessage_locals_dateArgAt_(IoMessage *self, IoObject *locals, int n)
{
	IoObject *v = IoMessage_locals_valueArgAt_(self, locals, n);
	if (!ISDATE(v)) IoMessage_locals_numberArgAt_errorForType_(self, locals, n, "Date");
	return v;
}
Example #3
0
IoObject *IoMessage_locals_messageArgAt_(IoMessage *self, IoObject *locals, int n)
{
	IoObject *v = IoMessage_locals_valueArgAt_(self, locals, n);
	if (!ISMESSAGE(v)) IoMessage_locals_numberArgAt_errorForType_(self, locals, n, "Message");
	return v;
}
Example #4
0
IoObject *IoMessage_locals_valueAsStringArgAt_(IoMessage *self, IoObject *locals, int n)
{
	return IoObject_asString_(IoMessage_locals_valueArgAt_(self, locals, n), self);
}
Example #5
0
IoObject *IoMessage_locals_blockArgAt_(IoMessage *self, IoObject *locals, int n)
{
	IoObject *v = IoMessage_locals_valueArgAt_(self, locals, n);
	if (!ISBLOCK(v)) IoMessage_locals_numberArgAt_errorForType_(self, locals, n, "Block");
	return v;
}
Example #6
0
IoObject *IoDrawStuff_eventTarget(IoDrawStuff *self, IoObject *locals, IoMessage *m)
{
    DATA(proto)->eventTarget = IOREF(IoMessage_locals_valueArgAt_(m, locals, 0));
    return self;
}        
Example #7
0
int IoMessage_locals_boolArgAt_(IoMessage *self, IoObject *locals, int n)
{
	IoObject *v = IoMessage_locals_valueArgAt_(self, locals, n);

	return !ISNIL(v) && !ISFALSE(v);
}
Example #8
0
IoObject *IoCairoContext_create(IoCairoContext *self, IoObject *locals, IoMessage *m)
{
	return IoCairoContext_newWithSurface_(IOSTATE, IoMessage_locals_valueArgAt_(m, locals, 0));
}
Example #9
0
IoDuration *IoMessage_locals_durationArgAt_(IoMessage *self, void *locals, int n)
{
	IoObject *v = IoMessage_locals_valueArgAt_(self, (IoObject *)locals, n);
	if (!ISDURATION(v)) IoMessage_locals_numberArgAt_errorForType_(self, (IoObject *)locals, n, "Duration");
	return v;
}
Example #10
0
IoObject *IoMessage_locals_theoraDecodeContextArgAt_(IoMessage *self, IoObject *locals, int n)
{
  IoObject* v = IoMessage_locals_valueArgAt_(self, locals, n);
  if (!ISTHEORADECODECONTEXT(v)) IoMessage_locals_numberArgAt_errorForType_(self, locals, n, protoId);
  return v;
}
Example #11
0
IoCoroutine *IoMessage_locals_coroutineArgAt_(IoMessage *self, void *locals, int n)
{
	IoObject *v = IoMessage_locals_valueArgAt_(self, (IoObject *)locals, n);
	if (!ISCOROUTINE(v)) IoMessage_locals_numberArgAt_errorForType_(self, (IoObject *)locals, n, "Coroutine");
	return v;
}
Example #12
0
File: IoDynLib.c Project: ADTSH/io
IoDynLib *IoDynLib_justCall(IoDynLib *self, IoObject *locals, IoMessage *m, int isVoid)
{
	int n, rc = 0;
	intptr_t *params = NULL;
	IoSymbol *callName = IoMessage_locals_symbolArgAt_(m, locals, 0);
	void *f = DynLib_pointerForSymbolName_(DATA(self), CSTRING(callName));

	//printf("DynLib calling '%s'\n", CSTRING(callName));

	if (f == NULL)
	{
		IoState_error_(IOSTATE, m, "Error resolving call '%s'.", CSTRING(callName));
		return IONIL(self);
	}

	if (IoMessage_argCount(m) > 9)
	{
		IoState_error_(IOSTATE, m, "Error, too many arguments (%i) to call '%s'.",
					IoMessage_argCount(m) - 1,
					CSTRING(callName));
		return IONIL(self);
	}

	if (IoMessage_argCount(m) > 1)
	{
		params = io_calloc(1, IoMessage_argCount(m) * sizeof(unsigned int));

		for (n = 0; n < IoMessage_argCount(m) - 1; n++)
		{
			IoObject *arg = IoMessage_locals_valueArgAt_(m, locals, n + 1);
			intptr_t p = marshal(self, arg);

			params[n] = p;

			/*
			if (p == 0)
			{
				IoState_error_(IOSTATE, m, "DynLib error marshalling argument (%i) to call '%s'.",
							n + 1, CSTRING(callName));
				// FIXME this can leak memory.
				io_free(params);
				return IONIL(self);
			}
			*/
		}
	}

#if 0
	printf("calling %s with %i arguments\n",
	CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 0)),
	IoMessage_argCount(m) - 1);
#endif

	IoState_pushCollectorPause(IOSTATE);

	if (isVoid)
	{
		IoDynLib_rawVoidCall(f, IoMessage_argCount(m), params);
	}
	else
	{
		rc = (int)IoDynLib_rawNonVoidCall(f, IoMessage_argCount(m), params);
	}

	IoState_popCollectorPause(IOSTATE);

	if(params)
	{
		for (n = 0; n < IoMessage_argCount(m) - 1; n ++)
		{
			IoObject *arg = IoMessage_locals_valueArgAt_(m, locals, n + 1);
			demarshal(self, arg, params[n]);
		}

		io_free(params);
	}

	return isVoid ? IONIL(self) : IONUMBER(rc);
}
Example #13
0
IoObject *IoAudioMixer_setAudioDevice(IoAudioMixer *self, IoObject *locals, IoMessage *m)
{
	DATA(self)->ioAudioDevice = IOREF(IoMessage_locals_valueArgAt_(m, locals, 0));
	return self;
}
Example #14
0
IoObject *IoMessage_locals_theoraCommentArgAt_(IoMessage *self, IoObject *locals, int n)
{
  IoObject* v = IoMessage_locals_valueArgAt_(self, locals, n);
  if (!ISTHEORACOMMENT(v)) IoMessage_locals_numberArgAt_errorForType_(self, locals, n, protoId);
  return v;
}
Example #15
0
IoObject *IoMessage_locals_theoraInfoArgAt_(IoMessage *self, IoObject *locals, int n)
{
  IoObject* v = IoMessage_locals_valueArgAt_(self, locals, n);
  if (!ISTHEORAINFO(v)) IoMessage_locals_numberArgAt_errorForType_(self, locals, n, "TheoraInfo");
  return v;
}
Example #16
0
IO_METHOD(IoSeq, between)
{
	/*doc Sequence betweenSeq(aSequence, anotherSequence)
	Returns a new Sequence containing the bytes between the
	occurrence of aSequence and anotherSequence in the receiver. 
	If aSequence is empty, this method is equivalent to beforeSeq(anotherSequence).
	If anotherSequence is nil, this method is equivalent to afterSeq(aSequence).
	nil is returned if no match is found.
	*/

	long start = 0;
	long end = 0;
	IoSeq *fromSeq, *toSeq;

	fromSeq = (IoSeq *)IoMessage_locals_valueArgAt_(m, locals, 0);

	if (ISSEQ(fromSeq))
	{
		if (IoSeq_rawSize(fromSeq) == 0)
		{
			start = 0;
		}
		else
		{
			start = UArray_find_from_(DATA(self), DATA(fromSeq), 0);

			if (start == -1)
			{
				//start = 0;
				return IONIL(self);
			}
			start += IoSeq_rawSize(fromSeq);
		}
	}
	else if (ISNIL(fromSeq))
	{
		start = 0;
	}
	else
	{
		IoState_error_(IOSTATE, m, "Nil or Sequence argument required for arg 0, not a %s",
					IoObject_name((IoObject *)fromSeq));
	}

	toSeq = (IoSeq *)IoMessage_locals_valueArgAt_(m, locals, 1);

	if (ISSEQ(toSeq))
	{
		end = UArray_find_from_(DATA(self), DATA(toSeq), start);
		//if (end == -1) start = UArray_size(DATA(self));
		if (end == -1) return IONIL(self);
	}
	else if (ISNIL(toSeq))
	{
		end = UArray_size(DATA(self));
	}
	else
	{
		IoState_error_(IOSTATE, m, "Nil or Sequence argument required for arg 1, not a %s",
					IoObject_name((IoObject *)toSeq));
	}

	{
		UArray *ba = UArray_slice(DATA(self), start, end);
		IoSeq *result = IoSeq_newWithUArray_copy_(IOSTATE, ba, 0);
		return result;
	}
}