[vlc-devel] [vlc-commits] lua: use luaL_checkint() where applicable

Filip Roséen filip at atch.se
Wed Aug 17 18:00:35 CEST 2016


Hi Remi,

On 16/08/14 16:19, Rémi Denis-Courmont wrote:

> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Aug 14 17:18:49 2016 +0300| [520b13a2ca88fc63ba3c1287e9314fbb2777c85d] | committer: Rémi Denis-Courmont
> 
> lua: use luaL_checkint() where applicable
> 
> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=520b13a2ca88fc63ba3c1287e9314fbb2777c85d
> ---
> 
>  modules/lua/demux.c         |  4 ++--
>  modules/lua/libs/dialog.c   | 14 +++++++-------
>  modules/lua/libs/net.c      | 16 ++++++++--------
>  modules/lua/libs/osd.c      |  4 ++--
>  modules/lua/libs/playlist.c | 10 +++++-----
>  modules/lua/libs/stream.c   |  2 +-
>  modules/lua/libs/volume.c   |  2 +-
>  7 files changed, 26 insertions(+), 26 deletions(-)

The precense of `luaL_checkint` is conditionally enabled only if
`LUA_COMPAT_APIINTCASTS` is defined for *lua* versions `>= 5.3.0`; as
such these changes breaks builds on system that have such version
present.

See the below for more information.

  - http://www.lua.org/manual/5.3/manual.html#8.3

---------------------------------------------------------------------

Earlier in the log
---------------------------------------------------------------------

Usage of `luaL_checkint` was replaced with `luaL_checkinteger` in the
past by the changes in the below linked commit:

  - http://git.videolan.org/?p=vlc.git;a=commit;h=2468da5

Looking earlier in the log, `LUA_COMPAT_APIINTCASTS` was defined by
the below (but effectivelly removed by `2468da5`):

 - http://git.videolan.org/?p=vlc.git;a=ocmmit;h=41caaa08


---------------------------------------------------------------------

Question
---------------------------------------------------------------------

 - Why was it decided to effectively roll back the changes introduced
   by `2468da5` while not taking `41caaa08` into account?

 - Is it a concious decision to not support`lua >= 5.3.0`?

---------------------------------------------------------------------

My thoughts
---------------------------------------------------------------------

If we want to use `luaL_checkint` while still supporting `lua >=
5.3.0` we should `#define LUA_COMPAT_APIINTCASTS` in
`modules/lua/vlc.h` in order to successfully build the relevant code
on the affected versions.

Though, given that the function is effectively deprecated in later
versions, it certainly (imo) makes more sense to introduce a helper
function (since such seems to be lacking in the lua api), that checks
whether or not the `lua_Integer` fits inside `int`, and if it does
returns a value of type `int` (otherwise errors).

Best Regards,\
Filip Roséen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20160817/5a69f3c0/attachment.html>


More information about the vlc-devel mailing list