My uncrustify config

Diff from the default config for c++. Good parameter definition.

> input_tab_size                           = 4        # number
> output_tab_size                          = 4        # number
> indent_columns                           = 4        # number
> indent_with_tabs                         = 0        # number
> indent_class                             = true     # false/true
> indent_class_colon                       = true     # false/true
> nl_fdef_brace                            = force    # ignore/add/remove/force

before:

#include "global.h"

#ifndef __c2dxspike__Stone__
#define __c2dxspike__Stone__
#include "HelloWorldScene.h"
#include <iostream>

typedef enum tagState {
kStateGrabbed,
kStateUngrabbed
} touchState;

class Stone : public CCNode, CCTargetedTouchDelegate {
public:
Stone();
virtual ~Stone();
...

CCRect Stone::setStoneColor(int stoneType)
{
this->stoneType = stoneType;
CCRect color;

switch (this->stoneType) {
case 0:
color = CCRectMake(68, 2, 32, 32);
break;

case 1:
color = CCRectMake(132, 2, 32, 32);
break;

case 2:
color = CCRectMake(2, 2, 32, 32);
break;

case 3:
color = CCRectMake(100, 2, 32, 32);
break;
}

return color;
}

after uncrustify *.cpp *.h –no-backup:

#include "global.h"

#ifndef __c2dxspike__Stone__
#define __c2dxspike__Stone__
#include "HelloWorldScene.h"
#include <iostream>

typedef enum tagState {
    kStateGrabbed,
    kStateUngrabbed
} touchState;

class Stone : public CCNode, CCTargetedTouchDelegate {
public:
    Stone();
    virtual ~Stone();
...

CCRect Stone::setStoneColor(int stoneType)
{
    this->stoneType = stoneType;
    CCRect color;

    switch (this->stoneType) {
    case 0:
        color = CCRectMake(68, 2, 32, 32);
        break;

    case 1:
        color = CCRectMake(132, 2, 32, 32);
        break;

    case 2:
        color = CCRectMake(2, 2, 32, 32);
        break;

    case 3:
        color = CCRectMake(100, 2, 32, 32);
        break;
    }

    return color;
}

Leave a Reply

Your email address will not be published. Required fields are marked *