Code::Blocks

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: Ceniza on July 01, 2005, 07:41:50 pm

Title: New AStyle plugin
Post by: Ceniza on July 01, 2005, 07:41:50 pm
I'm pretty sure it'sn't the most popular plugin of Code::Blocks, but when it comes handy it's good to have it working :)

The original plugin uses AStyle 1.15.3, the new plugin uses AStyle 1.17.0-dev CVS.

There was a big change that makes it easier to use: std::istream instead of the AStyle stream iterator.

The current implementation had a few problems when applying the settings, that's now fixed.

I added the Bracket type combobox so now you can decide if you want Break, Attach, Linux or None when you customize.

I hope it be accepted to replace the current CVS version.

Well, the link, of course: http://gda.utp.edu.co/~ceniza/CodeBlocks/astyle.zip
Title: New AStyle plugin
Post by: Urxae on July 01, 2005, 08:13:15 pm
Wouldn't it be better to create a patch against Code::Blocks CVS and submit it (http://sourceforge.net/tracker/?atid=707418&group_id=126998&func=browse)?
Title: New AStyle plugin
Post by: mandrav on July 01, 2005, 08:59:54 pm
Quote from: fvbommel
Wouldn't it be better to create a patch against Code::Blocks CVS and submit it (http://sourceforge.net/tracker/?atid=707418&group_id=126998&func=browse)?

Yes that is better for patches. But, I think, we have an exception here since he updated to the newest astyle code too (which we keep in our CVS)...

Anyway, thanks Ceniza. Your changes have been applied to CVS :)

Yiannis.
Title: New AStyle plugin
Post by: tiwag on July 02, 2005, 07:38:57 am
With the new astyle plugin,
the indentation of if(){} blocks is wrong,
when using K&R style (at least there i found it happen),
it's indented one size too much.

this sample, reference "K&R" style
Code: [Select]
void Notify() {
    if(!m_frame->IsRunning()) {
        m_gauge->SetValue(0);
    }
    else {
        if(!m_bInit) {
            if(m_thread->GetRSSLength()) {
                m_bInit = true;
            }
        }
        else {
            m_gauge->SetValue(m_thread->GetRSSPos());
            m_frame->SetStatusText(
                wxString::Format(wxT("Converting Data...  %i of %i"),
                                 m_thread->GetRSSPos(),
                                 m_thread->GetRSSLength()
                                )
            );
        }
    }
}


astyled with "K&R"
Code: [Select]
void Notify() {
    if ( !m_frame->IsRunning() ) {
            m_gauge->SetValue( 0 );
        }
    else {
            if ( !m_bInit ) {
                    if ( m_thread->GetRSSLength() ) {
                            m_bInit = true;
                        }
                }
            else {
                    m_gauge->SetValue( m_thread->GetRSSPos() );
                    m_frame->SetStatusText(
                        wxString::Format( wxT( "Converting Data...  %i of %i" ),
                                          m_thread->GetRSSPos(),
                                          m_thread->GetRSSLength()
                                        )
                    );
                }
        }
}

is indented one size too much !


btw, the K&R preview-sample misses a bracket '}'
Code: [Select]
namespace foospace {
    int Foo() {
        if (isBar) {
            bar();
            return 1;
        }   <<<<<<<<<<<<<<<<<<<<<missing
        else
            return 0;
    }
}
Title: New AStyle plugin
Post by: Ceniza on July 02, 2005, 09:34:53 am
Thanks for your feedback.

When I updated and "fixed" the plugin I focused in the Custom style and considered the predefined ones were right, but it seems I was wrong.

I had to enable and disable even more options to get the right results in the predifined styles. Hadn't noticed the sample was wrong for almost all of them.

I tested all the styles this time and they seem to be working as they should now.

I'd really need to make a file to test all the cases, pass it through AStyle, AStyle plugin and compare the results.

By now I'll upload the new files (just 2) which I had to modify. I'll try to make the test file later (I really need to sleep first).

I'll also include a 3rd file (the resource file) where I made a little change.

New files: http://gda.utp.edu.co/~ceniza/CodeBlocks/astyle-020705.zip
Title: New AStyle plugin
Post by: tiwag on July 02, 2005, 10:35:12 am
Quote from: Ceniza
Thanks for your feedback.

Thanks for your update, works fine now !

Quote from: Ceniza
I'll try to make the test file later (I really need to sleep first).

please don't hurry !  we look forward to hear from you again...
Title: New AStyle plugin
Post by: squizzz on July 02, 2005, 01:29:42 pm
Hey, I played a bit trying to fool Source code formatter (AStyle) plugin (finalbeta 1.0), and found nice benchmarks that make it quite easy. I thought that maybe someone also find this resource valuable, so here it goes: The 2004 Allegro ScreenHack (http://www.allegro.cc/forums/view_thread.php?_id=331094&page=0).

Most of the sources compiles & runs if Allegro game programming library (http://alleg.sourceforge.net/) is set up.

Btw. I found one example that worked *almost* correctly (function alert  should go into single line, I suppose):
before (http://img102.imageshack.us/img102/3500/00astylebefore2ex.jpg)
after (http://img102.imageshack.us/img102/5894/02astyleafter7xi.jpg)
Title: New AStyle plugin
Post by: Ceniza on July 02, 2005, 06:40:30 pm
Allegro... my old fellow :)

The ScreenHack entries really are a good source for testing, even though they won't test everything (most people uses C so it won't test namespaces, classes, ...).

Quote
Btw. I found one example that worked *almost* correctly (function alert should go into single line, I suppose):


In the original file the call to alert is split and AStyle will keep it split too with some indentation, so... it works correctly? :P

Quote
Thanks for your update, works fine now !


Glad to read it :)

Quote
please don't hurry ! we look forward to hear from you again...


Ok. When I get it done I'll comment about it here.
Title: New AStyle plugin
Post by: mandrav on July 02, 2005, 09:05:28 pm
Quote
New files: http://gda.utp.edu.co/~ceniza/CodeBlocks/astyle-020705.zip

CVS updated. Thanks :)

Yiannis.
Title: Re: New AStyle plugin
Post by: jochen on February 21, 2006, 02:38:33 pm
The new AStyle plugin completely deletes lines when they contain German umlauts, e. g.

    // **für Test auf U0***************

or

        if (U1RBL==0x07) // Änderung
        {
          ...
        }

Seems this makes it unusable :-(

Any idea?

Jochen