lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Tim,

I'm sorry for the "weak" documentation. I'll improve this as soon as I
have some more time (and I feel it's mature). In the meantime, here is
a usage example

https://github.com/rubyk/rubyk/blob/master/modules/bind.rb

The steps involved are:

1. generate xml documentation with Doxygen

2. create a Ruby script and require 'dub' (installed with 'sudo gem
install dub').
require 'rubygems'
require 'dub'
require 'dub/lua'

3. parse namespace

namespace = Dub.parse(path_to_namespace.xml)

4. bind to a generator

Dub::Lua.bind(namespace)

5. generate bindings for functions/classes:

# writes bindings 'Matrix' class
File.open('bindings/Matrix.cpp', 'wb') do |f|
  f.puts namespace[:Matrix]
end

There are some more options to customize the output (you can even
provide your own template) but the basics are there.

Gaspard

On Wed, Dec 15, 2010 at 6:32 PM, Tim Mensch <tim-lua-l@bitgems.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 12/15/2010 1:49 AM, Gaspard Bucher wrote:
>
>> You haven't considered "dub" (http://rubyk.org/en/project311.html).
>
>
>
>
>
>
> Because it's not listed on the wiki [1]. Anyone can edit the Wiki; it
> certainly deserves a link there with a relevant description.
>
>> The idea behind "dub" is that it parses Doxygen xml output and then it
>> can resolve templates and other typedefs. You can precisely control
>> the code that is generated by writing simple ERB templates...
>
>
>
>
>
>
> Interesting. The template seems to have a block for a destructor no
> matter what; can it support classes that Lua never destroys? I'd like to
> be able to eliminate the destructor code from any classes that are
> supposed to be held in shared_ptrs, so that I know that Lua isn't EVER
> going to destroy them outside of the shared_ptrs.
>
>> The tool is pretty new and requires optimization for very large source
>> trees but I managed to build the bindings for OpenCV with it and I am
>> using it all over in Rubyk.
>
>
>
>
>
> It also seems pretty light on documentation. As in I couldn't find any
> - -- not even a very basic "how to use it".
>
> I like the core idea; Doxygen is going to be a much better parser to use
> than any smaller project would likely be able to generate.
>
> Also, I used to be a big fan of Ruby, and I can at least edit Ruby files
> without shooting myself in the foot (ahem, Python), but I'm still
> disappointed that the code isn't written in Lua; I understand why you'd
> use Ruby for it, but it adds another bit of complexity to a project
> (Doxygen + Ruby + Lua + C++ + Makefiles + Rakefiles -- plus Java in my
> case, since I'm on Android).
>
> Tim
>
> [1] http://lua-users.org/wiki/BindingCodeToLua
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJNCPutAAoJENSbqLBCyKKsf9UIAJQnFRy0lryrecI9azSwM7Cm
> Cx9R2aYXPPT0GXGaGpZEkzqIdkbpAVyH+djPg5RuTcCombmd7VgSYZd1WDLqZBcS
> m7nJAUDYFboVD4/E0TKou6/3kJAFiinNwl2556x6PQIztIispgQs55IQEmgHVvba
> bEeXHbN6O1Au6FBenalf3es9DVtPDHso77wQUJKaoo1Zi6PyFeYYOW7cPQ3b1Tfi
> xGEVgDS8xNOJbuJ2Dpu7RTPZU5WO9QCGMHHeXIatI2rMcbfzkAr7jrVfwY8P5uvn
> k/KZQkvsKJR6ZfRjOnO9rFIuOg6jrLwQMWZQpuEO1ikdWgq1oNBnEhhWMFJbI3c=
> =SuKS
> -----END PGP SIGNATURE-----
>
>