Commit 2a6157cf authored by Mark Frohnmayer's avatar Mark Frohnmayer
Browse files

cleaning up TNL

parent d1f50484
Loading
Loading
Loading
Loading

tnl-1.N/core/core.h

deleted100644 → 0
+0 −60
Original line number Diff line number Diff line
//-----------------------------------------------------------------------------------
//
//   Torque Core Library
//   Copyright (C) 2005 GarageGames.com, Inc.
//   For more information see http://www.opentnl.org
//
//   This program is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation; either version 2 of the License, or
//   (at your option) any later version.
//
//   For use in products that are not compatible with the terms of the GNU 
//   General Public License, alternative licensing options are available 
//   from GarageGames.com.
//
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
//------------------------------------------------------------------------------------

#ifndef _CORE_H_
#define _CORE_H_

/// The Core namespace contains utility classes and base types used by Torque engine
/// components.
namespace TNL
{
};

#if defined(_DEBUG)
#include <crtdbg.h>
#endif

#ifndef _CORE_TYPES_H_
#include "core/coreTypes.h"
#endif

#ifndef _CORE_ASSERT_H_
#include "core/coreAssert.h"
#endif

#ifndef _CORE_ENDIAN_H_
#include "core/coreEndian.h"
#endif

#ifndef _CORE_PLATFORM_H_
#include "core/corePlatform.h"
#endif

#ifndef _CORE_HELPERS_H_
#include "core/coreHelpers.h"
#endif

#endif
 No newline at end of file

tnl-1.N/core/core.vcproj

deleted100644 → 0
+0 −345
Original line number Diff line number Diff line
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
	ProjectType="Visual C++"
	Version="8.00"
	Name="core"
	ProjectGUID="{6A753ED7-6441-4E1C-922C-1691450AEFB0}"
	Keyword="Win32Proj"
	>
	<Platforms>
		<Platform
			Name="Win32"
		/>
	</Platforms>
	<ToolFiles>
	</ToolFiles>
	<Configurations>
		<Configuration
			Name="Debug|Win32"
			OutputDirectory="Debug"
			IntermediateDirectory="Debug"
			ConfigurationType="4"
			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
			CharacterSet="2"
			>
			<Tool
				Name="VCPreBuildEventTool"
			/>
			<Tool
				Name="VCCustomBuildTool"
			/>
			<Tool
				Name="VCXMLDataGeneratorTool"
			/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"
			/>
			<Tool
				Name="VCMIDLTool"
			/>
			<Tool
				Name="VCCLCompilerTool"
				Optimization="0"
				AdditionalIncludeDirectories="../../lib/libtomcrypt;.."
				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;TORQUE_DEBUG;TORQUE_ENABLE_LOGGING"
				MinimalRebuild="true"
				BasicRuntimeChecks="3"
				RuntimeLibrary="1"
				UsePrecompiledHeader="0"
				WarningLevel="3"
				Detect64BitPortabilityProblems="false"
				DebugInformationFormat="4"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
			/>
			<Tool
				Name="VCPreLinkEventTool"
			/>
			<Tool
				Name="VCLibrarianTool"
				OutputFile="../cored.lib"
			/>
			<Tool
				Name="VCALinkTool"
			/>
			<Tool
				Name="VCXDCMakeTool"
			/>
			<Tool
				Name="VCBscMakeTool"
			/>
			<Tool
				Name="VCFxCopTool"
			/>
			<Tool
				Name="VCPostBuildEventTool"
			/>
		</Configuration>
		<Configuration
			Name="Release|Win32"
			OutputDirectory="Release"
			IntermediateDirectory="Release"
			ConfigurationType="4"
			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
			CharacterSet="2"
			>
			<Tool
				Name="VCPreBuildEventTool"
			/>
			<Tool
				Name="VCCustomBuildTool"
			/>
			<Tool
				Name="VCXMLDataGeneratorTool"
			/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"
			/>
			<Tool
				Name="VCMIDLTool"
			/>
			<Tool
				Name="VCCLCompilerTool"
				AdditionalIncludeDirectories="../../lib/libtomcrypt;.."
				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
				RuntimeLibrary="0"
				UsePrecompiledHeader="0"
				WarningLevel="3"
				Detect64BitPortabilityProblems="false"
				DebugInformationFormat="3"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
			/>
			<Tool
				Name="VCPreLinkEventTool"
			/>
			<Tool
				Name="VCLibrarianTool"
				OutputFile="../core.lib"
			/>
			<Tool
				Name="VCALinkTool"
			/>
			<Tool
				Name="VCXDCMakeTool"
			/>
			<Tool
				Name="VCBscMakeTool"
			/>
			<Tool
				Name="VCFxCopTool"
			/>
			<Tool
				Name="VCPostBuildEventTool"
			/>
		</Configuration>
		<Configuration
			Name="Ship|Win32"
			OutputDirectory="$(ConfigurationName)"
			IntermediateDirectory="$(ConfigurationName)"
			ConfigurationType="4"
			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
			CharacterSet="2"
			>
			<Tool
				Name="VCPreBuildEventTool"
			/>
			<Tool
				Name="VCCustomBuildTool"
			/>
			<Tool
				Name="VCXMLDataGeneratorTool"
			/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"
			/>
			<Tool
				Name="VCMIDLTool"
			/>
			<Tool
				Name="VCCLCompilerTool"
				AdditionalIncludeDirectories="../../lib/libtomcrypt;.."
				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;SHIP_BUILD"
				RuntimeLibrary="0"
				UsePrecompiledHeader="0"
				WarningLevel="3"
				Detect64BitPortabilityProblems="false"
				DebugInformationFormat="3"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
			/>
			<Tool
				Name="VCPreLinkEventTool"
			/>
			<Tool
				Name="VCLibrarianTool"
				OutputFile="../core.lib"
			/>
			<Tool
				Name="VCALinkTool"
			/>
			<Tool
				Name="VCXDCMakeTool"
			/>
			<Tool
				Name="VCBscMakeTool"
			/>
			<Tool
				Name="VCFxCopTool"
			/>
			<Tool
				Name="VCPostBuildEventTool"
			/>
		</Configuration>
	</Configurations>
	<References>
	</References>
	<Files>
		<File
			RelativePath=".\core.h"
			>
		</File>
		<File
			RelativePath=".\coreAssert.cpp"
			>
		</File>
		<File
			RelativePath=".\coreAssert.h"
			>
		</File>
		<File
			RelativePath=".\coreBitSet.h"
			>
		</File>
		<File
			RelativePath=".\coreBitStream.cpp"
			>
		</File>
		<File
			RelativePath=".\coreBitStream.h"
			>
		</File>
		<File
			RelativePath=".\coreByteBuffer.cpp"
			>
		</File>
		<File
			RelativePath=".\coreByteBuffer.h"
			>
		</File>
		<File
			RelativePath=".\coreDataChunker.cpp"
			>
		</File>
		<File
			RelativePath=".\coreDataChunker.h"
			>
		</File>
		<File
			RelativePath=".\coreEndian.h"
			>
		</File>
		<File
			RelativePath=".\coreHelpers.h"
			>
		</File>
		<File
			RelativePath=".\coreHuffmanStringProcessor.cpp"
			>
		</File>
		<File
			RelativePath=".\coreHuffmanStringProcessor.h"
			>
		</File>
		<File
			RelativePath=".\coreJournal.cpp"
			>
		</File>
		<File
			RelativePath=".\coreJournal.h"
			>
		</File>
		<File
			RelativePath=".\coreLog.cpp"
			>
		</File>
		<File
			RelativePath=".\coreLog.h"
			>
		</File>
		<File
			RelativePath=".\coreMethodDispatch.cpp"
			>
		</File>
		<File
			RelativePath=".\coreMethodDispatch.h"
			>
		</File>
		<File
			RelativePath=".\coreObject.cpp"
			>
		</File>
		<File
			RelativePath=".\coreObject.h"
			>
		</File>
		<File
			RelativePath=".\corePlatform.cpp"
			>
		</File>
		<File
			RelativePath=".\corePlatform.h"
			>
		</File>
		<File
			RelativePath=".\coreSingleton.h"
			>
		</File>
		<File
			RelativePath=".\coreString.h"
			>
		</File>
		<File
			RelativePath=".\coreStringTable.cpp"
			>
		</File>
		<File
			RelativePath=".\coreStringTable.h"
			>
		</File>
		<File
			RelativePath=".\coreThread.cpp"
			>
		</File>
		<File
			RelativePath=".\coreThread.h"
			>
		</File>
		<File
			RelativePath=".\coreTypes.h"
			>
		</File>
		<File
			RelativePath=".\coreVector.cpp"
			>
		</File>
		<File
			RelativePath=".\coreVector.h"
			>
		</File>
	</Files>
	<Globals>
	</Globals>
</VisualStudioProject>

tnl-1.N/core/coreAssert.cpp

deleted100644 → 0
+0 −85
Original line number Diff line number Diff line
//-----------------------------------------------------------------------------------
//
//   Torque Core Library
//   Copyright (C) 2005 GarageGames.com, Inc.
//   For more information see http://www.opentnl.org
//
//   This program is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation; either version 2 of the License, or
//   (at your option) any later version.
//
//   For use in products that are not compatible with the terms of the GNU 
//   General Public License, alternative licensing options are available 
//   from GarageGames.com.
//
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
//------------------------------------------------------------------------------------

#include "core/core.h"
#include "core/coreAssert.h"
#include <stdarg.h>
#include "core/coreLog.h"

namespace TNL {

#ifdef TORQUE_ENABLE_ASSERTS

//-------------------------------------- STATIC Declaration
static bool processing = false;

//--------------------------------------
static bool displayMessageBox(const char *title, const char *message, bool retry)
{
   if (retry)
      return AlertRetry(title, message);

   AlertOK(title, message);
   return false;
}   

//--------------------------------------
void Assert::processAssert(const char *filename, U32 lineNumber, const char  *message)
{
   processing = true;

   char buffer[2048];
   dSprintf(buffer, sizeof(buffer), "Fatal: (%s: %ld)", filename, lineNumber);
#ifdef TORQUE_DEBUG
   // In debug versions, allow a retry even for ISVs...
   bool retry = displayMessageBox(buffer, message, true);
#else
   bool retry = displayMessageBox(buffer, message, ((assertType == Fatal) ? true : false) );
#endif
   if (!retry)
      forceQuit();

   processing = false;
}

bool Assert::processingAssert()
{
   return processing;
}

#endif

//--------------------------------------
const char* avar(const char *message, ...)
{
   static char buffer[4096];
   va_list args;
   va_start(args, message);
   dVsprintf(buffer, sizeof(buffer), message, args);
   return( buffer );
}

};

tnl-1.N/core/coreAssert.h

deleted100644 → 0
+0 −96
Original line number Diff line number Diff line
//-----------------------------------------------------------------------------------
//
//   Torque Core Library
//   Copyright (C) 2005 GarageGames.com, Inc.
//   For more information see http://www.opentnl.org
//
//   This program is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation; either version 2 of the License, or
//   (at your option) any later version.
//
//   For use in products that are not compatible with the terms of the GNU 
//   General Public License, alternative licensing options are available 
//   from GarageGames.com.
//
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
//------------------------------------------------------------------------------------

#ifndef _CORE_ASSERT_H_
#define _CORE_ASSERT_H_

#ifndef _CORE_TYPES_H_
#include "core/coreTypes.h"
#endif

namespace TNL
{

/**
   sprintf style string formating into a fixed temporary buffer.
   @parsam in_msg sprintf style format string
   @returns pointer to fixed buffer containing formatted string

   <b>Example:</b>
   @code
   U8 a = 5;
   S16 b = -10;
   char *output = avar("hello %s! a=%u, b=%d", "world");
   ouput = "hello world! a=5, b=-10"
   @endcode
   @warning avar uses a static fixed buffer.  Treat the buffer as volatile data
   and use it immediately.  Other functions my use avar too and clobber the buffer.
 */
const char* avar(const char *in_msg, ...);

#if defined(TORQUE_DEBUG)
#define TORQUE_ENABLE_ASSERTS
#endif
	
#ifdef TORQUE_ENABLE_ASSERTS

/// Assert functions for validating proper program state.
class Assert
{
public:
   static void processAssert(const char*  filename, U32 lineNumber, const char*  message);
   static bool processingAssert();
};


   /**
      Assert that the statement x is true, otherwise halt.
      If the statement x is true, continue processing.
      If the statement x is false, log the file and line where the assert occured,
      the message y and displaying a dialog containing the message y. The user then
      has the option to halt or continue causing the debugger to break.
      These asserts are only present when TNL_ENABLE_ASSERTS is defined.
      This assert is very useful for verifying data as well as function entry and
      exit conditions.
    */
   #define Assert(x, y) { if (!bool(x)) { TNL::Assert::processAssert( __FILE__, __LINE__,  y); CORE_DEBUGBREAK(); } }

   /**
      AssertV - same as Assert, except that the message y must be a
      parenthesized printf-style variable argument list.
      These asserts are only present in DEBUG builds.
    */
   #define AssertV(x, y) { if (!bool(x)) { TNL::Assert::processAssert(__FILE__, __LINE__,  avar y); CORE_DEBUGBREAK(); } }

#else
   #define Assert(x, y)    { }
   #define AssertV(x, y)   { }
#endif

};

#endif // _CORE_ASSERT_H_

tnl-1.N/core/coreBitSet.h

deleted100644 → 0
+0 −110
Original line number Diff line number Diff line
//-----------------------------------------------------------------------------------
//
//   Torque Core Library
//   Copyright (C) 2005 GarageGames.com, Inc.
//   For more information see http://www.opentnl.org
//
//   This program is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation; either version 2 of the License, or
//   (at your option) any later version.
//
//   For use in products that are not compatible with the terms of the GNU 
//   General Public License, alternative licensing options are available 
//   from GarageGames.com.
//
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
//------------------------------------------------------------------------------------

#ifndef _CORE_BITSET_H_
#define _CORE_BITSET_H_

//Includes
#ifndef _CORE_TYPES_H_
#include "core/coreTypes.h"
#endif

namespace TNL {

/// Represents a word of bits.
///
/// A helper class to perform operations on a set of 32 bits.
class BitSet32
{
private:
   U32 mBits;

public:
   /// Default constructor initializes this bit set to all zeros.
   BitSet32()                         { mBits = 0; }

   /// Copy constructor.
   BitSet32(const BitSet32& in_rCopy) { mBits = in_rCopy.mBits; }

   /// Construct from an input U32.
   BitSet32(const U32 in_mask)        { mBits = in_mask; }

   /// @name Accessors
   /// @{

   /// Returns the U32 representation of the bit set.
   operator U32() const               { return mBits; }

   /// Returns the U32 representation of the bit set.
   U32 getMask() const                { return mBits; }

   /// @}

   /// @name Mutators
   ///
   /// Most of these methods take a word (ie, a BitSet32) of bits
   /// to operate with.
   /// @{

   /// Sets all the bits in the bit set to 1
   void set()                         { mBits  = 0xFFFFFFFFUL; }

   /// Sets all the bits in the bit set that are set in m.
   void set(const U32 m)              { mBits |= m; }

   /// For each bit set in s, sets or clears that bit in this, depending on whether b is true or false.
   void set(BitSet32 s, bool b)       { mBits = (mBits&~(s.mBits))|(b?s.mBits:0); }

   /// Clears all the bits in the bit set to 0.
   void clear()                       { mBits  = 0; }

   /// Clears all the bits in the bit set that are set in m.
   void clear(const U32 m)            { mBits &= ~m; }

   /// Flips all the bits in the bit set that are set in m.
   void toggle(const U32 m)           { mBits ^= m; }

   /// Test if the passed bits are set.
   bool test(const U32 m) const       { return (mBits & m) != 0; }

   /// Test if the passed bits and only the passed bits are set.
   bool testStrict(const U32 m) const { return (mBits & m) == m; }

   BitSet32& operator =(const U32 m)  { mBits  = m;  return *this; }
   BitSet32& operator|=(const U32 m)  { mBits |= m; return *this; }
   BitSet32& operator&=(const U32 m)  { mBits &= m; return *this; }
   BitSet32& operator^=(const U32 m)  { mBits ^= m; return *this; }

   BitSet32 operator|(const U32 m) const { return BitSet32(mBits | m); }
   BitSet32 operator&(const U32 m) const { return BitSet32(mBits & m); }
   BitSet32 operator^(const U32 m) const { return BitSet32(mBits ^ m); }

   /// @}
};

};

#endif //_CORE_BITSET_H_
Loading