Explorar o código

Rename lua_system to lua_globals

Daniele Bartolini %!s(int64=11) %!d(string=hai) anos
pai
achega
fd4e0d9e62

+ 3 - 3
engine/crown.cpp

@@ -198,7 +198,7 @@ bool init(Filesystem& fs, const ConfigSettings& cs)
 	audio_globals::init();
 	physics_globals::init();
 	bgfx::init();
-	lua_system::init();
+	lua_globals::init();
 	device_globals::init(fs, cs.boot_package, cs.boot_script);
 	device()->init();
 	return true;
@@ -213,7 +213,7 @@ void update()
 #endif
 		device()->update();
 		bgfx::frame();
-		lua_system::clear_temporaries();
+		lua_globals::clear_temporaries();
 		input_globals::keyboard().update();
 		input_globals::mouse().update();
 		input_globals::touch().update();
@@ -224,7 +224,7 @@ void shutdown()
 {
 	device()->shutdown();
 	device_globals::shutdown();
-	lua_system::shutdown();
+	lua_globals::shutdown();
 	bgfx::shutdown();
 	physics_globals::shutdown();
 	audio_globals::shutdown();

+ 1 - 1
engine/device.cpp

@@ -87,7 +87,7 @@ void Device::init()
 	material_manager::init();
 	debug_line::init();
 
-	_lua_environment = CE_NEW(_allocator, LuaEnvironment)(lua_system::state());
+	_lua_environment = CE_NEW(_allocator, LuaEnvironment)(lua_globals::state());
 
 	CE_LOGD("Crown Engine initialized.");
 	CE_LOGD("Initializing Game...");

+ 6 - 6
engine/lua/lua_environment.cpp

@@ -35,7 +35,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-namespace lua_system { extern int error_handler(lua_State*); }
+namespace lua_globals { extern int error_handler(lua_State*); }
 
 LuaEnvironment::LuaEnvironment(lua_State* L)
 	: _L(L)
@@ -45,7 +45,7 @@ LuaEnvironment::LuaEnvironment(lua_State* L)
 void LuaEnvironment::execute(const LuaResource* lr)
 {
 	using namespace lua_resource;
-	lua_pushcfunction(_L, lua_system::error_handler);
+	lua_pushcfunction(_L, lua_globals::error_handler);
 	luaL_loadbuffer(_L, program(lr), size(lr), "<unknown>");
 	lua_pcall(_L, 0, 0, -2);
 	lua_pop(_L, 1);
@@ -53,7 +53,7 @@ void LuaEnvironment::execute(const LuaResource* lr)
 
 void LuaEnvironment::execute_string(const char* s)
 {
-	lua_pushcfunction(_L, lua_system::error_handler);
+	lua_pushcfunction(_L, lua_globals::error_handler);
 	luaL_loadstring(_L, s);
 	lua_pcall(_L, 0, 0, -2);
 	lua_pop(_L, 1);
@@ -123,7 +123,7 @@ void LuaEnvironment::call_global(const char* func, uint8_t argc, ...)
 	va_list vl;
 	va_start(vl, argc);
 
-	lua_pushcfunction(_L, lua_system::error_handler);
+	lua_pushcfunction(_L, lua_globals::error_handler);
 	lua_getglobal(_L, func);
 
 	for (uint8_t i = 0; i < argc; i++)
@@ -153,7 +153,7 @@ void LuaEnvironment::call_physics_callback(Actor* actor_0, Actor* actor_1, Unit*
 {
 	LuaStack stack(_L);
 
-	lua_pushcfunction(_L, lua_system::error_handler);
+	lua_pushcfunction(_L, lua_globals::error_handler);
 	lua_getglobal(_L, "g_physics_callback");
 
 	stack.push_table();
@@ -173,7 +173,7 @@ void LuaEnvironment::call_trigger_callback(Actor* trigger, Actor* other, const c
 {
 	LuaStack stack(_L);
 
-	lua_pushcfunction(_L, lua_system::error_handler);
+	lua_pushcfunction(_L, lua_globals::error_handler);
 	lua_getglobal(_L, "g_trigger_callback");
 
 	stack.push_table();

+ 9 - 9
engine/lua/lua_stack.h

@@ -419,60 +419,60 @@ struct LuaStack
 
 	Vector2& get_vector2(int32_t index)
 	{
-		void* v = CHECKLIGHTDATA(_L, index, lua_system::is_vector2, "Vector2");
+		void* v = CHECKLIGHTDATA(_L, index, lua_globals::is_vector2, "Vector2");
 		return *(Vector2*)v;
 	}
 
 	Vector3& get_vector3(int32_t index)
 	{
-		void* v = CHECKLIGHTDATA(_L, index, lua_system::is_vector3, "Vector3");
+		void* v = CHECKLIGHTDATA(_L, index, lua_globals::is_vector3, "Vector3");
 		return *(Vector3*)v;
 	}
 
 	Matrix4x4& get_matrix4x4(int32_t index)
 	{
-		void* m = CHECKLIGHTDATA(_L, index, lua_system::is_matrix4x4, "Matrix4x4");
+		void* m = CHECKLIGHTDATA(_L, index, lua_globals::is_matrix4x4, "Matrix4x4");
 		return *(Matrix4x4*)m;
 	}
 
 	Quaternion& get_quaternion(int32_t index)
 	{
-		void* q = CHECKLIGHTDATA(_L, index, lua_system::is_quaternion, "Quaternion");
+		void* q = CHECKLIGHTDATA(_L, index, lua_globals::is_quaternion, "Quaternion");
 		return *(Quaternion*)q;
 	}
 
 	Color4 get_color4(int32_t index)
 	{
 		// Color4 represented as Quaternion
-		void* c = CHECKLIGHTDATA(_L, index, lua_system::is_quaternion, "Color4");
+		void* c = CHECKLIGHTDATA(_L, index, lua_globals::is_quaternion, "Color4");
 		Quaternion& q = *(Quaternion*)c;
 		return Color4(q.x, q.y, q.z, q.w);
 	}
 
 	void push_vector2(const Vector2& v)
 	{
-		lua_pushlightuserdata(_L, lua_system::next_vector2(v));
+		lua_pushlightuserdata(_L, lua_globals::next_vector2(v));
 		luaL_getmetatable(_L, "Lightuserdata_mt");
 		lua_setmetatable(_L, -2);
 	}
 
 	void push_vector3(const Vector3& v)
 	{
-		lua_pushlightuserdata(_L, lua_system::next_vector3(v));
+		lua_pushlightuserdata(_L, lua_globals::next_vector3(v));
 		luaL_getmetatable(_L, "Lightuserdata_mt");
 		lua_setmetatable(_L, -2);
 	}
 
 	void push_matrix4x4(const Matrix4x4& m)
 	{
-		lua_pushlightuserdata(_L, lua_system::next_matrix4x4(m));
+		lua_pushlightuserdata(_L, lua_globals::next_matrix4x4(m));
 		luaL_getmetatable(_L, "Lightuserdata_mt");
 		lua_setmetatable(_L, -2);
 	}
 
 	void push_quaternion(const Quaternion& q)
 	{
-		lua_pushlightuserdata(_L, lua_system::next_quaternion(q));
+		lua_pushlightuserdata(_L, lua_globals::next_quaternion(q));
 		luaL_getmetatable(_L, "Lightuserdata_mt");
 		lua_setmetatable(_L, -2);
 	}

+ 11 - 11
engine/lua/lua_system.cpp

@@ -77,7 +77,7 @@ extern void load_world(LuaEnvironment& env);
 extern void load_color4(LuaEnvironment& env);
 extern void load_material(LuaEnvironment& env);
 
-namespace lua_system
+namespace lua_globals
 {
 	static lua_State* s_L;
 
@@ -133,7 +133,7 @@ namespace lua_system
 	{
 		LuaStack stack(L);
 
-		if (lua_system::is_vector3(1))
+		if (lua_globals::is_vector3(1))
 		{
 			const Vector3& a = stack.get_vector3(1);
 			const Vector3& b = stack.get_vector3(2);
@@ -151,7 +151,7 @@ namespace lua_system
 	{
 		LuaStack stack(L);
 
-		if (lua_system::is_vector3(1))
+		if (lua_globals::is_vector3(1))
 		{
 			const Vector3& a = stack.get_vector3(1);
 			const Vector3& b = stack.get_vector3(2);
@@ -169,7 +169,7 @@ namespace lua_system
 	{
 		LuaStack stack(L);
 
-		if (lua_system::is_vector3(1))
+		if (lua_globals::is_vector3(1))
 		{
 			const Vector3& a = stack.get_vector3(1);
 			const float b = stack.get_float(2);
@@ -187,7 +187,7 @@ namespace lua_system
 	{
 		LuaStack stack(L);
 
-		if (lua_system::is_vector3(1))
+		if (lua_globals::is_vector3(1))
 		{
 			const Vector3& a = stack.get_vector3(1);
 			const float b = stack.get_float(2);
@@ -205,7 +205,7 @@ namespace lua_system
 	{
 		LuaStack stack(L);
 
-		if (lua_system::is_vector3(1))
+		if (lua_globals::is_vector3(1))
 		{
 			stack.push_vector3(-stack.get_vector3(1));
 			return 1;
@@ -218,7 +218,7 @@ namespace lua_system
 	{
 		LuaStack stack(L);
 
-		if (lua_system::is_vector3(1))
+		if (lua_globals::is_vector3(1))
 		{
 			Vector3& v = stack.get_vector3(1);
 			const char* s = stack.get_string(2);
@@ -239,7 +239,7 @@ namespace lua_system
 				return 1;
 			}
 		}
-		else if (lua_system::is_vector2(1))
+		else if (lua_globals::is_vector2(1))
 		{
 			Vector2& v = stack.get_vector2(1);
 			const char* s = stack.get_string(2);
@@ -263,7 +263,7 @@ namespace lua_system
 	{
 		LuaStack stack(L);
 
-		if (lua_system::is_vector3(1))
+		if (lua_globals::is_vector3(1))
 		{
 			Vector3& v = stack.get_vector3(1);
 			const char* s = stack.get_string(2);
@@ -273,7 +273,7 @@ namespace lua_system
 			else if (string::strcmp(s, "y") == 0) v.y = value;
 			else if (string::strcmp(s, "z") == 0) v.z = value;
 		}
-		else if (lua_system::is_vector2(1))
+		else if (lua_globals::is_vector2(1))
 		{
 			Vector2& v = stack.get_vector2(1);
 			const char* s = stack.get_string(2);
@@ -451,5 +451,5 @@ namespace lua_system
 		s_quat_used = 0;
 	}
 
-} // namespace lua_system
+} // namespace lua_globals
 } // namespace crown

+ 3 - 3
engine/lua/lua_system.h

@@ -36,13 +36,13 @@ struct Matrix4x4;
 struct Quaternion;
 
 /// Global lua-related functions
-namespace lua_system
+namespace lua_globals
 {
 	/// Initializes the lua system.
 	/// This is the place where to create and initialize per-application objects.
 	void init();
 
-	/// It should reverse the actions performed by lua_system::init().
+	/// It should reverse the actions performed by lua_globals::init().
 	void shutdown();
 
 	lua_State* state();
@@ -61,5 +61,5 @@ namespace lua_system
 	bool is_vector3(int32_t index);
 	bool is_matrix4x4(int32_t index);
 	bool is_quaternion(int32_t index);
-} // namespace lua_system
+} // namespace lua_globals
 } // namespace crown