no message
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@32 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
82ee09b978
commit
b233e001b3
15 changed files with 957 additions and 0 deletions
136
tools/HeaderGen/HeaderGen.cpp
Normal file
136
tools/HeaderGen/HeaderGen.cpp
Normal file
|
@ -0,0 +1,136 @@
|
|||
///////////////////////////////////////////////////////////////
|
||||
//Generates forwarding headers using the information
|
||||
//in the header.lst & vendor.lst files
|
||||
//
|
||||
//To create a header list from an existing directory of headers
|
||||
//dir *.h /b > headers.lst
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
struct Compiler
|
||||
{
|
||||
Compiler() {}
|
||||
Compiler(const string& VersionTest, const string& SubDir) :
|
||||
version_test(VersionTest), subdir(SubDir)
|
||||
{}
|
||||
string version_test;
|
||||
string subdir;
|
||||
};
|
||||
|
||||
typedef vector<Compiler> cv_t;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if(argc < 2)
|
||||
{
|
||||
cout <<"Usage: <Header List> [Version/Vender List]"<<endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
cv_t vendors;
|
||||
char buf[1024];
|
||||
string check;
|
||||
string subdir;
|
||||
fstream vendor_file;
|
||||
if(argc >= 3)
|
||||
{
|
||||
vendor_file.open(argv[2], ios::in);
|
||||
if(!vendor_file.is_open())
|
||||
{
|
||||
cout << "Unable to open vendor file: " << argv[2] << endl;
|
||||
return -2;
|
||||
}
|
||||
else
|
||||
{
|
||||
vendors.reserve(10);
|
||||
while(!vendor_file.eof())
|
||||
{
|
||||
check = "";
|
||||
subdir = "";
|
||||
vendor_file.getline(buf, 1024, '\n');
|
||||
check = buf;
|
||||
vendor_file.getline(buf, 1024, '\n');
|
||||
subdir = buf;
|
||||
vendor_file.getline(buf, 1024, '\n');
|
||||
if(!(check.empty() || subdir.empty()))
|
||||
vendors.push_back(Compiler(check, subdir));
|
||||
else
|
||||
{
|
||||
cout << "Error parsing vendors, check:" << check << "\tsubdir:" << subdir << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else //if(vendors.empty())
|
||||
{
|
||||
cout << "No vendor file provided, using defaults" << endl;
|
||||
vendors.reserve(10);
|
||||
vendors.push_back(Compiler("(_MSC_VER >= 1300)", "MSVC\\1300"));
|
||||
vendors.push_back(Compiler("(_MSC_VER >= 1200)", "MSVC\\1200"));
|
||||
vendors.push_back(Compiler("( (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 1)) )", "Reference"));
|
||||
}
|
||||
|
||||
fstream header_list(argv[1]);
|
||||
string header;
|
||||
stringstream ss;
|
||||
|
||||
if(!header_list.is_open())
|
||||
{
|
||||
cout << "Invalid header list file, " << argv[1] << endl;
|
||||
return -3;
|
||||
}
|
||||
while(!header_list.eof())
|
||||
{
|
||||
header_list >> header;
|
||||
cout << header << endl;
|
||||
fstream header_file(header.c_str(), ios::out);
|
||||
if(!header_file.is_open())
|
||||
{
|
||||
cout << "Unable to open header file for output: " << header << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss.str("");
|
||||
ss << "//Generated header: " << header << endl;
|
||||
size_t n = ss.str().size();
|
||||
for(size_t i=0; i<n; ++i)
|
||||
header_file << "/";
|
||||
header_file << endl;
|
||||
header_file << ss.str();
|
||||
header_file << "//Forwards to the appropriate code" << endl;
|
||||
header_file << "// that works on the detected compiler" << endl;
|
||||
header_file << endl << endl;
|
||||
|
||||
cv_t::iterator it=vendors.begin(), itEnd = vendors.end();
|
||||
|
||||
header_file << "#ifdef LOKI_USE_REFERENCE" << endl;
|
||||
header_file << "#\tinclude \".\\Reference\\" << header << "\"" << endl;
|
||||
header_file << "#else" << endl;
|
||||
|
||||
header_file << "#\tif " << it->version_test << endl;
|
||||
header_file << "#\t\tinclude \".\\" << it->subdir;
|
||||
header_file << "\\" << header << "\""<< endl;
|
||||
++it;
|
||||
for(; it!=itEnd; ++it)
|
||||
{
|
||||
header_file << "#elif " << it->version_test << endl;
|
||||
header_file << "#\t\tinclude \".\\" << it->subdir;
|
||||
header_file << "\\" << header << "\""<< endl;
|
||||
}
|
||||
header_file << "#\telse" << endl;
|
||||
header_file << "\t\t//Define LOKI_USE_REFERENCE and get back to us on the results" << endl;
|
||||
header_file << "#\t\terror Compiler not tested with Loki, #define LOKI_USE_REFERENCE" << endl;
|
||||
header_file << "#\tendif" << endl;
|
||||
header_file << "#endif" << endl;
|
||||
}
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
system("PAUSE");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
21
tools/HeaderGen/HeaderGen.sln
Normal file
21
tools/HeaderGen/HeaderGen.sln
Normal file
|
@ -0,0 +1,21 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 7.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HeaderGen", "HeaderGen.vcproj", "{402B97D0-B8F8-4B89-97AC-F031849FD94E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
ConfigName.0 = Debug
|
||||
ConfigName.1 = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectDependencies) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{402B97D0-B8F8-4B89-97AC-F031849FD94E}.Debug.ActiveCfg = Debug|Win32
|
||||
{402B97D0-B8F8-4B89-97AC-F031849FD94E}.Debug.Build.0 = Debug|Win32
|
||||
{402B97D0-B8F8-4B89-97AC-F031849FD94E}.Release.ActiveCfg = Release|Win32
|
||||
{402B97D0-B8F8-4B89-97AC-F031849FD94E}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
129
tools/HeaderGen/HeaderGen.vcproj
Normal file
129
tools/HeaderGen/HeaderGen.vcproj
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?xml version="1.0" encoding = "Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.00"
|
||||
Name="HeaderGen"
|
||||
ProjectGUID="{402B97D0-B8F8-4B89-97AC-F031849FD94E}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/HeaderGen.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/HeaderGen.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
OmitFramePointers="TRUE"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/HeaderGen.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
|
||||
<File
|
||||
RelativePath="HeaderGen.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc">
|
||||
<File
|
||||
RelativePath="C:\Program Files\Microsoft Visual Studio .NET\Vc7\include\fstream">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="C:\Program Files\Microsoft Visual Studio .NET\Vc7\include\iostream">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="ReadMe.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
21
tools/HeaderGen/Headers.lst
Normal file
21
tools/HeaderGen/Headers.lst
Normal file
|
@ -0,0 +1,21 @@
|
|||
AbstractFactory.h
|
||||
AssocVector.h
|
||||
EmptyType.h
|
||||
Factory.h
|
||||
Functor.h
|
||||
HierarchyGenerators.h
|
||||
MultiMethods.h
|
||||
NullType.h
|
||||
Singleton.h
|
||||
SmallObj.h
|
||||
SmartPtr.h
|
||||
static_check.h
|
||||
Threads.h
|
||||
Tuple.h
|
||||
TypeInfo.h
|
||||
Typelist.h
|
||||
TypeManip.h
|
||||
TypeTraits.h
|
||||
Visitor.h
|
||||
Singleton.cpp
|
||||
SmallObj.cpp
|
3
tools/HeaderGen/readme.txt
Normal file
3
tools/HeaderGen/readme.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
Cheesy vector-header generation tool
|
||||
Yes, I'm that lazy
|
||||
MKH
|
11
tools/HeaderGen/vendors.lst
Normal file
11
tools/HeaderGen/vendors.lst
Normal file
|
@ -0,0 +1,11 @@
|
|||
(_MSC_VER >= 1300)
|
||||
MSVC\1300
|
||||
|
||||
(_MSC_VER >= 1200)
|
||||
MSVC\1200
|
||||
|
||||
( (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 1)) )
|
||||
Reference
|
||||
|
||||
(__BORLANDC__)
|
||||
Borland
|
21
tools/RegressionTest/LokiRegressionTest.sln
Normal file
21
tools/RegressionTest/LokiRegressionTest.sln
Normal file
|
@ -0,0 +1,21 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 7.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LokiRegressionTest", "LokiRegressionTest.vcproj", "{E7FC3709-2BA7-4EAB-AF6B-B3ABC9BE493B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
ConfigName.0 = Debug
|
||||
ConfigName.1 = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectDependencies) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{E7FC3709-2BA7-4EAB-AF6B-B3ABC9BE493B}.Debug.ActiveCfg = Debug|Win32
|
||||
{E7FC3709-2BA7-4EAB-AF6B-B3ABC9BE493B}.Debug.Build.0 = Debug|Win32
|
||||
{E7FC3709-2BA7-4EAB-AF6B-B3ABC9BE493B}.Release.ActiveCfg = Release|Win32
|
||||
{E7FC3709-2BA7-4EAB-AF6B-B3ABC9BE493B}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
164
tools/RegressionTest/LokiRegressionTest.vcproj
Normal file
164
tools/RegressionTest/LokiRegressionTest.vcproj
Normal file
|
@ -0,0 +1,164 @@
|
|||
<?xml version="1.0" encoding = "Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.00"
|
||||
Name="LokiRegressionTest"
|
||||
ProjectGUID="{E7FC3709-2BA7-4EAB-AF6B-B3ABC9BE493B}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
ForceConformanceInForLoopScope="TRUE"
|
||||
RuntimeTypeInfo="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/LokiTest.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/LokiTest.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
OmitFramePointers="TRUE"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
ForceConformanceInForLoopScope="TRUE"
|
||||
RuntimeTypeInfo="TRUE"
|
||||
UsePrecompiledHeader="3"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/LokiTest.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
|
||||
<File
|
||||
RelativePath="..\..\SDK\Engine\Loki\Loki.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="LokiTest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="LokiTest.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="LokiTestTypes.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc">
|
||||
<File
|
||||
RelativePath="LokiTest_TypeList.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="LokiTest_TypeManip.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="LokiTest_TypeTraits.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Loki"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="..\..\SDK\Loki\NullType.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\SDK\Loki\VC7\TypeInfo.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\SDK\Loki\VC7\TypeList.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\SDK\Loki\VC7\TypeManip.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\SDK\Loki\VC7\TypeTraits.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="ReadMe.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
81
tools/RegressionTest/LokiTest.cpp
Normal file
81
tools/RegressionTest/LokiTest.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
// LokiTest.cpp : Defines the entry point for the console application.
|
||||
//
|
||||
|
||||
#include <conio.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
//#define LOKI_USE_REFERENCE
|
||||
|
||||
#include <Loki\static_check.h>
|
||||
#include <Loki\NullType.h>
|
||||
#include <Loki\TypeInfo.h>
|
||||
#include <Loki\TypeManip.h>
|
||||
#include <Loki\TypeList.h>
|
||||
#include <Loki\TypeTraits.h>
|
||||
|
||||
//The test use macros so that you can comment out any test
|
||||
// that result in compilation errors and continue testing
|
||||
// the remaining components
|
||||
//TODO break into seperate files, use boost methods to test
|
||||
// successful & unsuccessful compilations
|
||||
|
||||
#include "LokiTestTypes.h"
|
||||
#include "LokiTest_TypeManip.h"
|
||||
#include "LokiTest_TypeList.h"
|
||||
#include "LokiTest_TypeInfo.h"
|
||||
#include "LokiTest_TypeTraits.h"
|
||||
|
||||
//LOKI_TEST_TYPE2TYPE_HEADER
|
||||
LOKI_TEST_TYPE2TYPE_HEADER_BROKEN_PATTERN_MATCHING
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
argc;
|
||||
argv;
|
||||
//Compile-Time Assertions
|
||||
STATIC_CHECK(true, ThisShouldCompile);
|
||||
//STATIC_CHECK(false, ThisShouldNotCompile);
|
||||
|
||||
LOKI_TEST_NULLTYPE;
|
||||
|
||||
//Test TypeManip
|
||||
LOKI_TEST_INT2TYPE;
|
||||
//LOKI_TEST_TYPE2TYPE;
|
||||
LOKI_TEST_TYPE2TYPE_BROKEN_PATTERN_MATCHING;
|
||||
LOKI_TEST_SELECT;
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127) //constant conditionals
|
||||
LOKI_TEST_CONVERSION;
|
||||
#pragma warning(pop)
|
||||
|
||||
//TypeInfo
|
||||
LOKI_TEST_TYPEINFO;
|
||||
|
||||
//TypeTraits
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127) //constant conditionals
|
||||
{
|
||||
//TODO figure out correct results
|
||||
cout<<"Testing TypeTraits"<<endl;
|
||||
DUMP_TRAITS(int);
|
||||
DUMP_TRAITS(float);
|
||||
DUMP_TRAITS(volatile unsigned int);
|
||||
DUMP_TRAITS(const float);
|
||||
cout<<"Are the const & volatile qualifers handled correctly?"<<endl;
|
||||
cout<<endl<<endl;
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
//Test TypeList
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127) //constant conditionals
|
||||
LOKI_TEST_LENGTH;
|
||||
#pragma warning(pop)
|
||||
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
//*/
|
37
tools/RegressionTest/LokiTestTypes.h
Normal file
37
tools/RegressionTest/LokiTestTypes.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#pragma once
|
||||
#ifndef __LOKITESTTYPES_H
|
||||
#define __LOKITESTTYPES_H
|
||||
//Types to use in the test
|
||||
namespace Loki
|
||||
{
|
||||
namespace RegressionTest
|
||||
{
|
||||
struct Complex
|
||||
{
|
||||
float r,i;
|
||||
};
|
||||
struct Complex_Convertable
|
||||
{
|
||||
Complex_Convertable(){}
|
||||
Complex_Convertable(float x) : r(x), i(0) {}
|
||||
float r,i;
|
||||
};
|
||||
struct TwoWay
|
||||
{
|
||||
TwoWay(double x) : r(x) {}
|
||||
operator double(){return r;}
|
||||
double r;
|
||||
};
|
||||
struct SuperClass
|
||||
{
|
||||
};
|
||||
struct SubClass : SuperClass
|
||||
{
|
||||
};
|
||||
typedef TYPELIST_1(Loki::NullType) tyNullList;
|
||||
typedef TYPELIST_1(void) tyList1;
|
||||
typedef TYPELIST_2(int, double) tyList2;
|
||||
typedef TYPELIST_5(std::vector<int>, Loki::RegressionTest::Complex, void, int, double) tyList5;
|
||||
}
|
||||
}
|
||||
#endif
|
58
tools/RegressionTest/LokiTest_TypeInfo.h
Normal file
58
tools/RegressionTest/LokiTest_TypeInfo.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
|
||||
namespace Loki
|
||||
{
|
||||
namespace Test
|
||||
{
|
||||
struct CTBaseType
|
||||
{
|
||||
};
|
||||
struct CTDerivedType : CTBaseType
|
||||
{
|
||||
};
|
||||
struct RTBaseType
|
||||
{
|
||||
virtual ~RTBaseType(){}
|
||||
virtual const char*const name(){return "BaseType";}
|
||||
};
|
||||
struct RTDerivedType : RTBaseType
|
||||
{
|
||||
virtual const char*const name(){return "DerivedType";}
|
||||
};
|
||||
}//ns Test
|
||||
}//ns Loki
|
||||
|
||||
//TODO Test the other operators and before
|
||||
#define LOKI_TEST_TYPEINFO\
|
||||
{\
|
||||
cout<<"Testing TypeInfo"<<endl;\
|
||||
Loki::TypeInfo type_CTDerived(typeid(Loki::Test::CTDerivedType));\
|
||||
\
|
||||
Loki::Test::CTDerivedType* pDerived=0; pDerived;\
|
||||
if(typeid(*pDerived) == type_CTDerived)\
|
||||
cout<<"Compile-time TypeInfo works"<<endl;\
|
||||
else\
|
||||
cout<<"Compile-time TypeInfo is ***BROKEN***"<<endl;\
|
||||
\
|
||||
try\
|
||||
{\
|
||||
Loki::TypeInfo type_RTDerived(typeid(Loki::Test::RTDerivedType));\
|
||||
Loki::Test::RTBaseType* pBase = new Loki::Test::RTDerivedType;\
|
||||
pBase;\
|
||||
if(typeid(*pBase) == type_RTDerived)\
|
||||
cout<<"Run-time TypeInfo works"<<endl;\
|
||||
else\
|
||||
{\
|
||||
cout<<"Run-time TypeInfo is ***BROKEN***"<<endl;\
|
||||
cout<<"Is RTTI enabled?"<<endl;\
|
||||
cout<<"Compiler thinks pBase points to a ";\
|
||||
cout<<typeid(*pBase).name()<<endl;\
|
||||
}\
|
||||
delete pBase;\
|
||||
}\
|
||||
catch(...)\
|
||||
{\
|
||||
cout<<"Run-time TypeInfo is ***BROKEN***"<<endl;\
|
||||
cout<<"Run-time TypeInfo check threw - Is RTTI enabled?"<<endl;\
|
||||
}\
|
||||
cout<<endl<<endl;\
|
||||
}
|
79
tools/RegressionTest/LokiTest_TypeList.h
Normal file
79
tools/RegressionTest/LokiTest_TypeList.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
|
||||
#define LOKI_TEST_LENGTH\
|
||||
{\
|
||||
cout<<"Testing Length"<<endl;\
|
||||
cout<<"Length of List1: "<<Loki::TL::Length<Loki::RegressionTest::tyList1>::value<<endl;\
|
||||
cout<<"Length of List2: "<<Loki::TL::Length<Loki::RegressionTest::tyList2>::value<<endl;\
|
||||
cout<<"Length of List5: "<<Loki::TL::Length<Loki::RegressionTest::tyList5>::value<<endl;\
|
||||
if ( (Loki::TL::Length<Loki::RegressionTest::tyList1>::value==1) &&\
|
||||
(Loki::TL::Length<Loki::RegressionTest::tyList2>::value==2) &&\
|
||||
(Loki::TL::Length<Loki::RegressionTest::tyList5>::value==5) )\
|
||||
cout<<"Normal cases work"<<endl;\
|
||||
else\
|
||||
cout<<"Normal cases are ***BROKEN***"<<endl;\
|
||||
cout<<"Length of NullType: "<<Loki::TL::Length<Loki::NullType>::value<<endl;\
|
||||
cout<<"Length of NullList: "<<Loki::TL::Length<Loki::RegressionTest::tyNullList>::value<<endl;\
|
||||
if ( (Loki::TL::Length<Loki::NullType>::value==0) &&\
|
||||
(Loki::TL::Length<Loki::RegressionTest::tyNullList>::value==0) )\
|
||||
cout<<"Pathological cases work"<<endl;\
|
||||
else\
|
||||
cout<<"Pathological cases are ***BROKEN***"<<endl;\
|
||||
cout<<endl<<endl;\
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void TypeAt()
|
||||
{
|
||||
cout<<endl<<"Testing TypeAt"<<endl;
|
||||
//typedef TypeAt<List2, -1>::Result FailsToCompile;
|
||||
typedef TypeAt<List2, 0>::Result FirstType;
|
||||
typedef TypeAt<List2, 1>::Result SecondType;
|
||||
typedef TypeAt<List2, 2>::Result ThirdType;
|
||||
typedef TypeAt<List2, 3>::Result FourthType;
|
||||
typedef TypeAt<List2, 4>::Result FifthType;
|
||||
cout<<typeid(FirstType).name()<<endl;
|
||||
cout<<typeid(SecondType).name()<<endl;
|
||||
cout<<typeid(ThirdType).name()<<endl;
|
||||
cout<<typeid(FourthType).name()<<endl;
|
||||
cout<<typeid(FifthType).name()<<endl;
|
||||
}
|
||||
/*
|
||||
void IndexOf()
|
||||
{
|
||||
cout<<endl<<"Testing IndexOf"<<endl;
|
||||
cout<<"IndexOf int: "<<IndexOf<List2, int>::value<<endl;
|
||||
cout<<"IndexOf double: "<<IndexOf<List2, double>::value<<endl;
|
||||
cout<<"IndexOf vector: "<<IndexOf<List2, vector<int> >::value<<endl;
|
||||
cout<<"IndexOf Complex: "<<IndexOf<List2, Complex>::value<<endl;
|
||||
cout<<"IndexOf long: "<<IndexOf<List2, long>::value<<endl;
|
||||
}
|
||||
/*
|
||||
void Append()
|
||||
{
|
||||
cout <<endl<<"Testing Append" << endl;
|
||||
typedef Append<NullType, NullType>::Result List0;
|
||||
typedef Append<List0, bool>::Result List1;
|
||||
typedef Append<List1, double>::Result List2;
|
||||
typedef Append<List2, NullType>:: Result List3;
|
||||
cout << Length<List0>::value << endl;
|
||||
cout << Length<List1>::value << "\t";
|
||||
cout << typeid(TypeAt<List1, Length<List1>::value -1 >::Result).name() << endl;
|
||||
cout << Length<List2>::value << "\t";
|
||||
cout << typeid(TypeAt<List2, Length<List2>::value -1>::Result).name() << endl;
|
||||
cout << Length<List3>::value << "\t";
|
||||
cout << typeid(TypeAt<List3, Length<List3>::value -1>::Result).name() << endl;
|
||||
}
|
||||
/*
|
||||
void Erase()
|
||||
{
|
||||
cout <<endl<< "Testing Erase" << endl;
|
||||
cout <<"Erase is broken, notice the size goes up"<<endl;
|
||||
cout << Length<List1>::value << "\t"
|
||||
<< typeid(TypeAt<List1, Length<List1>::value -1 >::Result).name() << endl;
|
||||
cout << Length<List2>::value << "\t"
|
||||
<< typeid(TypeAt<List2, Length<List2>::value -1>::Result).name() << endl;
|
||||
cout << Length<List3>::value << "\t"
|
||||
<< typeid(TypeAt<List3, Length<List3>::value -1>::Result).name() << endl;
|
||||
}
|
||||
*/
|
164
tools/RegressionTest/LokiTest_TypeManip.h
Normal file
164
tools/RegressionTest/LokiTest_TypeManip.h
Normal file
|
@ -0,0 +1,164 @@
|
|||
|
||||
#include "LokiTestTypes.h"
|
||||
using std::endl;
|
||||
using std::cout;
|
||||
|
||||
//You're not using a C++ compiler if this fails.
|
||||
//Requires #include <Loki\NullType.h>
|
||||
#define LOKI_TEST_NULLTYPE\
|
||||
{\
|
||||
Loki::NullType nullTest;\
|
||||
cout<<"Testing NullType"<<endl;\
|
||||
cout<<"Sizeof nullType: "<<sizeof(nullTest)<<endl;\
|
||||
cout<<endl<<endl;\
|
||||
}
|
||||
|
||||
#define LOKI_TEST_SELECT\
|
||||
{\
|
||||
cout<<"Testing Select"<<endl;\
|
||||
typedef Loki::Select<true, void, Loki::NullType>::Result TrueType;\
|
||||
typedef Loki::Select<false, int, double>::Result FalseType;\
|
||||
cout<<"True case: "<<typeid(TrueType).name()<<endl;\
|
||||
cout<<"False case: "<<typeid(FalseType).name()<<endl;\
|
||||
cout<<endl<<endl;\
|
||||
}
|
||||
|
||||
|
||||
//TODO Need more test cases for _STRICT varaints
|
||||
//TODO What is the proper conversion results to/from void?
|
||||
#define LOKI_TEST_CONVERSION\
|
||||
{\
|
||||
cout<<"Testing Conversion"<<endl;\
|
||||
typedef Loki::Conversion<int, int> tySame;\
|
||||
typedef Loki::Conversion<int, Loki::RegressionTest::Complex> tyNoCon;\
|
||||
typedef Loki::Conversion<int, Loki::RegressionTest::Complex_Convertable> tyCon;\
|
||||
typedef Loki::Conversion<int, Loki::RegressionTest::TwoWay> ty2Way;\
|
||||
typedef Loki::Conversion<void, int> tyVoid;\
|
||||
cout<< tySame::sameType<<" <int, int>::sameType" <<endl;\
|
||||
cout<< tySame::exists<<" <int, int>::exists" <<endl;\
|
||||
cout<< tySame::exists2Way<<" <int, int>::exists2Way" <<endl;\
|
||||
if (tySame::sameType && tySame::exists && tySame::exists2Way)\
|
||||
cout<<"Works for same type"<<endl;\
|
||||
else\
|
||||
cout<<"Same type is ***BROKEN***"<<endl;\
|
||||
cout<<endl;\
|
||||
\
|
||||
cout<< tyNoCon::sameType<<" <int, Complex>::sameType" <<endl;\
|
||||
cout<< tyNoCon::exists<<" <int, Complex>::exists" <<endl;\
|
||||
cout<< tyNoCon::exists2Way<<" <int, Complex>::exists2Way" <<endl;\
|
||||
if (!tyNoCon::sameType && !tyNoCon::exists && !tyNoCon::exists2Way)\
|
||||
cout<<"Works for non-convertibles"<<endl;\
|
||||
else\
|
||||
cout<<"Non-convertibles is ***BROKEN***"<<endl;\
|
||||
cout<<endl;\
|
||||
\
|
||||
cout<< tyCon::sameType<<" <int, Complex_Convertable>::sameType" <<endl;\
|
||||
cout<< tyCon::exists<<" <int, Complex_Convertable>::exists" <<endl;\
|
||||
cout<< tyCon::exists2Way<<" <int, Complex_Convertable>::exists2Way" <<endl;\
|
||||
if (!tyCon::sameType && tyCon::exists && !tyCon::exists2Way)\
|
||||
cout<<"Works for one-way convertible"<<endl;\
|
||||
else\
|
||||
cout<<"One-way convertible is ***BROKEN***"<<endl;\
|
||||
cout<<endl;\
|
||||
\
|
||||
cout<< ty2Way::sameType<<" <int, TwoWay>::sameType" <<endl;\
|
||||
cout<< ty2Way::exists<<" <int, TwoWay>::exists" <<endl;\
|
||||
cout<< ty2Way::exists2Way<<" <int, TwoWay>::exists2Way" <<endl;\
|
||||
if (!ty2Way::sameType && ty2Way::exists && ty2Way::exists2Way)\
|
||||
cout<<"Works for two-way convertibles"<<endl;\
|
||||
else\
|
||||
cout<<"Two-way convertibles is ***BROKEN***"<<endl;\
|
||||
cout<<endl;\
|
||||
\
|
||||
cout<< tyVoid::sameType<<" <void, int>::sameType" <<endl;\
|
||||
cout<< tyVoid::exists<<" <void, int>::exists" <<endl;\
|
||||
cout<< tyVoid::exists2Way<<" <void, int>::exists2Way" <<endl;\
|
||||
if (!tyVoid::sameType && !tyVoid::exists && !tyVoid::exists2Way)\
|
||||
cout<<"Works for void"<<endl;\
|
||||
else\
|
||||
cout<<"Void conversion is ***BROKEN***"<<endl;\
|
||||
cout<<"What is the correct behavior here?"<<endl;\
|
||||
cout<<endl;\
|
||||
\
|
||||
cout<< SUPERSUBCLASS(Loki::RegressionTest::SuperClass, Loki::RegressionTest::SubClass)<<" SuperSubClass Super&Sub"<<endl;\
|
||||
cout<< SUPERSUBCLASS_STRICT(Loki::RegressionTest::SuperClass, Loki::RegressionTest::SubClass)<<" SuperSubClass_Strict Super&Sub"<<endl;\
|
||||
cout<< SUPERSUBCLASS(void, Loki::RegressionTest::SubClass)<<" to void*"<<endl;\
|
||||
cout<< SUPERSUBCLASS_STRICT(void, Loki::RegressionTest::SubClass)<<" _Strict to void*"<<endl;\
|
||||
cout<< SUPERSUBCLASS(Loki::RegressionTest::SubClass, Loki::RegressionTest::SuperClass)<<" SubSuperClass Sub&Super"<<endl;\
|
||||
cout<<endl<<endl;\
|
||||
}
|
||||
|
||||
#define LOKI_TEST_INT2TYPE\
|
||||
{\
|
||||
cout<<"Testing Int2Type"<<endl;\
|
||||
typedef Loki::Int2Type<0> tyZero;\
|
||||
typedef Loki::Int2Type<1> tyOne;\
|
||||
typedef Loki::Int2Type<-1> tyNegOne;\
|
||||
cout<<" Zero: "<<typeid(tyZero).name()<<endl;\
|
||||
cout<<" One: "<<typeid(tyOne).name()<<endl;\
|
||||
cout<<"Neg One: "<<typeid(tyNegOne).name()<<endl;\
|
||||
cout<<endl<<endl;\
|
||||
}
|
||||
|
||||
//I think this example is an undesirable way to solve this
|
||||
// problem, but we're just exercising Type2Type
|
||||
//MSVC7 has a template pattern matching problem that prevents this
|
||||
// example solution from compiling correctly.
|
||||
// Type2Type does work, but the solution it was created for doesn't
|
||||
#define LOKI_TEST_TYPE2TYPE_HEADER\
|
||||
struct Widget\
|
||||
{\
|
||||
Widget(int x, int reserved)\
|
||||
{\
|
||||
assert(reserved==-1);\
|
||||
}\
|
||||
};\
|
||||
struct NewWidget\
|
||||
{\
|
||||
NewWidget(int x)\
|
||||
{}\
|
||||
};\
|
||||
template<class T, class U>\
|
||||
T* Create(const U& arg, Loki::Type2Type<T>)\
|
||||
{\
|
||||
return new T(arg);\
|
||||
}\
|
||||
template<class U>\
|
||||
Widget* Create(const U& arg, Loki::Type2Type<Widget>)\
|
||||
{\
|
||||
return new Widget(arg, -1);\
|
||||
}
|
||||
#define LOKI_TEST_TYPE2TYPE\
|
||||
{\
|
||||
cout<<"Testing Type2Type"<<endl;\
|
||||
NewWidget* pNewWidget = Create(4, Loki::Type2Type<NewWidget>() );\
|
||||
delete pNewWidget;\
|
||||
Widget* pWidget = Create(100, Loki::Type2Type<Widget>() );\
|
||||
delete pWidget;\
|
||||
cout<<"Used Type2Type"<<endl;\
|
||||
}
|
||||
|
||||
#define LOKI_TEST_TYPE2TYPE_HEADER_BROKEN_PATTERN_MATCHING\
|
||||
struct Widget\
|
||||
{\
|
||||
Widget(int x, int reserved)\
|
||||
{\
|
||||
cc=x;\
|
||||
assert(reserved==-1);\
|
||||
}\
|
||||
int cc;\
|
||||
};\
|
||||
template<class U>\
|
||||
Widget* Create(const U& arg, Loki::Type2Type<Widget>)\
|
||||
{\
|
||||
return new Widget(arg, -1);\
|
||||
}
|
||||
#define LOKI_TEST_TYPE2TYPE_BROKEN_PATTERN_MATCHING\
|
||||
{\
|
||||
cout<<"Testing Type2Type"<<endl;\
|
||||
Widget* pWidget = Create(100, Loki::Type2Type<Widget>() );\
|
||||
delete pWidget;\
|
||||
cout<<"Used Type2Type"<<endl;\
|
||||
cout<<endl<<endl;\
|
||||
}
|
||||
|
27
tools/RegressionTest/LokiTest_TypeTraits.h
Normal file
27
tools/RegressionTest/LokiTest_TypeTraits.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
#define DUMP_TRAIT(type, trait)\
|
||||
if(Loki::TypeTraits<type>::trait)\
|
||||
cout<<#trait<<", ";
|
||||
|
||||
#define DUMP_TRAITS(type)\
|
||||
{\
|
||||
cout<<"("<<#type<<") ";\
|
||||
DUMP_TRAIT(type, isPointer);\
|
||||
DUMP_TRAIT(type, isReference);\
|
||||
DUMP_TRAIT(type, isMemberPointer);\
|
||||
DUMP_TRAIT(type, isStdUnsignedInt);\
|
||||
DUMP_TRAIT(type, isStdSignedInt);\
|
||||
DUMP_TRAIT(type, isStdIntegral);\
|
||||
DUMP_TRAIT(type, isStdFloat);\
|
||||
DUMP_TRAIT(type, isStdArith);\
|
||||
DUMP_TRAIT(type, isStdFundamental);\
|
||||
DUMP_TRAIT(type, isUnsignedInt);\
|
||||
DUMP_TRAIT(type, isSignedInt);\
|
||||
DUMP_TRAIT(type, isIntegral);\
|
||||
DUMP_TRAIT(type, isFloat);\
|
||||
DUMP_TRAIT(type, isArith);\
|
||||
DUMP_TRAIT(type, isFundamental);\
|
||||
DUMP_TRAIT(type, isConst);\
|
||||
DUMP_TRAIT(type, isVolatile);\
|
||||
cout<<endl;\
|
||||
}
|
5
tools/RegressionTest/readme.txt
Normal file
5
tools/RegressionTest/readme.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
Incomplete, needs work
|
||||
Output should be purged, and the results automatically verified.
|
||||
|
||||
|
||||
MKH
|
Loading…
Reference in a new issue