当前位置: 首页 > news >正文

delphi6直连redis服务(用lua脚本redis模块)

一、创建一个exe程序

        创建一个exe程序,引用LuaRedis.pas单元(此单元自己封装的代码,目前主要封装了获取key和设置key/value功能),代码如下:

unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;typeTForm1 = class(TForm)btn2: TButton;Memo1: TMemo;edt1: TEdit;edt2: TEdit;edt3: TEdit;btn3: TButton;edt4: TEdit;procedure btn2Click(Sender: TObject);procedure btn3Click(Sender: TObject);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;implementation
usesLuaRedis;{$R *.dfm}procedure TForm1.btn2Click(Sender: TObject);
varsTmp, sErrorMsg: string;
beginMemo1.Text := '';trysTmp := getValue(Trim(edt1.Text), sErrorMsg);    // value111Memo1.Text := sTmp + '->' + sErrorMsg;excepton e:Exception do beginShowMessage('【异常】' + e.Message);Exit;end;end;
end;procedure TForm1.btn3Click(Sender: TObject);
varsKey, sValue, sErrorMsg: string;
beginMemo1.Text := '';trysKey := Trim(edt2.Text);if setKeyValue(sKey, Trim(edt3.Text), StrToIntDef(Trim(edt4.Text), 0), sErrorMsg) then begin   // key111  value111sValue := getValue(Trim(edt2.Text), sErrorMsg);end;Memo1.Text := sKey + ':' + sValue + '->' + sErrorMsg;excepton e:Exception do beginShowMessage('【异常】' + e.Message);Exit;end;end;
end;end.

二、封装LuaRedis.pas单元代码

        上面说的封装LuaRedis.pas单元(通过registerLuaState()和destroyLuaState()来加载和销毁lua的状态机),同时引用Lua.pas, LuaLib.pas单元,代码如下:

unit LuaRedis;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Lua, LuaLib;constC_LuaPathFileName = './luaScript/mytest.lua';function getValue(myKey: string; var sErrorMsg: string): string;function setKeyValue(myKey, myValue: string; myExpire: Integer; var sErrorMsg: string): Boolean;varLuaObj: TLua;L: TLuaState;implementationfunction loadLuaScript(sLuaPathFileName: String; var sErrorMsg: string): Boolean;
varnTmp: Integer;
beginResult := False;trysErrorMsg := '默认提示消息(loadLuaScript)!';if not FileExists(sLuaPathFileName) then beginsErrorMsg := '未查到路径中此Lua脚本文件(' + sLuaPathFileName + ')';Exit;end;nTmp := LuaObj.DoFile(sLuaPathFileName);case nTmp ofLUA_OK : beginsErrorMsg := '成功加载路径中此Lua脚本文件!';Result := True;end;LUA_ERRSYNTAX : sErrorMsg := '在预编译Lua文件时发现了语法错误!';LUA_ERRMEM : sErrorMsg := '在执行Lua文件时内存分配错误!';LUA_ERRRUN : sErrorMsg := '在执行Lua文件中在调用函数时发生了运行时错误!';elsesErrorMsg := '加载失败路径中此Lua脚本文件!';end;excepton e:Exception do beginResult := False;sErrorMsg := '【异常】方法(loadLuaScript):' + e.Message;Exit;end;end;
end;function getValue(myKey: string; var sErrorMsg: string): string;
varnRet: Integer;
begintrysErrorMsg := '默认提示消息(getValue)!';if not loadLuaScript(C_LuaPathFileName, sErrorMsg) then beginExit;end;lua_getglobal(L, 'getValue');lua_pushstring(L, PAnsiChar(myKey));nRet := lua_pcall(L, 1, 1, 0);if nRet = 0 then beginResult := lua_toString(L, -1);sErrorMsg := 'Lua脚本正常执行';Exit;end elsesErrorMsg := 'Lua脚本执行失败!';excepton e:Exception do beginResult := '';sErrorMsg := '【异常】方法(getValue):' + e.Message;Exit;end;end;
end;function setKeyValue(myKey, myValue: string; myExpire: Integer; var sErrorMsg: string): Boolean;
varnRet: Integer;
beginResult := False;trysErrorMsg := '默认提示消息(setKeyValue)!';if not loadLuaScript(C_LuaPathFileName, sErrorMsg) then beginExit;end;lua_getglobal(L, 'setKeyValue');lua_pushstring(L, PAnsiChar(myKey));lua_pushstring(L, PAnsiChar(myValue));lua_pushinteger(L, myExpire);nRet := lua_pcall(L, 3, 1, 0);if nRet = 0 then beginResult := (lua_toInteger(L, -1) = 1);sErrorMsg := 'Lua脚本正常执行';Exit;end elsesErrorMsg := 'Lua脚本执行失败!';excepton e:Exception do beginResult := False;sErrorMsg := '【异常】方法(setKeyValue):' + e.Message;Exit;end;end;
end;procedure registerLuaState();
beginif LuaObj = nil then beginLuaObj := TLua.Create;if L = nil then beginL := LuaObj.LuaInstance;end;// luaL_openlibs 是一个由 luaL(Lua 实用程序库)提供的函数,它用于打开一组标准的Lua库。// 这些库通常包括基础库(base)、字符串处理库(string)、表操作库(table)、数学函数库(math)、I/O库(io)、操作系统库(os)等。// 这个函数通常在你的C/C++程序中与Lua交互时使用,以提供完整的Lua标准库功能。luaL_openlibs(L);end;
end;procedure destroyLuaState();
beginif LuaObj <> nil then beginif L <> nil then beginL := nil;end;LuaObj.Free;end;
end;initializationregisterLuaState();finalizationdestroyLuaState();end.

三、封装的Lua, LuaLib单元

        封装的Lua, LuaLib单元,代码如下:

{ 
/** * @package     Delphi Lua * @copyright   Copyright (c) 2009 Dennis D. Spreen (http://www.spreendigital.de/blog) * @license     http://opensource.org/licenses/gpl-license.php GNU Public License * @author      Dennis D. Spreen <dennis@spreendigital.de> * @version     1.3 * @revision    $Id: Lua.pas 102 2009-09-30 11:39:41Z dennis.spreen $ */ History 
1.3     DS      Improved Callback, now uses pointer instead of object index Modified RegisterFunctions to allow methods from other class to be registered, moved object table into TLua class 
1.2 DS  Added example on how to extend lua with a delphi dll 
1.1     DS      Improved global object table, this optimizes the delphi function calls 
1.0     DS      Initial Release Copyright 2009  Dennis D. Spreen (email : dennis@spreendigital.de) This program is free software; you can redistribute it and/or modify 
it under the terms of the GNU General Public License as published by 
the Free Software Foundation; either version 2 of the License, or 
(at your option) any later version. This program is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
GNU General Public License for more details. You should have received a copy of the GNU General Public License 
along with this program; if not, write to the Free Software 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
}  unit Lua;  interface  uses  Classes,  LuaLib;  type  TLuaState = Lua_State;  TLua = class(TObject)  private  fAutoRegister: Boolean;  CallbackList: TList;  // internal callback list  public  LuaInstance: TLuaState;  // Lua instance  constructor Create(AutoRegister: Boolean = True); overload; virtual;  destructor Destroy; override;  function DoFile(Filename: String): Integer; virtual;// load file and execute  procedure RegisterFunction(FuncName: AnsiString; MethodName: AnsiString = ''; Obj: TObject = NIL); virtual; //register function  procedure AutoRegisterFunctions(Obj: TObject);  // register all published functions  procedure UnregisterFunctions(Obj: TObject); // unregister all object functions  end;  implementation  type  TProc = function(L: TLuaState): Integer of object; // Lua Function  TCallback = class  Routine: TMethod;  // Code and Data for the method  Exec: TProc;       // Resulting execution function  end;  //  
// This function is called by Lua, it extracts the object by  
// pointer to the objects method by name, which is then called.  
//  
// @param       Lua_State   L   Pointer to Lua instance  
// @return      Integer         Number of result arguments on stack  
//  
function LuaCallBack(L: Lua_State): Integer; cdecl;  
var  CallBack: TCallBack;       // The Object stored in the Object Table  
begin  // Retrieve first Closure Value (=Object Pointer)  CallBack := lua_topointer(L, lua_upvalueindex(1));  // Execute only if Object is valid  if (assigned(CallBack) and assigned(CallBack.Exec)) then  Result := CallBack.Exec(L)  else  Result := 0;  
end;  { TLua }  //  
// Create a new Lua instance and optionally create Lua functions  
//  
// @param       Boolean      AutoRegister       (optional)  
// @return      TLua                            Lua Instance  
//  
constructor TLua.Create(AutoRegister: Boolean = True);
begin  inherited Create;  // Load Lua Lib if not already done  if (not LuaLibLoaded) then  LoadLuaLib();  // Open Library  LuaInstance := Lua_Open();  luaopen_base(LuaInstance);  fAutoRegister := AutoRegister;  // Create Object List on initialization  CallBackList := TList.Create;  // if set then register published functions  if (AutoRegister) then  AutoRegisterFunctions(self);  
end;  //  
// Dispose Lua instance  
//  
destructor TLua.Destroy;  
begin  // Unregister all functions if previously autoregistered  if (fAutoRegister) then  UnregisterFunctions(Self);  // dispose Object List on finalization  CallBackList.Free;  // Close instance  Lua_Close(LuaInstance);  inherited;  
end;  //  
// Wrapper for Lua File load and Execution  
//  
// @param       String  Filename        Lua Script file name  
// @return      Integer  
//  
function TLua.DoFile(Filename: String): Integer;  
begin  Result := lual_dofile(LuaInstance, PAnsiChar(AnsiString(Filename)));  
end;  //  
// Register a new Lua Function and map it to the Objects method name  
//  
// @param       AnsiString      FuncName        Lua Function Name  
// @param       AnsiString      MethodName      (optional) Objects Method name  
//  
procedure TLua.RegisterFunction(FuncName: AnsiString; MethodName: AnsiString = ''; Obj: TObject = NIL);  
var  CallBack: TCallBack; // Callback Object  
begin  // if method name not specified use Lua function name  if (MethodName = '') then  MethodName := FuncName;  // if not object specified use this object  if (Obj = NIL) then  Obj := Self;  // Add Callback Object to the Object Index  CallBack := TCallBack.Create;  CallBack.Routine.Data := Obj;  CallBack.Routine.Code := Obj.MethodAddress(String(MethodName));  CallBack.Exec := TProc(CallBack.Routine);  CallbackList.Add(CallBack);  // prepare Closure value (Method Name)  lua_pushstring(LuaInstance, PAnsiChar(FuncName));  // prepare Closure value (CallBack Object Pointer)  lua_pushlightuserdata(LuaInstance, CallBack);  // set new Lua function with Closure value  lua_pushcclosure(LuaInstance, LuaCallBack, 1);  lua_settable(LuaInstance, LUA_GLOBALSINDEX);  
end;  //  
// UnRegister all new Lua Function  
//  
// @param       TObject     Object      Object with prev registered lua functions  
//  
procedure TLua.UnregisterFunctions(Obj: TObject);  
var  I: Integer;  CallBack: TCallBack;  
begin  // remove obj from object list  for I := CallBackList.Count downto 1 do  begin  CallBack := CallBackList[I-1];  if (assigned(CallBack)) and (CallBack.Routine.Data = Obj) then  begin  CallBack.Free;  CallBackList.Items[I-1] := NIL;  CallBackList.Delete(I-1);  end;  end;  
end;  //  
// Register all published methods as Lua Functions  
//  
procedure TLua.AutoRegisterFunctions(Obj: TObject);  
type  PPointer = ^Pointer;  PMethodRec = ^TMethodRec;  TMethodRec = packed record  wSize: Word;  pCode: Pointer;  sName: ShortString;  end;  
var  MethodTable: PAnsiChar;  MethodRec: PMethodRec;  wCount: Word;  nMethod: Integer;  
begin  // Get a pointer to the class's published method table  MethodTable := PAnsiChar(Pointer(PAnsiChar(Obj.ClassType) + vmtMethodTable)^);  if (MethodTable <> Nil) then  begin  // Get the count of the methods in the table  Move(MethodTable^, wCount, 2);  // Position the MethodRec pointer at the first method in the table  // (skip over the 2-byte method count)  MethodRec := PMethodRec(MethodTable + 2);  // Iterate through all the published methods of this class  for nMethod := 0 to wCount - 1 do  begin  // Add the method name to the lua functions  RegisterFunction(MethodRec.sName, MethodRec.sName, Obj);  // Skip to the next method  MethodRec := PMethodRec(PAnsiChar(MethodRec) + MethodRec.wSize);  end;  end;  
end;  end.
(****************************************************************************** 
* Original copyright for the lua source and headers: 
*  1994-2004 Tecgraf, PUC-Rio. 
*  www.lua.org. 
* 
* Copyright for the Delphi adaptation: 
*  2005 Rolf Meyerhoff 
*  www.matrix44.de
* 
* Copyright for the Lua 5.1 adaptation: 
*  2007 Marco Antonio Abreu 
*  www.marcoabreu.eti.br 
* 
*  All rights reserved. 
* 
* Permission is hereby granted, free of charge, to any person obtaining 
* a copy of this software and associated documentation files (the 
* "Software"), to deal in the Software without restriction, including 
* without limitation the rights to use, copy, modify, merge, publish, 
* distribute, sublicense, and/or sell copies of the Software, and to 
* permit persons to whom the Software is furnished to do so, subject to 
* the following conditions: 
* 
* The above copyright notice and this permission notice shall be 
* included in all copies or substantial portions of the Software. 
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
******************************************************************************)  
unit LuaLib;  interface  const  LUA_VERSION   = 'Lua 5.1';  LUA_RELEASE   = 'Lua 5.1.2';  LUA_COPYRIGHT = 'Copyright (C) 1994-2004 Tecgraf, PUC-Rio';  LUA_AUTHORS   = 'R. Ierusalimschy, L. H. de Figueiredo & W. Celes';  LUA_PASCAL_51_AUTHOR = 'Marco Antonio Abreu';  LUA_PASCAL_51_COPYRIGHT = 'Copyright (C) 2007 Marco Antonio Abreu';  (* mark for precompiled code (`<esc>Lua') *)  LUA_SIGNATURE = #27'Lua';  (* option for multiple returns in `lua_pcall' and `lua_call' *)  LUA_MULTRET   = -1;  (* ** pseudo-indices *)  LUA_REGISTRYINDEX = -10000;  LUA_ENVIRONINDEX  = -10001;  LUA_GLOBALSINDEX  = -10002;  (* thread status; 0 is OK *)LUA_OK        = 0;   // (通常定义为 0):文件已成功加载,但尚未执行。此时,你可以使用 lua_pcall 或 lua_call 来执行它。LUA_TRD_YIELD = 1;LUA_ERRRUN    = 2;   // 在运行错误处理函数(由 lua_atpanic 设置)时发生了错误LUA_ERRSYNTAX = 3;   // 在预编译文件时发现了语法错误。LUA_ERRMEM    = 4;   // 内存分配错误。LUA_ERRERR    = 5;  (* extra error code for `luaL_load' *)  LUA_ERRFILE   = LUA_ERRERR + 1;  (* ** basic types *)  LUA_TNONE          = -1;  LUA_TNIL           = 0;  LUA_TBOOLEAN       = 1;  LUA_TLIGHTUSERDATA = 2;  LUA_TNUMBER        = 3;  LUA_TSTRING        = 4;  LUA_TTABLE         = 5;  LUA_TFUNCTION      = 6;  LUA_TUSERDATA      = 7;  LUA_TTHREAD        = 8;  (* minimum Lua stack available to a C function *)  LUA_MINSTACK       = 20;  (* ** garbage-collection function and options *)  LUA_GCSTOP        = 0;  LUA_GCRESTART     = 1;  LUA_GCCOLLECT     = 2;  LUA_GCCOUNT       = 3;  LUA_GCCOUNTB      = 4;  LUA_GCSTEP        = 5;  LUA_GCSETPAUSE    = 6;  LUA_GCSETSTEPMUL  = 7;  (* ** {====================================================================== ** Debug API ** ======================================================================= *)  (* ** Event codes *)  LUA_HOOKCALL    = 0;  LUA_HOOKRET     = 1;  LUA_HOOKLINE    = 2;  LUA_HOOKCOUNT   = 3;  LUA_HOOKTAILRET = 4;  (* ** Event masks *)  LUA_MASKCALL  = (1 shl LUA_HOOKCALL);  LUA_MASKRET   = (1 shl LUA_HOOKRET);  LUA_MASKLINE  = (1 shl LUA_HOOKLINE);  LUA_MASKCOUNT = (1 shl LUA_HOOKCOUNT);  (* ** {====================================================================== ** useful definitions for Lua kernel and libraries ** ======================================================================= *)  (* @@ LUA_NUMBER_SCAN is the format for reading numbers. @@ LUA_NUMBER_FMT is the format for writing numbers. @@ lua_number2str converts a number to a string. @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. @@ lua_str2number converts a string to a number. *)  LUA_NUMBER_SCAN   =   '%lf';  LUA_NUMBER_FMT     =  '%.14g';  LUAI_MAXNUMBER2STR =  32;  (* 16 digits, sign, point, and \0 *)  (* pre-defined references *)  LUA_NOREF  = -2;  LUA_REFNIL = -1;  LUA_IDSIZE = 60;  (* ** package names *)  LUA_COLIBNAME   = 'coroutine';  LUA_TABLIBNAME  = 'table';  LUA_IOLIBNAME   = 'io';  LUA_OSLIBNAME   = 'os';  LUA_STRLIBNAME  = 'string';  LUA_MATHLIBNAME = 'math';  LUA_DBLIBNAME   = 'debug';  LUA_LOADLIBNAME = 'package';  (* ** {====================================================== ** Generic Buffer manipulation ** ======================================================= *)  BUFSIZ = 512; (* From stdio.h *)  LUAL_BUFFERSIZE = BUFSIZ;  type  lua_State = type Pointer;  lua_CFunction = function(L: lua_State): Integer; cdecl;  (* ** functions that read/write blocks when loading/dumping Lua chunks *)  lua_Reader = function(L: lua_State; data: Pointer; var size: Cardinal): PAnsiChar; cdecl;  lua_Writer = function(L: lua_State; p: Pointer; sz: Cardinal; ud: Pointer): Integer; cdecl;  (* ** prototype for memory-allocation functions *)  lua_Alloc = function(ud, ptr: Pointer; osize, nsize: Cardinal): Pointer; cdecl;  (* type of numbers in Lua *)  lua_Number  = type double;  (* type for integer functions *)  lua_Integer = type integer;  lua_Debug = packed record  event: Integer;  name: PAnsiChar; (* (n) *)  namewhat: PAnsiChar; (* (n) `global', `local', `field', `method' *)  what: PAnsiChar; (* (S) `Lua', `C', `main', `tail' *)  source: PAnsiChar; (* (S) *)  currentline: Integer; (* (l) *)  nups: Integer;  (* (u) number of upvalues *)  linedefined: Integer; (* (S) *)  lastlinedefine: Integer;    (* (S) *)  short_src: array[0..LUA_IDSIZE - 1] of AnsiChar; (* (S) *)  (* private part *)  i_ci: Integer; (* active function *)  end;  (* Functions to be called by the debuger in specific events *)  lua_Hook = procedure(L: lua_State; var ar: lua_Debug); cdecl;  (* Lua Record *)  PluaL_reg = ^luaL_reg;  luaL_reg = packed record  name: PAnsiChar;  func: lua_CFunction;  end;  (* ** {====================================================== ** Generic Buffer manipulation ** ======================================================= *)  luaL_Buffer = packed record  p: PAnsiChar; (* current position in buffer *)  lvl: Integer;  (* number of strings in the stack (level) *)  L: lua_State;  buffer: array[0..LUAL_BUFFERSIZE - 1] of AnsiChar;  end;  var  (* ** state manipulation *)  lua_newstate:  function(f: lua_Alloc; ud: Pointer): lua_State; cdecl;  lua_close:     procedure(L: lua_State); cdecl;  lua_newthread: function(L: lua_State): lua_State; cdecl;  lua_atpanic:   function(L: lua_State; panicf: lua_CFunction): lua_CFunction; cdecl;  (* ** basic stack manipulation *)  lua_gettop:     function(L: lua_State): Integer; cdecl;  lua_settop:     procedure(L: lua_State; idx: Integer); cdecl;  lua_pushvalue:  procedure(L: lua_State; idx: Integer); cdecl;  lua_remove:     procedure(L: lua_State; idx: Integer); cdecl;  lua_insert:     procedure(L: lua_State; idx: Integer); cdecl;  lua_replace:    procedure(L: lua_State; idx: Integer); cdecl;  lua_checkstack: function(L: lua_State; extra: Integer): LongBool; cdecl;  lua_xmove:      procedure(from, dest: lua_State; n: Integer); cdecl;  (* ** access functions (stack -> C/Pascal) *)  lua_isnumber:    function(L: lua_State; idx: Integer): LongBool; cdecl;  lua_isstring:    function(L: lua_State; idx: Integer): LongBool; cdecl;  lua_iscfunction: function(L: lua_State; idx: Integer): LongBool; cdecl;  lua_isuserdata:  function(L: lua_State; idx: Integer): LongBool; cdecl;  lua_type:        function(L: lua_State; idx: Integer): Integer; cdecl;  lua_typename:    function(L: lua_State; tp: Integer): PAnsiChar; cdecl;  lua_equal:       function(L: lua_State; idx1, idx2: Integer): LongBool; cdecl;  lua_rawequal:    function(L: lua_State; idx1, idx2: Integer): LongBool; cdecl;  lua_lessthan:    function(L: lua_State; idx1, idx2: Integer): LongBool; cdecl;  lua_tonumber:    function(L: lua_State; idx: Integer): lua_Number; cdecl;  lua_tointeger:   function(L: lua_State; idx: Integer): lua_Integer; cdecl;  lua_toboolean:   function(L: lua_State; idx: Integer): LongBool; cdecl;  lua_tolstring:   function(L: lua_State; idx: Integer; var len: Cardinal): PAnsiChar; cdecl;  lua_objlen:      function(L: lua_State; idx: Integer): Cardinal; cdecl;  lua_tocfunction: function(L: lua_State; idx: Integer): lua_CFunction; cdecl;  lua_touserdata:  function(L: lua_State; idx: Integer): Pointer; cdecl;  lua_tothread:    function(L: lua_State; idx: Integer): lua_State; cdecl;  lua_topointer:   function(L: lua_State; idx: Integer): Pointer; cdecl;  (* ** push functions (C/Pascal -> stack) *)  lua_pushnil:      procedure(L: lua_State); cdecl;  lua_pushnumber:   procedure(L: lua_State; n: lua_Number); cdecl;  lua_pushinteger:  procedure(L: lua_State; n: lua_Integer); cdecl;  lua_pushlstring:  procedure(L: lua_State; s: PAnsiChar; len: Cardinal); cdecl;  lua_pushstring:   procedure(L: lua_State; s: PAnsiChar); cdecl;  lua_pushvfstring: function(L: lua_State; fmt, argp: PAnsiChar): PAnsiChar; cdecl;  lua_pushfstring:  function(L: lua_State; fmt: PAnsiChar; args: array of const): PAnsiChar; cdecl;  lua_pushcclosure: procedure(L: lua_State; fn: lua_CFunction; n: Integer); cdecl;  lua_pushboolean:  procedure(L: lua_State; b: LongBool); cdecl;  lua_pushlightuserdata: procedure(L: lua_State; p: Pointer); cdecl;  lua_pushthread:   function(L: lua_State): Integer; cdecl;  (* ** get functions (Lua -> stack) *)  lua_gettable:     procedure(L: lua_State; idx: Integer); cdecl;  lua_getfield:     procedure(L: lua_State; idx: Integer; k: PAnsiChar); cdecl;  lua_rawget:       procedure(L: lua_State; idx: Integer); cdecl;  lua_rawgeti:      procedure(L: lua_State; idx, n: Integer); cdecl;  lua_createtable:  procedure(L: lua_State; narr, nrec: Integer); cdecl;  lua_newuserdata:  function(L: lua_State; size: Cardinal): Pointer; cdecl;  lua_getmetatable: function(L: lua_State; idx: Integer): LongBool; cdecl;  lua_getfenv:      procedure(L: lua_State; idx: Integer); cdecl;  (* ** set functions (stack -> Lua) *)  lua_settable:     procedure(L: lua_State; idx: Integer); cdecl;  lua_setfield:     procedure(L: lua_State; idx: Integer; k: PAnsiChar ); cdecl;  lua_rawset:       procedure(L: lua_State; idx: Integer); cdecl;  lua_rawseti:      procedure(L: lua_State; idx, n: Integer); cdecl;  lua_setmetatable: function(L: lua_State; idx: Integer): LongBool; cdecl;  lua_setfenv:      function(L: lua_State; idx: Integer): LongBool; cdecl;  (* ** `load' and `call' functions (load and run Lua code) *)  lua_call:   procedure(L: lua_State; nargs, nresults: Integer); cdecl;  lua_pcall:  function(L: lua_State; nargs, nresults, errfunc: Integer): Integer; cdecl;  lua_cpcall: function(L: lua_State; func: lua_CFunction; ud: Pointer): Integer; cdecl;  lua_load:   function(L: lua_State; reader: lua_Reader; data: Pointer; chunkname: PAnsiChar): Integer; cdecl;  lua_dump:   function(L: lua_State; writer: lua_Writer; data: Pointer): Integer; cdecl;  (* ** coroutine functions *)  lua_yield:  function(L: lua_State; nresults: Integer): Integer; cdecl;  lua_resume: function(L: lua_State; narg: Integer): Integer; cdecl;  lua_status: function(L: lua_State): Integer; cdecl;  (* ** garbage-collection functions *)  lua_gc: function(L: lua_State; what, data: Integer): Integer; cdecl;  (* ** miscellaneous functions *)  lua_error:  function(L: lua_State): Integer; cdecl;  lua_next:   function(L: lua_State; idx: Integer): Integer; cdecl;  lua_concat: procedure(L: lua_State; n: Integer); cdecl;  lua_getallocf: function(L: lua_State; ud: Pointer): lua_Alloc; cdecl;  lua_setallocf: procedure(L: lua_State; f: lua_Alloc; ud: Pointer); cdecl;  (* ** {====================================================================== ** Debug API ** ======================================================================= *)  lua_getstack:   function(L: lua_State; level: Integer; var ar: lua_Debug): Integer; cdecl;  lua_getinfo:    function(L: lua_State; what: PAnsiChar; var ar: lua_Debug): Integer; cdecl;  lua_getlocal:   function(L: lua_State; var ar: lua_Debug; n: Integer): PAnsiChar; cdecl;  lua_setlocal:   function(L: lua_State; var ar: lua_Debug; n: Integer): PAnsiChar; cdecl;  lua_getupvalue: function(L: lua_State; funcindex, n: Integer): PAnsiChar; cdecl;  lua_setupvalue: function(L: lua_State; funcindex, n: Integer): PAnsiChar; cdecl;  lua_sethook:      function(L: lua_State; func: lua_Hook; mask, count: Integer): Integer; cdecl;  lua_gethook:      function(L: lua_State): lua_Hook; cdecl;  lua_gethookmask:  function(L: lua_State): Integer; cdecl;  lua_gethookcount: function(L: lua_State): Integer; cdecl;  (* lua libraries *)  luaopen_base:    function(L: lua_State): Integer; cdecl;  luaopen_debug:   function(L: lua_State): Integer; cdecl;  luaopen_io:      function(L: lua_State): Integer; cdecl;  luaopen_math:    function(L: lua_State): Integer; cdecl;  luaopen_os:      function(L: lua_State): Integer; cdecl;  luaopen_package: function(L: lua_State): Integer; cdecl;  luaopen_string:  function(L: lua_State): Integer; cdecl;  luaopen_table:   function(L: lua_State): Integer; cdecl;  (* open all previous libraries *)  luaL_openlibs:   procedure(L: lua_State); cdecl;  luaL_register:     procedure(L: lua_State; libname: PAnsiChar; lr: PluaL_reg); cdecl;  luaL_getmetafield: function(L: lua_State; obj: Integer; e: PAnsiChar): Integer; cdecl;  luaL_callmeta:     function(L: lua_State; obj: Integer; e: PAnsiChar): Integer; cdecl;  luaL_typerror:     function(L: lua_State; narg: Integer; tname: PAnsiChar): Integer; cdecl;  luaL_argerror:     function(L: lua_State; narg: Integer; extramsg: PAnsiChar): Integer; cdecl;  luaL_checklstring: function(L: lua_State; narg: Integer; var len: Cardinal): PAnsiChar; cdecl;  luaL_optlstring:   function(L: lua_State; narg: Integer; d: PAnsiChar; var len: Cardinal): PAnsiChar; cdecl;  luaL_checknumber:  function(L: lua_State; narg: Integer): lua_Number; cdecl;  luaL_optnumber:    function(L: lua_State; narg: Integer; d: lua_Number): lua_Number; cdecl;  luaL_checkinteger: function(L: lua_State; narg: Integer): lua_Integer; cdecl;  luaL_optinteger:   function(L: lua_State; narg: Integer; d: lua_Integer): lua_Integer; cdecl;  luaL_checkstack: procedure(L: lua_State; sz: Integer; msg: PAnsiChar); cdecl;  luaL_checktype:  procedure(L: lua_State; narg, t: Integer); cdecl;  luaL_checkany:   procedure(L: lua_State; narg: Integer); cdecl;  luaL_newmetatable: function(L: lua_State; tname: PAnsiChar): Integer; cdecl;  luaL_checkudata:   function(L: lua_State; narg: Integer; tname: PAnsiChar): Pointer; cdecl;  luaL_checkoption: function(L: lua_State; narg: Integer; def: PAnsiChar; lst: array of PAnsiChar): Integer; cdecl;  luaL_where: procedure(L: lua_State; lvl: Integer); cdecl;  luaL_error: function(L: lua_State; fmt: PAnsiChar; args: array of const): Integer; cdecl;  luaL_ref:   function(L: lua_State; t: Integer): Integer; cdecl;  luaL_unref: procedure(L: lua_State; t, ref: Integer); cdecl;  {$ifdef LUA_COMPAT_GETN}  luaL_getn: function(L: lua_State; t: Integer): Integer; cdecl;  luaL_setn: procedure(L: lua_State; t, n: Integer); cdecl;  
{$endif}  luaL_loadfile:   function(L: lua_State; filename: PAnsiChar): Integer; cdecl;  luaL_loadbuffer: function(L: lua_State; buff: PAnsiChar; sz: Cardinal; name: PAnsiChar): Integer; cdecl;  luaL_loadstring: function(L: lua_State; s: PAnsiChar): Integer; cdecl;  luaL_newstate:  function(): lua_State; cdecl;  luaL_gsub:      function(L: lua_State; s, p, r: PAnsiChar): PAnsiChar; cdecl;  luaL_findtable: function(L: lua_State; idx: Integer; fname: PAnsiChar; szhint: Integer): PAnsiChar; cdecl;  luaL_buffinit:   procedure(L: lua_State; var B: luaL_Buffer); cdecl;  luaL_prepbuffer: function(var B: luaL_Buffer): PAnsiChar; cdecl;  luaL_addlstring: procedure(var B: luaL_Buffer; s: PAnsiChar; l: Cardinal); cdecl;  luaL_addstring:  procedure(var B: luaL_Buffer; s: PAnsiChar); cdecl;  luaL_addvalue:   procedure(var B: luaL_Buffer); cdecl;  luaL_pushresult: procedure(var B: luaL_Buffer); cdecl;  (* ** =============================================================== ** some useful macros ** =============================================================== *)  {$ifndef LUA_COMPAT_GETN}  function  luaL_getn(L: lua_State; t: Integer): Integer;  procedure luaL_setn(L: lua_State; t, n: Integer);   
{$endif}  (* pseudo-indices *)  function lua_upvalueindex(i: Integer): Integer;  (* to help testing the libraries *)  procedure lua_assert(c: Boolean);  function lua_number2str(s: Lua_Number; n: Integer): String;  function lua_str2number(s: String; p: integer): Lua_Number;  (* argument and parameters checks *)  function luaL_argcheck(L: lua_State; cond: Boolean; narg: Integer; extramsg: PAnsiChar): Integer;  function luaL_checkstring(L: lua_State; narg: Integer): PAnsiChar;  function luaL_optstring(L: lua_State; narg: Integer; d: PAnsiChar): PAnsiChar;  function luaL_checkint(L: lua_State; narg: Integer): Integer;  function luaL_optint(L: lua_State; narg, d: Integer): Integer;  function luaL_checklong(L: lua_State; narg: Integer): LongInt;  function luaL_optlong(L: lua_State; narg: Integer; d: LongInt): LongInt;  function luaL_typename(L: lua_State; idx: Integer): PAnsiChar;  function luaL_dofile(L: lua_State; filename: PAnsiChar): Integer;  function luaL_dostring(L: lua_State; str: PAnsiChar): Integer;  procedure luaL_getmetatable(L: lua_State; tname: PAnsiChar);  (* Generic Buffer manipulation *)  procedure luaL_addchar(var B: luaL_Buffer; c: AnsiChar);  procedure luaL_putchar(var B: luaL_Buffer; c: AnsiChar);  procedure luaL_addsize(var B: luaL_Buffer; n: Cardinal);  function luaL_check_lstr(L: lua_State; numArg: Integer; var ls: Cardinal): PAnsiChar;  function luaL_opt_lstr(L: lua_State; numArg: Integer; def: PAnsiChar; var ls: Cardinal): PAnsiChar;  function luaL_check_number(L: lua_State; numArg: Integer): lua_Number;  function luaL_opt_number(L: lua_State; nArg: Integer; def: lua_Number): lua_Number;  function luaL_arg_check(L: lua_State; cond: Boolean; numarg: Integer; extramsg: PAnsiChar): Integer;  function luaL_check_string(L: lua_State; n: Integer): PAnsiChar;  function luaL_opt_string(L: lua_State; n: Integer; d: PAnsiChar): PAnsiChar;  function luaL_check_int(L: lua_State; n: Integer): Integer;  function luaL_check_long(L: lua_State; n: LongInt): LongInt;  function luaL_opt_int(L: lua_State; n, d: Integer): Integer;  function luaL_opt_long(L: lua_State; n: Integer; d: LongInt): LongInt;  procedure lua_pop(L: lua_State; n: Integer);  procedure lua_newtable(L: lua_State);  procedure lua_register(L: lua_state; name: PAnsiChar; f: lua_CFunction);  procedure lua_pushcfunction(L: lua_State; f: lua_CFunction);  function  lua_strlen(L: lua_State; i: Integer): Cardinal;  function lua_isfunction(L: lua_State; idx: Integer): Boolean;  function lua_istable(L: lua_State; idx: Integer): Boolean;  function lua_islightuserdata(L: lua_State; idx: Integer): Boolean;  function lua_isnil(L: lua_State; idx: Integer): Boolean;  function lua_isboolean(L: lua_State; idx: Integer): Boolean;  function lua_isthread(L: lua_State; idx: Integer): Boolean;  function lua_isnone(L: lua_State; idx: Integer): Boolean;  function lua_isnoneornil(L: lua_State; idx: Integer): Boolean;  procedure lua_pushliteral(L: lua_State; s: PAnsiChar);  procedure lua_setglobal(L: lua_State; name: PAnsiChar);  procedure lua_getglobal(L: lua_State; name: PAnsiChar);  function  lua_tostring(L: lua_State; idx: Integer): PAnsiChar;  (* ** compatibility macros and functions *)  function  lua_open(): lua_State;  procedure lua_getregistry(L: lua_State);  function  lua_getgccount(L: lua_State): Integer;  (* compatibility with ref system *)  function  lua_ref(L: lua_State; lock: Boolean): Integer;  procedure lua_unref(L: lua_State; ref: Integer);  procedure lua_getref(L: lua_State; ref: Integer);  (* ** Dynamic library manipulation *)  function  GetProcAddr( fHandle: THandle; const methodName: String; bErrorIfNotExists: Boolean = True ): Pointer;  procedure SetLuaLibFileName( newLuaLibFileName: String );  function  GetLuaLibFileName(): String;  function  LoadLuaLib( newLuaLibFileName: String = '' ): Integer;  procedure FreeLuaLib();  function LuaLibLoaded: Boolean;  implementation  uses  SysUtils, Math,  
{$ifdef MSWINDOWS}  Windows  
{$endif}  
;  var  fLibHandle: Integer = 0;  
{$ifdef MSWINDOWS}  fLuaLibFileName: String = 'Lua5.1.dll';  
{$endif}  
{$ifdef LINUX}  fLuaLibFileName: String = 'liblua.so.5.1';  
{$endif}  (* 
** Dynamic library manipulation 
*)  function GetProcAddr( fHandle: THandle; const methodName: String; bErrorIfNotExists: Boolean = True ): Pointer;  
begin  Result := GetProcAddress( fHandle, PAnsiChar( AnsiString(methodName) ) );  if bErrorIfNotExists and ( Result = nil ) then  Raise Exception.Create( 'Cannot load method ' + QuotedStr( methodName ) + ' from dynamic library.' );  
end;  procedure SetLuaLibFileName( newLuaLibFileName: String );  
begin  fLuaLibFileName := newLuaLibFileName;  
end;  function GetLuaLibFileName(): String;  
begin  Result := fLuaLibFileName;  
end;  function LuaLibLoaded: Boolean;  
begin  Result := fLibHandle <> 0;  
end;  function LoadLuaLib(newLuaLibFileName: String): Integer;  
begin  FreeLuaLib();  if newLuaLibFileName <> '' then  SetLuaLibFileName( newLuaLibFileName );  if not FileExists( GetLuaLibFileName() ) then begin  Result := -1;  exit;  end;  //  fLibHandle := LoadLibrary(PWideChar( (GetLuaLibFileName() ) ));  fLibHandle := LoadLibrary(PAnsiChar( (GetLuaLibFileName() ) ));if fLibHandle = 0 then begin  Result := -2;  exit;  end;  lua_newstate       := GetProcAddr( fLibHandle, 'lua_newstate' );  lua_close          := GetProcAddr( fLibHandle, 'lua_close' );  lua_newthread      := GetProcAddr( fLibHandle, 'lua_newthread' );  lua_atpanic        := GetProcAddr( fLibHandle, 'lua_atpanic' );  lua_gettop         := GetProcAddr( fLibHandle, 'lua_gettop' );  lua_settop         := GetProcAddr( fLibHandle, 'lua_settop' );  lua_pushvalue      := GetProcAddr( fLibHandle, 'lua_pushvalue' );  lua_remove         := GetProcAddr( fLibHandle, 'lua_remove' );  lua_insert         := GetProcAddr( fLibHandle, 'lua_insert' );  lua_replace        := GetProcAddr( fLibHandle, 'lua_replace' );  lua_checkstack     := GetProcAddr( fLibHandle, 'lua_checkstack' );  lua_xmove          := GetProcAddr( fLibHandle, 'lua_xmove' );  lua_isnumber       := GetProcAddr( fLibHandle, 'lua_isnumber' );  lua_isstring       := GetProcAddr( fLibHandle, 'lua_isstring' );  lua_iscfunction    := GetProcAddr( fLibHandle, 'lua_iscfunction' );  lua_isuserdata     := GetProcAddr( fLibHandle, 'lua_isuserdata' );  lua_type           := GetProcAddr( fLibHandle, 'lua_type' );  lua_typename       := GetProcAddr( fLibHandle, 'lua_typename' );  lua_equal          := GetProcAddr( fLibHandle, 'lua_equal' );  lua_rawequal       := GetProcAddr( fLibHandle, 'lua_rawequal' );  lua_lessthan       := GetProcAddr( fLibHandle, 'lua_lessthan' );  lua_tonumber       := GetProcAddr( fLibHandle, 'lua_tonumber' );  lua_tointeger      := GetProcAddr( fLibHandle, 'lua_tointeger' );  lua_toboolean      := GetProcAddr( fLibHandle, 'lua_toboolean' );  lua_tolstring      := GetProcAddr( fLibHandle, 'lua_tolstring' );  lua_objlen         := GetProcAddr( fLibHandle, 'lua_objlen' );  lua_tocfunction    := GetProcAddr( fLibHandle, 'lua_tocfunction' );  lua_touserdata     := GetProcAddr( fLibHandle, 'lua_touserdata' );  lua_tothread       := GetProcAddr( fLibHandle, 'lua_tothread' );  lua_topointer      := GetProcAddr( fLibHandle, 'lua_topointer' );  lua_pushnil        := GetProcAddr( fLibHandle, 'lua_pushnil' );  lua_pushnumber     := GetProcAddr( fLibHandle, 'lua_pushnumber' );  lua_pushinteger    := GetProcAddr( fLibHandle, 'lua_pushinteger' );  lua_pushlstring    := GetProcAddr( fLibHandle, 'lua_pushlstring' );  lua_pushstring     := GetProcAddr( fLibHandle, 'lua_pushstring' );  lua_pushvfstring   := GetProcAddr( fLibHandle, 'lua_pushvfstring' );  lua_pushfstring    := GetProcAddr( fLibHandle, 'lua_pushfstring' );  lua_pushcclosure   := GetProcAddr( fLibHandle, 'lua_pushcclosure' );  lua_pushboolean    := GetProcAddr( fLibHandle, 'lua_pushboolean' );  lua_pushlightuserdata := GetProcAddr( fLibHandle, 'lua_pushlightuserdata' );  lua_pushthread     := GetProcAddr( fLibHandle, 'lua_pushthread' );  lua_gettable       := GetProcAddr( fLibHandle, 'lua_gettable' );  lua_getfield       := GetProcAddr( fLibHandle, 'lua_getfield' );  lua_rawget         := GetProcAddr( fLibHandle, 'lua_rawget' );  lua_rawgeti        := GetProcAddr( fLibHandle, 'lua_rawgeti' );  lua_createtable    := GetProcAddr( fLibHandle, 'lua_createtable' );  lua_newuserdata    := GetProcAddr( fLibHandle, 'lua_newuserdata' );  lua_getmetatable   := GetProcAddr( fLibHandle, 'lua_getmetatable' );  lua_getfenv        := GetProcAddr( fLibHandle, 'lua_getfenv' );  lua_settable       := GetProcAddr( fLibHandle, 'lua_settable' );  lua_setfield       := GetProcAddr( fLibHandle, 'lua_setfield' );  lua_rawset         := GetProcAddr( fLibHandle, 'lua_rawset' );  lua_rawseti        := GetProcAddr( fLibHandle, 'lua_rawseti' );  lua_setmetatable   := GetProcAddr( fLibHandle, 'lua_setmetatable' );  lua_setfenv        := GetProcAddr( fLibHandle, 'lua_setfenv' );  lua_call           := GetProcAddr( fLibHandle, 'lua_call' );  lua_pcall          := GetProcAddr( fLibHandle, 'lua_pcall' );  lua_cpcall         := GetProcAddr( fLibHandle, 'lua_cpcall' );  lua_load           := GetProcAddr( fLibHandle, 'lua_load' );  lua_dump           := GetProcAddr( fLibHandle, 'lua_dump' );  lua_yield          := GetProcAddr( fLibHandle, 'lua_yield' );  lua_resume         := GetProcAddr( fLibHandle, 'lua_resume' );  lua_status         := GetProcAddr( fLibHandle, 'lua_status' );  lua_gc             := GetProcAddr( fLibHandle, 'lua_gc' );  lua_error          := GetProcAddr( fLibHandle, 'lua_error' );  lua_next           := GetProcAddr( fLibHandle, 'lua_next' );  lua_concat         := GetProcAddr( fLibHandle, 'lua_concat' );  lua_getallocf      := GetProcAddr( fLibHandle, 'lua_getallocf' );  lua_setallocf      := GetProcAddr( fLibHandle, 'lua_setallocf' );  lua_getstack       := GetProcAddr( fLibHandle, 'lua_getstack' );  lua_getinfo        := GetProcAddr( fLibHandle, 'lua_getinfo' );  lua_getlocal       := GetProcAddr( fLibHandle, 'lua_getlocal' );  lua_setlocal       := GetProcAddr( fLibHandle, 'lua_setlocal' );  lua_getupvalue     := GetProcAddr( fLibHandle, 'lua_getupvalue' );  lua_setupvalue     := GetProcAddr( fLibHandle, 'lua_setupvalue' );  lua_sethook        := GetProcAddr( fLibHandle, 'lua_sethook' );  lua_gethook        := GetProcAddr( fLibHandle, 'lua_gethook' );  lua_gethookmask    := GetProcAddr( fLibHandle, 'lua_gethookmask' );  lua_gethookcount   := GetProcAddr( fLibHandle, 'lua_gethookcount' );  luaopen_base       := GetProcAddr( fLibHandle, 'luaopen_base' );  luaopen_table      := GetProcAddr( fLibHandle, 'luaopen_table' );  luaopen_io         := GetProcAddr( fLibHandle, 'luaopen_io' );  luaopen_os         := GetProcAddr( fLibHandle, 'luaopen_os' );  luaopen_string     := GetProcAddr( fLibHandle, 'luaopen_string' );  luaopen_math       := GetProcAddr( fLibHandle, 'luaopen_math' );  luaopen_debug      := GetProcAddr( fLibHandle, 'luaopen_debug' );  luaopen_package    := GetProcAddr( fLibHandle, 'luaopen_package' );  luaL_openlibs      := GetProcAddr( fLibHandle, 'luaL_openlibs' );  luaL_register      := GetProcAddr( fLibHandle, 'luaL_register' );  luaL_getmetafield  := GetProcAddr( fLibHandle, 'luaL_getmetafield' );  luaL_callmeta      := GetProcAddr( fLibHandle, 'luaL_callmeta' );  luaL_typerror      := GetProcAddr( fLibHandle, 'luaL_typerror' );  luaL_argerror      := GetProcAddr( fLibHandle, 'luaL_argerror' );  luaL_checklstring  := GetProcAddr( fLibHandle, 'luaL_checklstring' );  luaL_optlstring    := GetProcAddr( fLibHandle, 'luaL_optlstring' );  luaL_checknumber   := GetProcAddr( fLibHandle, 'luaL_checknumber' );  luaL_optnumber     := GetProcAddr( fLibHandle, 'luaL_optnumber' );  luaL_checkinteger  := GetProcAddr( fLibHandle, 'luaL_checkinteger' );  luaL_optinteger    := GetProcAddr( fLibHandle, 'luaL_optinteger' );  luaL_checkstack    := GetProcAddr( fLibHandle, 'luaL_checkstack' );  luaL_checktype     := GetProcAddr( fLibHandle, 'luaL_checktype' );  luaL_checkany      := GetProcAddr( fLibHandle, 'luaL_checkany' );  luaL_newmetatable  := GetProcAddr( fLibHandle, 'luaL_newmetatable' );  luaL_checkudata    := GetProcAddr( fLibHandle, 'luaL_checkudata' );  luaL_where         := GetProcAddr( fLibHandle, 'luaL_where' );  luaL_error         := GetProcAddr( fLibHandle, 'luaL_error' );  luaL_checkoption   := GetProcAddr( fLibHandle, 'luaL_checkoption' );  luaL_ref           := GetProcAddr( fLibHandle, 'luaL_ref' );  luaL_unref         := GetProcAddr( fLibHandle, 'luaL_unref' );  
{$ifdef LUA_COMPAT_GETN}  luaL_getn          := GetProcAddr( fLibHandle, 'luaL_getn' );  luaL_setn          := GetProcAddr( fLibHandle, 'luaL_setn' );  
{$endif}  luaL_loadfile      := GetProcAddr( fLibHandle, 'luaL_loadfile' );  luaL_loadbuffer    := GetProcAddr( fLibHandle, 'luaL_loadbuffer' );  luaL_loadstring    := GetProcAddr( fLibHandle, 'luaL_loadstring' );  luaL_newstate      := GetProcAddr( fLibHandle, 'luaL_newstate' );  luaL_gsub          := GetProcAddr( fLibHandle, 'luaL_gsub' );  luaL_findtable     := GetProcAddr( fLibHandle, 'luaL_findtable' );  luaL_buffinit      := GetProcAddr( fLibHandle, 'luaL_buffinit' );  luaL_prepbuffer    := GetProcAddr( fLibHandle, 'luaL_prepbuffer' );  luaL_addlstring    := GetProcAddr( fLibHandle, 'luaL_addlstring' );  luaL_addstring     := GetProcAddr( fLibHandle, 'luaL_addstring' );  luaL_addvalue      := GetProcAddr( fLibHandle, 'luaL_addvalue' );  luaL_pushresult    := GetProcAddr( fLibHandle, 'luaL_pushresult' );  Result := fLibHandle;  
end;  procedure FreeLuaLib();  
begin  lua_newstate       := nil;  lua_close          := nil;  lua_newthread      := nil;  lua_atpanic        := nil;  lua_gettop         := nil;  lua_settop         := nil;  lua_pushvalue      := nil;  lua_remove         := nil;  lua_insert         := nil;  lua_replace        := nil;  lua_checkstack     := nil;  lua_xmove          := nil;  lua_isnumber       := nil;  lua_isstring       := nil;  lua_iscfunction    := nil;  lua_isuserdata     := nil;  lua_type           := nil;  lua_typename       := nil;  lua_equal          := nil;  lua_rawequal       := nil;  lua_lessthan       := nil;  lua_tonumber       := nil;  lua_tointeger      := nil;  lua_toboolean      := nil;  lua_tolstring      := nil;  lua_objlen         := nil;  lua_tocfunction    := nil;  lua_touserdata     := nil;  lua_tothread       := nil;  lua_topointer      := nil;  lua_pushnil        := nil;  lua_pushnumber     := nil;  lua_pushinteger    := nil;  lua_pushlstring    := nil;  lua_pushstring     := nil;  lua_pushvfstring   := nil;  lua_pushfstring    := nil;  lua_pushcclosure   := nil;  lua_pushboolean    := nil;  lua_pushlightuserdata := nil;  lua_pushthread     := nil;  lua_gettable       := nil;  lua_getfield       := nil;  lua_rawget         := nil;  lua_rawgeti        := nil;  lua_createtable    := nil;  lua_newuserdata    := nil;  lua_getmetatable   := nil;  lua_getfenv        := nil;  lua_settable       := nil;  lua_setfield       := nil;  lua_rawset         := nil;  lua_rawseti        := nil;  lua_setmetatable   := nil;  lua_setfenv        := nil;  lua_call           := nil;  lua_pcall          := nil;  lua_cpcall         := nil;  lua_load           := nil;  lua_dump           := nil;  lua_yield          := nil;  lua_resume         := nil;  lua_status         := nil;  lua_gc             := nil;  lua_error          := nil;  lua_next           := nil;  lua_concat         := nil;  lua_getallocf      := nil;  lua_setallocf      := nil;  lua_getstack       := nil;  lua_getinfo        := nil;  lua_getlocal       := nil;  lua_setlocal       := nil;  lua_getupvalue     := nil;  lua_setupvalue     := nil;  lua_sethook        := nil;  lua_gethook        := nil;  lua_gethookmask    := nil;  lua_gethookcount   := nil;  luaopen_base       := nil;  luaopen_table      := nil;  luaopen_io         := nil;  luaopen_os         := nil;  luaopen_string     := nil;  luaopen_math       := nil;  luaopen_debug      := nil;  luaopen_package    := nil;  luaL_openlibs      := nil;  luaL_register      := nil;  luaL_getmetafield  := nil;  luaL_callmeta      := nil;  luaL_typerror      := nil;  luaL_argerror      := nil;  luaL_checklstring  := nil;  luaL_optlstring    := nil;  luaL_checknumber   := nil;  luaL_optnumber     := nil;  luaL_checkinteger  := nil;  luaL_optinteger    := nil;  luaL_checkstack    := nil;  luaL_checktype     := nil;  luaL_checkany      := nil;  luaL_newmetatable  := nil;  luaL_checkudata    := nil;  luaL_where         := nil;  luaL_error         := nil;  luaL_checkoption   := nil;  luaL_ref           := nil;  luaL_unref         := nil;  
{$ifdef LUA_COMPAT_GETN}  luaL_getn          := nil;  luaL_setn          := nil;  
{$endif}  luaL_loadfile      := nil;  luaL_loadbuffer    := nil;  luaL_loadstring    := nil;  luaL_newstate      := nil;  luaL_gsub          := nil;  luaL_findtable     := nil;  luaL_buffinit      := nil;  luaL_prepbuffer    := nil;  luaL_addlstring    := nil;  luaL_addstring     := nil;  luaL_addvalue      := nil;  luaL_pushresult    := nil;  if fLibHandle <> 0 then begin  FreeLibrary( fLibHandle );  fLibHandle := 0;  end;  
end;  {$ifndef LUA_COMPAT_GETN}  
function luaL_getn(L: lua_State; t: Integer): Integer;  
begin  Result := lua_objlen(L, t);  
end;  procedure luaL_setn(L: lua_State; t, n: Integer);  
begin  
end;  
{$endif}  function lua_upvalueindex(i: Integer): Integer;  
begin  Result := LUA_GLOBALSINDEX - i;  
end;  procedure lua_pop(L: lua_State; n: Integer);  
begin  lua_settop(L, -(n) - 1);  
end;  procedure lua_newtable(L: lua_State);  
begin  lua_createtable(L, 0, 0);  
end;  function lua_strlen(L: lua_State; i: Integer): Cardinal;  
begin  result := lua_objlen(L, i);  
end;  procedure lua_register(L: lua_state; name: PAnsiChar; f: lua_CFunction);  
begin  lua_pushcfunction(L, f);  lua_setglobal(L, name);  
end;  procedure lua_pushcfunction(L: lua_State; f: lua_CFunction);  
begin  lua_pushcclosure(L, f, 0);  
end;  function lua_isfunction(L: lua_State; idx: Integer): Boolean;  
begin  Result := lua_type(L, idx) = LUA_TFUNCTION;  
end;  function lua_istable(L: lua_State; idx: Integer): Boolean;  
begin  Result := lua_type(L, idx) = LUA_TTABLE;  
end;  function lua_islightuserdata(L: lua_State; idx: Integer): Boolean;  
begin  Result := lua_type(L, idx) = LUA_TLIGHTUSERDATA;  
end;  function lua_isnil(L: lua_State; idx: Integer): Boolean;  
begin  Result := lua_type(L, idx) = LUA_TNIL;  
end;  function lua_isboolean(L: lua_State; idx: Integer): Boolean;  
begin  Result := lua_type(L, idx) = LUA_TBOOLEAN;  
end;  function lua_isthread(L: lua_State; idx: Integer): Boolean;  
begin  Result := lua_type(L, idx) = LUA_TTHREAD;  
end;  function lua_isnone(L: lua_State; idx: Integer): Boolean;  
begin  Result := lua_type(L, idx) = LUA_TNONE;  
end;  function lua_isnoneornil(L: lua_State; idx: Integer): Boolean;  
begin  Result := lua_type(L, idx) <= 0;  
end;  procedure lua_pushliteral(L: lua_State; s: PAnsiChar);  
begin  lua_pushlstring(L, s, StrLen(s));  
end;  procedure lua_setglobal(L: lua_State; name: PAnsiChar);  
begin  lua_setfield(L, LUA_GLOBALSINDEX, name);  
end;  procedure lua_getglobal(L: lua_State; name: PAnsiChar);  
begin  lua_getfield(L, LUA_GLOBALSINDEX, name);  
end;  function lua_tostring(L: lua_State; idx: Integer): PAnsiChar;  
var  len: Cardinal;  
begin  Result := lua_tolstring(L, idx, len);  
end;  function lua_getgccount(L: lua_State): Integer;  
begin  Result := lua_gc(L, LUA_GCCOUNT, 0);  
end;  function lua_open(): lua_State;  
begin  Result := luaL_newstate();  
end;  procedure lua_getregistry(L: lua_State);  
begin  lua_pushvalue(L, LUA_REGISTRYINDEX);  
end;  function lua_ref(L: lua_State; lock: Boolean): Integer;  
begin  if lock then  Result := luaL_ref(L, LUA_REGISTRYINDEX)  else begin  lua_pushstring(L, 'unlocked references are obsolete');  Result := lua_error(L);  end;  
end;  procedure lua_unref(L: lua_State; ref: Integer);  
begin  luaL_unref(L, LUA_REGISTRYINDEX, ref);  
end;  procedure lua_getref(L: lua_State; ref: Integer);  
begin  lua_rawgeti(L, LUA_REGISTRYINDEX, ref);  
end;  procedure lua_assert(c: Boolean);  
begin  
end;  function lua_number2str(s: Lua_Number; n: Integer): String;  
begin  Result := FormatFloat( LUA_NUMBER_FMT, RoundTo( s, n ) );  
end;  function lua_str2number(s: String; p: integer): Lua_Number;  
begin  Result := RoundTo( StrToFloat( s ), p );  
end;  function luaL_argcheck(L: lua_State; cond: Boolean; narg: Integer; extramsg: PAnsiChar): Integer;  
begin  if cond then  Result := 0  else  Result := luaL_argerror(L, narg, extramsg);  
end;  function luaL_checkstring(L: lua_State; narg: Integer): PAnsiChar;  
var  ls: Cardinal;  
begin  Result := luaL_checklstring(L, narg, ls);  
end;  function luaL_optstring(L: lua_State; narg: Integer; d: PAnsiChar): PAnsiChar;  
var  ls: Cardinal;  
begin  Result := luaL_optlstring(L, narg, d, ls);  
end;  function luaL_checkint(L: lua_State; narg: Integer): Integer;  
begin  Result := Trunc(luaL_checkinteger(L, narg));  
end;  function luaL_optint(L: lua_State; narg, d: Integer): Integer;  
begin  Result := Trunc(luaL_optinteger(L, narg, d));  
end;  function luaL_checklong(L: lua_State; narg: Integer): LongInt;  
begin  Result := Trunc(luaL_checkinteger(L, narg));  
end;  function luaL_optlong(L: lua_State; narg: Integer; d: LongInt): LongInt;  
begin  Result := Trunc(luaL_optinteger(L, narg, d));  
end;  function luaL_typename(L: lua_State; idx: Integer): PAnsiChar;  
begin  Result := lua_typename(L, lua_type(L, idx));  
end;  function luaL_dofile(L: lua_State; filename: PAnsiChar): Integer;  
begin  Result := luaL_loadfile(L, filename);  If Result = 0 Then  Result := lua_pcall(L, 0, LUA_MULTRET, 0);  
end;  function luaL_dostring(L: lua_State; str: PAnsiChar): Integer;  
begin  Result := luaL_loadstring(L, str);  If Result = 0 Then  Result := lua_pcall(L, 0, LUA_MULTRET, 0);  
end;  procedure luaL_getmetatable(L: lua_State; tname: PAnsiChar);  
begin  lua_getfield(L, LUA_REGISTRYINDEX, tname);  
end;  procedure luaL_addchar(var B: luaL_Buffer; c: AnsiChar);  
begin  if Integer(B.p) < Integer(B.buffer + LUAL_BUFFERSIZE) then  luaL_prepbuffer(B);  B.p^ := c;  Inc(B.p);  
{  // original C code 
#define luaL_addchar(B,c) \ ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ (*(B)->p++ = (char)(c))) 
}  
end;  procedure luaL_putchar(var B: luaL_Buffer; c: AnsiChar);  
begin  luaL_addchar(B, c);  
end;  procedure luaL_addsize(var B: luaL_Buffer; n: Cardinal);  
begin  Inc(B.p, n);  
end;  function luaL_check_lstr(L: lua_State; numArg: Integer; var ls: Cardinal): PAnsiChar;  
begin  Result := luaL_checklstring(L, numArg, ls);  
end;  function luaL_opt_lstr(L: lua_State; numArg: Integer; def: PAnsiChar; var ls: Cardinal): PAnsiChar;  
begin  Result := luaL_optlstring(L, numArg, def, ls);  
end;  function luaL_check_number(L: lua_State; numArg: Integer): lua_Number;  
begin  Result := luaL_checknumber(L, numArg);  
end;  function luaL_opt_number(L: lua_State; nArg: Integer; def: lua_Number): lua_Number;  
begin  Result := luaL_optnumber(L, nArg, def);  
end;  function luaL_arg_check(L: lua_State; cond: Boolean; numarg: Integer; extramsg: PAnsiChar): Integer;  
begin  Result := luaL_argcheck(L, cond, numarg, extramsg);  
end;  function luaL_check_string(L: lua_State; n: Integer): PAnsiChar;  
begin  Result := luaL_checkstring(L, n);  
end;  function luaL_opt_string(L: lua_State; n: Integer; d: PAnsiChar): PAnsiChar;  
begin  Result := luaL_optstring(L, n, d);  
end;  function luaL_check_int(L: lua_State; n: Integer): Integer;  
begin  Result := luaL_checkint(L, n);  
end;  function luaL_check_long(L: lua_State; n: LongInt): LongInt;  
begin  Result := luaL_checklong(L, n);  
end;  function luaL_opt_int(L: lua_State; n, d: Integer): Integer;  
begin  Result := luaL_optint(L, n, d);  
end;  function luaL_opt_long(L: lua_State; n: Integer; d: LongInt): LongInt;  
begin  Result := luaL_optlong(L, n, d);  
end;  end.

四、单元层级截图如下(上传有bin程序):

五、备注

        1、自己运行redis程序,保证正常(这是前提,自行检索相关内容);

        2、对上面的bin解压缩后,会看到luaScript里面有自己写的lua脚本,里面有redis的ip地址,默认是127.0.0.1的,可以自行使用;

        3、运行主程序exe,就能set和get相关redis功能;

相关文章:

delphi6直连redis服务(用lua脚本redis模块)

一、创建一个exe程序 创建一个exe程序&#xff0c;引用LuaRedis.pas单元&#xff08;此单元自己封装的代码&#xff0c;目前主要封装了获取key和设置key/value功能&#xff09;&#xff0c;代码如下&#xff1a; unit Unit1;interfaceusesWindows, Messages, SysUtils, Variant…...

嵌入式Linux:编译和使用Protobuf库

目录 1、开发环境和工具 2、安装和编译Protobuf、Protobuf-C库 3、编写和编译proto文件 4、修改makefile文件 5、测试示例 6、参考资料 Protobuf&#xff08;Protocol Buffers&#xff09;是由 Google 开发的一种轻量级、高效的结构化数据序列化方式&#xff0c;用于在不同应用…...

导航app为什么知道还有几秒变绿灯?

在使用地图导航app行驶至信号灯的交叉路口时&#xff0c;这些应用程序会贴心地告知用户距信号灯变化还有多少秒&#xff0c;无论是即将转为绿灯还是红灯。这一智能化提示不仅使得驾驶员能适时做好起步或刹车的准备&#xff0c;有效缓解了因等待时间不确定而产生的焦虑情绪&…...

设计模式 六大原则之单一职责原则

文章目录 概述代码例子小结 概述 先看下定义吧&#xff0c;如下&#xff1a; 单一职责原则的定义描述非常简单&#xff0c;也不难理解。一个类只负责完成一个职责或者功能。也就是说在类的设计中&#xff0c; 我们不要设计大而全的类,而是要设计粒度小、功能单一的类。 代码例…...

DOM重点核心(注册事件+DOM事件流)

目录 1.注册事件 注册时间概述 addEventListener() 删除事件 2.DOM事件流 DOM事件流理论 事件对象 事件对象的常见属性和方法 e.targe 和 this的区别 阻止默认行为 阻止冒泡 事件委托 禁止右键菜单和禁止选中文字 获得鼠标的坐标&#xff08;可视区、页面、浏览器…...

浅谈操作系统中的重要概念——线程(3)——设计模式

文章目录 一、什么是设计模式&#xff1f;二、单例模式2.1、饿汉模式2.2、懒汉模式2.3、多线程情况下调用 饿汉模式与懒汉模式 谁是安全的&#xff1f;&#xff1f;&#xff08;重点&#xff09; 三、工厂模式3.1、什么是工厂模式&#xff1f;3.1.1、构造方法存在的缺陷3.1.1.1…...

nginx配置域名与IP访问服务冲突问题

在最近的一次开发中遇到一个问题&#xff0c;我在云服务器上部署了两个服务&#xff0c;A服务和B服务&#xff0c; A服务在服务器中用的端口是80端口&#xff0c;所以我在浏览器访问的地址就是 B服务在服务器中用的是9818端口&#xff0c;所以我在浏览器访问的是 现在我给B服务…...

2024OD机试卷-字符串序列判定 (java\python\c++)

题目:字符串序列判定 题目描述 输入两个字符串 S 和 L ,都只包含英文小写字母。S长度 ≤ 100,L长度 ≤ 500,000。判定S是否是L的有效子串。 判定规则:S 中的每个字符在 L 中都能找到(可以不连续),且 S 在L中字符的前后顺序与 S 中顺序要保持一致。(例如,S = ” ace…...

7-128 最长公共子串

一个序列中去掉若干(也可以不去掉)元素剩下的部分称为其子序列。对于给定的序列X = <x1​,x2​,…,xm​>,称序列Z = <z1​,z2​,…,zk​>为X的一个子序列,仅当在X中存在一个递增序号序列<i1​,i2​,…,ik​>,对所有的j(1,2,…,k)满足 xij…...

【瑞萨RA6M3】2. UART 实验

https://blog.csdn.net/qq_35181236/article/details/132789258 使用 uart9 配置 打印 void hal_entry(void) {/* TODO: add your own code here */fsp_err_t err;uint8_t c;/* 配置串口 */err g_uart9.p_api->open(g_uart9.p_ctrl, g_uart9.p_cfg);while (1){g_uart9.…...

js遇到需要正则匹配来修改img标签+清除行内样式

方法一 var regex0 new RegExp("(i?)(\<img)([^\>]\>)", "gmi") //正则匹配表达式this.newcontent this.content.replace(regex0,"$2 styledisplay:block;margin: auto;width:120px; $3") //下面这个则需要在$2 $3左右添加和修改东…...

Vue学习v-if与v-else-if

Vue学习v-if与v-else-if 一、前言1、v-if2、v-else-if3、v-else4、示例 一、前言 v-if 和 v-else-if 是 Vue.js 中用于条件渲染的指令&#xff0c;它们通常与 v-else 一起使用。下面我来详细解释一下它们的用法和区别&#xff1a; 1、v-if 用法&#xff1a;v-if 是一个指令&…...

linux进阶高级配置,你需要知道的有哪些2-firewalld防火墙(一)

1、防火墙的技术上分类&#xff1a; 包过滤&#xff1a;firewalld属于这种 应用代理&#xff1a; 状态检测&#xff1a;ASA 2、firewalld的两种配置模式&#xff1a; 运行时配置 &#xff1a;立即生效 永久配置&#xff1a;重新加载服务生效 3、常用的区域&#xff1a; trust…...

Centos 中如何汉化man命令

刚学Linux&#xff0c;记不住命令和选项&#xff0c;很依赖里面的 man 查看命令&#xff0c;但因为着实看不懂&#xff0c;有没有什么办法把man查看命令的信息改成中文 在CentOS 7中&#xff0c;你可以通过安装man-pages-zh包来获取中文的man手册。以下是具体的步骤&#xff1a…...

原生小程序开发如何使用 tailwindcss

原生小程序开发如何使用 tailwindcss 原生小程序开发如何使用 tailwindcss 前言什么是 weapp-tailwindcss ?0. 准备环境以及小程序项目1. 安装与配置 tailwindcss 0. 使用包管理器安装 tailwindcss1. 在项目目录下创建 postcss.config.js 并注册 tailwindcss2. 配置 tailwind…...

spring alibaba中的seata分布式事务

Seata AT 模式设计思路 一阶段&#xff1a;业务数据和回滚日志记录在同一个本地事务中提交&#xff0c;释放本地锁和连接资源。 核心在于对业务sql进行解决解析&#xff0c;转换成undolog&#xff0c;并同时入库存 二阶段&#xff1a; 提交异步化&#xff0c;非常快速地完成…...

MQTT学习(二)

订阅主题和订阅确认 SUBSCRIBE——订阅主题 之前的CONNECT报文&#xff0c;分为 固定报头&#xff1a;必须存在&#xff0c;用于描述报文信息。里面有指出什么类型的报文&#xff0c;报文的等级。可变报头&#xff1a;不一定存在。主要看什么样子类型的报文。有效载荷部分&a…...

入职Java,不会git被开除了。。。

入职Java&#xff0c;不会git被开除了。。。 文章目录 入职Java&#xff0c;不会git被开除了。。。前言一、Git是什么&#xff1f;二、Git的核心概念三、Git的工作流程四、Git的常用命令五、总结 &#x1f308;你好呀&#xff01;我是 山顶风景独好 &#x1f49d;欢迎来到我的博…...

Mysql 隔离级别

MySQL的事务隔离级别是指在处理并发事务时&#xff0c;为保证数据的一致性和事务的独立性&#xff0c;数据库系统提供的不同级别控制策略。根据ACID特性中的隔离性&#xff08;Isolation&#xff09;&#xff0c;MySQL支持四种标准的事务隔离级别&#xff0c;每种级别有不同的并…...

每日一学—K邻算法:在风险传导中的创新应用与实践价值

文章目录 &#x1f4cb; 前言&#x1f3af; K邻算法的实践意义&#x1f3af; 创新应用与案例分析&#x1f525; 参与方式 &#x1f4cb; 前言 在当今工业领域&#xff0c;图思维方式与图数据技术的应用日益广泛&#xff0c;成为图数据探索、挖掘与应用的坚实基础。本文旨在分享…...

ES6从入门到精通:前言

ES6简介 ES6&#xff08;ECMAScript 2015&#xff09;是JavaScript语言的重大更新&#xff0c;引入了许多新特性&#xff0c;包括语法糖、新数据类型、模块化支持等&#xff0c;显著提升了开发效率和代码可维护性。 核心知识点概览 变量声明 let 和 const 取代 var&#xf…...

Prompt Tuning、P-Tuning、Prefix Tuning的区别

一、Prompt Tuning、P-Tuning、Prefix Tuning的区别 1. Prompt Tuning(提示调优) 核心思想:固定预训练模型参数,仅学习额外的连续提示向量(通常是嵌入层的一部分)。实现方式:在输入文本前添加可训练的连续向量(软提示),模型只更新这些提示参数。优势:参数量少(仅提…...

进程地址空间(比特课总结)

一、进程地址空间 1. 环境变量 1 &#xff09;⽤户级环境变量与系统级环境变量 全局属性&#xff1a;环境变量具有全局属性&#xff0c;会被⼦进程继承。例如当bash启动⼦进程时&#xff0c;环 境变量会⾃动传递给⼦进程。 本地变量限制&#xff1a;本地变量只在当前进程(ba…...

【OSG学习笔记】Day 18: 碰撞检测与物理交互

物理引擎&#xff08;Physics Engine&#xff09; 物理引擎 是一种通过计算机模拟物理规律&#xff08;如力学、碰撞、重力、流体动力学等&#xff09;的软件工具或库。 它的核心目标是在虚拟环境中逼真地模拟物体的运动和交互&#xff0c;广泛应用于 游戏开发、动画制作、虚…...

通过Wrangler CLI在worker中创建数据库和表

官方使用文档&#xff1a;Getting started Cloudflare D1 docs 创建数据库 在命令行中执行完成之后&#xff0c;会在本地和远程创建数据库&#xff1a; npx wranglerlatest d1 create prod-d1-tutorial 在cf中就可以看到数据库&#xff1a; 现在&#xff0c;您的Cloudfla…...

前端倒计时误差!

提示:记录工作中遇到的需求及解决办法 文章目录 前言一、误差从何而来?二、五大解决方案1. 动态校准法(基础版)2. Web Worker 计时3. 服务器时间同步4. Performance API 高精度计时5. 页面可见性API优化三、生产环境最佳实践四、终极解决方案架构前言 前几天听说公司某个项…...

1688商品列表API与其他数据源的对接思路

将1688商品列表API与其他数据源对接时&#xff0c;需结合业务场景设计数据流转链路&#xff0c;重点关注数据格式兼容性、接口调用频率控制及数据一致性维护。以下是具体对接思路及关键技术点&#xff1a; 一、核心对接场景与目标 商品数据同步 场景&#xff1a;将1688商品信息…...

定时器任务——若依源码分析

分析util包下面的工具类schedule utils&#xff1a; ScheduleUtils 是若依中用于与 Quartz 框架交互的工具类&#xff0c;封装了定时任务的 创建、更新、暂停、删除等核心逻辑。 createScheduleJob createScheduleJob 用于将任务注册到 Quartz&#xff0c;先构建任务的 JobD…...

c++ 面试题(1)-----深度优先搜索(DFS)实现

操作系统&#xff1a;ubuntu22.04 IDE:Visual Studio Code 编程语言&#xff1a;C11 题目描述 地上有一个 m 行 n 列的方格&#xff0c;从坐标 [0,0] 起始。一个机器人可以从某一格移动到上下左右四个格子&#xff0c;但不能进入行坐标和列坐标的数位之和大于 k 的格子。 例…...

Java - Mysql数据类型对应

Mysql数据类型java数据类型备注整型INT/INTEGERint / java.lang.Integer–BIGINTlong/java.lang.Long–––浮点型FLOATfloat/java.lang.FloatDOUBLEdouble/java.lang.Double–DECIMAL/NUMERICjava.math.BigDecimal字符串型CHARjava.lang.String固定长度字符串VARCHARjava.lang…...