SFML community forums

General => General discussions => Topic started by: Trass3r on January 20, 2011, 12:58:56 pm

Title: SWIG
Post by: Trass3r on January 20, 2011, 12:58:56 pm
Considering how much work it is to create and maintain a wrapper for sfml, would SWIG (http://www.swig.org/) be an alternative to contemplate?
This would open it to more programming languages and bring stuff like cross-language polymorphism for free.
Title: SWIG
Post by: Laurent on January 20, 2011, 01:56:25 pm
I think it has already been discussed, probably a long time ago.

Basically, I don't want to use such an abstraction because it doesn't take advantage of each language's specific features. I prefer to have bindings that are fine-tuned and 100% compliant with the target language, that perfect clones of the C++ API in every language.

Experience on current bindings showed that many things need to be redesigned and customized according to the target language.
Title: SWIG
Post by: Trass3r on January 20, 2011, 04:05:10 pm
You mean like special property setters and getters like in D and C#?
I thought the generators would do that automatically, gotta test it sometime.

Another issue that comes to my mind is addon libraries. E.g. SFGUI looks very promising, but doesn't have a wrapper.
Title: SWIG
Post by: Laurent on January 20, 2011, 04:12:50 pm
Quote
You mean like special property setters and getters like in D and C#?

Yes, and much more. Another example: transforming all the LoadFromXxx functions to constructors (or Create functions in the C binding). I doubt this can be done automatically.

And what about bindings that must use the C binding, not the C++ API?

Quote
Another issue that comes to my mind is addon libraries. E.g. SFGUI looks very promising, but doesn't have a wrapper.

External libraries can use whatever they like to create their bindings.
Title: SWIG
Post by: Trass3r on January 20, 2011, 04:44:34 pm
Quote from: "Laurent"
Another example: transforming all the LoadFromXxx functions to constructors (or Create functions in the C binding). I doubt this can be done automatically.

If these functions are supposed to be constructors in other languages, why aren't they constructors in C++?

Quote
And what about bindings that must use the C binding, not the C++ API?

SWIG supports D, so it has to (and I'm pretty sure it does) generate a C layer in between.

Quote
External libraries can use whatever they like to create their bindings.

Yep, of course, I just wonder if it works flawlessly.