seqlua

annotate seqlua_c_example.c @ 23:29792283522f

Removed iterator(...) function; ipairs doesn't accept iterator triplets anymore
author jbe
date Thu Aug 21 20:01:52 2014 +0200 (2014-08-21)
parents 144f0bddee2b
children 44880bcfc323
rev   line source
jbe@0 1 #include <lua.h>
jbe@0 2 #include <lauxlib.h>
jbe@0 3 #include "seqlualib.h"
jbe@0 4 #include <stdio.h>
jbe@0 5
jbe@0 6 static int seqlua_c_example_printcsv(lua_State *L) {
jbe@0 7 seqlua_Iterator iter;
jbe@0 8 seqlua_iterloop(L, &iter, 1) {
jbe@0 9 if (seqlua_itercount(&iter) > 1) fputs(",", stdout);
jbe@0 10 fputs(luaL_tolstring(L, -1, NULL), stdout);
jbe@8 11 lua_pop(L, 1); // pop value that luaL_tolstring pushed onto stack
jbe@0 12 }
jbe@0 13 fputs("\n", stdout);
jbe@0 14 return 0;
jbe@0 15 }
jbe@0 16
jbe@0 17 int luaopen_seqlua_c_example(lua_State *L) {
jbe@0 18 lua_pushcfunction(L, seqlua_c_example_printcsv);
jbe@0 19 lua_setglobal(L, "printcsv");
jbe@0 20 return 0;
jbe@0 21 }

Impressum / About Us