Beispiel #1
0
	void* ValuePointer::Call (void* arg0, void* arg1, void* arg2, void* arg3, void* arg4) {

		if (!hlValue) {

			value vals[] = {
				(value)arg0,
				(value)arg1,
				(value)arg2,
				(value)arg3,
				(value)arg4,
			};

			return val_callN ((value)Get (), vals, 5);

		} else {

			vdynamic* args[] = {
				(vdynamic*)arg0,
				(vdynamic*)arg1,
				(vdynamic*)arg2,
				(vdynamic*)arg3,
				(vdynamic*)arg4,
			};

			return hl_dyn_call ((vclosure*)hlValue, (vdynamic**)&args, 5);

		}

	}
Beispiel #2
0
static value apply1( value p1 ) {
	value env = NEKO_VM()->env;
	value *a = val_array_ptr(env) + 1;
	int n = val_array_size(env) - 1;
	a[n-1] = p1;
	return val_callN(a[-1],a,n);
}
Beispiel #3
0
/**
	$apply : function -> any* -> any
	<doc>
	Apply the function to several arguments.
	Return a function asking for more arguments or the function result if more args needed.
	</doc>
**/
static value builtin_apply( value *args, int nargs ) {
	value f, env;
	int fargs;
	int i;
	nargs--;
	args++;
	if( nargs < 0 )
		neko_error();
	f = args[-1];
	if( !val_is_function(f) )
		neko_error();
	if( nargs == 0 )
		return f;
	fargs = val_fun_nargs(f);
	if( fargs == nargs || fargs == VAR_ARGS )
		return val_callN(f,args,nargs);
	if( nargs > fargs )
		neko_error();
	env = alloc_array(fargs + 1);
	val_array_ptr(env)[0] = f;
	for(i=0;i<nargs;i++)
		val_array_ptr(env)[i+1] = args[i];
	while( i++ < fargs )
		val_array_ptr(env)[i] = val_null;
	return neko_alloc_apply(fargs-nargs,env);
}
Beispiel #4
0
value fcListFonts( value v_add ) {
	int i;
	FcFontSet *fonts = FcConfigGetFonts( 0, FcSetSystem );
	if( fonts == NULL ) val_throw( alloc_string("Fontconfig couldn't find any fonts") );
	
	for( i=0; i<fonts->nfont; i++ ) {
		FcPattern *font = fonts->fonts[i];
		
		FcChar8 *familyName;
		FcChar8 *style;
		int weight, slant;
		bool outline;
		
		FcPatternGetBool( font, FC_OUTLINE, 0, &outline );
		if( outline ) {
			FcPatternGetString( font, FC_FAMILY, 0, &familyName );
			FcPatternGetString( font, FC_STYLE, 0, &style);
			FcPatternGetInteger( font, FC_WEIGHT, 0, &weight);
			FcPatternGetInteger( font, FC_SLANT, 0, &slant);
			
	//		name = FcNameUnparse( font );
	//		printf("\nFont: %s || %s\n", familyName, style );
	//		FcPatternPrint( font );
	
			value arg[4] = {
				alloc_string((const char *)familyName), alloc_string((const char *)style),
				alloc_int(weight), alloc_int(slant)
			};
			
			val_callN( v_add, arg, 4 );
		}
	}
}
Beispiel #5
0
static value apply3( value p1, value p2, value p3 ) {
	value env = NEKO_VM()->env;
	value *a = val_array_ptr(env) + 1;
	int n = val_array_size(env) - 1;
	a[n-3] = p1;
	a[n-2] = p2;
	a[n-1] = p3;
	return val_callN(a[-1],a,n);
}
Beispiel #6
0
/**
	$call : f:function -> this:any -> args:array -> any
	<doc>Call [f] with [this] context and [args] arguments</doc>
**/
static value builtin_call( value f, value ctx, value args ) {
	value old;
	value ret;
	neko_vm *vm;
	val_check(args,array);
	vm = NEKO_VM();
	old = vm->vthis;
	vm->vthis = ctx;
	ret = val_callN(f,val_array_ptr(args),val_array_size(args));
	vm->vthis = old;
	return ret;
}
Beispiel #7
0
    bool mouseEvent(Mouse::MouseEvent event, int x, int y, int wheelData)
    {
        value vals[] =
            {
                EnumToValue(event),
                alloc_int(x),
                alloc_int(y),
                alloc_int(wheelData)
            };

        return val_get_bool(val_callN(clbkMouseEvent.get(), vals, 4));
    }
Beispiel #8
0
    void touchEvent(Touch::TouchEvent event, int x, int y, unsigned int contactIndex)
    {
        value vals[] =
            {
                EnumToValue(event),
                alloc_int(x),
                alloc_int(y),
                alloc_int(contactIndex)
            };

        val_callN(clbkTouchEvent.get(), vals, 4);
    }
    void collisionEvent(
                PhysicsCollisionObject::CollisionListener::EventType type,
                const PhysicsCollisionObject::CollisionPair &collisionPair,
                const Vector3 &contactPointA,
                const Vector3 &contactPointB)
    {
        value args[] =
            {
                EnumToValue(type),
                ObjectToValue(
                        new PhysicsCollisionObject::CollisionPair(
                                collisionPair.objectA,
                                collisionPair.objectB
                            )
                    ),
                ObjectToValue(&contactPointA, false),
                ObjectToValue(&contactPointB, false)
            };

        val_callN(clbkCollisionEvent.get(), args, 4);
    }
Beispiel #10
0
EXTERN value val_call3( value f, value arg1, value arg2, value arg3 ) {
	value args[3] = { arg1, arg2, arg3 };
	return val_callN(f,args,3);
}
Beispiel #11
0
EXTERN value val_call2( value f, value v1, value v2 ) {
	value args[2] = { v1, v2 };
	return val_callN(f,args,2);
}
Beispiel #12
0
EXTERN value val_call1( value f, value v ) {
	return val_callN(f,&v,1);
}
Beispiel #13
0
EXTERN value val_call0( value f ) {
	return val_callN(f,NULL,0);
}
Beispiel #14
0
value  api_val_callN(value  arg1,value  *arg2,int nargs)
{
	return val_callN(arg1,arg2,nargs);
}