Jump to content

ToLua++ Generator


Josh
 Share

Recommended Posts

What it does:

Scans all header files, generates a ToLua++ pkg file, and generates Lua binding code.

How to use:

Extract all files to your source code directory and run tolua++.bat

To expose a class you must add //lua after the class and after any members or methods you want to expose.

Example:

class foo//lua
{
public:
	int thing;//lua
	void bar();//lua
};

tolua++.zip

  • Confused 1
  • Upvote 5

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 4 weeks later...
  • 5 months later...
15 hours ago, Charrua said:

is there a similar tool for linux?

https://bitbucket.org/Codeblockz/toluapkggenerator2

This should compile on Monodevelop 2.2 or greater, although I haven't tested it! it adds more support like enumerations, methods/variables that are just in namespaces and not classes, size_t and other fixed size integer support, nested namespaces and classes (Although the #define you'll see by default makes it generate classes outside of all modules (i.e: hidden behind no Lua table), and methods in namespaces are only in the lowest namespace. (This is only by default. You can make it generate the full hierarchy in Lua by commenting out the define ```MINIMAL_NAMESPACE_NESTING``` at the top of "Program.cs".

Also it says "Unions are unsupported", but this is only partially true, look what Josh did in Vec3.h to expose the unions using a comment like: //float x, r, y, g, z, b;//lua

The same works here.

I strongly recommend you use this along with it: https://bitbucket.org/Codeblockz/fixtoluanamespaces

The instructions for the generator explain how. to add it (Simply compile & drop in same directory as ToLuaPkgGenrator2 executable). It's (I think) like Josh's FixGlueCode or whatever script.

if I were to tag something like

class AClass { //lua
    MyNamespace::SomeClass member; //lua
}

This second application will go through the generated ToLua bindings and rename "MyNamespace::SomeClass" to "SomeClass" in strings, not in the code... making sure ToLua++ knows that they represent the same class. Why don't I make the generator simply not write this preceding namespace to the generated pkg files? Well because ToLua++ still needs it to be named this way in code and the generator only adds 'using' statements for namespaces based on hierachy, it currently doesn't support using statements being generated for cases like this as it'd be much more complicated to handle all scenarios. The second application was the simpler solution.

You'll have to write your own bash script however that's equivalent to the batch script provided if you want to use this on Linux! Should be easy. If you do end up getting it running on Linux a share of the Bash would be appreciated, but not necessary! (As one of my projects unrelated to LE uses it and will need it to work on Linux as well.)

Link to comment
Share on other sites

thank's for your time and generator

yesterday i wrote a very simple class to start doing some tests and found that there is a generator for windows and as i have to write th .pkg by hand (for a simple test class is not so much work) i just be curios about the same tool for linux.

if I get it to work, in case i use it i'll will update here or on your thread, but, you know, if i already make it work by hand... and my class will not be so much complicated... chances are that i let it as is for a while :)

 

thank's again

 

Juan

Paren el mundo!, me quiero bajar.

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...