Results 1 to 7 of 7

Thread: JetLua - Delphi Lua SDK

  1. #1

    Post JetLua - Delphi Lua SDK

    logo256.png

    Download
    https://github.com/tinyBigGAMES/JetLua

    Overview
    JetLua is a Lua SDK for Delphi to allow easy integration for Lua scripting inside your Delphi application.

    Features

    • Support for Delphi 10.4 Sydney
    • Only two minimal interfaces to access feature set (IJetLua & IJetLuaContext)
    • You can auto register class/object JetLua routines
    • If you have created an AutoSetup class function, it's automatically called during registration where you can do global setup operations
    • You can declare tables in "table.table.table" format
    • You can declare global/table variables and access them
    • You can check the exists of global/table variables and routines
    • You can call global/table functions with a variable number of parameters
    • You can pull and push data from and to the Lua stack via the IJetLuaContext interface
    • You can load source code from a file, string and buffer
    • You can import Lua modules
    • Source is JIT compiled using moonjit
    • You can compile Lua sources (including imported modules) and bind to an EXE for stand-alone distribution
    • You can add version information, an icon, enable runtime-themes and high DPI aware support to EXEs


    You can find more information, updates, availability on our website.

    JetLua_DelphiIDE.jpg
    Last edited by drezgames; 15-08-2020 at 02:10 AM.

  2. #2
    This looks intruiging and impressively simple.

    Is any freepascal & crossplatform support planned?
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  3. #3
    Quote Originally Posted by JernejL View Post
    This looks intruiging and impressively simple.

    Is any freepascal & crossplatform support planned?
    Hi, thanks. Happy that you can see where I'm going with it. My goal was to reduce the complexly down to a fast, fun and easy way to access Lua from pascal.

    Yes, I've made substantial investments this year getting setup for cross-platform development. Mostly desktop Windows, Linux and macOS.
    20200621_233216.jpg

    If I can continue getting feedback I should be able to get it ported to and working on other platforms. At this time, initial development is being done on Windows. I've not yet test freepascal, but in theory the current version should be able to work assuming the last versions of freepascal can support the TJetLuaValue structure with operator overloading. Passing TClass and TObject to those auto register function most likely will not work. There is already one routine that can manually register a global routines, which should work. I can add another one to manually register table routines. I will look more into this and see what I can come up with. Testing and feedback would be invaluable for me if your up for it.

  4. #4
    @JernejL:

    Good news, I got the interface routines down to the now probably the minimum that I can:

    Code:
      { IJetLuaContext }
      IJetLuaContext = interface
        ['{6AEC306C-45BC-4C65-A0E1-044739DED1EB}']
    
    
        function  PushCount: Integer;
        procedure ClearStack;
        procedure PopStack(aCount: Integer);
        function  GetStackType(aIndex: Integer): TLuaType;
    
    
        function  GetValue(aType: TJetLuaValueType; aIndex: Integer): TJetLuaValue;
        procedure PushValue(aValue: TJetLuaValue);
    
    
        procedure SetTableFieldValue(aName: PChar; aValue: TJetLuaValue; aIndex: Integer);
        function  GetTableFieldValue(aName: PChar; aType: TJetLuaValueType; aIndex: Integer): TJetLuaValue;
      end;
    
    
      { TLuaFunction }
      TJetLuaFunction = procedure(aLua: IJetLuaContext) of object;
    
    
      { IJetLua }
      IJetLua = interface
        ['{671FAB20-00F2-4C81-96A6-6F675A37D00B}']
    
    
        procedure Reset;
    
    
        procedure LoadFile(aFilename: PChar; aAutoRun: Boolean = True);
        procedure LoadString(aData: PChar; aAutoRun: Boolean = True);
        procedure LoadBuffer(aData: Pointer; aSize: NativeUInt; aAutoRun: Boolean = True);
    
    
        procedure Run;
    
    
        function  RoutineExist(aName: PChar): Boolean;
        function  Call(aName: PChar; const aParams: array of TJetLuaValue): TJetLuaValue;
    
    
        function  VariableExist(aName: PChar): Boolean;
    
    
        procedure SetVariable(aName: PChar; aValue: TJetLuaValue);
        function  GetVariable(aName: PChar; aType: TJetLuaValueType): TJetLuaValue;
    
    
        procedure RegisterRoutine(aName: PChar; aRoutine: TJetLuaFunction);
    
    
        procedure RegisterRoutines(aClass: TClass); overload;
        procedure RegisterRoutines(aObject: TObject); overload;
        procedure RegisterRoutines(aTables: PChar; aClass: TClass; aTableName: PChar=nil); overload;
        procedure RegisterRoutines(aTables: PChar; aObject: TObject; aTableName: PChar=nil); overload;
    
    
        procedure AddVerInfo(aValue: Boolean);
        procedure SetNoConsole(aValue: Boolean);
        procedure SetVerInfo(aCompanyName: PChar; aFileVersion: PChar;
          aFileDescription: PChar; aInternalName: PChar; aLegalCopyright: PChar;
          aLegalTrademarks: PChar; aOriginalFilename: PChar; aProductName: PChar;
          aProductVersion: PChar; aComments: PChar);
        procedure SetExeFilename(aFilename: PChar);
        procedure SetIconFilename(aFilename: PChar);
        procedure EnableRuntimeThemes(aValue: Boolean);
        procedure EnableHighDPIAware(aValue: Boolean);
    
    
        procedure Compile(aSourceFilename: PChar; aPayloadFilename: PChar);
    
    
        function  HasPayload: Boolean;
        procedure RunPayload;
      end;
    Bad news:
    I did some initial tests and in it's present form, it will not work with freepascal, sigh. It's currently taking advantage of a lot of Delphi'ish features. Hopefully at some point I can get it working with freepascal.

  5. #5

  6. #6
    @JernejL

    I added this new routine that allows Lua function registration in freepascal:

    Code:
    procedure IJetLua.RegisterRoutine(aName: PChar; aData: Pointer; aCode: Pointer);
    So far so good. I will have to do more testing. The IJetLua.RegisterRoutines methods (the ones that take TClass and TObject params) take advantage of Delphi's extended RTTI to scan and find the JetLua function signatures for auto registration. With the added routine above, it now should be possible to implement auto registration in freepascal. Scan for the routines and call the above routine to register them. Does freepascal have extended RTTI like Delphi?
    Last edited by drezgames; 16-08-2020 at 02:05 PM.

  7. #7
    I know it has some RTTI, but i rarely dealt with that, it's question more suitable for lazarus forums.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL