ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

lua/lua.h

Go to the documentation of this file.
00001 /*
00002 ** Lua - An Extensible Extension Language
00003 ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
00004 ** e-mail: lua@tecgraf.puc-rio.br
00005 ** www: http://www.tecgraf.puc-rio.br/lua/
00006 ** See Copyright Notice at the end of this file
00007 */
00008 
00009 #ifndef GRIM_LUA_H
00010 #define GRIM_LUA_H
00011 
00012 #include "common/scummsys.h"
00013 #include "common/str.h"
00014 
00015 namespace Common {
00016     class String;
00017     class SeekableReadStream;
00018     class WriteStream;
00019     class File;
00020 }
00021 
00022 namespace Grim {
00023 
00024 #define LUA_VERSION     "Lua 3.1 (alpha)"
00025 #define LUA_COPYRIGHT   "Copyright (C) 1994-1998 TeCGraf, PUC-Rio"
00026 #define LUA_AUTHORS     "W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
00027 
00028 #define LUA_NOOBJECT  0
00029 
00030 #define LUA_ANYTAG    (-1)
00031 
00032 typedef void (*lua_CFunction)();
00033 typedef uint32 lua_Object;
00034 
00035 struct PointerId {
00036     uint64 id;
00037 };
00038 
00039 PointerId makeIdFromPointer(void *ptr);
00040 void *makePointerFromId(PointerId ptr);
00041 
00042 class LuaFile {
00043 public:
00044     Common::String _name;
00045     Common::String _filename;
00046     Common::SeekableReadStream *_in;
00047     Common::WriteStream *_out;
00048     bool _stdin, _stdout, _stderr;
00049 
00050 public:
00051     LuaFile();
00052     ~LuaFile();
00053 
00054     void close();
00055     bool isOpen() const;
00056     uint32 read(void *buf, uint32 len);
00057     uint32 write(const char *buf, uint32 len);
00058     void seek(int32 pos, int whence = 0);
00059 };
00060 
00061 class SaveGame;
00062 void lua_Save(SaveGame *state);
00063 void lua_Restore(SaveGame *state);
00064 
00065 void lua_removelibslists();
00066 
00067 void lua_open();
00068 void lua_close();
00069 bool lua_isopen();
00070 
00071 lua_Object lua_settagmethod(int32 tag, const char *event); // In: new method
00072 lua_Object lua_gettagmethod(int32 tag, const char *event);
00073 lua_Object lua_seterrormethod();  // In: new method
00074 
00075 int32 lua_newtag();
00076 int32 lua_copytagmethods(int32 tagto, int32 tagfrom);
00077 void lua_settag(int32 tag); // In: object
00078 
00079 void lua_error(const char *s);
00080 int32 lua_dostring(const char *string); // Out: returns
00081 int32 lua_dobuffer(const char *buff, int32 size, const char *name);
00082 int32 lua_callfunction(lua_Object f);
00083 // In: parameters; Out: returns */
00084 
00085 void lua_beginblock();
00086 void lua_endblock();
00087 
00088 lua_Object lua_lua2C(int32 number);
00089 
00090 #define lua_getparam(_)     lua_lua2C(_)
00091 #define lua_getresult(_)    lua_lua2C(_)
00092 
00093 int32 lua_isnil                (lua_Object object);
00094 int32 lua_istable              (lua_Object object);
00095 int32 lua_isuserdata           (lua_Object object);
00096 int32 lua_iscfunction          (lua_Object object);
00097 int32 lua_isnumber             (lua_Object object);
00098 int32 lua_isstring             (lua_Object object);
00099 int32 lua_isfunction           (lua_Object object);
00100 
00101 float lua_getnumber         (lua_Object object);
00102 const char *lua_getstring       (lua_Object object);
00103 lua_CFunction lua_getcfunction  (lua_Object object);
00104 int32 lua_getuserdata       (lua_Object object);
00105 
00106 void lua_pushnil();
00107 void lua_pushnumber(float n);
00108 void lua_pushstring(const char *s);
00109 void lua_pushCclosure(lua_CFunction fn, int32 n);
00110 void lua_pushusertag(int32 id, int32 tag);
00111 void lua_pushobject(lua_Object object);
00112 
00113 lua_Object lua_pop();
00114 lua_Object lua_getglobal(const char *name);
00115 lua_Object lua_rawgetglobal(const char *name);
00116 void lua_setglobal(const char *name); // In: value
00117 void lua_rawsetglobal(const char *name); // In: value
00118 
00119 void lua_settable(); // In: table, index, value
00120 void lua_rawsettable(); // In: table, index, value
00121 lua_Object lua_gettable(); // In: table, index
00122 lua_Object lua_rawgettable(); // In: table, index
00123 
00124 int32 lua_tag(lua_Object object);
00125 
00126 int32 lua_ref(int32 lock); // In: value
00127 lua_Object lua_getref(int32 ref);
00128 void lua_unref(int32 ref);
00129 
00130 lua_Object lua_createtable();
00131 int32 lua_collectgarbage(int32 limit);
00132 
00133 void lua_runtasks();
00134 void current_script();
00135 
00136 /* some useful macros/derived functions */
00137 
00138 #define lua_call(name)      lua_callfunction(lua_getglobal(name))
00139 
00140 #define lua_pushref(ref)    lua_pushobject(lua_getref(ref))
00141 
00142 #define lua_refobject(o,l)  (lua_pushobject(o), lua_ref(l))
00143 
00144 #define lua_register(n, f)  (lua_pushcfunction(f), lua_setglobal(n))
00145 
00146 #define lua_pushuserdata(u) lua_pushusertag(u, 0)
00147 
00148 #define lua_pushcfunction(f)    lua_pushCclosure(f, 0)
00149 
00150 #define lua_clonetag(t)     lua_copytagmethods(lua_newtag(), (t))
00151 
00152 /* ==========================================================================
00153 ** for compatibility with old versions. Avoid using these macros/functions
00154 ** If your program does need any of these, define LUA_COMPAT2_5
00155 */
00156 #define LUA_COMPAT2_5
00157 
00158 #ifdef LUA_COMPAT2_5
00159 
00160 lua_Object lua_setfallback(const char *event, lua_CFunction fallback);
00161 
00162 #define lua_storeglobal     lua_setglobal
00163 #define lua_type            lua_tag
00164 
00165 #define lua_lockobject(o)   lua_refobject(o,1)
00166 #define lua_lock()          lua_ref(1)
00167 #define lua_getlocked       lua_getref
00168 #define lua_pushlocked      lua_pushref
00169 #define lua_unlock          lua_unref
00170 #define lua_pushliteral(o)  lua_pushstring(o)
00171 #define lua_getindexed(o, n) (lua_pushobject(o), lua_pushnumber(n), lua_gettable())
00172 #define lua_getfield(o, f)  (lua_pushobject(o), lua_pushstring(f), lua_gettable())
00173 #define lua_copystring(o)   (strdup(lua_getstring(o)))
00174 #define lua_getsubscript    lua_gettable
00175 #define lua_storesubscript  lua_settable
00176 
00177 #endif
00178 
00179 
00180 /******************************************************************************
00181 * Copyright (c) 1994-1998 TeCGraf, PUC-Rio.  All rights reserved.
00182 *
00183 * Permission is hereby granted, without written agreement and without license
00184 * or royalty fees, to use, copy, modify, and distribute this software and its
00185 * documentation for any purpose, including commercial applications, subject to
00186 * the following conditions:
00187 *
00188 *  - The above copyright notice and this permission notice shall appear in all
00189 *    copies or substantial portions of this software.
00190 *
00191 *  - The origin of this software must not be misrepresented; you must not
00192 *    claim that you wrote the original software. If you use this software in a
00193 *    product, an acknowledgment in the product documentation would be greatly
00194 *    appreciated (but it is not required).
00195 *
00196 *  - Altered source versions must be plainly marked as such, and must not be
00197 *    misrepresented as being the original software.
00198 *
00199 * The authors specifically disclaim any warranties, including, but not limited
00200 * to, the implied warranties of merchantability and fitness for a particular
00201 * purpose.  The software provided hereunder is on an "as is" basis, and the
00202 * authors have no obligation to provide maintenance, support, updates,
00203 * enhancements, or modifications.  In no event shall TeCGraf, PUC-Rio, or the
00204 * authors be held liable to any party for direct, indirect, special,
00205 * incidental, or consequential damages arising out of the use of this software
00206 * and its documentation.
00207 *
00208 * The Lua language and this implementation have been entirely designed and
00209 * written by Waldemar Celes Filho, Roberto Ierusalimschy and
00210 * Luiz Henrique de Figueiredo at TeCGraf, PUC-Rio.
00211 *
00212 * NOTE: This implementation of Lua contains additional code and
00213 * modifications added only for ResidualVM project.
00214 * Look into the source code file "Changelog" for more info.
00215 ******************************************************************************/
00216 
00217 } // end of namespace Grim
00218 
00219 #endif


Generated on Sat Mar 16 2019 05:01:43 for ResidualVM by doxygen 1.7.1
curved edge   curved edge