seqlua

view seqlua_c_example.c @ 45:35eb59c51be6

Minor change in README
author jbe
date Mon Aug 25 04:02:06 2014 +0200 (2014-08-25)
parents 44880bcfc323
children 45855c3e5cb8
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