before the ThemeMetric templates that use them. That's broken
and unreasonable, so change this around a bit and make FromStack
(and Push) templates.
Push() takes a bit of a trick. Some Push overloads push the
actual value: scalars (int, float), RageColor (pushes a table).
Others--most of them--push a reference to a C++ object. We
want the scalars to have a reference parameter type, so we
don't make extra copies of things like RageColor when we push
them. We need to pass C++ objects by pointer (we need to
push the actual object's pointer, not a pointer to a copy).
Further, pushing a scalar is a const operation, but pushing
a reference to an object is not.
To do both with the same template, we handle objects with
this slightly odd template:
template<> void LuaHelpers::Push<T*>( lua_State *L, T *const &pObject );
The actual overload (T) is eg. "Actor*"; this fits within the
general prototype, "Push(lua_State *L, const T &object)", giving
us a const reference to a (non-const) pointer to Actor, and we're
conceptually pushing the pointer.
The net effect of this is that 1: what was before compile errors
now becomes link time errors, but 2: these specializations
don't have to be in the headers (except for new ones for
Preference and BroadcastOnChange).
Design goals are: minimal overhead (one table); minimal extra code to use
it (two lines in the header, to have a space to store a reference to the
table), same API for classes with and without a table; allow switching to
a table-bound class without derived classes having to know about it; keep
zero per-object overhead for classes that don't need it.
of its base classes, set __index in the methods table to point to the base class's
methods table. This has a few important advantages. First and most importantly,
types don't need access to the Luna type of their base to derive from it, so these
definitions don't have to be in the headers, and probably don't need to be
templated. Second, you can say:
function Actor:queue_rotate()
self:linear(0.5)
self:rotationz( 180 )
end
OnCommand=x,100;queue_rotate
This partially worked previously, but wasn't inherited; a function defined for
Actor wouldn't work for BitmapText.
(changes that use this in a few minutes)