1
General / Making a Lua binding, questions
« on: June 06, 2012, 06:47:44 am »
Hi,
For my game engine, I'm preparing a sort of Lua binding so that the scripter will be able to create and manipulate SFML objects directly.
I don't have much time at the moment and only started recently so it cannot do much yet, but here's a Windows executable version of the canonical demo translated in Lua: Download link.
What brings me here is a problem I encountered when trying to bind sf::Window, and more specifically its sf::Window(WindowHandle, const ContextSettings&) constructor. The problem here is WindowHandle, which gives me a compile-time error:
Looking a bit at the code of WindowHandle.hpp I tried to define _WIN32, but it didn't solve the problem. I'm not sure where to go from here, any hint Laurent?![Smiley :)](https://www.sfml-dev.org/forums/Smileys/default/smiley.gif)
Also as you can see, apart from constructors all functions calls have to be explicit (no support for default arguments). I think the only solution is to decompose all functions with default values to overloaded functions. I'd also like to define a getType() static member function for all SFML classes to do some dynamic typechecking and yield better error messages.
Since I'd like to avoid modifying the SFML source for obvious maintenance reasons, I'm thinking of creating a wrapper class for each SFML class that would inherit publicly and declare these new member functions. It'll be quite a bit of work though, so I'm wondering if anyone has got a better idea on how to do that before it's too late?![Tongue :P](https://www.sfml-dev.org/forums/Smileys/default/tongue.gif)
Thanks in advance!
For my game engine, I'm preparing a sort of Lua binding so that the scripter will be able to create and manipulate SFML objects directly.
I don't have much time at the moment and only started recently so it cannot do much yet, but here's a Windows executable version of the canonical demo translated in Lua: Download link.
What brings me here is a problem I encountered when trying to bind sf::Window, and more specifically its sf::Window(WindowHandle, const ContextSettings&) constructor. The problem here is WindowHandle, which gives me a compile-time error:
Code: [Select]
error: invalid use of incomplete type 'struct HWND__'
Looking a bit at the code of WindowHandle.hpp I tried to define _WIN32, but it didn't solve the problem. I'm not sure where to go from here, any hint Laurent?
![Smiley :)](https://www.sfml-dev.org/forums/Smileys/default/smiley.gif)
Also as you can see, apart from constructors all functions calls have to be explicit (no support for default arguments). I think the only solution is to decompose all functions with default values to overloaded functions. I'd also like to define a getType() static member function for all SFML classes to do some dynamic typechecking and yield better error messages.
Since I'd like to avoid modifying the SFML source for obvious maintenance reasons, I'm thinking of creating a wrapper class for each SFML class that would inherit publicly and declare these new member functions. It'll be quite a bit of work though, so I'm wondering if anyone has got a better idea on how to do that before it's too late?
![Tongue :P](https://www.sfml-dev.org/forums/Smileys/default/tongue.gif)
Thanks in advance!