Code::Blocks  SVN r11506
Macros | Functions | Variables
sqstdmath.cpp File Reference
#include <squirrel.h>
#include <math.h>
#include <stdlib.h>
#include <sqstdmath.h>
Include dependency graph for sqstdmath.cpp:

Go to the source code of this file.

Macros

#define SINGLE_ARG_FUNC(_funcname)
 
#define TWO_ARGS_FUNC(_funcname)
 
#define _DECL_FUNC(name, nparams, tycheck)   {_SC(#name),math_##name,nparams,tycheck}
 
#define M_PI   (3.14159265358979323846)
 

Functions

static SQInteger math_srand (HSQUIRRELVM v)
 
static SQInteger math_rand (HSQUIRRELVM v)
 
static SQInteger math_abs (HSQUIRRELVM v)
 
SQRESULT sqstd_register_mathlib (HSQUIRRELVM v)
 

Variables

static SQRegFunction mathlib_funcs []
 

Macro Definition Documentation

◆ _DECL_FUNC

#define _DECL_FUNC (   name,
  nparams,
  tycheck 
)    {_SC(#name),math_##name,nparams,tycheck}

Definition at line 61 of file sqstdmath.cpp.

◆ M_PI

#define M_PI   (3.14159265358979323846)

Definition at line 85 of file sqstdmath.cpp.

Referenced by sqstd_register_mathlib().

◆ SINGLE_ARG_FUNC

#define SINGLE_ARG_FUNC (   _funcname)
Value:
static SQInteger math_##_funcname(HSQUIRRELVM v){ \
SQFloat f; \
sq_getfloat(v,2,&f); \
sq_pushfloat(v,(SQFloat)_funcname(f)); \
return 1; \
}

Definition at line 7 of file sqstdmath.cpp.

Referenced by math_abs().

◆ TWO_ARGS_FUNC

#define TWO_ARGS_FUNC (   _funcname)
Value:
static SQInteger math_##_funcname(HSQUIRRELVM v){ \
SQFloat p1,p2; \
sq_getfloat(v,2,&p1); \
sq_getfloat(v,3,&p2); \
sq_pushfloat(v,(SQFloat)_funcname(p1,p2)); \
return 1; \
}

Definition at line 14 of file sqstdmath.cpp.

Referenced by math_abs().

Function Documentation

◆ math_abs()

static SQInteger math_abs ( HSQUIRRELVM  v)
static

Definition at line 37 of file sqstdmath.cpp.

References SINGLE_ARG_FUNC, sq_getinteger(), sq_pushinteger(), and TWO_ARGS_FUNC.

◆ math_rand()

static SQInteger math_rand ( HSQUIRRELVM  v)
static

Definition at line 31 of file sqstdmath.cpp.

References sq_pushinteger().

◆ math_srand()

static SQInteger math_srand ( HSQUIRRELVM  v)
static

Definition at line 22 of file sqstdmath.cpp.

References sq_getinteger(), and sq_throwerror().

◆ sqstd_register_mathlib()

SQRESULT sqstd_register_mathlib ( HSQUIRRELVM  v)

Variable Documentation

◆ mathlib_funcs

SQRegFunction mathlib_funcs[]
static
Initial value:
= {
_DECL_FUNC(sqrt,2,_SC(".n")),
_DECL_FUNC(sin,2,_SC(".n")),
_DECL_FUNC(cos,2,_SC(".n")),
_DECL_FUNC(asin,2,_SC(".n")),
_DECL_FUNC(acos,2,_SC(".n")),
_DECL_FUNC(log,2,_SC(".n")),
_DECL_FUNC(log10,2,_SC(".n")),
_DECL_FUNC(tan,2,_SC(".n")),
_DECL_FUNC(atan,2,_SC(".n")),
_DECL_FUNC(atan2,3,_SC(".nn")),
_DECL_FUNC(pow,3,_SC(".nn")),
_DECL_FUNC(floor,2,_SC(".n")),
_DECL_FUNC(ceil,2,_SC(".n")),
_DECL_FUNC(exp,2,_SC(".n")),
_DECL_FUNC(srand,2,_SC(".n")),
_DECL_FUNC(rand,1,NULL),
_DECL_FUNC(fabs,2,_SC(".n")),
_DECL_FUNC(abs,2,_SC(".n")),
{0,0},
}
#define _DECL_FUNC(name, nparams, tycheck)
Definition: sqstdmath.cpp:61
#define NULL
Definition: prefix.cpp:59

Definition at line 62 of file sqstdmath.cpp.

Referenced by sqstd_register_mathlib().