Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: Loaden on March 27, 2010, 02:54:50 pm

Title: Add astyle's features: --pad-header, update Astyle to 1.24 RELEASE
Post by: Loaden on March 27, 2010, 02:54:50 pm
Hello, everyone! After I renewed efforts, I have solved the problem that bothers me for a long time.
THE OLD QUESTION: http://forums.codeblocks.org/index.php/topic,11847.0.html (http://forums.codeblocks.org/index.php/topic,11847.0.html)

I downloaded the 'AStyle official release version 1.24' from official website, and replace all astyle source to lastest version.
Then, I make these patch for add '--pad-header' features.

It's works well now. :lol:
Code
Index: src/plugins/astyle/astyleconfigdlg.cpp

===================================================================

--- src/plugins/astyle/astyleconfigdlg.cpp (revision 6196)

+++ src/plugins/astyle/astyleconfigdlg.cpp (working copy)

@@ -224,6 +224,7 @@

   XRCCTRL(*this, "chkPadOperators", wxCheckBox)->Enable(!en);
   XRCCTRL(*this, "chkPadParensOut", wxCheckBox)->Enable(!en);
   XRCCTRL(*this, "chkPadParensIn", wxCheckBox)->Enable(!en);
+  XRCCTRL(*this, "chkPadHeader", wxCheckBox)->Enable(!en);
   XRCCTRL(*this, "chkUnpadParens", wxCheckBox)->Enable(!en);
   XRCCTRL(*this, "chkKeepComplex", wxCheckBox)->Enable(!en);
   XRCCTRL(*this, "chkKeepBlocks", wxCheckBox)->Enable(!en);
@@ -310,6 +311,7 @@

   XRCCTRL(*this, "chkPadOperators", wxCheckBox)->SetValue(cfg->ReadBool(_T("/pad_operators"), false));
   XRCCTRL(*this, "chkPadParensIn", wxCheckBox)->SetValue(cfg->ReadBool(_T("/pad_parentheses_in"), false));
   XRCCTRL(*this, "chkPadParensOut", wxCheckBox)->SetValue(cfg->ReadBool(_T("/pad_parentheses_out"), false));
+  XRCCTRL(*this, "chkPadHeader", wxCheckBox)->SetValue(cfg->ReadBool(_T("/pad_header"), false));
   XRCCTRL(*this, "chkUnpadParens", wxCheckBox)->SetValue(cfg->ReadBool(_T("/unpad_parentheses"), false));
   XRCCTRL(*this, "chkKeepComplex", wxCheckBox)->SetValue(cfg->ReadBool(_T("/keep_complex"), false));
   XRCCTRL(*this, "chkKeepBlocks", wxCheckBox)->SetValue(cfg->ReadBool(_T("/keep_blocks"), false));
@@ -365,6 +367,7 @@

   cfg->Write(_T("/pad_operators"), XRCCTRL(*this, "chkPadOperators", wxCheckBox)->GetValue());
   cfg->Write(_T("/pad_parentheses_in"), XRCCTRL(*this, "chkPadParensIn", wxCheckBox)->GetValue());
   cfg->Write(_T("/pad_parentheses_out"), XRCCTRL(*this, "chkPadParensOut", wxCheckBox)->GetValue());
+  cfg->Write(_T("/pad_header"), XRCCTRL(*this, "chkPadHeader", wxCheckBox)->GetValue());
   cfg->Write(_T("/unpad_parentheses"), XRCCTRL(*this, "chkUnpadParens", wxCheckBox)->GetValue());
   cfg->Write(_T("/keep_complex"), XRCCTRL(*this, "chkKeepComplex", wxCheckBox)->GetValue());
   cfg->Write(_T("/keep_blocks"), XRCCTRL(*this, "chkKeepBlocks", wxCheckBox)->GetValue());
Index: src/plugins/astyle/formattersettings.cpp

===================================================================

--- src/plugins/astyle/formattersettings.cpp (revision 6196)

+++ src/plugins/astyle/formattersettings.cpp (working copy)

@@ -137,6 +137,7 @@

       formatter.setOperatorPaddingMode(cfg->ReadBool(_T("/pad_operators")));
       formatter.setParensOutsidePaddingMode(cfg->ReadBool(_T("/pad_parentheses_out")));
       formatter.setParensInsidePaddingMode(cfg->ReadBool(_T("/pad_parentheses_in")));
+      formatter.setParensHeaderPaddingMode(cfg->ReadBool(_T("/pad_header")));
       formatter.setParensUnPaddingMode(cfg->ReadBool(_T("/unpad_parentheses")));
       formatter.setSingleStatementsMode(!cfg->ReadBool(_T("/keep_complex")));
       formatter.setBreakOneLineBlocksMode(!cfg->ReadBool(_T("/keep_blocks")));
Index: src/plugins/astyle/resources/configuration.xrc

===================================================================

--- src/plugins/astyle/resources/configuration.xrc (revision 6196)

+++ src/plugins/astyle/resources/configuration.xrc (working copy)

@@ -325,6 +325,13 @@

  <border>8</border>
  </object>
  <object class="sizeritem">
+ <object class="wxCheckBox" name="chkPadHeader">
+ <label>Insert space padding after paren headers only</label>
+ </object>
+ <flag>wxTOP|wxALIGN_LEFT|wxALIGN_TOP</flag>
+ <border>8</border>
+ </object>
+ <object class="sizeritem">
  <object class="wxCheckBox" name="chkUnpadParens">
  <label>Remove extra space padding around parenthesis</label>
  </object>

Quote
--pad-header / -H
Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...). Any end of line comments will remain in the original column, if possible. This can be used with unpad-paren to remove unwanted spaces.

if(isFoo(a, b))
    bar(a, b);

becomes:

if (isFoo(a, b))
    bar(a, b);

http://astyle.sourceforge.net/astyle.html (http://astyle.sourceforge.net/astyle.html)

[attachment deleted by admin]
Title: Re: Add astyle's features: --pad-header, update Astyle to 1.24 RELEASE
Post by: Loaden on March 29, 2010, 01:56:36 am
Why not anyone concerned about this?
When the AStyle upgrade to 1.24 before, --pad-header is the default effective.
So, to that extent, this is a bug fix.
Title: Re: Add astyle's features: --pad-header, update Astyle to 1.24 RELEASE
Post by: MortenMacFly on March 29, 2010, 07:04:41 am
Why not anyone concerned about this?
Why do you think so? the download counter clearly states that there is interest. One of them is me, having it applied in my local copy since yesterday. However, I already had updated astyle to 1.24 (even including some bug fixes from trunk), so this nothing really "new" to me.
However, as we don't update astyle before the release (we are in feature freeze) this will have to wait a little. Keep in mind that this doesn't mean nobody cares. Please be patient.
Title: Re: Add astyle's features: --pad-header, update Astyle to 1.24 RELEASE
Post by: Loaden on March 29, 2010, 07:12:37 am
Sorry, I thought that we do not care about this.But it seems that I be patient enough.
I have made all of my patch to the CB's patch tracker.
 :P
Title: Re: Add astyle's features: --pad-header, update Astyle to 1.24 RELEASE
Post by: MortenMacFly on March 29, 2010, 07:20:19 am
Sorry, I thought that we do not care about this.But it seems that I be patient enough.
I have made all of my patch to the CB's patch tracker.
Good one.

BTW: There is much happing at the moment as you probably realise - tons of patches, new plugins, new features, etc... It's hard to keep all of these things tracked, especially in the release phase. So if in doubt, a gentle reminder after the release will surely be helpful. However, of course not on day one after all. :lol: