Esempio n. 1
0
int main(int argc, char* argv[]) 
{ 
	HSQUIRRELVM v; 
	v = sq_open(1024); // creates a VM with initial stack size 1024 

	//REGISTRATION OF STDLIB
	//sq_pushroottable(v); //push the root table where the std function will be registered
	//sqstd_register_iolib(v);  //registers a library
	// ... call here other stdlibs string,math etc...
	//sq_pop(v,1); //pops the root table
	//END REGISTRATION OF STDLIB
	
	sqstd_seterrorhandlers(v); //registers the default error handlers

	sq_setprintfunc(v, printfunc,errorfunc); //sets the print function

	sq_pushroottable(v); //push the root table(were the globals of the script will be stored)
	if(SQ_SUCCEEDED(sqstd_dofile(v, _SC("test.nut"), SQFalse, SQTrue))) // also prints syntax errors if any 
	{
		call_foo(v,1,2.5,_SC("teststring"));
	}

	sq_pop(v,1); //pops the root table
	sq_close(v); 

	return 0; 
} 
Esempio n. 2
0
int main()
{
	std::cout << std::boolalpha;

	std::cout << "struct with_simple_foo has foo method = "
				<< has_foo<with_simple_foo>::value << std::endl;
	std::cout << "struct with_foo_int has foo method = "
				<< has_foo<with_foo_int>::value << std::endl;
	std::cout << "struct with_multiple_foo has foo method = "
				<< has_foo<with_multiple_foo>::value << std::endl;
	std::cout << "struct without_foo has foo method = "
				<< has_foo<without_foo>::value << std::endl;

	call_foo(with_simple_foo());
	call_foo(without_foo());

	return 0;
}
Esempio n. 3
0
int
main(void)
{
  g_extern = 42; /* 7.3.4 共享模块的全局变量 */
  call_foo();

  getchar();
  return 0;
}