lua : huge rework of the type API

this is needed to be able to use introspection

This should have no impact on the user