Update MovementApi to use LuaBind
Another step towards completing #1579 which is just this for every part of the API.
So the core of the issue is the following:
- Updated Movement and its child types to be compatible with LuaBind. This was actually a bit of a trick,
type_name
caused some issues so I ended up giving its ownmodule_name
(which is a value we use) to work around that. The other examples of this (ex. Drawable) seemed to work as expect still. - Updated Entity to be compatible with LuaBind. Only the top level Entity, as that is the only one I needed at this time.
- Converted MovementApi to use LuaBind. Only interesting thing is that because of inheritance, sometimes you have to declare a wrapping function because the method type actually uses a parent class.
- Unified the implementation of
target_movement:set_target
andcircle_movement:set_center
because did pretty much the same thing in different ways. I guess one might have a slightly different interface now.
In addition I made the following not actually needed changes as part of the ongoing efforts to refine LuaBind itself (also, on top of these changes, after translation is done I will probably have to do another larger rework):
- Added
LUA_TO_C_BIND_AS
to explicitly provide the type argument toLUA_TO_C_BIND
. It actually sees very little use (one so far, another I can think of, so probably not very many by the end) but its definition is very quick so I'll try it. - Changed the implementation of
ArgContext
to just callLuaTools::arg_error
instead of trying to inline it. I don't know why this was done in the first place. It seems too large to inline every time. - Removed extra template arguments from implementations of
CheckContext
. I believe there was a version of this that used nesting templates instead of dynamic dispatch, but the type is fixed incheck_arg
so I figure it should be fixed here. (Note,ValueContext
is still a template, because it has a template parameter for other reasons.) - Removed
CheckContext::type_error
and moved it to the top level. I don't think it will ever be anything but that generic implementation, so I made it so there was one instance of that implementation. (Some calls did call the method directly, they now callLuaBind::type_error
.) - Removed
CheckContextImpl
, with all of the above changes it was now an empty shell. - Removed the index argument from
CheckContext::error
. Not only is it not used, but I don't think it should be used because that index is meaningless except at the top level and the context classes don't know if they are at the top level or not. So it is now only passed to the top level wrappers. - Added support for
const ExportedToLua&
types. This does not enable any new functionality, although you can perhaps write some clearer signatures with it (I did this at the end so there is very little of that here). I did it because it is basically even in complexity with the previous implementation and avoids some nasty error messages if you try it. - Updated how
test_shared_exportable
divided between is two cases, using abstract vs concrete instead of final vs non-final. This required some updates to theExportableToLua
type tree but the result is a closer and stricter match to the actual exported types.
I think that is everything.
Edited by Cluedrew Kenfar Ink