• Home
  • Raw
  • Download

Lines Matching refs:L

26 static int math_abs (lua_State *L) {  in math_abs()  argument
27 lua_pushnumber(L, l_mathop(fabs)(luaL_checknumber(L, 1))); in math_abs()
31 static int math_sin (lua_State *L) { in math_sin() argument
32 lua_pushnumber(L, l_mathop(sin)(luaL_checknumber(L, 1))); in math_sin()
36 static int math_sinh (lua_State *L) { in math_sinh() argument
37 lua_pushnumber(L, l_mathop(sinh)(luaL_checknumber(L, 1))); in math_sinh()
41 static int math_cos (lua_State *L) { in math_cos() argument
42 lua_pushnumber(L, l_mathop(cos)(luaL_checknumber(L, 1))); in math_cos()
46 static int math_cosh (lua_State *L) { in math_cosh() argument
47 lua_pushnumber(L, l_mathop(cosh)(luaL_checknumber(L, 1))); in math_cosh()
51 static int math_tan (lua_State *L) { in math_tan() argument
52 lua_pushnumber(L, l_mathop(tan)(luaL_checknumber(L, 1))); in math_tan()
56 static int math_tanh (lua_State *L) { in math_tanh() argument
57 lua_pushnumber(L, l_mathop(tanh)(luaL_checknumber(L, 1))); in math_tanh()
61 static int math_asin (lua_State *L) { in math_asin() argument
62 lua_pushnumber(L, l_mathop(asin)(luaL_checknumber(L, 1))); in math_asin()
66 static int math_acos (lua_State *L) { in math_acos() argument
67 lua_pushnumber(L, l_mathop(acos)(luaL_checknumber(L, 1))); in math_acos()
71 static int math_atan (lua_State *L) { in math_atan() argument
72 lua_pushnumber(L, l_mathop(atan)(luaL_checknumber(L, 1))); in math_atan()
76 static int math_atan2 (lua_State *L) { in math_atan2() argument
77 lua_pushnumber(L, l_mathop(atan2)(luaL_checknumber(L, 1), in math_atan2()
78 luaL_checknumber(L, 2))); in math_atan2()
82 static int math_ceil (lua_State *L) { in math_ceil() argument
83 lua_pushnumber(L, l_mathop(ceil)(luaL_checknumber(L, 1))); in math_ceil()
87 static int math_floor (lua_State *L) { in math_floor() argument
88 lua_pushnumber(L, l_mathop(floor)(luaL_checknumber(L, 1))); in math_floor()
92 static int math_fmod (lua_State *L) { in math_fmod() argument
93 lua_pushnumber(L, l_mathop(fmod)(luaL_checknumber(L, 1), in math_fmod()
94 luaL_checknumber(L, 2))); in math_fmod()
98 static int math_modf (lua_State *L) { in math_modf() argument
100 lua_Number fp = l_mathop(modf)(luaL_checknumber(L, 1), &ip); in math_modf()
101 lua_pushnumber(L, ip); in math_modf()
102 lua_pushnumber(L, fp); in math_modf()
106 static int math_sqrt (lua_State *L) { in math_sqrt() argument
107 lua_pushnumber(L, l_mathop(sqrt)(luaL_checknumber(L, 1))); in math_sqrt()
111 static int math_pow (lua_State *L) { in math_pow() argument
112 lua_Number x = luaL_checknumber(L, 1); in math_pow()
113 lua_Number y = luaL_checknumber(L, 2); in math_pow()
114 lua_pushnumber(L, l_mathop(pow)(x, y)); in math_pow()
118 static int math_log (lua_State *L) { in math_log() argument
119 lua_Number x = luaL_checknumber(L, 1); in math_log()
121 if (lua_isnoneornil(L, 2)) in math_log()
124 lua_Number base = luaL_checknumber(L, 2); in math_log()
128 lua_pushnumber(L, res); in math_log()
133 static int math_log10 (lua_State *L) { in math_log10() argument
134 lua_pushnumber(L, l_mathop(log10)(luaL_checknumber(L, 1))); in math_log10()
139 static int math_exp (lua_State *L) { in math_exp() argument
140 lua_pushnumber(L, l_mathop(exp)(luaL_checknumber(L, 1))); in math_exp()
144 static int math_deg (lua_State *L) { in math_deg() argument
145 lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); in math_deg()
149 static int math_rad (lua_State *L) { in math_rad() argument
150 lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); in math_rad()
154 static int math_frexp (lua_State *L) { in math_frexp() argument
156 lua_pushnumber(L, l_mathop(frexp)(luaL_checknumber(L, 1), &e)); in math_frexp()
157 lua_pushinteger(L, e); in math_frexp()
161 static int math_ldexp (lua_State *L) { in math_ldexp() argument
162 lua_Number x = luaL_checknumber(L, 1); in math_ldexp()
163 int ep = luaL_checkint(L, 2); in math_ldexp()
164 lua_pushnumber(L, l_mathop(ldexp)(x, ep)); in math_ldexp()
170 static int math_min (lua_State *L) { in math_min() argument
171 int n = lua_gettop(L); /* number of arguments */ in math_min()
172 lua_Number dmin = luaL_checknumber(L, 1); in math_min()
175 lua_Number d = luaL_checknumber(L, i); in math_min()
179 lua_pushnumber(L, dmin); in math_min()
184 static int math_max (lua_State *L) { in math_max() argument
185 int n = lua_gettop(L); /* number of arguments */ in math_max()
186 lua_Number dmax = luaL_checknumber(L, 1); in math_max()
189 lua_Number d = luaL_checknumber(L, i); in math_max()
193 lua_pushnumber(L, dmax); in math_max()
198 static int math_random (lua_State *L) { in math_random() argument
202 switch (lua_gettop(L)) { /* check number of arguments */ in math_random()
204 lua_pushnumber(L, r); /* Number between 0 and 1 */ in math_random()
208 lua_Number u = luaL_checknumber(L, 1); in math_random()
209 luaL_argcheck(L, (lua_Number)1.0 <= u, 1, "interval is empty"); in math_random()
210 lua_pushnumber(L, l_mathop(floor)(r*u) + (lua_Number)(1.0)); /* [1, u] */ in math_random()
214 lua_Number l = luaL_checknumber(L, 1); in math_random()
215 lua_Number u = luaL_checknumber(L, 2); in math_random()
216 luaL_argcheck(L, l <= u, 2, "interval is empty"); in math_random()
217 lua_pushnumber(L, l_mathop(floor)(r*(u-l+1)) + l); /* [l, u] */ in math_random()
220 default: return luaL_error(L, "wrong number of arguments"); in math_random()
226 static int math_randomseed (lua_State *L) { in math_randomseed() argument
227 srand(luaL_checkunsigned(L, 1)); in math_randomseed()
271 LUAMOD_API int luaopen_math (lua_State *L) { in luaopen_math() argument
272 luaL_newlib(L, mathlib); in luaopen_math()
273 lua_pushnumber(L, PI); in luaopen_math()
274 lua_setfield(L, -2, "pi"); in luaopen_math()
275 lua_pushnumber(L, HUGE_VAL); in luaopen_math()
276 lua_setfield(L, -2, "huge"); in luaopen_math()