Browse Source

resource: use consistent naming and signature style

Daniele Bartolini 6 years ago
parent
commit
03f5328ba8

+ 2 - 2
src/resource/compile_options.cpp

@@ -139,7 +139,7 @@ void CompileOptions::add_requirement(const char* type, const char* name)
 	_data_compiler.add_requirement(_resource_id, path.c_str());
 }
 
-void CompileOptions::absolute_path(const char* path, DynamicString& abs)
+void CompileOptions::absolute_path(DynamicString& abs, const char* path)
 {
 	TempAllocator256 ta;
 	DynamicString source_dir(ta);
@@ -150,7 +150,7 @@ void CompileOptions::absolute_path(const char* path, DynamicString& abs)
 	source_filesystem.absolute_path(abs, path);
 }
 
-void CompileOptions::get_temporary_path(const char* suffix, DynamicString& abs)
+void CompileOptions::temporary_path(DynamicString& abs, const char* suffix)
 {
 	TempAllocator1024 ta;
 	DynamicString str(ta);

+ 2 - 2
src/resource/compile_options.h

@@ -111,10 +111,10 @@ struct CompileOptions
 	void add_requirement(const char* type, const char* name);
 
 	///
-	void absolute_path(const char* path, DynamicString& abs);
+	void absolute_path(DynamicString& abs, const char* path);
 
 	///
-	void get_temporary_path(const char* suffix, DynamicString& abs);
+	void temporary_path(DynamicString& abs, const char* suffix);
 
 	///
 	DeleteResult delete_file(const char* path);

+ 8 - 8
src/resource/lua_resource.cpp

@@ -36,17 +36,17 @@ namespace lua_resource_internal
 	s32 compile(CompileOptions& opts)
 	{
 		TempAllocator1024 ta;
-		DynamicString luasrc(ta);
-		DynamicString luabin(ta);
-		opts.absolute_path(opts.source_path(), luasrc);
-		opts.get_temporary_path("lua", luabin);
+		DynamicString lua_src(ta);
+		DynamicString lua_out(ta);
+		opts.absolute_path(lua_src, opts.source_path());
+		opts.temporary_path(lua_out, "lua");
 
 		const char* argv[] =
 		{
 			EXE_PATH("luajit"),
 			LUAJIT_FLAGS,
-			luasrc.c_str(),
-			luabin.c_str(),
+			lua_src.c_str(),
+			lua_out.c_str(),
 			NULL
 		};
 		Process pr;
@@ -70,8 +70,8 @@ namespace lua_resource_internal
 			, string_stream::c_str(output)
 			);
 
-		Buffer blob = opts.read_temporary(luabin.c_str());
-		opts.delete_file(luabin.c_str());
+		Buffer blob = opts.read_temporary(lua_out.c_str());
+		opts.delete_file(lua_out.c_str());
 
 		LuaResource lr;
 		lr.version = RESOURCE_HEADER(RESOURCE_VERSION_SCRIPT);

+ 25 - 25
src/resource/shader_resource.cpp

@@ -655,11 +655,11 @@ namespace shader_resource_internal
 		HashMap<DynamicString, ShaderPermutation> _shaders;
 		Vector<StaticCompile> _static_compile;
 
-		DynamicString _vs_source_path;
-		DynamicString _fs_source_path;
+		DynamicString _vs_src_path;
+		DynamicString _fs_src_path;
 		DynamicString _varying_path;
-		DynamicString _vs_compiled_path;
-		DynamicString _fs_compiled_path;
+		DynamicString _vs_out_path;
+		DynamicString _vs_out_path;
 
 		ShaderCompiler(CompileOptions& opts)
 			: _opts(opts)
@@ -668,17 +668,17 @@ namespace shader_resource_internal
 			, _bgfx_shaders(default_allocator())
 			, _shaders(default_allocator())
 			, _static_compile(default_allocator())
-			, _vs_source_path(default_allocator())
-			, _fs_source_path(default_allocator())
+			, _vs_src_path(default_allocator())
+			, _fs_src_path(default_allocator())
 			, _varying_path(default_allocator())
-			, _vs_compiled_path(default_allocator())
-			, _fs_compiled_path(default_allocator())
+			, _vs_out_path(default_allocator())
+			, _vs_out_path(default_allocator())
 		{
-			_opts.get_temporary_path("vs_source.sc", _vs_source_path);
-			_opts.get_temporary_path("fs_source.sc", _fs_source_path);
-			_opts.get_temporary_path("varying.sc", _varying_path);
-			_opts.get_temporary_path("vs_compiled.bin", _vs_compiled_path);
-			_opts.get_temporary_path("fs_compiled.bin", _fs_compiled_path);
+			_opts.temporary_path(_vs_src_path, "vs_src.sc");
+			_opts.temporary_path(_fs_src_path, "fs_src.sc");
+			_opts.temporary_path(_varying_path, "varying.sc");
+			_opts.temporary_path(_vs_out_path, "vs_out.bin");
+			_opts.temporary_path(_vs_out_path, "fs_out.bin");
 		}
 
 		s32 parse(const char* path)
@@ -1109,11 +1109,11 @@ namespace shader_resource_internal
 
 		void delete_temp_files()
 		{
-			_opts.delete_file(_vs_source_path.c_str());
-			_opts.delete_file(_fs_source_path.c_str());
+			_opts.delete_file(_vs_src_path.c_str());
+			_opts.delete_file(_fs_src_path.c_str());
 			_opts.delete_file(_varying_path.c_str());
-			_opts.delete_file(_vs_compiled_path.c_str());
-			_opts.delete_file(_fs_compiled_path.c_str());
+			_opts.delete_file(_vs_out_path.c_str());
+			_opts.delete_file(_vs_out_path.c_str());
 		}
 
 		s32 compile()
@@ -1232,8 +1232,8 @@ namespace shader_resource_internal
 			fs_code << shader._code.c_str();
 			fs_code << shader._fs_code.c_str();
 
-			_opts.write_temporary(_vs_source_path.c_str(), vs_code);
-			_opts.write_temporary(_fs_source_path.c_str(), fs_code);
+			_opts.write_temporary(_vs_src_path.c_str(), vs_code);
+			_opts.write_temporary(_fs_src_path.c_str(), fs_code);
 			_opts.write_temporary(_varying_path.c_str(), shader._varying.c_str(), shader._varying.length());
 
 			const char* shaderc = _opts.exe_path(shaderc_paths, countof(shaderc_paths));
@@ -1249,8 +1249,8 @@ namespace shader_resource_internal
 
 			sc = run_external_compiler(pr_vert
 				, shaderc
-				, _vs_source_path.c_str()
-				, _vs_compiled_path.c_str()
+				, _vs_src_path.c_str()
+				, _vs_out_path.c_str()
 				, _varying_path.c_str()
 				, "vertex"
 				, _opts.platform()
@@ -1267,8 +1267,8 @@ namespace shader_resource_internal
 
 			sc = run_external_compiler(pr_frag
 				, shaderc
-				, _fs_source_path.c_str()
-				, _fs_compiled_path.c_str()
+				, _fs_src_path.c_str()
+				, _vs_out_path.c_str()
 				, _varying_path.c_str()
 				, "fragment"
 				, _opts.platform()
@@ -1323,8 +1323,8 @@ namespace shader_resource_internal
 					);
 			}
 
-			Buffer tmpvs = _opts.read_temporary(_vs_compiled_path.c_str());
-			Buffer tmpfs = _opts.read_temporary(_fs_compiled_path.c_str());
+			Buffer tmpvs = _opts.read_temporary(_vs_out_path.c_str());
+			Buffer tmpfs = _opts.read_temporary(_vs_out_path.c_str());
 
 			delete_temp_files();
 

+ 8 - 8
src/resource/texture_resource.cpp

@@ -91,10 +91,10 @@ namespace texture_resource_internal
 		const bool generate_mips = sjson::parse_bool(obj["generate_mips"]);
 		const bool normal_map    = sjson::parse_bool(obj["normal_map"]);
 
-		DynamicString texsrc(ta);
-		DynamicString texout(ta);
-		opts.absolute_path(name.c_str(), texsrc);
-		opts.get_temporary_path("ktx", texout);
+		DynamicString tex_src(ta);
+		DynamicString tex_out(ta);
+		opts.absolute_path(tex_src, name.c_str());
+		opts.temporary_path(tex_out, "ktx");
 
 		const char* texturec = opts.exe_path(texturec_paths, countof(texturec_paths));
 		DATA_COMPILER_ASSERT(texturec != NULL
@@ -106,9 +106,9 @@ namespace texture_resource_internal
 		{
 			texturec,
 			"-f",
-			texsrc.c_str(),
+			tex_src.c_str(),
 			"-o",
-			texout.c_str(),
+			tex_out.c_str(),
 			(generate_mips ? "-m" : ""),
 			(normal_map    ? "-n" : ""),
 			NULL
@@ -134,8 +134,8 @@ namespace texture_resource_internal
 			, string_stream::c_str(output)
 			);
 
-		Buffer blob = opts.read_temporary(texout.c_str());
-		opts.delete_file(texout.c_str());
+		Buffer blob = opts.read_temporary(tex_out.c_str());
+		opts.delete_file(tex_out.c_str());
 
 		// Write DDS
 		opts.write(RESOURCE_HEADER(RESOURCE_VERSION_TEXTURE));