Advertisement

ASBind

Started by May 25, 2006 01:31 PM
3 comments, last by gilad_novik 18 years, 6 months ago
Here is my version for binding c++ classes into AS. I'm using ctags to generate the list, and then I parse it. For now, it can only bind classes with methods\properties. It doesn't support other stuff yet (global functions, global properties, ...) To use, start the app, and open your header file (or drag-drop into the window). Select the classes/functions you want to support from the tree view, and hit "Generate". It you should see the result inside the output view. I didn't use many files to test it with, so if it doesn't parse your file, or generates wrong information, please send me your original header file so I'll be able to test. I'll upload the source soon too, so you'll be able to modify if you want to. you can download it here: http://gilad.gsetup.com/ASBind.zip Gilad
I don't see this sort of thing working for any non-trivial code. I tried it out and it seems to just be dumping the contents of the class declaration into binding calls. It doesn't understand operators, constructors, or destructors, and it doesn't translate templates or types into names angelscript can understand (for example, unsigned int is uint32 in angelscript).

I was pleased to discover that it detected overloaded methods and used asMETHODPR to resolve them.

Furthering that, one of AngelScript's greatest strengths is the ability to make the script interface different from the C++ interface. You can even bind methods that aren't actually part of the class using a wrapper. Any sort of automation takes that power away from the user.
Advertisement
It was meant as a starting point for binding classes. When I wanted to bind windows stuff (like CWindow for example), it would take a long time to write every function by hand. So I've used my tool to generate most of the stuff, and the rest I did by myself.

As you already mentioned, there is still no support for constructors/destructors/operators. I'm planning to support them too.

In addition, I'm planning to remplace types with AS types (unsigned int => int, BOOL => bool, and so on...)

I shouldn't do everything for the user, it should just save some time typing most of the obvious stuff.

Gilad
Will it be easy to hack the source to change the formatting of the output?
Sure, I'll upload the source soon so you can modify it.

This topic is closed to new replies.

Advertisement