Using common project

This commit is contained in:
DHrpcs3 2015-12-21 12:00:15 +02:00
parent e5d10b0b05
commit a35040db63
13 changed files with 53 additions and 514 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "common"]
path = common
url = https://github.com/RPCS3/common

1
common Submodule

@ -0,0 +1 @@
Subproject commit 2a5a06098b88cf01aa39f95a2f1839ad75ea92c8

View File

@ -100,42 +100,42 @@
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<GenerateManifest>false</GenerateManifest>
<IncludePath>$(SolutionDir)shader_code/;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)common/include/;$(ProjectDir)../shader_code/;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)lib/$(Platform)-$(Configuration)/;$(LibraryPath)</LibraryPath>
<IntDir>$(SolutionDir)tmp/$(ProjectName)/$(Platform)-$(Configuration)/</IntDir>
<OutDir>$(SolutionDir)lib/$(Platform)-$(Configuration)/</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<GenerateManifest>false</GenerateManifest>
<IncludePath>$(SolutionDir)shader_code/;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)common/include/;$(ProjectDir)../shader_code/;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)lib/$(Platform)-$(Configuration)/;$(LibraryPath)</LibraryPath>
<IntDir>$(SolutionDir)tmp/$(ProjectName)/$(Platform)-$(Configuration)/</IntDir>
<OutDir>$(SolutionDir)lib/$(Platform)-$(Configuration)/</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<GenerateManifest>false</GenerateManifest>
<IncludePath>$(SolutionDir)shader_code/;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)common/include/;$(ProjectDir)../shader_code/;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)lib/$(Platform)-$(Configuration)/;$(LibraryPath)</LibraryPath>
<IntDir>$(SolutionDir)tmp/$(ProjectName)/$(Platform)-$(Configuration)/</IntDir>
<OutDir>$(SolutionDir)lib/$(Platform)-$(Configuration)/</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<GenerateManifest>false</GenerateManifest>
<IncludePath>$(SolutionDir)shader_code/;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)common/include/;$(ProjectDir)../shader_code/;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)lib/$(Platform)-$(Configuration)/;$(LibraryPath)</LibraryPath>
<IntDir>$(SolutionDir)tmp/$(ProjectName)/$(Platform)-$(Configuration)/</IntDir>
<OutDir>$(SolutionDir)lib/$(Platform)-$(Configuration)/</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<GenerateManifest>false</GenerateManifest>
<IncludePath>$(SolutionDir)shader_code/;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)common/include/;$(ProjectDir)../shader_code/;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)lib/$(Platform)-$(Configuration)/;$(LibraryPath)</LibraryPath>
<IntDir>$(SolutionDir)tmp/$(ProjectName)/$(Platform)-$(Configuration)/</IntDir>
<OutDir>$(SolutionDir)lib/$(Platform)-$(Configuration)/</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<GenerateManifest>false</GenerateManifest>
<IncludePath>$(SolutionDir)shader_code/;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)common/include/;$(ProjectDir)../shader_code/;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)lib/$(Platform)-$(Configuration)/;$(LibraryPath)</LibraryPath>
<IntDir>$(SolutionDir)tmp/$(ProjectName)/$(Platform)-$(Configuration)/</IntDir>
<OutDir>$(SolutionDir)lib/$(Platform)-$(Configuration)/</OutDir>

View File

@ -7,6 +7,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rsx_program_decompiler", "r
ProjectSection(ProjectDependencies) = postProject
{97E17077-A21F-45EF-9C3A-73A0BC092D7E} = {97E17077-A21F-45EF-9C3A-73A0BC092D7E}
{7D73447B-3D2D-4DFE-BF62-57E644C1D09F} = {7D73447B-3D2D-4DFE-BF62-57E644C1D09F}
{B03AE382-DB4D-459E-A52B-C94F55381F09} = {B03AE382-DB4D-459E-A52B-C94F55381F09}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shader_code", "shader_code\shader_code.vcxproj", "{97E17077-A21F-45EF-9C3A-73A0BC092D7E}"
@ -16,24 +17,48 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rsx_decompiler", "rsx_decom
{97E17077-A21F-45EF-9C3A-73A0BC092D7E} = {97E17077-A21F-45EF-9C3A-73A0BC092D7E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common\common.vcxproj", "{B03AE382-DB4D-459E-A52B-C94F55381F09}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9DAF4DF3-0E31-4C55-B367-6992C35F89CE}.Debug|x64.ActiveCfg = Debug|x64
{9DAF4DF3-0E31-4C55-B367-6992C35F89CE}.Debug|x64.Build.0 = Debug|x64
{9DAF4DF3-0E31-4C55-B367-6992C35F89CE}.Debug|x86.ActiveCfg = Debug|Win32
{9DAF4DF3-0E31-4C55-B367-6992C35F89CE}.Debug|x86.Build.0 = Debug|Win32
{9DAF4DF3-0E31-4C55-B367-6992C35F89CE}.Release|x64.ActiveCfg = Release|x64
{9DAF4DF3-0E31-4C55-B367-6992C35F89CE}.Release|x64.Build.0 = Release|x64
{9DAF4DF3-0E31-4C55-B367-6992C35F89CE}.Release|x86.ActiveCfg = Release|Win32
{9DAF4DF3-0E31-4C55-B367-6992C35F89CE}.Release|x86.Build.0 = Release|Win32
{97E17077-A21F-45EF-9C3A-73A0BC092D7E}.Debug|x64.ActiveCfg = Debug|x64
{97E17077-A21F-45EF-9C3A-73A0BC092D7E}.Debug|x64.Build.0 = Debug|x64
{97E17077-A21F-45EF-9C3A-73A0BC092D7E}.Debug|x86.ActiveCfg = Debug|Win32
{97E17077-A21F-45EF-9C3A-73A0BC092D7E}.Debug|x86.Build.0 = Debug|Win32
{97E17077-A21F-45EF-9C3A-73A0BC092D7E}.Release|x64.ActiveCfg = Release|x64
{97E17077-A21F-45EF-9C3A-73A0BC092D7E}.Release|x64.Build.0 = Release|x64
{97E17077-A21F-45EF-9C3A-73A0BC092D7E}.Release|x86.ActiveCfg = Release|Win32
{97E17077-A21F-45EF-9C3A-73A0BC092D7E}.Release|x86.Build.0 = Release|Win32
{7D73447B-3D2D-4DFE-BF62-57E644C1D09F}.Debug|x64.ActiveCfg = Debug|x64
{7D73447B-3D2D-4DFE-BF62-57E644C1D09F}.Debug|x64.Build.0 = Debug|x64
{7D73447B-3D2D-4DFE-BF62-57E644C1D09F}.Debug|x86.ActiveCfg = Debug|Win32
{7D73447B-3D2D-4DFE-BF62-57E644C1D09F}.Debug|x86.Build.0 = Debug|Win32
{7D73447B-3D2D-4DFE-BF62-57E644C1D09F}.Release|x64.ActiveCfg = Release|x64
{7D73447B-3D2D-4DFE-BF62-57E644C1D09F}.Release|x64.Build.0 = Release|x64
{7D73447B-3D2D-4DFE-BF62-57E644C1D09F}.Release|x86.ActiveCfg = Release|Win32
{7D73447B-3D2D-4DFE-BF62-57E644C1D09F}.Release|x86.Build.0 = Release|Win32
{B03AE382-DB4D-459E-A52B-C94F55381F09}.Debug|x64.ActiveCfg = Debug|x64
{B03AE382-DB4D-459E-A52B-C94F55381F09}.Debug|x64.Build.0 = Debug|x64
{B03AE382-DB4D-459E-A52B-C94F55381F09}.Debug|x86.ActiveCfg = Debug|Win32
{B03AE382-DB4D-459E-A52B-C94F55381F09}.Debug|x86.Build.0 = Debug|Win32
{B03AE382-DB4D-459E-A52B-C94F55381F09}.Release|x64.ActiveCfg = Release|x64
{B03AE382-DB4D-459E-A52B-C94F55381F09}.Release|x64.Build.0 = Release|x64
{B03AE382-DB4D-459E-A52B-C94F55381F09}.Release|x86.ActiveCfg = Release|Win32
{B03AE382-DB4D-459E-A52B-C94F55381F09}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,5 +1,5 @@
#pragma once
#include "fmt.h"
#include <common/StrFmt.h>
namespace endianness
{

View File

@ -333,11 +333,11 @@ int main(int argc, char** argv)
extract_objects_from_elf(argv[1], "tmp.vp.cg", { "_binary_vp_shader_vpo_start", "_binary_vp_shader_vpo_end" });
extract_objects_from_elf(argv[1], "tmp.fp.cg", { "_binary_fp_shader_fpo_start", "_binary_fp_shader_fpo_end" });
extract_ucode("tmp.fp.cg", "tmp.fp.ucode");
extract_ucode("tmp.vp.cg", "tmp.vp.ucode");
extract_ucode("compiled.cg", "tmp.vp.ucode");
rsx::decompiled_shader program;
if (1)
if (0)
{
using namespace rsx::fragment_program;
std::vector<char> file = load_file("tmp.fp.ucode");

View File

@ -80,7 +80,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<LibraryPath>$(SolutionDir)lib\$(Platform)-$(Configuration)\;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)rsx_program_decompiler_lib\;$(SolutionDir)shader_code/;$(SolutionDir)rsx_decompiler\;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)common\include\;$(SolutionDir)rsx_program_decompiler_lib\;$(SolutionDir)shader_code/;$(SolutionDir)rsx_decompiler\;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\</OutDir>
<TargetName>$(ProjectName)-$(Platform)-$(Configuration)</TargetName>
<IntDir>$(SolutionDir)tmp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
@ -93,7 +93,7 @@
<OutDir>$(SolutionDir)bin\</OutDir>
<TargetName>$(ProjectName)-$(Platform)-$(Configuration)</TargetName>
<IntDir>$(SolutionDir)tmp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
<IncludePath>$(SolutionDir)rsx_program_decompiler_lib\;$(SolutionDir)shader_code/;$(SolutionDir)rsx_decompiler\;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)common\include\;$(SolutionDir)rsx_program_decompiler_lib\;$(SolutionDir)shader_code/;$(SolutionDir)rsx_decompiler\;$(IncludePath)</IncludePath>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
@ -103,7 +103,7 @@
<IntDir>$(SolutionDir)tmp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)bin\</OutDir>
<LibraryPath>$(SolutionDir)lib\$(Platform)-$(Configuration)\;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)rsx_program_decompiler_lib\;$(SolutionDir)shader_code/;$(SolutionDir)rsx_decompiler\;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)common\include\;$(SolutionDir)rsx_program_decompiler_lib\;$(SolutionDir)shader_code/;$(SolutionDir)rsx_decompiler\;$(IncludePath)</IncludePath>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
@ -113,7 +113,7 @@
<OutDir>$(SolutionDir)bin\</OutDir>
<IntDir>$(SolutionDir)tmp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
<LibraryPath>$(SolutionDir)lib\$(Platform)-$(Configuration)\;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)rsx_program_decompiler_lib\;$(SolutionDir)shader_code/;$(SolutionDir)rsx_decompiler\;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)common\include\;$(SolutionDir)rsx_program_decompiler_lib\;$(SolutionDir)shader_code/;$(SolutionDir)rsx_decompiler\;$(IncludePath)</IncludePath>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
@ -128,7 +128,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>rsx_decompiler.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>rsx_decompiler.lib;common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -142,7 +142,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>rsx_decompiler.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>rsx_decompiler.lib;common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -160,7 +160,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>rsx_decompiler.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>rsx_decompiler.lib;common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -178,7 +178,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>rsx_decompiler.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>rsx_decompiler.lib;common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -1,5 +1,5 @@
#include "builder.h"
#include "fmt.h"
#include <common/StrFmt.h>
namespace shader_code
{
@ -64,7 +64,7 @@ namespace shader_code
std::string result;
int lvl = 0;
for (const std::string &line : fmt::split(build(), "\n", false))
for (const std::string &line : fmt::split(build(), { "\n" }, false))
{
if (line.empty())
{

View File

@ -1,6 +1,6 @@
#pragma once
#include "builder.h"
#include "fmt.h"
#include <common/StrFmt.h>
namespace shader_code
{

View File

@ -1,129 +0,0 @@
#include "fmt.h"
#include <algorithm>
namespace fmt
{
std::string replace_first(const std::string& src, const std::string& from, const std::string& to)
{
auto pos = src.find(from);
if (pos == std::string::npos)
{
return src;
}
return (pos ? src.substr(0, pos) + to : to) + std::string(src.c_str() + pos + from.length());
}
std::string replace_all(const std::string &src, const std::string& from, const std::string& to)
{
std::string target = src;
for (auto pos = target.find(from); pos != std::string::npos; pos = target.find(from, pos + 1))
{
target = (pos ? target.substr(0, pos) + to : to) + std::string(target.c_str() + pos + from.length());
pos += to.length();
}
return target;
}
std::vector<std::string> split(const std::string& source, std::initializer_list<std::string> separators, bool is_skip_empty)
{
std::vector<std::string> result;
std::size_t cursor_begin = 0;
for (std::size_t cursor_end = 0; cursor_end < source.length(); ++cursor_end)
{
for (auto &separator : separators)
{
if (strncmp(source.c_str() + cursor_end, separator.c_str(), separator.length()) == 0)
{
std::string candidate = source.substr(cursor_begin, cursor_end - cursor_begin);
if (!is_skip_empty || !candidate.empty())
result.push_back(candidate);
cursor_begin = cursor_end + separator.length();
cursor_end = cursor_begin - 1;
break;
}
}
}
if (cursor_begin != source.length())
{
result.push_back(source.substr(cursor_begin));
}
return std::move(result);
}
std::vector<std::string> split(const std::string& source, const std::string& separator, bool is_skip_empty)
{
return split(source, { separator }, is_skip_empty);
}
std::string tolower(std::string source)
{
std::transform(source.begin(), source.end(), source.begin(), ::tolower);
return source;
}
std::string toupper(std::string source)
{
std::transform(source.begin(), source.end(), source.begin(), ::toupper);
return source;
}
std::string escape(std::string source)
{
const std::pair<std::string, std::string> escape_list[] =
{
{ "\\", "\\\\" },
{ "\a", "\\a" },
{ "\b", "\\b" },
{ "\f", "\\f" },
{ "\n", "\\n\n" },
{ "\r", "\\r" },
{ "\t", "\\t" },
{ "\v", "\\v" },
};
source = replace_all(source, escape_list);
for (char c = 0; c < 32; c++)
{
if (c != '\n')
source = replace_all(source, std::string(1, c), Format("\\x%02X", c));
}
return source;
}
std::vector<std::string> string::split(std::initializer_list<std::string> separators, bool is_skip_empty) const
{
return fmt::split(*this, separators, is_skip_empty);
}
string& string::to_lower()
{
return *this = tolower(*this);
}
string string::as_lower() const
{
return tolower(*this);
}
string& string::to_upper()
{
return *this = toupper(*this);
}
string string::as_upper() const
{
return toupper(*this);
}
}

View File

@ -1,361 +0,0 @@
#pragma once
#include <string>
#include <vector>
#include <cstddef>
#include <functional>
using u8 = std::uint8_t;
using s8 = std::int8_t;
using u16 = std::uint16_t;
using s16 = std::int16_t;
using u32 = std::uint32_t;
using s32 = std::int32_t;
using u64 = std::uint64_t;
using s64 = std::int64_t;
#if defined(_MSC_VER)
#define snprintf _snprintf
#define force_inline __forceinline
#else
#define force_inline inline
#endif
#define safe_buffers
namespace fmt
{
struct empty_t{};
//small wrapper used to deal with bitfields
template<typename T>
T by_value(T x) { return x; }
//wrapper to deal with advance sprintf formating options with automatic length finding
template<typename... Args> std::string Format(const char* fmt, Args... parameters)
{
std::size_t length = 256;
std::string str;
for (;;)
{
std::vector<char> buffptr(length);
#if !defined(_MSC_VER)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
std::size_t printlen = snprintf(buffptr.data(), length, fmt, std::forward<Args>(parameters)...);
#pragma clang diagnostic pop
#else
std::size_t printlen = _snprintf_s(buffptr.data(), length, length - 1, fmt, std::forward<Args>(parameters)...);
#endif
if (printlen < length)
{
str = std::string(buffptr.data(), printlen);
break;
}
length *= 2;
}
return str;
}
std::string replace_first(const std::string& src, const std::string& from, const std::string& to);
std::string replace_all(const std::string &src, const std::string& from, const std::string& to);
template<std::size_t list_size>
std::string replace_all(std::string src, const std::pair<std::string, std::string>(&list)[list_size])
{
for (std::size_t pos = 0; pos < src.length(); ++pos)
{
for (std::size_t i = 0; i < list_size; ++i)
{
const std::size_t comp_length = list[i].first.length();
if (src.length() - pos < comp_length)
continue;
if (src.substr(pos, comp_length) == list[i].first)
{
src = (pos ? src.substr(0, pos) + list[i].second : list[i].second) + src.substr(pos + comp_length);
pos += list[i].second.length() - 1;
break;
}
}
}
return src;
}
template<std::size_t list_size>
std::string replace_all(std::string src, const std::pair<std::string, std::function<std::string()>>(&list)[list_size])
{
for (std::size_t pos = 0; pos < src.length(); ++pos)
{
for (std::size_t i = 0; i < list_size; ++i)
{
const std::size_t comp_length = list[i].first.length();
if (src.length() - pos < comp_length)
continue;
if (src.substr(pos, comp_length) == list[i].first)
{
src = (pos ? src.substr(0, pos) + list[i].second() : list[i].second()) + src.substr(pos + comp_length);
pos += list[i].second().length() - 1;
break;
}
}
}
return src;
}
template<typename T, bool is_enum = std::is_enum<T>::value>
struct unveil
{
typedef T result_type;
force_inline static result_type get_value(const T& arg)
{
return arg;
}
};
template<>
struct unveil<char*, false>
{
typedef const char* result_type;
force_inline static result_type get_value(const char* arg)
{
return arg;
}
};
template<std::size_t N>
struct unveil<const char[N], false>
{
typedef const char* result_type;
force_inline static result_type get_value(const char(&arg)[N])
{
return arg;
}
};
template<>
struct unveil<std::string, false>
{
typedef const char* result_type;
force_inline static result_type get_value(const std::string& arg)
{
return arg.c_str();
}
};
template<typename T>
struct unveil<T, true>
{
typedef typename std::underlying_type<T>::type result_type;
force_inline static result_type get_value(const T& arg)
{
return static_cast<result_type>(arg);
}
};
/*
template<typename T, typename T2>
struct unveil<be_t<T, T2>, false>
{
typedef typename unveil<T>::result_type result_type;
force_inline static result_type get_value(const be_t<T, T2>& arg)
{
return unveil<T>::get_value(arg.value());
}
};
*/
template<typename T>
force_inline typename unveil<T>::result_type do_unveil(const T& arg)
{
return unveil<T>::get_value(arg);
}
/*
fmt::format(const char* fmt, args...)
Formatting function with special functionality:
std::string forced to .c_str()
be_t<> forced to .value() (fmt::unveil reverts byte order automatically)
External specializations for fmt::unveil (can be found in another headers):
vm::ps3::ptr (fmt::unveil) (vm_ptr.h) (with appropriate address type, using .addr() can be avoided)
vm::ps3::bptr (fmt::unveil) (vm_ptr.h)
vm::psv::ptr (fmt::unveil) (vm_ptr.h)
vm::ps3::ref (fmt::unveil) (vm_ref.h)
vm::ps3::bref (fmt::unveil) (vm_ref.h)
vm::psv::ref (fmt::unveil) (vm_ref.h)
*/
template<typename... Args> force_inline safe_buffers std::string format(const char* fmt, Args... args)
{
return Format(fmt, do_unveil(args)...);
}
std::vector<std::string> split(const std::string& source, std::initializer_list<std::string> separators = { " ", "\t" }, bool is_skip_empty = true);
std::vector<std::string> split(const std::string& source, const std::string& separator, bool is_skip_empty = true);
template<typename T>
std::string merge(const T& source, const std::string& separator)
{
if (!source.size())
{
return{};
}
std::string result;
auto it = source.begin();
auto end = source.end();
for (--end; it != end; ++it)
{
result += *it + separator;
}
return result + source.back();
}
template<typename T>
std::string merge(std::initializer_list<T> sources, const std::string& separator)
{
if (!sources.size())
{
return{};
}
std::string result;
bool first = true;
for (auto &v : sources)
{
if (first)
{
result = fmt::merge(v, separator);
first = false;
}
else
{
result += separator + fmt::merge(v, separator);
}
}
return result;
}
std::string tolower(std::string source);
std::string toupper(std::string source);
std::string escape(std::string source);
template<typename T, bool use_std_to_string>
struct to_string_impl
{
static std::string func(const T& value)
{
return value.to_string();
}
};
template<typename T, bool use_std_to_string = std::is_arithmetic<T>::value>
std::string to_string(const T& value)
{
return to_string_impl<std::remove_cv_t<T>, use_std_to_string>::func(value);
}
class string : public std::string
{
public:
//using std::string;
string() = default;
template<typename T>
string(const T& value) : std::string(to_string(value))
{
}
string(std::size_t count, char ch) : std::string(count, ch)
{
}
template<typename T>
string& operator = (const T& rhs)
{
std::string::operator=(to_string(rhs));
return *this;
}
template<typename T>
string operator + (const T& rhs) const
{
return to_string(*this) + to_string(rhs);
}
template<typename T>
string& operator += (const T& rhs)
{
std::string::operator+=(to_string(rhs));
return *this;
}
std::vector<std::string> split(std::initializer_list<std::string> separators = { " ", "\t" }, bool is_skip_empty = true) const;
string& to_lower();
string as_lower() const;
string& to_upper();
string as_upper() const;
};
template<typename T>
struct to_string_impl<T, true>
{
static std::string func(const T& value)
{
return std::to_string(value);
}
};
template<bool use_std_to_string>
struct to_string_impl<std::string, use_std_to_string>
{
static const std::string& func(const std::string& value)
{
return value;
}
};
template<bool use_std_to_string>
struct to_string_impl<string, use_std_to_string>
{
static const std::string& func(const string& value)
{
return value;
}
};
template<bool use_std_to_string>
struct to_string_impl<char*, use_std_to_string>
{
static std::string func(const char* value)
{
return value;
}
};
template<bool use_std_to_string, std::size_t N>
struct to_string_impl<char[N], use_std_to_string>
{
static std::string func(const char(&value)[N])
{
return value;
}
};
}

View File

@ -73,21 +73,25 @@
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)lib\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)tmp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
<IncludePath>$(SolutionDir)common/include/;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)lib\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)tmp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
<IncludePath>$(SolutionDir)common/include/;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)lib\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)tmp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
<IncludePath>$(SolutionDir)common/include/;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)lib\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)tmp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
<IncludePath>$(SolutionDir)common/include/;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -156,13 +160,11 @@
<ItemGroup>
<ClCompile Include="builder.cpp" />
<ClCompile Include="clike_language.cpp" />
<ClCompile Include="fmt.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="builder.h" />
<ClInclude Include="clike_builder.h" />
<ClInclude Include="clike_language.h" />
<ClInclude Include="fmt.h" />
<ClInclude Include="glsl_builder.h" />
<ClInclude Include="glsl_language.h" />
</ItemGroup>

View File

@ -3,10 +3,8 @@
<ItemGroup>
<ClCompile Include="builder.cpp" />
<ClCompile Include="clike_language.cpp" />
<ClCompile Include="fmt.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="fmt.h" />
<ClInclude Include="builder.h" />
<ClInclude Include="clike_builder.h" />
<ClInclude Include="clike_language.h" />