seqlua

diff seqlua_c_example.c @ 0:47f9b323d68c

Initial commit
author jbe
date Wed Aug 20 00:39:10 2014 +0200 (2014-08-20)
parents
children 144f0bddee2b
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/seqlua_c_example.c	Wed Aug 20 00:39:10 2014 +0200
     1.3 @@ -0,0 +1,21 @@
     1.4 +#include <lua.h>
     1.5 +#include <lauxlib.h>
     1.6 +#include "seqlualib.h"
     1.7 +#include <stdio.h>
     1.8 +
     1.9 +static int seqlua_c_example_printcsv(lua_State *L) {
    1.10 +  seqlua_Iterator iter;
    1.11 +  seqlua_iterloop(L, &iter, 1) {
    1.12 +    if (seqlua_itercount(&iter) > 1) fputs(",", stdout);
    1.13 +    fputs(luaL_tolstring(L, -1, NULL), stdout);
    1.14 +    lua_pop(L, 1);
    1.15 +  }
    1.16 +  fputs("\n", stdout);
    1.17 +  return 0;
    1.18 +}
    1.19 +
    1.20 +int luaopen_seqlua_c_example(lua_State *L) {
    1.21 +  lua_pushcfunction(L, seqlua_c_example_printcsv);
    1.22 +  lua_setglobal(L, "printcsv");
    1.23 +  return 0;
    1.24 +}

Impressum / About Us