hedgewars/LuaPas.pas
author nemo
Wed, 03 Mar 2010 04:33:49 +0000
changeset 2916 31f8d418ced3
parent 2829 dfaa6f918ad2
child 2920 5cf48744a700
permissions -rw-r--r--
Make barrels a little easier to destroy (60 instead of 75) - still more than 2 shotgun blasts or a grenade, but in range of dynamite or a well-placed cluster
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     1
unit LuaPas;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     2
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     3
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     4
 * A complete Pascal wrapper for Lua 5.1 DLL module.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     5
 *
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     6
 * Created by Geo Massar, 2006
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     7
 * Distributed as free/open source.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     8
 *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     9
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    10
interface
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    11
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    12
{.$DEFINE LUA_GETHOOK}
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    13
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    14
type
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    15
  size_t   = type Cardinal;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    16
  Psize_t  = ^size_t;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    17
  PPointer = ^Pointer;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    18
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    19
  lua_State = record end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    20
  Plua_State = ^lua_State;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    21
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    22
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    23
{$IFDEF UNIX}
2809
b8956af350c1 mac build supports lua
koda
parents: 2799
diff changeset
    24
  {$IFDEF DARWIN}
b8956af350c1 mac build supports lua
koda
parents: 2799
diff changeset
    25
    LuaLibName = 'lua';
b8956af350c1 mac build supports lua
koda
parents: 2799
diff changeset
    26
  {$ELSE}
2829
dfaa6f918ad2 Another solution needs to be found.
nemo
parents: 2822
diff changeset
    27
    LuaLibName = 'lua5.1.so';
2809
b8956af350c1 mac build supports lua
koda
parents: 2799
diff changeset
    28
  {$ENDIF}
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    29
{$ELSE}
2822
0533562bc3a4 Engine:
smxx
parents: 2809
diff changeset
    30
  LuaLibName = 'lua.dll';
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    31
{$ENDIF}
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    32
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    33
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    34
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    35
(*                               luaconfig.h                                 *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    36
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    37
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    38
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    39
** $Id: luaconf.h,v 1.81 2006/02/10 17:44:06 roberto Exp $
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    40
** Configuration file for Lua
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    41
** See Copyright Notice in lua.h
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    42
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    43
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    44
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    45
** {==================================================================
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    46
@@ LUA_NUMBER is the type of numbers in Lua.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    47
** CHANGE the following definitions only if you want to build Lua
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    48
** with a number type different from double. You may also need to
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    49
** change lua_number2int & lua_number2integer.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    50
** ===================================================================
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    51
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    52
type
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    53
  LUA_NUMBER_  = type Double;            // ending underscore is needed in Pascal
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    54
  LUA_INTEGER_ = type LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    55
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    56
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    57
@@ LUA_IDSIZE gives the maximum size for the description of the source
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    58
@* of a function in debug information.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    59
** CHANGE it if you want a different size.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    60
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    61
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    62
  LUA_IDSIZE = 60;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    63
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    64
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    65
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    66
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    67
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    68
  LUAL_BUFFERSIZE = 1024;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    69
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    70
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    71
@@ LUA_PROMPT is the default prompt used by stand-alone Lua.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    72
@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    73
** CHANGE them if you want different prompts. (You can also change the
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    74
** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    75
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    76
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    77
  LUA_PROMPT  = '> ';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    78
  LUA_PROMPT2 = '>> ';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    79
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    80
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    81
@@ lua_readline defines how to show a prompt and then read a line from
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    82
@* the standard input.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    83
@@ lua_saveline defines how to "save" a read line in a "history".
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    84
@@ lua_freeline defines how to free a line read by lua_readline.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    85
** CHANGE them if you want to improve this functionality (e.g., by using
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    86
** GNU readline and history facilities).
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    87
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    88
function  lua_readline(L : Plua_State; var b : PChar; p : PChar): Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    89
procedure lua_saveline(L : Plua_State; idx : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    90
procedure lua_freeline(L : Plua_State; b : PChar);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    91
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    92
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    93
@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    94
@* is, whether we're running lua interactively).
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    95
** CHANGE it if you have a better definition for non-POSIX/non-Windows
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    96
** systems.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    97
*/
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    98
#include <io.h>
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    99
#include <stdio.h>
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   100
#define lua_stdin_is_tty()	_isatty(_fileno(stdin))
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   101
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   102
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   103
  lua_stdin_is_tty = TRUE;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   104
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   105
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   106
(*                                  lua.h                                    *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   107
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   108
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   109
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   110
** $Id: lua.h,v 1.216 2006/01/10 12:50:13 roberto Exp $
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   111
** Lua - An Extensible Extension Language
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   112
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   113
** See Copyright Notice at the end of this file
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   114
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   115
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   116
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   117
  LUA_VERSION     = 'Lua 5.1';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   118
  LUA_VERSION_NUM = 501;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   119
  LUA_COPYRIGHT   = 'Copyright (C) 1994-2006 Tecgraf, PUC-Rio';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   120
  LUA_AUTHORS     = 'R. Ierusalimschy, L. H. de Figueiredo & W. Celes';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   121
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   122
  (* mark for precompiled code (`<esc>Lua') *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   123
  LUA_SIGNATURE = #27'Lua';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   124
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   125
  (* option for multiple returns in `lua_pcall' and `lua_call' *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   126
  LUA_MULTRET = -1;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   127
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   128
  (*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   129
  ** pseudo-indices
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   130
  *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   131
  LUA_REGISTRYINDEX = -10000;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   132
  LUA_ENVIRONINDEX  = -10001;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   133
  LUA_GLOBALSINDEX  = -10002;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   134
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   135
function lua_upvalueindex(idx : LongInt) : LongInt;   // a marco
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   136
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   137
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   138
  (* thread status; 0 is OK *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   139
  LUA_YIELD_    = 1;     // Note: the ending underscore is needed in Pascal
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   140
  LUA_ERRRUN    = 2;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   141
  LUA_ERRSYNTAX = 3;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   142
  LUA_ERRMEM    = 4;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   143
  LUA_ERRERR    = 5;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   144
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   145
type
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   146
  lua_CFunction = function(L : Plua_State) : LongInt; cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   147
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   148
  (*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   149
  ** functions that read/write blocks when loading/dumping Lua chunks
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   150
  *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   151
  lua_Reader = function (L : Plua_State; ud : Pointer;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   152
                         sz : Psize_t) : PChar; cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   153
  lua_Writer = function (L : Plua_State; const p : Pointer; sz : size_t;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   154
                         ud : Pointer) : LongInt; cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   155
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   156
  (*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   157
  ** prototype for memory-allocation functions
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   158
  *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   159
  lua_Alloc = function (ud, ptr : Pointer;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   160
                        osize, nsize : size_t) : Pointer; cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   161
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   162
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   163
  (*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   164
  ** basic types
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   165
  *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   166
  LUA_TNONE          = -1;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   167
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   168
  LUA_TNIL           = 0;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   169
  LUA_TBOOLEAN       = 1;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   170
  LUA_TLIGHTUSERDATA = 2;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   171
  LUA_TNUMBER        = 3;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   172
  LUA_TSTRING        = 4;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   173
  LUA_TTABLE         = 5;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   174
  LUA_TFUNCTION      = 6;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   175
  LUA_TUSERDATA	     = 7;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   176
  LUA_TTHREAD        = 8;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   177
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   178
  (* minimum Lua stack available to a C function *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   179
  LUA_MINSTACK = 20;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   180
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   181
type
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   182
  (* type of numbers in Lua *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   183
  lua_Number = LUA_NUMBER_;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   184
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   185
  (* type for integer functions *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   186
  lua_Integer = LUA_INTEGER_;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   187
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   188
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   189
** state manipulation
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   190
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   191
function  lua_newstate(f : lua_Alloc; ud : Pointer) : Plua_State;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   192
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   193
procedure lua_close(L: Plua_State);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   194
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   195
function  lua_newthread(L : Plua_State) : Plua_State;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   196
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   197
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   198
function  lua_atpanic(L : Plua_State; panicf : lua_CFunction) : lua_CFunction;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   199
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   200
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   201
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   202
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   203
** basic stack manipulation
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   204
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   205
function  lua_gettop(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   206
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   207
procedure lua_settop(L : Plua_State; idx : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   208
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   209
procedure lua_pushvalue(L : Plua_State; idx : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   210
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   211
procedure lua_remove(L : Plua_State; idx : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   212
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   213
procedure lua_insert(L : Plua_State; idx : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   214
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   215
procedure lua_replace(L : Plua_State; idx : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   216
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   217
function  lua_checkstack(L : Plua_State; sz : LongInt) : LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   218
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   219
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   220
procedure lua_xmove(src, dest : Plua_State; n : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   221
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   222
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   223
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   224
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   225
** access functions (stack -> C)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   226
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   227
function lua_isnumber(L : Plua_State; idx : LongInt) : LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   228
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   229
function lua_isstring(L : Plua_State; idx : LongInt) : LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   230
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   231
function lua_iscfunction(L : Plua_State; idx : LongInt) : LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   232
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   233
function lua_isuserdata(L : Plua_State; idx : LongInt) : LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   234
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   235
function lua_type(L : Plua_State; idx : LongInt) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   236
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   237
function lua_typename(L : Plua_State; tp : LongInt) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   238
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   239
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   240
function lua_equal(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   241
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   242
function lua_rawequal(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   243
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   244
function lua_lessthan(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   245
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   246
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   247
function lua_tonumber(L : Plua_State; idx : LongInt) : lua_Number;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   248
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   249
function lua_tointeger(L : Plua_State; idx : LongInt) : lua_Integer;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   250
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   251
function lua_toboolean(L : Plua_State; idx : LongInt) : LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   252
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   253
function lua_tolstring(L : Plua_State; idx : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   254
                       len : Psize_t) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   255
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   256
function lua_objlen(L : Plua_State; idx : LongInt) : size_t;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   257
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   258
function lua_tocfunction(L : Plua_State; idx : LongInt) : lua_CFunction;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   259
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   260
function lua_touserdata(L : Plua_State; idx : LongInt) : Pointer;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   261
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   262
function lua_tothread(L : Plua_State; idx : LongInt) : Plua_State;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   263
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   264
function lua_topointer(L : Plua_State; idx : LongInt) : Pointer;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   265
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   266
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   267
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   268
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   269
** push functions (C -> stack)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   270
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   271
procedure lua_pushnil(L : Plua_State);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   272
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   273
procedure lua_pushnumber(L : Plua_State; n : lua_Number);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   274
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   275
procedure lua_pushinteger(L : Plua_State; n : lua_Integer);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   276
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   277
procedure lua_pushlstring(L : Plua_State; const s : PChar; ls : size_t);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   278
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   279
procedure lua_pushstring(L : Plua_State; const s : PChar);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   280
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   281
function  lua_pushvfstring(L : Plua_State;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   282
                           const fmt : PChar; argp : Pointer) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   283
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   284
function  lua_pushfstring(L : Plua_State; const fmt : PChar) : PChar; varargs;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   285
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   286
procedure lua_pushcclosure(L : Plua_State; fn : lua_CFunction; n : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   287
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   288
procedure lua_pushboolean(L : Plua_State; b : LongBool);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   289
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   290
procedure lua_pushlightuserdata(L : Plua_State; p : Pointer);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   291
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   292
function  lua_pushthread(L : Plua_state) : Cardinal;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   293
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   294
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   295
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   296
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   297
** get functions (Lua -> stack)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   298
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   299
procedure lua_gettable(L : Plua_State ; idx : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   300
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   301
procedure lua_getfield(L : Plua_State; idx : LongInt; k : PChar);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   302
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   303
procedure lua_rawget(L : Plua_State; idx : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   304
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   305
procedure lua_rawgeti(L : Plua_State; idx, n : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   306
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   307
procedure lua_createtable(L : Plua_State; narr, nrec : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   308
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   309
function  lua_newuserdata(L : Plua_State; sz : size_t) : Pointer;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   310
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   311
function  lua_getmetatable(L : Plua_State; objindex : LongInt) : LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   312
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   313
procedure lua_getfenv(L : Plua_State; idx : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   314
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   315
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   316
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   317
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   318
** set functions (stack -> Lua)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   319
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   320
procedure lua_settable(L : Plua_State; idx : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   321
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   322
procedure lua_setfield(L : Plua_State; idx : LongInt; const k : PChar);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   323
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   324
procedure lua_rawset(L : Plua_State; idx : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   325
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   326
procedure lua_rawseti(L : Plua_State; idx , n: LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   327
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   328
function lua_setmetatable(L : Plua_State; objindex : LongInt): LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   329
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   330
function lua_setfenv(L : Plua_State; idx : LongInt): LongBool;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   331
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   332
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   333
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   334
** `load' and `call' functions (load and run Lua code)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   335
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   336
procedure lua_call(L : Plua_State; nargs, nresults : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   337
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   338
function  lua_pcall(L : Plua_State;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   339
                    nargs, nresults, errfunc : LongInt) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   340
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   341
function  lua_cpcall(L : Plua_State;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   342
                     func : lua_CFunction; ud : Pointer) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   343
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   344
function  lua_load(L : Plua_State; reader : lua_Reader;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   345
                   dt : Pointer; const chunkname : PChar) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   346
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   347
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   348
function lua_dump(L : Plua_State; writer : lua_Writer; data: Pointer) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   349
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   350
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   351
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   352
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   353
** coroutine functions
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   354
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   355
function lua_yield(L : Plua_State; nresults : LongInt) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   356
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   357
function lua_resume(L : Plua_State; narg : LongInt) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   358
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   359
function lua_status(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   360
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   361
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   362
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   363
** garbage-collection functions and options
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   364
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   365
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   366
  LUA_GCSTOP       = 0;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   367
  LUA_GCRESTART    = 1;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   368
  LUA_GCCOLLECT    = 2;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   369
  LUA_GCCOUNT      = 3;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   370
  LUA_GCCOUNTB	   = 4;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   371
  LUA_GCSTEP       = 5;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   372
  LUA_GCSETPAUSE   = 6;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   373
  LUA_GCSETSTEPMUL = 7;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   374
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   375
function lua_gc(L : Plua_State; what, data : LongInt) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   376
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   377
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   378
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   379
** miscellaneous functions
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   380
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   381
function lua_error(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   382
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   383
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   384
function lua_next(L : Plua_State; idx : LongInt) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   385
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   386
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   387
procedure lua_concat(L : Plua_State; n : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   388
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   389
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   390
function  lua_getallocf(L : Plua_State; ud : PPointer) : lua_Alloc;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   391
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   392
procedure lua_setallocf(L : Plua_State; f : lua_Alloc; ud : Pointer);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   393
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   394
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   395
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   396
** ===============================================================
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   397
** some useful macros
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   398
** ===============================================================
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   399
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   400
procedure lua_pop(L : Plua_State; n : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   401
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   402
procedure lua_newtable(L : Plua_State);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   403
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   404
procedure lua_register(L : Plua_State; n : PChar; f : lua_CFunction);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   405
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   406
procedure lua_pushcfunction(L : Plua_State; f : lua_CFunction);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   407
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   408
function  lua_strlen(L : Plua_State; idx : LongInt) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   409
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   410
function lua_isfunction(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   411
function lua_istable(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   412
function lua_islightuserdata(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   413
function lua_isnil(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   414
function lua_isboolean(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   415
function lua_isthread(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   416
function lua_isnone(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   417
function lua_isnoneornil(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   418
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   419
procedure lua_pushliteral(L : Plua_State; s : PChar);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   420
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   421
procedure lua_setglobal(L : Plua_State; s : PChar);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   422
procedure lua_getglobal(L : Plua_State; s : PChar);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   423
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   424
function lua_tostring(L : Plua_State; idx : LongInt) : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   425
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   426
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   427
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   428
** compatibility macros and functions
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   429
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   430
function lua_open : Plua_State;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   431
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   432
procedure lua_getregistry(L : Plua_State);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   433
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   434
function lua_getgccount(L : Plua_State) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   435
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   436
type
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   437
  lua_Chuckreader = type lua_Reader;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   438
  lua_Chuckwriter = type lua_Writer;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   439
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   440
(* ====================================================================== *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   441
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   442
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   443
** {======================================================================
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   444
** Debug API
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   445
** =======================================================================
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   446
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   447
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   448
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   449
** Event codes
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   450
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   451
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   452
  LUA_HOOKCALL    = 0;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   453
  LUA_HOOKRET     = 1;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   454
  LUA_HOOKLINE    = 2;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   455
  LUA_HOOKCOUNT   = 3;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   456
  LUA_HOOKTAILRET = 4;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   457
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   458
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   459
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   460
** Event masks
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   461
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   462
  LUA_MASKCALL  = 1 shl LUA_HOOKCALL;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   463
  LUA_MASKRET   = 1 shl LUA_HOOKRET;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   464
  LUA_MASKLINE  = 1 shl LUA_HOOKLINE;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   465
  LUA_MASKCOUNT = 1 shl LUA_HOOKCOUNT;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   466
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   467
type
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   468
  lua_Debug = packed record
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   469
    event : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   470
    name : PChar;          (* (n) *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   471
    namewhat : PChar;      (* (n) `global', `local', `field', `method' *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   472
    what : PChar;          (* (S) `Lua', `C', `main', `tail' *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   473
    source : PChar;        (* (S) *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   474
    currentline : LongInt; (* (l) *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   475
    nups : LongInt;        (* (u) number of upvalues *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   476
    linedefined : LongInt; (* (S) *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   477
    short_src : array [0..LUA_IDSIZE-1] of Char; (* (S) *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   478
    (* private part *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   479
    i_ci : LongInt;        (* active function *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   480
  end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   481
  Plua_Debug = ^lua_Debug;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   482
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   483
  (* Functions to be called by the debuger in specific events *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   484
  lua_Hook = procedure (L : Plua_State; ar : Plua_Debug); cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   485
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   486
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   487
function lua_getstack(L : Plua_State; level : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   488
                      ar : Plua_Debug) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   489
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   490
function lua_getinfo(L : Plua_State; const what : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   491
                     ar: Plua_Debug): LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   492
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   493
function lua_getlocal(L : Plua_State;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   494
                      ar : Plua_Debug; n : LongInt) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   495
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   496
function lua_setlocal(L : Plua_State;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   497
                      ar : Plua_Debug; n : LongInt) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   498
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   499
function lua_getupvalue(L : Plua_State; funcindex, n : LongInt) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   500
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   501
function lua_setupvalue(L : Plua_State; funcindex, n : LongInt) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   502
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   503
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   504
function lua_sethook(L : Plua_State; func : lua_Hook;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   505
                     mask, count: LongInt): LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   506
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   507
{$IFDEF LUA_GETHOOK}
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   508
function lua_gethook(L : Plua_State) : lua_Hook;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   509
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   510
{$ENDIF}
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   511
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   512
function lua_gethookmask(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   513
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   514
function lua_gethookcount(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   515
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   516
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   517
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   518
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   519
(*                                  lualib.h                                 *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   520
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   521
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   522
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   523
** $Id: lualib.h,v 1.36 2005/12/27 17:12:00 roberto Exp $
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   524
** Lua standard libraries
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   525
** See Copyright Notice at the end of this file
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   526
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   527
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   528
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   529
  (* Key to file-handle type *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   530
  LUA_FILEHANDLE  = 'FILE*';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   531
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   532
  LUA_COLIBNAME   = 'coroutine';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   533
  LUA_TABLIBNAME  = 'table';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   534
  LUA_IOLIBNAME   = 'io';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   535
  LUA_OSLIBNAME   = 'os';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   536
  LUA_STRLIBNAME  = 'string';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   537
  LUA_MATHLIBNAME = 'math';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   538
  LUA_DBLIBNAME   = 'debug';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   539
  LUA_LOADLIBNAME = 'package';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   540
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   541
function luaopen_base(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   542
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   543
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   544
function luaopen_table(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   545
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   546
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   547
function luaopen_io(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   548
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   549
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   550
function luaopen_os(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   551
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   552
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   553
function luaopen_string(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   554
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   555
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   556
function luaopen_math(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   557
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   558
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   559
function luaopen_debug(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   560
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   561
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   562
function luaopen_package(L : Plua_State) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   563
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   564
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   565
procedure luaL_openlibs(L : Plua_State);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   566
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   567
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   568
procedure lua_assert(x : Boolean);    // a macro
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   569
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   570
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   571
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   572
(*                                  lauxlib.h                                *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   573
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   574
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   575
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   576
** $Id: lauxlib.h,v 1.87 2005/12/29 15:32:11 roberto Exp $
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   577
** Auxiliary functions for building Lua libraries
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   578
** See Copyright Notice at the end of this file.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   579
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   580
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   581
// not compatibility with the behavior of setn/getn in Lua 5.0
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   582
function  luaL_getn(L : Plua_State; idx : LongInt) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   583
procedure luaL_setn(L : Plua_State; i, j : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   584
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   585
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   586
  LUA_ERRFILE = LUA_ERRERR + 1;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   587
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   588
type
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   589
  luaL_Reg = packed record
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   590
    name : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   591
    func : lua_CFunction;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   592
  end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   593
  PluaL_Reg = ^luaL_Reg;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   594
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   595
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   596
procedure luaL_openlib(L : Plua_State; const libname : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   597
                       const lr : PluaL_Reg; nup : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   598
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   599
procedure luaL_register(L : Plua_State; const libname : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   600
                       const lr : PluaL_Reg);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   601
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   602
function luaL_getmetafield(L : Plua_State; obj : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   603
                           const e : PChar) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   604
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   605
function luaL_callmeta(L : Plua_State; obj : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   606
                       const e : PChar) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   607
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   608
function luaL_typerror(L : Plua_State; narg : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   609
                       const tname : PChar) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   610
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   611
function luaL_argerror(L : Plua_State; numarg : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   612
                       const extramsg : PChar) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   613
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   614
function luaL_checklstring(L : Plua_State; numArg : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   615
                           ls : Psize_t) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   616
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   617
function luaL_optlstring(L : Plua_State; numArg : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   618
                         const def: PChar; ls: Psize_t) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   619
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   620
function luaL_checknumber(L : Plua_State; numArg : LongInt) : lua_Number;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   621
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   622
function luaL_optnumber(L : Plua_State; nArg : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   623
                        def : lua_Number) : lua_Number;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   624
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   625
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   626
function luaL_checkinteger(L : Plua_State; numArg : LongInt) : lua_Integer;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   627
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   628
function luaL_optinteger(L : Plua_State; nArg : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   629
                        def : lua_Integer) : lua_Integer;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   630
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   631
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   632
procedure luaL_checkstack(L : Plua_State; sz : LongInt; const msg : PChar);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   633
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   634
procedure luaL_checktype(L : Plua_State; narg, t : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   635
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   636
procedure luaL_checkany(L : Plua_State; narg : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   637
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   638
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   639
function luaL_newmetatable(L : Plua_State; const tname : PChar) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   640
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   641
function luaL_checkudata(L : Plua_State; ud : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   642
                         const tname : PChar) : Pointer;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   643
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   644
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   645
procedure luaL_where(L : Plua_State; lvl : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   646
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   647
function  luaL_error(L : Plua_State; const fmt : PChar) : LongInt; varargs;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   648
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   649
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   650
function luaL_checkoption(L : Plua_State; narg : LongInt; const def : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   651
                          const lst : array of PChar) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   652
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   653
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   654
function  luaL_ref(L : Plua_State; t : LongInt) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   655
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   656
procedure luaL_unref(L : Plua_State; t, ref : LongInt);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   657
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   658
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   659
function luaL_loadfile(L : Plua_State; const filename : PChar) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   660
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   661
function luaL_loadbuffer(L : Plua_State; const buff : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   662
                         sz : size_t; const name: PChar) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   663
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   664
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   665
function luaL_loadstring(L : Plua_State; const s : Pchar) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   666
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   667
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   668
function luaL_newstate : Plua_State;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   669
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   670
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   671
function luaL_gsub(L : Plua_State; const s, p, r : PChar) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   672
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   673
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   674
function luaL_findtable(L : Plua_State; idx : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   675
                        const fname : PChar; szhint : LongInt) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   676
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   677
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   678
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   679
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   680
** ===============================================================
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   681
** some useful macros
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   682
** ===============================================================
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   683
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   684
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   685
function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   686
                       extramsg : PChar): LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   687
function luaL_checkstring(L : Plua_State; n : LongInt) : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   688
function luaL_optstring(L : Plua_State; n : LongInt; d : PChar) : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   689
function luaL_checkint(L : Plua_State; n : LongInt) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   690
function luaL_optint(L : Plua_State; n, d : LongInt): LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   691
function luaL_checklong(L : Plua_State; n : LongInt) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   692
function luaL_optlong(L : Plua_State; n : LongInt; d : LongInt) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   693
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   694
function luaL_typename(L : Plua_State; idx : LongInt) : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   695
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   696
function luaL_dofile(L : Plua_State; fn : PChar) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   697
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   698
function luaL_dostring(L : Plua_State; s : PChar) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   699
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   700
procedure luaL_getmetatable(L : Plua_State; n : PChar);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   701
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   702
(* not implemented yet
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   703
#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   704
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   705
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   706
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   707
** {======================================================
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   708
** Generic Buffer manipulation
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   709
** =======================================================
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   710
*)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   711
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   712
type
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   713
  luaL_Buffer = packed record
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   714
    p : PChar;       (* current position in buffer *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   715
    lvl : LongInt;   (* number of strings in the stack (level) *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   716
    L : Plua_State;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   717
    buffer : array [0..LUAL_BUFFERSIZE-1] of Char;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   718
  end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   719
  PluaL_Buffer = ^luaL_Buffer;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   720
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   721
procedure luaL_addchar(B : PluaL_Buffer; c : Char);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   722
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   723
(* compatibility only *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   724
procedure luaL_putchar(B : PluaL_Buffer; c : Char);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   725
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   726
procedure luaL_addsize(B : PluaL_Buffer; n : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   727
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   728
procedure luaL_buffinit(L : Plua_State; B : PluaL_Buffer);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   729
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   730
function  luaL_prepbuffer(B : PluaL_Buffer) : PChar;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   731
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   732
procedure luaL_addlstring(B : PluaL_Buffer; const s : PChar; ls : size_t);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   733
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   734
procedure luaL_addstring(B : PluaL_Buffer; const s : PChar);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   735
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   736
procedure luaL_addvalue(B : PluaL_Buffer);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   737
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   738
procedure luaL_pushresult(B : PluaL_Buffer);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2786
diff changeset
   739
  cdecl; external LuaLibName;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   740
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   741
(* ====================================================== *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   742
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   743
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   744
(* compatibility with ref system *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   745
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   746
(* pre-defined references *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   747
const
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   748
  LUA_NOREF  = -2;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   749
  LUA_REFNIL = -1;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   750
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   751
function lua_ref(L : Plua_State; lock : Boolean) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   752
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   753
procedure lua_unref(L : Plua_State; ref : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   754
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   755
procedure lua_getref(L : Plua_State; ref : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   756
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   757
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   758
(******************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   759
(******************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   760
(******************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   761
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   762
implementation
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   763
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   764
uses
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   765
  SysUtils;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   766
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   767
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   768
(*                            luaconfig.h                                    *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   769
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   770
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   771
function  lua_readline(L : Plua_State; var b : PChar; p : PChar): Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   772
var
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   773
  s : AnsiString;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   774
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   775
  Write(p);                        // show prompt
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   776
  ReadLn(s);                       // get line
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   777
  b := PChar(s);                   //   and return it
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   778
  lua_readline := (b[0] <> #4);          // test for ctrl-D
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   779
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   780
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   781
procedure lua_saveline(L : Plua_State; idx : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   782
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   783
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   784
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   785
procedure lua_freeline(L : Plua_State; b : PChar);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   786
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   787
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   788
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   789
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   790
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   791
(*                                  lua.h                                    *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   792
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   793
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   794
function lua_upvalueindex(idx : LongInt) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   795
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   796
  lua_upvalueindex := LUA_GLOBALSINDEX - idx;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   797
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   798
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   799
procedure lua_pop(L : Plua_State; n : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   800
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   801
  lua_settop(L, -n - 1);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   802
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   803
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   804
procedure lua_newtable(L : Plua_State);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   805
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   806
  lua_createtable(L, 0, 0);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   807
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   808
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   809
procedure lua_register(L : Plua_State; n : PChar; f : lua_CFunction);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   810
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   811
  lua_pushcfunction(L, f);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   812
  lua_setglobal(L, n);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   813
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   814
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   815
procedure lua_pushcfunction(L : Plua_State; f : lua_CFunction);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   816
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   817
  lua_pushcclosure(L, f, 0);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   818
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   819
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   820
function  lua_strlen(L : Plua_State; idx : LongInt) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   821
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   822
  lua_strlen := lua_objlen(L, idx);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   823
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   824
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   825
function lua_isfunction(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   826
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   827
  lua_isfunction := lua_type(L, n) = LUA_TFUNCTION;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   828
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   829
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   830
function lua_istable(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   831
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   832
  lua_istable := lua_type(L, n) = LUA_TTABLE;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   833
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   834
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   835
function lua_islightuserdata(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   836
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   837
  lua_islightuserdata := lua_type(L, n) = LUA_TLIGHTUSERDATA;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   838
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   839
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   840
function lua_isnil(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   841
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   842
  lua_isnil := lua_type(L, n) = LUA_TNIL;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   843
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   844
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   845
function lua_isboolean(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   846
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   847
  lua_isboolean := lua_type(L, n) = LUA_TBOOLEAN;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   848
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   849
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   850
function lua_isthread(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   851
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   852
  lua_isthread := lua_type(L, n) = LUA_TTHREAD;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   853
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   854
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   855
function lua_isnone(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   856
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   857
  lua_isnone := lua_type(L, n) = LUA_TNONE;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   858
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   859
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   860
function lua_isnoneornil(L : Plua_State; n : LongInt) : Boolean;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   861
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   862
  lua_isnoneornil := lua_type(L, n) <= 0;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   863
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   864
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   865
procedure lua_pushliteral(L : Plua_State; s : PChar);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   866
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   867
  lua_pushlstring(L, s, StrLen(s));
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   868
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   869
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   870
procedure lua_setglobal(L : Plua_State; s : PChar);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   871
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   872
  lua_setfield(L, LUA_GLOBALSINDEX, s);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   873
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   874
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   875
procedure lua_getglobal(L: Plua_State; s: PChar);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   876
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   877
  lua_getfield(L, LUA_GLOBALSINDEX, s);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   878
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   879
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   880
function lua_tostring(L : Plua_State; idx : LongInt) : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   881
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   882
  lua_tostring := lua_tolstring(L, idx, nil);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   883
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   884
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   885
function lua_open : Plua_State;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   886
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   887
  lua_open := luaL_newstate;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   888
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   889
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   890
procedure lua_getregistry(L : Plua_State);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   891
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   892
  lua_pushvalue(L, LUA_REGISTRYINDEX);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   893
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   894
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   895
function lua_getgccount(L : Plua_State) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   896
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   897
  lua_getgccount := lua_gc(L, LUA_GCCOUNT, 0);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   898
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   899
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   900
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   901
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   902
(*                                  lualib.h                                 *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   903
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   904
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   905
procedure lua_assert(x : Boolean);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   906
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   907
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   908
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   909
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   910
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   911
(*                                  lauxlib.h    n                           *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   912
(*****************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   913
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   914
function luaL_getn(L : Plua_State; idx : LongInt) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   915
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   916
  luaL_getn := lua_objlen(L, idx);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   917
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   918
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   919
procedure luaL_setn(L : plua_State; i, j : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   920
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   921
  (* no op *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   922
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   923
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   924
function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   925
                       extramsg : PChar): LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   926
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   927
  if not cond then
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   928
    luaL_argcheck := luaL_argerror(L, numarg, extramsg)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   929
  else
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   930
    luaL_argcheck := 0;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   931
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   932
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   933
function luaL_checkstring(L : Plua_State; n : LongInt) : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   934
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   935
  luaL_checkstring := luaL_checklstring(L, n, nil);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   936
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   937
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   938
function luaL_optstring(L : Plua_State; n : LongInt; d : PChar) : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   939
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   940
  luaL_optstring := luaL_optlstring(L, n, d, nil);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   941
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   942
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   943
function luaL_checkint(L : Plua_State; n : LongInt) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   944
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   945
  luaL_checkint := luaL_checkinteger(L, n);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   946
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   947
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   948
function luaL_optint(L : Plua_State; n, d : LongInt): LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   949
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   950
  luaL_optint := luaL_optinteger(L, n, d);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   951
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   952
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   953
function luaL_checklong(L : Plua_State; n : LongInt) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   954
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   955
  luaL_checklong := luaL_checkinteger(L, n);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   956
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   957
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   958
function luaL_optlong(L : Plua_State; n : LongInt; d : LongInt) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   959
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   960
  luaL_optlong := luaL_optinteger(L, n, d);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   961
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   962
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   963
function luaL_typename(L : Plua_State; idx : LongInt) : PChar;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   964
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   965
  luaL_typename := lua_typename( L, lua_type(L, idx) );
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   966
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   967
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   968
function luaL_dofile(L : Plua_State; fn : PChar) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   969
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   970
  luaL_dofile := luaL_loadfile(L, fn);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   971
  if luaL_dofile = 0 then
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   972
    luaL_dofile := lua_pcall(L, 0, 0, 0);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   973
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   974
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   975
function luaL_dostring(L : Plua_State; s : PChar) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   976
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   977
  luaL_dostring := luaL_loadstring(L, s);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   978
  if luaL_dostring = 0 then
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   979
    luaL_dostring := lua_pcall(L, 0, 0, 0);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   980
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   981
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   982
procedure luaL_getmetatable(L : Plua_State; n : PChar);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   983
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   984
  lua_getfield(L, LUA_REGISTRYINDEX, n);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   985
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   986
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   987
procedure luaL_addchar(B : PluaL_Buffer; c : Char);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   988
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   989
  if not(B^.p < B^.buffer + LUAL_BUFFERSIZE) then
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   990
    luaL_prepbuffer(B);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   991
  B^.p^ := c;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   992
  Inc(B^.p);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   993
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   994
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   995
procedure luaL_putchar(B : PluaL_Buffer; c : Char);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   996
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   997
  luaL_addchar(B, c);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   998
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   999
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1000
procedure luaL_addsize(B : PluaL_Buffer; n : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1001
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1002
  Inc(B^.p, n);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1003
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1004
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1005
function lua_ref(L : Plua_State; lock : Boolean) : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1006
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1007
  if lock then
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1008
    lua_ref := luaL_ref(L, LUA_REGISTRYINDEX)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1009
  else begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1010
    lua_pushstring(L, 'unlocked references are obsolete');
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1011
    lua_error(L);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1012
    lua_ref := 0;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1013
  end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1014
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1015
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1016
procedure lua_unref(L : Plua_State; ref : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1017
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1018
  luaL_unref(L, LUA_REGISTRYINDEX, ref);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1019
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1020
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1021
procedure lua_getref(L : Plua_State; ref : LongInt);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1022
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1023
  lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1024
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1025
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1026
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1027
(******************************************************************************
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1028
* Original copyright for the lua source and headers:
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1029
*  1994-2004 Tecgraf, PUC-Rio.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1030
*  www.lua.org.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1031
*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1032
*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1033
* Permission is hereby granted, free of charge, to any person obtaining
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1034
* a copy of this software and associated documentation files (the
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1035
* "Software"), to deal in the Software without restriction, including
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1036
* without limitation the rights to use, copy, modify, merge, publish,
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1037
* distribute, sublicense, and/or sell copies of the Software, and to
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1038
* permit persons to whom the Software is furnished to do so, subject to
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1039
* the following conditions:
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1040
*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1041
* The above copyright notice and this permission notice shall be
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1042
* included in all copies or substantial portions of the Software.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1043
*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1044
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1045
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1046
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1047
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1048
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1049
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1050
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1051
******************************************************************************)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1052
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1053
end.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
  1054