From 561594bb943bfdc9c9b888c1eacc2a6d34ca882b Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 8 Oct 2016 15:57:43 +0100 Subject: [PATCH] [Minor] Allow to create fann from table of layers --- src/lua/lua_fann.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lua/lua_fann.c b/src/lua/lua_fann.c index 3d15c6417..51d42b573 100644 --- a/src/lua/lua_fann.c +++ b/src/lua/lua_fann.c @@ -116,8 +116,17 @@ lua_fann_create (lua_State *L) if (nlayers > 0) { layers = g_malloc (nlayers * sizeof (layers[0])); - for (i = 0; i < nlayers; i ++) { - layers[i] = luaL_checknumber (L, i + 2); + if (lua_type (L, 2) == LUA_TNUMBER) { + for (i = 0; i < nlayers; i ++) { + layers[i] = luaL_checknumber (L, i + 2); + } + } + else if (lua_type (L, 2) == LUA_TTABLE) { + for (i = 0; i < nlayers; i ++) { + lua_rawgeti (L, 2, i + 1); + layers[i] = luaL_checknumber (L, -1); + lua_pop (L, 1); + } } f = fann_create_standard_array (nlayers, layers); -- 2.39.5