diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-04-30 18:13:55 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-04-30 18:13:55 -0300 |
| commit | 3ec9ee0d0f81fd0aabaef1303f971b2f7ee12315 (patch) | |
| tree | 07c3b5bdd856340429a3567212fc86fe80fdd005 /mathlib.c | |
| parent | 21c9ebf4a9891786d5683537868cc348340ca89d (diff) | |
| download | lua-3ec9ee0d0f81fd0aabaef1303f971b2f7ee12315.tar.gz lua-3ec9ee0d0f81fd0aabaef1303f971b2f7ee12315.tar.bz2 lua-3ec9ee0d0f81fd0aabaef1303f971b2f7ee12315.zip | |
new function "luaI_openlib" to help open libs.
Diffstat (limited to 'mathlib.c')
| -rw-r--r-- | mathlib.c | 51 |
1 files changed, 27 insertions, 24 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** Mathematics library to LUA | 3 | ** Mathematics library to LUA |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_mathlib="$Id: mathlib.c,v 1.15 1996/04/22 18:00:37 roberto Exp roberto $"; | 6 | char *rcs_mathlib="$Id: mathlib.c,v 1.16 1996/04/25 14:10:00 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
| 9 | #include <math.h> | 9 | #include <math.h> |
| @@ -195,33 +195,36 @@ static void math_randomseed (void) | |||
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | 197 | ||
| 198 | static struct lua_reg mathlib[] = { | ||
| 199 | {"abs", math_abs}, | ||
| 200 | {"sin", math_sin}, | ||
| 201 | {"cos", math_cos}, | ||
| 202 | {"tan", math_tan}, | ||
| 203 | {"asin", math_asin}, | ||
| 204 | {"acos", math_acos}, | ||
| 205 | {"atan", math_atan}, | ||
| 206 | {"atan2", math_atan2}, | ||
| 207 | {"ceil", math_ceil}, | ||
| 208 | {"floor", math_floor}, | ||
| 209 | {"mod", math_mod}, | ||
| 210 | {"sqrt", math_sqrt}, | ||
| 211 | {"min", math_min}, | ||
| 212 | {"max", math_max}, | ||
| 213 | {"log", math_log}, | ||
| 214 | {"log10", math_log10}, | ||
| 215 | {"exp", math_exp}, | ||
| 216 | {"deg", math_deg}, | ||
| 217 | {"rad", math_rad}, | ||
| 218 | {"random", math_random}, | ||
| 219 | {"randomseed", math_randomseed} | ||
| 220 | }; | ||
| 198 | 221 | ||
| 199 | /* | 222 | /* |
| 200 | ** Open math library | 223 | ** Open math library |
| 201 | */ | 224 | */ |
| 202 | void mathlib_open (void) | 225 | void mathlib_open (void) |
| 203 | { | 226 | { |
| 204 | lua_register ("abs", math_abs); | 227 | luaI_openlib(mathlib, (sizeof(mathlib)/sizeof(mathlib[0]))); |
| 205 | lua_register ("sin", math_sin); | 228 | old_pow = lua_refobject(lua_setfallback("arith", math_pow), 1); |
| 206 | lua_register ("cos", math_cos); | ||
| 207 | lua_register ("tan", math_tan); | ||
| 208 | lua_register ("asin", math_asin); | ||
| 209 | lua_register ("acos", math_acos); | ||
| 210 | lua_register ("atan", math_atan); | ||
| 211 | lua_register ("atan2", math_atan2); | ||
| 212 | lua_register ("ceil", math_ceil); | ||
| 213 | lua_register ("floor", math_floor); | ||
| 214 | lua_register ("mod", math_mod); | ||
| 215 | lua_register ("sqrt", math_sqrt); | ||
| 216 | lua_register ("min", math_min); | ||
| 217 | lua_register ("max", math_max); | ||
| 218 | lua_register ("log", math_log); | ||
| 219 | lua_register ("log10", math_log10); | ||
| 220 | lua_register ("exp", math_exp); | ||
| 221 | lua_register ("deg", math_deg); | ||
| 222 | lua_register ("rad", math_rad); | ||
| 223 | lua_register ("random", math_random); | ||
| 224 | lua_register ("randomseed", math_randomseed); | ||
| 225 | |||
| 226 | old_pow = lua_refobject(lua_setfallback("arith", math_pow), 1); | ||
| 227 | } | 229 | } |
| 230 | |||
