SVN revision: 12414
This commit is contained in:
Carsten Haitzler 2004-12-09 02:46:32 +00:00
parent aef7a9f080
commit d0f2572394
3 changed files with 12 additions and 2 deletions

View File

@ -98,7 +98,7 @@ main()
printf("Done. Return value of testfn() was %i\n", ret); printf("Done. Return value of testfn() was %i\n", ret);
printf("Test varargs...\n"); printf("Test varargs...\n");
vargs(1, 2, "hello", "there", 8, 9); vargs(1, 2, "hello", "there", 8, 77, 5.0, 7.77);
printf("\n\n"); printf("\n\n");
@ -113,6 +113,7 @@ vargs(a, b, ...)
for (new i = 2; i < numargs(); i++) for (new i = 2; i < numargs(); i++)
{ {
new val; new val;
new Float:fval;
new str[100]; new str[100];
printf(" GET ARG... %i\n", i); printf(" GET ARG... %i\n", i);
@ -125,11 +126,16 @@ vargs(a, b, ...)
} }
printf(" ARG: %s [max %i]\n", str, sizeof(str)); printf(" ARG: %s [max %i]\n", str, sizeof(str));
} }
else else if (i < 6)
{ {
val = getarg(i); val = getarg(i);
printf(" ARG: %i\n", val); printf(" ARG: %i\n", val);
} }
else if (i < 8)
{
fval = getfarg(i);
printf(" FARG: %f\n", fval);
}
} }
printf("ARGS DONE.\n"); printf("ARGS DONE.\n");
} }

View File

@ -36,8 +36,10 @@ enum Float_Angle_Mode
native numargs(); native numargs();
/* varags - get arg no "arg" */ /* varags - get arg no "arg" */
native getarg(arg, index=0); native getarg(arg, index=0);
native Float:getfarg(arg, index=0);
/* varags - set arg no "arg" */ /* varags - set arg no "arg" */
native setarg(arg, index=0, value); native setarg(arg, index=0, value);
native setfarg(arg, index=0, Float:value);
/* Convert a string into a floating point value */ /* Convert a string into a floating point value */
native Float:atof(const string[]); native Float:atof(const string[]);

View File

@ -59,4 +59,6 @@ _embryo_args_init(Embryo_Program *ep)
embryo_program_native_call_add(ep, "numargs", _embryo_args_numargs); embryo_program_native_call_add(ep, "numargs", _embryo_args_numargs);
embryo_program_native_call_add(ep, "getarg", _embryo_args_getarg); embryo_program_native_call_add(ep, "getarg", _embryo_args_getarg);
embryo_program_native_call_add(ep, "setarg", _embryo_args_setarg); embryo_program_native_call_add(ep, "setarg", _embryo_args_setarg);
embryo_program_native_call_add(ep, "getfarg", _embryo_args_getarg);
embryo_program_native_call_add(ep, "setfarg", _embryo_args_setarg);
} }