hedgewars/LuaPas.pas
branchwebgl
changeset 8026 4a4f21070479
parent 7151 ec15d9e1a7e3
child 8847 ff7fbab7cd56
equal deleted inserted replaced
8023:7de85783b823 8026:4a4f21070479
    52 (*
    52 (*
    53 @@ LUA_IDSIZE gives the maximum size for the description of the source
    53 @@ LUA_IDSIZE gives the maximum size for the description of the source
    54 @* of a function in debug information.
    54 @* of a function in debug information.
    55 ** CHANGE it if you want a different size.
    55 ** CHANGE it if you want a different size.
    56 *)
    56 *)
       
    57 
    57 const
    58 const
    58     LUA_IDSIZE = 60;
    59     LUA_IDSIZE = 60;
    59 
    60 
    60 (*
    61 (*
    61 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
    62 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
    62 *)
    63 *)
       
    64 
    63 const
    65 const
    64     LUAL_BUFFERSIZE = 1024;
    66     LUAL_BUFFERSIZE = 1024;
    65 
    67 
    66 (*
    68 (*
    67 @@ LUA_PROMPT is the default prompt used by stand-alone Lua.
    69 @@ LUA_PROMPT is the default prompt used by stand-alone Lua.
    68 @@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
    70 @@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
    69 ** CHANGE them if you want different prompts. (You can also change the
    71 ** CHANGE them if you want different prompts. (You can also change the
    70 ** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
    72 ** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
    71 *)
    73 *)
       
    74 
    72 const
    75 const
    73     LUA_PROMPT  = '> ';
    76     LUA_PROMPT  = '> ';
    74     LUA_PROMPT2 = '>> ';
    77     LUA_PROMPT2 = '>> ';
    75 
    78 
    76 (*
    79 (*
   110 ** Lua - An Extensible Extension Language
   113 ** Lua - An Extensible Extension Language
   111 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
   114 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
   112 ** See Copyright Notice at the end of this file
   115 ** See Copyright Notice at the end of this file
   113 *)
   116 *)
   114 
   117 
       
   118 
   115 const
   119 const
   116     LUA_VERSION     = 'Lua 5.1';
   120     LUA_VERSION     = 'Lua 5.1';
   117     LUA_VERSION_NUM = 501;
   121     LUA_VERSION_NUM = 501;
   118     LUA_COPYRIGHT   = 'Copyright (C) 1994-2006 Tecgraf, PUC-Rio';
   122     LUA_COPYRIGHT   = 'Copyright (C) 1994-2006 Tecgraf, PUC-Rio';
   119     LUA_AUTHORS     = 'R. Ierusalimschy, L. H. de Figueiredo & W. Celes';
   123     LUA_AUTHORS     = 'R. Ierusalimschy, L. H. de Figueiredo & W. Celes';
   129     *)
   133     *)
   130     LUA_REGISTRYINDEX = -10000;
   134     LUA_REGISTRYINDEX = -10000;
   131     LUA_ENVIRONINDEX  = -10001;
   135     LUA_ENVIRONINDEX  = -10001;
   132     LUA_GLOBALSINDEX  = -10002;
   136     LUA_GLOBALSINDEX  = -10002;
   133 
   137 
       
   138    
   134 function lua_upvalueindex(idx : LongInt) : LongInt;   // a marco
   139 function lua_upvalueindex(idx : LongInt) : LongInt;   // a marco
       
   140 
   135 
   141 
   136 const
   142 const
   137    (* thread status; 0 is OK *)
   143    (* thread status; 0 is OK *)
   138     LUA_YIELD_    = 1;     // Note: the ending underscore is needed in Pascal
   144     LUA_YIELD_    = 1;     // Note: the ending underscore is needed in Pascal
   139     LUA_ERRRUN    = 2;
   145     LUA_ERRRUN    = 2;
   140     LUA_ERRSYNTAX = 3;
   146     LUA_ERRSYNTAX = 3;
   141     LUA_ERRMEM    = 4;
   147     LUA_ERRMEM    = 4;
   142     LUA_ERRERR    = 5;
   148     LUA_ERRERR    = 5;
   143 
   149 
       
   150    
   144 type
   151 type
   145    lua_CFunction = function(L : Plua_State) : LongInt; cdecl;
   152    lua_CFunction = function(L : Plua_State) : LongInt; cdecl;
   146 
   153 
   147     (*
   154     (*
   148     ** functions that read/write blocks when loading/dumping Lua chunks
   155     ** functions that read/write blocks when loading/dumping Lua chunks
   152 
   159 
   153   (*
   160   (*
   154   ** prototype for memory-allocation functions
   161   ** prototype for memory-allocation functions
   155   *)
   162   *)
   156   lua_Alloc = function (ud, ptr : Pointer; osize, nsize : size_t) : Pointer; cdecl;
   163   lua_Alloc = function (ud, ptr : Pointer; osize, nsize : size_t) : Pointer; cdecl;
       
   164 
   157 
   165 
   158 const
   166 const
   159     (*
   167     (*
   160     ** basic types
   168     ** basic types
   161     *)
   169     *)
   178     lua_Number = LUA_NUMBER_;
   186     lua_Number = LUA_NUMBER_;
   179 
   187 
   180     (* type for integer functions *)
   188     (* type for integer functions *)
   181     lua_Integer = LUA_INTEGER_;
   189     lua_Integer = LUA_INTEGER_;
   182 
   190 
       
   191    
   183 (*
   192 (*
   184 ** state manipulation
   193 ** state manipulation
   185 *)
   194 *)
   186 function  lua_newstate(f : lua_Alloc; ud : Pointer) : Plua_State;
   195 function  lua_newstate(f : lua_Alloc; ud : Pointer) : Plua_State;
   187     cdecl; external LuaLibName;
   196     cdecl; external LuaLibName;
   238 function lua_isuserdata(L : Plua_State; idx : LongInt) : LongBool;
   247 function lua_isuserdata(L : Plua_State; idx : LongInt) : LongBool;
   239     cdecl; external LuaLibName;
   248     cdecl; external LuaLibName;
   240     
   249     
   241 function lua_type(L : Plua_State; idx : LongInt) : LongInt;
   250 function lua_type(L : Plua_State; idx : LongInt) : LongInt;
   242     cdecl; external LuaLibName;
   251     cdecl; external LuaLibName;
   243     
   252 
   244 function lua_typename(L : Plua_State; tp : LongInt) : PChar;
   253 function lua_typename(L : Plua_State; tp : LongInt) : PChar;
   245     cdecl; external LuaLibName;
   254     cdecl; external LuaLibName;
   246 
       
   247     
   255     
   248 function lua_equal(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
   256 function lua_equal(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
   249     cdecl; external LuaLibName;
   257     cdecl; external LuaLibName;
   250     
   258     
   251 function lua_rawequal(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
   259 function lua_rawequal(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
   261     cdecl; external LuaLibName;
   269     cdecl; external LuaLibName;
   262     
   270     
   263 function lua_toboolean(L : Plua_State; idx : LongInt) : LongBool;
   271 function lua_toboolean(L : Plua_State; idx : LongInt) : LongBool;
   264     cdecl; external LuaLibName;
   272     cdecl; external LuaLibName;
   265     
   273     
   266     
       
   267 function lua_tolstring(L : Plua_State; idx : LongInt; len : Psize_t) : PChar;
   274 function lua_tolstring(L : Plua_State; idx : LongInt; len : Psize_t) : PChar;
   268     cdecl; external LuaLibName;
   275     cdecl; external LuaLibName;
   269     
   276 
   270 function lua_objlen(L : Plua_State; idx : LongInt) : size_t;
   277 function lua_objlen(L : Plua_State; idx : LongInt) : size_t;
   271     cdecl; external LuaLibName;
   278     cdecl; external LuaLibName;
   272     
   279     
   273 function lua_tocfunction(L : Plua_State; idx : LongInt) : lua_CFunction;
   280 function lua_tocfunction(L : Plua_State; idx : LongInt) : lua_CFunction;
   274     cdecl; external LuaLibName;
   281     cdecl; external LuaLibName;
   292 procedure lua_pushnumber(L : Plua_State; n : lua_Number);
   299 procedure lua_pushnumber(L : Plua_State; n : lua_Number);
   293     cdecl; external LuaLibName;
   300     cdecl; external LuaLibName;
   294     
   301     
   295 procedure lua_pushinteger(L : Plua_State; n : lua_Integer);
   302 procedure lua_pushinteger(L : Plua_State; n : lua_Integer);
   296     cdecl; external LuaLibName;
   303     cdecl; external LuaLibName;
   297     
   304 
   298 procedure lua_pushlstring(L : Plua_State; const s : PChar; ls : size_t);
   305 procedure lua_pushlstring(L : Plua_State; const s : PChar; ls : size_t);
   299     cdecl; external LuaLibName;
   306     cdecl; external LuaLibName;
   300     
   307     
   301 procedure lua_pushstring(L : Plua_State; const s : PChar);
   308 procedure lua_pushstring(L : Plua_State; const s : PChar);
   302     cdecl; external LuaLibName;
   309     cdecl; external LuaLibName;
   303     
       
   304     
   310     
   305 function  lua_pushvfstring(L : Plua_State;
   311 function  lua_pushvfstring(L : Plua_State;
   306     const fmt : PChar; argp : Pointer) : PChar;
   312     const fmt : PChar; argp : Pointer) : PChar;
   307     cdecl; external LuaLibName;
   313     cdecl; external LuaLibName;
   308     
   314     
   325 (*
   331 (*
   326 ** get functions (Lua -> stack)
   332 ** get functions (Lua -> stack)
   327 *)
   333 *)
   328 procedure lua_gettable(L : Plua_State ; idx : LongInt);
   334 procedure lua_gettable(L : Plua_State ; idx : LongInt);
   329     cdecl; external LuaLibName;
   335     cdecl; external LuaLibName;
   330     
   336 
   331 procedure lua_getfield(L : Plua_State; idx : LongInt; k : PChar);
   337 procedure lua_getfield(L : Plua_State; idx : LongInt; k : PChar);
   332     cdecl; external LuaLibName;
   338     cdecl; external LuaLibName;
   333     
   339 
   334 procedure lua_rawget(L : Plua_State; idx : LongInt);
   340 procedure lua_rawget(L : Plua_State; idx : LongInt);
   335     cdecl; external LuaLibName;
   341     cdecl; external LuaLibName;
   336     
   342     
   337 procedure lua_rawgeti(L : Plua_State; idx, n : LongInt);
   343 procedure lua_rawgeti(L : Plua_State; idx, n : LongInt);
   338     cdecl; external LuaLibName;
   344     cdecl; external LuaLibName;
   353 (*
   359 (*
   354 ** set functions (stack -> Lua)
   360 ** set functions (stack -> Lua)
   355 *)
   361 *)
   356 procedure lua_settable(L : Plua_State; idx : LongInt);
   362 procedure lua_settable(L : Plua_State; idx : LongInt);
   357     cdecl; external LuaLibName;
   363     cdecl; external LuaLibName;
   358     
   364 
   359 procedure lua_setfield(L : Plua_State; idx : LongInt; const k : PChar);
   365 procedure lua_setfield(L : Plua_State; idx : LongInt; const k : PChar);
   360     cdecl; external LuaLibName;
   366     cdecl; external LuaLibName;
   361     
   367 
   362 procedure lua_rawset(L : Plua_State; idx : LongInt);
   368 procedure lua_rawset(L : Plua_State; idx : LongInt);
   363     cdecl; external LuaLibName;
   369     cdecl; external LuaLibName;
   364     
   370     
   365 procedure lua_rawseti(L : Plua_State; idx , n: LongInt);
   371 procedure lua_rawseti(L : Plua_State; idx , n: LongInt);
   366     cdecl; external LuaLibName;
   372     cdecl; external LuaLibName;
   404     cdecl; external LuaLibName;
   410     cdecl; external LuaLibName;
   405 
   411 
   406 (*
   412 (*
   407 ** garbage-collection functions and options
   413 ** garbage-collection functions and options
   408 *)
   414 *)
       
   415 
   409 const
   416 const
   410     LUA_GCSTOP       = 0;
   417     LUA_GCSTOP       = 0;
   411     LUA_GCRESTART    = 1;
   418     LUA_GCRESTART    = 1;
   412     LUA_GCCOLLECT    = 2;
   419     LUA_GCCOLLECT    = 2;
   413     LUA_GCCOUNT      = 3;
   420     LUA_GCCOUNT      = 3;
   414     LUA_GCCOUNTB     = 4;
   421     LUA_GCCOUNTB     = 4;
   415     LUA_GCSTEP       = 5;
   422     LUA_GCSTEP       = 5;
   416     LUA_GCSETPAUSE   = 6;
   423     LUA_GCSETPAUSE   = 6;
   417     LUA_GCSETSTEPMUL = 7;
   424     LUA_GCSETSTEPMUL = 7;
   418 
   425    
   419 function lua_gc(L : Plua_State; what, data : LongInt) : LongInt;
   426 function lua_gc(L : Plua_State; what, data : LongInt) : LongInt;
   420     cdecl; external LuaLibName;
   427     cdecl; external LuaLibName;
   421 
   428 
   422 (*
   429 (*
   423 ** miscellaneous functions
   430 ** miscellaneous functions