1with Interfaces.C; use Interfaces.C;
2with System;
3
4package Lua is
5
6   type Lua_Return_Code is
7     (LUA_OK,
8      LUA_YIELD,
9      LUA_ERRRUN,
10      LUA_ERRSYNTAX,
11      LUA_ERRMEM,
12      LUA_ERRGCMM,
13      LUA_ERRERR,
14      LUA_ERRFILE);
15   --  Status types
16
17   type Lua_Type is
18     (LUA_TNONE,
19      LUA_TNIL,
20      LUA_TBOOLEAN,
21      LUA_TLIGHTUSERDATA,
22      LUA_TNUMBER,
23      LUA_TSTRING,
24      LUA_TTABLE,
25      LUA_TFUNCTION,
26      LUA_TUSERDATA,
27      LUA_TTHREAD);
28   --  Lua types
29
30   type Lua_State is new System.Address;
31   --  Lua state is the structure containing the state of the interpreter.
32
33   type Lua_User_Data is new System.Address;
34   type Lua_Light_User_Data is new System.Address;
35
36   type Lua_Function is access function (State : Lua_State) return Integer;
37
38   subtype Lua_Integer is ptrdiff_t;
39   subtype Lua_Unsigned is unsigned;
40   subtype Lua_Float is Long_Float;
41   subtype Lua_Index is Integer;
42
43   Lua_Type_Error     : exception;
44   Lua_Override_Error : exception;
45   Lua_Error          : exception;
46
47   ---------------------
48   -- State Functions --
49   ---------------------
50
51   function New_State return Lua_State;
52   --  Create a new state using the default memory allocator. See Lua.Advanced
53   --  in case you want to use custom allocators.
54
55   procedure Close (State : Lua_State);
56   --  Destroys all objects in the given Lua state (calling the corresponding
57   --  garbage - collection metamethods, if any) and frees all dynamic memory
58   --  used by this state. On several platforms, you may not need to call this
59   --  function, because all resources are naturally released when the host
60   --  program ends. On the other hand, long - running programs that create
61   --  multiple states, such as daemons or web servers, might need to close
62   --  states as soon as they are not needed.
63
64   ---------------------
65   --  Load functions --
66   ---------------------
67
68   function Load_File
69     (State    : Lua_State;
70      Filename : String;
71      Mode     : String := "")
72      return Lua_Return_Code;
73   --  Loads a file as a Lua chunk. This function uses Load to load the
74   --  chunk in the file named filename. If filename is NULL, then it loads
75   --  from the standard input. The first line in the file is ignored if
76   --  it starts with a #.
77   --
78   --  The string mode works as in function Load.
79   --
80   --  This function returns the same results as Load, but it has an extra
81   --  error code LUA_ERRFILE if it cannot open / read the file or the file
82   --  has a wrong mode.
83   --
84   --  As lua_load, this function only loads the chunk; it does not run it.
85
86   procedure Load_File
87     (State    : Lua_State;
88      Filename : String;
89      Mode     : String := "");
90   --  Same as previous function except that Lua_Error exception is raised in
91   --  LUA_OK is not returned.
92
93   procedure Load_String
94     (State : Lua_State;
95      Str   : String);
96   --  Load a string and raise Lua_Error in case of error
97
98   procedure Open_Libs (State : Lua_State);
99   --  Opens all standard Lua libraries into the given state.
100
101   ----------------------
102   --  Stack Functions --
103   ----------------------
104
105   function Get_Top (State : Lua_State) return Lua_Index;
106   --  Returns the index of the top element in the stack. Because indices start
107   --  at 1, this result is equal to the number of elements in the stack (and
108   --  so 0 means an empty stack).
109
110   procedure Set_Top
111     (State : Lua_State;
112      Index : Lua_Index);
113   --  Accepts any index, or 0, and sets the stack top to this index. If the
114   --  new top is larger than the old one, then the new elements are filled
115   --  with nil. If index is 0, then all stack elements are removed.
116
117   function Check_Stack (State : Lua_State; N : Integer) return Boolean;
118   --  Ensures that there are at least extra free stack slots in the stack. It
119   --  returns False if it cannot fulfill the request, because it would cause
120   --  the stack to be larger than a fixed maximum size (typically at least a
121   --  few thousand elements) or because it cannot allocate memory for the new
122   --  stack size. This function never shrinks the stack; if the stack is
123   --  already larger than the new size, it is left unchanged.
124
125   procedure Pop
126     (State : Lua_State;
127      N     : Integer := 1);
128   --  Pops n elements from the stack.
129
130   procedure Push_Value (State : Lua_State; Index : Lua_Index);
131   --  Pushes a copy of the element at the given index onto the stack.
132
133   procedure Remove (State : Lua_State; Index : Lua_Index);
134   --  Removes the element at the given valid index, shifting down the elements
135   --  above this index to fill the gap. This function cannot be called with a
136   --  pseudo - index, because a pseudo - index is not an actual stack
137   --  position.
138
139   procedure Insert (State : Lua_State; Index : Lua_Index);
140   --  Moves the top element into the given valid index, shifting up the
141   --  elements above this index to open space. This function cannot be called
142   --  with a pseudo - index, because a pseudo - index is not an actual stack
143   --  position.
144
145   procedure Replace (State : Lua_State; Index : Lua_Index);
146   --  Moves the top element into the given valid index without shifting any
147   --  element (therefore replacing the value at the given index), and then
148   --  pops the top element.
149
150   procedure Copy
151     (State : Lua_State;
152      From  : Integer;
153      To    : Integer);
154   --  Moves the element at index from into the valid index to without
155   --  shifting any element (therefore replacing the value at that position).
156
157   function Absolute_Index
158     (State : Lua_State;
159      Index : Lua_Index)
160      return Lua_Index;
161   --  Converts the acceptable index idx into an absolute index (that is, one
162   --  that does not depend on the stack top).
163
164   --------------------------
165   -- Convertion Functions --
166   --------------------------
167
168   --  The following functions read objects from the Lua stack and return their
169   --  Ada corresponding value.
170
171   function To_Ada
172     (State   : Lua_State;
173      Index   : Lua_Index)
174      return Lua_Float;
175   --  Converts the Lua value at the given index to the Ada type Lua_Float
176   --  The Lua value must be a number or a string convertible to a number
177   --  otherwise, raise Lua_Type_Error.
178
179   function To_Ada
180     (State   : Lua_State;
181      Index   : Lua_Index)
182      return Lua_Integer;
183   --  Converts the Lua value at the given index to the Ada type Lua_Integer
184   --  The Lua value must be a number or a string convertible to a number
185   --  otherwise, raise Lua_Type_Error.
186
187   function To_Ada
188     (State  : Lua_State;
189      Index  : Lua_Index)
190      return Lua_Unsigned;
191   --  Converts the Lua value at the given index to the Ada type Lua_Unsigned
192   --  The Lua value must be a number or a string convertible to a number
193   --  otherwise, raise Lua_Type_Error.
194
195   function To_Ada
196     (State : Lua_State;
197      Index : Lua_Index)
198      return Boolean;
199   --  Converts the Lua value at the given index to a boolean value.
200   --  Like all tests in Lua, To_Boolean returns true for any Lua value
201   --  different from false and nil; otherwise it returns false. (If you want
202   --  to accept only actual boolean values, use Is_Boolean to test the
203   --  value's type.)
204
205   function To_Ada
206     (State : Lua_State;
207      Index : Lua_Index)
208      return Lua_Function;
209   --  Converts a value at the given index to a C function. That value must be
210   --  a C function; otherwise, returns NULL.
211
212   function To_Ada
213     (State : Lua_State;
214      Index : Lua_Index)
215      return Lua_User_Data;
216   --  If the value at the given index is a full userdata, returns its block
217   --  address. If the value is a light userdata, returns its pointer.
218   --  Otherwise, returns NULL.
219
220   function To_Ada
221     (State : Lua_State;
222      Index : Lua_Index)
223      return Lua_State;
224   --  Converts the value at the given index to a Lua thread (represented as
225   --  Lua_State). This value must be a thread; otherwise, the function
226   --  returns NULL.
227
228   function To_Ada
229     (State : Lua_State;
230      Index : Lua_Index)
231      return String;
232   --  Converts the Lua value at the given index to a Ada string. The Lua value
233   --  must be a string or a number; otherwise, the function raise
234   --  Lua_Type_Error. If the value is a number, then lua_tolstring also
235   --  changes the actual value in the stack to a string. (This change
236   --  confuses lua_next when lua_tolstring is applied to keys during a table
237   --  traversal.)
238
239   --------------------
240   -- Push Functions --
241   --------------------
242
243   procedure Push (State : Lua_State);
244   --  Pushes a nil value onto the stack.
245
246   procedure Push (State : Lua_State; Data : Lua_Float);
247   --  Pushes a lua float onto the stack.
248
249   procedure Push (State : Lua_State; Data : Lua_Integer);
250   --  Pushes a number with value n onto the stack.
251
252   procedure Push (State : Lua_State; Data : Lua_Unsigned);
253   --  Pushes a number with value n onto the stack.
254
255   procedure Push (State : Lua_State; Data : String);
256   --  Push a string on the stack
257
258   procedure Push_Closure
259     (State : Lua_State;
260      Fun   : Lua_Function;
261      Closure_Size : Integer := 0);
262
263   --  Pushes a new C closure onto the stack.
264   --
265   --  When a C function is created, it is possible to associate some values
266   --  with it, thus creating a C closure (see �4.4); these values are then
267   --  accessible to the function whenever it is called. To associate values
268   --  with a C function, first these values should be pushed onto the stack
269   --  (when there are multiple values, the first value is pushed first). Then
270   --  lua_pushcclosure is called to create and push the C function onto the
271   --  stack, with the argument n telling how many values should be associated
272   --  with the function. lua_pushcclosure also pops these values from the
273   --  stack.
274
275   --  The maximum value for n is 255.
276
277   --  When n is zero, this function creates a light C function, which is just
278   --  a pointer to the C function. In that case, it never throws a memory
279   --  error.
280
281   procedure Push (State : Lua_State; Data : Boolean);
282   --  Pushes a boolean value with value b onto the stack.
283
284   procedure Push (State : Lua_State; Data : Lua_Light_User_Data);
285   --  Pushes a light userdata onto the stack. Userdata represent C values in
286   --  Lua. A light userdata represents a pointer, a void * . It is a value
287   --  (like a number) : you do not create it, it has no individual metatable,
288   --  and it is not collected (as it was never created). A light userdata is
289   --  equal to "any" light userdata with the same C address.
290
291   --------------------------
292   -- Type Check Functions --
293   --------------------------
294
295   function Is_Number (State : Lua_State; Index : Lua_Index) return Boolean;
296   --  Returns 1 if the value at the given index is a number or a string
297   --  convertible to a number, and 0 otherwise.
298
299   function Is_String (State : Lua_State; Index : Lua_Index) return Boolean;
300   --  Returns 1 if the value at the given index is a string or a number
301   --  (which is always convertible to a string), and 0 otherwise.
302
303   function Is_Function (State : Lua_State; Index : Lua_Index) return Boolean;
304   --  Returns 1 if the value at the given index is a C function, and 0
305   --  otherwise.
306
307   function Is_User_Data (State : Lua_State; Index : Lua_Index) return Boolean;
308   --  Returns 1 if the value at the given index is a userdata (either full or
309   --  light), and 0 otherwise.
310
311   function Get_Type
312     (State : Lua_State;
313      Index : Lua_Index)
314      return Lua_Type;
315   --  Returns the type of the value in the given valid index, or LUA_TNONE
316   --  for a non - valid (but acceptable) index.
317
318   function Type_Name
319     (State : Lua_State;
320      Index : Lua_Index)
321      return String;
322   --  Returns the name of the type encoded by the value tp, which must be
323   --  one the values returned by lua_type.
324
325   ----------------
326   -- Operations --
327   ----------------
328
329   type Lua_Compare_Op is
330     (LUA_OPEQ,
331      LUA_OPLT,
332      LUA_OPLE);
333
334   function Compare
335     (State    : Lua_State;
336      Index1   : Lua_Index;
337      Index2   : Lua_Index;
338      Operator : Lua_Compare_Op)
339      return Boolean;
340
341   procedure Concat (State : Lua_State; N : Integer);
342   --  Concatenates the n values at the top of the stack, pops them, and leaves
343   --  the result at the top. If n is 1, the result is the single value on the
344   --  stack (that is, the function does nothing); if n is 0, the result is the
345   --  empty string. Concatenation is performed following the usual semantics
346   --  of Lua.
347
348   type Lua_Arith_Op is
349     (LUA_OPADD,
350      LUA_OPSUB,
351      LUA_OPMUL,
352      LUA_OPDIV,
353      LUA_OPMOD,
354      LUA_OPPOW,
355      LUA_OPUNM);
356
357   procedure Arith (State : Lua_State; Operator : Lua_Arith_Op);
358   --  Performs an arithmetic operation over the two values (or one, in the
359   --  case of negation) at the top of the stack, with the value at the top
360   --  being the second operand, pops these values, and pushes the result of
361   --  the operation. The function follows the semantics of the corresponding
362   --  Lua operator (that is, it may call metamethods).
363
364   ---------------------
365   -- Table Functions --
366   ---------------------
367
368   function Next (State : Lua_State; Index : Lua_Index) return Boolean;
369   --  Pops a key from the stack, and pushes a key value pair from the table
370   --  at the given index (the "next" pair after the given key). If there are
371   --  no more elements in the table, then lua_next returns False (and pushes
372   --  nothing).
373
374   procedure Get_Table (State : Lua_State; Index : Lua_Index);
375   --  Pushes onto the stack the value t[k], where t is the value at the given
376   --  index and k is the value at the top of the stack.
377   --
378   --  This function pops the key from the stack (putting the resulting value
379   --  in its place). As in Lua, this function may trigger a metamethod for the
380   --  "index" event
381
382   procedure Set_Table
383     (State : Lua_State;
384      Index : Lua_Index);
385   --  Does the equivalent to t[k] = v, where t is the value at the given
386   --  index, v is the value at the top of the stack, and k is the value just
387   --  below the top.
388   --
389   --  This function pops both the key and the value from the stack. As in Lua,
390   --  this function may trigger a metamethod for the "newindex" event
391
392   procedure Get_Field
393     (State : Lua_State;
394      Index : Lua_Index;
395      Name  : String);
396   --  Pushes onto the stack the value t[k], where t is the value at the given
397   --  index. As in Lua, this function may trigger a metamethod for the "index"
398   --  event
399
400   procedure Set_Field
401     (State    : Lua_State;
402      Index    : Lua_Index;
403      Name     : String;
404      Override : Boolean := True);
405   --  Does the equivalent to t[k] = v, where t is the value at the given
406   --  index and v is the value at the top of the stack.
407   --
408   --  This function pops the value from the stack. As in Lua, this function
409   --  may trigger a metamethod for the "newindex" event
410
411   procedure Set_Field
412     (State    : Lua_State;
413      Index    : Lua_Index;
414      Name     : String;
415      Fun      : Lua_Function;
416      Override : Boolean := True);
417
418   procedure Create_Table
419     (State       : Lua_State;
420      N_Seq_Elmts : Integer := 0;
421      N_Elmts     : Integer := 0);
422
423   procedure Raw_Get (State : Lua_State; Index : Lua_Index);
424   --  Similar to lua_gettable, but does a raw access (i.e., without
425   --  metamethods).
426
427   procedure Raw_Geti
428     (State : Lua_State;
429      Index : Lua_Index;
430      N     : Integer);
431   --  Pushes onto the stack the value t[n], where t is the table at the given
432   --  index. The access is raw; that is, it does not invoke metamethods.
433
434   -------------
435   -- Threads --
436   -------------
437
438   procedure X_Move
439     (From_State : Lua_State;
440      To_State   : Lua_State;
441      N          : Integer);
442   --  Exchange values between different threads of the same state.
443   --
444   --  This function pops n values from the stack from, and pushes them onto
445   --  the stack to.
446
447   function New_Thread (State : Lua_State) return Lua_State;
448   --  Creates a new thread, pushes it on the stack, and returns a pointer to
449   --  a lua_State that represents this new thread. The new thread returned by
450   --  this function shares with the original thread its global environment,
451   --  but has an independent execution stack.
452   --
453   --  There is no explicit function to close or to destroy a thread. Threads
454   --  are subject to garbage collection, like any Lua object.
455
456   function Push_Thread (State : Lua_State) return Integer;
457   --  Pushes the thread represented by L onto the stack. Returns 1 if this
458   --  thread is the main thread of its state.
459
460   function Resume
461     (State  : Lua_State;
462      Thread : Lua_State;
463      N_Args : Integer)
464      return Integer;
465   --  Starts and resumes a coroutine in a given thread.
466
467   ------------------------
468   -- Global Environment --
469   ------------------------
470
471   procedure Get_Global
472     (State : Lua_State;
473      Name  : String);
474   --  Pushes onto the stack the value of the global name.
475
476   procedure Set_Global
477     (State : Lua_State;
478      Name  : String);
479   --  Pops a value from the stack and sets it as the new value of global name.
480
481   procedure Register_Object
482     (State : Lua_State;
483      Name  : String);
484   --  Helper function to register an Ada object inside lua state. Name is the
485   --  name in Lua global environment with which the function is associated to.
486   --  To ease creation of hierarchies in the global environment, if Name
487   --  contains '.' then a hierarchy using Lua tables is created. For example:
488   --
489   --     Register (S, "a.b.c");
490   --
491   --  will create a global table called "a". The table "a" will contain a
492   --  table at index "b" and this last table will contain one element "b" set
493   --  to the object on top of the stack. Note that an error will be raised
494   --  in case you try to register twice at the same location.
495
496   procedure Register_Function
497     (State : Lua_State;
498      Name  : String;
499      Fun   : Lua_Function);
500   --  Same as previous function except that the registered object is a
501   --  closure passed as argument to the function instead of using the stack
502
503   ----------------
504   -- Metatables --
505   ----------------
506
507   function Get_Metatable
508     (State : Lua_State;
509      Index : Lua_Index) return int;
510   pragma Import (C, Get_Metatable, "lua_getmetatable");
511
512   procedure Set_Metatable (State : Lua_State; Index : Lua_Index);
513   pragma Import (C, Set_Metatable, "lua_setmetatable");
514   --  Pop a table from the stack and sets it as the new metatable for
515   --  the value at the given index.
516
517   function New_Metatable (State : Lua_State; Name : String) return Boolean;
518   --  Create a new metable in the registry called Name. If the metatable is
519   --  already there return False, else True. Note that in all cases the
520   --  metatable is pushed at the top of the stack
521
522   procedure New_Metatable (State : Lua_State; Name : String);
523   --  Same as above but no status is returned
524
525   procedure Set_Metatable
526     (State : Lua_State;
527      Name  : String);
528   --  Sets the metatable of the object at the top of the stack as the
529   --  metatable associated with name Name in the registry
530
531   procedure Get_Metatable
532     (State : Lua_State;
533      Name  : String);
534   --  Push on top of the stack the metatable registered at entry Name in the
535   --  registry
536
537   function Check_User_Data
538     (State : Lua_State;
539      Index : Lua_Index;
540      Name  : String)
541      return Lua_User_Data;
542   --  Check if object at position Index has a metatable and it is the same as
543   --  metatable stored at Name entry in the registry. In case the object has
544   --  not metatable or the metatables do not correspond then return null and
545   --  set an error in the current state. Otherwise return the address of the
546   --  user data of the object.
547
548   function Test_User_Data
549     (State : Lua_State;
550      Index : Lua_Index;
551      Name  : String)
552      return Lua_User_Data;
553   --  Same as previous function except that no error object is pushed on the
554   --  stack.
555
556   ------------
557   -- Others --
558   ------------
559
560   function At_Panic (State : Lua_State;
561                      Fun : Lua_Function)
562                      return Lua_Function;
563
564   function Version (State : Lua_State) return access Lua_Float;
565
566   function Raw_Len (State : Lua_State; Index : Lua_Index) return size_t;
567   --  Returns the raw "length" of the value at the given index: for strings,
568   --  this is the string length; for tables, this is the result of the length
569   --  operator ('#') with no metamethods; for userdata, this is the size of
570   --  the block of memory allocated for the userdata; for other values,
571   --  it is 0.
572
573   function Raw_Equal
574     (State : Lua_State;
575      Index1 : Lua_Index;
576      Index2 : Lua_Index) return int;
577   pragma Import (C, Raw_Equal, "lua_rawequal");
578   --  Returns 1 if the two values in indices index1 and index2 are
579   --  primitively equal (that is, without calling metamethods). Otherwise
580   --  returns 0. Also returns 0 if any of the indices are non valid.
581
582   function New_User_Data
583     (State : Lua_State;
584      Size  : size_t)
585      return System.Address;
586
587   procedure Get_User_Value (State : Lua_State; Index : Lua_Index);
588   pragma Import (C, Get_User_Value, "lua_getuservalue");
589   --  Pushes onto the stack the Lua value associated with the userdata at
590   --  the given index. This Lua value must be a table or nil.
591
592   procedure Raw_Set (State : Lua_State; Index : Lua_Index);
593   --  Similar to lua_settable, but does a raw assignment (i.e.,
594   --  without metamethods).
595
596   procedure Raw_Seti
597     (State : Lua_State;
598      Index : Lua_Index;
599      N     : Integer);
600   --  Does the equivalent of t[n] = v, where t is the table at the given
601   --  index and v is the value at the top of the stack.
602   --
603   --  This function pops the value from the stack. The assignment is raw;
604   --  that is, it does not invoke metamethods.
605
606   procedure Set_User_Value (State : Lua_State;
607                             Index : Lua_Index);
608   --  Pops a table or nil from the stack and sets it as the new value
609   --  associated to the userdata at the given index.
610
611   procedure Call
612     (State    : Lua_State;
613      Nargs    : Integer := 0;
614      NResults : Integer := 0;
615      Context  : Integer := 0;
616      Cont_Fun : Lua_Function := null);
617
618   function Get_Context
619     (State   : Lua_State;
620      Context : Integer)
621      return int;
622   pragma Import (C, Get_Context, "lua_getctx");
623
624   function PCall
625     (State    : Lua_State;
626      Nargs    : Integer := 0;
627      NResults : Integer := 0;
628      Err_Fun  : Integer := 0;
629      Context  : Integer := 0;
630      Cont_Fun : Lua_Function := null)
631      return Lua_Return_Code;
632   pragma Import (C, PCall, "lua_pcallk");
633
634   procedure PCall
635     (State    : Lua_State;
636      Nargs    : Integer := 0;
637      NResults : Integer := 0;
638      Err_Fun  : Integer := 0;
639      Context  : Integer := 0;
640      Cont_Fun : Lua_Function := null);
641   --  Same as PCall function except that a Lua_Error exception is raised in
642   --  case of error.
643
644   function Yield
645     (State    : Lua_State;
646      NResults : Integer;
647      Context  : Integer;
648      Cont_Fun : Lua_Function := null) return int;
649   pragma Import (C, Yield, "lua_yieldk");
650
651   function Status (State : Lua_State) return Lua_Return_Code;
652
653   function Error (State : Lua_State) return Integer;
654   --  Generates a Lua error. The error message (which can actually be a Lua
655   --  value of any type) must be on the stack top. This function does a long
656   --  jump, and therefore never returns.
657
658   procedure Len (State : Lua_State; Index : Lua_Index);
659
660   function Upvalue_Index (N : Positive) return Lua_Index;
661
662private
663
664   pragma Convention (C, Lua_Return_Code);
665   for Lua_Type use
666     (LUA_TNONE          => -1,
667      LUA_TNIL           => 0,
668      LUA_TBOOLEAN       => 1,
669      LUA_TLIGHTUSERDATA => 2,
670      LUA_TNUMBER        => 3,
671      LUA_TSTRING        => 4,
672      LUA_TTABLE         => 5,
673      LUA_TFUNCTION      => 6,
674      LUA_TUSERDATA      => 7,
675      LUA_TTHREAD        => 8);
676   pragma Convention (C, Lua_Type);
677   pragma Convention (C, Lua_Function);
678   pragma Convention (C, Lua_Compare_Op);
679   pragma Convention (C, Lua_Arith_Op);
680
681   pragma Import (C, New_User_Data, "lua_newuserdata");
682   pragma Import (C, Raw_Seti, "lua_rawseti");
683   pragma Import (C, Raw_Set, "lua_rawset");
684   pragma Import (C, Call, "lua_callk");
685   pragma Import (C, Set_Table, "lua_settable");
686   pragma Import (C, Create_Table, "lua_createtable");
687   pragma Import (C, Raw_Geti, "lua_rawgeti");
688   pragma Import (C, Raw_Get, "lua_rawget");
689   pragma Import (C, Push_Closure, "lua_pushcclosure");
690   pragma Import (C, At_Panic, "lua_atpanic");
691   pragma Import (C, Version, "lua_version");
692   pragma Import (C, Status, "lua_status");
693   pragma Import (C, Error, "lua_error");
694   pragma Import (C, Len, "lua_len");
695   pragma Import (C, Resume, "lua_resume");
696   pragma Import (C, Push_Thread, "lua_pushthread");
697   pragma Import (C, New_Thread, "lua_newthread");
698   pragma Import (C, X_Move, "lua_xmove");
699   pragma Import (C, Get_Type, "lua_type");
700   pragma Import (C, Get_Table, "lua_gettable");
701   pragma Import (C, Set_User_Value, "lua_setuservalue");
702   pragma Import (C, New_State, "luaL_newstate");
703   pragma Import (C, Close, "lua_close");
704   pragma Import (C, Open_Libs, "luaL_openlibs");
705   pragma Import (C, Get_Top, "lua_gettop");
706   pragma Import (C, Set_Top, "lua_settop");
707   pragma Import (C, Push_Value, "lua_pushvalue");
708   pragma Import (C, Remove, "lua_remove");
709   pragma Import (C, Insert, "lua_insert");
710   pragma Import (C, Replace, "lua_replace");
711   pragma Import (C, Copy, "lua_copy");
712   pragma Import (C, Absolute_Index, "lua_absindex");
713   pragma Inline (Check_Stack);
714   pragma Inline (To_Ada);
715   pragma Import (C, Concat, "lua_concat");
716   pragma Import (C, Arith, "lua_arith");
717   pragma Import (C, Raw_Len, "lua_rawlen");
718end Lua;
719