Explorar el Código

Refactoring and documenting

Panagiotis Christopoulos Charitos hace 15 años
padre
commit
26197a938e

+ 1 - 1
docs/Doxyfile

@@ -1278,7 +1278,7 @@ INCLUDE_FILE_PATTERNS  =
 # instead of the = operator.
 
 PREDEFINED             = "PROPERTY_RW(_v0_,_v1_,_v2_,_v3_):=_v0_ _v1_;" \
-                         "PROPERTY_R(_v0_,_v1_,_v2_):=_v0_ _v2_;"
+                         "PROPERTY_R(_v0_,_v1_,_v2_):=_v0_ _v1_;"
 
 # 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. 

+ 7 - 6
src/Main.cpp

@@ -156,15 +156,15 @@ void initPhysics()
 
 
 
-	/*for (int i=0;i<app->getScene()->getPhyWorld()->getDynamicsWorld()->getCollisionObjectArray().size();i++)
+	/*for (int i=0; i<app->getScene()->getPhyWorld()->getDynamicsWorld()->getCollisionObjectArray().size();i++)
 	{
-		btCollisionObject* colObj = copyArray[i];
+		btCollisionObject* colObj = app->getScene()->getPhyWorld()->getDynamicsWorld()->getCollisionObjectArray()[i];
 		btRigidBody* body = btRigidBody::upcast(colObj);
-		if (body)
+		if( body )
 		{
-			if (body->getMotionState())
+			if( body->getMotionState() )
 			{
-				btDefaultMotionState* myMotionState = (btDefaultMotionState*)body->getMotionState();
+				MotionState* myMotionState = (MotionState*)body->getMotionState();
 				myMotionState->m_graphicsWorldTrans = myMotionState->m_startWorldTrans;
 				body->setCenterOfMassTransform( myMotionState->m_graphicsWorldTrans );
 				colObj->setInterpolationWorldTransform( myMotionState->m_startWorldTrans );
@@ -182,7 +182,8 @@ void initPhysics()
 				btRigidBody::upcast(colObj)->setLinearVelocity(btVector3(0,0,0));
 				btRigidBody::upcast(colObj)->setAngularVelocity(btVector3(0,0,0));
 			}
-		}*/
+		}
+	}*/
 }
 
 

+ 16 - 16
src/Resources/ShaderPrePreprocessor.cpp

@@ -89,7 +89,7 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 						// play
 
 						// its defined in same place so there is probable circular includance
-						if( vertShaderBegins.definedInLine==scanner.getLineNmbr() && vertShaderBegins.definedInFile==filename )
+						if( vertShaderBegins.definedInLine==scanner.getLineNumber() && vertShaderBegins.definedInFile==filename )
 						{
 							PARSE_ERR( "vertShaderBegins already defined in the same place. Check for circular or multiple includance" );
 							return false;
@@ -120,9 +120,9 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 						}
 
 						vertShaderBegins.definedInFile = filename;
-						vertShaderBegins.definedInLine = scanner.getLineNmbr();
+						vertShaderBegins.definedInLine = scanner.getLineNumber();
 						vertShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(depth) + " // " + lines[scanner.getLineNmbr()-1] );
+						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' + Util::intToStr(depth) + " // " + lines[scanner.getLineNumber()-1] );
 						// stop play
 					}
 /* geomShaderBegins */
@@ -131,7 +131,7 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 						// play
 
 						// its defined in same place so there is probable circular includance
-						if( geomShaderBegins.definedInLine==scanner.getLineNmbr() && geomShaderBegins.definedInFile==filename )
+						if( geomShaderBegins.definedInLine==scanner.getLineNumber() && geomShaderBegins.definedInFile==filename )
 						{
 							PARSE_ERR( "geomShaderBegins already defined in the same place. Check for circular or multiple includance" );
 							return false;
@@ -161,9 +161,9 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 						}
 
 						geomShaderBegins.definedInFile = filename;
-						geomShaderBegins.definedInLine = scanner.getLineNmbr();
+						geomShaderBegins.definedInLine = scanner.getLineNumber();
 						geomShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(depth) + " // " + lines[scanner.getLineNmbr()-1] );
+						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' + Util::intToStr(depth) + " // " + lines[scanner.getLineNumber()-1] );
 						// stop play
 					}
 /* fragShaderBegins */
@@ -172,7 +172,7 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 						// play
 
 						// its defined in same place so there is probable circular includance
-						if( fragShaderBegins.definedInLine==scanner.getLineNmbr() && fragShaderBegins.definedInFile==filename )
+						if( fragShaderBegins.definedInLine==scanner.getLineNumber() && fragShaderBegins.definedInFile==filename )
 						{
 							PARSE_ERR( "fragShaderBegins already defined in the same place. Check for circular or multiple includance" );
 							return false;
@@ -193,9 +193,9 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 						}
 
 						fragShaderBegins.definedInFile = filename;
-						fragShaderBegins.definedInLine = scanner.getLineNmbr();
+						fragShaderBegins.definedInLine = scanner.getLineNumber();
 						fragShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(depth) + " // " + lines[scanner.getLineNmbr()-1] );
+						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' + Util::intToStr(depth) + " // " + lines[scanner.getLineNumber()-1] );
 						// stop play
 					}
 /* include */
@@ -206,9 +206,9 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 						{
 							// play
 							//int line = sourceLines.size();
-							sourceLines.push_back( string("#line 0 ") + Util::intToStr(depth+1) + " // " + lines[scanner.getLineNmbr()-1] );
+							sourceLines.push_back( string("#line 0 ") + Util::intToStr(depth+1) + " // " + lines[scanner.getLineNumber()-1] );
 							if( !parseFileForPragmas( token->getValue().getString(), depth+1 ) ) return false;
-							sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(depth) +  " // end of " + lines[scanner.getLineNmbr()-1] );
+							sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' + Util::intToStr(depth) +  " // end of " + lines[scanner.getLineNumber()-1] );
 							// stop play
 						}
 						else
@@ -233,7 +233,7 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 								Vec<ShaderVarPragma>::iterator attrib = findShaderVar( output.attributes, varName );
 								if( attrib != output.attributes.end() )
 								{
-									if( attrib->definedInLine==scanner.getLineNmbr() && attrib->definedInFile==filename )
+									if( attrib->definedInLine==scanner.getLineNumber() && attrib->definedInFile==filename )
 									{
 										PARSE_ERR( "\"" << varName << "\" already defined in the same place. Check for circular or multiple includance" );
 									}
@@ -255,8 +255,8 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 								}
 								
 								// all ok, push it back
-								output.attributes.push_back( ShaderVarPragma( filename, scanner.getLineNmbr(), varName, loc ) );
-								sourceLines.push_back( lines[scanner.getLineNmbr()-1] );
+								output.attributes.push_back( ShaderVarPragma( filename, scanner.getLineNumber(), varName, loc ) );
+								sourceLines.push_back( lines[scanner.getLineNumber()-1] );
 							}
 							else
 							{
@@ -291,13 +291,13 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 /* newline */		
 		else if( token->getCode() == Scanner::TC_NEWLINE )
 		{
-			sourceLines.push_back( lines[ scanner.getLineNmbr() - 2 ] );
+			sourceLines.push_back( lines[ scanner.getLineNumber() - 2 ] );
 			//PRINT( lines[ scanner.getLineNmbr() - 2 ] )
 		}
 /* EOF */
 		else if( token->getCode() == Scanner::TC_EOF )
 		{
-			sourceLines.push_back( lines[ scanner.getLineNmbr() - 1 ] );
+			sourceLines.push_back( lines[ scanner.getLineNumber() - 1 ] );
 			//PRINT( lines[ scanner.getLineNmbr() - 1 ] )
 			break;
 		}

+ 3 - 3
src/Resources/ShaderPrePreprocessor.h

@@ -6,13 +6,13 @@
 
 
 /**
- * @brief Helper class used for shader program loading
+ * Helper class used for shader program loading
  *
  * The class fills some of the GLSL spec deficiencies. It adds the include preprocessor directive and the support to have all the
  * shaders in the same file. The file that includes all the shaders is called ShaderPrePreprocessor-compatible. The preprocessor pragmas are
  * four: include, vertShaderBegins, fragShaderBegins and attribute. The *ShaderBegins indicate where the shader code begins and must be
- * in certain order, first the vert shader and then the frag. The include is self-explanatory. The attribute is used to bind custom
- * locations to attributes.
+ * in certain order, first the vert shader then the optional geom and then the frag. The include is self-explanatory. The attribute is
+ * used to bind custom locations to attributes.
  */
 class ShaderPrePreprocessor
 {

+ 2 - 2
src/Tokenizer/Parser.h

@@ -13,8 +13,8 @@ namespace Parser {
 //=====================================================================================================================================
 // Parser macros                                                                                                                      =
 //=====================================================================================================================================
-#define PARSE_ERR(x) ERROR( "Parse Error (" << scanner.getScriptName() << ':' << scanner.getLineNmbr() << "): " << x )
-#define PARSE_WARN(x) WARNING( "Parse Warning (" << scanner.getScriptName() << ':' << scanner.getLineNmbr() << "): " << x )
+#define PARSE_ERR(x) ERROR( "Parse Error (" << scanner.getScriptName() << ':' << scanner.getLineNumber() << "): " << x )
+#define PARSE_WARN(x) WARNING( "Parse Warning (" << scanner.getScriptName() << ':' << scanner.getLineNumber() << "): " << x )
 
 // common parser errors
 #define PARSE_ERR_EXPECTED(x) PARSE_ERR( "Expected " << x << " and not " << Scanner::getTokenInfo(scanner.getCrntToken()) );

+ 3 - 3
src/Tokenizer/Scanner.cpp

@@ -243,7 +243,7 @@ void Scanner::getAllprintAll()
 	do
 	{
 		getNextToken();
-		cout << setw(3) << setfill('0') << getLineNmbr() << ": " << getTokenInfo( crntToken ) << endl;
+		cout << setw(3) << setfill('0') << getLineNumber() << ": " << getTokenInfo( crntToken ) << endl;
 	} while( crntToken.code != TC_EOF );
 }
 
@@ -319,10 +319,10 @@ const Scanner::Token& Scanner::getNextToken()
 		if( ch == '/' || ch == '*' )
 		{
 			putBackChar();
-			int line = getLineNmbr();
+			int line = getLineNumber();
 			checkComment();
 			
-			commentedLines = getLineNmbr() - line; // update commentedLines
+			commentedLines = getLineNumber() - line; // update commentedLines
 			lineNmbr -= commentedLines; // part of the ultimate hack
 		}
 		else

+ 16 - 16
src/Tokenizer/Scanner.h

@@ -28,7 +28,7 @@ class Scanner
 		bool checkChar();
 		bool checkSpecial();
 
-		void getLine(); ///< Reads a line from the script file
+		void getLine(); ///< Reads a line from the iostream
 		char getNextChar(); ///< 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 putBackChar(); ///< Put the char that Scanner::GetNextChar got back to the current line
 
@@ -52,7 +52,7 @@ class Scanner
 		};
 
 		static uint asciiLookupTable []; ///< The array contains one ascii_code_e for every symbol of the ASCII table
-		/// 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 for example asciiLookupTable[ (int)'a' ]
@@ -88,7 +88,7 @@ class Scanner
 			TC_INC, TC_DEC, TC_SHL, TC_SHR,                                                                                //32 - 35
 			TC_ASSIGN, TC_ASSIGNADD, TC_ASSIGNSUB, TC_ASSIGNMUL, TC_ASSIGNDIV, TC_ASSIGNMOD, TC_ASSIGNSHL, TC_ASSIGNSHR, TC_ASSIGNAND, TC_ASSIGNXOR,
 				TC_ASSIGNOR                                                                                             //36 - 47
-		};
+		}; // end enum TokenCode
 
 		/// The value of @ref Token::dataType
 		enum TokenDataType
@@ -100,7 +100,7 @@ class Scanner
 		};
 
 		/// Used inside the Token
-		struct TokenDataVal
+		class TokenDataVal
 		{
 			friend class Scanner;
 			friend class Token;
@@ -119,18 +119,18 @@ class Scanner
 
 			public:
 				// accessors
-				char        getChar()   const { return char_; } ///< Access the data as C char
-				ulong       getInt()    const { return int_; } ///< Access the data as unsigned int
-				float       getFloat()  const { return float_; }  ///< Access the data as double
-				const char* getString() const { return string; }  ///< Access the data as C string
-		};
+				char        getChar()   const { return char_; }  ///< Access the data as C char
+				ulong       getInt()    const { return int_; }   ///< Access the data as unsigned int
+				float       getFloat()  const { return float_; } ///< Access the data as double
+				const char* getString() const { return string; } ///< Access the data as C string
+		}; // end class TokenDataVal
 
 		/// The Token class
 		struct Token
 		{
-			PROPERTY_R( TokenCode, code, getCode )
-			PROPERTY_R( TokenDataType, dataType, getDataType )
-			PROPERTY_R( TokenDataVal, value, getValue )
+			PROPERTY_R( TokenCode, code, getCode ) ///< @ref PROPERTY_R : The first thing you shoud know about a token
+			PROPERTY_R( TokenDataType, dataType, getDataType ) ///< @ref PROPERTY_R : Additional info in case @ref code is @ref TC_NUMBER
+			PROPERTY_R( TokenDataVal, value, getValue ) ///< @ref PROPERTY_R : A value variant
 
 			friend class Scanner;
 
@@ -140,7 +140,7 @@ class Scanner
 			public:
 				Token(): code( TC_ERROR ) {}
 				Token( const Token& b );
-		};
+		}; // end class Token
 
 	//===================================================================================================================================
 	// reserved words                                                                                                                   =
@@ -164,7 +164,7 @@ class Scanner
 		char  line [MAX_SCRIPT_LINE_LEN]; ///< In contains the current line's text
 		char* pchar; ///< Points somewhere to @ref line
 		int   lineNmbr; ///< The number of the current line
-		bool  newlinesAsWhitespace; ///< Treat newlines as whitespace. If false means that the Scanner returns a new token for every line it finds
+		bool  newlinesAsWhitespace; ///< Treat newlines as whitespace. If false means that the Scanner returns (among others) newline tokens
 		/**
 		 * 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
@@ -199,7 +199,7 @@ class Scanner
 		const Token& getCrntToken() const { return crntToken; } ///< Accessor for the current token
 
 		const char* getScriptName() const { return scriptName; } ///< Get the name of the stream
-		int         getLineNmbr() const { return lineNmbr; } ///< Get the current line the Scanner is processing
-};
+		int         getLineNumber() const { return lineNmbr; } ///< Get the current line the Scanner is processing
+}; // end class Scanner
 
 #endif