seqlua

view seqlua_c_example.c @ 51:06c5f2f9ec41

Added Lua version number 5.2 to README file
author jbe
date Mon Aug 25 12:12:46 2014 +0200 (2014-08-25)
parents 45855c3e5cb8
children 3362ec36cb09
line source
1 #include <lua.h>
2 #include <lauxlib.h>
3 #include <seqlualib.h>
4 #include <stdio.h>
6 int seqlua_c_example_printcsv(lua_State *L) {
7 seqlua_Iterator iter;
8 seqlua_iterloop(L, &iter, 1) {
9 if (seqlua_itercount(&iter) > 1) fputs(",", stdout);
10 fputs(luaL_tolstring(L, -1, NULL), stdout);
11 // two values need to be popped (the value pushed by
12 // seqlua_iternext and the value pushed by luaL_tolstring)
13 lua_pop(L, 2);
14 }
15 fputs("\n", stdout);
16 return 0;
17 }
19 int luaopen_seqlua_c_example(lua_State *L) {
20 lua_pushcfunction(L, seqlua_c_example_printcsv);
21 lua_setglobal(L, "printcsv");
22 return 0;
23 }

Impressum / About Us