Using smaller runtime reloading code based on http://github.com/skeeto/interactive-c-demo

master
Martin Felis 2016-09-16 17:29:17 +02:00
parent 678266e2ff
commit c4da4e1037
166 changed files with 211 additions and 19376 deletions

View File

@ -1,169 +0,0 @@
cmake_minimum_required(VERSION 2.8)
project( RuntimeCompiledCPlusPlus )
#
# Options
#
option(BUILD_EXAMPLES "Build example applications" ON)
option(GLFW_SYSTEM "Use the operating system glfw library" OFF)
find_package(OpenGL REQUIRED)
if(UNIX AND NOT APPLE)
set(BUILD_TYPE SHARED)
else()
set(BUILD_TYPE STATIC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
include(cmake/ProjectFiles.cmake)
#
# RuntimeCompiler
#
add_library(RuntimeCompiler ${BUILD_TYPE} ${RuntimeCompiler_SRCS})
#
# RuntimeObjectSystem
#
add_library(RuntimeObjectSystem ${BUILD_TYPE} ${RuntimeObjectSystem_SRCS})
target_link_libraries(RuntimeObjectSystem RuntimeCompiler)
if(UNIX)
target_link_libraries(RuntimeObjectSystem dl)
endif()
#
# Make Install
#
install(DIRECTORY RuntimeObjectSystem/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/RuntimeObjectSystem
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY RuntimeCompiler/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/RuntimeCompiler
FILES_MATCHING PATTERN "*.h")
install(TARGETS RuntimeObjectSystem RuntimeCompiler
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)
if(BUILD_EXAMPLES)
#
# ConsoleExample
#
add_executable(ConsoleExample ${ConsoleExample_SRCS})
target_link_libraries(ConsoleExample RuntimeCompiler RuntimeObjectSystem)
#
# Renderer
#
add_library(Renderer ${BUILD_TYPE} ${Renderer_SRCS})
target_link_libraries(Renderer ${OPENGL_LIBRARIES} ${ASSIMP_LIBRARIES})
#
# Systems
#
add_library(Systems ${BUILD_TYPE} ${Systems_SRCS})
#
# Freetype WIN32
#
if(WIN32)
set(FREETYPE_INCLUDE_DIR_freetype2 ${CMAKE_SOURCE_DIR}/External/support/freetype/include/freetype)
set(FREETYPE_INCLUDE_DIR_ft2build ${CMAKE_SOURCE_DIR}/External/support/freetype/include)
if(${CMAKE_CL_64})
set(FREETYPE_LIBRARY ${CMAKE_SOURCE_DIR}/External/support/lib/freetype2410MTx64.lib)
else()
set(FREETYPE_LIBRARY ${CMAKE_SOURCE_DIR}/External/support/lib/freetype2410MT.lib)
endif()
elseif(APPLE)
set(FREETYPE_INCLUDE_DIR_freetype2 ${CMAKE_SOURCE_DIR}/External/support/freetype/include/freetype)
set(FREETYPE_INCLUDE_DIR_ft2build ${CMAKE_SOURCE_DIR}/External/support/freetype/include)
FIND_LIBRARY(ZLIB_LIBRARY libs)
MARK_AS_ADVANCED(ZLIB_LIBRARY)
set(FREETYPE_LIBRARY ${CMAKE_SOURCE_DIR}/External/support/lib/MacOSX/libfreetype.a ${ZLIB_LIBRARY})
endif()
#
# glfw
#
if(GLFW_SYSTEM)
set(GLFW_LIBRARIES glfw)
else()
include_directories(External/glfw/include)
if(WIN32)
set(GLFW_LIBRARIES glfw winmm)
add_subdirectory( ${CMAKE_SOURCE_DIR}/External/glfw/projects )
else()
add_library( glfw STATIC IMPORTED )
if(APPLE)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
FIND_LIBRARY(IOKIT_LIBRARY IOKit)
MARK_AS_ADVANCED(COCOA_LIBRARY IOKIT_LIBRARY)
set_target_properties( glfw PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/External/glfw/libOSX/libglfw.a )
set(GLFW_LIBRARIES glfw ${COCOA_LIBRARY} ${IOKIT_LIBRARY})
else()
set_target_properties( glfw PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/External/glfw/libX11/libglfw.a )
set(GLFW_LIBRARIES glfw X11 pthread)
endif()
endif()
endif()
#
# assimp
#
if(WIN32)
add_library( assimp STATIC IMPORTED )
set(ASSIMP_LIBRARIES assimp)
if(${CMAKE_CL_64})
set_target_properties( assimp PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/External/assimp/lib/assimp_release-dll_x64/assimp.lib )
set(ASSIMP_DLL ${CMAKE_SOURCE_DIR}/External/assimp/bin/assimp_release-dll_win32/Assimp64.dll)
else()
set_target_properties( assimp PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/External/assimp/lib/assimp_release-dll_win32/assimp.lib )
set(ASSIMP_DLL ${CMAKE_SOURCE_DIR}/External/assimp/bin/assimp_release-dll_win32/Assimp32.dll)
endif()
if(CMAKE_GENERATOR STREQUAL "NMake Makefiles")
file(COPY ${ASSIMP_DLL} DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
else()
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
file(COPY ${ASSIMP_DLL} DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${OUTPUTCONFIG})
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
endif()
endif()
#
# SimpleTest
#
add_subdirectory(External/libRocket/Build)
include_directories(
${OPENGL_INCLUDE_DIR}
External/libRocket/Include
External/assimp/include
)
if(WIN32)
add_executable(SimpleTest WIN32 ${SimpleTest_SRCS})
else()
add_executable(SimpleTest ${SimpleTest_SRCS})
endif()
target_link_libraries(SimpleTest
RuntimeCompiler
RuntimeObjectSystem
Renderer
Systems
RocketCore
RocketControls
RocketDebugger
${OPENGL_LIBRARIES}
${GLFW_LIBRARIES}
${ASSIMP_LIBRARIES}
)
if(MSVC)
set_target_properties(SimpleTest ConsoleExample PROPERTIES COMPILE_FLAGS "/FC")
else()
Set(CMAKE_CXX_FLAGS "-DCOMPILE_PATH=\"\\\"$(PWD)\\\"\"")
endif()
endif()

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Common</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

View File

@ -1,55 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef AUCOLOR_DEF
#define AUCOLOR_DEF
#include <string.h> // for memcpy on linux
class AUColor
{
public:
AUColor(float Red = 0.0f, float Green = 0.0f, float Blue = 0.0f, float Alpha = 0.0f)
{
m_Color.r = Red;
m_Color.g = Green;
m_Color.b = Blue;
m_Color.a = Alpha;
}
AUColor( const float rgba[4] )
{
memcpy( m_Color.rgba, rgba, sizeof( m_Color.rgba ) );
}
union ColorUnion
{
struct
{
float r;
float g;
float b;
float a;
};
float rgba[4];
} m_Color;
};
#endif //AUCOLOR_DEF

View File

@ -1,184 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef AUDORIENTATION3D_DEFINED
#define AUDORIENTATION3D_DEFINED
#include "AUVec3f.inl" //interface relies on class AUVec3f
#include <limits> //for numerical limits
class AUOrientation3D
{
public:
AUOrientation3D() :
m_v3dForwards( 1.0f, 0.0f, 0.0f ),
m_v3dUp( 0.0f, 1.0f, 0.0f ),
m_v3dRight( 0.0f, 0.0f, 1.0f )
{
}
AUOrientation3D( const AUVec3f& v3dForwards_, const AUVec3f& v3dUp_) :
m_v3dForwards( v3dForwards_ ),
m_v3dUp( v3dUp_ )
{
OrthoNormalise();
}
//Inspectors
const AUVec3f& GetForwards() const { return m_v3dForwards; }
const AUVec3f& GetUp() const { return m_v3dUp; }
const AUVec3f& GetRight() const { return m_v3dRight; }
void LoadglViewMatrix( float *const fglMatrix_ ) const
{
//note: OpenGL camera defaults to looking down -z, thus orient z with Forwards
fglMatrix_[0] = m_v3dRight.x;
fglMatrix_[1] = m_v3dUp.x;
fglMatrix_[2] = -m_v3dForwards.x;
fglMatrix_[3] = 0.0f;
fglMatrix_[4] = m_v3dRight.y;
fglMatrix_[5] = m_v3dUp.y;
fglMatrix_[6] = -m_v3dForwards.y;
fglMatrix_[7] = 0.0f;
fglMatrix_[8] = m_v3dRight.z;
fglMatrix_[9] = m_v3dUp.z;
fglMatrix_[10] = -m_v3dForwards.z;
fglMatrix_[11] = 0.0f;
fglMatrix_[12] = 0.0f;
fglMatrix_[13] = 0.0f;
fglMatrix_[14] = 0.0f;
fglMatrix_[15] = 1.0f;
}
void LoadglObjectMatrix( float *const fglMatrix_ ) const
{
//note: OpenGL camera defaults to looking down -z, thus orient z with Forwards
fglMatrix_[0] = m_v3dForwards.x;
fglMatrix_[1] = m_v3dForwards.y;
fglMatrix_[2] = m_v3dForwards.z;
fglMatrix_[3] = 0.0f;
fglMatrix_[4] = m_v3dUp.x;
fglMatrix_[5] = m_v3dUp.y;
fglMatrix_[6] = m_v3dUp.z;
fglMatrix_[7] = 0.0f;
fglMatrix_[8] = m_v3dRight.x;
fglMatrix_[9] = m_v3dRight.y;
fglMatrix_[10] = m_v3dRight.z;
fglMatrix_[11] = 0.0f;
fglMatrix_[12] = 0.0f;
fglMatrix_[13] = 0.0f;
fglMatrix_[14] = 0.0f;
fglMatrix_[15] = 1.0f;
}
//Mutators
AUVec3f& GetForwards() { return m_v3dForwards; }
AUVec3f& GetUp() { return m_v3dUp; }
AUVec3f& GetRight() { return m_v3dRight; }
void Set( const AUVec3f& v3dForwards_, const AUVec3f& v3dUp_)
{
m_v3dForwards = v3dForwards_;
m_v3dUp = v3dUp_;
OrthoNormalise();
}
void Rotate( const AUVec3f& v3dAxis_, float fTheta_)
{
float fCosTheta = static_cast<float>( cos(fTheta_ ) );
float fSinTheta = static_cast<float>( sin(fTheta_ ) );
AUVec3f v3dtemp = v3dAxis_.Cross( m_v3dForwards );
m_v3dForwards += fSinTheta * v3dtemp +
( fCosTheta - 1.0f ) * v3dAxis_.Cross( v3dtemp );
v3dtemp = v3dAxis_.Cross( m_v3dUp );
m_v3dUp += fSinTheta * v3dtemp +
( fCosTheta - 1.0f ) * v3dAxis_.Cross( v3dtemp );
//orthonormalise coordinate system
OrthoNormalise();
}
protected:
void OrthoNormalise()
{
if( true == m_v3dForwards.Normalise() )
{
//have a normalised forwards vector
m_v3dRight = m_v3dForwards.Cross( m_v3dUp );
if( true == m_v3dRight.Normalise() )
{
//and now have a normalised right vector so safe to generate cross.
m_v3dUp = m_v3dRight.Cross( m_v3dForwards );
}
else
{
//have a forwards vector only, so generate an arbitary `up'.
m_v3dUp.SetX( m_v3dForwards.z );
m_v3dUp.SetY( m_v3dForwards.x );
m_v3dUp.SetZ( m_v3dForwards.y );
//will now get a 'guaranteed' right from this
m_v3dRight = m_v3dForwards.Cross( m_v3dUp );
//and so can generate a true up
m_v3dUp = m_v3dRight.Cross( m_v3dForwards );
}
}
else
{
//can't use forwards as our main vector, so try up
if( true == m_v3dUp.Normalise() )
{
//have a up vector only, so generate an arbitary `up'.
m_v3dForwards.SetX( m_v3dUp.z );
m_v3dForwards.SetY( m_v3dUp.x );
m_v3dForwards.SetZ( m_v3dUp.y );
//will now get a 'guaranteed' right from this
m_v3dRight = m_v3dForwards.Cross( m_v3dUp );
//and so can generate a true forwards
m_v3dForwards = m_v3dUp.Cross( m_v3dRight );
}
else
{
//have no appropriate starting vectors, so fake it.
m_v3dForwards.Set( 1.0f, 0.0f, 0.0f );
m_v3dUp.Set( 0.0f, 1.0f, 0.0f );
m_v3dRight.Set( 0.0f, 0.0f, 1.0f );
}
}
}
private:
AUVec3f m_v3dForwards;
AUVec3f m_v3dUp;
AUVec3f m_v3dRight;
};
#endif //AUDORIENTATION3D_DEFINED

View File

@ -1,211 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef AUVEC3F_DEFINED
#define AUVEC3F_DEFINED
#include <cmath>
#include <limits>
class AUVec3f
{
public:
AUVec3f(float fX_ = 0.0f, float fY_ = 0.0f, float fZ_ = 0.0f) :
x( fX_ ),
y( fY_ ),
z( fZ_ )
{
}
AUVec3f( const AUVec3f& v3din_ ) :
x( v3din_.x ),
y( v3din_.y ),
z( v3din_.z )
{
}
//Mutators
void SetX( float fX_ ) { x = fX_; }
void SetY( float fY_ ) { y = fY_; }
void SetZ( float fZ_ ) { z = fZ_; }
void Set( float fX_, float fY_, float fZ_ )
{
x = fX_;
y = fY_;
z = fZ_;
}
float Dot( const AUVec3f& V_ ) const
{
return x * V_.x
+ y * V_.y
+ z * V_.z;
}
AUVec3f Cross( const AUVec3f& V_ ) const
{
AUVec3f newV( y * V_.z - z * V_.y,
z * V_.x - x * V_.z,
x * V_.y - y * V_.x );
return newV;
}
bool Normalise()
{
float fMagnitude = Magnitude();
if(fMagnitude != 0.0f)
{
x /= fMagnitude;
y /= fMagnitude;
z /= fMagnitude;
return true;
}
else
{
return false;
}
}
AUVec3f GetNormalised() const
{
AUVec3f v = *this;
v.Normalise();
return v;
}
AUVec3f Lerp( const AUVec3f& V_, float t ) const
{
return (*this + (V_ - *this) * t);
}
bool IsInfinite() const
{
float inf = std::numeric_limits<float>::infinity();
return ( x == inf || y == inf || z == inf );
}
void SetInfinite()
{
x = y = z = std::numeric_limits<float>::infinity();
}
bool IsZero() const
{
return (x == 0.0f && y == 0.0f && z == 0.0f);
}
//Operators
AUVec3f& operator+=( const AUVec3f& V_ )
{
x += V_.x;
y += V_.y;
z += V_.z;
return *this;
}
AUVec3f& operator-=( const AUVec3f& V_ )
{
x -= V_.x;
y -= V_.y;
z -= V_.z;
return *this;
}
AUVec3f& operator*=( const float& fScalar_ )
{
x *= fScalar_;
y *= fScalar_;
z *= fScalar_;
return *this;
}
AUVec3f& operator/=( const float& fScalar_ )
{
x /= fScalar_;
y /= fScalar_;
z /= fScalar_;
return *this;
}
bool operator==( const AUVec3f& V_ ) const
{
return ( x == V_.x ) && ( y == V_.y ) && ( z == V_.z );
}
bool operator!=( const AUVec3f& V_ ) const
{
return !(*this == V_);
}
float Magnitude() const
{
return static_cast<float>( sqrt( Dot( *this ) ) );
}
float MagnitudeSqr() const
{
return static_cast<float>( Dot( *this ) );
}
AUVec3f operator+( const AUVec3f& V2_ ) const
{
AUVec3f newV_( *this );
return ( newV_ += V2_ );
}
AUVec3f operator-( const AUVec3f& V2_ ) const
{
AUVec3f newV_( *this );
return ( newV_ -= V2_ );
}
AUVec3f operator*( const float& fScalar_ ) const
{
AUVec3f newV_( *this );
return ( newV_ *= fScalar_ );
}
AUVec3f operator/( const float& fScalar_ )
{
AUVec3f newV_( *this );
return ( newV_ /= fScalar_ );
}
AUVec3f operator-()
{
AUVec3f newV_( -x, -y, -z );
return newV_;
}
float x;
float y;
float z;
};
//functions which do not have to be members
inline AUVec3f operator*( const float& fScalar_, const AUVec3f& V1_ )
{
return V1_ * fScalar_;
}
#endif //AUVEC3F_DEFINED

View File

@ -1,141 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="AUOrientation3D.inl" />
<None Include="AUVec3f.inl" />
<None Include="Math.inl" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AUColor.inl" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2947A63C-A245-4853-B4CC-476354188AEE}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Common</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,46 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef AUMATH_DEFINED
#define AUMATH_DEFINED
#define _USE_MATH_DEFINES
#include <math.h>
/* Adds some helpful macros and exposes the non-standard constants available in math.h (may not be portable):
* M_E - e
* M_LOG2E - log2(e)
* M_LOG10E - log10(e)
* M_LN2 - ln(2)
* M_LN10 - ln(10)
* M_PI - pi
* M_PI_2 - pi/2
* M_PI_4 - pi/4
* M_1_PI - 1/pi
* M_2_PI - 2/pi
* M_2_SQRTPI - 2/sqrt(pi)
* M_SQRT2 - sqrt(2)
* M_SQRT1_2 - 1/sqrt(2)
*/
#define DEG2RAD(deg) ((deg)*((PI)/(180.0)))
#define RAD2DEG(rad) ((rad)*((180.0)/(PI)))
#define LERP(a, b, t) ((a) + (t) * ((b) - (a)))
#endif // AUMATH_DEFINED

View File

@ -1,178 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1276108983">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1276108983" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1276108983" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1276108983." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.2955533" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1756156840" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
<builder buildPath="${workspace_loc:/ConsoleExample}/Debug" id="cdt.managedbuild.target.gnu.builder.exe.debug.377545259" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.1810853815" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1907407507" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.846703946" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1425650716" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.688363401" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/RuntimeObjectSystem}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/RuntimeCompiler}&quot;"/>
<listOptionValue builtIn="false" value=".././"/>
</option>
<option id="gnu.cpp.compiler.option.other.other.2075038741" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0" valueType="string"/>
<option id="gnu.cpp.compiler.option.preprocessor.def.464421523" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
<listOptionValue builtIn="false" value="COMPILE_PATH=\&quot;$(PWD)/\&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.146584487" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1544651211" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.276839919" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.exe.debug.option.debugging.level.1732120782" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.2036268186" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/RuntimeObjectSystem}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/RuntimeCompiler}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.201952547" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.405055214" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1890000143" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
<option id="gnu.cpp.link.option.paths.1299448631" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/RuntimeObjectSystem/Debug}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/RuntimeCompiler/Debug}&quot;"/>
</option>
<option id="gnu.cpp.link.option.libs.766766320" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="RuntimeObjectSystem"/>
<listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="RuntimeCompiler"/>
<listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="dl"/>
</option>
<option id="gnu.cpp.link.option.flags.458483182" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="-export-dynamic" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1956742743" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1568270871" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
<option id="gnu.both.asm.option.include.paths.973910921" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/RuntimeObjectSystem}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/RuntimeCompiler}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.978949246" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings">
<externalSettings containerId="RuntimeCompiler;" factoryId="org.eclipse.cdt.core.cfg.export.settings.sipplier">
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/RuntimeCompiler"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/RuntimeCompiler/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="RuntimeCompiler" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<externalSettings containerId="RuntimeObjectSystem;" factoryId="org.eclipse.cdt.core.cfg.export.settings.sipplier">
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/RuntimeObjectSystem"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/RuntimeObjectSystem/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="RuntimeObjectSystem" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
</storageModule>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.exe.release.190462196">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.190462196" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.190462196" name="Release" parent="cdt.managedbuild.config.gnu.exe.release">
<folderInfo id="cdt.managedbuild.config.gnu.exe.release.190462196." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.1219255078" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.870798980" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
<builder buildPath="${workspace_loc:/ConsoleExample}/Release" id="cdt.managedbuild.target.gnu.builder.exe.release.1395186556" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.975275992" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1179029702" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
<option id="gnu.cpp.compiler.exe.release.option.optimization.level.797473603" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.exe.release.option.debugging.level.1744608935" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.preprocessor.def.587903555" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
<listOptionValue builtIn="false" value="COMPILE_PATH=\&quot;$(PWD)/\&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.995885181" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1184831331" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.2100840880" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.exe.release.option.debugging.level.571480313" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.536062682" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.165818965" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.318472648" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release">
<option id="gnu.cpp.link.option.libs.1453788816" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="RuntimeObjectSystem"/>
<listOptionValue builtIn="false" value="RuntimeCompiler"/>
<listOptionValue builtIn="false" value="dl"/>
</option>
<option id="gnu.cpp.link.option.paths.820482508" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/RuntimeObjectSystem/Release}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/RuntimeCompiler/Release}&quot;"/>
</option>
<option id="gnu.cpp.link.option.flags.439005262" superClass="gnu.cpp.link.option.flags" value="-export-dynamic" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.85499237" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.306697180" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.498206058" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="ConsoleExample.cdt.managedbuild.target.gnu.exe.1465143487" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.190462196;cdt.managedbuild.config.gnu.exe.release.190462196.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1179029702;cdt.managedbuild.tool.gnu.cpp.compiler.input.995885181">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1276108983;cdt.managedbuild.config.gnu.exe.debug.1276108983.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1907407507;cdt.managedbuild.tool.gnu.cpp.compiler.input.146584487">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.190462196;cdt.managedbuild.config.gnu.exe.release.190462196.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1184831331;cdt.managedbuild.tool.gnu.c.compiler.input.536062682">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1276108983;cdt.managedbuild.config.gnu.exe.debug.1276108983.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1544651211;cdt.managedbuild.tool.gnu.c.compiler.input.201952547">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Release">
<resource resourceType="PROJECT" workspacePath="/ConsoleExample"/>
</configuration>
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/ConsoleExample"/>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
</cproject>

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ConsoleExample</name>
<comment></comment>
<projects>
<project>RuntimeCompiler</project>
<project>RuntimeObjectSystem</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -1,67 +0,0 @@
eclipse.preferences.version=1
org.eclipse.cdt.codan.checkers.errnoreturn=Warning
org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
org.eclipse.cdt.codan.checkers.errreturnvalue=Error
org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.checkers.noreturn=Error
org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false}
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true}
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false}
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false}
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")}
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}

View File

@ -1,8 +0,0 @@
eclipse.preferences.version=1
environment/project/cdt.managedbuild.config.gnu.exe.debug.1276108983/append=true
environment/project/cdt.managedbuild.config.gnu.exe.debug.1276108983/appendContributed=true
environment/project/cdt.managedbuild.config.gnu.exe.release.190462196/CWD/delimiter=\:
environment/project/cdt.managedbuild.config.gnu.exe.release.190462196/CWD/operation=replace
environment/project/cdt.managedbuild.config.gnu.exe.release.190462196/CWD/value=/media/psf/Home/Documents/Github/dougbinks/RuntimeCompiledCPlusPlus/Aurora/Examples/ConsoleExample/Release
environment/project/cdt.managedbuild.config.gnu.exe.release.190462196/append=true
environment/project/cdt.managedbuild.config.gnu.exe.release.190462196/appendContributed=true

View File

@ -1,45 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
// ConsoleExample.cpp : simple example using console command line
#include "ConsoleGame.h"
#include <iostream>
#ifdef _WIN32
#include <conio.h>
#endif
int main(int argc, char* argv[])
{
ConsoleGame game;
if( game.Init() )
{
while( game.MainLoop() )
{
}
}
else
{
std::cout << "\nFailed Initialisation, press a key to exit.\n";
_getche();
}
std::cout << "Exiting...\n";
return 0;
}

View File

@ -1,178 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B95544FF-96D5-4395-8E62-C02A512534D7}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ConsoleExample</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\Aurora_x86.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\Aurora_x64.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\Aurora_x86.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\Aurora_x64.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>RuntimeObjectSystem.lib;RuntimeCompiler_VS2010.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)$(Configuration);</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>RuntimeObjectSystem.lib;RuntimeCompiler_VS2010.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>RuntimeObjectSystem.lib;RuntimeCompiler_VS2010.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)$(Configuration);</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>RuntimeObjectSystem.lib;RuntimeCompiler_VS2010.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ConsoleExample.cpp" />
<ClCompile Include="ConsoleGame.cpp" />
<ClCompile Include="RuntimeObject01.cpp" />
<ClCompile Include="StdioLogSystem.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="ConsoleGame.h" />
<ClInclude Include="InterfaceIds.h" />
<ClInclude Include="IUpdateable.h" />
<ClInclude Include="StdioLogSystem.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Runtime Modifiable">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ConsoleExample.cpp" />
<ClCompile Include="RuntimeObject01.cpp">
<Filter>Runtime Modifiable</Filter>
</ClCompile>
<ClCompile Include="StdioLogSystem.cpp" />
<ClCompile Include="ConsoleGame.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="StdioLogSystem.h" />
<ClInclude Include="ConsoleGame.h" />
<ClInclude Include="InterfaceIds.h" />
<ClInclude Include="IUpdateable.h" />
</ItemGroup>
</Project>

View File

@ -1,252 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
91977BBD16EB398A003FAE7A /* libRuntimeCompiler.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 91977BBB16EB398A003FAE7A /* libRuntimeCompiler.a */; };
91977BBE16EB398A003FAE7A /* libRuntimeObjectSystem.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 91977BBC16EB398A003FAE7A /* libRuntimeObjectSystem.a */; };
91DE41E7161B1BB800BE0D16 /* ConsoleExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91DE41DF161B1BB800BE0D16 /* ConsoleExample.cpp */; };
91DE41E8161B1BB800BE0D16 /* ConsoleGame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91DE41E0161B1BB800BE0D16 /* ConsoleGame.cpp */; };
91DE41E9161B1BB800BE0D16 /* RuntimeObject01.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91DE41E4161B1BB800BE0D16 /* RuntimeObject01.cpp */; };
91DE41EA161B1BB800BE0D16 /* StdioLogSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91DE41E5161B1BB800BE0D16 /* StdioLogSystem.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
91A171CC161B175E004B5954 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 12;
dstPath = "";
dstSubfolderSpec = 16;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
91977BBB16EB398A003FAE7A /* libRuntimeCompiler.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libRuntimeCompiler.a; path = "../../../../../../../Library/Developer/Xcode/DerivedData/Aurora-amgiihqkoasuvzdugsovjupxbfdk/Build/Products/Debug/libRuntimeCompiler.a"; sourceTree = "<group>"; };
91977BBC16EB398A003FAE7A /* libRuntimeObjectSystem.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libRuntimeObjectSystem.a; path = "../../../../../../../Library/Developer/Xcode/DerivedData/Aurora-amgiihqkoasuvzdugsovjupxbfdk/Build/Products/Debug/libRuntimeObjectSystem.a"; sourceTree = "<group>"; };
91A171CE161B175E004B5954 /* ConsoleExample */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ConsoleExample; sourceTree = BUILT_PRODUCTS_DIR; };
91DE41DF161B1BB800BE0D16 /* ConsoleExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleExample.cpp; sourceTree = "<group>"; };
91DE41E0161B1BB800BE0D16 /* ConsoleGame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleGame.cpp; sourceTree = "<group>"; };
91DE41E1161B1BB800BE0D16 /* ConsoleGame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConsoleGame.h; sourceTree = "<group>"; };
91DE41E2161B1BB800BE0D16 /* InterfaceIds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceIds.h; sourceTree = "<group>"; };
91DE41E3161B1BB800BE0D16 /* IUpdateable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IUpdateable.h; sourceTree = "<group>"; };
91DE41E4161B1BB800BE0D16 /* RuntimeObject01.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuntimeObject01.cpp; sourceTree = "<group>"; };
91DE41E5161B1BB800BE0D16 /* StdioLogSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StdioLogSystem.cpp; sourceTree = "<group>"; };
91DE41E6161B1BB800BE0D16 /* StdioLogSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StdioLogSystem.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
91A171CB161B175E004B5954 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
91977BBD16EB398A003FAE7A /* libRuntimeCompiler.a in Frameworks */,
91977BBE16EB398A003FAE7A /* libRuntimeObjectSystem.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
91A171C3161B175E004B5954 = {
isa = PBXGroup;
children = (
91977BBB16EB398A003FAE7A /* libRuntimeCompiler.a */,
91977BBC16EB398A003FAE7A /* libRuntimeObjectSystem.a */,
91DE41DF161B1BB800BE0D16 /* ConsoleExample.cpp */,
91DE41E0161B1BB800BE0D16 /* ConsoleGame.cpp */,
91DE41E1161B1BB800BE0D16 /* ConsoleGame.h */,
91DE41E2161B1BB800BE0D16 /* InterfaceIds.h */,
91DE41E3161B1BB800BE0D16 /* IUpdateable.h */,
91DE41E4161B1BB800BE0D16 /* RuntimeObject01.cpp */,
91DE41E5161B1BB800BE0D16 /* StdioLogSystem.cpp */,
91DE41E6161B1BB800BE0D16 /* StdioLogSystem.h */,
91A171CF161B175E004B5954 /* Products */,
);
sourceTree = "<group>";
};
91A171CF161B175E004B5954 /* Products */ = {
isa = PBXGroup;
children = (
91A171CE161B175E004B5954 /* ConsoleExample */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
91A171CD161B175E004B5954 /* ConsoleExample */ = {
isa = PBXNativeTarget;
buildConfigurationList = 91A171D8161B175E004B5954 /* Build configuration list for PBXNativeTarget "ConsoleExample" */;
buildPhases = (
91A171CA161B175E004B5954 /* Sources */,
91A171CB161B175E004B5954 /* Frameworks */,
91A171CC161B175E004B5954 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = ConsoleExample;
productName = ConsoleExample;
productReference = 91A171CE161B175E004B5954 /* ConsoleExample */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
91A171C5161B175E004B5954 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0440;
ORGANIZATIONNAME = "Doug Binks";
};
buildConfigurationList = 91A171C8161B175E004B5954 /* Build configuration list for PBXProject "ConsoleExample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 91A171C3161B175E004B5954;
productRefGroup = 91A171CF161B175E004B5954 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
91A171CD161B175E004B5954 /* ConsoleExample */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
91A171CA161B175E004B5954 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
91DE41E7161B1BB800BE0D16 /* ConsoleExample.cpp in Sources */,
91DE41E8161B1BB800BE0D16 /* ConsoleGame.cpp in Sources */,
91DE41E9161B1BB800BE0D16 /* RuntimeObject01.cpp in Sources */,
91DE41EA161B1BB800BE0D16 /* StdioLogSystem.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
91A171D6161B175E004B5954 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../../External/boost,
../External/boost,
);
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
91A171D7161B175E004B5954 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../../External/boost,
../External/boost,
);
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 10.8;
SDKROOT = macosx;
};
name = Release;
};
91A171D9161B175E004B5954 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = ../../External/boost;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../External/boost/stage/libOSX\"",
"\"$(SRCROOT)/../../../../../../../Library/Developer/Xcode/DerivedData/Aurora-amgiihqkoasuvzdugsovjupxbfdk/Build/Products/Debug\"",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = "";
};
name = Debug;
};
91A171DA161B175E004B5954 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = ../../External/boost;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../External/boost/stage/libOSX\"",
"\"$(SRCROOT)/../../../../../../../Library/Developer/Xcode/DerivedData/Aurora-amgiihqkoasuvzdugsovjupxbfdk/Build/Products/Debug\"",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = "";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
91A171C8161B175E004B5954 /* Build configuration list for PBXProject "ConsoleExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
91A171D6161B175E004B5954 /* Debug */,
91A171D7161B175E004B5954 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
91A171D8161B175E004B5954 /* Build configuration list for PBXNativeTarget "ConsoleExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
91A171D9161B175E004B5954 /* Debug */,
91A171DA161B175E004B5954 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 91A171C5161B175E004B5954 /* Project object */;
}

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:ConsoleExample.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,175 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "ConsoleGame.h"
#include "../../RuntimeCompiler/AUArray.h"
#include "../../RuntimeCompiler/BuildTool.h"
#include "../../RuntimeCompiler/ICompilerLogger.h"
#include "../../RuntimeCompiler/FileChangeNotifier.h"
#include "../../RuntimeObjectSystem/IObjectFactorySystem.h"
#include "../../RuntimeObjectSystem/ObjectFactorySystem/ObjectFactorySystem.h"
#include "../../RuntimeObjectSystem/RuntimeObjectSystem.h"
#include "StdioLogSystem.h"
#include "../../RuntimeObjectSystem/IObject.h"
#include "IUpdateable.h"
#include "InterfaceIds.h"
#include <iostream>
#ifdef WIN32
#include <conio.h>
#include <tchar.h>
#else
#include <unistd.h>
int _getche()
{
int ret = getchar();
return ret;
}
int _kbhit()
{
std::cout << "This port needs a fix, CTRL-C to quit\n";
return 0;
}
int Sleep( int msecs )
{
return usleep( msecs * 1000);
}
#endif
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdarg.h>
// Remove windows.h define of GetObject which conflicts with EntitySystem GetObject
#if defined _WINDOWS_ && defined GetObject
#undef GetObject
#endif
using FileSystemUtils::Path;
ConsoleGame::ConsoleGame()
: m_pCompilerLogger(0)
, m_pRuntimeObjectSystem(0)
, m_pUpdateable(0)
{
}
ConsoleGame::~ConsoleGame()
{
if( m_pRuntimeObjectSystem )
{
// clean temp object files
m_pRuntimeObjectSystem->CleanObjectFiles();
}
if( m_pRuntimeObjectSystem && m_pRuntimeObjectSystem->GetObjectFactorySystem() )
{
m_pRuntimeObjectSystem->GetObjectFactorySystem()->RemoveListener(this);
// delete object via correct interface
IObject* pObj = m_pRuntimeObjectSystem->GetObjectFactorySystem()->GetObject( m_ObjectId );
delete pObj;
}
delete m_pRuntimeObjectSystem;
delete m_pCompilerLogger;
}
bool ConsoleGame::Init()
{
//Initialise the RuntimeObjectSystem
m_pRuntimeObjectSystem = new RuntimeObjectSystem;
m_pCompilerLogger = new StdioLogSystem();
if( !m_pRuntimeObjectSystem->Initialise(m_pCompilerLogger, 0) )
{
m_pRuntimeObjectSystem = 0;
return false;
}
m_pRuntimeObjectSystem->GetObjectFactorySystem()->AddListener(this);
// construct first object
IObjectConstructor* pCtor = m_pRuntimeObjectSystem->GetObjectFactorySystem()->GetConstructor( "RuntimeObject01" );
if( pCtor )
{
IObject* pObj = pCtor->Construct();
pObj->GetInterface( &m_pUpdateable );
if( 0 == m_pUpdateable )
{
delete pObj;
m_pCompilerLogger->LogError("Error - no updateable interface found\n");
return false;
}
m_ObjectId = pObj->GetObjectId();
}
return true;
}
void ConsoleGame::OnConstructorsAdded()
{
// This could have resulted in a change of object pointer, so release old and get new one.
if( m_pUpdateable )
{
IObject* pObj = m_pRuntimeObjectSystem->GetObjectFactorySystem()->GetObject( m_ObjectId );
pObj->GetInterface( &m_pUpdateable );
if( 0 == m_pUpdateable )
{
delete pObj;
m_pCompilerLogger->LogError( "Error - no updateable interface found\n");
}
}
}
bool ConsoleGame::MainLoop()
{
//check status of any compile
if( m_pRuntimeObjectSystem->GetIsCompiledComplete() )
{
// load module when compile complete
m_pRuntimeObjectSystem->LoadCompiledModule();
}
if( !m_pRuntimeObjectSystem->GetIsCompiling() )
{
static int numUpdates = 0;
std::cout << "\nMain Loop - press q to quit. Updates every second. Update: " << numUpdates++ << "\n";
if( _kbhit() )
{
int ret = _getche();
if( 'q' == ret )
{
return false;
}
}
const float deltaTime = 1.0f;
m_pRuntimeObjectSystem->GetFileChangeNotifier()->Update( deltaTime );
m_pUpdateable->Update( deltaTime );
Sleep(1000);
}
return true;
}

View File

@ -1,64 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef CONSOLEGAME_INCLUDED
#define CONSOLEGAME_INCLUDED
#include "../../RuntimeObjectSystem/IObjectFactorySystem.h"
#include "../../RuntimeObjectSystem/ObjectInterface.h"
#include "../../RuntimeCompiler/AUArray.h"
#ifndef _WIN32
int _getche();
#endif
struct IUpdateable;
struct IRuntimeObjectSystem;
class ConsoleGame : public IObjectFactoryListener
{
public:
ConsoleGame();
virtual ~ConsoleGame();
bool Init();
bool MainLoop();
// IObjectFactoryListener
virtual void OnConstructorsAdded();
// ~IObjectFactoryListener
private:
// Runtime Systems
ICompilerLogger* m_pCompilerLogger;
IRuntimeObjectSystem* m_pRuntimeObjectSystem;
// Runtime object
IUpdateable* m_pUpdateable;
ObjectId m_ObjectId;
};
#endif // CONSOLEGAME_INCLUDED

View File

@ -1,30 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef IUPDATEABLE_INCLUDED
#define IUPDATEABLE_INCLUDED
#include "../../RuntimeObjectSystem/IObject.h"
struct IUpdateable : public IObject
{
virtual void Update( float deltaTime ) = 0;
};
#endif // IUPDATEABLE_INCLUDED

View File

@ -1,41 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// InterfaceId header file.
//
// Specifys interface ids for getting hold of interfaces
//
////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef INTERFACEIDS_INCLUDED
#define INTERFACEIDS_INCLUDED
#include "../../RuntimeObjectSystem/IObject.h"
enum InterfaceIDEnumConsoleExample
{
IID_IUPDATEABLE = IID_ENDInterfaceID,
IID_ENDInterfaceIDEnumConsoleExample
};
#endif //INTERFACEIDS_INCLUDED

View File

@ -1,18 +0,0 @@
#include "../../RuntimeObjectSystem/ObjectInterfacePerModule.h"
#include "../../RuntimeObjectSystem/IObject.h"
#include "IUpdateable.h"
#include "InterfaceIds.h"
#include <iostream>
class RuntimeObject01 : public TInterface<IID_IUPDATEABLE,IUpdateable>
{
public:
virtual void Update( float deltaTime )
{
std::cout << "Runtime Object 01231 update called!\n";
}
};
REGISTERCLASS(RuntimeObject01);

View File

@ -1,62 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "StdioLogSystem.h"
// Currently we create the file on first real output, and only close it on shutdown
#include <stdarg.h>
#include <assert.h>
#include <iostream>
#ifdef _WIN32
#include "Windows.h"
#pragma warning( disable : 4996 4800 )
#endif
void StdioLogSystem::LogError(const char * format, ...)
{
va_list args;
va_start(args, format);
LogInternal(format, args);
}
void StdioLogSystem::LogWarning(const char * format, ...)
{
va_list args;
va_start(args, format);
LogInternal(format, args);
}
void StdioLogSystem::LogInfo(const char * format, ...)
{
va_list args;
va_start(args, format);
LogInternal(format, args);
}
void StdioLogSystem::LogInternal(const char * format, va_list args)
{
int result = vsnprintf(m_buff, LOGSYSTEM_MAX_BUFFER-1, format, args);
// Make sure there's a limit to the amount of rubbish we can output
m_buff[LOGSYSTEM_MAX_BUFFER-1] = '\0';
std::cout << m_buff;
#ifdef _WIN32
OutputDebugStringA( m_buff );
#endif
}

View File

@ -1,45 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef STDIOLOGSYSTEM_INCLUDED
#define STDIOLOGSYSTEM_INCLUDED
#include "../../RuntimeCompiler/ICompilerLogger.h"
#include <string>
#include <stdio.h>
// StdioLogSystem for compiler
const size_t LOGSYSTEM_MAX_BUFFER = 4096;
class StdioLogSystem : public ICompilerLogger
{
public:
virtual void LogError(const char * format, ...);
virtual void LogWarning(const char * format, ...);
virtual void LogInfo(const char * format, ...);
protected:
void LogInternal(const char * format, va_list args);
char m_buff[LOGSYSTEM_MAX_BUFFER];
};
#endif //STDIOLOGSYSTEM_INCLUDED

View File

@ -1,117 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.lib.debug.608542581">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.lib.debug.608542581" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Renderer"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Renderer/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="Renderer" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.lib.debug.608542581" name="Debug" parent="cdt.managedbuild.config.gnu.lib.debug">
<folderInfo id="cdt.managedbuild.config.gnu.lib.debug.608542581." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.lib.debug.692794203" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.lib.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.lib.debug.1755057110" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.lib.debug"/>
<builder buildPath="${workspace_loc:/Renderer}/Debug" id="cdt.managedbuild.target.gnu.builder.lib.debug.752934565" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.lib.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.lib.debug.184129066" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.debug"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug.2092090364" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug">
<option id="gnu.cpp.compiler.lib.debug.option.optimization.level.665308524" name="Optimization Level" superClass="gnu.cpp.compiler.lib.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.lib.debug.option.debugging.level.400956895" name="Debug Level" superClass="gnu.cpp.compiler.lib.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.preprocessor.def.343682515" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1596403577" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.debug.1135249047" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.lib.debug.option.optimization.level.2084836761" name="Optimization Level" superClass="gnu.c.compiler.lib.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.lib.debug.option.debugging.level.829038116" name="Debug Level" superClass="gnu.c.compiler.lib.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1516369546" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.1661923958" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1627732611" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.lib.debug.1992103398" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.328971994" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.lib.release.464728051">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.lib.release.464728051" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Renderer"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Renderer/Release"/>
<entry flags="RESOLVED" kind="libraryFile" name="Renderer" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.lib.release.464728051" name="Release" parent="cdt.managedbuild.config.gnu.lib.release">
<folderInfo id="cdt.managedbuild.config.gnu.lib.release.464728051." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.lib.release.865289951" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.lib.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.lib.release.1020687031" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.lib.release"/>
<builder buildPath="${workspace_loc:/Renderer}/Release" id="cdt.managedbuild.target.gnu.builder.lib.release.1684052887" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.lib.release"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.lib.release.2052861868" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.release"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release.1841089163" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release">
<option id="gnu.cpp.compiler.lib.release.option.optimization.level.657478535" name="Optimization Level" superClass="gnu.cpp.compiler.lib.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.lib.release.option.debugging.level.727805803" name="Debug Level" superClass="gnu.cpp.compiler.lib.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.preprocessor.def.1156887572" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1831226054" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.release.1891115586" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.lib.release.option.optimization.level.1708390488" name="Optimization Level" superClass="gnu.c.compiler.lib.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.lib.release.option.debugging.level.1325630466" name="Debug Level" superClass="gnu.c.compiler.lib.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1918014784" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.891266598" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1216662905" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.lib.release.1882103123" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.933361084" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="Renderer.cdt.managedbuild.target.gnu.lib.410811969" name="Static Library" projectType="cdt.managedbuild.target.gnu.lib"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.release.464728051;cdt.managedbuild.config.gnu.lib.release.464728051.;cdt.managedbuild.tool.gnu.c.compiler.lib.release.1891115586;cdt.managedbuild.tool.gnu.c.compiler.input.1918014784">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.debug.608542581;cdt.managedbuild.config.gnu.lib.debug.608542581.;cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug.2092090364;cdt.managedbuild.tool.gnu.cpp.compiler.input.1596403577">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.debug.608542581;cdt.managedbuild.config.gnu.lib.debug.608542581.;cdt.managedbuild.tool.gnu.c.compiler.lib.debug.1135249047;cdt.managedbuild.tool.gnu.c.compiler.input.1516369546">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.release.464728051;cdt.managedbuild.config.gnu.lib.release.464728051.;cdt.managedbuild.tool.gnu.cpp.compiler.lib.release.1841089163;cdt.managedbuild.tool.gnu.cpp.compiler.input.1831226054">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope"/>
</cproject>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Renderer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -1,9 +0,0 @@
eclipse.preferences.version=1
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.debug.608542581/CPATH/delimiter=\:
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.debug.608542581/CPATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.debug.608542581/CPLUS_INCLUDE_PATH/delimiter=\:
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.debug.608542581/CPLUS_INCLUDE_PATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.debug.608542581/C_INCLUDE_PATH/delimiter=\:
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.debug.608542581/C_INCLUDE_PATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.debug.608542581/append=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.debug.608542581/appendContributed=true

View File

@ -1,438 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "AURenMesh.h"
#ifndef _WIN32
#define NO_ASSIMP //Currently not adding assimp support to other platforms
#endif
#include "../Common/AUVec3f.inl" //for cross product used in calculateing normals
// Windows Requirements
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#endif //_WIN32
#ifdef __MACH__
#include <OpenGL/gl.h>
#else
// OpenGL requirements
#include <GL/gl.h>
#endif //__MACH__
#ifndef NO_ASSIMP
#include <assimp.hpp>
#include <aiScene.h>
#include <aiPostProcess.h>
#endif //NO_ASSIMP
#ifndef _WIN32
#include <string.h>
int _stricmp( const char* pS1, const char* pS2 )
{
return strcasecmp( pS1, pS2 );
}
#endif
#include <fstream>
#include <assert.h>
AURenMesh::AURenMesh() :
m_pafVertexCoordinates( NULL ),
m_pafTextureCoordinates( NULL ),
m_pafNormals( NULL ),
m_pausTriangleIndices( NULL ),
m_uiNumVertices( 0 ),
m_uiNumTriangles( 0 )
{
}
AURenMesh::~AURenMesh()
{
Clear();
}
void AURenMesh::Clear()
{
delete[] m_pafNormals;
delete[] m_pafVertexCoordinates;
delete[] m_pafTextureCoordinates;
delete[] m_pausTriangleIndices;
}
bool AURenMesh::LoadFromFile( const std::string& strFilename )
{
// Safely delete any existing data before loading new mesh
Clear();
int index = (int)strFilename.size() - 3;
std::string extension = index >= 0 ? strFilename.substr(index, 3) : "";
if (!_stricmp(extension.c_str(), "aml"))
{
return LoadFromFileAML(strFilename);
}
else
{
return LoadFromFileImport(strFilename);
}
}
bool AURenMesh::SaveToFile( const std::string& strFilename )
{
std::ofstream outFile;
outFile.open(strFilename.c_str(), std::ios::binary);
if( !outFile )
{
return false;
}
outFile << "AML Aurora File" << std::endl;
outFile << 1 << std::endl; // version
outFile << m_uiNumVertices << std::endl;
outFile << m_uiNumTriangles << std::endl;
outFile.write( reinterpret_cast<char*>( m_pafVertexCoordinates ), 3 * m_uiNumVertices * sizeof( float ) );
outFile.write( reinterpret_cast<char*>( m_pafTextureCoordinates ), 2 * m_uiNumVertices * sizeof( float ) );
outFile.write( reinterpret_cast<char*>( m_pafNormals ), 3 * m_uiNumVertices * sizeof( float ) );
outFile.write( reinterpret_cast<char*>( m_pausTriangleIndices ), 3 * m_uiNumTriangles * sizeof( unsigned short ) );
outFile.close();
return true;
}
bool AURenMesh::LoadFromFileAML( const std::string& strFilename_ )
{
std::ifstream inFile;
inFile.open(strFilename_.c_str(), std::ios::binary);
if( !inFile )
{
return false;
}
inFile.ignore(10000,'\n'); //ignore first line
int iVersion;
inFile >> iVersion; //currently ignore version number
inFile >> m_uiNumVertices;
inFile >> m_uiNumTriangles;
//now discard end of line
inFile.ignore(10000,'\n');
m_pafVertexCoordinates = new float[ 3 * m_uiNumVertices ];
m_pafNormals = new float[ 3 * m_uiNumVertices ];
m_pafTextureCoordinates = new float[ 2 * m_uiNumVertices ];
m_pausTriangleIndices = new unsigned short[ 3 * m_uiNumTriangles ];
inFile.read( reinterpret_cast<char*>( m_pafVertexCoordinates ), 3 * m_uiNumVertices * sizeof( float ) );
inFile.read( reinterpret_cast<char*>( m_pafTextureCoordinates ), 2 * m_uiNumVertices * sizeof( float ) );
inFile.read( reinterpret_cast<char*>( m_pafNormals ), 3 * m_uiNumVertices * sizeof( float ) );
inFile.read( reinterpret_cast<char*>( m_pausTriangleIndices ), 3 * m_uiNumTriangles * sizeof( unsigned short ) );
return true;
}
bool AURenMesh::LoadFromFileImport( const std::string& strFilename )
{
#ifndef NO_ASSIMP
Assimp::Importer importer;
const aiScene* pScene = importer.ReadFile( strFilename, aiProcessPreset_TargetRealtime_Fast );
if (!pScene || pScene->mNumMeshes == 0)
{
return false;
}
ProcessScene(pScene);
return true;
#else
assert( false );
return false;
#endif
}
void AURenMesh::ProcessScene( const aiScene* pScene )
{
#ifndef NO_ASSIMP
// Calculate total number of verts and tris across all meshes in scene
m_uiNumVertices = 0;
m_uiNumTriangles = 0;
for (unsigned int i=0; i<pScene->mNumMeshes; ++i)
{
aiMesh* pMesh = pScene->mMeshes[i];
m_uiNumVertices += pMesh->mNumVertices;
m_uiNumTriangles += pMesh->mNumFaces;
}
// Allocate sufficent space for all data
m_pafVertexCoordinates = new float[ 3 * m_uiNumVertices ];
m_pafNormals = new float[ 3 * m_uiNumVertices ];
m_pafTextureCoordinates = new float[ 2 * m_uiNumVertices ];
m_pausTriangleIndices = new unsigned short[ 3 * m_uiNumTriangles ];
// Iterate through all meshes and load data
int vertIndex = 0;
int normalIndex = 0;
int texIndex = 0;
int triIndex = 0;
for (unsigned int i=0; i<pScene->mNumMeshes; ++i)
{
aiMesh* pMesh = pScene->mMeshes[i];
// Load Verts
for (unsigned int j=0; j<pMesh->mNumVertices; ++j)
{
const aiVector3D& vec = pMesh->mVertices[j];
m_pafVertexCoordinates[vertIndex] = vec.x;
m_pafVertexCoordinates[vertIndex+1] = vec.y;
m_pafVertexCoordinates[vertIndex+2] = vec.z;
vertIndex += 3;
}
// Load Normals
for (unsigned int j=0; j<pMesh->mNumVertices; ++j)
{
const aiVector3D& vec = pMesh->mNormals[j];
m_pafNormals[normalIndex] = vec.x;
m_pafNormals[normalIndex+1] = vec.y;
m_pafNormals[normalIndex+2] = vec.z;
normalIndex += 3;
}
// Load Tex Coords
if (pMesh->HasTextureCoords(0))
{
for (unsigned int j=0; j<pMesh->mNumVertices; ++j)
{
const aiVector3D& vec = pMesh->mTextureCoords[0][j];
m_pafTextureCoordinates[texIndex] = vec.x;
m_pafTextureCoordinates[texIndex+1] = vec.y;
texIndex += 2;
}
}
// Load Tris
for (unsigned int j=0; j<pMesh->mNumFaces; ++j)
{
const aiFace& tri = pMesh->mFaces[j];
m_pausTriangleIndices[triIndex] = tri.mIndices[0];
m_pausTriangleIndices[triIndex+1] = tri.mIndices[1];
m_pausTriangleIndices[triIndex+2] = tri.mIndices[2];
triIndex += 3;
}
}
#endif
}
//////////////////////////////////////////////////////////////////////////////////////////
// Function: AURenMesh::AURenMesh
//
// Last Modified by: Douglas John Binks (DJB)
//
// Last Modified: 21 June 2000
//
// Purpose: Normalises the size and position of the object to be
// centered around the origin and of the correct BCube extent.
//
// Inputs: fBCubeHalfWidth_ : float giving the half width of the
// bounding cube.
//
// Outputs: None.
//
// Returns: None.
//
//////////////////////////////////////////////////////////////////////////////////////////
void AURenMesh::NormaliseToBCubeHalfWidth( float fBCubeHalfWidth_ )
{
//set up min and max variablse for each axis and use a real value from the
//array to initialise (as a `made up' value may be wrong unless we use
//floatmax for min etc.).
float fMinX = m_pafVertexCoordinates[0];
float fMaxX = m_pafVertexCoordinates[0];
float fMinY = m_pafVertexCoordinates[1];
float fMaxY = m_pafVertexCoordinates[1];
float fMinZ = m_pafVertexCoordinates[2];
float fMaxZ = m_pafVertexCoordinates[2];
//Go through array of vertices to find the real min and max
unsigned int uiCountCoords;
for( uiCountCoords = 0;
uiCountCoords < 3 * m_uiNumVertices;
uiCountCoords += 3 )
{
if( fMinX > m_pafVertexCoordinates[ uiCountCoords ] )
{
fMinX = m_pafVertexCoordinates[ uiCountCoords ];
}
else
{
if( fMaxX < m_pafVertexCoordinates[ uiCountCoords ] )
{
fMaxX = m_pafVertexCoordinates[ uiCountCoords ];
}
}
if( fMinY > m_pafVertexCoordinates[ uiCountCoords + 1 ] )
{
fMinY = m_pafVertexCoordinates[ uiCountCoords + 1 ];
}
else
{
if( fMaxY < m_pafVertexCoordinates[ uiCountCoords + 1 ] )
{
fMaxY = m_pafVertexCoordinates[ uiCountCoords + 1 ];
}
}
if( fMinZ > m_pafVertexCoordinates[ uiCountCoords + 2 ] )
{
fMinZ = m_pafVertexCoordinates[ uiCountCoords + 2 ];
}
else
{
if( fMaxZ < m_pafVertexCoordinates[ uiCountCoords + 2 ] )
{
fMaxZ = m_pafVertexCoordinates[ uiCountCoords + 2 ];
}
}
}
//calulate the current center
float fCenterX = ( fMaxX + fMinX )/2.0f;
float fCenterY = ( fMaxY + fMinY )/2.0f;
float fCenterZ = ( fMaxZ + fMinZ )/2.0f;
//calculate the largest distance^2 from the center
float fMaxDistance2 = 0.0f;
float fDistance2;
float fX2, fY2, fZ2;
for( uiCountCoords = 0;
uiCountCoords < 3 * m_uiNumVertices;
uiCountCoords += 3 )
{
fX2 = m_pafVertexCoordinates[ uiCountCoords ] - fCenterX;
fX2 *= fX2;
fY2 = m_pafVertexCoordinates[ uiCountCoords + 1 ] - fCenterY;
fY2 *= fY2;
fZ2 = m_pafVertexCoordinates[ uiCountCoords + 2 ] - fCenterZ;
fZ2 *= fZ2;
fDistance2 = fX2 + fY2 + fZ2;
if( fDistance2 > fMaxDistance2 )
{
fMaxDistance2 = fDistance2;
}
}
//calculate normalising coefficient such that Xnew = cf * Xold
float fCoefficient = fBCubeHalfWidth_ / sqrt( fMaxDistance2 );
//now do normalisation ( use seperate calcs for X,Y,Z so as to use possible
//parallel floating point units).
for( uiCountCoords = 0;
uiCountCoords < 3 * m_uiNumVertices;
uiCountCoords += 3 )
{
m_pafVertexCoordinates[ uiCountCoords ] =
fCoefficient * ( m_pafVertexCoordinates[ uiCountCoords ] - fCenterX );
m_pafVertexCoordinates[ uiCountCoords + 1 ] =
fCoefficient * ( m_pafVertexCoordinates[ uiCountCoords + 1 ] - fCenterY );
m_pafVertexCoordinates[ uiCountCoords + 2 ] =
fCoefficient * ( m_pafVertexCoordinates[ uiCountCoords + 2 ] - fCenterZ );
}
}
//////////////////////////////////////////////////////////////////////////////////////////
// Function: AURenMesh::Render
//
// Last Modified by: Douglas John Binks (DJB)
//
// Last Modified: 25 July 2000
//
// Purpose: Draws the mesh.
//
// Inputs: None.
//
// Outputs: None.
//
// Returns: None.
//
//////////////////////////////////////////////////////////////////////////////////////////
void AURenMesh::Render(const AUColor* pCol ) const
{
if( 0 == m_uiNumVertices )
{
return;
}
const GLfloat pafDiffuseColor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat pafSpecularColor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat fShininess = 40.0f;
if( 0 == pCol )
{
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, pafDiffuseColor);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pafDiffuseColor);
}
else
{
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, pCol->m_Color.rgba );
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pCol->m_Color.rgba);
}
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pafSpecularColor);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, fShininess);
const GLint iNumCoordinatesPerVertex = 3;
const GLsizei iStride = 0;
//set up vertex arrays
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_NORMAL_ARRAY );
glVertexPointer( iNumCoordinatesPerVertex, GL_FLOAT, iStride,
(const GLvoid*)m_pafVertexCoordinates );
glNormalPointer( GL_FLOAT, iStride,
(const GLvoid*)m_pafNormals );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer( 2, GL_FLOAT, iStride,
(const GLvoid*)m_pafTextureCoordinates );
//do actual drawing
glDrawElements( GL_TRIANGLES, 3 * m_uiNumTriangles, GL_UNSIGNED_SHORT, m_pausTriangleIndices );
//unset vertex arrays
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
}

View File

@ -1,85 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef AURENDMESH_DEF
#define AURENDMESH_DEF
#include <string>
#include "../Common/AUColor.inl"
#include "IAURenderable.h"
struct aiScene;
class AURenMesh
{
public:
AURenMesh();
bool LoadFromFile( const std::string& strFilename );
bool SaveToFile( const std::string& strFilename ); // Saves as AML
virtual ~AURenMesh();
void NormaliseToBCubeHalfWidth( float fBCubeHalfWidth );
void Render( const AUColor* pCol = 0 ) const;
protected:
bool LoadFromFileAML( const std::string& strFilename ); // For native AML format
bool LoadFromFileImport( const std::string& strFilename ); // Use AssImp library for other formats
void ProcessScene( const aiScene* pScene ); // Convert AssImp imported scene into internal data structures
void Clear();
float* m_pafVertexCoordinates;
float* m_pafTextureCoordinates;
float* m_pafNormals;
unsigned short* m_pausTriangleIndices;
unsigned int m_uiNumVertices;
unsigned int m_uiNumTriangles;
};
class AURenderableMesh : public IAURenderableMesh
{
public:
AURenderableMesh( AURenMesh* pMesh ) :
m_pMesh( pMesh ),
m_Color( 1.0f, 1.0f, 1.0f, 1.0f )
{
}
virtual const AUColor& GetColor() const
{
return m_Color;
}
virtual void SetColor( const AUColor& color )
{
m_Color = color;
}
virtual void Render() const
{
m_pMesh->Render( &m_Color );
}
AURenMesh* GetMesh()
{
return m_pMesh;
}
private:
AURenMesh* m_pMesh;
AUColor m_Color;
};
#endif //AURENDMESH_DEF

View File

@ -1,82 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "AURenderContext.h"
#include "IAURenderable.h"
// Windows Requirements
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#endif //_WIN32
#ifdef __MACH__
#include <OpenGL/gl.h>
#else
// OpenGL requirements
#include <GL/gl.h>
#endif //__MACH__
AURenderContext::AURenderContext()
{
}
AURenderContext::~AURenderContext()
{
}
AUDynArray<AUEntityId> g_entities;
void AURenderContext::Render( IEntitySystem* pEntitySystem )
{
//loop through setting matrices and calling render.
pEntitySystem->GetAll( g_entities );
for( size_t i = 0; i < g_entities.Size(); ++i )
{
IAUEntity* pEntity = pEntitySystem->Get( g_entities[ i ] );
IAURenderable* pRenderable = pEntity->GetRenderable();
if( pRenderable )
{
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
// Translation
const AUVec3f& t = pEntity->GetPosition();
glTranslatef( t.x, t.y, t.z );
// Rotation
float fglMatrix[16];
pEntity->GetOrientation().LoadglObjectMatrix(fglMatrix);
glMultMatrixf(fglMatrix);
// Scale
glEnable(GL_NORMALIZE); // Needed so normals don't get wrecked by scaling - not sure how costly it is though
const AUVec3f& s = pEntity->GetScale();
glScalef( s.x, s.y, s.z );
pRenderable->Render();
glPopMatrix();
}
}
}

View File

@ -1,29 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#include "../Systems/IEntitySystem.h"
class AURenderContext
{
public:
AURenderContext();
~AURenderContext();
void Render( IEntitySystem* pEntitySystem );
};

View File

@ -1,37 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef IAURENDMESH_DEF
#define IAURENDMESH_DEF
#include "../Common/AUColor.inl"
struct IAURenderable
{
virtual ~IAURenderable() {}
virtual void Render() const = 0; //should not be publically exposed.
};
struct IAURenderableMesh : public IAURenderable
{
virtual const AUColor& GetColor() const = 0;
virtual void SetColor( const AUColor& color ) = 0;
};
#endif //IAURENDMESH_DEF

View File

@ -1,218 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
910A9D8C1623026D0032E310 /* AURenderContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910A9D861623026D0032E310 /* AURenderContext.cpp */; };
910A9D8D1623026D0032E310 /* AURenderContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 910A9D871623026D0032E310 /* AURenderContext.h */; };
910A9D8E1623026D0032E310 /* AURenMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910A9D881623026D0032E310 /* AURenMesh.cpp */; };
910A9D8F1623026D0032E310 /* AURenMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 910A9D891623026D0032E310 /* AURenMesh.h */; };
910A9D911623026D0032E310 /* IAURenderable.h in Headers */ = {isa = PBXBuildFile; fileRef = 910A9D8B1623026D0032E310 /* IAURenderable.h */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
910A9D7C162302540032E310 /* libRenderer.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRenderer.a; sourceTree = BUILT_PRODUCTS_DIR; };
910A9D861623026D0032E310 /* AURenderContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AURenderContext.cpp; sourceTree = "<group>"; };
910A9D871623026D0032E310 /* AURenderContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AURenderContext.h; sourceTree = "<group>"; };
910A9D881623026D0032E310 /* AURenMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AURenMesh.cpp; sourceTree = "<group>"; };
910A9D891623026D0032E310 /* AURenMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AURenMesh.h; sourceTree = "<group>"; };
910A9D8B1623026D0032E310 /* IAURenderable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IAURenderable.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
910A9D79162302540032E310 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
910A9D71162302540032E310 = {
isa = PBXGroup;
children = (
910A9D861623026D0032E310 /* AURenderContext.cpp */,
910A9D871623026D0032E310 /* AURenderContext.h */,
910A9D881623026D0032E310 /* AURenMesh.cpp */,
910A9D891623026D0032E310 /* AURenMesh.h */,
910A9D8B1623026D0032E310 /* IAURenderable.h */,
910A9D7D162302540032E310 /* Products */,
);
sourceTree = "<group>";
};
910A9D7D162302540032E310 /* Products */ = {
isa = PBXGroup;
children = (
910A9D7C162302540032E310 /* libRenderer.a */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
910A9D7A162302540032E310 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
910A9D8D1623026D0032E310 /* AURenderContext.h in Headers */,
910A9D8F1623026D0032E310 /* AURenMesh.h in Headers */,
910A9D911623026D0032E310 /* IAURenderable.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
910A9D7B162302540032E310 /* Renderer */ = {
isa = PBXNativeTarget;
buildConfigurationList = 910A9D80162302540032E310 /* Build configuration list for PBXNativeTarget "Renderer" */;
buildPhases = (
910A9D78162302540032E310 /* Sources */,
910A9D79162302540032E310 /* Frameworks */,
910A9D7A162302540032E310 /* Headers */,
);
buildRules = (
);
dependencies = (
);
name = Renderer;
productName = Renderer;
productReference = 910A9D7C162302540032E310 /* libRenderer.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
910A9D73162302540032E310 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0440;
ORGANIZATIONNAME = "Doug Binks";
};
buildConfigurationList = 910A9D76162302540032E310 /* Build configuration list for PBXProject "Renderer" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 910A9D71162302540032E310;
productRefGroup = 910A9D7D162302540032E310 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
910A9D7B162302540032E310 /* Renderer */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
910A9D78162302540032E310 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
910A9D8C1623026D0032E310 /* AURenderContext.cpp in Sources */,
910A9D8E1623026D0032E310 /* AURenMesh.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
910A9D7E162302540032E310 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
910A9D7F162302540032E310 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
SDKROOT = macosx;
};
name = Release;
};
910A9D81162302540032E310 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
EXECUTABLE_PREFIX = lib;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = "";
};
name = Debug;
};
910A9D82162302540032E310 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
EXECUTABLE_PREFIX = lib;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = "";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
910A9D76162302540032E310 /* Build configuration list for PBXProject "Renderer" */ = {
isa = XCConfigurationList;
buildConfigurations = (
910A9D7E162302540032E310 /* Debug */,
910A9D7F162302540032E310 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
910A9D80162302540032E310 /* Build configuration list for PBXNativeTarget "Renderer" */ = {
isa = XCConfigurationList;
buildConfigurations = (
910A9D81162302540032E310 /* Debug */,
910A9D82162302540032E310 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 910A9D73162302540032E310 /* Project object */;
}

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Renderer.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,191 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="AURenderContext.cpp" />
<ClCompile Include="AURenMesh.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AURenderContext.h" />
<ClInclude Include="IAURenderable.h" />
<ClInclude Include="AURenMesh.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{26DDDB96-4A8E-4A1B-997C-970DE0CCCE37}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Renderer</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x86.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x64.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x86.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x64.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>GLEW_STATIC ;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\External\glew-1.6.0\include;$(SolutionDir)\External\libRocket\Include;$(SolutionDir)\External\assimp\include;$(SolutionDir)\External\Independant JPEG Group\jpeg-6b\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<AdditionalDependencies>opengl32.lib;glu32.lib;assimp.lib;</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\External\assimp\lib\assimp_release-dll_win32</AdditionalLibraryDirectories>
</Lib>
<PostBuildEvent>
<Command>xcopy /y "$(SolutionDir)\External\assimp\bin\assimp_release-dll_win32\*.dll" "$(OutDir)"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>copy dlls for assimp</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>GLEW_STATIC ;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\External\glew-1.6.0\include;$(SolutionDir)\External\libRocket\Include;$(SolutionDir)\External\assimp\include;$(SolutionDir)\External\Independant JPEG Group\jpeg-6b\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<AdditionalDependencies>opengl32.lib;glu32.lib;assimp.lib;</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\External\assimp\lib\assimp_release-dll_x64</AdditionalLibraryDirectories>
</Lib>
<PostBuildEvent>
<Command>xcopy /y "$(SolutionDir)\External\assimp\bin\assimp_release-dll_win32\*.dll" "$(OutDir)"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>copy dlls for assimp</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>GLEW_STATIC ;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\External\glew-1.6.0\include;$(SolutionDir)\External\libRocket\Include;$(SolutionDir)\External\assimp\include;$(SolutionDir)\External\Independant JPEG Group\jpeg-6b\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Lib>
<AdditionalDependencies>opengl32.lib;glu32.lib;assimp.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\External\assimp\lib\assimp_release-dll_win32</AdditionalLibraryDirectories>
</Lib>
<PostBuildEvent>
<Command>xcopy /y "$(SolutionDir)\External\assimp\bin\assimp_release-dll_win32\*.dll" "$(OutDir)"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>copy dlls for assimp</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>GLEW_STATIC ;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\External\glew-1.6.0\include;$(SolutionDir)\External\libRocket\Include;$(SolutionDir)\External\assimp\include;$(SolutionDir)\External\Independant JPEG Group\jpeg-6b\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Lib>
<AdditionalDependencies>opengl32.lib;glu32.lib;assimp.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\External\assimp\lib\assimp_release-dll_x64</AdditionalLibraryDirectories>
</Lib>
<PostBuildEvent>
<Command>xcopy /y "$(SolutionDir)\External\assimp\bin\assimp_release-dll_win32\*.dll" "$(OutDir)"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>copy dlls for assimp</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,139 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.lib.debug.735003935">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.lib.debug.735003935" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/RuntimeCompiler"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/RuntimeCompiler/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="RuntimeCompiler" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.lib.debug.735003935" name="Debug" parent="cdt.managedbuild.config.gnu.lib.debug">
<folderInfo id="cdt.managedbuild.config.gnu.lib.debug.735003935." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.lib.debug.563560451" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.lib.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.lib.debug.46412535" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.lib.debug"/>
<builder buildPath="${workspace_loc:/RuntimeCompiler}/Debug" id="cdt.managedbuild.target.gnu.builder.lib.debug.2061339863" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.lib.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.lib.debug.2043221626" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.debug"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug.2117386528" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug">
<option id="gnu.cpp.compiler.lib.debug.option.optimization.level.1797238125" name="Optimization Level" superClass="gnu.cpp.compiler.lib.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.lib.debug.option.debugging.level.1530988899" name="Debug Level" superClass="gnu.cpp.compiler.lib.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1611084390" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.debug.1085419437" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.lib.debug.option.optimization.level.687469194" name="Optimization Level" superClass="gnu.c.compiler.lib.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.lib.debug.option.debugging.level.1041993265" name="Debug Level" superClass="gnu.c.compiler.lib.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.179819654" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.421472412" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1252161614" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.lib.debug.1041193080" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1759886864" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="SimpleFileWatcher/FileWatcherOSX.cpp|SimpleFileWatcher/FileWatcherWin32.cpp|RuntimeCompiler.xcodeproj|Compiler_PlatformWindows.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.lib.release.1097325480">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.lib.release.1097325480" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/RuntimeCompiler"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/RuntimeCompiler/Release"/>
<entry flags="RESOLVED" kind="libraryFile" name="RuntimeCompiler" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.lib.release.1097325480" name="Release" parent="cdt.managedbuild.config.gnu.lib.release">
<folderInfo id="cdt.managedbuild.config.gnu.lib.release.1097325480." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.lib.release.1953437611" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.lib.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.lib.release.903776312" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.lib.release"/>
<builder buildPath="${workspace_loc:/RuntimeCompiler}/Release" id="cdt.managedbuild.target.gnu.builder.lib.release.1784641017" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.lib.release"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.lib.release.637685334" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.release"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release.2051347353" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release">
<option id="gnu.cpp.compiler.lib.release.option.optimization.level.2082470474" name="Optimization Level" superClass="gnu.cpp.compiler.lib.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.lib.release.option.debugging.level.1326155830" name="Debug Level" superClass="gnu.cpp.compiler.lib.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.588401514" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.release.1918268963" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.lib.release.option.optimization.level.66077283" name="Optimization Level" superClass="gnu.c.compiler.lib.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.lib.release.option.debugging.level.519714166" name="Debug Level" superClass="gnu.c.compiler.lib.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.66392424" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.873683834" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.437740912" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.lib.release.1882195477" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1451312208" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="SimpleFileWatcher/FileWatcherOSX.cpp|SimpleFileWatcher/FileWatcherWin32.cpp|RuntimeCompiler.xcodeproj|Compiler_PlatformWindows.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="RuntimeCompiler.cdt.managedbuild.target.gnu.lib.239370883" name="Static Library" projectType="cdt.managedbuild.target.gnu.lib"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.release.1097325480;cdt.managedbuild.config.gnu.lib.release.1097325480.;cdt.managedbuild.tool.gnu.cpp.compiler.lib.release.2051347353;cdt.managedbuild.tool.gnu.cpp.compiler.input.588401514">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.debug.735003935;cdt.managedbuild.config.gnu.lib.debug.735003935.;cdt.managedbuild.tool.gnu.c.compiler.lib.debug.1085419437;cdt.managedbuild.tool.gnu.c.compiler.input.179819654">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.936987132;cdt.managedbuild.config.gnu.exe.debug.936987132.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1741870421;cdt.managedbuild.tool.gnu.cpp.compiler.input.1138639279">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.release.1097325480;cdt.managedbuild.config.gnu.lib.release.1097325480.;cdt.managedbuild.tool.gnu.c.compiler.lib.release.1918268963;cdt.managedbuild.tool.gnu.c.compiler.input.66392424">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.debug.234302887;cdt.managedbuild.config.gnu.lib.debug.234302887.;cdt.managedbuild.tool.gnu.c.compiler.lib.debug.1677737855;cdt.managedbuild.tool.gnu.c.compiler.input.1241055091">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.release.484346236;cdt.managedbuild.config.gnu.lib.release.484346236.;cdt.managedbuild.tool.gnu.c.compiler.lib.release.878499957;cdt.managedbuild.tool.gnu.c.compiler.input.881078710">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.936987132;cdt.managedbuild.config.gnu.exe.debug.936987132.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1338382594;cdt.managedbuild.tool.gnu.c.compiler.input.212010964">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.2062855309;cdt.managedbuild.config.gnu.exe.release.2062855309.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.231062248;cdt.managedbuild.tool.gnu.cpp.compiler.input.179509481">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.debug.735003935;cdt.managedbuild.config.gnu.lib.debug.735003935.;cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug.2117386528;cdt.managedbuild.tool.gnu.cpp.compiler.input.1611084390">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.2062855309;cdt.managedbuild.config.gnu.exe.release.2062855309.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.113863370;cdt.managedbuild.tool.gnu.c.compiler.input.341730099">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
</cproject>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RuntimeCompiler</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -1,93 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef AUARRAY_DEFINED
#define AUARRAY_DEFINED
#include <stdlib.h>
#include <vector>
// Here we define a semi-virtualised wrapper for a vector-like object so that it can
// be used to pass results across DLL boundaries including resizing without memory
// manager problems.
// Ideally it should not use std::vector as this may not work if one side was compiled
// using debug and the other optimised.
template <class T> class IAUDynArray
{
protected:
IAUDynArray<T>() {}
~IAUDynArray<T>() {}
public:
virtual void Resize(size_t size) = 0;
virtual void Add(const T& item) = 0;
size_t Size() const
{
return m_vec.size();
}
void Clear()
{
Resize(0);
}
T& operator[] (size_t i)
{
return m_vec[i];
}
const T& operator[] (size_t i) const
{
return m_vec[i];
}
protected:
std::vector<T> m_vec;
};
template <class T> class AUDynArray : public IAUDynArray<T>
{
public:
AUDynArray<T>(size_t size = 0)
{
this->m_vec.resize(size);
}
~AUDynArray<T>()
{
// Ensure this code is created, despite the templates
Resize(0);
}
void Resize(size_t size)
{
this->m_vec.resize(size);
}
void Add(const T& item)
{
this->m_vec.push_back(item);
}
};
#endif //AUARRAY_DEFINED

View File

@ -1,126 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "BuildTool.h"
#include "Compiler.h"
#include <fstream>
#include <algorithm>
#include "ICompilerLogger.h"
using namespace std;
using namespace FileSystemUtils;
BuildTool::BuildTool()
{
}
BuildTool::~BuildTool()
{
}
void BuildTool::Clean( const FileSystemUtils::Path& temporaryPath_ ) const
{
// Remove any existing intermediate directory
FileSystemUtils::PathIterator pathIter( temporaryPath_ );
std::string obj_extension = m_Compiler.GetObjectFileExtension();
while( ++pathIter )
{
if( pathIter.GetPath().Extension() == obj_extension )
{
if( m_pLogger )
{
m_pLogger->LogInfo( "Deleting temp RCC++ obj file: %s\n", pathIter.GetPath().c_str() );
}
pathIter.GetPath().Remove();
}
}
}
void BuildTool::Initialise( ICompilerLogger * pLogger )
{
m_pLogger = pLogger;
m_Compiler.Initialise(pLogger);
}
void BuildTool::BuildModule( const std::vector<FileToBuild>& buildFileList_,
const CompilerOptions& compilerOptions_,
std::vector<FileSystemUtils::Path> linkLibraryList_,
const FileSystemUtils::Path& moduleName_ )
{
// Initial version is very basic, simply compiles them.
Path objectFileExtension = m_Compiler.GetObjectFileExtension();
vector<Path> compileFileList; // List of files we pass to the compiler
compileFileList.reserve( buildFileList_.size() );
vector<Path> forcedCompileFileList; // List of files which must be compiled even if object file exists
vector<Path> nonForcedCompileFileList; // List of files which can be linked if already compiled
// Seperate into seperate file lists of force and non-forced,
// so we can ensure we don't have the same file in both
for( size_t i = 0; i < buildFileList_.size(); ++i )
{
Path buildFile = buildFileList_[i].filePath;
if( buildFileList_[i].forceCompile )
{
if( find( forcedCompileFileList.begin(), forcedCompileFileList.end(), buildFile ) == forcedCompileFileList.end() )
{
forcedCompileFileList.push_back( buildFile );
}
}
else
{
if( find( nonForcedCompileFileList.begin(), nonForcedCompileFileList.end(), buildFile ) == nonForcedCompileFileList.end() )
{
nonForcedCompileFileList.push_back( buildFile );
}
}
}
// Add all forced compile files to build list
for( size_t i = 0; i < forcedCompileFileList.size(); ++i )
{
compileFileList.push_back( forcedCompileFileList[i] );
}
// runtime folder needs to be aware of compilation level and debug/
// Add non forced files, but only if they don't exist in forced compile list
for( size_t i = 0; i < nonForcedCompileFileList.size(); ++i )
{
Path buildFile = nonForcedCompileFileList[i];
if( find( forcedCompileFileList.begin(), forcedCompileFileList.end(), buildFile ) == forcedCompileFileList.end() )
{
// Check if we have a pre-compiled object version of this file, and if so use that.
Path objectFileName = compilerOptions_.intermediatePath / buildFile.Filename();
objectFileName.ReplaceExtension(objectFileExtension.c_str());
if( objectFileName.Exists() && buildFile.Exists() )
{
FileSystemUtils::filetime_t objTime = objectFileName.GetLastWriteTime();
if( objTime > buildFile.GetLastWriteTime() )
{
// we only want to use the object file if it's newer than the source file
buildFile = objectFileName;
}
}
compileFileList.push_back(buildFile);
}
}
m_Compiler.RunCompile( compileFileList, compilerOptions_, linkLibraryList_, moduleName_ );
}

View File

@ -1,72 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#include <vector>
#include <string>
#include "Compiler.h"
#include "FileSystemUtils.h"
class BuildTool
{
public:
BuildTool();
~BuildTool();
void Initialise( ICompilerLogger * pLogger );
// Clean - cleans up the intermediate files
void Clean( const FileSystemUtils::Path& temporaryPath_ ) const;
struct FileToBuild
{
FileToBuild( const FileSystemUtils::Path& filePath_ )
: filePath( filePath_ )
, forceCompile( false )
{
}
FileToBuild( const FileSystemUtils::Path& filePath_, bool forceCompile_ )
: filePath( filePath_ )
, forceCompile( forceCompile_ )
{
}
FileSystemUtils::Path filePath;
bool forceCompile; //if true the file is compiled even if object file is present
};
void BuildModule( const std::vector<FileToBuild>& buildFileList_,
const CompilerOptions& compilerOptions_,
std::vector<FileSystemUtils::Path> linkLibraryList_,
const FileSystemUtils::Path& moduleName_ );
bool GetIsComplete()
{
return m_Compiler.GetIsComplete();
}
void SetFastCompileMode( bool bFast )
{
m_Compiler.SetFastCompileMode( bFast );
}
private:
Compiler m_Compiler;
ICompilerLogger* m_pLogger;
};

View File

@ -1,49 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
enum RCppOptimizationLevel
{
RCCPPOPTIMIZATIONLEVEL_DEFAULT = 0, // RCCPPOPTIMIZATIONLEVEL_DEBUG in DEBUG, RCCPPOPTIMIZATIONLEVEL_PERF in release. This is the default state.
RCCPPOPTIMIZATIONLEVEL_DEBUG, // Low optimization, improve debug experiece. Default in DEBUG
RCCPPOPTIMIZATIONLEVEL_PERF, // Optimization for performance, debug experience may suffer. Default in RELEASE
RCCPPOPTIMIZATIONLEVEL_NOT_SET, // No optimization set in compile, so either underlying compiler default or set through SetAdditionalCompileOptions
RCCPPOPTIMIZATIONLEVEL_SIZE, // Size of enum, do not use to set opt level
};
static const char* RCppOptimizationLevelStrings[] =
{
"DEFAULT",
"DEBUG",
"PERF",
"NOT_SET",
};
// GetActualOptimizationLevel - translates DEFAULT into DEUG or PERF
inline RCppOptimizationLevel GetActualOptimizationLevel( RCppOptimizationLevel optimizationLevel_ )
{
if( RCCPPOPTIMIZATIONLEVEL_DEFAULT == optimizationLevel_ )
{
#ifdef _DEBUG
optimizationLevel_ = RCCPPOPTIMIZATIONLEVEL_DEBUG;
#else
optimizationLevel_ = RCCPPOPTIMIZATIONLEVEL_PERF;
#endif
}
return optimizationLevel_;
}

View File

@ -1,73 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#include <string>
#include <vector>
#include "FileSystemUtils.h"
#include "CompileOptions.h"
class PlatformCompilerImplData;
struct ICompilerLogger;
struct CompilerOptions
{
std::vector<FileSystemUtils::Path> includeDirList;
std::vector<FileSystemUtils::Path> libraryDirList;
std::string compileOptions;
std::string linkOptions;
RCppOptimizationLevel optimizationLevel;
FileSystemUtils::Path baseIntermediatePath;
FileSystemUtils::Path intermediatePath;
FileSystemUtils::Path compilerLocation;
};
class Compiler
{
public:
Compiler();
~Compiler();
void Initialise( ICompilerLogger * pLogger );
// On Win32 the compile command line process can be preserved in between compiles for improved performance,
// however this can result in Zombie processes and also prevent handles such as sockets from being closed.
// This function is safe to call at any time, but will only have an effect on Win32 compiles from the second
// compile on after the call (as the first must launch the process and set the VS environment).
//
// Defaults to m_bFastCompileMode = false
void SetFastCompileMode( bool bFast )
{
m_bFastCompileMode = bFast;
// call GetIsComplete() to ensure this stops process
GetIsComplete();
}
std::string GetObjectFileExtension() const;
void RunCompile( const std::vector<FileSystemUtils::Path>& filesToCompile_,
const CompilerOptions& compilerOptions_,
std::vector<FileSystemUtils::Path> linkLibraryList_,
const FileSystemUtils::Path& moduleName_ );
bool GetIsComplete() const;
private:
PlatformCompilerImplData* m_pImplData;
bool m_bFastCompileMode;
};

View File

@ -1,290 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//
// Notes:
// - We use a single intermediate directory for compiled .obj files, which means
// we don't support compiling multiple files with the same name. Could fix this
// with either mangling names to include paths, or recreating folder structure
//
//
#include "Compiler.h"
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
#include "assert.h"
#include <sys/wait.h>
#include "ICompilerLogger.h"
using namespace std;
const char c_CompletionToken[] = "_COMPLETION_TOKEN_" ;
class PlatformCompilerImplData
{
public:
PlatformCompilerImplData()
: m_bCompileIsComplete( false )
, m_pLogger( 0 )
, m_ChildForCompilationPID( 0 )
{
m_PipeStdOut[0] = 0;
m_PipeStdOut[1] = 1;
m_PipeStdErr[0] = 0;
m_PipeStdErr[1] = 1;
}
volatile bool m_bCompileIsComplete;
ICompilerLogger* m_pLogger;
pid_t m_ChildForCompilationPID;
int m_PipeStdOut[2];
int m_PipeStdErr[2];
};
Compiler::Compiler()
: m_pImplData( 0 )
{
}
Compiler::~Compiler()
{
delete m_pImplData;
}
std::string Compiler::GetObjectFileExtension() const
{
return ".o";
}
bool Compiler::GetIsComplete() const
{
if( !m_pImplData->m_bCompileIsComplete && m_pImplData->m_ChildForCompilationPID )
{
// check for whether process is closed
int procStatus;
pid_t ret = waitpid( m_pImplData->m_ChildForCompilationPID, &procStatus, WNOHANG);
if( ret && ( WIFEXITED(procStatus) || WIFSIGNALED(procStatus) ) )
{
m_pImplData->m_bCompileIsComplete = true;
m_pImplData->m_ChildForCompilationPID = 0;
// get output and log
if( m_pImplData->m_pLogger )
{
const size_t buffSize = 256 * 80; //should allow for a few lines...
char buffer[buffSize];
ssize_t numread = 0;
while( ( numread = read( m_pImplData->m_PipeStdOut[0], buffer, buffSize-1 ) ) > 0 )
{
buffer[numread] = 0;
m_pImplData->m_pLogger->LogInfo( buffer );
}
while( ( numread = read( m_pImplData->m_PipeStdErr[0], buffer, buffSize-1 ) )> 0 )
{
buffer[numread] = 0;
m_pImplData->m_pLogger->LogError( buffer ); //TODO: seperate warnings from errors.
}
}
// close the pipes as this process no longer needs them.
close( m_pImplData->m_PipeStdOut[0] );
m_pImplData->m_PipeStdOut[0] = 0;
close( m_pImplData->m_PipeStdErr[0] );
m_pImplData->m_PipeStdErr[0] = 0;
}
}
return m_pImplData->m_bCompileIsComplete;
}
void Compiler::Initialise( ICompilerLogger * pLogger )
{
m_pImplData = new PlatformCompilerImplData;
m_pImplData->m_pLogger = pLogger;
}
void Compiler::RunCompile( const std::vector<FileSystemUtils::Path>& filesToCompile_,
const CompilerOptions& compilerOptions_,
std::vector<FileSystemUtils::Path> linkLibraryList_,
const FileSystemUtils::Path& moduleName_ )
{
const std::vector<FileSystemUtils::Path>& includeDirList = compilerOptions_.includeDirList;
const std::vector<FileSystemUtils::Path>& libraryDirList = compilerOptions_.libraryDirList;
const char* pCompileOptions = compilerOptions_.compileOptions.c_str();
const char* pLinkOptions = compilerOptions_.linkOptions.c_str();
std::string compilerLocation = compilerOptions_.compilerLocation.m_string;
if (compilerLocation.size()==0){
#ifdef __clang__
compilerLocation = "clang++ ";
#else // default to g++
compilerLocation = "g++ ";
#endif //__clang__
}
//NOTE: Currently doesn't check if a prior compile is ongoing or not, which could lead to memory leaks
m_pImplData->m_bCompileIsComplete = false;
//create pipes
if ( pipe( m_pImplData->m_PipeStdOut ) != 0 )
{
if( m_pImplData->m_pLogger )
{
m_pImplData->m_pLogger->LogError( "Error in Compiler::RunCompile, cannot create pipe - perhaps insufficient memory?\n");
}
return;
}
//create pipes
if ( pipe( m_pImplData->m_PipeStdErr ) != 0 )
{
if( m_pImplData->m_pLogger )
{
m_pImplData->m_pLogger->LogError( "Error in Compiler::RunCompile, cannot create pipe - perhaps insufficient memory?\n");
}
return;
}
pid_t retPID;
switch( retPID = fork() )
{
case -1: // error, no fork
if( m_pImplData->m_pLogger )
{
m_pImplData->m_pLogger->LogError( "Error in Compiler::RunCompile, cannot fork() process - perhaps insufficient memory?\n");
}
return;
case 0: // child process - carries on below.
break;
default: // current process - returns to allow application to run whilst compiling
close( m_pImplData->m_PipeStdOut[1] );
m_pImplData->m_PipeStdOut[1] = 0;
close( m_pImplData->m_PipeStdErr[1] );
m_pImplData->m_PipeStdErr[1] = 0;
m_pImplData->m_ChildForCompilationPID = retPID;
return;
}
//duplicate the pipe to stdout, so output goes to pipe
dup2( m_pImplData->m_PipeStdErr[1], STDERR_FILENO );
dup2( m_pImplData->m_PipeStdOut[1], STDOUT_FILENO );
close( m_pImplData->m_PipeStdOut[0] );
m_pImplData->m_PipeStdOut[0] = 0;
close( m_pImplData->m_PipeStdErr[0] );
m_pImplData->m_PipeStdErr[0] = 0;
std::string compileString = compilerLocation + " " + "-g -fPIC -fvisibility=hidden -shared ";
#ifndef __LP64__
compileString += "-m32 ";
#endif
RCppOptimizationLevel optimizationLevel = GetActualOptimizationLevel( compilerOptions_.optimizationLevel );
switch( optimizationLevel )
{
case RCCPPOPTIMIZATIONLEVEL_DEFAULT:
assert(false);
case RCCPPOPTIMIZATIONLEVEL_DEBUG:
compileString += "-O0 ";
break;
case RCCPPOPTIMIZATIONLEVEL_PERF:
compileString += "-Os ";
break;
case RCCPPOPTIMIZATIONLEVEL_NOT_SET:;
}
// Check for intermediate directory, create it if required
// There are a lot more checks and robustness that could be added here
if( !compilerOptions_.intermediatePath.Exists() )
{
bool success = compilerOptions_.intermediatePath.CreateDir();
if( success && m_pImplData->m_pLogger ) { m_pImplData->m_pLogger->LogInfo("Created intermediate folder \"%s\"\n", compilerOptions_.intermediatePath.c_str()); }
else if( m_pImplData->m_pLogger ) { m_pImplData->m_pLogger->LogError("Error creating intermediate folder \"%s\"\n", compilerOptions_.intermediatePath.c_str()); }
}
FileSystemUtils::Path output = moduleName_;
bool bCopyOutput = false;
if( compilerOptions_.intermediatePath.Exists() )
{
// add save object files
compileString = "cd \"" + compilerOptions_.intermediatePath.m_string + "\"\n" + compileString + " --save-temps ";
output = compilerOptions_.intermediatePath / "a.out";
bCopyOutput = true;
}
// include directories
for( size_t i = 0; i < includeDirList.size(); ++i )
{
compileString += "-I\"" + includeDirList[i].m_string + "\" ";
}
// library and framework directories
for( size_t i = 0; i < libraryDirList.size(); ++i )
{
compileString += "-L\"" + libraryDirList[i].m_string + "\" ";
compileString += "-F\"" + libraryDirList[i].m_string + "\" ";
}
if( !bCopyOutput )
{
// output file
compileString += "-o " + output.m_string + " ";
}
if( pCompileOptions )
{
compileString += pCompileOptions;
compileString += " ";
}
if( pLinkOptions && strlen(pLinkOptions) )
{
compileString += "-Wl,";
compileString += pLinkOptions;
compileString += " ";
}
// files to compile
for( size_t i = 0; i < filesToCompile_.size(); ++i )
{
compileString += "\"" + filesToCompile_[i].m_string + "\" ";
}
// libraries to link
for( size_t i = 0; i < linkLibraryList_.size(); ++i )
{
compileString += " " + linkLibraryList_[i].m_string + " ";
}
if( bCopyOutput )
{
compileString += "\n mv \"" + output.m_string + "\" \"" + moduleName_.m_string + "\"\n";
}
std::cout << compileString << std::endl << std::endl;
execl("/bin/sh", "sh", "-c", compileString.c_str(), (const char*)NULL);
}

View File

@ -1,567 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
// RuntimeDLLTest01.cpp : Defines the entry point for the console application.
//
// Notes:
// - We use a single intermediate directory for compiled .obj files, which means
// we don't support compiling multiple files with the same name. Could fix this
// with either mangling names to include paths, or recreating folder structure
//
//
#include "Compiler.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include "FileSystemUtils.h"
#include "assert.h"
#include <process.h>
#include "ICompilerLogger.h"
using namespace std;
using namespace FileSystemUtils;
struct VSVersionInfo
{
int Version;
std::string Path;
};
const std::string c_CompletionToken( "_COMPLETION_TOKEN_" );
void GetPathsOfVisualStudioInstalls( std::vector<VSVersionInfo>* pVersions );
void ReadAndHandleOutputThread( LPVOID arg );
void WriteInput( HANDLE hPipeWrite, std::string& input );
class PlatformCompilerImplData
{
public:
PlatformCompilerImplData()
: m_bCompileIsComplete( false )
, m_CmdProcessOutputRead( NULL )
, m_CmdProcessInputWrite( NULL )
{
ZeroMemory( &m_CmdProcessInfo, sizeof(m_CmdProcessInfo) );
}
void InitialiseProcess()
{
//init compile process
STARTUPINFOW si;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
#ifndef _WIN64
std::string cmdSetParams = "@PROMPT $ \n\"" + m_VSPath + "Vcvarsall.bat\" x86\n";
#else
std::string cmdSetParams = "@PROMPT $ \n\"" + m_VSPath + "Vcvarsall.bat\" x86_amd64\n";
#endif
// Set up the security attributes struct.
SECURITY_ATTRIBUTES sa;
sa.nLength= sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
// Create the child output pipe.
//redirection of output
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
HANDLE hOutputReadTmp = NULL, hOutputWrite = NULL, hErrorWrite = NULL;
if (!CreatePipe(&hOutputReadTmp,&hOutputWrite,&sa,20*1024))
{
if( m_pLogger ) m_pLogger->LogError("[RuntimeCompiler] Failed to create output redirection pipe\n");
goto ERROR_EXIT;
}
si.hStdOutput = hOutputWrite;
// Create a duplicate of the output write handle for the std error
// write handle. This is necessary in case the child application
// closes one of its std output handles.
if (!DuplicateHandle(GetCurrentProcess(),hOutputWrite,
GetCurrentProcess(),&hErrorWrite,0,
TRUE,DUPLICATE_SAME_ACCESS))
{
if( m_pLogger ) m_pLogger->LogError("[RuntimeCompiler] Failed to duplicate error output redirection pipe\n");
goto ERROR_EXIT;
}
si.hStdError = hErrorWrite;
// Create new output read handle and the input write handles. Set
// the Properties to FALSE. Otherwise, the child inherits the
// properties and, as a result, non-closeable handles to the pipes
// are created.
if( si.hStdOutput )
{
if (!DuplicateHandle(GetCurrentProcess(),hOutputReadTmp,
GetCurrentProcess(),
&m_CmdProcessOutputRead, // Address of new handle.
0,FALSE, // Make it uninheritable.
DUPLICATE_SAME_ACCESS))
{
if( m_pLogger ) m_pLogger->LogError("[RuntimeCompiler] Failed to duplicate output read pipe\n");
goto ERROR_EXIT;
}
CloseHandle( hOutputReadTmp );
hOutputReadTmp = NULL;
}
HANDLE hInputRead,hInputWriteTmp;
// Create a pipe for the child process's STDIN.
if (!CreatePipe(&hInputRead, &hInputWriteTmp, &sa, 4096))
{
if( m_pLogger ) m_pLogger->LogError("[RuntimeCompiler] Failed to create input pipes\n");
goto ERROR_EXIT;
}
si.hStdInput = hInputRead;
// Create new output read handle and the input write handles. Set
// the Properties to FALSE. Otherwise, the child inherits the
// properties and, as a result, non-closeable handles to the pipes
// are created.
if( si.hStdOutput )
{
if (!DuplicateHandle(GetCurrentProcess(),hInputWriteTmp,
GetCurrentProcess(),
&m_CmdProcessInputWrite, // Address of new handle.
0,FALSE, // Make it uninheritable.
DUPLICATE_SAME_ACCESS))
{
if( m_pLogger ) m_pLogger->LogError("[RuntimeCompiler] Failed to duplicate input write pipe\n");
goto ERROR_EXIT;
}
}
/*
// Ensure the write handle to the pipe for STDIN is not inherited.
if ( !SetHandleInformation(hInputWrite, HANDLE_FLAG_INHERIT, 0) )
{
m_pLogger->LogError("[RuntimeCompiler] Failed to make input write pipe non inheritable\n");
goto ERROR_EXIT;
}
*/
wchar_t* pCommandLine = L"cmd /q";
//CreateProcessW won't accept a const pointer, so copy to an array
wchar_t pCmdLineNonConst[1024];
wcscpy_s( pCmdLineNonConst, pCommandLine );
CreateProcessW(
NULL, //__in_opt LPCTSTR lpApplicationName,
pCmdLineNonConst, //__inout_opt LPTSTR lpCommandLine,
NULL, //__in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes,
NULL, //__in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes,
TRUE, //__in BOOL bInheritHandles,
0, //__in DWORD dwCreationFlags,
NULL, //__in_opt LPVOID lpEnvironment,
NULL, //__in_opt LPCTSTR lpCurrentDirectory,
&si, //__in LPSTARTUPINFO lpStartupInfo,
&m_CmdProcessInfo //__out LPPROCESS_INFORMATION lpProcessInformation
);
//send initial set up command
WriteInput( m_CmdProcessInputWrite, cmdSetParams );
//launch threaded read.
_beginthread( ReadAndHandleOutputThread, 0, this ); //this will exit when process for compile is closed
ERROR_EXIT:
if( hOutputReadTmp )
{
CloseHandle( hOutputReadTmp );
}
if( hOutputWrite )
{
CloseHandle( hOutputWrite );
}
if( hErrorWrite )
{
CloseHandle( hErrorWrite );
}
}
void CleanupProcessAndPipes()
{
// do not reset m_bCompileIsComplete and other members here, just process and pipes
if( m_CmdProcessInfo.hProcess )
{
TerminateProcess( m_CmdProcessInfo.hProcess, 0 );
TerminateThread( m_CmdProcessInfo.hThread, 0 );
CloseHandle( m_CmdProcessInfo.hThread );
ZeroMemory( &m_CmdProcessInfo, sizeof(m_CmdProcessInfo) );
CloseHandle( m_CmdProcessInputWrite );
m_CmdProcessInputWrite = 0;
CloseHandle( m_CmdProcessOutputRead );
m_CmdProcessOutputRead = 0;
}
}
~PlatformCompilerImplData()
{
CleanupProcessAndPipes();
}
std::string m_VSPath;
PROCESS_INFORMATION m_CmdProcessInfo;
HANDLE m_CmdProcessOutputRead;
HANDLE m_CmdProcessInputWrite;
volatile bool m_bCompileIsComplete;
ICompilerLogger* m_pLogger;
};
Compiler::Compiler()
: m_pImplData( 0 )
, m_bFastCompileMode( false )
{
}
Compiler::~Compiler()
{
delete m_pImplData;
}
std::string Compiler::GetObjectFileExtension() const
{
return ".obj";
}
bool Compiler::GetIsComplete() const
{
bool bComplete = m_pImplData->m_bCompileIsComplete;
if( bComplete & !m_bFastCompileMode )
{
m_pImplData->CleanupProcessAndPipes();
}
return bComplete;
}
void Compiler::Initialise( ICompilerLogger * pLogger )
{
m_pImplData = new PlatformCompilerImplData;
m_pImplData->m_pLogger = pLogger;
// get VS compiler path
std::vector<VSVersionInfo> Versions;
GetPathsOfVisualStudioInstalls( &Versions );
if( !Versions.empty() )
{
m_pImplData->m_VSPath = Versions[0].Path;
}
else
{
m_pImplData->m_VSPath = "";
if( m_pImplData->m_pLogger )
{
m_pImplData->m_pLogger->LogError("No Supported Compiler for RCC++ found.\n");
}
}
}
void Compiler::RunCompile( const std::vector<FileSystemUtils::Path>& filesToCompile_,
const CompilerOptions& compilerOptions_,
std::vector<FileSystemUtils::Path> linkLibraryList_,
const FileSystemUtils::Path& moduleName_ )
{
if( m_pImplData->m_VSPath.empty() )
{
if (m_pImplData->m_pLogger) { m_pImplData->m_pLogger->LogError("No Supported Compiler for RCC++ found, cannot compile changes.\n"); }
m_pImplData->m_bCompileIsComplete = true;
return;
}
m_pImplData->m_bCompileIsComplete = false;
//optimization and c runtime
#ifdef _DEBUG
std::string flags = "/nologo /Zi /FC /MDd /LDd ";
#else
std::string flags = "/nologo /Zi /FC /MD /LD "; //also need debug information in release
#endif
RCppOptimizationLevel optimizationLevel = GetActualOptimizationLevel( compilerOptions_.optimizationLevel );
switch( optimizationLevel )
{
case RCCPPOPTIMIZATIONLEVEL_DEFAULT:
assert(false);
case RCCPPOPTIMIZATIONLEVEL_DEBUG:
flags += "/Od ";
break;
case RCCPPOPTIMIZATIONLEVEL_PERF:
flags += "/O2 /Oi ";
// Add improved debugging options if available: http://randomascii.wordpress.com/2013/09/11/debugging-optimized-codenew-in-visual-studio-2012/
#if (_MSC_VER >= 1700)
flags += "/d2Zi+ ";
#endif
break;
case RCCPPOPTIMIZATIONLEVEL_NOT_SET:;
}
if( NULL == m_pImplData->m_CmdProcessInfo.hProcess )
{
m_pImplData->InitialiseProcess();
}
flags += compilerOptions_.compileOptions;
flags += " ";
std::string linkOptions;
bool bHaveLinkOptions = ( 0 != compilerOptions_.linkOptions.length() );
if( compilerOptions_.libraryDirList.size() || bHaveLinkOptions )
{
linkOptions = " /link ";
for( size_t i = 0; i < compilerOptions_.libraryDirList.size(); ++i )
{
linkOptions += " /LIBPATH:\"" + compilerOptions_.libraryDirList[i].m_string + "\"";
}
if( bHaveLinkOptions )
{
linkOptions += compilerOptions_.linkOptions;
linkOptions += " ";
}
}
// faster linking if available: https://randomascii.wordpress.com/2015/07/27/programming-is-puzzles/
#if (_MSC_VER >= 1900)
if( linkOptions.empty() )
{
linkOptions = " /link ";
}
linkOptions += "/DEBUG:FASTLINK ";
#endif
// Check for intermediate directory, create it if required
// There are a lot more checks and robustness that could be added here
if ( !compilerOptions_.intermediatePath.Exists() )
{
bool success = compilerOptions_.intermediatePath.CreateDir();
if( success && m_pImplData->m_pLogger ) { m_pImplData->m_pLogger->LogInfo("Created intermediate folder \"%s\"\n", compilerOptions_.intermediatePath.c_str()); }
else if( m_pImplData->m_pLogger ) { m_pImplData->m_pLogger->LogError("Error creating intermediate folder \"%s\"\n", compilerOptions_.intermediatePath.c_str()); }
}
//create include path search string
std::string strIncludeFiles;
for( size_t i = 0; i < compilerOptions_.includeDirList.size(); ++i )
{
strIncludeFiles += " /I \"" + compilerOptions_.includeDirList[i].m_string + "\"";
}
// When using multithreaded compilation, listing a file for compilation twice can cause errors, hence
// we do a final filtering of input here.
// See http://msdn.microsoft.com/en-us/library/bb385193.aspx - "Source Files and Build Order"
// Create compile path search string
std::string strFilesToCompile;
std::set<std::string> filteredPaths;
for( size_t i = 0; i < filesToCompile_.size(); ++i )
{
std::string strPath = filesToCompile_[i].m_string;
FileSystemUtils::ToLowerInPlace(strPath);
std::set<std::string>::const_iterator it = filteredPaths.find(strPath);
if (it == filteredPaths.end())
{
strFilesToCompile += " \"" + strPath + "\"";
filteredPaths.insert(strPath);
}
}
std::string strLinkLibraries;
for( size_t i = 0; i < linkLibraryList_.size(); ++i )
{
strLinkLibraries += " \"" + linkLibraryList_[i].m_string + "\" ";
}
char* pCharTypeFlags = "";
#ifdef UNICODE
pCharTypeFlags = "/D UNICODE /D _UNICODE ";
#endif
// /MP - use multiple processes to compile if possible. Only speeds up compile for multiple files and not link
std::string cmdToSend = "cl " + flags + pCharTypeFlags
+ " /MP /Fo\"" + compilerOptions_.intermediatePath.m_string + "\\\\\" "
+ "/D WIN32 /EHa /Fe" + moduleName_.m_string;
cmdToSend += " " + strIncludeFiles + " " + strFilesToCompile + strLinkLibraries + linkOptions
+ "\necho ";
if( m_pImplData->m_pLogger ) m_pImplData->m_pLogger->LogInfo( "%s", cmdToSend.c_str() ); // use %s to prevent any tokens in compile string being interpreted as formating
cmdToSend += c_CompletionToken + "\n";
WriteInput( m_pImplData->m_CmdProcessInputWrite, cmdToSend );
}
void GetPathsOfVisualStudioInstalls( std::vector<VSVersionInfo>* pVersions )
{
//HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\<version>\Setup\VS\<edition>
std::string keyName = "SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7";
const size_t NUMNAMESTOCHECK = 6;
// supporting: VS2005, VS2008, VS2010, VS2011, VS2013, VS2015
std::string valueName[NUMNAMESTOCHECK] = {"8.0","9.0","10.0","11.0","12.0","14.0"};
// we start searching for a compatible compiler from the current version backwards
int startVersion = NUMNAMESTOCHECK - 1;
//switch around prefered compiler to the one we've used to compile this file
const unsigned int MSCVERSION = _MSC_VER;
switch( MSCVERSION )
{
case 1400: //VS 2005
startVersion = 0;
break;
case 1500: //VS 2008
startVersion = 1;
break;
case 1600: //VS 2010
startVersion = 2;
break;
case 1700: //VS 2012
startVersion = 3;
break;
case 1800: //VS 2013
startVersion = 4;
break;
case 1900: //VS 2015
startVersion = 5;
break;
default:
assert( false ); //unsupported compiler, find MSCVERSION to add case, increase NUMNAMESTOCHECK and add valueName.
}
char value[MAX_PATH];
DWORD size = MAX_PATH;
HKEY key;
LONG retKeyVal = RegOpenKeyExA(
HKEY_LOCAL_MACHINE, //__in HKEY hKey,
keyName.c_str(), //__in_opt LPCTSTR lpSubKey,
0, //__reserved DWORD ulOptions,
KEY_READ | KEY_WOW64_32KEY, //__in REGSAM samDesired,
&key //__out PHKEY phkResult
);
int loopCount = 1;
if( startVersion != NUMNAMESTOCHECK - 1 )
{
// we potentially need to restart search from top
loopCount = 2;
}
for( int loop = 0; loop < loopCount; ++loop )
{
for( int i = startVersion; i >= 0; --i )
{
LONG retVal = RegQueryValueExA(
key, //__in HKEY hKey,
valueName[i].c_str(), //__in_opt LPCTSTR lpValueName,
NULL, //__reserved LPDWORD lpReserved,
NULL , //__out_opt LPDWORD lpType,
(LPBYTE)value, //__out_opt LPBYTE lpData,
&size //__inout_opt LPDWORD lpcbData
);
if( ERROR_SUCCESS == retVal )
{
VSVersionInfo vInfo;
vInfo.Version = i + 8;
vInfo.Path = value;
pVersions->push_back( vInfo );
}
}
startVersion = NUMNAMESTOCHECK - 1; // if we loop around again make sure it's from the top
}
RegCloseKey( key );
return;
}
void ReadAndHandleOutputThread( LPVOID arg )
{
PlatformCompilerImplData* pImpl = (PlatformCompilerImplData*)arg;
CHAR lpBuffer[1024];
DWORD nBytesRead;
bool bReadActive = true;
bool bReadOneMore = false;
while( bReadActive )
{
if (!ReadFile(pImpl->m_CmdProcessOutputRead,lpBuffer,sizeof(lpBuffer)-1,
&nBytesRead,NULL) || !nBytesRead)
{
bReadActive = false;
if (GetLastError() != ERROR_BROKEN_PIPE) //broken pipe is OK
{
if( pImpl->m_pLogger ) pImpl->m_pLogger->LogError( "[RuntimeCompiler] Redirect of compile output failed on read\n" );
}
}
else
{
// Display the characters read in logger.
lpBuffer[nBytesRead]=0;
//fist check for completion token...
std::string buffer( lpBuffer );
size_t found = buffer.find( c_CompletionToken );
if( found != std::string::npos )
{
//we've found the completion token, which means we quit
buffer = buffer.substr( 0, found );
if( pImpl->m_pLogger ) pImpl->m_pLogger->LogInfo("[RuntimeCompiler] Complete\n");
pImpl->m_bCompileIsComplete = true;
}
if( bReadActive || buffer.length() ) //don't output blank last line
{
//check if this is an error
size_t errorFound = buffer.find( " : error " );
size_t fatalErrorFound = buffer.find( " : fatal error " );
if( ( errorFound != std::string::npos ) || ( fatalErrorFound != std::string::npos ) )
{
if( pImpl->m_pLogger ) pImpl->m_pLogger->LogError( "%s", buffer.c_str() );
}
else
{
if( pImpl->m_pLogger ) pImpl->m_pLogger->LogInfo( "%s", buffer.c_str() );
}
}
}
}
}
void WriteInput( HANDLE hPipeWrite, std::string& input )
{
DWORD nBytesWritten;
DWORD length = (DWORD)input.length();
WriteFile( hPipeWrite, input.c_str() , length, &nBytesWritten, NULL );
}

View File

@ -1,196 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "FileChangeNotifier.h"
#include <algorithm>
using namespace std;
#define DEFAULT_MIN_TIME_BETWEEN_RECOMPILES 1.0f
#define DEFAULT_NOTIFY_DELAY 0.1f
#define FILE_CHANGE_SPAM_TIME 1.0f
FileChangeNotifier::FileChangeNotifier()
: m_bActive(true)
, m_bRecompilePending(false)
, m_fMinTimeBetweenNotifications(DEFAULT_MIN_TIME_BETWEEN_RECOMPILES)
, m_fChangeNotifyDelay(DEFAULT_NOTIFY_DELAY)
, m_fTimeUntilNextAllowedRecompile(0.0f)
, m_fFileChangeSpamTimeRemaining(0.0f)
, m_pFileWatcher( new FW::FileWatcher() ) // Create the file watch object
{
m_LastFileChanged = "";
}
FileChangeNotifier::~FileChangeNotifier()
{
delete m_pFileWatcher;
}
void FileChangeNotifier::SetMinTimeBetweenNotifications( float fMinTime )
{
m_fMinTimeBetweenNotifications = max(0.0f, fMinTime);
}
void FileChangeNotifier::SetChangeNotifyDelay( float fDelay)
{
m_fChangeNotifyDelay = max(0.0f, fDelay);
}
void FileChangeNotifier::Update( float fDeltaTime )
{
if (m_bActive)
{
m_pFileWatcher->update();
m_fTimeUntilNextAllowedRecompile = max(0.0f, m_fTimeUntilNextAllowedRecompile - fDeltaTime);
m_fFileChangeSpamTimeRemaining = max(0.0f, m_fFileChangeSpamTimeRemaining - fDeltaTime);
if (m_bRecompilePending)
{
TriggerNotificationIfPossible();
}
}
}
void FileChangeNotifier::Watch( const FileSystemUtils::Path& filename, IFileChangeListener *pListener )
{
FileSystemUtils::Path fixedFilename = filename.DelimitersToOSDefault(); // Note this doesn't handle ../
fixedFilename = fixedFilename.GetCleanPath();
fixedFilename.ToOSCanonicalCase();
if( m_fileListenerMap[fixedFilename].insert(pListener).second )
{
bool bPathIsDir = !fixedFilename.HasExtension();
FileSystemUtils::Path pathDir = bPathIsDir ? fixedFilename : fixedFilename.ParentPath();
if( m_WatchedDirs.insert( pathDir.m_string ).second )
{
m_pFileWatcher->addWatch( pathDir.m_string, this );
}
}
pListener->OnRegisteredWithNotifier(this);
}
void FileChangeNotifier::Watch( const char *filename, IFileChangeListener *pListener )
{
Watch(FileSystemUtils::Path(filename), pListener);
}
void FileChangeNotifier::RemoveListener( IFileChangeListener *pListener )
{
TFileListenerMap::iterator it = m_fileListenerMap.begin();
TFileListenerMap::iterator itEnd = m_fileListenerMap.end();
while (it != itEnd)
{
it->second.erase(pListener);
++it;
}
pListener->OnRegisteredWithNotifier(NULL);
}
void FileChangeNotifier::handleFileAction( FW::WatchID watchid, const FW::String& dir, const FW::String& filename,
FW::Action action )
{
if (m_bActive)
{
FileSystemUtils::Path filePath(filename);
if( !filename.HasParentPath() )
{
filePath = dir / filePath;
}
filePath = filePath.DelimitersToOSDefault();
filePath.ToOSCanonicalCase();
// Check for multiple hits on the same file in close succession
// (Can be caused by NTFS system making multiple changes even though only
// one actual change occurred)
bool bIgnoreFileChange = (filePath == m_LastFileChanged) &&
m_fFileChangeSpamTimeRemaining > 0.0f;
m_LastFileChanged = filePath;
if (!bIgnoreFileChange)
{
m_changedFileList.insert(filePath.m_string);
if (!m_bRecompilePending)
{
m_bRecompilePending = true;
m_fTimeUntilNextAllowedRecompile = max(m_fTimeUntilNextAllowedRecompile, m_fChangeNotifyDelay);
}
m_fFileChangeSpamTimeRemaining = FILE_CHANGE_SPAM_TIME;
TriggerNotificationIfPossible();
}
}
}
void FileChangeNotifier::TriggerNotificationIfPossible()
{
if (m_fTimeUntilNextAllowedRecompile <= 0.0f)
{
m_fTimeUntilNextAllowedRecompile = m_fMinTimeBetweenNotifications;
m_bRecompilePending = false;
NotifyListeners();
m_changedFileList.clear();
}
else
{
m_bRecompilePending = true;
}
}
void FileChangeNotifier::NotifyListeners()
{
std::map<IFileChangeListener*, AUDynArray<const char*> > interestedListenersMap;
// Determine which listeners are interested in which changed files
TPathNameList::const_iterator fileIt = m_changedFileList.begin();
TPathNameList::const_iterator fileItEnd = m_changedFileList.end();
while (fileIt != fileItEnd)
{
TFileChangeListeners& listeners = m_fileListenerMap[*fileIt];
TFileChangeListeners::iterator listenerIt = listeners.begin();
TFileChangeListeners::iterator listenerItEnd = listeners.end();
while (listenerIt != listenerItEnd)
{
interestedListenersMap[*listenerIt].Add(fileIt->c_str());
++listenerIt;
}
++fileIt;
}
// Notify each listener with an appropriate file list
std::map<IFileChangeListener*, AUDynArray<const char*> >::iterator finalIt = interestedListenersMap.begin();
std::map<IFileChangeListener*, AUDynArray<const char*> >::iterator finalItEnd = interestedListenersMap.end();
while (finalIt != finalItEnd)
{
finalIt->first->OnFileChange(finalIt->second);
++finalIt;
}
}

View File

@ -1,111 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef FILECHANGENOTIFIER_INCLUDED
#define FILECHANGENOTIFIER_INCLUDED
#include "IFileChangeNotifier.h"
#include "SimpleFileWatcher/FileWatcher.h"
#include <vector>
#include <map>
#include <set>
#include "FileSystemUtils.h"
// Manages the registering of files with the file monitor and triggering
// Of compilation when a registered file changes
class FileChangeNotifier : public IFileChangeNotifier, public FW::FileWatchListener
{
public:
FileChangeNotifier();
virtual ~FileChangeNotifier();
// IFileChangeNotifier
virtual bool IsMonitoringActive() const
{
return m_bActive;
}
virtual void SetMonitoringActive( bool bActive )
{
m_bActive = bActive;
}
virtual float GetMinTimeBetweenNotifications() const
{
return m_fMinTimeBetweenNotifications;
}
virtual void SetMinTimeBetweenNotifications( float fMinTime );
virtual float GetChangeNotifyDelay() const
{
return m_fChangeNotifyDelay;
}
virtual void SetChangeNotifyDelay( float fDelay );
virtual void Update( float fDeltaTime );
// Add file to trigger compilation when it changes
virtual void Watch( const FileSystemUtils::Path& filename, IFileChangeListener *pListener );
virtual void Watch( const char *filename, IFileChangeListener *pListener );
virtual void RemoveListener( IFileChangeListener *pListener );
// ~IFileChangeNotifier
// FW::FileWatchListener
void handleFileAction(FW::WatchID watchid, const FW::String& dir, const FW::String& filename,
FW::Action action);
// ~FW::FileWatchListener
private:
void TriggerNotificationIfPossible();
void NotifyListeners();
typedef std::set<IFileChangeListener*> TFileChangeListeners;
typedef std::map<FileSystemUtils::Path, TFileChangeListeners> TFileListenerMap;
typedef std::set<std::string> TPathNameList;
// Private members
FW::FileWatcher* m_pFileWatcher;
TPathNameList m_WatchedDirs;
TFileListenerMap m_fileListenerMap;
TPathNameList m_changedFileList;
bool m_bActive;
bool m_bRecompilePending;
float m_fMinTimeBetweenNotifications;
float m_fChangeNotifyDelay;
float m_fTimeUntilNextAllowedRecompile;
float m_fFileChangeSpamTimeRemaining;
FileSystemUtils::Path m_LastFileChanged;
};
#endif //FILECHANGENOTIFIER_INCLUDED

View File

@ -1,584 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
// we use std::string as there are many string types in the community
// and this can be easily swapped for your own implementation if desired
#include <string>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#ifdef _WIN32
#include <direct.h>
#include <sys/utime.h>
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#undef GetObject
#undef GetCurrentTime
#define FILESYSTEMUTILS_SEPERATORS "/\\"
#else
#include <utime.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#define FILESYSTEMUTILS_SEPERATORS "/"
#endif
namespace FileSystemUtils
{
#ifdef _WIN32
typedef __time64_t filetime_t;
#else
typedef time_t filetime_t;
#endif
class Path
{
public:
std::string m_string;
Path()
{
}
Path( const std::string& rhs_ )
: m_string( rhs_ )
{
}
Path( const char* rhs_ )
: m_string( rhs_ )
{
}
virtual ~Path() {} // for RCC++
const char* c_str() const;
Path& operator=( const std::string& rhs_ );
Path& operator=( const char* rhs_ );
bool Exists() const;
bool CreateDir() const;
bool Remove() const;
filetime_t GetLastWriteTime() const;
void SetLastWriteTime( filetime_t time_ ) const;
uint64_t GetFileSize() const;
bool HasExtension() const;
bool HasParentPath() const;
std::string Extension() const;
// returns filename - i.e. part after final seperator: ./dirone/hello.txt > hello.txt ; ./dirone/hello > hello ; ./dirone/ > [empty string]
Path Filename() const;
Path ParentPath() const;
Path DelimitersToOSDefault() const;
// returns a path cleaned of /../ by removing prior dir
Path GetCleanPath() const;
void ToOSCanonicalCase(); // lower case on Windows, preserve case on Linux
// replaces extension if one exists, or adds it if not
void ReplaceExtension( const std::string& ext );
#ifdef _WIN32
static const char seperator = '\\';
static const char altseperator = '/';
#else
static const char seperator = '/';
static const char altseperator = '\\';
#endif
};
inline void ToLowerInPlace( std::string& inout_str )
{
for( size_t i = 0; i < inout_str.size(); ++i )
{
if( inout_str[i] >= 'A' && inout_str[i] <= 'Z' )
{
//tolower
inout_str[i] -= 'A'-'a';
}
}
}
///////////////////////////////////////////////////////////////////
// Path function definitions
inline const char* Path::c_str() const
{
return m_string.c_str();
}
inline Path& Path::operator=( const std::string& rhs_ )
{
m_string = rhs_;
return *this;
}
inline Path& Path::operator=( const char* rhs_ )
{
m_string = rhs_;
return *this;
}
inline bool Path::Exists() const
{
int error = -1;
#ifdef _WIN32
struct _stat buffer;
error = _stat( m_string.c_str(), &buffer );
#else
struct stat buffer;
error = stat( m_string.c_str(), &buffer );
#endif
if( 0 == error )
{
return true;
}
return false;
}
inline bool Path::CreateDir() const
{
if( m_string.length() == 0 )
{
return false;
}
if( Exists() )
{
return false;
}
// we may need to create the parent path recursively
Path parentpath = ParentPath();
if( !parentpath.Exists() )
{
parentpath.CreateDir();
}
int error = -1;
#ifdef _WIN32
error = _mkdir( m_string.c_str() );
#else
error = mkdir( m_string.c_str(), 0777 );
#endif
if( 0 == error )
{
return true;
}
return false;
}
inline filetime_t Path::GetLastWriteTime() const
{
filetime_t lastwritetime = 0;
int error = -1;
#ifdef _WIN32
struct _stat64 buffer;
error = _stat64( c_str(), &buffer );
#else
struct stat buffer;
error = stat( c_str(), &buffer );
#endif
if( 0 == error )
{
lastwritetime = buffer.st_mtime;
}
return lastwritetime;
}
inline void Path::SetLastWriteTime( filetime_t time_ ) const
{
#ifdef _WIN32
__utimbuf64 modtime = { time_, time_ };
_utime64( c_str(), &modtime );
#else
utimbuf modtime = { time_, time_ };
utime( c_str(), &modtime );
#endif
}
inline filetime_t GetCurrentTime()
{
filetime_t timer;
#ifdef _WIN32
_time64(&timer);
#else
time(&timer);
#endif
return timer;
}
inline tm GetTimeStruct( filetime_t time )
{
tm ret;
#ifdef _WIN32
_gmtime64_s(&ret, &time);
#else
gmtime_r(&time, &ret);
#endif
return ret;
}
inline bool Path::Remove() const
{
int error = remove( c_str() );
if( !error )
{
return true;
}
return false;
}
inline uint64_t Path::GetFileSize() const
{
uint64_t filesize = 0;
int error = -1;
#ifdef _WIN32
struct _stat64 buffer;
error = _stat64( c_str(), &buffer );
#else
struct stat buffer;
error = stat( c_str(), &buffer );
#endif
if( 0 == error )
{
filesize = buffer.st_size;
}
return filesize;
}
inline bool Path::HasExtension() const
{
size_t posdot = m_string.find_last_of( '.' );
if( posdot != std::string::npos )
{
size_t posseperator = m_string.find_last_of( seperator );
if( posseperator != std::string::npos && posseperator > posdot )
{
return false; // the dot is for a directory such as ./ or ../ or the path is malformed
}
size_t posaltseperator = m_string.find_last_of( altseperator );
if( posaltseperator != std::string::npos && posaltseperator > posdot )
{
return false; // the dot is for a directory such as ./ or ../ or the path is malformed
}
return true;
}
return false;
}
inline bool Path::HasParentPath() const
{
size_t posseperator = m_string.find_last_of( seperator );
if( posseperator != std::string::npos && posseperator > 0 )
{
return true;
}
size_t posaltseperator = m_string.find_last_of( altseperator );
if( posaltseperator != std::string::npos && posaltseperator > 0 )
{
return true;
}
return false;
}
inline std::string Path::Extension() const
{
std::string ext;
if( HasExtension() )
{
size_t pos = m_string.find_last_of( '.' );
if( pos < m_string.length() )
{
ext = m_string.substr( pos );
}
}
return ext;
}
inline Path Path::Filename() const
{
Path filename;
size_t pos = m_string.find_last_of( seperator ) + 1;
if( pos <= m_string.length() )
{
filename = m_string.substr(pos);
}
return filename;
}
inline Path Path::ParentPath() const
{
Path parentpath = m_string;
if( parentpath.m_string.length() == 0 )
{
return parentpath;
}
//remove any trailing seperators
while( parentpath.m_string.find_last_of( FILESYSTEMUTILS_SEPERATORS ) == parentpath.m_string.length()-1 )
{
parentpath.m_string.erase(parentpath.m_string.length()-1, 1);
}
size_t pos = parentpath.m_string.find_last_of( FILESYSTEMUTILS_SEPERATORS );
if( pos < parentpath.m_string.length() )
{
parentpath = parentpath.m_string.substr(0, pos);
//remove any trailing seperators
while( parentpath.m_string.find_last_of( FILESYSTEMUTILS_SEPERATORS ) == parentpath.m_string.length()-1)
{
parentpath.m_string.erase(parentpath.m_string.length()-1, 1);
}
}
return parentpath;
}
inline Path Path::DelimitersToOSDefault() const
{
Path path = m_string;
for( size_t i = 0; i < path.m_string.size(); ++i )
{
if( path.m_string[i] == altseperator )
{
path.m_string[i] = seperator;
}
}
return path;
}
inline void Path::ReplaceExtension( const std::string& ext )
{
if( HasExtension() )
{
size_t pos = m_string.find_last_of( '.' );
if( pos < m_string.length() )
{
m_string.erase( m_string.begin() + pos, m_string.end() );
}
}
m_string += ext;
}
inline Path operator/( const Path& lhs_, const Path& rhs_ )
{
if( 0 == lhs_.m_string.length() )
{
return rhs_;
}
if( 0 == rhs_.m_string.length() )
{
return lhs_;
}
std::string strlhs = lhs_.m_string;
while( strlhs.length() && strlhs.find_last_of( FILESYSTEMUTILS_SEPERATORS ) == strlhs.length()-1 )
{
strlhs.erase(strlhs.length()-1, 1);
}
//note: should probably remove preceding seperators to rhs_, but this has not as yet occured
Path join = strlhs + Path::seperator + rhs_.m_string;
return join;
}
inline bool operator==( const Path& lhs_, const Path& rhs_ )
{
return lhs_.m_string == rhs_.m_string;
}
inline bool operator<( const Path& lhs_, const Path& rhs_ )
{
return lhs_.m_string < rhs_.m_string;
}
inline Path GetCurrentPath()
{
Path currPath;
#ifdef _WIN32
char currdir[MAX_PATH];
GetCurrentDirectoryA( sizeof( currdir ), currdir );
currPath = currdir;
#else
char* currdir = getcwd(0,0);
currPath = currdir;
free( currdir );
#endif
return currPath;
}
inline Path Path::GetCleanPath() const
{
Path path = m_string;
bool bFound = false;
do
{
bFound = false;
size_t pos = path.m_string.find( ".." );
if( pos != std::string::npos && pos+3 < path.m_string.length() && pos > 0 )
{
Path a = path.m_string.substr(0,pos-1); // pos-1 as we don't want delimiter
Path b = path.m_string.substr(pos+3,path.m_string.length()); // pos+3 as we don't want delimiter
a = a.ParentPath();
path = a / b;
bFound = true;
}
} while( bFound );
return path;
}
inline void Path::ToOSCanonicalCase()
{
#ifdef _WIN32
ToLowerInPlace( m_string );
#endif
}
class PathIterator
{
private:
Path m_dir;
Path m_path;
bool m_bIsValid;
#ifdef _WIN32
void ImpCtor()
{
Path test = m_dir / "*";
m_path = m_dir;
m_hFind = INVALID_HANDLE_VALUE;
m_hFind = FindFirstFileA(test.c_str(), &m_ffd);
m_bIsValid = INVALID_HANDLE_VALUE != m_hFind;
}
bool ImpNext()
{
if( m_bIsValid )
{
m_bIsValid = 0 != FindNextFileA( m_hFind, &m_ffd );
if( m_bIsValid )
{
m_path = m_dir / m_ffd.cFileName;
if( m_path.Filename() == ".." )
{
return ImpNext();
}
}
}
return m_bIsValid;
}
void ImpDtor()
{
FindClose( m_hFind );
}
HANDLE m_hFind;
WIN32_FIND_DATAA m_ffd;
#else
void ImpCtor()
{
Path test = m_dir / "*";
m_path = m_dir;
m_numFilesInList = scandir( m_path.c_str(), &m_paDirFileList, 0, alphasort);
m_bIsValid = m_numFilesInList > 0;
m_currFile = 0;
if( !m_bIsValid )
{
m_paDirFileList = 0;
}
}
bool ImpNext()
{
if( m_bIsValid )
{
++m_currFile;
m_bIsValid = m_currFile < m_numFilesInList;
if( m_bIsValid )
{
m_path = m_dir / m_paDirFileList[ m_currFile ]->d_name;
if( strcmp( m_paDirFileList[ m_currFile ]->d_name, "." ) == 0 ||
strcmp( m_paDirFileList[ m_currFile ]->d_name, ".." ) == 0 )
{
return ImpNext();
}
}
}
return m_bIsValid;
}
void ImpDtor()
{
free(m_paDirFileList);
}
struct dirent **m_paDirFileList;
int m_numFilesInList;
int m_currFile;
#endif
public:
PathIterator( const Path& path_ )
: m_dir( path_ )
{
ImpCtor();
}
~PathIterator()
{
ImpDtor();
}
bool operator++()
{
return ImpNext();
}
bool IsValid() const
{
return m_bIsValid;
}
const Path& GetPath() const
{
return m_path;
}
};
}
inline FileSystemUtils::Path operator/( const std::string& lhs_, const std::string& rhs_ )
{
//remove any trailing seperators
FileSystemUtils::Path pathlhs = lhs_;
FileSystemUtils::Path pathrhs = rhs_;
return pathlhs / pathrhs;
}

View File

@ -1,34 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
// Compiler Logger - implement this interface to recieve logging from the RuntimeCompiler module
// In Aurora, this interface exists to avoid dependency on the Systems project
#ifndef ICOMPILERLOGGER_INCLUDED
#define ICOMPILERLOGGER_INCLUDED
struct ICompilerLogger
{
virtual void LogError(const char * format, ...) = 0;
virtual void LogWarning(const char * format, ...) = 0;
virtual void LogInfo(const char * format, ...) = 0;
virtual ~ICompilerLogger() {}
};
#endif // ICOMPILERLOGGER_INCLUDED

View File

@ -1,78 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef IFILECHANGENOTIFIER_INCLUDED
#define IFILECHANGENOTIFIER_INCLUDED
#include "../RuntimeCompiler/AUArray.h"
#include <set>
struct IFileChangeListener;
struct IFileChangeNotifier
{
virtual bool IsMonitoringActive() const = 0;
virtual void SetMonitoringActive( bool bActive ) = 0;
virtual float GetMinTimeBetweenNotifications() const = 0;
virtual void SetMinTimeBetweenNotifications( float fMinTime ) = 0;
// Delay to allow multiple file changes to accumulate before notifying listeners
virtual float GetChangeNotifyDelay() const = 0;
virtual void SetChangeNotifyDelay( float fDelay ) = 0;
virtual void Update( float fTimeDelta ) = 0;
virtual void Watch( const char *filename, IFileChangeListener *pListener ) = 0; // can be file or directory
virtual void RemoveListener( IFileChangeListener *pListener ) = 0;
virtual ~IFileChangeNotifier() {}
};
// IFileChangeListener will automatically deregister with FileChangeNotifier
// it registered with (via Watch method) on destruction
// Will not give expected results if the listener registers with multiple notifiers
struct IFileChangeListener
{
IFileChangeListener() : _registeredNotifier(0) {}
virtual ~IFileChangeListener()
{
if (_registeredNotifier)
{
_registeredNotifier->RemoveListener(this);
}
}
// Listener must make copies of strings if it wants to store them
virtual void OnFileChange( const IAUDynArray<const char*>& filelist ) = 0;
// Should be called by IFileChangeNotifier implementation only
void OnRegisteredWithNotifier( IFileChangeNotifier* pNotifier )
{
_registeredNotifier = pNotifier;
}
private:
IFileChangeNotifier* _registeredNotifier;
};
#endif // IFILECHANGENOTIFIER_INCLUDED

View File

@ -1,264 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
9106B90116AE8B9A003D2CD9 /* FileSystemUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 9106B90016AE8B9A003D2CD9 /* FileSystemUtils.h */; };
915C293416EB817400654B4E /* Compiler_PlatformPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 915C293316EB817400654B4E /* Compiler_PlatformPosix.cpp */; };
91CDEF8D1619F0D70061B76E /* BuildTool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91CDEF7D1619F0D70061B76E /* BuildTool.cpp */; };
91CDEF8E1619F0D70061B76E /* BuildTool.h in Headers */ = {isa = PBXBuildFile; fileRef = 91CDEF7E1619F0D70061B76E /* BuildTool.h */; };
91CDEF901619F0D70061B76E /* Compiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 91CDEF801619F0D70061B76E /* Compiler.h */; };
91CDEF911619F0D70061B76E /* FileChangeNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91CDEF811619F0D70061B76E /* FileChangeNotifier.cpp */; };
91CDEF921619F0D70061B76E /* FileChangeNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 91CDEF821619F0D70061B76E /* FileChangeNotifier.h */; };
91CDEF951619F0D70061B76E /* ICompilerLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 91CDEF851619F0D70061B76E /* ICompilerLogger.h */; };
91CDEF961619F0D70061B76E /* IFileChangeNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 91CDEF861619F0D70061B76E /* IFileChangeNotifier.h */; };
91CDEF981619F0D70061B76E /* FileWatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91CDEF881619F0D70061B76E /* FileWatcher.cpp */; };
91CDEF991619F0D70061B76E /* FileWatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 91CDEF891619F0D70061B76E /* FileWatcher.h */; };
91CDEF9A1619F0D70061B76E /* FileWatcherImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 91CDEF8A1619F0D70061B76E /* FileWatcherImpl.h */; };
91CDEF9B1619F0D70061B76E /* FileWatcherOSX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91CDEF8B1619F0D70061B76E /* FileWatcherOSX.cpp */; };
91CDEF9C1619F0D70061B76E /* FileWatcherOSX.h in Headers */ = {isa = PBXBuildFile; fileRef = 91CDEF8C1619F0D70061B76E /* FileWatcherOSX.h */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
9106B90016AE8B9A003D2CD9 /* FileSystemUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileSystemUtils.h; sourceTree = "<group>"; };
915C293316EB817400654B4E /* Compiler_PlatformPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Compiler_PlatformPosix.cpp; sourceTree = "<group>"; };
919FE7001619F04600A269B6 /* libRuntimeCompiler.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRuntimeCompiler.a; sourceTree = BUILT_PRODUCTS_DIR; };
91CDEF7D1619F0D70061B76E /* BuildTool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BuildTool.cpp; sourceTree = "<group>"; };
91CDEF7E1619F0D70061B76E /* BuildTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BuildTool.h; sourceTree = "<group>"; };
91CDEF801619F0D70061B76E /* Compiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Compiler.h; sourceTree = "<group>"; };
91CDEF811619F0D70061B76E /* FileChangeNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileChangeNotifier.cpp; sourceTree = "<group>"; };
91CDEF821619F0D70061B76E /* FileChangeNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileChangeNotifier.h; sourceTree = "<group>"; };
91CDEF851619F0D70061B76E /* ICompilerLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ICompilerLogger.h; sourceTree = "<group>"; };
91CDEF861619F0D70061B76E /* IFileChangeNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IFileChangeNotifier.h; sourceTree = "<group>"; };
91CDEF881619F0D70061B76E /* FileWatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileWatcher.cpp; path = SimpleFileWatcher/FileWatcher.cpp; sourceTree = "<group>"; };
91CDEF891619F0D70061B76E /* FileWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileWatcher.h; path = SimpleFileWatcher/FileWatcher.h; sourceTree = "<group>"; };
91CDEF8A1619F0D70061B76E /* FileWatcherImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileWatcherImpl.h; path = SimpleFileWatcher/FileWatcherImpl.h; sourceTree = "<group>"; };
91CDEF8B1619F0D70061B76E /* FileWatcherOSX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileWatcherOSX.cpp; path = SimpleFileWatcher/FileWatcherOSX.cpp; sourceTree = "<group>"; };
91CDEF8C1619F0D70061B76E /* FileWatcherOSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileWatcherOSX.h; path = SimpleFileWatcher/FileWatcherOSX.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
919FE6FD1619F04600A269B6 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
919FE6F51619F04600A269B6 = {
isa = PBXGroup;
children = (
915C293316EB817400654B4E /* Compiler_PlatformPosix.cpp */,
9106B90016AE8B9A003D2CD9 /* FileSystemUtils.h */,
91CDEF9E1619F0E30061B76E /* SimpleFileWatcher */,
91CDEF7D1619F0D70061B76E /* BuildTool.cpp */,
91CDEF7E1619F0D70061B76E /* BuildTool.h */,
91CDEF801619F0D70061B76E /* Compiler.h */,
91CDEF811619F0D70061B76E /* FileChangeNotifier.cpp */,
91CDEF821619F0D70061B76E /* FileChangeNotifier.h */,
91CDEF851619F0D70061B76E /* ICompilerLogger.h */,
91CDEF861619F0D70061B76E /* IFileChangeNotifier.h */,
919FE7011619F04600A269B6 /* Products */,
);
sourceTree = "<group>";
};
919FE7011619F04600A269B6 /* Products */ = {
isa = PBXGroup;
children = (
919FE7001619F04600A269B6 /* libRuntimeCompiler.a */,
);
name = Products;
sourceTree = "<group>";
};
91CDEF9E1619F0E30061B76E /* SimpleFileWatcher */ = {
isa = PBXGroup;
children = (
91CDEF881619F0D70061B76E /* FileWatcher.cpp */,
91CDEF891619F0D70061B76E /* FileWatcher.h */,
91CDEF8A1619F0D70061B76E /* FileWatcherImpl.h */,
91CDEF8B1619F0D70061B76E /* FileWatcherOSX.cpp */,
91CDEF8C1619F0D70061B76E /* FileWatcherOSX.h */,
);
name = SimpleFileWatcher;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
919FE6FE1619F04600A269B6 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
91CDEF8E1619F0D70061B76E /* BuildTool.h in Headers */,
91CDEF901619F0D70061B76E /* Compiler.h in Headers */,
91CDEF921619F0D70061B76E /* FileChangeNotifier.h in Headers */,
91CDEF951619F0D70061B76E /* ICompilerLogger.h in Headers */,
91CDEF961619F0D70061B76E /* IFileChangeNotifier.h in Headers */,
91CDEF991619F0D70061B76E /* FileWatcher.h in Headers */,
91CDEF9A1619F0D70061B76E /* FileWatcherImpl.h in Headers */,
91CDEF9C1619F0D70061B76E /* FileWatcherOSX.h in Headers */,
9106B90116AE8B9A003D2CD9 /* FileSystemUtils.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
919FE6FF1619F04600A269B6 /* RuntimeCompiler */ = {
isa = PBXNativeTarget;
buildConfigurationList = 919FE7041619F04600A269B6 /* Build configuration list for PBXNativeTarget "RuntimeCompiler" */;
buildPhases = (
919FE6FC1619F04600A269B6 /* Sources */,
919FE6FD1619F04600A269B6 /* Frameworks */,
919FE6FE1619F04600A269B6 /* Headers */,
);
buildRules = (
);
dependencies = (
);
name = RuntimeCompiler;
productName = RuntimeCompiler;
productReference = 919FE7001619F04600A269B6 /* libRuntimeCompiler.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
919FE6F71619F04600A269B6 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0440;
ORGANIZATIONNAME = "Doug Binks";
};
buildConfigurationList = 919FE6FA1619F04600A269B6 /* Build configuration list for PBXProject "RuntimeCompiler" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 919FE6F51619F04600A269B6;
productRefGroup = 919FE7011619F04600A269B6 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
919FE6FF1619F04600A269B6 /* RuntimeCompiler */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
919FE6FC1619F04600A269B6 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
91CDEF8D1619F0D70061B76E /* BuildTool.cpp in Sources */,
91CDEF911619F0D70061B76E /* FileChangeNotifier.cpp in Sources */,
91CDEF981619F0D70061B76E /* FileWatcher.cpp in Sources */,
91CDEF9B1619F0D70061B76E /* FileWatcherOSX.cpp in Sources */,
915C293416EB817400654B4E /* Compiler_PlatformPosix.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
919FE7021619F04600A269B6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = ../External/boost/;
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
919FE7031619F04600A269B6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = ../External/boost/;
MACOSX_DEPLOYMENT_TARGET = 10.8;
SDKROOT = macosx;
};
name = Release;
};
919FE7051619F04600A269B6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
EXECUTABLE_PREFIX = lib;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = "";
};
name = Debug;
};
919FE7061619F04600A269B6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
EXECUTABLE_PREFIX = lib;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = "";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
919FE6FA1619F04600A269B6 /* Build configuration list for PBXProject "RuntimeCompiler" */ = {
isa = XCConfigurationList;
buildConfigurations = (
919FE7021619F04600A269B6 /* Debug */,
919FE7031619F04600A269B6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
919FE7041619F04600A269B6 /* Build configuration list for PBXNativeTarget "RuntimeCompiler" */ = {
isa = XCConfigurationList;
buildConfigurations = (
919FE7051619F04600A269B6 /* Debug */,
919FE7061619F04600A269B6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 919FE6F71619F04600A269B6 /* Project object */;
}

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:RuntimeCompiler.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,164 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{790D95ED-C6E6-24E5-345B-37FB1E098082}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x86.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x64.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x86.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x64.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<ExceptionHandling>Async</ExceptionHandling>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<ExceptionHandling>Async</ExceptionHandling>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>
</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>
</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Compiler_PlatformPosix.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="FileChangeNotifier.cpp" />
<ClCompile Include="BuildTool.cpp" />
<ClCompile Include="Compiler_PlatformWindows.cpp" />
<ClCompile Include="SimpleFileWatcher\FileWatcher.cpp" />
<ClCompile Include="SimpleFileWatcher\FileWatcherLinux.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="SimpleFileWatcher\FileWatcherOSX.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="SimpleFileWatcher\FileWatcherWin32.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AUArray.h" />
<ClInclude Include="CompileOptions.h" />
<ClInclude Include="FileChangeNotifier.h" />
<ClInclude Include="BuildTool.h" />
<ClInclude Include="Compiler.h" />
<ClInclude Include="FileSystemUtils.h" />
<ClInclude Include="IFileChangeNotifier.h" />
<ClInclude Include="ICompilerLogger.h" />
<ClInclude Include="SimpleFileWatcher\FileWatcher.h" />
<ClInclude Include="SimpleFileWatcher\FileWatcherImpl.h" />
<ClInclude Include="SimpleFileWatcher\FileWatcherLinux.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="SimpleFileWatcher\FileWatcherOSX.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="SimpleFileWatcher\FileWatcherWin32.h" />
<ClInclude Include="SimpleFileWatcher\FileWatcherWin32_AltImpl.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="FileChangeNotifier.cpp" />
<ClCompile Include="BuildTool.cpp" />
<ClCompile Include="Compiler_PlatformWindows.cpp" />
<ClCompile Include="SimpleFileWatcher\FileWatcher.cpp">
<Filter>SimpleFileWatcher</Filter>
</ClCompile>
<ClCompile Include="SimpleFileWatcher\FileWatcherWin32.cpp">
<Filter>SimpleFileWatcher</Filter>
</ClCompile>
<ClCompile Include="Compiler_PlatformPosix.cpp" />
<ClCompile Include="SimpleFileWatcher\FileWatcherLinux.cpp">
<Filter>SimpleFileWatcher</Filter>
</ClCompile>
<ClCompile Include="SimpleFileWatcher\FileWatcherOSX.cpp">
<Filter>SimpleFileWatcher</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="FileChangeNotifier.h" />
<ClInclude Include="BuildTool.h" />
<ClInclude Include="Compiler.h" />
<ClInclude Include="IFileChangeNotifier.h" />
<ClInclude Include="ICompilerLogger.h" />
<ClInclude Include="SimpleFileWatcher\FileWatcher.h">
<Filter>SimpleFileWatcher</Filter>
</ClInclude>
<ClInclude Include="SimpleFileWatcher\FileWatcherImpl.h">
<Filter>SimpleFileWatcher</Filter>
</ClInclude>
<ClInclude Include="SimpleFileWatcher\FileWatcherWin32.h">
<Filter>SimpleFileWatcher</Filter>
</ClInclude>
<ClInclude Include="FileSystemUtils.h" />
<ClInclude Include="SimpleFileWatcher\FileWatcherWin32_AltImpl.h">
<Filter>SimpleFileWatcher</Filter>
</ClInclude>
<ClInclude Include="CompileOptions.h" />
<ClInclude Include="SimpleFileWatcher\FileWatcherLinux.h">
<Filter>SimpleFileWatcher</Filter>
</ClInclude>
<ClInclude Include="SimpleFileWatcher\FileWatcherOSX.h">
<Filter>SimpleFileWatcher</Filter>
</ClInclude>
<ClInclude Include="AUArray.h" />
</ItemGroup>
<ItemGroup>
<Filter Include="SimpleFileWatcher">
<UniqueIdentifier>{0baef244-e3d1-4bf8-b037-fb5e814ef3d4}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View File

@ -1,83 +0,0 @@
/**
Copyright (c) 2009 James Wynn (james@jameswynn.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "FileWatcher.h"
#include "FileWatcherImpl.h"
#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_WIN32
# include "FileWatcherWin32.h"
# define FILEWATCHER_IMPL FileWatcherWin32
#elif FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_KQUEUE
# include "FileWatcherOSX.h"
# define FILEWATCHER_IMPL FileWatcherOSX
#elif FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_LINUX
# include "FileWatcherLinux.h"
# define FILEWATCHER_IMPL FileWatcherLinux
#endif
namespace FW
{
//--------
FileWatcher::FileWatcher()
{
mImpl = new FILEWATCHER_IMPL();
}
//--------
FileWatcher::~FileWatcher()
{
delete mImpl;
mImpl = 0;
}
//--------
WatchID FileWatcher::addWatch(const String& directory, FileWatchListener* watcher)
{
return mImpl->addWatch(directory, watcher, false);
}
//--------
WatchID FileWatcher::addWatch(const String& directory, FileWatchListener* watcher, bool recursive)
{
return mImpl->addWatch(directory, watcher, recursive);
}
//--------
void FileWatcher::removeWatch(const String& directory)
{
mImpl->removeWatch(directory);
}
//--------
void FileWatcher::removeWatch(WatchID watchid)
{
mImpl->removeWatch(watchid);
}
//--------
void FileWatcher::update()
{
mImpl->update();
}
};//namespace FW

View File

@ -1,123 +0,0 @@
/**
Main header for the FileWatcher class. Declares all implementation
classes to reduce compilation overhead.
@author James Wynn
@date 4/15/2009
Copyright (c) 2009 James Wynn (james@jameswynn.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _FW_FILEWATCHER_H_
#define _FW_FILEWATCHER_H_
#pragma once
#include <string>
#include <stdexcept>
#include "../FileSystemUtils.h"
namespace FW
{
/// Type for a string
typedef FileSystemUtils::Path String;
/// Type for a watch id
typedef unsigned long WatchID;
// forward declarations
class FileWatcherImpl;
class FileWatchListener;
/// Actions to listen for. Rename will send two events, one for
/// the deletion of the old file, and one for the creation of the
/// new file.
namespace Actions
{
enum Action
{
/// Sent when a file is created or renamed
Add = 1,
/// Sent when a file is deleted or renamed
Delete = 2,
/// Sent when a file is modified
Modified = 4
};
};
typedef Actions::Action Action;
/// Listens to files and directories and dispatches events
/// to notify the parent program of the changes.
/// @class FileWatcher
class FileWatcher
{
public:
///
///
FileWatcher();
///
///
virtual ~FileWatcher();
/// Add a directory watch. Same as the other addWatch, but doesn't have recursive option.
/// For backwards compatibility.
WatchID addWatch(const String& directory, FileWatchListener* watcher);
/// Add a directory watch
WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive);
/// Remove a directory watch. This is a brute force search O(nlogn).
void removeWatch(const String& directory);
/// Remove a directory watch. This is a map lookup O(logn).
void removeWatch(WatchID watchid);
/// Updates the watcher. Must be called often.
void update();
private:
/// The implementation
FileWatcherImpl* mImpl;
};//end FileWatcher
/// Basic interface for listening for file events.
/// @class FileWatchListener
class FileWatchListener
{
public:
FileWatchListener() {}
virtual ~FileWatchListener() {}
/// Handles the action file action
/// @param watchid The watch id for the directory
/// @param dir The directory
/// @param filename The filename that was accessed (not full path)
/// @param action Action that was performed
virtual void handleFileAction(WatchID watchid, const String& dir, const String& filename, Action action) = 0;
};//class FileWatchListener
};//namespace FW
#endif//_FW_FILEWATCHER_H_

View File

@ -1,78 +0,0 @@
/**
Basic interface for the FileWatcher backend.
@author James Wynn
@date 5/11/2009
Copyright (c) 2009 James Wynn (james@jameswynn.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _FW_FILEWATCHERIMPL_H_
#define _FW_FILEWATCHERIMPL_H_
#pragma once
#include "FileWatcher.h"
#define FILEWATCHER_PLATFORM_WIN32 1
#define FILEWATCHER_PLATFORM_LINUX 2
#define FILEWATCHER_PLATFORM_KQUEUE 3
#if defined(_WIN32)
# define FILEWATCHER_PLATFORM FILEWATCHER_PLATFORM_WIN32
#elif defined(__APPLE_CC__) || defined(BSD)
# define FILEWATCHER_PLATFORM FILEWATCHER_PLATFORM_KQUEUE
#elif defined(__linux__)
# define FILEWATCHER_PLATFORM FILEWATCHER_PLATFORM_LINUX
#endif
namespace FW
{
struct WatchStruct;
class FileWatcherImpl
{
public:
///
///
FileWatcherImpl() {}
///
///
virtual ~FileWatcherImpl() {}
/// Add a directory watch
virtual WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive) = 0;
/// Remove a directory watch. This is a brute force lazy search O(nlogn).
virtual void removeWatch(const String& directory) = 0;
/// Remove a directory watch. This is a map lookup O(logn).
virtual void removeWatch(WatchID watchid) = 0;
/// Updates the watcher. Must be called often.
virtual void update() = 0;
/// Handles the action
virtual void handleAction(WatchStruct* watch, const String& filename, unsigned long action) = 0;
};//end FileWatcherImpl
};//namespace FW
#endif//_FW_FILEWATCHERIMPL_H_

View File

@ -1,176 +0,0 @@
/**
Copyright (c) 2009 James Wynn (james@jameswynn.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
James Wynn james@jameswynn.com
*/
#include "FileWatcherLinux.h"
#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_LINUX
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sys/inotify.h>
#define BUFF_SIZE ((sizeof(struct inotify_event)+FILENAME_MAX)*1024)
namespace FW
{
struct WatchStruct
{
WatchID mWatchID;
String mDirName;
FileWatchListener* mListener;
};
//--------
FileWatcherLinux::FileWatcherLinux()
{
mFD = inotify_init();
if (mFD < 0)
fprintf (stderr, "Error: %s\n", strerror(errno));
mTimeOut.tv_sec = 0;
mTimeOut.tv_usec = 0;
FD_ZERO(&mDescriptorSet);
}
//--------
FileWatcherLinux::~FileWatcherLinux()
{
WatchMap::iterator iter = mWatches.begin();
WatchMap::iterator end = mWatches.end();
for(; iter != end; ++iter)
{
delete iter->second;
}
mWatches.clear();
}
//--------
WatchID FileWatcherLinux::addWatch(const String& directory, FileWatchListener* watcher, bool recursive)
{
const char* pDir = directory.c_str();
int wd = inotify_add_watch (mFD, pDir,
IN_CLOSE_WRITE | IN_MOVED_TO | IN_CREATE | IN_MOVED_FROM | IN_DELETE | IN_MODIFY | IN_ATTRIB );
WatchStruct* pWatch = new WatchStruct();
pWatch->mListener = watcher;
pWatch->mWatchID = wd;
pWatch->mDirName = directory;
mWatches.insert(std::make_pair(wd, pWatch));
return wd;
}
//--------
void FileWatcherLinux::removeWatch(const String& directory)
{
WatchMap::iterator iter = mWatches.begin();
WatchMap::iterator end = mWatches.end();
for(; iter != end; ++iter)
{
if(directory == iter->second->mDirName)
{
removeWatch(iter->first);
return;
}
}
}
//--------
void FileWatcherLinux::removeWatch(WatchID watchid)
{
WatchMap::iterator iter = mWatches.find(watchid);
if(iter == mWatches.end())
return;
WatchStruct* watch = iter->second;
mWatches.erase(iter);
inotify_rm_watch(mFD, watchid);
delete watch;
watch = 0;
}
//--------
void FileWatcherLinux::update()
{
FD_SET(mFD, &mDescriptorSet);
int ret = select(mFD + 1, &mDescriptorSet, NULL, NULL, &mTimeOut);
if(ret < 0)
{
perror("select");
}
else if(FD_ISSET(mFD, &mDescriptorSet))
{
ssize_t len, i = 0;
//char action[81+FILENAME_MAX] = {0};
char buff[BUFF_SIZE] = {0};
len = read (mFD, buff, BUFF_SIZE);
while (i < len)
{
struct inotify_event *pevent = (struct inotify_event *)&buff[i];
WatchStruct* watch = mWatches[pevent->wd];
handleAction(watch, pevent->name, pevent->mask);
i += sizeof(struct inotify_event) + pevent->len;
}
}
}
//--------
void FileWatcherLinux::handleAction(WatchStruct* watch, const String& filename, unsigned long action)
{
if(!watch->mListener)
return;
if( (IN_CLOSE_WRITE & action) || (IN_MODIFY & action) || ( IN_ATTRIB & action ) )
{
watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename,
Actions::Modified);
}
if( ( IN_MOVED_TO & action ) || ( IN_CREATE & action ) )
{
watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename,
Actions::Add);
}
if(( IN_MOVED_FROM & action ) || ( IN_DELETE & action ) )
{
watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename,
Actions::Delete);
}
}
};//namespace FW
#endif//FILEWATCHER_PLATFORM_LINUX

View File

@ -1,176 +0,0 @@
/**
Copyright (c) 2009 James Wynn (james@jameswynn.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
James Wynn james@jameswynn.com
*/
#include "FileWatcherLinux.h"
#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_LINUX
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sys/inotify.h>
#define BUFF_SIZE ((sizeof(struct inotify_event)+FILENAME_MAX)*1024)
namespace FW
{
struct WatchStruct
{
WatchID mWatchID;
String mDirName;
FileWatchListener* mListener;
};
//--------
FileWatcherLinux::FileWatcherLinux()
{
mFD = inotify_init();
if (mFD < 0)
fprintf (stderr, "Error: %s\n", strerror(errno));
mTimeOut.tv_sec = 0;
mTimeOut.tv_usec = 0;
FD_ZERO(&mDescriptorSet);
}
//--------
FileWatcherLinux::~FileWatcherLinux()
{
WatchMap::iterator iter = mWatches.begin();
WatchMap::iterator end = mWatches.end();
for(; iter != end; ++iter)
{
delete iter->second;
}
mWatches.clear();
}
//--------
WatchID FileWatcherLinux::addWatch(const String& directory, FileWatchListener* watcher, bool recursive)
{
const char* pDir = directory.c_str();
int wd = inotify_add_watch (mFD, pDir,
IN_CLOSE_WRITE | IN_MOVED_TO | IN_CREATE | IN_MOVED_FROM | IN_DELETE | IN_MODIFY | IN_ATTRIB );
WatchStruct* pWatch = new WatchStruct();
pWatch->mListener = watcher;
pWatch->mWatchID = wd;
pWatch->mDirName = directory;
mWatches.insert(std::make_pair(wd, pWatch));
return wd;
}
//--------
void FileWatcherLinux::removeWatch(const String& directory)
{
WatchMap::iterator iter = mWatches.begin();
WatchMap::iterator end = mWatches.end();
for(; iter != end; ++iter)
{
if(directory == iter->second->mDirName)
{
removeWatch(iter->first);
return;
}
}
}
//--------
void FileWatcherLinux::removeWatch(WatchID watchid)
{
WatchMap::iterator iter = mWatches.find(watchid);
if(iter == mWatches.end())
return;
WatchStruct* watch = iter->second;
mWatches.erase(iter);
inotify_rm_watch(mFD, watchid);
delete watch;
watch = 0;
}
//--------
void FileWatcherLinux::update()
{
FD_SET(mFD, &mDescriptorSet);
int ret = select(mFD + 1, &mDescriptorSet, NULL, NULL, &mTimeOut);
if(ret < 0)
{
perror("select");
}
else if(FD_ISSET(mFD, &mDescriptorSet))
{
ssize_t len, i = 0;
//char action[81+FILENAME_MAX] = {0};
char buff[BUFF_SIZE] = {0};
len = read (mFD, buff, BUFF_SIZE);
while (i < len)
{
struct inotify_event *pevent = (struct inotify_event *)&buff[i];
WatchStruct* watch = mWatches[pevent->wd];
handleAction(watch, pevent->name, pevent->mask);
i += sizeof(struct inotify_event) + pevent->len;
}
}
}
//--------
void FileWatcherLinux::handleAction(WatchStruct* watch, const String& filename, unsigned long action)
{
if(!watch->mListener)
return;
if( (IN_CLOSE_WRITE & action) || (IN_MODIFY & action) )
{
watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename,
Actions::Modified);
}
if( ( IN_MOVED_TO & action ) || ( IN_CREATE & action ) )
{
watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename,
Actions::Add);
}
if(( IN_MOVED_FROM & action ) || ( IN_DELETE & action ) )
{
watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename,
Actions::Delete);
}
}
};//namespace FW
#endif//FILEWATCHER_PLATFORM_LINUX

View File

@ -1,91 +0,0 @@
/**
Implementation header file for Linux based on inotify.
@author James Wynn
@date 4/15/2009
Copyright (c) 2009 James Wynn (james@jameswynn.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _FW_FILEWATCHERLINUX_H_
#define _FW_FILEWATCHERLINUX_H_
#pragma once
#include "FileWatcherImpl.h"
#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_LINUX
#include <map>
#include <sys/types.h>
namespace FW
{
/// Implementation for Linux based on inotify.
/// @class FileWatcherLinux
class FileWatcherLinux : public FileWatcherImpl
{
public:
/// type for a map from WatchID to WatchStruct pointer
typedef std::map<WatchID, WatchStruct*> WatchMap;
public:
///
///
FileWatcherLinux();
///
///
virtual ~FileWatcherLinux();
/// Add a directory watch
/// @exception FileNotFoundException Thrown when the requested directory does not exist
WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive);
/// Remove a directory watch. This is a brute force lazy search O(nlogn).
void removeWatch(const String& directory);
/// Remove a directory watch. This is a map lookup O(logn).
void removeWatch(WatchID watchid);
/// Updates the watcher. Must be called often.
void update();
/// Handles the action
void handleAction(WatchStruct* watch, const String& filename, unsigned long action);
private:
/// Map of WatchID to WatchStruct pointers
WatchMap mWatches;
/// The last watchid
WatchID mLastWatchID;
/// inotify file descriptor
int mFD;
/// time out data
struct timeval mTimeOut;
/// File descriptor set
fd_set mDescriptorSet;
};//end FileWatcherLinux
};//namespace FW
#endif//FILEWATCHER_PLATFORM_LINUX
#endif//_FW_FILEWATCHERLINUX_H_

View File

@ -1,400 +0,0 @@
/**
Copyright (c) 2009 James Wynn (james@jameswynn.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
James Wynn james@jameswynn.com
*/
/**
Major changes Doug Binks
**/
#include "FileWatcherOSX.h"
#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_KQUEUE
#include <sys/event.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>
#include <assert.h>
namespace FW
{
#define MAX_FILELIST_SIZE 2048
typedef struct kevent KEvent;
struct FileInfo
{
FileInfo()
: mFilename(0), mModifiedTime(0)
{
}
const char* mFilename;
time_t mModifiedTime;
};
int comparator(const void* f1, const void* f2)
{
FileInfo* finfo1 = (FileInfo*)f1;
FileInfo* finfo2 = (FileInfo*)f2;
int retVal = strcmp(finfo1->mFilename, finfo2->mFilename);
return retVal;
}
struct WatchStruct
{
WatchID mWatchID;
String mDirName;
FileWatchListener* mListener;
KEvent mDirKevent;
FileInfo mFileList[MAX_FILELIST_SIZE];
size_t mFileListCount;
WatchStruct(WatchID watchid, const String& dirname, FileWatchListener* listener)
: mWatchID(watchid), mDirName(dirname), mListener(listener), mFileListCount( 0 )
{
addAll(true);
}
~WatchStruct()
{
removeAll();
}
void addFile(const std::string& name)
{
// create entry in file list
struct stat attrib;
stat(name.c_str(), &attrib);
char* namecopy = new char[name.length() + 1];
strncpy(namecopy, name.c_str(), name.length());
namecopy[name.length()] = 0;
mFileList[mFileListCount].mFilename = namecopy;
mFileList[mFileListCount].mModifiedTime = attrib.st_mtime;
++mFileListCount;
}
void removeFile(const std::string& name)
{
// bsearch
FileInfo key;
key.mFilename = name.c_str();
FileInfo* found = (FileInfo*)bsearch(&key, &mFileList, mFileListCount, sizeof(FileInfo), comparator);
if(!found)
{
return;
}
key.mFilename = 0; // prevent deletion of key string
delete found->mFilename;
found->mFilename = 0;
assert( mFileListCount > 1 );
// move end to current
memcpy(found, &mFileList[mFileListCount-1], sizeof(FileInfo));
memset(&mFileList[mFileListCount-1], 0, sizeof(FileInfo));
--mFileListCount;
}
// called when the directory is actually changed
// means a file has been added or removed
// rescans the watched directory adding/removing files and sending notices
void rescan()
{
// if new file, call addFile
// if missing file, call removeFile
// if timestamp modified, call handleAction(filename, ACTION_MODIFIED);
DIR* dir = opendir(mDirName.c_str());
if(!dir)
return;
struct dirent* dentry;
size_t fileIndex = 0;
struct stat attrib;
bool bRescanRequired = false; //if files are added or deleted we need a rescan.
while((dentry = readdir(dir)) != NULL)
{
std::string fname = mDirName.m_string + "/" + dentry->d_name;
stat(fname.c_str(), &attrib);
if(!S_ISREG(attrib.st_mode))
continue;
if( fileIndex < mFileListCount )
{
FileInfo& entry = mFileList[fileIndex];
int result = strcmp(entry.mFilename, fname.c_str());
if(result == 0)
{
stat(entry.mFilename, &attrib);
time_t timestamp = attrib.st_mtime;
if(entry.mModifiedTime != timestamp)
{
entry.mModifiedTime = timestamp;
handleAction(entry.mFilename, Actions::Modified);
}
++fileIndex;
}
else
{
// file might have been added or deleted
// if we find the file in our list, then we have some deletions up to that point
// otherwise we have an add
bRescanRequired = true;
size_t currFile = fileIndex+1;
while( currFile < mFileListCount )
{
FileInfo& entry = mFileList[currFile];
int res = strcmp(entry.mFilename, fname.c_str());
if(res == 0)
{
//have found the file in our list
break;
}
++currFile;
}
//process events but don't add/remove to list.
if( currFile < mFileListCount )
{
//have some deletions.
while( fileIndex < currFile )
{
FileInfo& entry = mFileList[currFile];
handleAction(entry.mFilename, Actions::Delete);
++fileIndex;
}
++fileIndex;
}
else
{
//we don't increment fileIndex here as it's an add in the middle.
handleAction(fname.c_str(), Actions::Add);
}
}
}
else
{
// just add
addFile(fname);
handleAction(fname.c_str(), Actions::Add);
++fileIndex;
}
}//end while
closedir(dir);
while( fileIndex < mFileListCount )
{
// the last files have been deleted...
bRescanRequired = true;
FileInfo& entry = mFileList[fileIndex];
handleAction(entry.mFilename, Actions::Delete);
++fileIndex;
}
if( bRescanRequired )
{
removeAll();
addAll(false);
}
};
void handleAction(const String& filename, FW::Action action)
{
mListener->handleFileAction(mWatchID, mDirName, filename, action);
}
void addAll( bool bCreatedirevent )
{
if( bCreatedirevent )
{
// add base dir
int fd = open(mDirName.c_str(), O_RDONLY);
EV_SET(&mDirKevent, fd, EVFILT_VNODE,
EV_ADD | EV_ENABLE | EV_CLEAR,
NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB | NOTE_RENAME | NOTE_REVOKE,
0, 0);
}
//fprintf(stderr, "ADDED: %s\n", mDirName.c_str());
// scan directory and call addFile(name, false) on each file
DIR* dir = opendir(mDirName.c_str());
if(!dir)
return;
struct dirent* entry;
struct stat attrib;
while((entry = readdir(dir)) != NULL)
{
std::string fname = (mDirName.m_string + "/" + std::string(entry->d_name));
stat(fname.c_str(), &attrib);
if(S_ISREG(attrib.st_mode))
addFile(fname);
//else
// fprintf(stderr, "NOT ADDED: %s (%d)\n", fname.c_str(), attrib.st_mode);
}//end while
closedir(dir);
}
void removeAll()
{
// go through list removing each file but not the directory
for(int i = 0; i < mFileListCount; ++i)
{
FileInfo& entry = mFileList[i];
// delete
delete[] entry.mFilename;
entry.mModifiedTime = 0;
}
mFileListCount = 0;
}
};
void FileWatcherOSX::update()
{
int nev = 0;
struct kevent event;
// DJB updated code to handle multiple directories correctly
// first look for events which have occurred in our queue
while((nev = kevent(mDescriptor, 0, 0, &event, 1, &mTimeOut)) != 0)
{
if(nev == -1)
perror("kevent");
else
{
// have an event, need to find the watch which has this event
WatchMap::iterator iter = mWatches.begin();
WatchMap::iterator end = mWatches.end();
for(; iter != end; ++iter)
{
WatchStruct* watch = iter->second;
if( event.ident == watch->mDirKevent.ident )
{
watch->rescan();
break;
}
}
}
}
}
//--------
FileWatcherOSX::FileWatcherOSX()
{
mDescriptor = kqueue();
mTimeOut.tv_sec = 0;
mTimeOut.tv_nsec = 0;
}
//--------
FileWatcherOSX::~FileWatcherOSX()
{
WatchMap::iterator iter = mWatches.begin();
WatchMap::iterator end = mWatches.end();
for(; iter != end; ++iter)
{
delete iter->second;
}
mWatches.clear();
close(mDescriptor);
}
//--------
WatchID FileWatcherOSX::addWatch(const String& directory, FileWatchListener* watcher, bool recursive)
{
/* int fd = open(directory.c_str(), O_RDONLY);
if(fd == -1)
perror("open");
EV_SET(&change, fd, EVFILT_VNODE,
EV_ADD | EV_ENABLE | EV_ONESHOT,
NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB,
0, (void*)"testing");
*/
WatchStruct* watch = new WatchStruct(++mLastWatchID, directory, watcher);
mWatches.insert(std::make_pair(mLastWatchID, watch));
// DJB we add the event to our kqueue (but don't request any return events, these are looked for in update loop
kevent(mDescriptor, (KEvent*)&(watch->mDirKevent), 1, 0, 0, 0);
return mLastWatchID;
}
//--------
void FileWatcherOSX::removeWatch(const String& directory)
{
WatchMap::iterator iter = mWatches.begin();
WatchMap::iterator end = mWatches.end();
for(; iter != end; ++iter)
{
if(directory == iter->second->mDirName)
{
removeWatch(iter->first);
return;
}
}
}
//--------
void FileWatcherOSX::removeWatch(WatchID watchid)
{
WatchMap::iterator iter = mWatches.find(watchid);
if(iter == mWatches.end())
return;
WatchStruct* watch = iter->second;
mWatches.erase(iter);
//inotify_rm_watch(mFD, watchid);
delete watch; // Note: this also removes the event for the watch from the queue
watch = 0;
}
//--------
void FileWatcherOSX::handleAction(WatchStruct* watch, const String& filename, unsigned long action)
{
assert(false);//should not get here for OSX impl
}
};//namespace FW
#endif//FILEWATCHER_PLATFORM_KQUEUE

View File

@ -1,88 +0,0 @@
/**
Implementation header file for OSX based on KEvent.
@author James Wynn
@date 4/15/2009
Copyright (c) 2009 James Wynn (james@jameswynn.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _FW_FILEWATCHEROSX_H_
#define _FW_FILEWATCHEROSX_H_
#pragma once
#include "FileWatcherImpl.h"
#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_KQUEUE
#include <map>
#include <sys/types.h>
namespace FW
{
/// Implementation for OSX based on kqueue.
/// @class FileWatcherOSX
class FileWatcherOSX : public FileWatcherImpl
{
public:
/// type for a map from WatchID to WatchStruct pointer
typedef std::map<WatchID, WatchStruct*> WatchMap;
public:
///
///
FileWatcherOSX();
///
///
virtual ~FileWatcherOSX();
/// Add a directory watch
WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive);
/// Remove a directory watch. This is a brute force lazy search O(nlogn).
void removeWatch(const String& directory);
/// Remove a directory watch. This is a map lookup O(logn).
void removeWatch(WatchID watchid);
/// Updates the watcher. Must be called often.
void update();
/// Handles the action
void handleAction(WatchStruct* watch, const String& filename, unsigned long action);
private:
/// Map of WatchID to WatchStruct pointers
WatchMap mWatches;
/// The descriptor for the kqueue
int mDescriptor;
/// time out data
struct timespec mTimeOut;
/// WatchID allocator
int mLastWatchID;
};//end FileWatcherOSX
};//namespace FW
#endif//__APPLE_CC__
#endif//_FW_FILEWATCHEROSX_H_

View File

@ -1,361 +0,0 @@
/**
Copyright (c) 2009 James Wynn (james@jameswynn.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "FileWatcherWin32.h"
#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_WIN32
#include <windows.h>
#if defined(_MSC_VER)
#pragma comment(lib, "comctl32.lib")
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "ole32.lib")
// disable secure warnings
#pragma warning (disable: 4996)
#endif
namespace FW
{
/// Internal watch data
struct WatchStruct
{
OVERLAPPED mOverlapped;
HANDLE mDirHandle;
BYTE mBuffer[32 * 1024];
LPARAM lParam;
DWORD mNotifyFilter;
bool mStopNow;
FileWatcherImpl* mFileWatcher;
FileWatchListener* mFileWatchListener;
char* mDirName;
WatchID mWatchid;
bool mIsRecursive;
};
#pragma region Internal Functions
// forward decl
bool RefreshWatch(WatchStruct* pWatch, bool _clear = false);
/// Unpacks events and passes them to a user defined callback.
void CALLBACK WatchCallback(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped)
{
#ifndef WIN32_FW_USE_FINDFIRST_API
char szFile[MAX_PATH];
PFILE_NOTIFY_INFORMATION pNotify;
WatchStruct* pWatch = (WatchStruct*) lpOverlapped;
size_t offset = 0;
if(dwNumberOfBytesTransfered == 0)
return;
if (dwErrorCode == ERROR_SUCCESS)
{
do
{
pNotify = (PFILE_NOTIFY_INFORMATION) &pWatch->mBuffer[offset];
offset += pNotify->NextEntryOffset;
int count = WideCharToMultiByte(CP_ACP, 0, pNotify->FileName,
pNotify->FileNameLength / sizeof(WCHAR),
szFile, MAX_PATH - 1, NULL, NULL);
szFile[count] = TEXT('\0');
pWatch->mFileWatcher->handleAction(pWatch, szFile, pNotify->Action);
} while (pNotify->NextEntryOffset != 0);
}
if (!pWatch->mStopNow)
{
RefreshWatch(pWatch);
}
#endif
}
/// Refreshes the directory monitoring.
bool RefreshWatch(WatchStruct* pWatch, bool _clear)
{
#ifndef WIN32_FW_USE_FINDFIRST_API
return ReadDirectoryChangesW(
pWatch->mDirHandle, pWatch->mBuffer, sizeof(pWatch->mBuffer), pWatch->mIsRecursive,
pWatch->mNotifyFilter, NULL, &pWatch->mOverlapped, _clear ? 0 : WatchCallback) != 0;
#else
return true;
#endif
}
/// Stops monitoring a directory.
void DestroyWatch(WatchStruct* pWatch)
{
if (pWatch)
{
pWatch->mStopNow = TRUE;
#ifndef WIN32_FW_USE_FINDFIRST_API
CancelIo(pWatch->mDirHandle);
RefreshWatch(pWatch, true);
if (!HasOverlappedIoCompleted(&pWatch->mOverlapped))
{
SleepEx(5, TRUE);
}
CloseHandle(pWatch->mOverlapped.hEvent);
CloseHandle(pWatch->mDirHandle);
#endif
delete[] pWatch->mDirName;
HeapFree(GetProcessHeap(), 0, pWatch);
}
}
/// Starts monitoring a directory.
WatchStruct* CreateWatch(const char* szDirectory, bool recursive, DWORD mNotifyFilter)
{
WatchStruct* pWatch;
size_t ptrsize = sizeof(*pWatch);
pWatch = static_cast<WatchStruct*>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ptrsize));
#ifndef WIN32_FW_USE_FINDFIRST_API
pWatch->mDirHandle = CreateFileA(szDirectory, FILE_LIST_DIRECTORY,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL);
if (pWatch->mDirHandle != INVALID_HANDLE_VALUE)
{
pWatch->mOverlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
pWatch->mNotifyFilter = mNotifyFilter;
pWatch->mIsRecursive = recursive;
if (RefreshWatch(pWatch))
{
return pWatch;
}
else
{
CloseHandle(pWatch->mOverlapped.hEvent);
CloseHandle(pWatch->mDirHandle);
}
}
HeapFree(GetProcessHeap(), 0, pWatch);
return NULL;
#else
return pWatch;
#endif
}
#pragma endregion
//--------
FileWatcherWin32::FileWatcherWin32()
: mLastWatchID(0)
{
}
//--------
FileWatcherWin32::~FileWatcherWin32()
{
WatchMap::iterator iter = mWatches.begin();
WatchMap::iterator end = mWatches.end();
for(; iter != end; ++iter)
{
DestroyWatch(iter->second);
}
mWatches.clear();
}
//--------
WatchID FileWatcherWin32::addWatch(const String& directory, FileWatchListener* watcher, bool recursive)
{
WatchStruct* watch = CreateWatch(directory.c_str(), recursive,
FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_FILE_NAME);
#ifdef WIN32_FW_USE_FINDFIRST_API
WatchID watchid = (unsigned long)fw.add( directory.m_string );
#else
WatchID watchid = ++mLastWatchID;
#endif
if(watch)
{
watch->mWatchid = watchid;
watch->mFileWatcher = this;
watch->mFileWatchListener = watcher;
watch->mDirName = new char[directory.m_string.length()+1];
strcpy(watch->mDirName, directory.c_str());
}
mWatches.insert(std::make_pair(watchid, watch));
return watchid;
}
//--------
void FileWatcherWin32::removeWatch(const String& directory)
{
WatchMap::iterator iter = mWatches.begin();
WatchMap::iterator end = mWatches.end();
for(; iter != end; ++iter)
{
if(directory == iter->second->mDirName)
{
removeWatch(iter->first);
return;
}
}
}
//--------
void FileWatcherWin32::removeWatch(WatchID watchid)
{
WatchMap::iterator iter = mWatches.find(watchid);
if(iter == mWatches.end())
return;
WatchStruct* watch = iter->second;
#ifdef WIN32_FW_USE_FINDFIRST_API
fw.remove(watch->mWatchid);
#endif
mWatches.erase(iter);
DestroyWatch(watch);
}
//--------
void FileWatcherWin32::update()
{
#ifndef WIN32_FW_USE_FINDFIRST_API
MsgWaitForMultipleObjectsEx(0, NULL, 0, QS_ALLINPUT, MWMO_ALERTABLE);
#endif
#ifdef WIN32_FW_USE_FINDFIRST_API
static std::vector<FileWatcherWin32_AltImpl::fw_event> events;
events.clear();
fw.watch(events);
for( size_t c = 0; c != events.size(); ++c )
{
WatchMap::iterator iter = mWatches.find(events[c].id);
if(iter == mWatches.end())
continue;
switch(events[c].ty)
{
case FileWatcherWin32_AltImpl::CHANGE_SIZE:
{
std::string old_name;
DWORD fni;
std::string new_name = fw.get_event_filename( iter->second->mDirName, events[c].id, events[c].ty, fni, old_name );
if( !new_name.empty() )
{
handleAction(iter->second, new_name.c_str(), fni );
}
break;
}
case FileWatcherWin32_AltImpl::CHANGE_FILE_NAME:
{
std::string old_name;
DWORD fni;
std::string new_name = fw.get_event_filename( iter->second->mDirName, events[c].id, events[c].ty, fni, old_name );
if( !new_name.empty() )
{
//changed from-to
if( !old_name.empty() )
{
handleAction(iter->second, old_name.c_str(), FILE_ACTION_RENAMED_OLD_NAME );
handleAction(iter->second, new_name.c_str(), FILE_ACTION_RENAMED_NEW_NAME );
}
else
{
handleAction(iter->second, new_name.c_str(), fni );
}
}
break;
}
case FileWatcherWin32_AltImpl::CHANGE_LAST_WRITE:
case FileWatcherWin32_AltImpl::CHANGE_CREATION:
{
std::string old_name;
DWORD fni;
std::string new_name = fw.get_event_filename( iter->second->mDirName, events[c].id, events[c].ty, fni, old_name );
if( !new_name.empty() )
{
handleAction(iter->second, new_name.c_str(), fni );
}
break;
}
default:
break;
}
}
#endif
}
//--------
void FileWatcherWin32::handleAction(WatchStruct* watch, const String& filename, unsigned long action)
{
Action fwAction;
switch(action)
{
case FILE_ACTION_RENAMED_NEW_NAME:
case FILE_ACTION_ADDED:
fwAction = Actions::Add;
break;
case FILE_ACTION_RENAMED_OLD_NAME:
case FILE_ACTION_REMOVED:
fwAction = Actions::Delete;
break;
case FILE_ACTION_MODIFIED:
fwAction = Actions::Modified;
break;
};
watch->mFileWatchListener->handleFileAction(watch->mWatchid, watch->mDirName, filename, fwAction);
}
};//namespace FW
#endif//_WIN32

View File

@ -1,98 +0,0 @@
/**
Implementation for Windows. Uses ReadDirectoryChangesW to watch for
file system changes.
@author James Wynn
@date 4/15/2009
Copyright (c) 2009 James Wynn (james@jameswynn.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _FW_FILEWATCHERWIN32_H_
#define _FW_FILEWATCHERWIN32_H_
#pragma once
#include "FileWatcherImpl.h"
#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_WIN32
// Uncomment define below or include in build options to use FindFirstChangeNotification
// rather than ReadDirectoryChanges
// #define WIN32_FW_USE_FINDFIRST_API
#ifdef WIN32_FW_USE_FINDFIRST_API
#include "FileWatcherWin32_AltImpl.h"
#endif
#include <map>
namespace FW
{
/// Implementation for Win32 based on ReadDirectoryChangesW.
/// @class FileWatcherWin32
class FileWatcherWin32 : public FileWatcherImpl
{
public:
/// type for a map from WatchID to WatchStruct pointer
typedef std::map<WatchID, WatchStruct*> WatchMap;
public:
///
///
FileWatcherWin32();
///
///
virtual ~FileWatcherWin32();
/// Add a directory watch
WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive);
/// Remove a directory watch. This is a brute force lazy search O(nlogn).
void removeWatch(const String& directory);
/// Remove a directory watch. This is a map lookup O(logn).
void removeWatch(WatchID watchid);
/// Updates the watcher. Must be called often.
void update();
/// Handles the action
void handleAction(WatchStruct* watch, const String& filename, unsigned long action);
private:
/// Map of WatchID to WatchStruct pointers
WatchMap mWatches;
/// The last watchid
WatchID mLastWatchID;
#ifdef WIN32_FW_USE_FINDFIRST_API
FileWatcherWin32_AltImpl fw;
#endif
};//end FileWatcherWin32
};//namespace FW
#endif//FILEWATCHER_PLATFORM_WIN32
#endif//_FW_FILEWATCHERWIN32_H_

View File

@ -1,367 +0,0 @@
//
// Copyright (c) 2013 Márton Tamás
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
// Minor modifications by Doug Binks
// This implementation for FileWatcherWin32 uses FindFirstChangeNotification rather
// than ReadDirectoryChanges
#ifndef _FileWatcherWin32_AltImpl_h_
#define _FileWatcherWin32_AltImpl_h_
#pragma once
#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_WIN32
#include <iostream>
#include <vector>
#include <string>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
namespace FW
{
const static int fw_types[] = { FILE_NOTIFY_CHANGE_LAST_WRITE, FILE_NOTIFY_CHANGE_CREATION, FILE_NOTIFY_CHANGE_SIZE, FILE_NOTIFY_CHANGE_FILE_NAME };
const static size_t NUMTYPES = sizeof(fw_types)/sizeof(int);
class FileWatcherWin32_AltImpl
{
struct filedata
{
std::string fname;
LARGE_INTEGER fsize;
FILETIME ftime;
FILETIME fwritetime;
filedata( std::string n = std::string(), LARGE_INTEGER s = LARGE_INTEGER(), FILETIME t = FILETIME(), FILETIME tw = FILETIME())
{
fname = n;
fsize = s;
ftime = t;
fwritetime = tw;
}
};
std::vector< HANDLE > handles[NUMTYPES];
std::vector< std::vector< filedata > > dir_contents;
void get_dir_contents( const std::string& path, std::vector< filedata >& contents )
{
WIN32_FIND_DATAA fd;
HANDLE dir_lister = FindFirstFileA( (path + "\\*").c_str(), &fd );
if( dir_lister == INVALID_HANDLE_VALUE )
{
std::cout << "Couldn't list files." << std::endl;
return;
}
do
{
if( !(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
LARGE_INTEGER fsize;
fsize.LowPart = fd.nFileSizeLow;
fsize.HighPart = fd.nFileSizeHigh;
FILETIME ftime;
ftime = fd.ftCreationTime;
FILETIME fwritetime;
fwritetime = fd.ftLastWriteTime;
contents.push_back(filedata( fd.cFileName, fsize, ftime, fwritetime ));
}
}
while(FindNextFileA(dir_lister, &fd) != 0);
FindClose(dir_lister);
}
public:
~FileWatcherWin32_AltImpl()
{
for( int c = 0; c < NUMTYPES; ++c )
{
for( size_t d = 0; d != handles[c].size(); ++d )
{
FindCloseChangeNotification(handles[c][d]);
}
}
}
enum type
{
CHANGE_LAST_WRITE = 0, CHANGE_CREATION, CHANGE_SIZE, CHANGE_FILE_NAME, CHANGE_NONE
};
struct fw_event
{
size_t id;
type ty;
fw_event( size_t i = -1, type t = CHANGE_NONE )
{
id = i;
ty = t;
}
};
size_t add( const std::string& path )
{
size_t id = handles[0].size();
for( int c = 0; c < NUMTYPES; ++c )
{
handles[c].push_back( FindFirstChangeNotificationA( path.c_str(), false, fw_types[c] ) );
}
for( int c = 0; c < NUMTYPES; ++c )
{
if( handles[c][id] == INVALID_HANDLE_VALUE )
{
std::cerr << "Couldn't create handle." << std::endl;
return -1;
}
}
dir_contents.resize(id + 1);
get_dir_contents( path, dir_contents[id] );
return id;
}
bool watch(std::vector<fw_event>& ids)
{
for( int c = 0; c < NUMTYPES; ++c )
{
DWORD status = WaitForMultipleObjects(handles[c].size(), &handles[c][0], false, 0);
for( size_t d = 0; d < handles[c].size(); ++d )
{
if( status == WAIT_OBJECT_0 + d )
{
ids.push_back( fw_event( d, (type)c ) );
if( FindNextChangeNotification( handles[c][d] ) == false )
{
return false;
}
}
}
}
return true;
}
std::string get_event_filename( const std::string& path, size_t id, type ty, DWORD& fni, std::string& old_name )
{
static std::vector< filedata > contents;
contents.clear();
get_dir_contents( path, contents );
switch(ty)
{
//change in file write time
//find the not matching write time
case CHANGE_LAST_WRITE:
{
for( auto c = contents.begin(); c != contents.end(); ++c )
{
for( auto d = dir_contents[id].begin(); d != dir_contents[id].end(); ++d )
{
if( c->fname == d->fname &&
( c->fwritetime.dwLowDateTime != d->fwritetime.dwLowDateTime ||
c->fwritetime.dwHighDateTime != d->fwritetime.dwHighDateTime )
)
{
//make sure we 'neutralize' the event
d->fwritetime.dwLowDateTime = c->fwritetime.dwLowDateTime;
d->fwritetime.dwHighDateTime = c->fwritetime.dwHighDateTime;
fni = FILE_ACTION_MODIFIED;
return d->fname;
}
}
}
break;
}
//change in file creation time
//find the not matching creation time
case CHANGE_CREATION:
{
for( auto c = contents.begin(); c != contents.end(); ++c )
{
for( auto d = dir_contents[id].begin(); d != dir_contents[id].end(); ++d )
{
if( c->fname == d->fname &&
( c->ftime.dwLowDateTime != d->ftime.dwLowDateTime ||
c->ftime.dwHighDateTime != d->ftime.dwHighDateTime )
)
{
//make sure we 'neutralize' the event
d->ftime.dwLowDateTime = c->ftime.dwLowDateTime;
d->ftime.dwHighDateTime = c->ftime.dwHighDateTime;
fni = FILE_ACTION_ADDED;
return d->fname;
}
}
}
break;
}
//change in file name
//find the new filename, and add it
//remove the old filename
case CHANGE_FILE_NAME:
{
std::string filename;
bool file_deleted = contents.size() < dir_contents[id].size();
for( auto c = contents.begin(); c != contents.end(); ++c )
{
bool found = false;
for( auto d = dir_contents[id].begin(); d != dir_contents[id].end(); ++d )
{
if( c->fname == d->fname )
{
found = true;
break;
}
}
if( !found )
{
//this is what we are looking for, the new filename
filename = c->fname;
dir_contents[id].push_back(*c); //add the new file
fni = FILE_ACTION_ADDED;
break;
}
}
for( auto c = dir_contents[id].begin(); c != dir_contents[id].end(); ++c )
{
bool found = false;
for( auto d = contents.begin(); d != contents.end(); ++d )
{
if( c->fname == d->fname )
{
found = true;
break;
}
}
if( !found )
{
//this is the old filename
if( file_deleted ) //file removed
{
filename = c->fname;
fni = FILE_ACTION_REMOVED;
}
else
{
old_name = c->fname;
fni = FILE_ACTION_MODIFIED;
}
dir_contents[id].erase(c);
return filename;
}
}
//in case a new file was created
if( !filename.empty() )
{
fni = FILE_ACTION_ADDED;
return filename;
}
break;
}
//change in file size
//find the not matching file size
case CHANGE_SIZE:
{
for( auto c = contents.begin(); c != contents.end(); ++c )
{
for( auto d = dir_contents[id].begin(); d != dir_contents[id].end(); ++d )
{
if( c->fname == d->fname &&
( c->fsize.LowPart != d->fsize.LowPart ||
c->fsize.HighPart != d->fsize.HighPart )
)
{
//make sure we 'neutralize' the event
d->fsize.LowPart = c->fsize.LowPart;
d->fsize.HighPart = c->fsize.HighPart;
fni = FILE_ACTION_MODIFIED;
return d->fname;
}
}
}
//new file
for( auto c = contents.begin(); c != contents.end(); ++c )
{
bool found = false;
for( auto d = dir_contents[id].begin(); d != dir_contents[id].end(); ++d )
{
if( c->fname == d->fname )
{
found = true;
break;
}
}
if( !found )
{
//this is what we are looking for, the new filename
fni = FILE_ACTION_ADDED;
return c->fname;
}
}
break;
}
default:
break;
}
return "";
}
void remove( size_t id )
{
for( int c = 0; c < NUMTYPES; ++c )
{
auto it = handles[c].begin();
auto it2 = dir_contents.begin();
for( int d = 0; d < id; ++d )
{
++it;
++it2;
};
FindCloseChangeNotification( handles[c][id] );
handles[c].erase(it);
dir_contents.erase(it2);
}
}
};
}
#endif
#endif

View File

@ -1,151 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.lib.debug.1026456576">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.lib.debug.1026456576" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/RuntimeObjectSystem"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/RuntimeObjectSystem/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="RuntimeObjectSystem" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.lib.debug.1026456576" name="Debug" parent="cdt.managedbuild.config.gnu.lib.debug">
<folderInfo id="cdt.managedbuild.config.gnu.lib.debug.1026456576." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.lib.debug.1979145498" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.lib.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.lib.debug.781912131" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.lib.debug"/>
<builder buildPath="${workspace_loc:/RuntimeObjectSystem}/Debug" id="cdt.managedbuild.target.gnu.builder.lib.debug.1050292368" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.lib.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.lib.debug.101577515" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.debug"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug.52104751" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug">
<option id="gnu.cpp.compiler.lib.debug.option.optimization.level.1986020607" name="Optimization Level" superClass="gnu.cpp.compiler.lib.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.lib.debug.option.debugging.level.1605547910" name="Debug Level" superClass="gnu.cpp.compiler.lib.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.preprocessor.def.2124317057" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
<listOptionValue builtIn="false" value="COMPILE_PATH=\&quot;$(PWD)/\&quot;"/>
</option>
<option id="gnu.cpp.compiler.option.include.paths.119856938" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1976600625" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.debug.384391127" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.lib.debug.option.optimization.level.636574194" name="Optimization Level" superClass="gnu.c.compiler.lib.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.lib.debug.option.debugging.level.1761970298" name="Debug Level" superClass="gnu.c.compiler.lib.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1780377236" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.1173425635" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base">
<option defaultValue="true" id="gnu.c.link.option.shared.441072199" name="Shared (-shared)" superClass="gnu.c.link.option.shared" valueType="boolean"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.205495881" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
<option defaultValue="true" id="gnu.cpp.link.option.shared.1117453678" name="Shared (-shared)" superClass="gnu.cpp.link.option.shared" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1430412328" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.assembler.lib.debug.1717050908" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1422014786" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="RuntimeObjectSystem.xcodeproj|RuntimeObjectSystem_PlatformWindows.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.lib.release.807648135">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.lib.release.807648135" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/RuntimeObjectSystem"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/RuntimeObjectSystem/Release"/>
<entry flags="RESOLVED" kind="libraryFile" name="RuntimeObjectSystem" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.lib.release.807648135" name="Release" parent="cdt.managedbuild.config.gnu.lib.release">
<folderInfo id="cdt.managedbuild.config.gnu.lib.release.807648135." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.lib.release.1101614359" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.lib.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.lib.release.945125298" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.lib.release"/>
<builder buildPath="${workspace_loc:/RuntimeObjectSystem}/Release" id="cdt.managedbuild.target.gnu.builder.lib.release.900136280" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.lib.release"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.lib.release.904007212" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.release"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release.597862592" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release">
<option id="gnu.cpp.compiler.lib.release.option.optimization.level.954296701" name="Optimization Level" superClass="gnu.cpp.compiler.lib.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.lib.release.option.debugging.level.1156733452" name="Debug Level" superClass="gnu.cpp.compiler.lib.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.preprocessor.def.1700854108" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
<listOptionValue builtIn="false" value="COMPILE_PATH=\&quot;$(PWD)/\&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.748803344" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.release.1444296048" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.lib.release.option.optimization.level.165841896" name="Optimization Level" superClass="gnu.c.compiler.lib.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.lib.release.option.debugging.level.1259870149" name="Debug Level" superClass="gnu.c.compiler.lib.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.461506863" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.898425308" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base">
<option defaultValue="true" id="gnu.c.link.option.shared.552764434" name="Shared (-shared)" superClass="gnu.c.link.option.shared" valueType="boolean"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.2023302099" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
<option defaultValue="true" id="gnu.cpp.link.option.shared.1468896392" name="Shared (-shared)" superClass="gnu.cpp.link.option.shared" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.233070691" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.assembler.lib.release.882687823" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.831649956" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="RuntimeObjectSystem.xcodeproj|RuntimeObjectSystem_PlatformWindows.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="RuntimeObjectSystem.cdt.managedbuild.target.gnu.lib.971421004" name="Static Library" projectType="cdt.managedbuild.target.gnu.lib"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.release.807648135;cdt.managedbuild.config.gnu.lib.release.807648135.;cdt.managedbuild.tool.gnu.c.compiler.lib.release.1444296048;cdt.managedbuild.tool.gnu.c.compiler.input.461506863">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.release.807648135;cdt.managedbuild.config.gnu.lib.release.807648135.;cdt.managedbuild.tool.gnu.cpp.compiler.lib.release.597862592;cdt.managedbuild.tool.gnu.cpp.compiler.input.748803344">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.debug.1026456576;cdt.managedbuild.config.gnu.lib.debug.1026456576.;cdt.managedbuild.tool.gnu.c.compiler.lib.debug.384391127;cdt.managedbuild.tool.gnu.c.compiler.input.1780377236">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.debug.1026456576;cdt.managedbuild.config.gnu.lib.debug.1026456576.;cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug.52104751;cdt.managedbuild.tool.gnu.cpp.compiler.input.1976600625">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Release">
<resource resourceType="PROJECT" workspacePath="/RuntimeObjectSystem"/>
</configuration>
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/RuntimeObjectSystem"/>
</configuration>
</storageModule>
</cproject>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RuntimeObjectSystem</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -1,141 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// IObject header file.
//
// The RuntimeCompiler library does not declare an IObject interface, only forward declares it.
// Hence each project can define their own base interface for objects they want to runtime compile
// and construct by using their own declaration of IObject in their own header file.
//
////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef IOBJECT_INCLUDED
#define IOBJECT_INCLUDED
#include "ObjectInterface.h"
struct ISimpleSerializer;
class ObjectFactorySystem;
// IIDs
enum InterfaceIDEnum
{
IID_IOBJECT,
IID_ENDInterfaceID
};
typedef unsigned int InterfaceID;
// Template to help with IIDs
template< InterfaceID Tiid, typename TSuper> struct TInterface : public TSuper
{
static const InterfaceID s_interfaceID = Tiid;
virtual void GetInterface( InterfaceID _iid, void** pReturn )
{
switch(_iid)
{
case Tiid:
*pReturn= this;
break;
default:
TSuper::GetInterface(_iid, pReturn);
}
}
};
// IObject itself below is a special case as the base class
// Also it doesn't hurt to have it coded up explicitly for reference
struct IObject
{
static const InterfaceID s_interfaceID = IID_IOBJECT;
virtual void GetInterface( InterfaceID iid, void** pReturn )
{
switch( iid )
{
case IID_IOBJECT:
*pReturn = this;
break;
default:
*pReturn = NULL;
}
}
template< typename T> void GetInterface( T** pReturn )
{
GetInterface( T::s_interfaceID, (void**)pReturn );
}
IObject() : _isRuntimeDelete(false) {}
virtual ~IObject()
{
}
// Perform any object initialization
// Should be called with isFirstInit=true on object creation
// Will automatically be called with isFirstInit=false whenever a system serialization is performed
virtual void Init( bool isFirstInit )
{
}
//return the PerTypeObjectId of this object, which is unique per class
virtual PerTypeObjectId GetPerTypeId() const = 0;
virtual void GetObjectId( ObjectId& id ) const
{
id.m_ConstructorId = GetConstructor()->GetConstructorId();
id.m_PerTypeId = GetPerTypeId();
}
virtual ObjectId GetObjectId() const
{
ObjectId ret;
GetObjectId( ret );
return ret;
}
//return the constructor for this class
virtual IObjectConstructor* GetConstructor() const = 0;
//serialise is not pure virtual as many objects do not need state
virtual void Serialize(ISimpleSerializer *pSerializer) {};
virtual const char* GetTypeName() const = 0;
protected:
bool IsRuntimeDelete() { return _isRuntimeDelete; }
private:
friend class ObjectFactorySystem;
// Set to true when object is being deleted because a new version has been created
// Destructor should use this information to not delete other IObjects in this case
// since these objects will still be needed
bool _isRuntimeDelete;
};
#endif //IOBJECT_INCLUDED

View File

@ -1,74 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef IOBJECTFACTORYSYSTEM_INCLUDED
#define IOBJECTFACTORYSYSTEM_INCLUDED
#include "../RuntimeCompiler/AUArray.h"
#include "../RuntimeObjectSystem/ObjectInterface.h"
#include "../RuntimeCompiler/ICompilerLogger.h"
struct IRuntimeObjectSystem;
struct IObjectFactoryListener
{
// Called after a full serialization of objects is done when a new
// object constructor is added, so listeners can update any object
// pointers they're holding
virtual void OnConstructorsAdded() = 0;
virtual ~IObjectFactoryListener() {}
};
struct IObjectFactorySystem
{
virtual IObjectConstructor* GetConstructor( const char* type ) const = 0;
virtual ConstructorId GetConstructorId( const char* type ) const = 0;
virtual IObjectConstructor* GetConstructor( ConstructorId id ) const = 0;
virtual void AddConstructors(IAUDynArray<IObjectConstructor*> &constructors) = 0;
virtual void GetAll(IAUDynArray<IObjectConstructor*> &constructors) const = 0;
virtual IObject* GetObject( ObjectId id ) const = 0;
virtual void AddListener(IObjectFactoryListener* pListener) = 0;
virtual void RemoveListener(IObjectFactoryListener* pListener) = 0;
virtual void SetLogger( ICompilerLogger* pLogger ) = 0;
virtual void SetRuntimeObjectSystem( IRuntimeObjectSystem* pRuntimeObjectSystem ) = 0;
virtual void SetTestSerialization( bool bTest ) = 0;
virtual bool GetTestSerialization() const = 0;
virtual ~IObjectFactorySystem() {}
// sets the history of object constructors to a given size
// if set to smaller than before, will preserve the latest
// will not resize smaller than required to preserve current undo state
// default history size is 0, which means history is off (no undo & redo)
// if AddConstructors is called when the current history location is -ve,
// the constructors are updated to locatin 0 (current) prior to adding.
virtual void SetObjectConstructorHistorySize( int num_ ) = 0;
virtual int GetObjectConstructorHistorySize() = 0;
// undo & redo object constructor changes
// this will only undo swapped constructors, not new ones
virtual bool UndoObjectConstructorChange() = 0;
virtual bool RedoObjectConstructorChange() = 0;
// history location is 0 for current, +ve number for a previous location
// undo calls causes location +1, redo -1 bounded by HistorySize and 0.
virtual int GetObjectContstructorHistoryLocation() = 0;
};
#endif //IOBJECTFACTORYSYSTEM_INCLUDED

View File

@ -1,144 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef IRUNTIMEOBJECTSYSTEM_INCLUDED
#define IRUNTIMEOBJECTSYSTEM_INCLUDED
#include "../RuntimeCompiler/CompileOptions.h"
struct ICompilerLogger;
struct IObjectFactorySystem;
struct IFileChangeNotifier;
class BuildTool;
struct RuntimeProtector;
struct SystemTable;
struct IPerModuleInterface;
enum TestBuildResult
{
TESTBUILDRRESULT_SUCCESS, // SUCCESS, yay!
TESTBUILDRRESULT_NO_FILES_TO_BUILD, // file registration error or no runtime files of this type
TESTBUILDRRESULT_BUILD_FILE_GONE, // the file is no longer present
TESTBUILDRRESULT_BUILD_NOT_STARTED, // file change detection could be broken, or if an include may not be included anywhere
TESTBUILDRRESULT_BUILD_FAILED, // a build was started, but it failed or module failed to load. See log.
TESTBUILDRRESULT_OBJECT_SWAP_FAIL, // build succeeded, module loaded but errors on swapping
};
struct ITestBuildNotifier
{
// Notifier gets name of file which and result type.
// Errors will also be output to log in 'standard' RCC++ way.
// file may be NULL if type TESTBUILDFAILTYPE_NO_FILES_TO_BUILD.
// The default callback outputs result and file to log, and returns true.
//
// Return true to continue with testing more files or false to end test.
virtual bool TestBuildCallback(const char* file, TestBuildResult type) = 0;
// Notifier should implement sleep function for a small interval - say 10-100ms.
// Additionally, any message queues / view updates should be handled here, especially
// on Win32 where the file change notifiers need the message queue to be processed.
// Default uses usleep or Sleep, dispatches messages on Win32 and returns true.
//
// Return true to continue with testing or false to end test.
virtual bool TestBuildWaitAndUpdate() = 0;
};
namespace FileSystemUtils
{
class Path;
}
struct IRuntimeObjectSystem : public ITestBuildNotifier
{
// Initialise RuntimeObjectSystem. pLogger and pSystemTable should be deleted by creator.
// Both pLogger and pSystemTable can be 0
virtual bool Initialise( ICompilerLogger * pLogger, SystemTable* pSystemTable ) = 0;
virtual bool GetIsCompiling() = 0;
virtual bool GetIsCompiledComplete() = 0;
virtual bool LoadCompiledModule() = 0;
virtual bool GetLastLoadModuleSuccess() const = 0;
// GetNumberLoadedModules() returns total number successfully loaded, not current number loaded
// Mainly useful for detected wether a new module has been loaded by checking for change
virtual unsigned int GetNumberLoadedModules() const = 0;
virtual IObjectFactorySystem* GetObjectFactorySystem() const = 0;
virtual IFileChangeNotifier* GetFileChangeNotifier() const = 0;
virtual void CompileAll( bool bForceRecompile ) = 0;
// Compile & Link settings can be associated with a project identifier.
// This identifier should be defined by the application using RCC++,
// for example using enums or an identifier service.
// Identifier 0 is the default for all code not using the project identifiers.
// The backing storage will use the an array lookup, so use compact identifiers
// such as (0, 1, 2, 3) and not (20,39,42,250).
virtual void CompileAllInProject( bool bForcerecompile_, unsigned short projectId_ = 0 ) = 0;
virtual void AddToRuntimeFileList( const char* filename, unsigned short projectId_ = 0 ) = 0;
virtual void RemoveFromRuntimeFileList( const char* filename, unsigned short projectId_ = 0 ) = 0;
virtual void AddIncludeDir( const char *path_, unsigned short projectId_ = 0 ) = 0;
virtual void AddLibraryDir( const char *path_, unsigned short projectId_ = 0 ) = 0;
virtual void SetAdditionalCompileOptions( const char *options, unsigned short projectId_ = 0 ) = 0;
virtual void SetAdditionalLinkOptions( const char *options, unsigned short projectId_ = 0 ) = 0;
virtual void SetCompilerLocation ( const char* path, unsigned short projectId_ = 0 ) = 0;
virtual void SetOptimizationLevel( RCppOptimizationLevel optimizationLevel_, unsigned short projectId_ = 0 ) = 0;
virtual RCppOptimizationLevel GetOptimizationLevel( unsigned short projectId_ = 0 ) = 0;
// Intermediate Dir has DEBUG in debug or RELEASE plus project optimization level appended to it.
// defaults to current directory plus /Runtime
virtual void SetIntermediateDir( const char* path_, unsigned short projectId_ = 0 ) = 0;
virtual void SetAutoCompile( bool autoCompile ) = 0;
virtual bool GetAutoCompile() const = 0;
// see Compiler::SetFastCompileMode
virtual void SetFastCompileMode( bool bFast ) = 0;
// clean up temporary object files
virtual void CleanObjectFiles() const = 0;
virtual void SetupObjectConstructors(IPerModuleInterface* pPerModuleInterface) = 0;
//ensure subclasses are deleted correctly
virtual ~IRuntimeObjectSystem(){};
// exception handling to catch and protect main app from crashing when using runtime compiling
virtual void SetProtectionEnabled( bool bProtectionEnabled_ ) = 0;
virtual bool IsProtectionEnabled() const = 0;
virtual bool TryProtectedFunction( RuntimeProtector* pProtectedObject_ ) = 0;
// tests one by one touching each runtime modifiable source file
// returns the number of errors - 0 if all passed.
virtual int TestBuildAllRuntimeSourceFiles( ITestBuildNotifier* callback, bool bTestFileTracking ) = 0;
// tests touching each header which has RUNTIME_MODIFIABLE_INCLUDE.
// returns the number of errors - 0 if all passed.
virtual int TestBuildAllRuntimeHeaders( ITestBuildNotifier* callback, bool bTestFileTracking ) = 0;
// FindFile - attempts to find the file in a source directory
virtual FileSystemUtils::Path FindFile( const FileSystemUtils::Path& input ) = 0;
// AddPathToSourceSearch - adds a path to help source search. Can be called multiple times to add paths.
virtual void AddPathToSourceSearch( const char* path ) = 0;
};
#endif // IRUNTIMEOBJECTSYSTEM_INCLUDED

View File

@ -1,148 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef ISIMPLESERIALIZER_INCLUDED
#define ISIMPLESERIALIZER_INCLUDED
// Currently this system is more of a 'property store' rather than a serializer,
// but could be modified in future in that direction if needed, though more likely
// will be scrapped for something more sophisticated
#include "../RuntimeObjectSystem/ObjectInterface.h"
#define SERIALIZE(prop) pSerializer->SerializeProperty(#prop, prop);
struct ISerializedValue {
virtual ~ISerializedValue()
{
}
};
template <typename T>
struct SerializedValue : ISerializedValue
{
// NOTE: this requires value being serialized to have a correct copy constructor that
// will copy all values that would otherwise be deleted when object being serialized
// is deleted
SerializedValue(const T& value) : value(value)
{
}
const T value;
};
struct ISimpleSerializer
{
virtual void Clear() = 0;
virtual void Clear(ObjectId ownerId) = 0;
virtual void Clear(ObjectId ownerId, const char* propertyName) = 0;
virtual bool IsLoading() const = 0;
// Stores a copy of the value when loading is false
// Returns true on successful property load, or always when saving a value
template <typename T> bool SerializeProperty(const char* propertyName, T& value);
// Array of T version of SerializeProperty
// Stores a copy of the value when loading is false
// Returns true on successful property load, or always when saving a value
template <typename T, size_t N> bool SerializeProperty(const char* propertyName, T (&arrayIn)[N] );
virtual ~ISimpleSerializer( ) {}
private:
// Implementation requires backing the following functions with keyed storage
// pValue should be deleted by implementation in destructor.
virtual void SetISerializedValue(const char* propertyName, const ISerializedValue* pValue) = 0;
virtual const ISerializedValue* GetISerializedValue(const char* propertyName) const = 0;
};
// NOTE: this is less efficient than having separate functions for setting and getting properties,
// but allows for user code to generally have much simpler serialization methods without needing to
// handle save and load separately (in most cases)
template <typename T>
inline bool ISimpleSerializer::SerializeProperty(const char* propertyName, T& value)
{
if (IsLoading())
{
const SerializedValue<T>* pSV = static_cast<const SerializedValue<T>*>(GetISerializedValue(propertyName));
if (!pSV)
{
return false;
}
value = pSV->value;
}
else
{
const SerializedValue<T>* pSv = new SerializedValue<T>(value);
SetISerializedValue(propertyName, pSv);
}
return true;
}
template <typename T, size_t N>
struct SerializedValueArray : ISerializedValue
{
// NOTE: this requires value being serialized to have a correct copy constructor that
// will copy all values that would otherwise be deleted when object being serialized
// is deleted
SerializedValueArray(const T (&arrayIn)[N] )
{
memcpy( valueArray, arrayIn, sizeof( valueArray) );
}
T valueArray[N];
};
// NOTE: this is less efficient than having separate functions for setting and getting properties,
// but allows for user code to generally have much simpler serialization methods without needing to
// handle save and load separately (in most cases)
template <typename T, size_t N>
inline bool ISimpleSerializer::SerializeProperty(const char* propertyName, T (&arrayIn)[N])
{
if (IsLoading())
{
const SerializedValueArray<T,N>* pSV = static_cast<const SerializedValueArray<T,N>*>(GetISerializedValue(propertyName));
if (!pSV)
{
return false;
}
memcpy( arrayIn, pSV->valueArray, sizeof( arrayIn ) );
}
else
{
const SerializedValueArray<T,N>* pSv = new SerializedValueArray<T,N>(arrayIn);
SetISerializedValue(propertyName, pSv);
}
return true;
}
#endif //ISIMPLESERIALIZER_INCLUDED

View File

@ -1,454 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "ObjectFactorySystem.h"
#include "../ObjectInterface.h"
#include "../ObjectInterfacePerModule.h"
#include "../IObject.h"
#include "../IRuntimeObjectSystem.h"
IObjectConstructor* ObjectFactorySystem::GetConstructor( const char* type ) const
{
CONSTRUCTORMAP::const_iterator found = m_ConstructorIds.find( type );
if( found != m_ConstructorIds.end() )
{
return m_Constructors[ found->second ];
}
return 0;
}
ConstructorId ObjectFactorySystem::GetConstructorId( const char* type ) const
{
CONSTRUCTORMAP::const_iterator found = m_ConstructorIds.find( type );
if( found != m_ConstructorIds.end() )
{
return found->second;
}
return InvalidId;
}
IObjectConstructor* ObjectFactorySystem::GetConstructor( ConstructorId id ) const
{
if( id < m_Constructors.size() )
{
return m_Constructors[ id ];
}
return 0;
}
void ObjectFactorySystem::ProtectedObjectSwapper::ProtectedFunc()
{
m_ProtectedPhase = PHASE_SERIALIZEOUT;
// serialize all out
if( m_pLogger ) m_pLogger->LogInfo( "Serializing out from %d old constructors...\n", (int)m_ConstructorsOld.size());
// use a temporary serializer in case there is an exception, so preserving any old state (if there is any)
m_Serializer.SetIsLoading( false );
for( size_t i = 0; i < m_ConstructorsOld.size(); ++i )
{
IObjectConstructor* pOldConstructor = m_ConstructorsOld[i];
size_t numObjects = pOldConstructor->GetNumberConstructedObjects();
for( size_t j = 0; j < numObjects; ++j )
{
IObject* pOldObject = pOldConstructor->GetConstructedObject( j );
if (pOldObject)
{
m_Serializer.Serialize( pOldObject );
}
}
}
// swap serializer
if( m_pLogger ) m_pLogger->LogInfo( "Swapping in and creating objects for %d new constructors...\n", (int)m_ConstructorsToAdd.size());
m_ProtectedPhase = PHASE_CONSTRUCTNEW;
TConstructors& constructorsNew = m_pObjectFactorySystem->m_Constructors;
//swap old constructors with new ones and create new objects
for( size_t i = 0; i < m_ConstructorsToAdd.size(); ++i )
{
IObjectConstructor* pConstructor = m_ConstructorsToAdd[i];
//replace constructor, but if one exists then replace objects
IObjectConstructor* pOldConstructor = m_pObjectFactorySystem->GetConstructor( pConstructor->GetName() );
if( pOldConstructor == pConstructor )
{
// don't add constructor if it's already in existance
continue;
}
// Reconstruct objects, starting at end to reduce overhead in factory container
if( pOldConstructor )
{
// replace and construct
pConstructor->SetConstructorId( pOldConstructor->GetConstructorId() );
constructorsNew[ pConstructor->GetConstructorId() ] = pConstructor;
for( PerTypeObjectId objId = 0; objId < pOldConstructor->GetNumberConstructedObjects(); ++ objId )
{
// create new object
if( pOldConstructor->GetConstructedObject( objId ) )
{
pConstructor->Construct();
}
else
{
pConstructor->ConstructNull();
}
}
m_ConstructorsReplaced.push_back( pOldConstructor );
}
else
{
ConstructorId id = constructorsNew.size();
m_pObjectFactorySystem->m_ConstructorIds[ pConstructor->GetName() ] = id;
constructorsNew.push_back( pConstructor );
pConstructor->SetConstructorId( id );
}
}
if( m_pLogger ) m_pLogger->LogInfo( "Serialising in...\n");
//serialize back
m_ProtectedPhase = PHASE_SERIALIZEIN;
m_Serializer.SetIsLoading( true );
for( size_t i = 0; i < constructorsNew.size(); ++i )
{
IObjectConstructor* pConstructor = constructorsNew[i];
for( PerTypeObjectId objId = 0; objId < pConstructor->GetNumberConstructedObjects(); ++ objId )
{
// Serialize new object
IObject* pObject = pConstructor->GetConstructedObject( objId );
if (pObject)
{
m_Serializer.Serialize( pObject );
}
}
}
// auto construct singletons
// now in 2 phases - construct then init
m_ProtectedPhase = PHASE_AUTOCONSTRUCTSINGLETONS;
std::vector<bool> bSingletonConstructed( constructorsNew.size(), false );
if( m_pLogger ) m_pLogger->LogInfo( "Auto Constructing Singletons...\n");
for( size_t i = 0; i < constructorsNew.size(); ++i )
{
IObjectConstructor* pConstructor = constructorsNew[i];
if( pConstructor->GetIsAutoConstructSingleton() )
{
if( 0 == pConstructor->GetNumberConstructedObjects() )
{
pConstructor->GetSingleton();
bSingletonConstructed[i] = true;
}
}
}
// Do a second pass, initializing objects now that they've all been serialized
// and testing serialization if required
m_ProtectedPhase = PHASE_INITANDSERIALIZEOUTTEST;
if( m_bTestSerialization )
{
if( m_pLogger ) m_pLogger->LogInfo( "Initialising and testing new serialisation...\n");
}
else
{
if( m_pLogger ) m_pLogger->LogInfo( "Initialising...\n");
}
for( size_t i = 0; i < constructorsNew.size(); ++i )
{
IObjectConstructor* pConstructor = constructorsNew[i];
for( PerTypeObjectId objId = 0; objId < pConstructor->GetNumberConstructedObjects(); ++ objId )
{
IObject* pObject = pConstructor->GetConstructedObject( objId );
if (pObject)
{
// if a singleton was newly constructed in earlier phase, pass true to init.
pObject->Init( bSingletonConstructed[i] );
if( m_bTestSerialization && ( m_ConstructorsOld.size() <= i || m_ConstructorsOld[ i ] != constructorsNew[ i ] ) )
{
//test serialize out for all new objects, we assume old objects are OK.
SimpleSerializer tempSerializer;
tempSerializer.SetIsLoading( false );
tempSerializer.Serialize( pObject );
}
}
}
}
m_ProtectedPhase = PHASE_DELETEOLD;
//delete old objects which have been replaced
for( size_t i = 0; i < m_ConstructorsOld.size(); ++i )
{
if( m_ConstructorsOld[i] != constructorsNew[i] )
{
//TODO: could put a constructor around this.
//constructor has been replaced
IObjectConstructor* pOldConstructor = m_ConstructorsOld[i];
size_t numObjects = pOldConstructor->GetNumberConstructedObjects();
for( size_t j = 0; j < numObjects; ++j )
{
IObject* pOldObject = pOldConstructor->GetConstructedObject( j );
if( pOldObject )
{
pOldObject->_isRuntimeDelete = true;
delete pOldObject;
}
}
pOldConstructor->ClearIfAllDeleted();
assert( 0 == pOldConstructor->GetNumberConstructedObjects() );
}
}
}
bool ObjectFactorySystem::HandleRedoUndo( const TConstructors& constructors )
{
if( constructors.size() == 0 )
{
m_pLogger->LogInfo( "ObjectFactorySystem::HandleRedoUndo() called with no constructors.\n" );
return true;
}
ProtectedObjectSwapper swapper;
swapper.m_ConstructorsToAdd = constructors;
swapper.m_ConstructorsOld = m_Constructors;
swapper.m_pLogger = m_pLogger;
swapper.m_pObjectFactorySystem = this;
swapper.m_bTestSerialization = false; // we don't need to test as this should alraedy have been done
swapper.m_ProtectedPhase = PHASE_NONE;
// we use the protected function to do all serialization
m_pRuntimeObjectSystem->TryProtectedFunction( &swapper );
CompleteConstructorSwap( swapper );
return !swapper.HasHadException() || ( PHASE_DELETEOLD == swapper.m_ProtectedPhase );
}
void ObjectFactorySystem::AddConstructors( IAUDynArray<IObjectConstructor*> &constructors )
{
if( constructors.Size() == 0 )
{
m_pLogger->LogInfo( "ObjectFactorySystem::AddConstructors() called with no constructors.\n" );
return;
}
if( m_HistoryCurrentLocation )
{
m_pLogger->LogInfo( "Need to fast forward undo system to current state of source code.\n" );
while( RedoObjectConstructorChange() ) {}
}
ProtectedObjectSwapper swapper;
swapper.m_ConstructorsToAdd.assign( &constructors[0], &constructors[constructors.Size() - 1] + 1 );
swapper.m_ConstructorsOld = m_Constructors;
swapper.m_pLogger = m_pLogger;
swapper.m_pObjectFactorySystem = this;
swapper.m_bTestSerialization = m_bTestSerialization;
swapper.m_ProtectedPhase = PHASE_NONE;
// we use the protected function to do all serialization
m_pRuntimeObjectSystem->TryProtectedFunction( &swapper );
CompleteConstructorSwap( swapper );
if( m_HistoryMaxSize )
{
HistoryPoint historyPoint = { swapper.m_ConstructorsReplaced, swapper.m_ConstructorsToAdd };
m_HistoryConstructors.push_back( historyPoint );
if( (int)m_HistoryConstructors.size() > m_HistoryMaxSize )
{
m_HistoryConstructors.erase( m_HistoryConstructors.begin() );
}
}
}
void ObjectFactorySystem::CompleteConstructorSwap( ProtectedObjectSwapper& swapper )
{
if( swapper.HasHadException() && PHASE_DELETEOLD != swapper.m_ProtectedPhase )
{
if( m_pLogger )
{
m_pLogger->LogError( "Exception during object swapping, switching back to previous objects.\n" );
switch( swapper.m_ProtectedPhase )
{
case PHASE_NONE:
AU_ASSERT( false );
break;
case PHASE_SERIALIZEOUT:
m_pLogger->LogError( "\tError occured during serialize out old objects phase.\n" );
break;
case PHASE_CONSTRUCTNEW:
m_pLogger->LogError( "\tError occured during constructing new objects phase.\n" );
break;
case PHASE_SERIALIZEIN:
m_pLogger->LogError( "\tError occured during serialize into the new objects phase.\n" );
break;
case PHASE_AUTOCONSTRUCTSINGLETONS:
m_pLogger->LogError( "\tError occured during auto construct singletons phase.\n" );
break;
case PHASE_INITANDSERIALIZEOUTTEST:
if( m_bTestSerialization )
{
m_pLogger->LogError( "\tError occured during Initialization and serialize test of new objects phase.\n" );
}
else
{
m_pLogger->LogError( "\tError occured during Initialization phase.\n" );
}
break;
case PHASE_DELETEOLD:
break;
}
}
//swap back to new constructors before everything is serialized back in
m_Constructors = swapper.m_ConstructorsOld;
if( PHASE_SERIALIZEOUT != swapper.m_ProtectedPhase )
{
//serialize back with old objects - could cause exception which isn't handled, but hopefully not.
swapper.m_Serializer.SetIsLoading( true );
for( size_t i = 0; i < m_Constructors.size(); ++i )
{
IObjectConstructor* pConstructor = m_Constructors[i];
for( PerTypeObjectId objId = 0; objId < pConstructor->GetNumberConstructedObjects(); ++ objId )
{
// Iserialize new object
IObject* pObject = pConstructor->GetConstructedObject( objId );
if (pObject)
{
swapper.m_Serializer.Serialize( pObject );
}
}
}
// Do a second pass, initializing objects now that they've all been serialized
for( size_t i = 0; i < m_Constructors.size(); ++i )
{
IObjectConstructor* pConstructor = m_Constructors[i];
for( PerTypeObjectId objId = 0; objId < pConstructor->GetNumberConstructedObjects(); ++ objId )
{
IObject* pObject = pConstructor->GetConstructedObject( objId );
if (pObject)
{
pObject->Init(false);
}
}
}
}
}
else
{
if( m_pLogger ) m_pLogger->LogInfo( "Object swap completed\n");
if( swapper.HasHadException() && PHASE_DELETEOLD == swapper.m_ProtectedPhase )
{
if( m_pLogger ) m_pLogger->LogError( "Exception during object destruction of old objects, leaking.\n" );
}
}
// Notify any listeners that constructors have changed
TObjectFactoryListeners::iterator it = m_Listeners.begin();
TObjectFactoryListeners::iterator itEnd = m_Listeners.end();
while (it != itEnd)
{
(*it)->OnConstructorsAdded();
++it;
}
}
void ObjectFactorySystem::GetAll(IAUDynArray<IObjectConstructor*> &constructors) const
{
constructors.Resize(m_Constructors.size());
std::vector<IObjectConstructor*>::const_iterator it = m_Constructors.begin();
std::vector<IObjectConstructor*>::const_iterator itEnd = m_Constructors.end();
for(int i = 0; it != itEnd; ++it, ++i)
{
constructors[i] = *it;
}
}
IObject* ObjectFactorySystem::GetObject( ObjectId id ) const
{
IObjectConstructor* pConstructor = ObjectFactorySystem::GetConstructor( id.m_ConstructorId );
if( pConstructor )
{
return pConstructor->GetConstructedObject( id.m_PerTypeId );
}
return 0;
}
void ObjectFactorySystem::AddListener(IObjectFactoryListener* pListener)
{
m_Listeners.insert(pListener);
}
void ObjectFactorySystem::RemoveListener(IObjectFactoryListener* pListener)
{
m_Listeners.erase(pListener);
}
void ObjectFactorySystem::SetObjectConstructorHistorySize( int num_ )
{
if( num_ >= m_HistoryCurrentLocation )
{
m_HistoryMaxSize = num_;
}
while( m_HistoryMaxSize < (int)m_HistoryConstructors.size() )
{
m_HistoryConstructors.erase( m_HistoryConstructors.begin() );
}
}
int ObjectFactorySystem::GetObjectConstructorHistorySize()
{
return m_HistoryMaxSize;
}
bool ObjectFactorySystem::UndoObjectConstructorChange()
{
if( m_HistoryCurrentLocation < (int)m_HistoryConstructors.size() )
{
++m_HistoryCurrentLocation;
size_t loc = m_HistoryConstructors.size() - m_HistoryCurrentLocation;
return HandleRedoUndo( m_HistoryConstructors[ loc ].before );
}
return false;
}
bool ObjectFactorySystem::RedoObjectConstructorChange()
{
if( m_HistoryCurrentLocation > 0 )
{
size_t loc = m_HistoryConstructors.size() - m_HistoryCurrentLocation;
--m_HistoryCurrentLocation;
return HandleRedoUndo( m_HistoryConstructors[ loc ].after );
}
return false;
}
int ObjectFactorySystem::GetObjectContstructorHistoryLocation()
{
return m_HistoryCurrentLocation;
}

View File

@ -1,136 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef OBJECTFACTORYSYSTEM_INCLUDED
#define OBJECTFACTORYSYSTEM_INCLUDED
#include "../IObjectFactorySystem.h"
#include "../SimpleSerializer/SimpleSerializer.h"
#include "../RuntimeProtector.h"
#include <map>
#include <string>
#include <set>
// class ObjectFactorySystem
// implements interface IObjectFactorySystem
// also implements RuntimeProtector so that when new constructors are added and used,
// exceptions can be caught by the runtime system to allow fixing on the fly.
class ObjectFactorySystem : public IObjectFactorySystem
{
public:
ObjectFactorySystem()
: m_pLogger( 0 )
, m_pRuntimeObjectSystem( 0 )
, m_bTestSerialization(true)
, m_HistoryMaxSize( 0 )
, m_HistoryCurrentLocation( 0 )
{
}
virtual IObjectConstructor* GetConstructor( const char* type ) const;
virtual ConstructorId GetConstructorId( const char* type ) const;
virtual IObjectConstructor* GetConstructor( ConstructorId id ) const;
virtual void AddConstructors(IAUDynArray<IObjectConstructor*> &constructors);
virtual void GetAll(IAUDynArray<IObjectConstructor*> &constructors) const;
virtual IObject* GetObject( ObjectId id ) const;
virtual void AddListener(IObjectFactoryListener* pListener);
virtual void RemoveListener(IObjectFactoryListener* pListener);
virtual void SetLogger( ICompilerLogger * pLogger )
{
m_pLogger = pLogger;
}
virtual void SetRuntimeObjectSystem( IRuntimeObjectSystem* pRuntimeObjectSystem )
{
m_pRuntimeObjectSystem = pRuntimeObjectSystem;
}
virtual void SetTestSerialization( bool bTest )
{
m_bTestSerialization = bTest;
}
virtual bool GetTestSerialization() const
{
return m_bTestSerialization;
}
virtual void SetObjectConstructorHistorySize( int num_ );
virtual int GetObjectConstructorHistorySize();
virtual bool UndoObjectConstructorChange();
virtual bool RedoObjectConstructorChange();
virtual int GetObjectContstructorHistoryLocation();
private:
typedef std::map<std::string,ConstructorId> CONSTRUCTORMAP;
typedef std::set<IObjectFactoryListener*> TObjectFactoryListeners;
typedef std::vector<IObjectConstructor*> TConstructors;
CONSTRUCTORMAP m_ConstructorIds;
TConstructors m_Constructors;
TObjectFactoryListeners m_Listeners;
ICompilerLogger* m_pLogger;
IRuntimeObjectSystem* m_pRuntimeObjectSystem;
bool m_bTestSerialization;
// History
int m_HistoryMaxSize;
int m_HistoryCurrentLocation; // positive non-zero number means previous
struct HistoryPoint
{
TConstructors before;
TConstructors after;
};
std::vector<HistoryPoint> m_HistoryConstructors;
bool HandleRedoUndo( const TConstructors& constructors );
enum ProtectedPhase
{
PHASE_NONE,
PHASE_SERIALIZEOUT,
PHASE_CONSTRUCTNEW,
PHASE_SERIALIZEIN,
PHASE_AUTOCONSTRUCTSINGLETONS,
PHASE_INITANDSERIALIZEOUTTEST,
PHASE_DELETEOLD,
};
// temp data needed during object swap
struct ProtectedObjectSwapper: public RuntimeProtector
{
TConstructors m_ConstructorsToAdd;
TConstructors m_ConstructorsOld;
TConstructors m_ConstructorsReplaced;
SimpleSerializer m_Serializer;
ICompilerLogger* m_pLogger;
ObjectFactorySystem* m_pObjectFactorySystem;
bool m_bTestSerialization;
ProtectedPhase m_ProtectedPhase;
// RuntimeProtector implementation
virtual void ProtectedFunc();
};
friend struct ProtectedObjectSwapper;
void CompleteConstructorSwap( ProtectedObjectSwapper& swapper );
};
#endif //OBJECTFACTORYSYSTEM_INCLUDED

View File

@ -1,119 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef OBJECTINTERFACE_INCLUDED
#define OBJECTINTERFACE_INCLUDED
#include <vector>
#include <stdlib.h>
struct SystemTable; //This is the interface to your own engine code, which you need to define yourself if required.
struct IObject;
const size_t InvalidId = (size_t)-1;
typedef size_t PerTypeObjectId;
typedef size_t ConstructorId;
struct ObjectId
{
ObjectId() : m_PerTypeId(InvalidId), m_ConstructorId(InvalidId) {}
PerTypeObjectId m_PerTypeId;
ConstructorId m_ConstructorId;
bool operator<( ObjectId lhs ) const
{
if( m_ConstructorId < lhs.m_ConstructorId )
{
return true;
}
if( m_ConstructorId == lhs.m_ConstructorId )
{
return m_PerTypeId < lhs.m_PerTypeId;
}
return false;
}
bool operator==( const ObjectId& rhs) const
{
return (m_ConstructorId == rhs.m_ConstructorId && m_PerTypeId == rhs.m_PerTypeId);
}
bool IsValid() const
{
return (m_ConstructorId != InvalidId && m_PerTypeId != InvalidId);
}
void SetInvalid()
{
m_ConstructorId = InvalidId;
m_PerTypeId = InvalidId;
}
};
struct SourceDependencyInfo;
struct IObjectConstructor
{
virtual IObject* Construct() = 0;
virtual void ConstructNull() = 0; //for use in object replacement, ensures a deleted object can be replaced
virtual const char* GetName() = 0;
virtual const char* GetFileName() = 0;
virtual const char* GetCompiledPath() = 0;
virtual size_t GetMaxNumIncludeFiles() const = 0;
virtual const char* GetIncludeFile( size_t Num_ ) const = 0;
virtual size_t GetMaxNumLinkLibraries() const = 0;
virtual const char* GetLinkLibrary( size_t Num_ ) const = 0;
virtual size_t GetMaxNumSourceDependencies() const = 0;
virtual SourceDependencyInfo GetSourceDependency( size_t Num_ ) const = 0;
virtual void SetProjectId( unsigned short projectId_ ) = 0;
virtual unsigned short GetProjectId() const = 0;
// Singleton functions
virtual bool GetIsSingleton() const = 0;
virtual bool GetIsAutoConstructSingleton() const = 0;
IObject* GetSingleton()
{
return Construct();
}
virtual IObject* GetConstructedObject( PerTypeObjectId num ) const = 0; //should return 0 for last or deleted object
virtual size_t GetNumberConstructedObjects() const = 0;
virtual ConstructorId GetConstructorId() const = 0;
virtual void SetConstructorId( ConstructorId id ) = 0; //take care how you use this - should only be used by id service
virtual void ClearIfAllDeleted() = 0; //if there are no objects left then clear internal memory (does not reduce memory consumption)
virtual ~IObjectConstructor() {}
};
struct IPerModuleInterface
{
virtual std::vector<IObjectConstructor*>& GetConstructors() = 0;
virtual void SetProjectIdForAllConstructors( unsigned short projectId_ ) = 0;
virtual void SetSystemTable( SystemTable* pSystemTable ) = 0;
virtual const std::vector<const char*>& GetRequiredSourceFiles() const = 0;
virtual void AddRequiredSourceFiles( const char* file_ ) = 0;
virtual void SetModuleFileName( const char* name ) = 0;
virtual ~IPerModuleInterface() {}
};
#ifdef _WIN32
typedef IPerModuleInterface* (__cdecl *GETPerModuleInterface_PROC)(void);
#else
typedef IPerModuleInterface* ( *GETPerModuleInterface_PROC)(void);
#endif
#endif //OBJECTINTERFACE_INCLUDED

View File

@ -1,395 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef OBJECTINTERFACEPERMODULE_INCLUDED
#define OBJECTINTERFACEPERMODULE_INCLUDED
#include "ObjectInterface.h"
#include "RuntimeInclude.h"
#include "RuntimeLinkLibrary.h"
#include "RuntimeSourceDependency.h"
#include <string>
#include <vector>
#include <assert.h>
#ifndef RCCPPOFF
#define AU_ASSERT( statement ) do { if (!(statement)) { volatile int* p = 0; int a = *p; if(a) {} } } while(0)
#else
#define AU_ASSERT( statement ) assert( statement )
#endif //RCCPPOFF
class PerModuleInterface : public IPerModuleInterface
{
public:
static PerModuleInterface* GetInstance();
static SystemTable* g_pSystemTable;
void AddConstructor( IObjectConstructor* pConstructor );
virtual std::vector<IObjectConstructor*>& GetConstructors();
virtual void SetProjectIdForAllConstructors( unsigned short projectId_ );
virtual void SetSystemTable( SystemTable* pSystemTable );
SystemTable* GetSystemTable()
{
return g_pSystemTable;
}
virtual const std::vector<const char*>& GetRequiredSourceFiles() const;
virtual void AddRequiredSourceFiles( const char* file_ );
virtual void SetModuleFileName( const char* name )
{
m_ModuleFilename = name;
}
const char* GetCompiledPath() const
{
#ifdef COMPILE_PATH
return COMPILE_PATH;
#else
return "";
#endif
}
private:
PerModuleInterface();
~PerModuleInterface()
{
}
static PerModuleInterface* ms_pObjectManager;
std::vector<IObjectConstructor*> m_ObjectConstructors;
std::vector<const char*> m_RequiredSourceFiles;
std::string m_ModuleFilename;
};
template<typename T> class TObjectConstructorConcrete: public IObjectConstructor
{
public:
TObjectConstructorConcrete(
#ifndef RCCPPOFF
const char* Filename,
IRuntimeIncludeFileList* pIncludeFileList_,
IRuntimeSourceDependencyList* pSourceDependencyList_,
IRuntimeLinkLibraryList* pLinkLibraryList,
#endif
bool bIsSingleton,
bool bIsAutoConstructSingleton)
: m_bIsSingleton( bIsSingleton )
, m_bIsAutoConstructSingleton( bIsAutoConstructSingleton )
, m_pModuleInterface(0)
, m_Project(0)
#ifndef RCCPPOFF
, m_FileName( Filename )
, m_pIncludeFileList(pIncludeFileList_)
, m_pSourceDependencyList(pSourceDependencyList_)
, m_pLinkLibraryList(pLinkLibraryList)
#endif
{
#ifndef RCCPPOFF
// add path to filename
#ifdef COMPILE_PATH
m_FileName = COMPILE_PATH + m_FileName;
#endif
#endif
PerModuleInterface::GetInstance()->AddConstructor( this );
m_pModuleInterface = PerModuleInterface::GetInstance();
m_Id = InvalidId;
}
virtual IObject* Construct()
{
T* pT = 0;
if( m_bIsSingleton && m_ConstructedObjects.size() && m_ConstructedObjects[0] )
{
return m_ConstructedObjects[0];
}
if( m_FreeIds.empty() )
{
PerTypeObjectId id = m_ConstructedObjects.size();
pT = new T();
pT->SetPerTypeId( id );
m_ConstructedObjects.push_back( pT );
}
else
{
PerTypeObjectId id = m_FreeIds.back();
m_FreeIds.pop_back();
pT = new T();
pT->SetPerTypeId( id );
AU_ASSERT( 0 == m_ConstructedObjects[ id ] );
m_ConstructedObjects[ id ] = pT;
}
return pT;
}
virtual void ConstructNull()
{
// should not occur for singletons
AU_ASSERT( !m_bIsSingleton );
m_ConstructedObjects.push_back( NULL );
}
virtual const char* GetName()
{
return T::GetTypeNameStatic();
}
virtual void SetProjectId( unsigned short projectId_ )
{
m_Project = projectId_;
}
virtual unsigned short GetProjectId() const
{
return m_Project;
}
virtual const char* GetFileName()
{
#ifndef RCCPPOFF
return m_FileName.c_str();
#else
return 0;
#endif
}
virtual const char* GetCompiledPath()
{
#ifndef RCCPPOFF
#ifdef COMPILE_PATH
return COMPILE_PATH;
#else
return "";
#endif
#else
return 0;
#endif
}
virtual const char* GetIncludeFile( size_t Num_ ) const
{
#ifndef RCCPPOFF
if( m_pIncludeFileList )
{
return m_pIncludeFileList->GetIncludeFile( Num_ );
}
#endif
return 0;
}
virtual size_t GetMaxNumIncludeFiles() const
{
#ifndef RCCPPOFF
if( m_pIncludeFileList )
{
return m_pIncludeFileList->MaxNum;
}
#endif
return 0;
}
virtual const char* GetLinkLibrary( size_t Num_ ) const
{
#ifndef RCCPPOFF
if( m_pLinkLibraryList )
{
return m_pLinkLibraryList->GetLinkLibrary( Num_ );
}
#endif
return 0;
}
virtual size_t GetMaxNumLinkLibraries() const
{
#ifndef RCCPPOFF
if( m_pLinkLibraryList )
{
return m_pLinkLibraryList->MaxNum;
}
#endif
return 0;
}
virtual SourceDependencyInfo GetSourceDependency( size_t Num_ ) const
{
#ifndef RCCPPOFF
if( m_pSourceDependencyList )
{
return m_pSourceDependencyList->GetSourceDependency( Num_ );
}
#endif
return SourceDependencyInfo::GetNULL();
}
virtual size_t GetMaxNumSourceDependencies() const
{
#ifndef RCCPPOFF
if( m_pSourceDependencyList )
{
return m_pSourceDependencyList->MaxNum;
}
#endif
return 0;
}
virtual bool GetIsSingleton() const
{
return m_bIsSingleton;
}
virtual bool GetIsAutoConstructSingleton() const
{
return m_bIsSingleton && m_bIsAutoConstructSingleton;
}
virtual IObject* GetConstructedObject( PerTypeObjectId id ) const
{
if( m_ConstructedObjects.size() > id )
{
return m_ConstructedObjects[id];
}
return 0;
}
virtual size_t GetNumberConstructedObjects() const
{
return m_ConstructedObjects.size();
}
virtual ConstructorId GetConstructorId() const
{
return m_Id;
}
virtual void SetConstructorId( ConstructorId id )
{
if( InvalidId == m_Id )
{
m_Id = id;
}
}
void DeRegister( PerTypeObjectId id )
{
//remove from constructed objects.
//use swap with last one
if( m_ConstructedObjects.size() - 1 == id )
{
//it's the last one, just remove it.
m_ConstructedObjects.pop_back();
}
else
{
m_FreeIds.push_back( id );
m_ConstructedObjects[ id ] = 0;
}
}
virtual void ClearIfAllDeleted()
{
m_FreeIds.clear();
m_ConstructedObjects.clear();
}
private:
bool m_bIsSingleton;
bool m_bIsAutoConstructSingleton;
std::vector<T*> m_ConstructedObjects;
std::vector<PerTypeObjectId> m_FreeIds;
ConstructorId m_Id;
PerModuleInterface* m_pModuleInterface;
unsigned short m_Project;
#ifndef RCCPPOFF
std::string m_FileName;
IRuntimeIncludeFileList* m_pIncludeFileList;
IRuntimeSourceDependencyList* m_pSourceDependencyList;
IRuntimeLinkLibraryList* m_pLinkLibraryList;
#endif
};
template<typename T> class TActual: public T
{
public:
// overload new/delete to get alignment correct
#ifdef _WIN32
void* operator new(size_t size)
{
size_t align = __alignof( TActual<T> );
return _aligned_malloc( size, align );
}
void operator delete(void* p)
{
_aligned_free( p );
}
#else
void* operator new(size_t size)
{
size_t align = __alignof__( TActual<T> );
void* pRet;
int retval = posix_memalign( &pRet, align, size );
(void)retval; //unused
return pRet;
}
void operator delete(void* p)
{
free( p );
}
#endif //_WIN32
friend class TObjectConstructorConcrete<TActual>;
virtual ~TActual() { m_Constructor.DeRegister( m_Id ); }
virtual PerTypeObjectId GetPerTypeId() const { return m_Id; }
virtual IObjectConstructor* GetConstructor() const { return &m_Constructor; }
static const char* GetTypeNameStatic();
virtual const char* GetTypeName() const
{
return GetTypeNameStatic();
}
private:
void SetPerTypeId( PerTypeObjectId id ) { m_Id = id; }
PerTypeObjectId m_Id;
static TObjectConstructorConcrete<TActual> m_Constructor;
};
#ifndef RCCPPOFF
#define REGISTERBASE( T, bIsSingleton, bIsAutoConstructSingleton ) \
static RuntimeIncludeFiles< __COUNTER__ > g_includeFileList_##T; \
static RuntimeSourceDependency< __COUNTER__ > g_sourceDependencyList_##T; \
static RuntimeLinkLibrary< __COUNTER__ > g_linkLibraryList_##T; \
template<> TObjectConstructorConcrete< TActual< T > > TActual< T >::m_Constructor( __FILE__, &g_includeFileList_##T, &g_sourceDependencyList_##T, &g_linkLibraryList_##T, bIsSingleton, bIsAutoConstructSingleton );\
template<> const char* TActual< T >::GetTypeNameStatic() { return #T; } \
template class TActual< T >;
#else
#define REGISTERBASE( T, bIsSingleton, bIsAutoConstructSingleton ) \
template<> TObjectConstructorConcrete< TActual< T > > TActual< T >::m_Constructor( bIsSingleton, bIsAutoConstructSingleton); \
template<> const char* TActual< T >::GetTypeNameStatic() { return #T; } \
template class TActual< T >;
#endif
//NOTE: the file macro will only emit the full path if /FC option is used in visual studio or /ZI (Which forces /FC)
#define REGISTERCLASS( T ) REGISTERBASE( T, false, false )
#define REGISTERSINGLETON( T, bIsAutoConstructSingleton ) REGISTERBASE( T, true, bIsAutoConstructSingleton )
#endif // OBJECTINTERFACEPERMODULE_INCLUDED

View File

@ -1,83 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
// ObjectInterfaceOerDllSource.cpp : Defines the entry point for the DLL application.
#include "ObjectInterfacePerModule.h"
PerModuleInterface* PerModuleInterface::ms_pObjectManager = NULL;
SystemTable* PerModuleInterface::g_pSystemTable = 0;
extern "C"
#ifdef _WIN32
__declspec(dllexport) //should create file with export import macros etc.
#else
__attribute__((visibility("default")))
#endif
IPerModuleInterface* GetPerModuleInterface()
{
return PerModuleInterface::GetInstance();
}
PerModuleInterface* PerModuleInterface::GetInstance()
{
if( !ms_pObjectManager )
{
ms_pObjectManager = new PerModuleInterface;
}
return ms_pObjectManager;
}
void PerModuleInterface::AddConstructor( IObjectConstructor* pConstructor )
{
m_ObjectConstructors.push_back( pConstructor );
}
std::vector<IObjectConstructor*>& PerModuleInterface::GetConstructors()
{
return m_ObjectConstructors;
}
void PerModuleInterface::SetProjectIdForAllConstructors( unsigned short projectId_ )
{
for( size_t i = 0; i < m_ObjectConstructors.size(); ++i )
{
m_ObjectConstructors[ i ]->SetProjectId( projectId_ );
}
}
void PerModuleInterface::SetSystemTable( SystemTable* pSystemTable )
{
g_pSystemTable = pSystemTable;
}
PerModuleInterface::PerModuleInterface()
{
//ensure this file gets compiled
AddRequiredSourceFiles( __FILE__ );
}
const std::vector<const char*>& PerModuleInterface::GetRequiredSourceFiles() const
{
return m_RequiredSourceFiles;
}
void PerModuleInterface::AddRequiredSourceFiles( const char* file_ )
{
m_RequiredSourceFiles.push_back( file_ );
}

View File

@ -1,112 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef RUNTIMEINCLUDE_INCLUDED
#define RUNTIMEINCLUDE_INCLUDED
#include <stddef.h>
#ifndef RCCPPOFF
//NOTE: the file macro will only emit the full path if /FC option is used in visual studio or /ZI (Which forces /FC)
//Following creates a list of files which are runtime modifiable, to be used in headers
//requires use of __COUNTER__ predefined macro, which is in gcc 4.3+, clang/llvm and MSVC
struct IRuntimeIncludeFileList
{
IRuntimeIncludeFileList( size_t max ) : MaxNum( max )
{
}
// GetIncludeFile may return 0, so you should iterate through to GetMaxNum() ignoring 0 returns
virtual const char* GetIncludeFile( size_t Num_ ) const
{
return 0;
}
size_t MaxNum; // initialized in constructor below
};
namespace
{
template< size_t COUNT > struct RuntimeIncludeFiles : public RuntimeIncludeFiles<COUNT-1>
{
RuntimeIncludeFiles( size_t max ) : RuntimeIncludeFiles<COUNT-1>( max )
{
}
RuntimeIncludeFiles() : RuntimeIncludeFiles<COUNT-1>( COUNT )
{
}
virtual const char* GetIncludeDir( size_t Num_ ) const
{
if( Num_ < COUNT )
{
return this->RuntimeIncludeFiles< COUNT-1 >::GetIncludeDir( Num_ );
}
else return 0;
}
};
template<> struct RuntimeIncludeFiles<0> : public IRuntimeIncludeFileList
{
RuntimeIncludeFiles( size_t max ) : IRuntimeIncludeFileList( max )
{
}
RuntimeIncludeFiles() : IRuntimeIncludeFileList( 0 )
{
}
virtual const char* GetIncludeDir( size_t Num_ ) const
{
return 0;
}
};
#define RUNTIME_MODIFIABLE_INCLUDE_BASE( N ) \
template<> struct RuntimeIncludeFiles< N + 1 > : public RuntimeIncludeFiles< N >\
{ \
RuntimeIncludeFiles( size_t max ) : RuntimeIncludeFiles<N>( max ) {} \
RuntimeIncludeFiles< N + 1 >() : RuntimeIncludeFiles<N>( N + 1 ) {} \
virtual const char* GetIncludeFile( size_t Num_ ) const \
{ \
if( Num_ <= N ) \
{ \
if( Num_ == N ) \
{ \
return __FILE__; \
} \
else return this->RuntimeIncludeFiles< N >::GetIncludeFile( Num_ ); \
} \
else return 0; \
} \
}; \
#define RUNTIME_MODIFIABLE_INCLUDE namespace { RUNTIME_MODIFIABLE_INCLUDE_BASE( __COUNTER__ ) }
}
#else
#define RUNTIME_MODIFIABLE_INCLUDE
#endif //RCCPPOFF
#endif //RUNTIMEINCLUDE_INCLUDED

View File

@ -1,111 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef RUNTIMELINKLIBRARY_INCLUDED
#define RUNTIMELINKLIBRARY_INCLUDED
#ifndef RCCPPOFF
//NOTE: the file macro will only emit the full path if /FC option is used in visual studio or /ZI (Which forces /FC)
//Following creates a list of files which are runtime modifiable, to be used in headers
//requires use of __COUNTER__ predefined macro, which is in gcc 4.3+, clang/llvm and MSVC
struct IRuntimeLinkLibraryList
{
IRuntimeLinkLibraryList( size_t max ) : MaxNum( max )
{
}
// GetIncludeFile may return 0, so you should iterate through to GetMaxNum() ignoring 0 returns
virtual const char* GetLinkLibrary( size_t Num_ ) const
{
return 0;
}
size_t MaxNum; // initialized in constructor below
};
namespace
{
template< size_t COUNT > struct RuntimeLinkLibrary : public RuntimeLinkLibrary<COUNT-1>
{
RuntimeLinkLibrary( size_t max ) : RuntimeLinkLibrary<COUNT-1>( max )
{
}
RuntimeLinkLibrary() : RuntimeLinkLibrary<COUNT-1>( COUNT )
{
}
virtual const char* GetLinkLibrary( size_t Num_ ) const
{
if( Num_ < COUNT )
{
return this->RuntimeLinkLibrary< COUNT-1 >::GetLinkLibrary( Num_ );
}
else return 0;
}
};
template<> struct RuntimeLinkLibrary<0> : public IRuntimeLinkLibraryList
{
RuntimeLinkLibrary( size_t max ) : IRuntimeLinkLibraryList( max )
{
}
RuntimeLinkLibrary() : IRuntimeLinkLibraryList( 0 )
{
}
virtual const char* GetLinkLibrary( size_t Num_ ) const
{
return 0;
}
};
#define RUNTIME_COMPILER_LINKLIBRARY_BASE( LIBRARY, N ) \
template<> struct RuntimeLinkLibrary< N + 1 > : public RuntimeLinkLibrary< N >\
{ \
RuntimeLinkLibrary( size_t max ) : RuntimeLinkLibrary<N>( max ) {} \
RuntimeLinkLibrary< N + 1 >() : RuntimeLinkLibrary<N>( N + 1 ) {} \
virtual const char* GetLinkLibrary( size_t Num_ ) const \
{ \
if( Num_ <= N ) \
{ \
if( Num_ == N ) \
{ \
return LIBRARY; \
} \
else return this->RuntimeLinkLibrary< N >::GetLinkLibrary( Num_ ); \
} \
else return 0; \
} \
}; \
#define RUNTIME_COMPILER_LINKLIBRARY( LIBRARY ) namespace { RUNTIME_COMPILER_LINKLIBRARY_BASE( LIBRARY, __COUNTER__ ) }
}
#else
#define RUNTIME_COMPILER_LINKLIBRARY( LIBRARY )
#endif //RCCPPOFF
#endif //RUNTIMELINKLIBRARY_INCLUDED

File diff suppressed because it is too large Load Diff

View File

@ -1,220 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef RUNTIMEOBJECTSYSTEM_INCLUDED
#define RUNTIMEOBJECTSYSTEM_INCLUDED
#include "../RuntimeCompiler/IFileChangeNotifier.h"
#include "../RuntimeCompiler/BuildTool.h"
#include "../RuntimeCompiler/AUArray.h"
#include "ObjectInterface.h"
#include "IRuntimeObjectSystem.h"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#undef GetObject
#else
typedef void* HMODULE;
#endif
#include <vector>
#include <map>
#include "../RuntimeCompiler/FileSystemUtils.h"
struct ICompilerLogger;
struct IObjectFactorySystem;
class RuntimeObjectSystem : public IRuntimeObjectSystem, IFileChangeListener
{
public:
RuntimeObjectSystem();
virtual ~RuntimeObjectSystem();
// Initialise RuntimeObjectSystem. pLogger should be deleted by creator
virtual bool Initialise( ICompilerLogger * pLogger, SystemTable* pSystemTable );
virtual bool GetIsCompiling()
{
return m_bCompiling;
}
virtual bool GetIsCompiledComplete();
virtual bool LoadCompiledModule();
virtual IObjectFactorySystem* GetObjectFactorySystem() const
{
return m_pObjectFactorySystem;
}
virtual IFileChangeNotifier* GetFileChangeNotifier() const
{
return m_pFileChangeNotifier;
}
virtual void CompileAll( bool bForceRecompile );
virtual void CompileAllInProject( bool bForcerecompile_, unsigned short projectId_ = 0 );
virtual void AddToRuntimeFileList( const char* filename, unsigned short projectId_ = 0 );
virtual void RemoveFromRuntimeFileList( const char* filename, unsigned short projectId_ = 0 );
virtual void AddIncludeDir( const char* path_, unsigned short projectId_ = 0 );
virtual void AddLibraryDir( const char* path_, unsigned short projectId_ = 0 );
virtual void SetAdditionalCompileOptions( const char* options, unsigned short projectId_ = 0 );
virtual void SetAdditionalLinkOptions( const char* options, unsigned short projectId_ = 0 );
virtual void SetCompilerLocation ( const char* path, unsigned short projectId_ = 0 );
virtual void SetOptimizationLevel( RCppOptimizationLevel optimizationLevel_, unsigned short projectId_ = 0 );
virtual RCppOptimizationLevel GetOptimizationLevel( unsigned short projectId_ = 0 );
virtual void SetIntermediateDir( const char* path_, unsigned short projectId_ = 0 );
virtual void SetAutoCompile( bool autoCompile );
virtual bool GetAutoCompile() const
{
return m_bAutoCompile;
}
virtual void SetFastCompileMode( bool bFast )
{
if( m_pBuildTool )
{
m_pBuildTool->SetFastCompileMode( bFast );
}
}
virtual void CleanObjectFiles() const;
virtual bool GetLastLoadModuleSuccess() const
{
return m_bLastLoadModuleSuccess;
}
virtual unsigned int GetNumberLoadedModules() const
{
return m_TotalLoadedModulesEver;
}
virtual void SetupObjectConstructors(IPerModuleInterface* pPerModuleInterface);
// exception handling to catch and protect main app from crashing when using runtime compiling
virtual void SetProtectionEnabled( bool bProtectionEnabled_ );
virtual bool IsProtectionEnabled() const
{
return m_bProtectionEnabled;
}
virtual bool TryProtectedFunction( RuntimeProtector* pProtectedObject_ );
// tests one by one touching each runtime modifiable source file
// returns the number of errors - 0 if all passed.
virtual int TestBuildAllRuntimeSourceFiles( ITestBuildNotifier* callback, bool bTestFileTracking );
// tests touching each header which has RUNTIME_MODIFIABLE_INCLUDE.
// returns the number of errors - 0 if all passed.
virtual int TestBuildAllRuntimeHeaders( ITestBuildNotifier* callback, bool bTestFileTracking );
virtual bool TestBuildCallback(const char* file, TestBuildResult type);
virtual bool TestBuildWaitAndUpdate();
// FindFile - attempts to find the file in a source directory
virtual FileSystemUtils::Path FindFile( const FileSystemUtils::Path& input );
// AddPathToSourceSearch - adds a path to help source search. Can be called multiple times to add paths.
virtual void AddPathToSourceSearch( const char* path );
// IFileChangeListener
virtual void OnFileChange(const IAUDynArray<const char*>& filelist);
// ~IFileChangeListener
std::vector<FileSystemUtils::Path> linkLibraryList;
private:
typedef std::vector<FileSystemUtils::Path> TFileList;
typedef std::map<FileSystemUtils::Path,FileSystemUtils::Path> TFileMap;
typedef TFileMap::iterator TFileMapIterator;
typedef std::multimap<FileSystemUtils::Path,FileSystemUtils::Path> TFileToFilesMap;
typedef TFileToFilesMap::iterator TFileToFilesIterator;
typedef std::pair<FileSystemUtils::Path,FileSystemUtils::Path> TFileToFilePair;
typedef std::pair<TFileToFilesMap::iterator,TFileToFilesMap::iterator> TFileToFilesEqualRange;
void StartRecompile();
void SetupRuntimeFileTracking( const IAUDynArray<IObjectConstructor*>& constructors_ );
// Members set in initialise
ICompilerLogger* m_pCompilerLogger;
SystemTable* m_pSystemTable;
// Members created by this system
IObjectFactorySystem* m_pObjectFactorySystem;
IFileChangeNotifier* m_pFileChangeNotifier;
BuildTool* m_pBuildTool;
bool m_bCompiling;
bool m_bLastLoadModuleSuccess;
std::vector<HMODULE> m_Modules; // Stores runtime created modules, but not the exe module.
bool m_bAutoCompile;
FileSystemUtils::Path m_CurrentlyCompilingModuleName;
// per project information
struct ProjectSettings
{
ProjectSettings()
{
m_CompilerOptions.optimizationLevel = RCCPPOPTIMIZATIONLEVEL_DEFAULT;
m_CompilerOptions.baseIntermediatePath = ms_DefaultIntermediatePath;
}
CompilerOptions m_CompilerOptions;
TFileList m_RuntimeFileList;
TFileToFilesMap m_RuntimeIncludeMap;
TFileToFilesMap m_RuntimeLinkLibraryMap;
TFileToFilesMap m_RuntimeSourceDependencyMap;
std::vector<BuildTool::FileToBuild> m_BuildFileList;
std::vector<BuildTool::FileToBuild> m_PendingBuildFileList; // if a compile is already underway, store files here.
static FileSystemUtils::Path ms_DefaultIntermediatePath;
};
std::vector<ProjectSettings> m_Projects;
ProjectSettings& GetProject( unsigned short projectId_ );
unsigned short m_CurrentlyBuildingProject;
unsigned int m_TotalLoadedModulesEver;
bool m_bProtectionEnabled;
// File mappings - we need to map from compiled path to a potentially different path
// on the system the code is running on
TFileMap m_FoundSourceDirectoryMappings; // mappings between directories found and requested
unsigned int m_NumNotFoundSourceFiles; // count of source directories not found
// platform implementation in RuntimeObjectSystem_Plaform*.cpp
public:
struct PlatformImpl;
private:
PlatformImpl* m_pImpl;
void CreatePlatformImpl();
void DeletePlatformImpl();
};
#endif // RUNTIMEOBJECTSYSTEM_INCLUDED

View File

@ -1,208 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RuntimeSourceDependency.h" />
<ClInclude Include="RuntimeProtector.h" />
<ClInclude Include="IObject.h" />
<ClInclude Include="IObjectFactorySystem.h" />
<ClInclude Include="IRuntimeObjectSystem.h" />
<ClInclude Include="ISimpleSerializer.h" />
<ClInclude Include="ObjectFactorySystem\ObjectFactorySystem.h" />
<ClInclude Include="ObjectInterface.h" />
<ClInclude Include="ObjectInterfacePerModule.h" />
<ClInclude Include="RuntimeInclude.h" />
<ClInclude Include="RuntimeLinkLibrary.h" />
<ClInclude Include="RuntimeObjectSystem.h" />
<ClInclude Include="SimpleSerializer\SimpleSerializer.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ObjectFactorySystem\ObjectFactorySystem.cpp" />
<ClCompile Include="ObjectInterfacePerModuleSource.cpp" />
<ClCompile Include="RuntimeObjectSystem.cpp" />
<ClCompile Include="RuntimeObjectSystem_PlatformPosix.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="RuntimeObjectSystem_PlatformWindows.cpp" />
<ClCompile Include="SimpleSerializer\SimpleSerializer.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{FA4E24F1-885C-406B-89A8-436F28D090B2}</ProjectGuid>
<RootNamespace>Systems</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x86.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x64.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x86.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Aurora_x64.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<CustomBuildAfterTargets>
</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<CustomBuildAfterTargets />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<ExceptionHandling>Async</ExceptionHandling>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<AdditionalDependencies>
</AdditionalDependencies>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Lib>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
<PostBuildEvent>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<ExceptionHandling>Async</ExceptionHandling>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<AdditionalDependencies>
</AdditionalDependencies>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Lib>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
<PostBuildEvent />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<ExceptionHandling>Async</ExceptionHandling>
<MinimalRebuild>false</MinimalRebuild>
<PreprocessorDefinitions>_UNICODE;UNICODE;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Lib>
<AdditionalDependencies>
</AdditionalDependencies>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Lib>
<PostBuildEvent>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<ExceptionHandling>Async</ExceptionHandling>
<MinimalRebuild>false</MinimalRebuild>
<PreprocessorDefinitions>_UNICODE;UNICODE;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Lib>
<AdditionalDependencies>
</AdditionalDependencies>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Lib>
<PostBuildEvent />
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="ObjectInterfacePerModuleSource.cpp" />
<ClCompile Include="ObjectFactorySystem\ObjectFactorySystem.cpp">
<Filter>ObjectFactorySystem</Filter>
</ClCompile>
<ClCompile Include="SimpleSerializer\SimpleSerializer.cpp">
<Filter>SimpleSerializer</Filter>
</ClCompile>
<ClCompile Include="RuntimeObjectSystem.cpp" />
<ClCompile Include="RuntimeObjectSystem_PlatformWindows.cpp" />
<ClCompile Include="RuntimeObjectSystem_PlatformPosix.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="IObject.h" />
<ClInclude Include="IObjectFactorySystem.h" />
<ClInclude Include="ISimpleSerializer.h" />
<ClInclude Include="ObjectInterface.h" />
<ClInclude Include="ObjectInterfacePerModule.h" />
<ClInclude Include="ObjectFactorySystem\ObjectFactorySystem.h">
<Filter>ObjectFactorySystem</Filter>
</ClInclude>
<ClInclude Include="SimpleSerializer\SimpleSerializer.h">
<Filter>SimpleSerializer</Filter>
</ClInclude>
<ClInclude Include="RuntimeInclude.h" />
<ClInclude Include="IRuntimeObjectSystem.h" />
<ClInclude Include="RuntimeObjectSystem.h" />
<ClInclude Include="RuntimeLinkLibrary.h" />
<ClInclude Include="RuntimeProtector.h" />
<ClInclude Include="RuntimeSourceDependency.h" />
</ItemGroup>
<ItemGroup>
<Filter Include="SimpleSerializer">
<UniqueIdentifier>{d5986d12-394a-47fc-9758-17ebc5c6720c}</UniqueIdentifier>
</Filter>
<Filter Include="ObjectFactorySystem">
<UniqueIdentifier>{59da87f4-0b75-46be-82e1-26feaffac32c}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View File

@ -1,288 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
910584A816D67FF600FDEAC3 /* RuntimeProtector.h in Headers */ = {isa = PBXBuildFile; fileRef = 910584A716D67FF600FDEAC3 /* RuntimeProtector.h */; };
910987F416441841006315D5 /* RuntimeLinkLibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = 910987F316441841006315D5 /* RuntimeLinkLibrary.h */; };
915C293216EB816D00654B4E /* RuntimeObjectSystem_PlatformPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 915C293116EB816D00654B4E /* RuntimeObjectSystem_PlatformPosix.cpp */; };
91B4FC2E161A027C0029E1A5 /* IObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B4FC1C161A027C0029E1A5 /* IObject.h */; };
91B4FC2F161A027C0029E1A5 /* IObjectFactorySystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B4FC1D161A027C0029E1A5 /* IObjectFactorySystem.h */; };
91B4FC30161A027C0029E1A5 /* IRuntimeObjectSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B4FC1E161A027C0029E1A5 /* IRuntimeObjectSystem.h */; };
91B4FC31161A027C0029E1A5 /* ISimpleSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B4FC1F161A027C0029E1A5 /* ISimpleSerializer.h */; };
91B4FC32161A027C0029E1A5 /* ObjectFactorySystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B4FC21161A027C0029E1A5 /* ObjectFactorySystem.cpp */; };
91B4FC33161A027C0029E1A5 /* ObjectFactorySystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B4FC22161A027C0029E1A5 /* ObjectFactorySystem.h */; };
91B4FC34161A027C0029E1A5 /* ObjectInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B4FC23161A027C0029E1A5 /* ObjectInterface.h */; };
91B4FC35161A027C0029E1A5 /* ObjectInterfacePerModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B4FC24161A027C0029E1A5 /* ObjectInterfacePerModule.h */; };
91B4FC36161A027C0029E1A5 /* ObjectInterfacePerModuleSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B4FC25161A027C0029E1A5 /* ObjectInterfacePerModuleSource.cpp */; };
91B4FC37161A027C0029E1A5 /* RuntimeInclude.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B4FC26161A027C0029E1A5 /* RuntimeInclude.h */; };
91B4FC38161A027C0029E1A5 /* RuntimeObjectSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B4FC27161A027C0029E1A5 /* RuntimeObjectSystem.cpp */; };
91B4FC39161A027C0029E1A5 /* RuntimeObjectSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B4FC28161A027C0029E1A5 /* RuntimeObjectSystem.h */; };
91B4FC3A161A027C0029E1A5 /* SimpleSerializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B4FC2A161A027C0029E1A5 /* SimpleSerializer.cpp */; };
91B4FC3B161A027C0029E1A5 /* SimpleSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B4FC2B161A027C0029E1A5 /* SimpleSerializer.h */; };
91EF513F17280D8A009B4B4B /* RuntimeSourceDependency.h in Headers */ = {isa = PBXBuildFile; fileRef = 91EF513E17280D8A009B4B4B /* RuntimeSourceDependency.h */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
910584A716D67FF600FDEAC3 /* RuntimeProtector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuntimeProtector.h; sourceTree = "<group>"; };
910987F316441841006315D5 /* RuntimeLinkLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuntimeLinkLibrary.h; sourceTree = "<group>"; };
913A25D21619FB7D006AF4C1 /* libRuntimeObjectSystem.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRuntimeObjectSystem.a; sourceTree = BUILT_PRODUCTS_DIR; };
915C293116EB816D00654B4E /* RuntimeObjectSystem_PlatformPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuntimeObjectSystem_PlatformPosix.cpp; sourceTree = "<group>"; };
91B4FC1C161A027C0029E1A5 /* IObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IObject.h; sourceTree = "<group>"; };
91B4FC1D161A027C0029E1A5 /* IObjectFactorySystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IObjectFactorySystem.h; sourceTree = "<group>"; };
91B4FC1E161A027C0029E1A5 /* IRuntimeObjectSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IRuntimeObjectSystem.h; sourceTree = "<group>"; };
91B4FC1F161A027C0029E1A5 /* ISimpleSerializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISimpleSerializer.h; sourceTree = "<group>"; };
91B4FC21161A027C0029E1A5 /* ObjectFactorySystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectFactorySystem.cpp; sourceTree = "<group>"; };
91B4FC22161A027C0029E1A5 /* ObjectFactorySystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectFactorySystem.h; sourceTree = "<group>"; };
91B4FC23161A027C0029E1A5 /* ObjectInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectInterface.h; sourceTree = "<group>"; };
91B4FC24161A027C0029E1A5 /* ObjectInterfacePerModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectInterfacePerModule.h; sourceTree = "<group>"; };
91B4FC25161A027C0029E1A5 /* ObjectInterfacePerModuleSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectInterfacePerModuleSource.cpp; sourceTree = "<group>"; };
91B4FC26161A027C0029E1A5 /* RuntimeInclude.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuntimeInclude.h; sourceTree = "<group>"; };
91B4FC27161A027C0029E1A5 /* RuntimeObjectSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuntimeObjectSystem.cpp; sourceTree = "<group>"; };
91B4FC28161A027C0029E1A5 /* RuntimeObjectSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuntimeObjectSystem.h; sourceTree = "<group>"; };
91B4FC2A161A027C0029E1A5 /* SimpleSerializer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleSerializer.cpp; sourceTree = "<group>"; };
91B4FC2B161A027C0029E1A5 /* SimpleSerializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleSerializer.h; sourceTree = "<group>"; };
91EF513E17280D8A009B4B4B /* RuntimeSourceDependency.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuntimeSourceDependency.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
913A25CF1619FB7D006AF4C1 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
913A25C71619FB7D006AF4C1 = {
isa = PBXGroup;
children = (
915C293116EB816D00654B4E /* RuntimeObjectSystem_PlatformPosix.cpp */,
910987F316441841006315D5 /* RuntimeLinkLibrary.h */,
910584A716D67FF600FDEAC3 /* RuntimeProtector.h */,
91B4FC1C161A027C0029E1A5 /* IObject.h */,
91B4FC1D161A027C0029E1A5 /* IObjectFactorySystem.h */,
91B4FC1E161A027C0029E1A5 /* IRuntimeObjectSystem.h */,
91B4FC1F161A027C0029E1A5 /* ISimpleSerializer.h */,
91B4FC20161A027C0029E1A5 /* ObjectFactorySystem */,
91B4FC23161A027C0029E1A5 /* ObjectInterface.h */,
91B4FC24161A027C0029E1A5 /* ObjectInterfacePerModule.h */,
91B4FC25161A027C0029E1A5 /* ObjectInterfacePerModuleSource.cpp */,
91B4FC26161A027C0029E1A5 /* RuntimeInclude.h */,
91EF513E17280D8A009B4B4B /* RuntimeSourceDependency.h */,
91B4FC27161A027C0029E1A5 /* RuntimeObjectSystem.cpp */,
91B4FC28161A027C0029E1A5 /* RuntimeObjectSystem.h */,
91B4FC29161A027C0029E1A5 /* SimpleSerializer */,
913A25D31619FB7D006AF4C1 /* Products */,
);
sourceTree = "<group>";
};
913A25D31619FB7D006AF4C1 /* Products */ = {
isa = PBXGroup;
children = (
913A25D21619FB7D006AF4C1 /* libRuntimeObjectSystem.a */,
);
name = Products;
sourceTree = "<group>";
};
91B4FC20161A027C0029E1A5 /* ObjectFactorySystem */ = {
isa = PBXGroup;
children = (
91B4FC21161A027C0029E1A5 /* ObjectFactorySystem.cpp */,
91B4FC22161A027C0029E1A5 /* ObjectFactorySystem.h */,
);
path = ObjectFactorySystem;
sourceTree = "<group>";
};
91B4FC29161A027C0029E1A5 /* SimpleSerializer */ = {
isa = PBXGroup;
children = (
91B4FC2A161A027C0029E1A5 /* SimpleSerializer.cpp */,
91B4FC2B161A027C0029E1A5 /* SimpleSerializer.h */,
);
path = SimpleSerializer;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
913A25D01619FB7D006AF4C1 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
91B4FC2E161A027C0029E1A5 /* IObject.h in Headers */,
91B4FC2F161A027C0029E1A5 /* IObjectFactorySystem.h in Headers */,
91B4FC30161A027C0029E1A5 /* IRuntimeObjectSystem.h in Headers */,
91B4FC31161A027C0029E1A5 /* ISimpleSerializer.h in Headers */,
91B4FC33161A027C0029E1A5 /* ObjectFactorySystem.h in Headers */,
91B4FC34161A027C0029E1A5 /* ObjectInterface.h in Headers */,
91B4FC35161A027C0029E1A5 /* ObjectInterfacePerModule.h in Headers */,
91B4FC37161A027C0029E1A5 /* RuntimeInclude.h in Headers */,
91B4FC39161A027C0029E1A5 /* RuntimeObjectSystem.h in Headers */,
91B4FC3B161A027C0029E1A5 /* SimpleSerializer.h in Headers */,
910987F416441841006315D5 /* RuntimeLinkLibrary.h in Headers */,
910584A816D67FF600FDEAC3 /* RuntimeProtector.h in Headers */,
91EF513F17280D8A009B4B4B /* RuntimeSourceDependency.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
913A25D11619FB7D006AF4C1 /* RuntimeObjectSystem */ = {
isa = PBXNativeTarget;
buildConfigurationList = 913A25D61619FB7D006AF4C1 /* Build configuration list for PBXNativeTarget "RuntimeObjectSystem" */;
buildPhases = (
913A25CE1619FB7D006AF4C1 /* Sources */,
913A25CF1619FB7D006AF4C1 /* Frameworks */,
913A25D01619FB7D006AF4C1 /* Headers */,
);
buildRules = (
);
dependencies = (
);
name = RuntimeObjectSystem;
productName = RuntimeObjectSystem;
productReference = 913A25D21619FB7D006AF4C1 /* libRuntimeObjectSystem.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
913A25C91619FB7D006AF4C1 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0440;
ORGANIZATIONNAME = "Doug Binks";
};
buildConfigurationList = 913A25CC1619FB7D006AF4C1 /* Build configuration list for PBXProject "RuntimeObjectSystem" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 913A25C71619FB7D006AF4C1;
productRefGroup = 913A25D31619FB7D006AF4C1 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
913A25D11619FB7D006AF4C1 /* RuntimeObjectSystem */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
913A25CE1619FB7D006AF4C1 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
91B4FC32161A027C0029E1A5 /* ObjectFactorySystem.cpp in Sources */,
91B4FC36161A027C0029E1A5 /* ObjectInterfacePerModuleSource.cpp in Sources */,
91B4FC38161A027C0029E1A5 /* RuntimeObjectSystem.cpp in Sources */,
91B4FC3A161A027C0029E1A5 /* SimpleSerializer.cpp in Sources */,
915C293216EB816D00654B4E /* RuntimeObjectSystem_PlatformPosix.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
913A25D41619FB7D006AF4C1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
913A25D51619FB7D006AF4C1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
SDKROOT = macosx;
};
name = Release;
};
913A25D71619FB7D006AF4C1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
EXECUTABLE_PREFIX = lib;
HEADER_SEARCH_PATHS = ../External/boost/;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = "";
};
name = Debug;
};
913A25D81619FB7D006AF4C1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
EXECUTABLE_PREFIX = lib;
HEADER_SEARCH_PATHS = ../External/boost/;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = "";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
913A25CC1619FB7D006AF4C1 /* Build configuration list for PBXProject "RuntimeObjectSystem" */ = {
isa = XCConfigurationList;
buildConfigurations = (
913A25D41619FB7D006AF4C1 /* Debug */,
913A25D51619FB7D006AF4C1 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
913A25D61619FB7D006AF4C1 /* Build configuration list for PBXNativeTarget "RuntimeObjectSystem" */ = {
isa = XCConfigurationList;
buildConfigurations = (
913A25D71619FB7D006AF4C1 /* Debug */,
913A25D81619FB7D006AF4C1 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 913A25C91619FB7D006AF4C1 /* Project object */;
}

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:RuntimeObjectSystem.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,163 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "RuntimeObjectSystem.h"
#include "RuntimeProtector.h"
#ifdef __APPLE__
// Mach ports requirements
#include <mach/mach.h>
#endif
#include <pthread.h>
#include <assert.h>
#include <signal.h>
#include <string.h>
static __thread RuntimeProtector* m_pCurrProtector = 0; // for nested threaded handling, one per thread.
#ifdef __APPLE__
static bool ms_bMachPortSet = false;
const size_t NUM_OLD_EXCEPTION_HANDLERS = 16;
static mach_msg_type_number_t old_count;
static exception_mask_t old_masks[NUM_OLD_EXCEPTION_HANDLERS];
static mach_port_t old_ports[NUM_OLD_EXCEPTION_HANDLERS];
static exception_behavior_t old_behaviors[NUM_OLD_EXCEPTION_HANDLERS];
static thread_state_flavor_t old_flavors[NUM_OLD_EXCEPTION_HANDLERS];
#endif
void RuntimeObjectSystem::CreatePlatformImpl()
{
#ifdef __APPLE__
if( !ms_bMachPortSet )
{
// prevent OS X debugger from catching signals in a none re-catchable way
task_get_exception_ports(mach_task_self(), EXC_MASK_BAD_ACCESS | EXC_MASK_BAD_INSTRUCTION, old_masks, &old_count, old_ports, old_behaviors, old_flavors);
task_set_exception_ports(mach_task_self(), EXC_MASK_BAD_ACCESS | EXC_MASK_BAD_INSTRUCTION, MACH_PORT_NULL, EXCEPTION_DEFAULT, MACHINE_THREAD_STATE);
ms_bMachPortSet = true;
}
#endif
}
void RuntimeObjectSystem::DeletePlatformImpl()
{
}
void RuntimeObjectSystem::SetProtectionEnabled( bool bProtectionEnabled_ )
{
m_bProtectionEnabled = bProtectionEnabled_;
#ifdef __APPLE__
if( !m_bProtectionEnabled )
{
if( ms_bMachPortSet )
{
for( int i = 0; i < old_count; ++i )
{
task_set_exception_ports( mach_task_self(), old_masks[i], old_ports[i], old_behaviors[i], old_flavors[i]);
}
}
}
else
{
CreatePlatformImpl();
}
#endif
}
void signalHandler(int sig, siginfo_t *info, void *context)
{
// we only handle synchronous signals with this handler, so they come to the correct thread.
assert( m_pCurrProtector );
// store exception information
switch( sig )
{
case SIGILL:
m_pCurrProtector->ExceptionInfo.Type = RuntimeProtector::ESE_InvalidInstruction;
break;
case SIGBUS:
m_pCurrProtector->ExceptionInfo.Type = RuntimeProtector::ESE_AccessViolation;
break;
case SIGSEGV:
m_pCurrProtector->ExceptionInfo.Type = RuntimeProtector::ESE_AccessViolation;
break;
default: assert(false); //should not get here
}
m_pCurrProtector->ExceptionInfo.Addr = info->si_addr;
longjmp(m_pCurrProtector->m_env, sig );
}
bool RuntimeObjectSystem::TryProtectedFunction( RuntimeProtector* pProtectedObject_ )
{
if( !m_bProtectionEnabled )
{
pProtectedObject_->ProtectedFunc();
return true;
}
// allow cascading by storing prev and current impl
pProtectedObject_->m_pPrevious = m_pCurrProtector;
m_pCurrProtector = pProtectedObject_;
struct sigaction oldAction[3]; // we need to store old actions, could remove for optimization
bool bHasJustHadException = false;
if( m_TotalLoadedModulesEver != pProtectedObject_->m_ModulesLoadedCount )
{
// clear exceptions if we've just loaded a new module
pProtectedObject_->m_ModulesLoadedCount = m_TotalLoadedModulesEver;
pProtectedObject_->m_bHashadException = false;
}
if( !pProtectedObject_->m_bHashadException )
{
if( setjmp(m_pCurrProtector->m_env) )
{
pProtectedObject_->m_bHashadException = true;
bHasJustHadException = true;
}
else
{
struct sigaction newAction;
memset( &newAction, 0, sizeof( newAction ));
newAction.sa_sigaction = signalHandler;
newAction.sa_flags = SA_SIGINFO; //use complex signal hander function sa_sigaction not sa_handler
sigaction(SIGILL, &newAction, &oldAction[0] );
sigaction(SIGBUS, &newAction, &oldAction[1] );
sigaction(SIGSEGV, &newAction, &oldAction[2] );
pProtectedObject_->ProtectedFunc();
}
//reset
sigaction(SIGILL, &oldAction[0], NULL );
sigaction(SIGBUS, &oldAction[1], NULL );
sigaction(SIGSEGV, &oldAction[2], NULL );
}
m_pCurrProtector = pProtectedObject_->m_pPrevious;
return !bHasJustHadException;
}
bool RuntimeObjectSystem::TestBuildWaitAndUpdate()
{
usleep( 100 * 1000 );
return true;
}

View File

@ -1,197 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "RuntimeProtector.h"
#include "RuntimeObjectSystem.h"
#define WIN32_LEAN_AND_MEAN
#include "Windows.h"
#include "WinBase.h"
#include "excpt.h"
#include <assert.h>
// windows includes can cause GetObject to be defined, we undefine it here.
#ifdef GetObject
#undef GetObject
#endif
struct RuntimeObjectSystem::PlatformImpl
{
enum ExceptionState
{
ES_PASS,
ES_CATCH,
};
ExceptionState s_exceptionState;
PlatformImpl()
: s_exceptionState( ES_PASS )
{
}
int RuntimeExceptionFilter()
{
if( !AmBeingDebugged() )
{
// if there's no debugger, we simply continue operating.
// TODO: Should implement a method to ensure this can be
// disabled so process crashes on end user machines
return EXCEPTION_EXECUTE_HANDLER;
}
int result;
switch (s_exceptionState)
{
case ES_PASS:
// Let pass to debugger once, then catch it
result = EXCEPTION_CONTINUE_SEARCH;
s_exceptionState = ES_CATCH;
break;
case ES_CATCH:
// Catch it now. Reset to catch in debugger again next time.
result = EXCEPTION_EXECUTE_HANDLER;
s_exceptionState = ES_PASS;
break;
default:;
assert(false);
}
return result;
}
bool AmBeingDebugged()
{
if( IsDebuggerPresent() )
{
return true;
}
BOOL bRDebugPresent = FALSE;
CheckRemoteDebuggerPresent( GetModuleHandle(NULL), &bRDebugPresent );
if( FALSE == bRDebugPresent )
{
return false;
}
else
{
return true;
}
}
int SimpleExceptionFilter( void * nativeExceptionInfo, RuntimeProtector* pRuntimeProtector )
{
EXCEPTION_RECORD *pRecord = ((LPEXCEPTION_POINTERS) nativeExceptionInfo)->ExceptionRecord;
int nCode = pRecord->ExceptionCode;
pRuntimeProtector->ExceptionInfo.Type = RuntimeProtector::ESE_Unknown;
pRuntimeProtector->ExceptionInfo.Addr = 0;
if (nCode == EXCEPTION_ACCESS_VIOLATION)
{
ULONG_PTR flavour = pRecord->ExceptionInformation[0];
switch( flavour )
{
case 0:
pRuntimeProtector->ExceptionInfo.Type = RuntimeProtector::ESE_AccessViolationRead;
pRuntimeProtector->ExceptionInfo.Addr = (void*)pRecord->ExceptionInformation[1];
break;
case 1:
pRuntimeProtector->ExceptionInfo.Type = RuntimeProtector::ESE_AccessViolationWrite;
pRuntimeProtector->ExceptionInfo.Addr = (void*)pRecord->ExceptionInformation[1];
break;
default:
break;
}
}
else if( nCode == EXCEPTION_ILLEGAL_INSTRUCTION )
{
pRuntimeProtector->ExceptionInfo.Type = RuntimeProtector::ESE_InvalidInstruction;
pRuntimeProtector->ExceptionInfo.Addr = pRecord->ExceptionAddress;
}
if( !pRuntimeProtector->m_bHintAllowDebug )
{
// We don't want debugging to catch this
return EXCEPTION_EXECUTE_HANDLER;
}
// Otherwise fall back
return RuntimeExceptionFilter();
}
};
void RuntimeObjectSystem::CreatePlatformImpl()
{
m_pImpl = new PlatformImpl();
}
void RuntimeObjectSystem::DeletePlatformImpl()
{
delete m_pImpl;
}
void RuntimeObjectSystem::SetProtectionEnabled( bool bProtectionEnabled_ )
{
m_bProtectionEnabled = bProtectionEnabled_;
}
bool RuntimeObjectSystem::TryProtectedFunction( RuntimeProtector* pProtectedObject_ )
{
bool bJustCaughtException = false;
if( m_TotalLoadedModulesEver != pProtectedObject_->m_ModulesLoadedCount )
{
// clear exceptions if we've just loaded a new module
pProtectedObject_->m_ModulesLoadedCount = m_TotalLoadedModulesEver;
pProtectedObject_->m_bHashadException = false;
}
if( m_bProtectionEnabled )
{
if( !pProtectedObject_->m_bHashadException )
{
__try
{
pProtectedObject_->ProtectedFunc();
}
__except( m_pImpl->SimpleExceptionFilter( GetExceptionInformation(), pProtectedObject_ ) )
{
// If we hit any structured exception, exceptionInfo will be initialized
// If it's one we recognise and we hinted for no debugging, we'll go straight here, with info filled out
// If not we'll go to debugger first, then here
pProtectedObject_->m_bHashadException = true;
bJustCaughtException = true;
}
}
}
else
{
pProtectedObject_->m_bHashadException = false;
pProtectedObject_->ProtectedFunc();
}
return !bJustCaughtException;
}
bool RuntimeObjectSystem::TestBuildWaitAndUpdate()
{
Sleep( 100 );
MSG msg;
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
DispatchMessage( &msg );
}
return true;
}

View File

@ -1,86 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef _WIN32
#include <setjmp.h> // used by posix type systems to chain handling
#endif
// class RuntimeProtector
// overload void ProtectedFunc() to use, put function context (io) in new members
// do not create threads within protected function
// for threaded usuage use a protector per thread
// amortize virtual function call and exception handling by processing many things in one call
// note this isn't a functor as we prefer the explicit function name, and not using lambda's due to Cx11
// not being supported sufficiently as yet
struct RuntimeProtector
{
// consctructor, hint allow debug may be ignored when true if on an OS which has not had this implemented
RuntimeProtector()
: m_bHashadException( false )
, m_bHintAllowDebug( true )
, m_ModulesLoadedCount( 0 )
#ifndef _WIN32
, m_pPrevious( 0 )
#endif
{
}
virtual ~RuntimeProtector() {}
// don't call this directly, derive a class and implement it for your protected func
virtual void ProtectedFunc() = 0;
bool HasHadException() const
{
return m_bHashadException;
}
void ClearExceptions()
{
m_bHashadException = false;
}
//exception information (exposed rather than get/set for simplicity)
enum ExceptionType
{
ESE_Unknown,
ESE_AccessViolation,
ESE_AccessViolationRead, //may just get ESE_AccessViolation
ESE_AccessViolationWrite, //may just get ESE_AccessViolation
ESE_InvalidInstruction
};
struct ExceptionInfo_t
{
ExceptionType Type;
void* Addr; //address of data for access voilation, or instruction for invalid instruction
};
ExceptionInfo_t ExceptionInfo;
bool m_bHashadException;
bool m_bHintAllowDebug; // some RuntimeProtectors may not want to allow debug
// internal
unsigned int m_ModulesLoadedCount; // used internally to reset exceptions when a new module is loaded
#ifndef _WIN32
jmp_buf m_env;
RuntimeProtector* m_pPrevious; // used by posix type systems to chain handling
#endif
};

View File

@ -1,131 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef RUNTIMESOURCEDEPENDENCY_INCLUDED
#define RUNTIMESOURCEDEPENDENCY_INCLUDED
//NOTE: the file macro will only emit the full path if /FC option is used in visual studio or /ZI (Which forces /FC)
//Following creates a list of files which are runtime modifiable, to be used in headers
//requires use of __COUNTER__ predefined macro, which is in gcc 4.3+, clang/llvm and MSVC
// Source Dependencies are constructed from a macro template from sources which may include
// the __FILE__ macro, so to reduce inter-dependencies we return three values which are combined
// by the higher level code. The full source dependency filename is then pseudo-code:
// RemoveAnyFileName( relativeToPath ) + ReplaceExtension( filename, extension )
struct SourceDependencyInfo
{
static SourceDependencyInfo GetNULL() { SourceDependencyInfo ret = {0,0,0}; return ret; }
const char* filename; // If NULL then no SourceDependencyInfo
const char* extension; // If NULL then use extension in filename
const char* relativeToPath; // If NULL filename is either full or relative to known path
};
#ifndef RCCPPOFF
struct IRuntimeSourceDependencyList
{
IRuntimeSourceDependencyList( size_t max ) : MaxNum( max )
{
}
// GetIncludeFile may return 0, so you should iterate through to GetMaxNum() ignoring 0 returns
virtual SourceDependencyInfo GetSourceDependency( size_t Num_ ) const
{
return SourceDependencyInfo::GetNULL();
}
size_t MaxNum; // initialized in constructor below
};
namespace
{
template< size_t COUNT > struct RuntimeSourceDependency : RuntimeSourceDependency<COUNT-1>
{
RuntimeSourceDependency( size_t max ) : RuntimeSourceDependency<COUNT-1>( max )
{
}
RuntimeSourceDependency() : RuntimeSourceDependency<COUNT-1>( COUNT )
{
}
virtual SourceDependencyInfo GetSourceDependency( size_t Num_ ) const
{
if( Num_ < COUNT )
{
return this->RuntimeSourceDependency< COUNT-1 >::GetSourceDependency( Num_ );
}
else return SourceDependencyInfo::GetNULL();
}
};
template<> struct RuntimeSourceDependency<0> : IRuntimeSourceDependencyList
{
RuntimeSourceDependency( size_t max ) : IRuntimeSourceDependencyList( max )
{
}
RuntimeSourceDependency() : IRuntimeSourceDependencyList( 0 )
{
}
virtual SourceDependencyInfo GetSourceDependency( size_t Num_ ) const
{
return SourceDependencyInfo::GetNULL();
}
};
#define RUNTIME_COMPILER_SOURCEDEPENDENCY_BASE( SOURCEFILE, SOURCEEXT, RELATIVEPATHTO, N ) \
template<> struct RuntimeSourceDependency< N + 1 > : RuntimeSourceDependency< N >\
{ \
RuntimeSourceDependency( size_t max ) : RuntimeSourceDependency<N>( max ) {} \
RuntimeSourceDependency< N + 1 >() : RuntimeSourceDependency<N>( N + 1 ) {} \
virtual SourceDependencyInfo GetSourceDependency( size_t Num_ ) const \
{ \
if( Num_ <= N ) \
{ \
if( Num_ == N ) \
{ \
return { SOURCEFILE, SOURCEEXT, RELATIVEPATHTO }; \
} \
else return this->RuntimeSourceDependency< N >::GetSourceDependency( Num_ ); \
} \
else return SourceDependencyInfo::GetNULL(); \
} \
}; \
// The RUNTIME_COMPILER_SOURCEDEPENDENCY macro will return the name of the current file, which should be a header file.
// The runtime system will strip off the extension and add .cpp
#define RUNTIME_COMPILER_SOURCEDEPENDENCY namespace { RUNTIME_COMPILER_SOURCEDEPENDENCY_BASE( __FILE__, ".cpp", 0, __COUNTER__ ) }
// if you want to specify another extension use this version:
#define RUNTIME_COMPILER_SOURCEDEPENDENCY_EXT( EXT_ ) namespace { RUNTIME_COMPILER_SOURCEDEPENDENCY_BASE( __FILE__, EXT_, 0, __COUNTER__ ) }
// for complete freedom of which file to specify, use this version (FILE_ is relative to current file path):
#define RUNTIME_COMPILER_SOURCEDEPENDENCY_FILE( FILE_, EXT_ ) namespace { RUNTIME_COMPILER_SOURCEDEPENDENCY_BASE( FILE_, EXT_, __FILE__, __COUNTER__ ) }
}
#else
#define RUNTIME_COMPILER_SOURCEDEPENDENCY
#endif //RCCPPOFF
#endif //RUNTIMESOURCEDEPENDENCY_INCLUDED

View File

@ -1,130 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "SimpleSerializer.h"
#include <assert.h>
#include "../../RuntimeObjectSystem/IObject.h"
SimpleSerializer::SimpleSerializer()
: m_numProperties(0)
, m_bLoading( false )
, m_pCurrentObject( 0 )
{
}
SimpleSerializer::~SimpleSerializer()
{
Clear();
}
void SimpleSerializer::Clear()
{
TSerializationMap::iterator it = m_map.begin();
while (it != m_map.end())
{
TValueGroup::iterator it2 = it->second.begin();
while (it2 != it->second.end())
{
delete it2->second;
++it2;
}
++it;
}
}
void SimpleSerializer::Clear(ObjectId ownerId)
{
TSerializationMap::iterator found = m_map.find(ownerId);
if (found != m_map.end())
{
TValueGroup::iterator it = found->second.begin();
while (it != found->second.end())
{
delete it->second;
++it;
}
}
}
void SimpleSerializer::Clear(ObjectId ownerId, const char* propertyName)
{
TSerializationMap::iterator found = m_map.find(ownerId);
if (found != m_map.end())
{
TValueGroup::iterator propertyFound = found->second.find(propertyName);
if (propertyFound != found->second.end())
{
delete propertyFound->second;
found->second.erase(propertyFound);
}
}
}
void SimpleSerializer::Serialize( IObject* pObject )
{
assert( pObject );
assert( 0 == m_pCurrentObject ); //should not serialize an object from within another
m_pCurrentObject = pObject;
ObjectId ownerId;
m_pCurrentObject->GetObjectId(ownerId);
// gSys->pLogSystem->Log( eLV_COMMENTS, "SimpleSerialiser: Serialising %s object: objectIdtype \"%s\", perTypeID:%d, address:0x%p\n"
// , m_bLoading ? "in" : "out", pObject->GetTypeName(), ownerId.m_PerTypeId, pObject );
m_CurrentSerialization = m_map.find(ownerId);
m_pCurrentObject->Serialize( this );
//reset m_pCurrentObject
m_pCurrentObject = 0;
}
void SimpleSerializer::SetISerializedValue(const char* propertyName, const ISerializedValue* pValue)
{
assert( m_pCurrentObject );
assert(pValue);
if( m_CurrentSerialization == m_map.end() )
{
ObjectId ownerId;
m_pCurrentObject->GetObjectId(ownerId);
m_map[ownerId][propertyName] = pValue;
m_CurrentSerialization = m_map.find(ownerId);
}
m_CurrentSerialization->second[propertyName] = pValue;
}
const ISerializedValue* SimpleSerializer::GetISerializedValue(const char* propertyName) const
{
assert( m_pCurrentObject );
assert( propertyName );
assert( m_bLoading );
const ISerializedValue* pRet = NULL;
//TSerializationMap::const_iterator found = m_map.find(ownerId);
if (m_CurrentSerialization != m_map.end())
{
TValueGroup::const_iterator propertyFound = m_CurrentSerialization->second.find(propertyName);
if (propertyFound != m_CurrentSerialization->second.end())
{
pRet = propertyFound->second;
}
}
return pRet;
}

View File

@ -1,73 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef SIMPLESERIALIZER_INCLUDED
#define SIMPLESERIALIZER_INCLUDED
#include "../ISimpleSerializer.h"
#include <map>
#include <string>
struct IObject;
class SimpleSerializer : public ISimpleSerializer
{
public:
SimpleSerializer();
virtual ~SimpleSerializer();
// ISimpleSerializer
void Clear();
void Clear(ObjectId ownerId);
void Clear(ObjectId ownerId, const char* propertyName);
void Serialize( IObject* Object );
void SetISerializedValue(const char* propertyName, const ISerializedValue* pValue);
const ISerializedValue *GetISerializedValue(const char* propertyName) const;
virtual bool IsLoading() const
{
return m_bLoading;
}
void SetIsLoading( bool loading )
{
m_bLoading = loading;
m_pCurrentObject = 0;
}
// ~ISimpleSerializer
private:
typedef std::map<std::string, const ISerializedValue*> TValueGroup;
typedef std::map<ObjectId, TValueGroup> TSerializationMap;
TSerializationMap m_map;
int m_numProperties;
bool m_bLoading;
IObject* m_pCurrentObject;
TSerializationMap::iterator m_CurrentSerialization;
};
#endif // SIMPLESERIALIZER_INCLUDED

View File

@ -1,142 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.lib.debug.860035198">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.lib.debug.860035198" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Systems"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Systems/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="Systems" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.lib.debug.860035198" name="Debug" parent="cdt.managedbuild.config.gnu.lib.debug">
<folderInfo id="cdt.managedbuild.config.gnu.lib.debug.860035198." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.lib.debug.175074654" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.lib.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.lib.debug.2062249829" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.lib.debug"/>
<builder buildPath="${workspace_loc:/Systems}/Debug" id="cdt.managedbuild.target.gnu.builder.lib.debug.78366013" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.lib.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.lib.debug.1280907465" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.debug"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug.1821526338" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug">
<option id="gnu.cpp.compiler.lib.debug.option.optimization.level.1086951588" name="Optimization Level" superClass="gnu.cpp.compiler.lib.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.lib.debug.option.debugging.level.901718784" name="Debug Level" superClass="gnu.cpp.compiler.lib.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.1764530289" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/External/glfw/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/External/libRocket/Include}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.710250828" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.debug.1378813775" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.lib.debug.option.optimization.level.1451554492" name="Optimization Level" superClass="gnu.c.compiler.lib.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.lib.debug.option.debugging.level.290948634" name="Debug Level" superClass="gnu.c.compiler.lib.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2068178206" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.522171818" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1598674831" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.lib.debug.866658230" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.931738070" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.lib.release.1748641566">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.lib.release.1748641566" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Systems"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Systems/Release"/>
<entry flags="RESOLVED" kind="libraryFile" name="Systems" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.lib.release.1748641566" name="Release" parent="cdt.managedbuild.config.gnu.lib.release">
<folderInfo id="cdt.managedbuild.config.gnu.lib.release.1748641566." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.lib.release.1559382567" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.lib.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.lib.release.1423398317" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.lib.release"/>
<builder buildPath="${workspace_loc:/Systems}/Release" id="cdt.managedbuild.target.gnu.builder.lib.release.640295213" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.lib.release"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.lib.release.1987092875" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.release"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release.392520281" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release">
<option id="gnu.cpp.compiler.lib.release.option.optimization.level.1830103707" name="Optimization Level" superClass="gnu.cpp.compiler.lib.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.lib.release.option.debugging.level.2020609050" name="Debug Level" superClass="gnu.cpp.compiler.lib.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.1914817276" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/External/glfw/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/External/libRocket/Include}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1158218638" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.release.1786368493" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.lib.release.option.optimization.level.1835847589" name="Optimization Level" superClass="gnu.c.compiler.lib.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.lib.release.option.debugging.level.713004075" name="Debug Level" superClass="gnu.c.compiler.lib.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.932000691" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.1580172071" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.389213345" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.lib.release.1513327439" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1706693769" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="Systems.cdt.managedbuild.target.gnu.lib.431153185" name="Static Library" projectType="cdt.managedbuild.target.gnu.lib"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.debug.860035198;cdt.managedbuild.config.gnu.lib.debug.860035198.;cdt.managedbuild.tool.gnu.c.compiler.lib.debug.1378813775;cdt.managedbuild.tool.gnu.c.compiler.input.2068178206">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.2005646078;cdt.managedbuild.config.gnu.exe.debug.2005646078.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.687695312;cdt.managedbuild.tool.gnu.c.compiler.input.425611365">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.release.1748641566;cdt.managedbuild.config.gnu.lib.release.1748641566.;cdt.managedbuild.tool.gnu.cpp.compiler.lib.release.392520281;cdt.managedbuild.tool.gnu.cpp.compiler.input.1158218638">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.release.1748641566;cdt.managedbuild.config.gnu.lib.release.1748641566.;cdt.managedbuild.tool.gnu.c.compiler.lib.release.1786368493;cdt.managedbuild.tool.gnu.c.compiler.input.932000691">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1672253013;cdt.managedbuild.config.gnu.exe.release.1672253013.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.121131410;cdt.managedbuild.tool.gnu.cpp.compiler.input.979990569">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.2005646078;cdt.managedbuild.config.gnu.exe.debug.2005646078.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.2012223656;cdt.managedbuild.tool.gnu.cpp.compiler.input.566622792">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.lib.debug.860035198;cdt.managedbuild.config.gnu.lib.debug.860035198.;cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug.1821526338;cdt.managedbuild.tool.gnu.cpp.compiler.input.710250828">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1672253013;cdt.managedbuild.config.gnu.exe.release.1672253013.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1465361180;cdt.managedbuild.tool.gnu.c.compiler.input.1617300142">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Release">
<resource resourceType="PROJECT" workspacePath="/Systems"/>
</configuration>
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/Systems"/>
</configuration>
</storageModule>
</cproject>

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Systems</name>
<comment></comment>
<projects>
<project>Renderer</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -1,121 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "AssetSystem.h"
#include "../../Renderer/AURenMesh.h"
#include "../../RuntimeCompiler/FileSystemUtils.h"
AssetSystem::AssetSystem(const char* AssetDirName_)
{
//search for asset directory
FileSystemUtils::Path currPath;
currPath = FileSystemUtils::GetCurrentPath();
bool bAssetDirFound = false;
//test root and downwards for directory
while( currPath.HasParentPath() )
{
FileSystemUtils::Path testPath = currPath / AssetDirName_;
if( testPath.Exists() )
{
bAssetDirFound = true;
m_AssetDirectory = testPath.m_string;
break;
}
currPath = currPath.ParentPath();
}
if( !bAssetDirFound )
{
//could be a development build, so test location of this source file and down
currPath = __FILE__;
if(currPath.Exists() )
{
while( currPath.HasParentPath() )
{
FileSystemUtils::Path testPath = currPath / AssetDirName_;
if( testPath.Exists() )
{
bAssetDirFound = true;
m_AssetDirectory = testPath.m_string;
break;
}
currPath = currPath.ParentPath();
}
}
}
}
AssetSystem::~AssetSystem()
{
MESHMAP::iterator currMesh = m_Meshes.begin();
while( currMesh != m_Meshes.end() )
{
delete currMesh->second;
++currMesh;
}
}
IAURenderableMesh* AssetSystem::CreateRenderableMeshFromFile( const char* pFilename )
{
IAURenderableMesh* pRenMesh= 0;
std::string filename( pFilename );
MESHMAP::iterator found = m_Meshes.find( filename );
if( found != m_Meshes.end() )
{
pRenMesh = new AURenderableMesh( found->second );
}
else
{
std::string fileToLoad( pFilename );
FindFile( fileToLoad );
AURenMesh* pMesh = new AURenMesh;
pMesh->LoadFromFile( fileToLoad );
m_Meshes[ filename ] = pMesh; //use passed in filename for map
pRenMesh = new AURenderableMesh( pMesh );
}
return pRenMesh;
}
void AssetSystem::DestroyRenderableMesh(IAURenderableMesh* pMesh)
{
delete pMesh;
}
bool AssetSystem::FindFile( std::string& filename )
{
if( FileSystemUtils::Path( filename ).Exists() )
{
return true;
}
//else try in asset directory
FileSystemUtils::Path testpath = m_AssetDirectory;
testpath = testpath / filename;
if( testpath.Exists() )
{
filename = testpath.m_string;
return true;
}
return false;
}

View File

@ -1,50 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef ASSETSYSTEM_INCLUDED
#define ASSETSYSTEM_INCLUDED
#include "../IAssetSystem.h"
#include <map>
#include <string>
class AURenMesh;
class AssetSystem : public IAssetSystem
{
public:
AssetSystem( const char* AssetDirName_ );
virtual ~AssetSystem();
virtual IAURenderableMesh* CreateRenderableMeshFromFile( const char* pFilename );
virtual void DestroyRenderableMesh( IAURenderableMesh* pMesh );
virtual const char* GetAssetDirectory() const
{
return m_AssetDirectory.c_str();
}
private:
bool FindFile( std::string& filename );
typedef std::map<std::string, AURenMesh*> MESHMAP;
MESHMAP m_Meshes;
std::string m_AssetDirectory;
};
#endif //ASSETSYSTEM_INCLUDED

View File

@ -1,50 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef DEFINITIONS_DEFINED
#define DEFINITIONS_DEFINED
#ifndef _WIN32
//the following won't work with the templated variety
#define _snprintf_s(a,b,c,...) snprintf(a,b,__VA_ARGS__)
#endif
// All typedefs, defines and macros start AU_ to avoid conflicts
typedef int AUEntityId; // (Will be a) salted id for uniquely identifying entities
struct IRuntimeObjectSystem;
struct IEntitySystem;
struct ITimeSystem;
struct ILogSystem;
struct IAssetSystem;
struct IAUEntity;
struct IAURenderable;
struct IAURenderableMesh;
struct IAUUpdateable;
struct ISimpleSerializer;
struct IObjectFactorySystem;
struct IGUISystem;
struct IFileChangeNotifier;
struct IGame;
class CalSound;
#endif // DEFINITIONS_DEFINED

View File

@ -1,138 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
// Implementation
// Apply salts and buffer reuse later
#include "EntitySystem.h"
#include "../../Renderer/IAURenderable.h"
#include "../IUpdateable.h"
#include <assert.h>
//#include physics etc proxies for delete
void EntitySystem::Entity::SetName(const char * sName)
{
if (sName && sName[0])
{
#ifdef _WIN32
strncpy_s(m_sName, sName, AU_ENTITY_NAME_LENGTH);
#else
strncpy(m_sName,sName,AU_ENTITY_NAME_LENGTH);
#endif
m_sName[AU_ENTITY_NAME_LENGTH-1] = '\0';
// Could re length warn here
}
else
{
m_sName[0] = '\0';
// And here
}
}
void EntitySystem::Entity::SetObject(IEntityObject *pObject) { m_pObject = pObject; } // Not safe to delete, created in DLLs...
void EntitySystem::Entity::SetRenderable(IAURenderable *pRenderable) { m_pRenderable = pRenderable; } // Not safe to delete, created in DLLs...
void EntitySystem::Entity::SetUpdateable(IAUUpdateable *pUpdateable) { m_pUpdateable = pUpdateable; } // Not safe to delete, created in DLLs...
AUEntityId EntitySystem::Create(const char * sName)
{
Entity *pEntity = new Entity(m_nextId++);
pEntity->SetName(sName);
m_Entities[pEntity->GetId()] = pEntity;
return pEntity->GetId();
}
bool EntitySystem::Destroy(AUEntityId id)
{
TCESEntities::iterator it = m_Entities.find(id);
if (it != m_Entities.end())
{
IAUEntity *pEntity = it->second;
delete pEntity;
m_Entities.erase(it);
return true;
}
return false;
}
IAUEntity * EntitySystem::Get(AUEntityId id)
{
TCESEntities::iterator it = m_Entities.find(id);
if (it != m_Entities.end())
{
return it->second;
}
return NULL;
}
IAUEntity * EntitySystem::Get(const char * sName)
{
if (sName != NULL && *sName != '\0')
{
TCESEntities::iterator it = m_Entities.begin();
TCESEntities::iterator itEnd = m_Entities.end();
for (; it != itEnd; ++it)
{
if (!strcmp(it->second->GetName(), sName))
{
return it->second;
}
}
}
return NULL;
}
void EntitySystem::GetAll(IAUDynArray<AUEntityId> &entities) const
{
entities.Resize(m_Entities.size());
TCESEntities::const_iterator it = m_Entities.begin();
TCESEntities::const_iterator itEnd = m_Entities.end();
for(int i = 0; it != itEnd; ++it, ++i)
{
entities[i] = it->second->m_id;
}
}
void EntitySystem::Reset()
{
AUDynArray<AUEntityId> entities;
GetAll(entities);
for (size_t i = 0; i < entities.Size(); ++i)
{
Destroy(entities[i]);
}
assert(m_Entities.size() == 0);
}
EntitySystem::EntitySystem(void) : m_nextId(1)
{
}
EntitySystem::~EntitySystem(void)
{
}

View File

@ -1,105 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#include "../IEntitySystem.h"
#include <map>
class EntitySystem : public IEntitySystem
{
public:
/// IEntitySystem methods
AUEntityId Create(const char * sName);
bool Destroy(AUEntityId id);
IAUEntity * Get(AUEntityId id);
IAUEntity * Get(const char * sName);
void GetAll(IAUDynArray<AUEntityId> &entities) const;
void Reset();
/// New methods
EntitySystem(void);
~EntitySystem(void);
protected:
class Entity : public IAUEntity
{
public:
AUEntityId m_id;
IEntityObject* m_pObject;
IAURenderable* m_pRenderable;
//IAUTransform * m_pTransform
IAUUpdateable* m_pUpdateable;
AUVec3f m_vPos;
AUVec3f m_vScale;
AUOrientation3D m_vOrientation;
char m_sName[AU_ENTITY_NAME_LENGTH];
/// IAUEntity methods
AUEntityId GetId() const { return m_id; }
const char * GetName() const { return m_sName; }
void SetName(const char * _sName);
const IEntityObject * GetObject() const { return m_pObject; }
IEntityObject * GetObject() { return m_pObject; }
void SetObject(IEntityObject *pObject);
const IAURenderable * GetRenderable() const { return m_pRenderable; }
IAURenderable * GetRenderable() { return m_pRenderable; }
void SetRenderable(IAURenderable *pRender);
const IAUUpdateable * GetUpdateable() const { return m_pUpdateable; }
IAUUpdateable * GetUpdateable() { return m_pUpdateable; }
void SetUpdateable(IAUUpdateable *pUpdateable);
const AUVec3f& GetPosition() const { return m_vPos; }
AUVec3f& GetPosition() { return m_vPos; }
void SetPosition(const AUVec3f& vPos) { m_vPos = vPos; }
void SetPosition(float x, float y, float z) { m_vPos = AUVec3f(x, y, z); }
const AUVec3f& GetScale() const { return m_vScale; }
AUVec3f& GetScale() { return m_vScale; }
void SetScale(const AUVec3f& vScale) { m_vScale = vScale; }
void SetScale(float fScale) { m_vScale = AUVec3f(fScale, fScale, fScale); }
const AUOrientation3D& GetOrientation() const { return m_vOrientation; }
AUOrientation3D& GetOrientation() { return m_vOrientation; }
void SetOrientation(const AUOrientation3D& vOrientation) { m_vOrientation = vOrientation; }
void SetOrientation(float xForward, float yForward, float zForward, float xUp, float yUp, float zUp)
{
m_vOrientation = AUOrientation3D( AUVec3f(xForward, yForward, zForward), AUVec3f(xUp, yUp, zUp) );
}
/// New methods
Entity(AUEntityId id)
: m_id(id)
, m_pRenderable(0)
, m_pUpdateable(0)
, m_vScale(1.0f, 1.0f, 1.0f)
, m_pObject( NULL )
{ m_sName[0] = '\n'; }
};
typedef std::map<AUEntityId, Entity*> TCESEntities;
TCESEntities m_Entities;
AUEntityId m_nextId;
};

View File

@ -1,58 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "GUIDocument.h"
#include <Rocket/Core.h>
#include <assert.h>
GUIDocument::GUIDocument(IGUIInstancer* pInstancer, Rocket::Core::ElementDocument* pDocument, bool bHoldingRLReference)
: GUIElement(pInstancer, pDocument, bHoldingRLReference)
, m_pDocument(pDocument)
{
assert(m_pDocument);
}
GUIDocument::~GUIDocument()
{
}
IGUIElement* GUIDocument::Element()
{
return this;
}
void GUIDocument::Show()
{
m_pDocument->Show();
}
void GUIDocument::Hide()
{
m_pDocument->Hide();
}
void GUIDocument::AddReference()
{
GUIElement::AddReference();
}
void GUIDocument::RemoveReference()
{
GUIElement::RemoveReference();
}

View File

@ -1,51 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef GUIDOCUMENT_INCLUDED
#define GUIDOCUMENT_INCLUDED
#include "../IGUIDocument.h"
#include "GUIElement.h"
// Forward declare Rocket::Core::ElementDocument
namespace Rocket { namespace Core { class ElementDocument; } }
class GUIDocument : public GUIElement, public IGUIDocument
{
public:
GUIDocument(IGUIInstancer* pInstancer, Rocket::Core::ElementDocument* pDocument, bool bHoldingRLReference);
~GUIDocument();
// IGUIDocument
virtual IGUIElement* Element();
virtual void Show();
virtual void Hide();
virtual void AddReference();
virtual void RemoveReference();
// ~IGUIDocument
private:
Rocket::Core::ElementDocument* m_pDocument;
};
#endif // GUIDOCUMENT_INCLUDED

View File

@ -1,207 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "GUIElement.h"
#include "IGUIInstancer.h"
#include <Rocket/Core.h>
#include <Rocket/Core/EventListener.h>
#include <assert.h>
#include <map>
class GUIEvent : public IGUIEvent
{
public:
GUIEvent( Rocket::Core::Event& event )
: m_Event( event )
{
}
virtual void GetParameter(const char* parameter, char* buffer, size_t buffer_size ) const
{
Rocket::Core::String strvalue = "";
if( m_Event.GetParameters() )
{
m_Event.GetParameters()->GetInto( parameter, strvalue );
}
#ifdef _WIN32
strcpy_s( buffer, buffer_size, strvalue.CString() );
#else
strncpy( buffer, strvalue.CString(), buffer_size); //not quite the same, but similar safe effect.
#endif
}
private:
Rocket::Core::Event& m_Event;
};
class EventHolder : public Rocket::Core::EventListener
{
public:
static EventHolder* GetEventHolder( IGUIEventListener* pEvent )
{
std::map<IGUIEventListener*, EventHolder*>::iterator found = m_EventListeners.find( pEvent ) ;
if( found != m_EventListeners.end() )
{
return found->second;
}
else
{
return 0;
}
}
EventHolder( IGUIEventListener* pEvent )
: m_pEvent( pEvent )
{
//there should be no events registered for this id
assert( m_EventListeners.find( pEvent ) == m_EventListeners.end());
m_EventListeners[ pEvent ] = this;
}
~EventHolder()
{
m_EventListeners.erase( m_pEvent );
}
virtual void ProcessEvent(Rocket::Core::Event& event)
{
GUIEvent guiEvent( event );
m_pEvent->OnEvent( guiEvent );
}
private:
EventHolder();
EventHolder( EventHolder& event );
EventHolder& operator=( EventHolder& event );
IGUIEventListener* m_pEvent;
static std::map<IGUIEventListener*, EventHolder*> m_EventListeners;
};
std::map<IGUIEventListener*, EventHolder*> EventHolder::m_EventListeners;
GUIElement::GUIElement(IGUIInstancer* pInstancer, Rocket::Core::Element* pElement, bool bHoldingRLReference)
: m_pInstancer(pInstancer)
, m_pElement(pElement)
, m_bHoldingRLReference(bHoldingRLReference)
{
assert(m_pInstancer && m_pElement);
}
GUIElement::~GUIElement()
{
if (m_bHoldingRLReference)
{
m_pElement->RemoveReference();
}
}
void GUIElement::AddReference()
{
ReferenceCountable::AddReference();
}
void GUIElement::RemoveReference()
{
ReferenceCountable::RemoveReference();
}
void GUIElement::OnReferenceDeactivate()
{
m_pInstancer->Release(this);
}
const char* GUIElement::GetId() const
{
return m_pElement->GetId().CString();
}
void GUIElement::SetInnerRML(const char* content)
{
m_pElement->SetInnerRML(content);
}
void GUIElement::SetProperty(const char* name, const char* value)
{
m_pElement->SetProperty(name, value);
}
void GUIElement::GetAttribute(const char* attribute, char* buffer, size_t buffer_size ) const
{
if( buffer_size && buffer )
{
buffer[0] = 0;
Rocket::Core::Variant* pVar = m_pElement->GetAttribute(attribute);
if( pVar )
{
Rocket::Core::String strvalue;
pVar->GetInto( strvalue );
#ifdef _WIN32
strcpy_s( buffer, buffer_size, strvalue.CString() );
#else
strncpy( buffer, strvalue.CString(), buffer_size); //not quite the same, but similar safe effect.
#endif
}
}
}
void GUIElement::SetAttribute(const char* name, const char* value)
{
m_pElement->SetAttribute(name, value);
}
float GUIElement::GetClientWidth() const
{
return m_pElement->GetClientWidth();
}
float GUIElement::GetClientHeight() const
{
return m_pElement->GetClientHeight();
}
IGUIElement* GUIElement::GetElementById(const char* id)
{
Rocket::Core::Element* pElement = m_pElement->GetElementById(id);
if (pElement)
{
return m_pInstancer->InstanceElement(pElement, false);
}
return NULL;
}
void GUIElement::AddEventListener( const char* eventname, IGUIEventListener* pEventListener )
{
assert( m_pElement );
EventHolder* pEvent = new EventHolder( pEventListener );
m_pElement->AddEventListener( eventname, pEvent );
}
void GUIElement::RemoveEventListener( const char* eventname, IGUIEventListener* pEventListener)
{
assert( m_pElement );
EventHolder* pEvent = EventHolder::GetEventHolder( pEventListener );
assert( pEvent );
m_pElement->RemoveEventListener( eventname, pEvent );
delete pEvent;
}

View File

@ -1,70 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#pragma once
#ifndef GUIELEMENT_INCLUDED
#define GUIELEMENT_INCLUDED
#include "../IGUIElement.h"
#include "ReferenceCountable.h"
struct IGUIInstancer;
// Forward declare Rocket::Core::Element
namespace Rocket { namespace Core { class Element; } }
class GUIElement : public ReferenceCountable, public IGUIElement
{
public:
GUIElement(IGUIInstancer* pInstancer, Rocket::Core::Element* pElement, bool bHoldingRLReference);
virtual ~GUIElement();
// IGUIElement
virtual const char* GetId() const;
virtual void SetInnerRML(const char* content);
virtual void SetProperty(const char* name, const char* value);
virtual IGUIElement* GetElementById(const char* id);
virtual void GetAttribute(const char* attribute, char* buffer, size_t buffer_size ) const;
virtual void SetAttribute(const char* name, const char* value);
virtual float GetClientWidth() const;
virtual float GetClientHeight() const;
virtual void AddReference();
virtual void RemoveReference();
virtual void AddEventListener( const char* eventname, IGUIEventListener* pEventListener );
virtual void RemoveEventListener( const char* eventname, IGUIEventListener* pEventListener );
// ~IGUIElement
protected:
// ReferenceCountable
virtual void OnReferenceDeactivate();
// ~ReferenceCountable
private:
Rocket::Core::Element* m_pElement;
IGUIInstancer* m_pInstancer;
bool m_bHoldingRLReference;
};
#endif // GUIELEMENT_INCLUDED

View File

@ -1,132 +0,0 @@
//
// Copyright (c) 2010-2011 Matthew Jack and Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#include "GUISystem.h"
#include "GUIElement.h"
#include "GUIDocument.h"
#include <Rocket/Core.h>
#include <Rocket/Debugger.h>
#include <assert.h>
GUISystem::GUISystem() : m_pContext(0)
{
}
GUISystem::~GUISystem()
{
TInstancedElements::iterator it = m_instanced.begin();
TInstancedElements::iterator itEnd = m_instanced.end();
while (it != itEnd)
{
delete *it;
++it;
}
}
void GUISystem::SetContext(Rocket::Core::Context* pContext)
{
m_pContext = pContext;
assert(m_pContext);
}
void GUISystem::ClearStyleSheetCache()
{
Rocket::Core::Factory::ClearStyleSheetCache();
}
IGUIDocument* GUISystem::LoadDocument(const char* file, const char* id)
{
assert(m_pContext);
// Check for an existing document with this ID
Rocket::Core::ElementDocument* pExisting = m_pContext->GetDocument(id);
Rocket::Core::ElementDocument* pED = m_pContext->LoadDocument(file);
if (pED)
{
if (pExisting)
{
// Delete existing document now that new one has been successfully loaded
pExisting->Hide();
m_pContext->UnloadDocument(pExisting);
}
pED->SetId(id);
return InstanceDocument(pED, true);
}
return NULL;
}
IGUIDocument* GUISystem::GetDocument(const char* id)
{
assert(m_pContext);
Rocket::Core::ElementDocument* pED = m_pContext->GetDocument(id);
if (pED)
{
return InstanceDocument(pED, false);
}
return NULL;
}
IGUIElement* GUISystem::GetLogElement()
{
Rocket::Core::Element* pElement = Rocket::Debugger::GetLogElement();
if (pElement)
{
return InstanceElement(pElement, false);
}
return NULL;
}
GUIElement* GUISystem::InstanceElement(Rocket::Core::Element* pElement, bool bHoldingRLReference)
{
GUIElement* pGUIElement = new GUIElement(this, pElement, bHoldingRLReference);
m_instanced.insert(pGUIElement);
return pGUIElement;
}
GUIDocument* GUISystem::InstanceDocument(Rocket::Core::ElementDocument* pDocument, bool bHoldingRLReference)
{
GUIDocument* pGUIDocument = new GUIDocument(this, pDocument, bHoldingRLReference);
m_instanced.insert(pGUIDocument);
return pGUIDocument;
}
void GUISystem::Release(GUIElement* pElement)
{
GUIElement* pGUIElement = static_cast<GUIElement*>(pElement);
TInstancedElements::iterator it = m_instanced.find(pGUIElement);
assert(it != m_instanced.end());
if (it != m_instanced.end())
{
delete *it;
m_instanced.erase(it);
}
}

Some files were not shown because too many files have changed in this diff Show More