Permalink
Browse files

And finally factor out ttp stubs

  • Loading branch information...
creationix committed Oct 6, 2011
1 parent 1476636 commit 0dcb4d57a1eed76f4463aaf48e210f19a4402857
Showing with 56 additions and 41 deletions.
  1. +1 −0 Makefile
  2. +1 −41 src/luv.c
  3. +39 −0 src/luv_tty.c
  4. +15 −0 src/luv_tty.h
View
@@ -16,6 +16,7 @@ LUVLIBS=${BUILDDIR}/utils.o \
${BUILDDIR}/luv_stream.o \
${BUILDDIR}/luv_tcp.o \
${BUILDDIR}/luv_pipe.o \
+ ${BUILDDIR}/luv_tty.o \
${BUILDDIR}/lhttp_parser.o
ALLLIBS=${BUILDDIR}/luvit.o \
View
@@ -10,48 +10,8 @@
#include "luv_stream.h"
#include "luv_tcp.h"
#include "luv_pipe.h"
+#include "luv_tty.h"
-////////////////////////////////////////////////////////////////////////////////
-// Constructors //
-////////////////////////////////////////////////////////////////////////////////
-
-static int luv_new_tty (lua_State* L) {
- int before = lua_gettop(L);
-
- //uv_tty_t* handle = (uv_tty_t*)
- lua_newuserdata(L, sizeof(uv_tty_t));
-
- // Set metatable for type
- luaL_getmetatable(L, "luv_pipe");
- lua_setmetatable(L, -2);
-
- // Create a local environment for storing stuff
- lua_newtable(L);
- lua_setfenv (L, -2);
-
- assert(lua_gettop(L) == before + 1);
-
- return 1;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// TTY Functions //
-////////////////////////////////////////////////////////////////////////////////
-
-static int luv_tty_init(lua_State* L) {
- error(L, "TODO: Implement luv_tty_init");
- return 0;
-}
-
-static int luv_tty_set_mode(lua_State* L) {
- error(L, "TODO: Implement luv_tty_set_mode");
- return 0;
-}
-
-static int luv_tty_get_winsize(lua_State* L) {
- error(L, "TODO: Implement luv_tty_get_winsize");
- return 0;
-}
////////////////////////////////////////////////////////////////////////////////
// Loop Functions //
View
@@ -0,0 +1,39 @@
+#include <stdlib.h>
+#include <assert.h>
+
+#include "luv_tty.h"
+
+int luv_new_tty (lua_State* L) {
+ int before = lua_gettop(L);
+
+ //uv_tty_t* handle = (uv_tty_t*)
+ lua_newuserdata(L, sizeof(uv_tty_t));
+
+ // Set metatable for type
+ luaL_getmetatable(L, "luv_pipe");
+ lua_setmetatable(L, -2);
+
+ // Create a local environment for storing stuff
+ lua_newtable(L);
+ lua_setfenv (L, -2);
+
+ assert(lua_gettop(L) == before + 1);
+
+ return 1;
+}
+
+int luv_tty_init(lua_State* L) {
+ error(L, "TODO: Implement luv_tty_init");
+ return 0;
+}
+
+int luv_tty_set_mode(lua_State* L) {
+ error(L, "TODO: Implement luv_tty_set_mode");
+ return 0;
+}
+
+int luv_tty_get_winsize(lua_State* L) {
+ error(L, "TODO: Implement luv_tty_get_winsize");
+ return 0;
+}
+
View
@@ -0,0 +1,15 @@
+#ifndef LUV_TTY
+#define LUV_TTY
+
+#include "lua.h"
+#include "lauxlib.h"
+#include "uv.h"
+#include "utils.h"
+#include "luv_stream.h"
+
+int luv_new_tty (lua_State* L);
+int luv_tty_init(lua_State* L);
+int luv_tty_set_mode(lua_State* L);
+int luv_tty_get_winsize(lua_State* L);
+
+#endif

0 comments on commit 0dcb4d5

Please sign in to comment.