Jump to content

Code Style


GreenBox

Recommended Posts


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   101
  • Joined:  11/13/11
  • Last Seen:  

I want to cry every time I see how our code isn't uniform, each file/function uses a different code style.

It already was proposed before, but let's reconsider: We should normalize our source with astyle(http://astyle.sourceforge.net/).

We just have a problem, it will break all patches. What you guys think about it? And what style we should use, Allman? K&R?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.00
  • Content Count:  713
  • Reputation:   70
  • Joined:  11/08/11
  • Last Seen:  

I want to cry every time I see you guys using spaces everywhere to indent while like 98% of source use tab :P

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  69
  • Topics Per Day:  0.02
  • Content Count:  592
  • Reputation:   31
  • Joined:  11/14/11
  • Last Seen:  

hope this will be fix.. +1

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

I'm in favor of AStyle too, but when I tryed some function was getting quite long.

The better IDE I had to do this was codeblock, "format projet" using IDE, you'll see what I was talking about.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  148
  • Reputation:   46
  • Joined:  11/02/11
  • Last Seen:  

I use Allman but I think K&R is more beautiful.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

I vote for these Astyle options for trunk/src/:

# Brackets are broken from namespaces, classes, and function definitions. 
# Brackets are attached to statements within a function.
--style=kr

# Indent using tabs. Convert 4 spaces to 1 tab.
--indent=tab=4

# Indent 'class' and 'struct' blocks
--indent-classes

# Indent multi-line preprocessor definitions ending with a backslash.
--indent-preprocessor

# Indent comments beginning in column one.
--indent-col1-comments

# When a header is built of multiple lines, the lines will be aligned with the paren on the preceding line.
--min-conditional-indent=0

# Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...).
--pad-header
# Remove extra space padding around parenthesis on the inside and outside.
--unpad-paren

# Don't break complex statements and multiple statements residing on a single line.
--keep-one-line-statements

#########################################################
# Which --align-pointer and --align-reference options?
#########################################################

# Do not retain a backup of the original file. (your working copy has SVN History)
--suffix=none

# For each directory in the command line, process all subdirectories recursively.
--recursive

Also, some previous discussion: (rough draft) Scripting & Coding Style Guidelines and User:Gepard/Sandbox.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  148
  • Reputation:   46
  • Joined:  11/02/11
  • Last Seen:  

My parameter list:

--style=kr
--align-pointer=name
--align-reference=name
--mode=c
--lineend=linux
--convert-tabs
--keep-one-line-statements
--min-conditional-indent=0
--pad-header
--unpad-paren
--indent-col1-comments
--indent-preprocessor
--indent-labels
--indent-cases
--indent-switches
--indent=spaces=4
--suffix=none
--max-instatement-indent=80
--recursive

@edit

It is reducing the file size better thant I thought it would.

Also, a diff for atcommand.c so you can see how it would look like: atcommand.c.patch

went from 283kb to 275kb

@edit2

I uploaded the files already on astyle to a github repo so you can see for yourselves.

https://github.com/mkbu95/rathena_src_astyle

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  213
  • Reputation:   109
  • Joined:  05/21/12
  • Last Seen:  

Approved the K&R style patch based on votes, and discussion. GreenBox will soon reply with his commit he is making for it.

Thank you!

-Cookie

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   101
  • Joined:  11/13/11
  • Last Seen:  

Implemented in r16968.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

@GreenBox: was the conversion of indents from tabs to spaces intentional?

I want to cry every time I see you guys using spaces everywhere to indent while like 98% of source use tab :P

I also voted for tab indents /rice

# Indent using tabs. Convert 4 spaces to 1 tab.
--indent=tab=4

  • Upvote 1
Link to comment
Share on other sites

×
×
  • Create New...