Browse Source

Added love.signal.raise, changed love.signal.registerSignal to love.signal.hook

bart@bart 16 years ago
parent
commit
576a5b0903

+ 7 - 1
src/modules/signal/posix/Signal.cpp

@@ -38,10 +38,11 @@ namespace posix
 		::signal(signals, SIG_DFL);
 	}
 	
-	bool Signal::registerSignal(int sgn)
+	bool Signal::hook(int sgn)
 	{
 		signals |= sgn;
 		::signal(sgn, (void (*)(int)) &handler);
+		return true;
 	}
 	
 	void Signal::setCallback(lua_State *L)
@@ -58,6 +59,11 @@ namespace posix
 		cb = new Reference(L);
 	}
 	
+	bool Signal::raise(int sgn)
+	{
+		return ::raise(sgn);
+	}
+	
 	void handler(int signal)
 	{
 		if (cb == 0)

+ 2 - 1
src/modules/signal/posix/Signal.h

@@ -42,9 +42,10 @@ namespace posix
 	public:
 		Signal();
 		~Signal();
-		bool registerSignal(int sgn);
+		bool hook(int sgn);
 		void setCallback(lua_State *L);
 		const char * getName() const;
+		bool raise(int sgn);
 	}; // Signal
 	
 	void handler(int signal);

+ 11 - 3
src/modules/signal/posix/wrap_Signal.cpp

@@ -33,10 +33,10 @@ namespace posix
 {
 	static Signal * instance = 0;
 	
-	int w_registerSignal(lua_State *L)
+	int w_hook(lua_State *L)
 	{
 		luaL_argcheck(L, lua_isnumber(L, 1), 1, "Expected number");
-		lua_pushboolean(L, instance->registerSignal(lua_tonumber(L, 1)));
+		lua_pushboolean(L, instance->hook(lua_tonumber(L, 1)));
 		return 1;
 	}
 	
@@ -45,11 +45,19 @@ namespace posix
 		luaL_argcheck(L, lua_isfunction(L, 1), 1, "Expected function");
 		instance->setCallback(L);
 	}
+	
+	int w_raise(lua_State *L)
+	{
+		luaL_argcheck(L, lua_isnumber(L, 1), 1, "Expected number");
+		lua_pushboolean(L, instance->raise(lua_tonumber(L, 1)));
+		return 1;
+	}
 
 	// List of functions to wrap.
 	static const luaL_Reg functions[] = {
-		{ "registerSignal", w_registerSignal },
+		{ "hook", w_hook },
 		{ "setCallback", w_setCallback }, 
+		{ "raise", w_raise },
 		{ 0, 0 }
 	};
 	

+ 2 - 1
src/modules/signal/posix/wrap_Signal.h

@@ -31,8 +31,9 @@ namespace signal
 {
 namespace posix
 {
-	int w_registerSignal(lua_State *L);
+	int w_hook(lua_State *L);
 	int w_setCallback(lua_State *L);
+	int w_raise(lua_State *L);
 
 	extern "C" LOVE_EXPORT int luaopen_love_signal(lua_State * L);