Commit 6ab160bb authored by math's avatar math
Browse files

* BrainLinter does now recognize falsy indented public,protected and private lables

 * CodeGenerator now
   * doesn't write trailing whitespace
   * write output to the files if they won't exists
parent 576b0d8b
......@@ -34,12 +34,12 @@
*/
int main( int argc, char* argv[] )
{
std::cout << "BrainCognize Copyright (C) 2009 SomeCopyrightowner" << std::endl
<< "This program comes with ABSOLUTELY NO WARRANTY." << std::endl
<< "This is free software, and you are welcome to redistribute it" << std::endl
<< "under the terms of the GNU Lesser General Public License." << std::endl
<< "You should have received a copy of the GNU Lesser General Public License" << std::endl
<< "along with BrainCognize. If not, see <http://www.gnu.org/licenses/>." << std::endl;
std::cout << "BrainCognize Copyright (C) 2009 SomeCopyrightowner\n"
"This program comes with ABSOLUTELY NO WARRANTY.\n"
"This is free software, and you are welcome to redistribute it\n"
"under the terms of the GNU Lesser General Public License.\n"
"You should have received a copy of the GNU Lesser General Public License\n"
"along with BrainCognize. If not, see <http://www.gnu.org/licenses/>." << std::endl;
BMainApplication app;
return app.runQT( argc, argv );
......
......@@ -30,25 +30,25 @@
*/
class BGLScenePainter
{
public:
BGLScenePainter();
virtual ~BGLScenePainter();
/**
* Initialize the OpenGL context, e.g., set main transformation matrices.
*/
virtual void initGL() const;
/**
* Do the OpenGL painting in every frame.
*/
virtual void paintGL() const;
/**
* Called, when the window is resized and re-initialization of the
* window parameters and matrices may need to be done.
*/
virtual void resizeGL( int width, int height ) const;
public:
BGLScenePainter();
virtual ~BGLScenePainter();
/**
* Initialize the OpenGL context, e.g., set main transformation matrices.
*/
virtual void initGL() const;
/**
* Do the OpenGL painting in every frame.
*/
virtual void paintGL() const;
/**
* Called, when the window is resized and re-initialization of the
* window parameters and matrices may need to be done.
*/
virtual void resizeGL( int width, int height ) const;
};
......
......@@ -30,17 +30,17 @@
*/
class BGUI
{
public:
virtual ~BGUI();
public:
virtual ~BGUI();
/**
* \brief
* enable/disable the access to the GUI
* \post
* GUI enabled/disabled
* \param enable true iff gui should be enabled
*/
virtual void setEnabled( bool enable ) = 0;
/**
* \brief
* enable/disable the access to the GUI
* \post
* GUI enabled/disabled
* \param enable true iff gui should be enabled
*/
virtual void setEnabled( bool enable ) = 0;
};
/**
......
......@@ -48,42 +48,42 @@ class BQtPipelineBrowser;
*/
class BMainWindow : public BGUI
{
public:
public:
/**
* Set up all widgets menus an buttons in the main window.
*/
void setupGUI( QMainWindow *MainWindow );
/**
* Set up all widgets menus an buttons in the main window.
*/
void setupGUI( QMainWindow *MainWindow );
/**
* \brief
* enable/disable the access to the GUI
* \post
* GUI enabled/disabeld
* \param enable true iff gui should be enabled
*/
void setEnabled( bool enable );
/**
* \brief
* enable/disable the access to the GUI
* \post
* GUI enabled/disabeld
* \param enable true iff gui should be enabled
*/
void setEnabled( bool enable );
private:
QAction* m_actionLoad;
QAction* m_actionSave;
QAction* m_actionPreferences;
QAction* m_actionExit;
QAction* m_actionAbout_BrainCognize;
QWidget* m_centralwidget;
QMenuBar* m_menubar;
QMenu* m_menuFile;
QMenu* m_menuHelp;
QStatusBar* m_statusBar;
QToolBar* m_toolBar;
private:
QAction* m_actionLoad;
QAction* m_actionSave;
QAction* m_actionPreferences;
QAction* m_actionExit;
QAction* m_actionAbout_BrainCognize;
QWidget* m_centralwidget;
QMenuBar* m_menubar;
QMenu* m_menuFile;
QMenu* m_menuHelp;
QStatusBar* m_statusBar;
QToolBar* m_toolBar;
BQtGLWidget* m_glWidget;
BQtPipelineBrowser* m_pipelineBrowser;
BQtGLWidget* m_glWidget;
BQtPipelineBrowser* m_pipelineBrowser;
/**
* Helper routine for adding new docks with GL content
*/
void addDockableGLWidget( QMainWindow *MainWindow );
/**
* Helper routine for adding new docks with GL content
*/
void addDockableGLWidget( QMainWindow *MainWindow );
};
#endif // BMAINWINDOW_H
......@@ -35,55 +35,55 @@ class BGLScenePainter;
*/
class BQtGLWidget: public QGLWidget
{
public:
explicit BQtGLWidget( QWidget *parent = 0 );
BQtGLWidget( BGLScenePainter* scenePainter, QWidget *parent = 0 );
virtual ~BQtGLWidget();
public:
explicit BQtGLWidget( QWidget *parent = 0 );
BQtGLWidget( BGLScenePainter* scenePainter, QWidget *parent = 0 );
virtual ~BQtGLWidget();
/**
* returns the recommended size for the widget to allow
* parent widgets to give it a proper initial layout
*/
QSize sizeHint() const;
/**
* returns the recommended size for the widget to allow
* parent widgets to give it a proper initial layout
*/
QSize sizeHint() const;
/**
* This virtual function is called whenever the widget has been
* resized. The new size is passed in width and height.
*
* \note It seem that the function is not called if declared const, so it
* is not const.
*/
void resizeGL( int width, int height );
/**
* This virtual function is called whenever the widget has been
* resized. The new size is passed in width and height.
*
* \note It seem that the function is not called if declared const, so it
* is not const.
*/
void resizeGL( int width, int height );
protected:
/**
* This function is called once before the first
* call to paintGL() or resizeGL(), and then once whenever
* the widget has been assigned a new QGLContext.
*
* \note It seem that the function is not called if declared const, so it
* is not const.
*/
void initializeGL();
protected:
/**
* This function is called once before the first
* call to paintGL() or resizeGL(), and then once whenever
* the widget has been assigned a new QGLContext.
*
* \note It seem that the function is not called if declared const, so it
* is not const.
*/
void initializeGL();
private:
/**
* This function is called whenever the widget needs to be painted.
*
* \note It seem that the function is not called if declared const, so it
* is not const.
*/
void paintGL();
private:
/**
* This function is called whenever the widget needs to be painted.
*
* \note It seem that the function is not called if declared const, so it
* is not const.
*/
void paintGL();
/**
* Holds the GL scene painter of the widget
*/
BGLScenePainter* m_scenePainter;
/**
* Holds the GL scene painter of the widget
*/
BGLScenePainter* m_scenePainter;
/**
* Holds the recommended size for the widget
*/
QSize m_recommendedSize;
/**
* Holds the recommended size for the widget
*/
QSize m_recommendedSize;
};
#endif // BQTGLWIDGET_H
......@@ -33,21 +33,21 @@
*/
class BQtPipelineBrowser: public QDockWidget
{
public:
BQtPipelineBrowser();
virtual ~BQtPipelineBrowser();
public:
BQtPipelineBrowser();
virtual ~BQtPipelineBrowser();
/**
* returns the recommended size for the widget to allow
* parent widgets to give it a proper initial layout
*/
QSize sizeHint() const;
/**
* returns the recommended size for the widget to allow
* parent widgets to give it a proper initial layout
*/
QSize sizeHint() const;
private:
/**
* Holds the recommended size for the widget
*/
QSize m_recommendedSize;
private:
/**
* Holds the recommended size for the widget
*/
QSize m_recommendedSize;
};
#endif // BQTPIPELINEBROWSER_H
......@@ -30,12 +30,12 @@
class BGUITest : public CxxTest::TestSuite
{
public:
// Since BGUI is abstrac no test are here to define
void testInstanziation( void )
{
TS_ASSERT( true );
}
public:
// Since BGUI is abstrac no test are here to define
void testInstanziation( void )
{
TS_ASSERT( true );
}
};
#endif // BGUI_TEST_H
......@@ -1879,10 +1879,10 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, error):
'Weird number of spaces at line-start. '
'Are you using a 2-space indent?')
# Labels should always be indented at least one space.
elif not initial_spaces and line[:2] != '//' and Search(r'[^:]:\s*$',
elif initial_spaces and line[:2] != '//' and Search(r'[^:]:\s*$',
line):
error(filename, linenum, 'whitespace/labels', 4,
'Labels should always be indented at least one space. '
'Labels should never be indented. '
'If this is a member-initializer list in a constructor, '
'the colon should be on the line after the definition header.')
......
......@@ -2,6 +2,7 @@
from optparse import OptionParser
import os
import sys
class RawCode(object):
def __init__(self, name, attr, structors):
......@@ -49,7 +50,11 @@ class RawCode(object):
def indent(self, level, str):
result = ""
for line in str.splitlines( True ):
result += (level*self._indent) + line
if line.strip() == "":
# don't indent empty lines
result += line
else:
result += (level*self._indent) + line
return result
def signatures(self, accessor):
......@@ -111,7 +116,7 @@ class HeaderCode(RawCode):
member_level = 1
result = self._header
result += self.indent(0, self._doxy)
result += "class " + self._name + " : public \n"
result += "class " + self._name + "\n"
result += "{\n"
result += self.indent(modifier_level, "public:\n")
if self._structors:
......@@ -144,15 +149,15 @@ class ImplementationCode(RawCode):
def renderSignatures(self):
result = ""
for sig in self.signatures("get"):
result += "\n" + sig[0] + self._name + "::" + sig[1] + "\n"
result += sig[0] + self._name + "::" + sig[1] + "\n"
result += "{\n"
result += self.indent(1, "return m_" + sig[1][3].lower() + sig[1][4:-8]) + ";\n"
result += "}\n"
result += "}\n\n"
for sig in self.signatures("set"):
result += "\n" + sig[0] + self._name + "::" + sig[1] + "\n"
result += sig[0] + self._name + "::" + sig[1] + "\n"
result += "{\n"
result += self.indent(1, "m_" + sig[1].split()[-2] + " = " + sig[1].split()[-2] + ";\n")
result += "}\n"
result += "}\n\n"
return result
def __str__(self):
......@@ -172,11 +177,29 @@ class TestCode(RawCode):
result = "TestCode"
return result
def exists( fname ):
return os.path.exists( fname )
def writeToFile( fname, payload ):
file = open(fname, 'w')
file.write( payload )
file.close()
def writeIfNotExists( code, extension ):
fname = code._name + extension
if exists( fname ):
sys.stderr.write("Error: file " + fname + " already exists.\n")
sys.exit(1)
else:
writeToFile( fname, str(code) )
def main():
synopsis = "\n\t%prog [options] Classname"
synopsis += "\n\t%prog --help\n"
synopsis += "Example:"
synopsis += "\n\t%prog --class --header --member=int,plistId --member=BSomeOtherClass,myMemeberVar BSomeClass"
synopsis += "\n\n%prog automatically writes the code to the corresponding files"
synopsis += "\n(cpp, h) and exists if it already exists."
parser = OptionParser(usage=synopsis, version="%prog 0.0_pre_alpha (USE AT YOUR OWN RISK)")
parser.set_defaults(testsuite=False)
parser.set_defaults(cls=False)
......@@ -207,9 +230,9 @@ def main():
parser.error("No code should be generated?, use at least one option: --class, --header or --test")
if options.cls:
print ImplementationCode(classname, attributes, options.structors)
writeIfNotExists( ImplementationCode(classname, attributes, options.structors), ".cpp" )
if options.header:
print HeaderCode(classname, attributes, options.structors)
writeIfNotExists( HeaderCode(classname, attributes, options.structors), ".h" )
if options.testsuite:
print TestCode(classname)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment