ultralight-ux / Ultralight

Lightweight, high-performance HTML renderer for game and app developers.
https://ultralig.ht
4.69k stars 197 forks source link

Generate automatic language bindings for C API via SWIG #310

Open adamjs opened 4 years ago

adamjs commented 4 years ago

Use SWIG to generate automatic, low-level language bindings for our C API to simplify the task of maintaining bindings for other languages.

SWIG supports the following language targets we care about:

Janrupf commented 4 years ago

Would not recommend doing Java with SWIG... I tried that and it was horrible. With Java/JNI it is very easy to wrap the C++ API directly and bind C++ pointers to Java objects. The SWIG wrapper generates a lot of weird types which makes using it complicated.

adamjs commented 4 years ago

Yeah same deal with C#, SWIG requires a lot of massaging in their language target scripts to produce usable output (don't get me started on the crazy hoops they force you to go through just to have sane bindings for callbacks/listeners).

Ignoring ABI concerns, the C++ API is definitely more "wrappable" for similar class-based languages like C# and Java-- I'm open to using other alternatives for certain language targets (SWIG can't even target Rust so it's no panacea).

My main goal is just to reduce the burden of maintainability so we have some automatic bindgen running on the buildbots that can be used instead of the raw C/C++ API (which is obviously going to break often as trunk is updated).