Jump to content

[Release] ToLua++ binding generator. [C#]


Crazycarpet
 Share

Recommended Posts

Hey all! So recently I've been using Josh's BlitzMax ToLua++ package generator but it just didn't quite do everything I needed, so based off his design I wrote my own C# version that supports a little more variety of situations.

 

The usage is the same! just tag classes (or structs), and public members with the '//lua' comment in your C++ header files and follow the instructions provided on the BitBucket page. After you implement this into your project you will be-able to generator all your ToLua++ bindings with 1-click.

 

The one thing you have to do manually is open the generated C++ files and add any required includes as I haven't made a clean way for this to be done automatically (yet).

 

You can get ToLuaPkgGenerator here. (Windows Only)

 

Just a simple tool I wrote to make my life easier, hope others find it useful as well!

Here's an example of the pkg file generated for the Leadwerks namespace: https://pastebin.com/NjpE8L8d

 

Edit:

- ToLuaPkgGenerator no longer removes default arguments but now rather replaces unsupported types with the nearest supported one. (In the pkg files, your code is never modified by these programs!)

- Todays update will also encase namespaced classes in modules to further prevent ambiguity issues.

(i.e: System:Print() will now be Leadwerks.System:Print())

** This doesn't overload the default bindings Leadwerks provides so the provided Lua files will still work. **

 

Edit #2:

- A naive solution to a namespace issue can be found in my BB repositories called FixToLuaNamespaces. Edit the batch file provided in ToLuaPkgGenerator, uncommenting out the line that executes this application on each generated cpp gluecode file. You simply drop the compiled FixToLuaNamespaces.exe file in the same directory and the ToLuaPkgGenerator.exe file.

 

- In this solution when ToLuaPkgGenerator generates a return type preceded by a namespace like Leadwerks::Sound. FixToLuaNamespaces would replace the strings "Leadwerks::Sound" with "Sound" assuming that's the way ToLua++ named them when they were exposed.

  • Upvote 3
Link to comment
Share on other sites

WIP LuaBridge binding generator aswell. https://bitbucket.org/Codeblockz/luabridgegenerator

Luabridge - https://github.com/vinniefalco/LuaBridge

 

ToLua++ is better though imo, it handles overloaded methods and constructors, LuaBridge does not... LuaBridge is however better for sheer speed.

 

Note that this won't currently work because it doesn't remove overloaded methods... but it will in a few days.

 

Edit: STILL haven't got around to this, i plan on forking toLua++ to add function overloading support instead I just haven't had time! :(

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...