浏览代码

Added Lua dll example

Sergey Lyubka 12 年之前
父节点
当前提交
b07745ab50
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      examples/lua_dll.c

+ 19 - 0
examples/lua_dll.c

@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+#include "lua.h"
+#include "lauxlib.h"
+
+static int smile(lua_State *L) {
+  (void) L;  // Unused
+  printf("%s\n", ":-)");
+  return 0;
+}
+
+int LUA_API luaopen_lua_dll(lua_State *L) {
+  static const struct luaL_Reg api[] = {
+    {"smile", smile},
+    {NULL, NULL},
+  };
+  luaL_openlib(L, "lua_dll", api, 0);
+  return 1;
+}