Playing with Sqrat for a while, I've found out that it is not alltogether as nice as easy as it looked at first sight, at least not for us (or maybe I'm really just too stupid).
First, it is not trivial to bind
enum values, of which we have quite a number bound. You need to add each enum name with its proper value to the constant table. Not all values are contiguous either, and not all are in our own headers.
Basically, as far as
enum values go, we are left with the following choices:
- maintain the enum and its script binding separately
- use X-Macros
The first solution is error prone and a maintenance nightmare, the second solution is
moderately ugly and doesn't look like C++. Also it won't work for the wxWidgets enums that we bind (will have to do these by hand either way).
Also, giving X-Macros a try (which
kind of worked, too), I suddenly realized that Code::Blocks uses Unicode strings, so when a script is called, its identifiers should obviously be provided as
wchar_t.
Adding a
L wrapper generated "
note: no known conversion for argument 1 from 'const wchar_t [4]' to 'const SQChar* {aka const char*}'".
Oh oh, looks like I forgot compiling with
-DSQUNICODE.
Now, compiling with
-DSQUNICODE, it turns out that neither Squirrel nor Sqrat work properly in Unicode mode... Squirrel has a special codepath for MSVC to behave properly, and typedefs
wchar_t on every other compiler (no, I'm not joking, look at lines 116-125 in
squirrel.h), and Sqrat calls
sq_throwerror with ordinary C character strings, regardless of ANSI/Unicode mode (with
-DSQUNICODE, the function expects
const wchar_t*). Both issues break the build.
Ideas? Seriously, I must be making a mistake here, this cannot be
