diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-10-10 09:57:55 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-10-10 09:57:55 -0300 |
commit | 533737f26e3f8036d7978e09427ea5ff75aec9df (patch) | |
tree | 003004a423cf20bc4e1493918760494b0d694f93 /lmathlib.c | |
parent | a41d60e1d1f3a954648884d4ab7fb7e9ccdd52d6 (diff) | |
download | lua-533737f26e3f8036d7978e09427ea5ff75aec9df.tar.gz lua-533737f26e3f8036d7978e09427ea5ff75aec9df.tar.bz2 lua-533737f26e3f8036d7978e09427ea5ff75aec9df.zip |
new functions `lua_getfield' and `lua_setfield'
Diffstat (limited to 'lmathlib.c')
-rw-r--r-- | lmathlib.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.56 2003/03/11 12:30:37 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.57 2003/10/07 20:13:41 roberto Exp roberto $ |
3 | ** Standard mathematical library | 3 | ** Standard mathematical library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -235,12 +235,10 @@ static const luaL_reg mathlib[] = { | |||
235 | */ | 235 | */ |
236 | LUALIB_API int luaopen_math (lua_State *L) { | 236 | LUALIB_API int luaopen_math (lua_State *L) { |
237 | luaL_openlib(L, LUA_MATHLIBNAME, mathlib, 0); | 237 | luaL_openlib(L, LUA_MATHLIBNAME, mathlib, 0); |
238 | lua_pushliteral(L, "pi"); | ||
239 | lua_pushnumber(L, PI); | 238 | lua_pushnumber(L, PI); |
240 | lua_settable(L, -3); | 239 | lua_setfield(L, -2, "pi"); |
241 | lua_pushliteral(L, "__pow"); | ||
242 | lua_pushcfunction(L, math_pow); | 240 | lua_pushcfunction(L, math_pow); |
243 | lua_settable(L, LUA_GLOBALSINDEX); | 241 | lua_setfield(L, LUA_GLOBALSINDEX, "__pow"); |
244 | return 1; | 242 | return 1; |
245 | } | 243 | } |
246 | 244 | ||