The Battle for Wesnoth  1.15.2+dev
Macros | Functions | Variables
lmathlib.cpp File Reference
#include "lprefix.h"
#include <stdlib.h>
#include <math.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
Include dependency graph for lmathlib.cpp:

Go to the source code of this file.

Macros

#define lmathlib_c
 
#define LUA_LIB
 
#define PI   (l_mathop(3.141592653589793238462643383279502884))
 
#define l_rand()   rand()
 
#define l_srand(x)   srand(x)
 
#define L_RANDMAX   RAND_MAX
 

Functions

static int math_abs (lua_State *L)
 
static int math_sin (lua_State *L)
 
static int math_cos (lua_State *L)
 
static int math_tan (lua_State *L)
 
static int math_asin (lua_State *L)
 
static int math_acos (lua_State *L)
 
static int math_atan (lua_State *L)
 
static int math_toint (lua_State *L)
 
static void pushnumint (lua_State *L, lua_Number d)
 
static int math_floor (lua_State *L)
 
static int math_ceil (lua_State *L)
 
static int math_fmod (lua_State *L)
 
static int math_modf (lua_State *L)
 
static int math_sqrt (lua_State *L)
 
static int math_ult (lua_State *L)
 
static int math_log (lua_State *L)
 
static int math_exp (lua_State *L)
 
static int math_deg (lua_State *L)
 
static int math_rad (lua_State *L)
 
static int math_min (lua_State *L)
 
static int math_max (lua_State *L)
 
static int math_random (lua_State *L)
 
static int math_randomseed (lua_State *L)
 
static int math_type (lua_State *L)
 
LUAMOD_API int luaopen_math (lua_State *L)
 

Variables

static const luaL_Reg mathlib []
 

Macro Definition Documentation

◆ l_rand

#define l_rand ( )    rand()

Definition at line 32 of file lmathlib.cpp.

Referenced by math_random(), and math_randomseed().

◆ L_RANDMAX

#define L_RANDMAX   RAND_MAX

Definition at line 34 of file lmathlib.cpp.

Referenced by math_random().

◆ l_srand

#define l_srand (   x)    srand(x)

Definition at line 33 of file lmathlib.cpp.

Referenced by math_randomseed().

◆ lmathlib_c

#define lmathlib_c

Definition at line 7 of file lmathlib.cpp.

◆ LUA_LIB

#define LUA_LIB

Definition at line 8 of file lmathlib.cpp.

◆ PI

#define PI   (l_mathop(3.141592653589793238462643383279502884))

Definition at line 23 of file lmathlib.cpp.

Referenced by luaopen_math(), math_deg(), and math_rad().

Function Documentation

◆ luaopen_math()

LUAMOD_API int luaopen_math ( lua_State L)

◆ math_abs()

static int math_abs ( lua_State L)
static

◆ math_acos()

static int math_acos ( lua_State L)
static

Definition at line 70 of file lmathlib.cpp.

References l_mathop, lua_pushnumber(), and luaL_checknumber().

◆ math_asin()

static int math_asin ( lua_State L)
static

Definition at line 65 of file lmathlib.cpp.

References l_mathop, lua_pushnumber(), and luaL_checknumber().

◆ math_atan()

static int math_atan ( lua_State L)
static

Definition at line 75 of file lmathlib.cpp.

References l_mathop, lua_pushnumber(), luaL_checknumber(), and luaL_optnumber().

◆ math_ceil()

static int math_ceil ( lua_State L)
static

Definition at line 116 of file lmathlib.cpp.

References d, l_mathop, lua_isinteger(), lua_settop(), luaL_checknumber(), and pushnumint().

◆ math_cos()

static int math_cos ( lua_State L)
static

Definition at line 55 of file lmathlib.cpp.

References l_mathop, lua_pushnumber(), and luaL_checknumber().

◆ math_deg()

static int math_deg ( lua_State L)
static

Definition at line 204 of file lmathlib.cpp.

References l_mathop, lua_pushnumber(), luaL_checknumber(), and PI.

◆ math_exp()

static int math_exp ( lua_State L)
static

Definition at line 199 of file lmathlib.cpp.

References l_mathop, lua_pushnumber(), and luaL_checknumber().

◆ math_floor()

static int math_floor ( lua_State L)
static

Definition at line 105 of file lmathlib.cpp.

References d, l_mathop, lua_isinteger(), lua_settop(), luaL_checknumber(), and pushnumint().

◆ math_fmod()

static int math_fmod ( lua_State L)
static

◆ math_log()

static int math_log ( lua_State L)
static

Definition at line 179 of file lmathlib.cpp.

References l_mathop, lua_isnoneornil, lua_pushnumber(), and luaL_checknumber().

◆ math_max()

static int math_max ( lua_State L)
static

Definition at line 229 of file lmathlib.cpp.

References i, lua_compare(), lua_gettop(), LUA_OPLT, lua_pushvalue(), luaL_argcheck, and n.

◆ math_min()

static int math_min ( lua_State L)
static

Definition at line 215 of file lmathlib.cpp.

References i, lua_compare(), lua_gettop(), LUA_OPLT, lua_pushvalue(), luaL_argcheck, and n.

◆ math_modf()

static int math_modf ( lua_State L)
static

◆ math_rad()

static int math_rad ( lua_State L)
static

Definition at line 209 of file lmathlib.cpp.

References l_mathop, lua_pushnumber(), luaL_checknumber(), and PI.

◆ math_random()

static int math_random ( lua_State L)
static

◆ math_randomseed()

static int math_randomseed ( lua_State L)
static

Definition at line 277 of file lmathlib.cpp.

References l_rand, l_srand, and luaL_checknumber().

◆ math_sin()

static int math_sin ( lua_State L)
static

Definition at line 50 of file lmathlib.cpp.

References l_mathop, lua_pushnumber(), and luaL_checknumber().

◆ math_sqrt()

static int math_sqrt ( lua_State L)
static

Definition at line 166 of file lmathlib.cpp.

References l_mathop, lua_pushnumber(), and luaL_checknumber().

◆ math_tan()

static int math_tan ( lua_State L)
static

Definition at line 60 of file lmathlib.cpp.

References l_mathop, lua_pushnumber(), and luaL_checknumber().

◆ math_toint()

static int math_toint ( lua_State L)
static

Definition at line 83 of file lmathlib.cpp.

References lua_pushinteger(), lua_pushnil(), lua_tointegerx(), luaL_checkany(), and n.

◆ math_type()

static int math_type ( lua_State L)
static

◆ math_ult()

static int math_ult ( lua_State L)
static

Definition at line 172 of file lmathlib.cpp.

References a, b, lua_pushboolean(), and luaL_checkinteger().

◆ pushnumint()

static void pushnumint ( lua_State L,
lua_Number  d 
)
static

Definition at line 96 of file lmathlib.cpp.

References lua_numbertointeger, lua_pushinteger(), lua_pushnumber(), and n.

Referenced by math_ceil(), math_floor(), and math_modf().

Variable Documentation

◆ mathlib

const luaL_Reg mathlib[]
static

Definition at line 352 of file lmathlib.cpp.