minimal.c
00001 #include <stdarg.h>
00002 #include <stdio.h>
00003
00004 #include <squirrel.h>
00005 #include <sqstdio.h>
00006 #include <sqstdaux.h>
00007
00008 #ifdef _MSC_VER
00009 #pragma comment (lib ,"squirrel.lib")
00010 #pragma comment (lib ,"sqstdlib.lib")
00011 #endif
00012
00013 #ifdef SQUNICODE
00014 #define scvprintf vwprintf
00015 #else
00016 #define scvprintf vprintf
00017 #endif
00018
00019 void printfunc(HSQUIRRELVM v, const SQChar *s, ...)
00020 {
00021 va_list arglist;
00022 va_start(arglist, s);
00023 scvprintf(s, arglist);
00024 va_end(arglist);
00025 }
00026
00027 void call_foo(HSQUIRRELVM v, int n,float f,const SQChar *s)
00028 {
00029 SQInteger top = sq_gettop(v);
00030 sq_pushroottable(v);
00031 sq_pushstring(v,_SC("foo"),-1);
00032 if(SQ_SUCCEEDED(sq_get(v,-2))) {
00033 sq_pushroottable(v);
00034 sq_pushinteger(v,n);
00035 sq_pushfloat(v,f);
00036 sq_pushstring(v,s,-1);
00037 sq_call(v,4,SQFalse,SQTrue);
00038 }
00039 sq_settop(v,top);
00040 }
00041
00042 int main(int argc, char* argv[])
00043 {
00044 HSQUIRRELVM v;
00045 v = sq_open(1024);
00046
00047
00048
00049 sqstd_seterrorhandlers(v);
00050
00051 sq_setprintfunc(v, printfunc);
00052
00053 sq_pushroottable(v);
00054 if(SQ_SUCCEEDED(sqstd_dofile(v, _SC("test.nut"), SQFalse, SQTrue)))
00055 {
00056 call_foo(v,1,2.5,_SC("teststring"));
00057 }
00058
00059 sq_pop(v,1);
00060 sq_close(v);
00061
00062 return 0;
00063 }