Skip to content

Commit

Permalink
Compile-time refactoring.
Browse files Browse the repository at this point in the history
A few Lock turned into Lock*, to reduce compile time dependencies (many remain).
A bunch of new headers added to split dependencies up.
A bunch of compiler warnings removed by commenting out unused function/method formal argument/parameters.
xrCore/_stl_extensions.h almost taken out of the equation.
  • Loading branch information
tamlin-mike authored and Xottab-DUTY committed Aug 5, 2017
1 parent 5a3b1e4 commit da3e330
Show file tree
Hide file tree
Showing 266 changed files with 2,212 additions and 1,651 deletions.
6 changes: 3 additions & 3 deletions Externals/openal/OpenAL-Windows/Router/Router.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(xrExternals)\openal\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(xrExternals)openal\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;ROUTER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
Expand Down Expand Up @@ -118,7 +118,7 @@
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>$(xrExternals)\openal\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(xrExternals)openal\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;ROUTER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
Expand Down Expand Up @@ -163,7 +163,7 @@
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>$(xrExternals)\openal\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(xrExternals)openal\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;ROUTER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
Expand Down
13 changes: 13 additions & 0 deletions src/Common/Common.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\xrCommon\inlining_macros.h" />
<ClInclude Include="..\xrCommon\math_funcs.h" />
<ClInclude Include="..\xrCommon\math_funcs_inline.h" />
<ClInclude Include="..\xrCommon\misc_math_types.h" />
<ClInclude Include="..\xrCommon\predicates.h" />
<ClInclude Include="..\xrCommon\xalloc.h" />
<ClInclude Include="..\xrCommon\xr_deque.h" />
<ClInclude Include="..\xrCommon\xr_list.h" />
<ClInclude Include="..\xrCommon\xr_map.h" />
<ClInclude Include="..\xrCommon\xr_set.h" />
<ClInclude Include="..\xrCommon\xr_stack.h" />
<ClInclude Include="..\xrCommon\xr_string.h" />
<ClInclude Include="..\xrCommon\xr_vector.h" />
<ClInclude Include="Compiler.inl" />
<ClInclude Include="Config.hpp" />
<ClInclude Include="face_smoth_flags.h" />
Expand Down
42 changes: 42 additions & 0 deletions src/Common/Common.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,45 @@
<ClInclude Include="Compiler.inl">
<Filter>Platform</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\inlining_macros.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\math_funcs.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\math_funcs_inline.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\misc_math_types.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\xalloc.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\xr_map.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\xr_set.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\xr_stack.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\xr_string.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\xr_vector.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\predicates.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\xr_list.h">
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="..\xrCommon\xr_deque.h">
<Filter>xrCommon</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="NvMender2003">
Expand All @@ -50,6 +89,9 @@
<Filter Include="Platform">
<UniqueIdentifier>{05b6dbf9-e387-495f-9d92-e2b8ecc350fa}</UniqueIdentifier>
</Filter>
<Filter Include="xrCommon">
<UniqueIdentifier>{103b77e6-94b0-400a-a75f-3b0b45f13ee2}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="NvMender2003\NVMeshMender.cpp">
Expand Down
1 change: 1 addition & 0 deletions src/Common/LevelStructure.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "Common/GUID.hpp"
#include "xrCore/_fbox.h"

enum fsL_Chunks
{
Expand Down
2 changes: 2 additions & 0 deletions src/Common/_d3d_extensions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once
#ifndef _D3D_EXT_internal
#define _D3D_EXT_internal
#include "xrCore/FixedVector.h"

#ifndef NO_XR_LIGHT
struct Flight
Expand Down
147 changes: 74 additions & 73 deletions src/Common/object_comparer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
////////////////////////////////////////////////////////////////////////////

#pragma once
#include "xrCore/FixedVector.h"

template <typename P>
struct CComparer
Expand All @@ -15,174 +16,174 @@ struct CComparer
struct CHelper
{
template <bool a>
IC static bool compare(const T& _1, const T& _2, const P& p)
IC static bool compare(const T& a1, const T& a2, const P& p)
{
return (p(_1, _2));
return p(a1, a2);
}

template <>
IC static bool compare<true>(const T& _1, const T& _2, const P& p)
IC static bool compare<true>(const T& a1, const T& a2, const P& p)
{
return (CComparer::compare(*_1, *_2, p));
return CComparer::compare(*a1, *a2, p);
}
};

IC static bool compare(LPCSTR _1, LPCSTR _2, const P& p) { return (p(_1, _2)); }
IC static bool compare(LPSTR _1, LPSTR _2, const P& p) { return (p(_1, _2)); }
IC static bool compare(const shared_str& _1, const shared_str& _2, const P& p) { return (p(_1, _2)); }
IC static bool compare(LPCSTR s1, LPCSTR s2, const P& p) { return p(s1, s2); }
IC static bool compare(LPSTR s1, LPSTR s2, const P& p) { return p(s1, s2); }
IC static bool compare(const shared_str& s1, const shared_str& s2, const P& p) { return p(s1, s2); }
template <typename T1, typename T2>
IC static bool compare(const std::pair<T1, T2>& _1, const std::pair<T1, T2>& _2, const P& p)
IC static bool compare(const std::pair<T1, T2>& p1, const std::pair<T1, T2>& p2, const P& p)
{
return (compare(_1.first, _2.first, p) && compare(_1.second, _2.second, p));
return compare(p1.first, p2.first, p) && compare(p1.second, p2.second, p);
}

template <typename T, int size>
IC static bool compare(const svector<T, size>& _1, const svector<T, size>& _2, const P& p)
IC static bool compare(const svector<T, size>& v1, const svector<T, size>& v2, const P& p)
{
if (_1.size() != _2.size())
return (p());
if (v1.size() != v2.size())
return p();

svector<T, size>::const_iterator I = _1.begin(), J = _2.begin();
svector<T, size>::const_iterator E = _1.end();
svector<T, size>::const_iterator I = v1.begin(), J = v2.begin();
svector<T, size>::const_iterator E = v1.end();
for (; I != E; ++I, ++J)
if (!compare(*I, *J, p))
return (false);
return (true);
return false;
return true;
}

template <typename T1, typename T2>
IC static bool compare(const std::queue<T1, T2>& __1, const std::queue<T1, T2>& __2, const P& p)
IC static bool compare(const std::queue<T1, T2>& q1, const std::queue<T1, T2>& q2, const P& p)
{
std::queue<T1, T2> _1 = __1;
std::queue<T1, T2> _2 = __2;
std::queue<T1, T2> lq1 = q1;
std::queue<T1, T2> lq2 = q2;

if (_1.size() != _2.size())
return (p());
if (lq1.size() != lq2.size())
return p();

for (; !_1.empty(); _1.pop(), _2.pop())
if (!compare(_1.front(), _2.front(), p))
return (false);
return (true);
for (; !lq1.empty(); lq1.pop(), lq2.pop())
if (!compare(lq1.front(), lq2.front(), p))
return false;
return true;
}

template <template <typename _1, typename _2> class T1, typename T2, typename T3>
IC static bool compare(const T1<T2, T3>& __1, const T1<T2, T3>& __2, const P& p, bool)
template <template <typename T1X, typename T2X> class T1, typename T2, typename T3>
IC static bool compare(const T1<T2, T3>& a1, const T1<T2, T3>& a2, const P& p, bool)
{
T1<T2, T3> _1 = __1;
T1<T2, T3> _2 = __2;
T1<T2, T3> la1 = a1;
T1<T2, T3> la2 = a2;

if (_1.size() != _2.size())
return (p());
if (la1.size() != la2.size())
return p();

for (; !_1.empty(); _1.pop(), _2.pop())
if (!compare(_1.top(), _2.top(), p))
return (false);
return (true);
for (; !la1.empty(); la1.pop(), la2.pop())
if (!compare(la1.top(), la2.top(), p))
return false;
return true;
}

template <template <typename _1, typename _2, typename _3> class T1, typename T2, typename T3, typename T4>
IC static bool compare(const T1<T2, T3, T4>& __1, const T1<T2, T3, T4>& __2, const P& p, bool)
template <template <typename T1X, typename T2X, typename T3X> class T1, typename T2, typename T3, typename T4>
IC static bool compare(const T1<T2, T3, T4>& a1, const T1<T2, T3, T4>& a2, const P& p, bool)
{
T1<T2, T3, T4> _1 = __1;
T1<T2, T3, T4> _2 = __2;
T1<T2, T3, T4> la1 = a1;
T1<T2, T3, T4> la2 = a2;

if (_1.size() != _2.size())
return (p());
if (la1.size() != la2.size())
return p();

for (; !_1.empty(); _1.pop(), _2.pop())
if (!compare(_1.top(), _2.top(), p))
return (false);
return (true);
for (; !la1.empty(); la1.pop(), la2.pop())
if (!compare(la1.top(), la2.top(), p))
return false;
return true;
}

template <typename T1, typename T2>
IC static bool compare(const xr_stack<T1, T2>& _1, const xr_stack<T1, T2>& _2, const P& p)
IC static bool compare(const xr_stack<T1, T2>& s1, const xr_stack<T1, T2>& s2, const P& p)
{
return (compare(_1, _2, p, true));
return compare(s1, s2, p, true);
}

template <typename T1, typename T2, typename T3>
IC static bool compare(
const std::priority_queue<T1, T2, T3>& _1, const std::priority_queue<T1, T2, T3>& _2, const P& p)
const std::priority_queue<T1, T2, T3>& q1, const std::priority_queue<T1, T2, T3>& q2, const P& p)
{
return (compare(_1, _2, p, true));
return compare(q1, q2, p, true);
}

struct CHelper3
{
template <typename T>
IC static bool compare(const T& _1, const T& _2, const P& p)
IC static bool compare(const T& a1, const T& a2, const P& p)
{
if (_1.size() != _2.size())
return (p());
if (a1.size() != a2.size())
return p();

T::const_iterator I = _1.begin(), J = _2.begin();
T::const_iterator E = _1.end();
T::const_iterator I = a1.begin(), J = a2.begin();
T::const_iterator E = a1.end();
for (; I != E; ++I, ++J)
if (!CComparer::compare(*I, *J, p))
return (false);
return (true);
return false;
return true;
}
};

template <typename T>
struct CHelper4
{
template <bool a>
IC static bool compare(const T& _1, const T& _2, const P& p)
IC static bool compare(const T& a1, const T& a2, const P& p)
{
return (CHelper<T>::compare<object_type_traits::is_pointer<T>::value>(_1, _2, p));
return CHelper<T>::compare<object_type_traits::is_pointer<T>::value>(a1, a2, p);
}

template <>
IC static bool compare<true>(const T& _1, const T& _2, const P& p)
IC static bool compare<true>(const T& a1, const T& a2, const P& p)
{
return (CHelper3::compare(_1, _2, p));
return CHelper3::compare(a1, a2, p);
}
};

template <typename T>
IC static bool compare(const T& _1, const T& _2, const P& p)
IC static bool compare(const T& a1, const T& a2, const P& p)
{
return (CHelper4<T>::compare<object_type_traits::is_stl_container<T>::value>(_1, _2, p));
return CHelper4<T>::compare<object_type_traits::is_stl_container<T>::value>(a1, a2, p);
}
};

template <typename P>
IC bool compare(LPCSTR p0, LPSTR p1, const P& p)
{
return (p(p0, p1));
return p(p0, p1);
}

template <typename P>
IC bool compare(LPSTR p0, LPCSTR p1, const P& p)
{
return (p(p0, p1));
return p(p0, p1);
}

template <typename T, typename P>
IC bool compare(const T& p0, const T& p1, const P& p)
{
return (CComparer<P>::compare(p0, p1, p));
return CComparer<P>::compare(p0, p1, p);
}

namespace object_comparer
{
namespace detail
{
template <template <typename _1> class P>
template <template <typename TX> class P>
struct comparer
{
template <typename T>
IC bool operator()(const T& _1, const T& _2) const
IC bool operator()(const T& a1, const T& a2) const
{
return (P<T>()(_1, _2));
return P<T>()(a1, a2);
}
IC bool operator()() const { return (P<bool>()(false, true)); }
IC bool operator()(LPCSTR _1, LPCSTR _2) const { return (P<int>()(xr_strcmp(_1, _2), 0)); }
IC bool operator()(LPSTR _1, LPSTR _2) const { return (P<int>()(xr_strcmp(_1, _2), 0)); }
IC bool operator()(LPCSTR _1, LPSTR _2) const { return (P<int>()(xr_strcmp(_1, _2), 0)); }
IC bool operator()(LPSTR _1, LPCSTR _2) const { return (P<int>()(xr_strcmp(_1, _2), 0)); }
IC bool operator()() const { return P<bool>()(false, true); }
IC bool operator()(LPCSTR s1, LPCSTR s2) const { return (P<int>()(xr_strcmp(s1, s2), 0)); }
IC bool operator()(LPSTR s1, LPSTR s2) const { return (P<int>()(xr_strcmp(s1, s2), 0)); }
IC bool operator()(LPCSTR s1, LPSTR s2) const { return (P<int>()(xr_strcmp(s1, s2), 0)); }
IC bool operator()(LPSTR s1, LPCSTR s2) const { return (P<int>()(xr_strcmp(s1, s2), 0)); }
};
};
};
Expand Down
Loading

0 comments on commit da3e330

Please sign in to comment.