瀏覽代碼

Refactoring

Panagiotis Christopoulos Charitos 14 年之前
父節點
當前提交
92c683dfe2

File diff suppressed because it is too large
+ 1 - 2
build/debug/Makefile


+ 1 - 1
build/debug/gen.cfg.py

@@ -9,6 +9,6 @@ executableName = "anki"
 
 compiler = "g++"
 
-compilerFlags = "-DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\\\"`svnversion ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -fsingle-precision-constant -msse4"
+compilerFlags = "-DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\\\"`svnversion ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Winline -W -Wwrite-strings -Wno-unused -Wno-long-long -pipe -g3 -fsingle-precision-constant -msse4"
 
 linkerFlags = "-rdynamic -L../../extern/lib-x86-64-linux -Wl,-Bdynamic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread -lfreetype"

+ 6 - 2
docs/doxyfile

@@ -1346,8 +1346,12 @@ INCLUDE_FILE_PATTERNS  = *.h \
 # undefined via #undef or recursively expanded use the := operator 
 # instead of the = operator.
 
-PREDEFINED             = "PROPERTY_RW(_v0_,_v1_,_v2_,_v3_) := private: _v0_ _v1_; public: const _v0_& _v3_() const; /**< Property getter */ public: _v0_& _v3_(); /**< Property getter #2*/ void _v2_(_v0_&); /**< Property setter*/ private: _v0_ _v1_;" \
-                         "PROPERTY_R(_v0_,_v1_,_v2_):= private: _v0_ _v1_; public: const _v0_& _v2_() const; /**< Property getter */ private: _v0_ _v1_;"
+PREDEFINED             = "GETTER_RW(_t_,_v_,_m_) := public: const _t_& _m_() const; _t_& _m_();" \
+                         "GETTER_R(_t_,_v_,_m_) := public: const _t_& _m_() const;" \
+                         "GETTER_SETTER(_t_,_v_,_mg_,_ms_) := public: const _t_& _mg_() const; _t_& _mg_(); void _ms_(const _t_&)" \
+                         "GETTER_RW_BY_VAL(_t_,_v_,_m_) := public: _t_ _m_() const; _t_& _m_();" \
+                         "GETTER_R_BY_VAL(_t_,_v_,_m_) := public: _t_ _m_() const;" \
+                         "GETTER_SETTER_BY_VAL(_t_,_v_,_mg_,_ms_) := public: _t_ _mg_() const; _t_& _mg_(); void _ms_(_t_)"
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
 # this tag can be used to specify a list of macro names that should be expanded. 

+ 11 - 11
src/Events/Event.cpp

@@ -5,19 +5,19 @@
 namespace Event {
 
 
-//======================================================================================================================
-// Constructor                                                                                                         =
-//======================================================================================================================
-Event::Event(EventType type_, float startTime_, float duration_):
-	type(type_),
+//==============================================================================
+// Constructor                                                                 =
+//==============================================================================
+Event::Event(EventType type_, float startTime_, float duration_)
+:	type(type_),
 	startTime(startTime_),
 	duration(duration_)
 {}
 
 
-//======================================================================================================================
-// operator=                                                                                                           =
-//======================================================================================================================
+//==============================================================================
+// operator=                                                                   =
+//==============================================================================
 Event& Event::operator=(const Event& b)
 {
 	type = b.type;
@@ -27,9 +27,9 @@ Event& Event::operator=(const Event& b)
 }
 
 
-//======================================================================================================================
-// update                                                                                                              =
-//======================================================================================================================
+//==============================================================================
+// update                                                                      =
+//==============================================================================
 void Event::update(float prevUpdateTime, float crntTime)
 {
 	ASSERT(!isDead(crntTime));

+ 9 - 2
src/Events/Event.h

@@ -32,7 +32,7 @@ class Event
 		GETTER_R(float, startTime, getStartTime)
 		GETTER_R(float, duration, getDuration)
 		GETTER_R(EventType, type, getEventType)
-		bool isDead(float crntTime) const {return crntTime >= startTime + duration;}
+		bool isDead(float crntTime) const;
 		/// @}
 
 		/// Copy
@@ -49,7 +49,8 @@ class Event
 		/// Linear interpolation between values
 		/// @param[in] from Starting value
 		/// @param[in] to Ending value
-		/// @param[in] delta The percentage from the from "from" value. Values from [0.0, 1.0]
+		/// @param[in] delta The percentage from the from "from" value. Values
+		/// from [0.0, 1.0]
 		template<typename Type>
 		static Type interpolate(const Type& from, const Type& to, float delta);
 
@@ -60,6 +61,12 @@ class Event
 };
 
 
+inline bool Event::isDead(float crntTime) const
+{
+	return crntTime >= startTime + duration;
+}
+
+
 template<typename Type>
 Type Event::interpolate(const Type& from, const Type& to, float delta)
 {

+ 25 - 22
src/Events/EventMainRendererPpsHdr.cpp

@@ -6,37 +6,39 @@
 namespace Event {
 
 
-//======================================================================================================================
-// Constructor                                                                                                         =
-//======================================================================================================================
+//==============================================================================
+// Constructor                                                                 =
+//==============================================================================
 MainRendererPpsHdr::MainRendererPpsHdr(float startTime, float duration,
-                                       float exposure_, uint blurringIterationsNum_, float blurringDist_):
-	Event(MAIN_RENDERER_PPS_HDR, startTime, duration)
+	float exposure_, uint blurringIterationsNum_, float blurringDist_)
+:	Event(MAIN_RENDERER_PPS_HDR, startTime, duration)
 {
 	finalData.exposure = exposure_;
 	finalData.blurringIterationsNum = blurringIterationsNum_;
 	finalData.blurringDist = blurringDist_;
 
-	originalData.exposure = MainRendererSingleton::getInstance().getPps().getHdr().getExposure();
-	originalData.blurringIterationsNum =
-		MainRendererSingleton::getInstance().getPps().getHdr().getBlurringIterationsNum();
-	originalData.blurringDist = MainRendererSingleton::getInstance().getPps().getHdr().getBlurringDist();
+	originalData.exposure = MainRendererSingleton::getInstance().getPps().
+		getHdr().getExposure();
+	originalData.blurringIterationsNum = MainRendererSingleton::getInstance().
+		getPps().getHdr().getBlurringIterationsNum();
+	originalData.blurringDist = MainRendererSingleton::getInstance().getPps().
+		getHdr().getBlurringDist();
 }
 
 
-//======================================================================================================================
-// Constructor                                                                                                         =
-//======================================================================================================================
-MainRendererPpsHdr::MainRendererPpsHdr(const MainRendererPpsHdr& b):
-	Event(MAIN_RENDERER_PPS_HDR, 0.0, 0.0)
+//==============================================================================
+// Copy constructor                                                            =
+//==============================================================================
+MainRendererPpsHdr::MainRendererPpsHdr(const MainRendererPpsHdr& b)
+:	Event(MAIN_RENDERER_PPS_HDR, 0.0, 0.0)
 {
 	*this = b;
 }
 
 
-//======================================================================================================================
-// operator=                                                                                                           =
-//======================================================================================================================
+//==============================================================================
+// operator=                                                                   =
+//==============================================================================
 MainRendererPpsHdr& MainRendererPpsHdr::operator=(const MainRendererPpsHdr& b)
 {
 	Event::operator=(b);
@@ -46,9 +48,9 @@ MainRendererPpsHdr& MainRendererPpsHdr::operator=(const MainRendererPpsHdr& b)
 }
 
 
-//======================================================================================================================
-// updateSp                                                                                                            =
-//======================================================================================================================
+//==============================================================================
+// updateSp                                                                    =
+//==============================================================================
 void MainRendererPpsHdr::updateSp(float /*prevUpdateTime*/, float crntTime)
 {
 	float d = crntTime - getStartTime(); // delta
@@ -57,8 +59,9 @@ void MainRendererPpsHdr::updateSp(float /*prevUpdateTime*/, float crntTime)
 	MainRendererSingleton::getInstance().getPps().getHdr().setExposure(
 		interpolate(originalData.exposure, finalData.exposure, dp));
 
-	MainRendererSingleton::getInstance().getPps().getHdr().setBlurringIterationsNum(
-		interpolate(originalData.blurringIterationsNum, finalData.blurringIterationsNum, dp));
+	MainRendererSingleton::getInstance().getPps().getHdr().
+		setBlurringIterationsNum(interpolate(originalData.blurringIterationsNum,
+		finalData.blurringIterationsNum, dp));
 
 	MainRendererSingleton::getInstance().getPps().getHdr().setBlurringDist(
 		interpolate(originalData.blurringDist, finalData.blurringDist, dp));

+ 1 - 1
src/Events/EventMainRendererPpsHdr.h

@@ -13,7 +13,7 @@ class MainRendererPpsHdr: public Event
 	public:
 		/// Constructor
 		MainRendererPpsHdr(float startTime, float duration,
-		                   float exposure, uint blurringIterationsNum, float blurringDist);
+			float exposure, uint blurringIterationsNum, float blurringDist);
 
 		/// Copy constructor
 		MainRendererPpsHdr(const MainRendererPpsHdr& b);

+ 7 - 7
src/Events/EventManager.cpp

@@ -1,13 +1,13 @@
-#include <boost/foreach.hpp>
 #include "EventManager.h"
+#include <boost/foreach.hpp>
 
 
 namespace Event {
 
 
-//======================================================================================================================
-// updateAllEvents                                                                                                     =
-//======================================================================================================================
+//==============================================================================
+// updateAllEvents                                                             =
+//==============================================================================
 void Manager::updateAllEvents(float prevUpdateTime_, float crntTime_)
 {
 	prevUpdateTime = prevUpdateTime_;
@@ -23,9 +23,9 @@ void Manager::updateAllEvents(float prevUpdateTime_, float crntTime_)
 }
 
 
-//======================================================================================================================
-// findADeadEvent                                                                                                      =
-//======================================================================================================================
+//==============================================================================
+// findADeadEvent                                                              =
+//==============================================================================
 Manager::EventsContainer::iterator Manager::findADeadEvent(EventType type)
 {
 	EventsContainer::iterator it = events.begin();

+ 1 - 1
src/Events/EventManager.h

@@ -1,8 +1,8 @@
 #ifndef EVENT_MANAGER_H
 #define EVENT_MANAGER_H
 
-#include <boost/ptr_container/ptr_deque.hpp>
 #include "Event.h"
+#include <boost/ptr_container/ptr_deque.hpp>
 
 
 namespace Event {

+ 3 - 3
src/Events/EventManager.inl.h

@@ -4,9 +4,9 @@
 namespace Event {
 
 
-//======================================================================================================================
-//  createEvent                                                                                                        =
-//======================================================================================================================
+//==============================================================================
+//  createEvent                                                                =
+//==============================================================================
 template<typename EventType>
 EventType& Manager::createEvent(const EventType& event)
 {

+ 19 - 17
src/Events/EventSceneColor.cpp

@@ -7,30 +7,31 @@
 namespace Event {
 
 
-//======================================================================================================================
-// Constructor                                                                                                         =
-//======================================================================================================================
-SceneColor::SceneColor(float startTime, float duration, const Vec3& finalColor_):
-	Event(SCENE_COLOR, startTime, duration),
+//==============================================================================
+// Constructor                                                                 =
+//==============================================================================
+SceneColor::SceneColor(float startTime, float duration,
+	const Vec3& finalColor_)
+:	Event(SCENE_COLOR, startTime, duration),
 	finalColor(finalColor_)
 {
 	originalColor = SceneSingleton::getInstance().getAmbientCol();
 }
 
 
-//======================================================================================================================
-// Constructor copy                                                                                                    =
-//======================================================================================================================
-SceneColor::SceneColor(const SceneColor& b):
-	Event(SCENE_COLOR, 0.0, 0.0)
+//==============================================================================
+// Constructor copy                                                            =
+//==============================================================================
+SceneColor::SceneColor(const SceneColor& b)
+:	Event(SCENE_COLOR, 0.0, 0.0)
 {
 	*this = b;
 }
 
 
-//======================================================================================================================
-// operator=                                                                                                           =
-//======================================================================================================================
+//==============================================================================
+// operator=                                                                   =
+//==============================================================================
 SceneColor& SceneColor::operator=(const SceneColor& b)
 {
 	Event::operator=(b);
@@ -40,15 +41,16 @@ SceneColor& SceneColor::operator=(const SceneColor& b)
 }
 
 
-//======================================================================================================================
-// updateSp                                                                                                            =
-//======================================================================================================================
+//==============================================================================
+// updateSp                                                                    =
+//==============================================================================
 void SceneColor::updateSp(float /*prevUpdateTime*/, float crntTime)
 {
 	float d = crntTime - getStartTime(); // delta
 	float dp = d / float(getDuration()); // delta as persentage
 
-	SceneSingleton::getInstance().setAmbientCol(interpolate(originalColor, finalColor, dp));
+	SceneSingleton::getInstance().setAmbientCol(
+		interpolate(originalColor, finalColor, dp));
 }
 
 

+ 1 - 0
src/Events/EventSceneColor.h

@@ -32,4 +32,5 @@ class SceneColor: public Event
 
 } // end namespace
 
+
 #endif

+ 46 - 30
src/Renderer/Renderer.h

@@ -25,12 +25,10 @@ class ModelNode;
 
 
 /// Offscreen renderer
-/// It is a class and not a namespace because we may need external renderers for security cameras for example
+/// It is a class and not a namespace because we may need external renderers
+/// for security cameras for example
 class Renderer
 {
-	//==================================================================================================================
-	// Public                                                                                                          =
-	//==================================================================================================================
 	public:
 		/// The types of rendering a ModelNode
 		enum ModelNodeRenderType
@@ -75,35 +73,40 @@ class Renderer
 		/// @param projectionMat The projection matrix
 		/// @param view The view vector
 		/// @return The unprojected coords
-		static Vec3 unproject(const Vec3& windowCoords, const Mat4& modelViewMat, const Mat4& projectionMat,
-		                      const int view[4]);
+		static Vec3 unproject(const Vec3& windowCoords,
+			const Mat4& modelViewMat, const Mat4& projectionMat,
+			const int view[4]);
 
 		/// OpenGL wrapper
-		static void setViewport(uint x, uint y, uint w, uint h) {glViewport(x, y, w, h);}
+		static void setViewport(uint x, uint y, uint w, uint h);
 
-		/// Draws a quad. Actually it draws 2 triangles because OpenGL will no longer support quads
+		/// Draws a quad. Actually it draws 2 triangles because OpenGL will no
+		/// longer support quads
 		void drawQuad();
 
 		/// Create FAI texture
-		static void createFai(uint width, uint height, int internalFormat, int format, int type, Texture& fai);
-
-		/// Calculate the planes needed for the calculation of the fragment position z in view space.
-		/// Having the fragment's depth, the camera's zNear and zFar the z of the fragment is being calculated inside
-		/// the fragment shader from:
-		/// @code z = (- zFar * zNear) / (zFar - depth * (zFar - zNear)) @endcode
-		/// The above can be optimized and this method actually precalculates a few things in order to lift a few
-		/// calculations from the fragment shader. So the z is:
+		static void createFai(uint width, uint height, int internalFormat,
+			int format, int type, Texture& fai);
+
+		/// Calculate the planes needed for the calculation of the fragment
+		/// position z in view space. Having the fragment's depth, the camera's
+		/// zNear and zFar the z of the fragment is being calculated inside the
+		/// fragment shader from:
+		/// @code z = (- zFar * zNear) / (zFar - depth * (zFar - zNear))
+		/// @endcode
+		/// The above can be optimized and this method actually precalculates a
+		/// few things in order to lift a few calculations from the fragment
+		/// shader. So the z is:
 		/// @code z =  -planes.y / (planes.x + depth) @endcode
 		/// @param[in] cameraRange The zNear, zFar
 		/// @param[out] planes The planes
 		static void calcPlanes(const Vec2& cameraRange, Vec2& planes);
 
-		/// Calculates two values needed for the calculation of the fragment position in view space.
-		static void calcLimitsOfNearPlane(const PerspectiveCamera& cam, Vec2& limitsOfNearPlane);
+		/// Calculates two values needed for the calculation of the fragment
+		/// position in view space.
+		static void calcLimitsOfNearPlane(const PerspectiveCamera& cam,
+			Vec2& limitsOfNearPlane);
 
-	//==================================================================================================================
-	// Protected                                                                                                       =
-	//==================================================================================================================
 	protected:
 		/// @name Rendering stages
 		/// @{
@@ -113,25 +116,32 @@ class Renderer
 		Bs bs; ///< Blending stage
 		/// @}
 
-		uint width; ///< Width of the rendering. Dont confuse with the window width
-		uint height; ///< Height of the rendering. Dont confuse with the window width
+		/// Width of the rendering. Don't confuse with the window width
+		uint width;
+		/// Height of the rendering. Don't confuse with the window width
+		uint height;
 		float aspectRatio; ///< Just a precalculated value
 		const Camera* cam; ///< Current camera
-		static int maxColorAtachments; ///< Max color attachments an FBO can accept
+		/// Max color attachments an FBO can accept
+		static int maxColorAtachments;
 		SceneDrawer sceneDrawer;
 		SkinsDeformer skinsDeformer;
 
 		/// @name Optimization vars
 		/// Used in other stages
 		/// @{
-		Vec2 planes; ///< Used to to calculate the frag pos in view space inside a few shader programs
-		Vec2 limitsOfNearPlane; ///< Used to to calculate the frag pos in view space inside a few shader programs
-		Vec2 limitsOfNearPlane2; ///< Used to to calculate the frag pos in view space inside a few shader programs
+
+		/// Used to to calculate the frag pos in view space inside a few shader
+		/// programs
+		Vec2 planes;
+		/// Used to to calculate the frag pos in view space inside a few shader
+		/// programs
+		Vec2 limitsOfNearPlane;
+		/// Used to to calculate the frag pos in view space inside a few shader
+		/// programs
+		Vec2 limitsOfNearPlane2;
 		/// @}
 
-	//==================================================================================================================
-	// Protected                                                                                                       =
-	//==================================================================================================================
 	private:
 		uint framesNum; ///< Frame number
 		Mat4 viewProjectionMat; ///< Precalculated in case anyone needs it
@@ -145,4 +155,10 @@ class Renderer
 };
 
 
+inline void Renderer::setViewport(uint x, uint y, uint w, uint h)
+{
+	glViewport(x, y, w, h);
+}
+
+
 #endif

+ 99 - 81
src/Util/Scanner/Scanner.cpp

@@ -3,11 +3,11 @@
 #include <cstring>
 #include <cmath>
 #include <cassert>
+#include "Scanner.h"
+#include "ScannerException.h"
 #include <sstream>
 #include <iomanip>
 #include <boost/lexical_cast.hpp>
-#include "Scanner.h"
-#include "ScannerException.h"
 
 
 namespace Scanner {
@@ -16,9 +16,9 @@ namespace Scanner {
 	Exception(std::string() + x, __LINE__, scriptName, lineNmbr)
 
 
-//======================================================================================================================
-// statics                                                                                                             =
-//======================================================================================================================
+//==============================================================================
+// statics                                                                     =
+//==============================================================================
 char Scanner::eofChar = 0x7F;
 
 
@@ -62,9 +62,9 @@ Scanner::ResWord* Scanner::rwTable [] =  // reserved word table
 Scanner::AsciiFlag Scanner::asciiLookupTable [128] = {AC_ERROR};
 
 
-//======================================================================================================================
-// Constructors                                                                                                        =
-//======================================================================================================================
+//==============================================================================
+// Constructors                                                                =
+//==============================================================================
 
 Scanner::Scanner(bool newlinesAsWhitespace)
 {
@@ -81,7 +81,8 @@ Scanner::Scanner(const char* filename, bool newlinesAsWhitespace)
 }
 
 
-Scanner::Scanner(std::istream& istream_, const char* scriptName_, bool newlinesAsWhitespace)
+Scanner::Scanner(std::istream& istream_, const char* scriptName_,
+	bool newlinesAsWhitespace)
 {
 	strcpy(scriptName, "unnamed-script");
 	init(newlinesAsWhitespace);
@@ -89,9 +90,9 @@ Scanner::Scanner(std::istream& istream_, const char* scriptName_, bool newlinesA
 }
 
 
-//======================================================================================================================
-// initAsciiMap                                                                                                        =
-//======================================================================================================================
+//==============================================================================
+// initAsciiMap                                                                =
+//==============================================================================
 void Scanner::initAsciiMap()
 {
 	memset(&asciiLookupTable[0], AC_ERROR, sizeof(asciiLookupTable));
@@ -110,18 +111,22 @@ void Scanner::initAsciiMap()
 		asciiLookupTable[x] = AC_DIGIT;
 	}
 
-	asciiLookupTable[':'] = asciiLookupTable['['] = asciiLookupTable[']'] = asciiLookupTable['('] = AC_SPECIAL;
-	asciiLookupTable[')'] = asciiLookupTable['.'] = asciiLookupTable['{'] = asciiLookupTable['}'] = AC_SPECIAL;
-	asciiLookupTable[','] = asciiLookupTable[';'] = asciiLookupTable['?'] = asciiLookupTable['='] = AC_SPECIAL;
-	asciiLookupTable['!'] = asciiLookupTable['<'] = asciiLookupTable['>'] = asciiLookupTable['|'] = AC_SPECIAL;
-	asciiLookupTable['&'] = asciiLookupTable['+'] = asciiLookupTable['-'] = asciiLookupTable['*'] = AC_SPECIAL;
-	asciiLookupTable['/'] = asciiLookupTable['~'] = asciiLookupTable['%'] = asciiLookupTable['#'] = AC_SPECIAL;
-	asciiLookupTable['^'] = AC_SPECIAL;
-
-	asciiLookupTable['\t'] = asciiLookupTable[' '] = asciiLookupTable['\0'] = AC_WHITESPACE;
+	asciiLookupTable[':'] = asciiLookupTable['['] = asciiLookupTable[']'] =
+		asciiLookupTable['('] = asciiLookupTable[')'] = asciiLookupTable['.'] =
+		asciiLookupTable['{'] = asciiLookupTable['}'] = asciiLookupTable[','] =
+		asciiLookupTable[';'] = asciiLookupTable['?'] = asciiLookupTable['='] =
+		asciiLookupTable['!'] = asciiLookupTable['<'] = asciiLookupTable['>'] =
+		asciiLookupTable['|'] = asciiLookupTable['&'] = asciiLookupTable['+'] =
+		asciiLookupTable['-'] = asciiLookupTable['*'] = asciiLookupTable['/'] =
+		asciiLookupTable['~'] = asciiLookupTable['%'] = asciiLookupTable['#'] =
+		asciiLookupTable['^'] = AC_SPECIAL;
+
+	asciiLookupTable['\t'] = asciiLookupTable[' '] = asciiLookupTable['\0'] =
+		AC_WHITESPACE;
 	asciiLookupTable['\n'] = AC_ERROR; // newline is unacceptable char
 
-	asciiLookupTable['@'] = asciiLookupTable['`'] = asciiLookupTable['$'] = AC_ACCEPTABLE_IN_COMMENTS;
+	asciiLookupTable['@'] = asciiLookupTable['`'] = asciiLookupTable['$'] =
+		AC_ACCEPTABLE_IN_COMMENTS;
 
 	asciiLookupTable['\"']         = AC_DOUBLEQUOTE;
 	asciiLookupTable['\'']         = AC_QUOTE;
@@ -130,9 +135,9 @@ void Scanner::initAsciiMap()
 }
 
 
-//======================================================================================================================
-// init                                                                                                                =
-//======================================================================================================================
+//==============================================================================
+// init                                                                        =
+//==============================================================================
 void Scanner::init(bool newlinesAsWhitespace_)
 {
 	newlinesAsWhitespace = newlinesAsWhitespace_;
@@ -149,9 +154,9 @@ void Scanner::init(bool newlinesAsWhitespace_)
 }
 
 
-//======================================================================================================================
-// getLine                                                                                                             =
-//======================================================================================================================
+//==============================================================================
+// getLine                                                                     =
+//==============================================================================
 void Scanner::getLine()
 {
 	if(!inStream->getline(line, MAX_SCRIPT_LINE_LEN - 1, '\n'))
@@ -168,9 +173,9 @@ void Scanner::getLine()
 }
 
 
-//======================================================================================================================
-// getNextChar                                                                                                         =
-//======================================================================================================================
+//==============================================================================
+// getNextChar                                                                 =
+//==============================================================================
 char Scanner::getNextChar()
 {
 	if(*pchar=='\0')
@@ -189,16 +194,16 @@ char Scanner::getNextChar()
 	else if(lookupAscii(*pchar) == AC_ERROR)
 	{
 		throw SCANNER_EXCEPTION("Unacceptable char '" + *pchar + "' 0x" +
-		                        boost::lexical_cast<std::string>(static_cast<uint>(*pchar)));
+			boost::lexical_cast<std::string>(static_cast<uint>(*pchar)));
 	}
 
 	return *pchar;
 }
 
 
-//======================================================================================================================
-// putBackChar                                                                                                         =
-//======================================================================================================================
+//==============================================================================
+// putBackChar                                                                 =
+//==============================================================================
 char Scanner::putBackChar()
 {
 	if(pchar != line && *pchar != eofChar)
@@ -210,23 +215,23 @@ char Scanner::putBackChar()
 }
 
 
-//======================================================================================================================
-// getAllPrintAll                                                                                                      =
-//======================================================================================================================
+//==============================================================================
+// getAllPrintAll                                                              =
+//==============================================================================
 void Scanner::getAllPrintAll()
 {
 	do
 	{
 		getNextToken();
-		std::cout << std::setw(3) << std::setfill('0') << getLineNumber() << ": " <<
-			crntToken.getInfoStr() << std::endl;
+		std::cout << std::setw(3) << std::setfill('0') << getLineNumber() <<
+			": " << crntToken.getInfoStr() << std::endl;
 	} while(crntToken.code != TC_EOF);
 }
 
 
-//======================================================================================================================
-// loadFile                                                                                                            =
-//======================================================================================================================
+//==============================================================================
+// loadFile                                                                    =
+//==============================================================================
 void Scanner::loadFile(const char* filename_)
 {
 	inFstream.open(filename_);
@@ -239,9 +244,9 @@ void Scanner::loadFile(const char* filename_)
 }
 
 
-//======================================================================================================================
-// loadIstream                                                                                                        =
-//======================================================================================================================
+//==============================================================================
+// loadIstream                                                                 =
+//==============================================================================
 void Scanner::loadIstream(std::istream& istream_, const char* scriptName_)
 {
 	if(inStream != NULL)
@@ -252,7 +257,9 @@ void Scanner::loadIstream(std::istream& istream_, const char* scriptName_)
 	inStream = &istream_;
 
 	// init globals
-	assert(strlen(scriptName_) <= sizeof(scriptName) / sizeof(char) - 1); // Too big name
+
+	// Too big name
+	assert(strlen(scriptName_) <= sizeof(scriptName) / sizeof(char) - 1);
 	crntToken.code = TC_ERROR;
 	lineNmbr = 0;
 	strcpy(scriptName, scriptName_);
@@ -261,18 +268,18 @@ void Scanner::loadIstream(std::istream& istream_, const char* scriptName_)
 }
 
 
-//======================================================================================================================
-// unload                                                                                                              =
-//======================================================================================================================
+//==============================================================================
+// unload                                                                      =
+//==============================================================================
 void Scanner::unload()
 {
 	inFstream.close();
 }
 
 
-//======================================================================================================================
-// getNextToken                                                                                                        =
-//======================================================================================================================
+//==============================================================================
+// getNextToken                                                                =
+//==============================================================================
 const Token& Scanner::getNextToken()
 {
 	start:
@@ -283,7 +290,9 @@ const Token& Scanner::getNextToken()
 	{
 		crntToken.code = TC_NEWLINE;
 		--commentedLines;
-		++lineNmbr; // the ultimate hack. I should remember not to do such crap in the future
+		// the ultimate hack. I should remember not to do such crap in the
+		// future
+		++lineNmbr;
 	}
 	else if(*pchar == '/')
 	{
@@ -356,7 +365,8 @@ const Token& Scanner::getNextToken()
 			case AC_ERROR:
 			default:
 				getNextChar();
-				throw SCANNER_EXCEPTION("Unexpected character \'" + *pchar + '\'');
+				throw SCANNER_EXCEPTION("Unexpected character \'" + *pchar +
+					'\'');
 				goto start;
 		}
 	}
@@ -375,9 +385,9 @@ const Token& Scanner::getNextToken()
 	return crntToken;
 }
 
-//======================================================================================================================
-// checkWord                                                                                                           =
-//======================================================================================================================
+//==============================================================================
+// checkWord                                                                   =
+//==============================================================================
 void Scanner::checkWord()
 {
 	char* tmpStr = &crntToken.asString[0];
@@ -419,9 +429,9 @@ void Scanner::checkWord()
 }
 
 
-//======================================================================================================================
-// checkComment                                                                                                        =
-//======================================================================================================================
+//==============================================================================
+// checkComment                                                                =
+//==============================================================================
 void Scanner::checkComment()
 {
 	// Beginning
@@ -489,19 +499,22 @@ void Scanner::checkComment()
 }
 
 
-//======================================================================================================================
-// checkNumber                                                                                                         =
-//======================================================================================================================
+//==============================================================================
+// checkNumber                                                                 =
+//==============================================================================
 void Scanner::checkNumber()
 {
-	// This func is working great, dont try to understand it and dont even think to try touching it.
+	// This func is working great, dont try to understand it and dont even
+	// think to try touching it.
 
 	//RASSERT_THROW_EXCEPTION(sizeof(long) != 8); // ulong must be 64bit
 	long num = 0;     // value of the number & part of the float num before '.'
 	long fnum = 0;    // part of the float num after '.'
 	long dad = 0;     // digits after dot (for floats)
-	bool expSign = 0; // exponent sign in case float is represented in mant/exp format. 0 means positive and 1 negative
-	long exp = 0;     // the exponent in case float is represented in mant/exp format
+	bool expSign = 0; // exponent sign in case float is represented in mant/exp
+	                  // format. 0 means positive and 1 negative
+	long exp = 0;     // the exponent in case float is represented in mant/exp
+	                  // format
 	char* tmpStr = &crntToken.asString[0];
 	crntToken.dataType = DT_INT;
 	uint asc;
@@ -791,13 +804,14 @@ void Scanner::checkNumber()
 		}
 
 		*tmpStr = '\0';
-		throw SCANNER_EXCEPTION("Bad number suffix \"" + &crntToken.asString[0] + '\"');
+		throw SCANNER_EXCEPTION("Bad number suffix \"" +
+			&crntToken.asString[0] + '\"');
 }
 
 
-//======================================================================================================================
-// checkString                                                                                                         =
-//======================================================================================================================
+//==============================================================================
+// checkString                                                                 =
+//==============================================================================
 void Scanner::checkString()
 {
 	char* tmpStr = &crntToken.asString[0];
@@ -810,7 +824,8 @@ void Scanner::checkString()
 		{
 			crntToken.code = TC_ERROR;
 			*tmpStr = '\0';
-			throw SCANNER_EXCEPTION("Incorrect string ending \"" + &crntToken.asString[0] + '\"');
+			throw SCANNER_EXCEPTION("Incorrect string ending \"" +
+				&crntToken.asString[0] + '\"');
 			return;
 		}
 		// Escape Codes
@@ -821,7 +836,8 @@ void Scanner::checkString()
 			{
 				crntToken.code = TC_ERROR;
 				*tmpStr = '\0';
-				throw SCANNER_EXCEPTION("Incorrect string ending \"" + &crntToken.asString[0] + '\"');
+				throw SCANNER_EXCEPTION("Incorrect string ending \"" +
+					&crntToken.asString[0] + '\"');
 				return;
 			}
 
@@ -860,7 +876,8 @@ void Scanner::checkString()
 				case '\0':
 					break; // not an escape char but works almost the same
 				default:
-					throw SCANNER_EXCEPTION("Unrecognized escape character \'\\" + ch + '\'');
+					throw SCANNER_EXCEPTION(
+						"Unrecognized escape character \'\\" + ch + '\'');
 					*tmpStr++ = ch;
 			}
 		}
@@ -884,9 +901,9 @@ void Scanner::checkString()
 }
 
 
-//======================================================================================================================
-// checkChar                                                                                                           =
-//======================================================================================================================
+//==============================================================================
+// checkChar                                                                   =
+//==============================================================================
 void Scanner::checkChar()
 {
 	char ch = getNextChar();
@@ -953,7 +970,8 @@ void Scanner::checkChar()
 				break;
 			default:
 				ch0 = ch;
-				throw SCANNER_EXCEPTION("Unrecognized escape character \'\\" + ch + '\'');
+				throw SCANNER_EXCEPTION("Unrecognized escape character \'\\" +
+					ch + '\'');
 		}
 		crntToken.value.char_ = ch0;
 	}
@@ -975,9 +993,9 @@ void Scanner::checkChar()
 }
 
 
-//======================================================================================================================
-// checkSpecial                                                                                                        =
-//======================================================================================================================
+//==============================================================================
+// checkSpecial                                                                =
+//==============================================================================
 void Scanner::checkSpecial()
 {
 	char ch = *pchar;

+ 40 - 26
src/Util/Scanner/Scanner.h

@@ -1,8 +1,8 @@
 #ifndef SCANNER_H
 #define SCANNER_H
 
-#include <fstream>
 #include "ScannerToken.h"
+#include <fstream>
 
 
 namespace Scanner {
@@ -10,13 +10,11 @@ namespace Scanner {
 
 /// C++ Tokenizer
 ///
-/// The Scanner loads a file or an already loaded iostream and extracts the tokens. The script must be in C++ format.
-/// The class does not make any kind of memory allocations so it can be fast.
+/// The Scanner loads a file or an already loaded iostream and extracts the
+/// tokens. The script must be in C++ format. The class does not make any kind
+/// of memory allocations so it can be fast.
 class Scanner
 {
-	//==================================================================================================================
-	// Public                                                                                                          =
-	//==================================================================================================================
 	public:
 		/// Constructor #1
 		/// @param newlinesAsWhitespace @see newlinesAsWhitespace
@@ -32,7 +30,9 @@ class Scanner
 		/// @see loadIstream
 		/// @param newlinesAsWhitespace @see newlinesAsWhitespace
 		/// @exception Exception
-		Scanner(std::istream& istream_, const char* scriptName_ = "unamed-istream", bool newlinesAsWhitespace = true);
+		Scanner(std::istream& istream_,
+			const char* scriptName_ = "unamed-istream",
+			bool newlinesAsWhitespace = true);
 
 		/// It only unloads the file if file is chosen
 		~Scanner() {unload();}
@@ -46,12 +46,14 @@ class Scanner
 		/// @param istream_ The stream from where to read
 		/// @param scriptName_ The name of the stream. For error reporting
 		/// @exception Exception
-		void loadIstream(std::istream& istream_, const char* scriptName_ = "unamed-istream");
+		void loadIstream(std::istream& istream_,
+			const char* scriptName_ = "unamed-istream");
 
 		/// Extracts all tokens and prints them. Used for debugging
 		void getAllPrintAll();
 
-		/// Get the next token from the stream. Its virtual and you can override it
+		/// Get the next token from the stream. Its virtual and you can
+		/// override it
 		/// @return The next Token
 		/// @exception Exception
 		virtual const Token& getNextToken();
@@ -66,11 +68,9 @@ class Scanner
 		/// Get the current line the Scanner is processing
 		int getLineNumber() const {return lineNmbr;}
 
-	//==================================================================================================================
-	// Protected                                                                                                       =
-	//==================================================================================================================
 	protected:
-		/// Every char in the Ascii table is binded with one characteristic code type. This helps the scanning
+		/// Every char in the Ascii table is binded with one characteristic
+		/// code type. This helps the scanning
 		enum AsciiFlag
 		{
 			AC_ERROR = 0,
@@ -84,7 +84,8 @@ class Scanner
 			AC_ACCEPTABLE_IN_COMMENTS = 128 ///< Only accepted in comments
 		};
 
-		/// Reserved words like "int" "const" etc. Currently the reserved words list is being populated with dummy data
+		/// Reserved words like "int" "const" etc. Currently the reserved words
+		/// list is being populated with dummy data
 		struct ResWord
 		{
 			const char* string;
@@ -93,7 +94,8 @@ class Scanner
 
 		static char eofChar; ///< Special end of file character
 
-		static AsciiFlag asciiLookupTable[]; ///< The array contains one AsciiFlag for every symbol of the ASCII table
+		/// The array contains one AsciiFlag for every symbol of the ASCII table
+		static AsciiFlag asciiLookupTable[];
 
 		/// @name Reserved words
 		/// Groups of ResWord grouped by the length of the ResWord::string
@@ -101,26 +103,35 @@ class Scanner
 		static ResWord rw2[], rw3[], rw4[], rw5[], rw6[], rw7[];
 		/// @}
 
-		static ResWord* rwTable[]; ///< The array contains all the groups of ResWord
+		/// The array contains all the groups of ResWord
+		static ResWord* rwTable[];
 
 		Token crntToken; ///< The current token
-		char  line[MAX_SCRIPT_LINE_LEN]; ///< In contains the current line's text
+		/// In contains the current line's text
+		char  line[MAX_SCRIPT_LINE_LEN];
 		char* pchar; ///< Points somewhere to @ref line
 		int   lineNmbr; ///< The number of the current line
 
-		/// Treat newlines as whitespace. If false means that the Scanner returns (among others) newline tokens
+		/// Treat newlines as whitespace. If false means that the Scanner
+		/// returns (among others) newline tokens
 		bool newlinesAsWhitespace;
 
 		/// Commented lines number
-		/// Used to keep track of the newlines in multiline comments so we can then return the correct number of newlines
+		/// Used to keep track of the newlines in multiline comments so we can
+		/// then return the correct number of newlines
 		/// in case of newlinesAsWhitespace is false
 		int commentedLines;
 
 		/// @name Input
 		/// @{
-		std::ifstream inFstream; ///< The file stream. Used if the @ref Scanner is initiated using @ref loadFile
-		std::istream* inStream; ///< Points to either @ref inFstream or an external std::istream
-		char scriptName[512]; ///< The name of the input stream. Mainly used for error messaging
+
+		/// The file stream. Used if the @ref Scanner is initiated using
+		/// @ref loadFile
+		std::ifstream inFstream;
+		/// Points to either @ref inFstream or an external std::istream
+		std::istream* inStream;
+		/// The name of the input stream. Mainly used for error messaging
+		char scriptName[512];
 		/// @}
 
 		/// @name Checkers
@@ -133,17 +144,20 @@ class Scanner
 		void checkSpecial();
 		/// @}
 
-		/// It reads a new line from the iostream and it points @ref pchar to the beginning of that line
+		/// It reads a new line from the iostream and it points @ref pchar to
+		/// the beginning of that line
 		void getLine();
 
-		/// Get the next char from the @ref line. If @ref line empty then get new line. It returns '\\0' if we are in the
+		/// Get the next char from the @ref line. If @ref line empty then get
+		/// new line. It returns '\\0' if we are in the
 		/// end of the line
 		char getNextChar();
 
 		/// Put the char that @ref getNextChar got back to the current line
 		char putBackChar();
 
-		/// Initializes the asciiLookupTable. It runs only once in the construction of the first Scanner @see Scanner()
+		/// Initializes the asciiLookupTable. It runs only once in the
+		/// construction of the first Scanner @see Scanner()
 		static void initAsciiMap();
 
 		/// To save us from typing
@@ -154,7 +168,7 @@ class Scanner
 
 		/// Unloads the file
 		void unload();
-}; // end class Scanner
+};
 
 
 } // end namespace

+ 2 - 1
src/Util/Scanner/ScannerCommon.h

@@ -4,7 +4,8 @@
 
 namespace Scanner {
 
-const int MAX_SCRIPT_LINE_LEN = 1024; ///< The max allowed length of a script line
+/// The max allowed length of a script line
+const int MAX_SCRIPT_LINE_LEN = 1024;
 
 }
 

+ 17 - 15
src/Util/Scanner/ScannerException.cpp

@@ -1,38 +1,40 @@
-#include <boost/lexical_cast.hpp>
 #include "ScannerException.h"
+#include <boost/lexical_cast.hpp>
 
 
 namespace Scanner {
 
 
-//======================================================================================================================
-// Constructor                                                                                                         =
-//======================================================================================================================
-Exception::Exception(const std::string& err, int errNo_, const std::string& scriptFilename_, int scriptLineNmbr_):
-	error(err),
+//==============================================================================
+// Constructor                                                                 =
+//==============================================================================
+Exception::Exception(const std::string& err, int errNo_,
+	const std::string& scriptFilename_, int scriptLineNmbr_)
+:	error(err),
 	errNo(errNo_),
 	scriptFilename(scriptFilename_),
 	scriptLineNmbr(scriptLineNmbr_)
 {}
 
 
-//======================================================================================================================
-// Copy constructor                                                                                                    =
-//======================================================================================================================
-Exception::Exception(const Exception& e):
-	error(e.error),
+//==============================================================================
+// Copy constructor                                                            =
+//==============================================================================
+Exception::Exception(const Exception& e)
+:	error(e.error),
 	errNo(e.errNo),
 	scriptFilename(e.scriptFilename),
 	scriptLineNmbr(e.scriptLineNmbr)
 {}
 
 
-//======================================================================================================================
-// what                                                                                                                =
-//======================================================================================================================
+//==============================================================================
+// what                                                                        =
+//==============================================================================
 const char* Exception::what() const throw()
 {
-	errWhat = "Scanner exception #" + boost::lexical_cast<std::string>(errNo) + " (" + scriptFilename + ':' +
+	errWhat = "Scanner exception #" + boost::lexical_cast<std::string>(errNo) +
+		" (" + scriptFilename + ':' +
 		boost::lexical_cast<std::string>(scriptLineNmbr) + ") " + error;
 	return errWhat.c_str();
 }

+ 2 - 1
src/Util/Scanner/ScannerException.h

@@ -12,7 +12,8 @@ class Exception: public std::exception
 {
 	public:
 		/// Constructor
-		Exception(const std::string& err, int errNo, const std::string& scriptFilename, int scriptLineNmbr);
+		Exception(const std::string& err, int errNo,
+			const std::string& scriptFilename, int scriptLineNmbr);
 
 		/// Copy constructor
 		Exception(const Exception& e);

+ 22 - 16
src/Util/Scanner/ScannerToken.cpp

@@ -1,18 +1,18 @@
+#include "ScannerToken.h"
 #include <cstring>
 #include <cstdio>
 #include <iostream>
 #include <boost/lexical_cast.hpp>
-#include "ScannerToken.h"
 
 
 namespace Scanner {
 
 
-//======================================================================================================================
-// Copy constructor                                                                                                    =
-//======================================================================================================================
-Token::Token(const Token& b):
-	code(b.code),
+//==============================================================================
+// Copy constructor                                                            =
+//==============================================================================
+Token::Token(const Token& b)
+:	code(b.code),
 	dataType(b.dataType)
 {
 	switch(b.dataType)
@@ -34,9 +34,9 @@ Token::Token(const Token& b):
 }
 
 
-//======================================================================================================================
-// getInfoStr                                                                                                          =
-//======================================================================================================================
+//==============================================================================
+// getInfoStr                                                                  =
+//==============================================================================
 std::string Token::getInfoStr() const
 {
 	char tokenInfoStr[512];
@@ -52,13 +52,18 @@ std::string Token::getInfoStr() const
 			sprintf(tokenInfoStr, "string \"%s\"", value.string);
 			break;
 		case TC_CHAR:
-			sprintf(tokenInfoStr, "char '%c' (\"%s\")", value.char_, &asString[0]);
+			sprintf(tokenInfoStr, "char '%c' (\"%s\")", value.char_,
+				&asString[0]);
 			break;
 		case TC_NUMBER:
 			if(dataType == DT_FLOAT)
-				sprintf(tokenInfoStr, "float %f or %e (\"%s\")", value.float_, value.float_, &asString[0]);
+			{
+				sprintf(tokenInfoStr, "float %f or %e (\"%s\")", value.float_,
+					value.float_, &asString[0]);
+			}
 			else
-				sprintf(tokenInfoStr, "int %lu (\"%s\")", value.int_, &asString[0]);
+				sprintf(tokenInfoStr, "int %lu (\"%s\")", value.int_,
+					&asString[0]);
 			break;
 		case TC_IDENTIFIER:
 			sprintf(tokenInfoStr, "identifier \"%s\"", value.string);
@@ -73,7 +78,8 @@ std::string Token::getInfoStr() const
 			}
 			else if(code>=TC_SCOPERESOLUTION && code<=TC_ASSIGNOR)
 			{
-				sprintf(tokenInfoStr, "operator no %d", code - TC_SCOPERESOLUTION);
+				sprintf(tokenInfoStr, "operator no %d",
+					code - TC_SCOPERESOLUTION);
 			}
 	}
 
@@ -81,9 +87,9 @@ std::string Token::getInfoStr() const
 }
 
 
-//======================================================================================================================
-// print                                                                                                               =
-//======================================================================================================================
+//==============================================================================
+// print                                                                       =
+//==============================================================================
 void Token::print() const
 {
 	std::cout << "Token: " << getInfoStr() << std::endl;

+ 14 - 7
src/Util/Scanner/ScannerToken.h

@@ -13,7 +13,8 @@ namespace Scanner {
 enum TokenCode
 {
 	// general codes
-	TC_ERROR, TC_EOF, TC_COMMENT, TC_NUMBER, TC_CHAR, TC_STRING, TC_IDENTIFIER, TC_NEWLINE,
+	TC_ERROR, TC_EOF, TC_COMMENT, TC_NUMBER, TC_CHAR, TC_STRING, TC_IDENTIFIER,
+	TC_NEWLINE,
 
 	// keywords listed by strlen (dummy keywords at the moment)
 	TC_KE,
@@ -57,9 +58,11 @@ class TokenDataVal
 		/// @name Accessors
 		/// @{
 		char getChar() const {return char_;} ///< Access the data as C char
-		unsigned long getInt() const {return int_;} ///< Access the data as unsigned int
+		/// Access the data as unsigned int
+		unsigned long getInt() const {return int_;}
 		double getFloat() const {return float_;} ///< Access the data as double
-		const char* getString() const {return string;} ///< Access the data as C string
+		/// Access the data as C string
+		const char* getString() const {return string;}
 		/// @}
 
 	private:
@@ -69,7 +72,9 @@ class TokenDataVal
 			char char_;
 			unsigned long int_;
 			double float_;
-			char* string; ///< points to @ref Token::asString if the token is string or identifier
+			/// Points to @ref Token::asString if the token is string or
+			/// identifier
+			char* string;
 		};
 }; // end class TokenDataVal
 
@@ -82,7 +87,8 @@ class Token
 	public:
 		Token(): code(TC_ERROR) {}
 		Token(const Token& b);
-		std::string getInfoStr() const; ///< Get a string with the info of the token
+		/// Get a string with the info of the token
+		std::string getInfoStr() const;
 		void print() const; ///< Print info of the token
 
 		/// @name accessors
@@ -96,9 +102,10 @@ class Token
 	private:
 		boost::array<char, MAX_SCRIPT_LINE_LEN> asString;
 		TokenCode code; ///< The first thing you should know about a token
-		TokenDataType dataType; ///< Additional info in case @ref code is @ref TC_NUMBER
+		/// Additional info in case @ref code is @ref TC_NUMBER
+		TokenDataType dataType;
 		TokenDataVal value; ///< A value variant
-}; // end class Token
+};
 
 
 } // end namespace

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