[vlc-commits] lua: reorder to avoid forward declaration

Rémi Denis-Courmont git at videolan.org
Wed Mar 6 21:57:38 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Mar  6 22:24:05 2019 +0200| [cb105cd83713879061ffd771737a7aabef06b7d5] | committer: Rémi Denis-Courmont

lua: reorder to avoid forward declaration

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cb105cd83713879061ffd771737a7aabef06b7d5
---

 modules/lua/libs/objects.c | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/modules/lua/libs/objects.c b/modules/lua/libs/objects.c
index d385ed9061..4e85a648ba 100644
--- a/modules/lua/libs/objects.c
+++ b/modules/lua/libs/objects.c
@@ -42,6 +42,27 @@
 /*****************************************************************************
  * Generic vlc_object_t wrapper creation
  *****************************************************************************/
+
+int (vlclua_push_vlc_object)(lua_State *L, vlc_object_t *p_obj)
+{
+    vlc_object_t **udata =
+        (vlc_object_t **)lua_newuserdata(L, sizeof (vlc_object_t *));
+
+    *udata = p_obj;
+
+    if (luaL_newmetatable(L, "vlc_object"))
+    {
+        /* Hide the metatable */
+        lua_pushliteral(L, "none of your business");
+        lua_setfield(L, -2, "__metatable");
+        /* Set the garbage collector if needed */
+        lua_pushcfunction(L, vlclua_object_release);
+        lua_setfield(L, -2, "__gc");
+    }
+    lua_setmetatable(L, -2);
+    return 1;
+}
+
 static int vlclua_object_release( lua_State *L )
 {
     vlc_object_t **p_obj = (vlc_object_t **)luaL_checkudata( L, 1, "vlc_object" );
@@ -88,25 +109,6 @@ static int vlclua_get_input( lua_State *L )
     return 1;
 }
 
-#undef vlclua_push_vlc_object
-int vlclua_push_vlc_object( lua_State *L, vlc_object_t *p_obj )
-{
-    vlc_object_t **udata = (vlc_object_t **)
-        lua_newuserdata( L, sizeof( vlc_object_t * ) );
-    *udata = p_obj;
-
-    if( luaL_newmetatable( L, "vlc_object" ) )
-    {
-        /* Hide the metatable */
-        lua_pushliteral( L, "none of your business" );
-        lua_setfield( L, -2, "__metatable" );
-        /* Set the garbage collector if needed */
-        lua_pushcfunction( L, vlclua_object_release );
-        lua_setfield( L, -2, "__gc" );
-    }
-    lua_setmetatable( L, -2 );
-    return 1;
-}
 static int vlclua_get_vout( lua_State *L )
 {
     input_thread_t *p_input = vlclua_get_input_internal( L );



More information about the vlc-commits mailing list