summaryrefslogtreecommitdiffhomepage
path: root/stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/stream.c b/stream.c
new file mode 100644
index 0000000..d6a5254
--- /dev/null
+++ b/stream.c
@@ -0,0 +1,23 @@
+#include "stream.h"
+
+#include <lauxlib.h>
+#include <lua.h>
+
+/// Creates and pushes new Stream into the Lua stack.
+/// \param L Lua state to push to
+/// \param fd File descriptor used by stream
+/// \return TODO
+int stream_push_new(lua_State * L, const int fd)
+{
+ struct stream * s = lua_newuserdata(L, sizeof(struct stream));
+ s->fd = fd;
+
+ if (1 == luaL_newmetatable(L, "stream"))
+ {
+ // TODO: initialize metatable for stream
+ }
+
+ lua_setmetatable(L, -2);
+
+ return LUA_OK;
+}