I've a fairly common 2-dimensional floating point Vector class in my C++ code that I'm wrapping into SWIG.

For convenience's sake, I've added "in" typemaps that also let a Lua user pass a table into functions that expect a Vector2. The typecheck guarantees that there's a table that starts with at least 2 numbers, and the typemap converts that table to a Vector2.

The trick is that some functions (inconsistently across the C++ code) take a reference to the Vector (const Vector&).

I've found that I can lie in the interface files, so a function that is declared in C++ as "float Dot(const Vector2& v1, const Vector2& v2);" becomes "float Dot(Vector2 v1, Vector2 v2);" in the interface. Since const and references don't really mean anything to Lua, this works out ok.

However, I'd prefer to have the interface files match the C++ headers a little more closely, both for consistency's sake and so other contributors can add code more easily without having to learn about SWIG typemaps and why interface files need function parameters to be declared differently.

What's the usual strategy for this kind of wrapping? Do people maintain separate typemaps for the const/reference parameter and the normal one, or just use modified interface files?