annotate seqlua_c_example.c @ 57:da4b9d6a5b7e
Fixed bug due to problem combining luaL_buffinit with seqlua_iterinit
author |
jbe |
date |
Tue Jan 05 04:26:49 2016 +0100 (2016-01-05) |
parents |
92ce3958aca7 |
children |
|
rev |
line source |
jbe@0
|
1 #include <lua.h>
|
jbe@0
|
2 #include <lauxlib.h>
|
jbe@50
|
3 #include <seqlualib.h>
|
jbe@0
|
4 #include <stdio.h>
|
jbe@0
|
5
|
jbe@25
|
6 int seqlua_c_example_printcsv(lua_State *L) {
|
jbe@0
|
7 seqlua_Iterator iter;
|
jbe@54
|
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@25
|
11 // two values need to be popped (the value pushed by
|
jbe@25
|
12 // seqlua_iternext and the value pushed by luaL_tolstring)
|
jbe@25
|
13 lua_pop(L, 2);
|
jbe@0
|
14 }
|
jbe@0
|
15 fputs("\n", stdout);
|
jbe@0
|
16 return 0;
|
jbe@0
|
17 }
|
jbe@0
|
18
|
jbe@0
|
19 int luaopen_seqlua_c_example(lua_State *L) {
|
jbe@0
|
20 lua_pushcfunction(L, seqlua_c_example_printcsv);
|
jbe@0
|
21 lua_setglobal(L, "printcsv");
|
jbe@0
|
22 return 0;
|
jbe@0
|
23 }
|