Advertisement

[Library Announcement] Binding Generator Library for AngelScript

Started by November 11, 2024 05:35 PM
3 comments, last by WitchLord 1 week, 5 days ago

I've made a binding generator for AngelScript at https://github.com/HenryAWE/asbind20.

The basic feature is almost complete. The library is preparing for its first release. I think it is worth to share this library here, as well as asking for suggestion & feedback.

Although the interface of AngelScript is very friendly to C++ comparing to most binding APIs from other script languages, it still needs many additional proxy functions (e.g. when binding a constructor). However, most of these proxies have similar logic, so they can be generated by some template tricks.

This library provides tools for calling script function. You won't need to manually choose asIScriptContext::SetArgXxx() / asIScriptContext::GetReturnXxx() with correct types. It also has RAII utilities for managing lifetime of asIScriptContext.

In general, my library aims to automate everything that can be generated by template meta-programing. You can check the README in repository for further information.

None

Nice! 🙂

I'll need to take a closer look at this later on, but I'll definitely add a link to it on the “Further resources” page.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

WitchLord said:

Nice! 🙂

I'll need to take a closer look at this later on, but I'll definitely add a link to it on the “Further resources” page.

Thanks.

I have a question when writing the binding generator. If the proxy function, such as a wrapper for constructor, is auto-generated, which native calling convention is preferred?

I noticed that the official add-on and documentation seems to prefer asCALL_CDECL_OBJLAST. In my past experience, many C++ libraries put the parameter equivalent to this at first when simulating a member function (i.e. method) using global function. The utilities from standard library such as std::invoke also treats the first argument as class object when needed. Is putting the object parameter at the last position have advantage in performance or portability?

None

There is no specific reason for using one or the other. Both work equally well. It is just a matter of preference.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement