<div dir="ltr">On 1 November 2013 08:14, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I've tried to describe Piglit's coding style and conventions in more<br>
detail. Hopefully, new contributors will read this and it'll save<br>
some some time and effort for the reviewers.<br>
<br>
Please feel free to add/update this info.<br></blockquote><div><br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
HACKING | 57 ++++++++++++++++++++++++++++++++++++++++++++-------------<br>
1 file changed, 44 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/HACKING b/HACKING<br>
index a227fc6..03519e5 100644<br>
--- a/HACKING<br>
+++ b/HACKING<br>
@@ -63,25 +63,56 @@ entirely new project. The most important reasons are:<br>
<br>
<br>
<br>
+\ Coding style<br>
+ -------------<br>
<br>
-\ Ugly Things (or: Coding style)<br>
- -------------------------------<br>
+Basic formatting:<br>
<br>
-As a rule of thumb, coding style should be preserved in test code taken from<br>
-other projects, as long as that code is self-contained.<br>
+* Indent with 8-column tabs<br>
+* Limit lines to 78 characters or less<br>
+* Function return type and name go on successive lines<br>
+* Opening function brace goes on line by itself<br>
+* Opening statement braces go on same line as the 'for' or 'else'<br>
<br>
-Apart from that, the following rules are cast in stone:<br>
+The following indent command will generally format your code for piglit's<br>
+style:<br>
<br>
-1. Use tabulators for indentation<br>
-2. Use spaces for alignment<br>
-3. No whitespace at the end of a line<br>
+ indent -br -i8 -npcs -ce input.c -o output.c<br>
<br>
-See <a href="http://electroly.com/mt/archives/000002.html" target="_blank">http://electroly.com/mt/archives/000002.html</a> for a well-written rationale.<br>
+Though, that doesn't give perfect results. It messes up the<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN/END section. And array initializers sometimes<br>
+come out funny.<br>
<br>
-Use whatever tabulator size you want:<br>
-If you adhere to the rules above, the tab size does not matter. Tab size 4<br>
-is recommended because it keeps the line lengths reasonable, but in the end,<br>
-that's purely a matter of personal taste.<br>
+When in doubt see other recently added piglit tests for coding style.<br>
+<br>
+<br>
+Code conventions:<br>
+<br>
+* Use "const" qualifiers whenever possible on array declarations, pointers<br>
+ and global variables.<br>
+* Use "static const" for initialized arrays whenever possible.<br>
+* Preprocessor macros should be UPPER_CASE<br>
+* Enumeration tokens should be UPPER_CASE<br>
+* Most other identifiers are lower_case_with_underscores<br>
+* Use int, float, bool except when GL types (GLint, GLfloat) are really needed<br>
+* Don't put declarations after code. For example:<br>
+ if (x < 3)<br>
+ x = 0;<br>
+ int y = x * x;<br>
+ This will not compile with MSVC. The 'int y' declaration must be at the<br>
+ top of the brace-block.<br>
+* Don't use named/designated initializers. They don't compile with MSVC.<br>
+* Write tests that are easily read, understood and debugged. Long, complicated<br>
+ functions are frowned upon.<br>
+* Don't try to test too much in a single test program. Most piglit programs<br>
+ are less than 300 lines long.<br>
+<br>
+<br>
+Utility code:<br>
+<br>
+Piglit has a rich set of utility functions for basic drawing, setting<br>
+up shaders, probing pixels, error checking, etc. Try to use them before<br>
+rolling your own.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
1.7.10.4<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>