seqlua

annotate seqlua_c_example.c @ 32:3ff7cec8d3ce

Do not respect __len metamethods
author jbe
date Sun Aug 24 00:00:43 2014 +0200 (2014-08-24)
parents 44880bcfc323
children 45855c3e5cb8
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@25 6 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@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 }

Impressum / About Us