summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-05-18 18:24:16 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-06-25 14:36:08 +0900
commitc25467ff5c58b523fdb50ca074588567ab72d799 (patch)
treead77f0d58465b67fe12a66e3006a9d98b5787bfd /src
parent8716be5193650bac671aee4538ed66aa380a4059 (diff)
Evas filters: Implement very basic print function
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/filters/evas_filter_parser.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/lib/evas/filters/evas_filter_parser.c b/src/lib/evas/filters/evas_filter_parser.c
index 1f9f9d3..16f8071 100644
--- a/src/lib/evas/filters/evas_filter_parser.c
+++ b/src/lib/evas/filters/evas_filter_parser.c
@@ -1820,6 +1820,50 @@ _lua_generic_function(lua_State *L, const char *name,
1820 return instr->return_count; 1820 return instr->return_count;
1821} 1821}
1822 1822
1823static int
1824_lua_print(lua_State *L)
1825{
1826 Eina_Strbuf *s;
1827 int nargs = lua_gettop(L);
1828 int i;
1829
1830 if (nargs < 1)
1831 {
1832 DBG("LUA: (nothing)");
1833 return 0;
1834 }
1835
1836 s = eina_strbuf_new();
1837
1838 for (i = 1; i <= nargs; i++)
1839 {
1840 if (lua_isstring(L, i))
1841 eina_strbuf_append(s, lua_tostring(L, i));
1842 else if (lua_isnumber(L, i))
1843 {
1844 double d = lua_tonumber(L, i);
1845
1846 if (fabs(d - floor(d)) < 0.000001)
1847 eina_strbuf_append_printf(s, "%d", (int) d);
1848 else
1849 eina_strbuf_append_printf(s, "%f", d);
1850 }
1851 else
1852 eina_strbuf_append(s, "<>");
1853 eina_strbuf_append_char(s, ' ');
1854 }
1855
1856 INF("LUA: %s", eina_strbuf_string_get(s));
1857 eina_strbuf_free(s);
1858
1859 return 0;
1860}
1861
1862static const struct luaL_Reg printlib[] = {
1863 { "print", _lua_print },
1864 { NULL, NULL }
1865};
1866
1823#define LUA_GENERIC_FUNCTION(name) \ 1867#define LUA_GENERIC_FUNCTION(name) \
1824static int \ 1868static int \
1825_lua_##name(lua_State *L) \ 1869_lua_##name(lua_State *L) \
@@ -1860,6 +1904,11 @@ _lua_state_create(Evas_Filter_Program *pgm)
1860 luaopen_string(L); 1904 luaopen_string(L);
1861 luaopen_math(L); 1905 luaopen_math(L);
1862 1906
1907 // Implement print
1908 lua_getglobal(L, "_G");
1909 luaL_register(L, NULL, printlib);
1910 lua_pop(L, 1);
1911
1863 // Store program 1912 // Store program
1864 lua_pushlightuserdata(L, (void *) &this_is_not_a_cat); 1913 lua_pushlightuserdata(L, (void *) &this_is_not_a_cat);
1865 lua_pushlightuserdata(L, pgm); 1914 lua_pushlightuserdata(L, pgm);