<p dir="ltr"><br>
Forgot to send to list.</p>
<p dir="ltr">><br>
> 26. mai 2015 15.35 skrev "Brian Paul" <<a href="mailto:brianp@vmware.com">brianp@vmware.com</a>>:<br>
> ><br>
> > On 05/25/2015 01:59 PM, Thomas Helland wrote:<br>
> >><br>
> >> 2015-05-25 18:20 GMT+02:00 Brian Paul <<a href="mailto:brianp@vmware.com">brianp@vmware.com</a>>:<br>
> >>><br>
> >>> This hasn't been updated in a long time and from recent discussion on<br>
> >>> the mailing list, it's not always clear what's expected. Hopefully,<br>
> >>> this will help a bit.<br>
> >>> ---<br>
> >>> docs/devinfo.html | 155 ++++++++++++++++++++++++++++++------------------------<br>
> >>> 1 file changed, 86 insertions(+), 69 deletions(-)<br>
> >>><br>
> >>> diff --git a/docs/devinfo.html b/docs/devinfo.html<br>
> >>> index a6fb76b..4ab8e4b 100644<br>
> >>> --- a/docs/devinfo.html<br>
> >>> +++ b/docs/devinfo.html<br>
> >>> @@ -28,97 +28,114 @@<br>
> >>> <h2 id="style">Coding Style</h2><br>
> >>><br>
> >>> <p><br>
> >>> -Mesa's code style has changed over the years. Here's the latest.<br>
> >>> +Mesa is over 20 years old and the coding style has evolved over time.<br>
> >>> +Some old parts use a style that's a bit out of date.<br>
> >>> +If the guidelines below don't cover something, try following the format of<br>
> >>> +existing, neighboring code.<br>
> >>> </p><br>
> >>><br>
> >>> <p><br>
> >>> -Comment your code! It's extremely important that open-source code be<br>
> >>> -well documented. Also, strive to write clean, easily understandable code.<br>
> >>> +Basic formatting guidelines<br>
> >>> </p><br>
> >>><br>
> >>> -<p><br>
> >>> -3-space indentation<br>
> >>> -</p><br>
> >>> -<br>
> >>> -<p><br>
> >>> -If you use tabs, set them to 8 columns<br>
> >>> -</p><br>
> >>> +<ul><br>
> >>> +<li>3-space indentation, no tabs.<br>
> >>> +<li>Limit lines to 78 or fewer characters. The idea is to prevent line<br>
> >>> +wrapping in 80-column editors and terminals. There are exceptions, such<br>
> >>> +as if you're defining a large, static table of information.<br>
> >>> +<li>Opening braces go on the same line as the if/for/while statement.<br>
> >>> +For example:<br>
> >>> +<pre><br>
> >>> + if (condition) {<br>
> >>> + foo;<br>
> >>> + } else {<br>
> >>> + bar;<br>
> >>> + }<br>
> >>> +</pre><br>
> >>><br>
> >>> -<p><br>
> >>> -Line width: the preferred width to fill comments and code in Mesa is 78<br>
> >>> -columns. Exceptions are sometimes made for clarity (e.g. tabular data is<br>
> >>> -sometimes filled to a much larger width so that extraneous carriage returns<br>
> >>> -don't obscure the table).<br>
> >>> -</p><br>
> >>> +<li>Put a space before/after operators. For example, <tt>a = b + c;</tt><br>
> >>> +and not <tt>a=b+c;</tt><br>
> >>><br>
> >>> -<p><br>
> >>> -Brace example:<br>
> >>> -</p><br>
> >>> +<li>This GNU indent command generally does the right thing for formatting:<br>
> >>> <pre><br>
> >>> - if (condition) {<br>
> >>> - foo;<br>
> >>> - }<br>
> >>> - else {<br>
> >>> - bar;<br>
> >>> - }<br>
> >>> -<br>
> >>> - switch (condition) {<br>
> >>> - case 0:<br>
> >>> - foo();<br>
> >>> - break;<br>
> >>> -<br>
> >>> - case 1: {<br>
> >>> - ...<br>
> >>> - break;<br>
> >>> - }<br>
> >>> -<br>
> >>> - default:<br>
> >>> - ...<br>
> >>> - break;<br>
> >>> - }<br>
> >>> + indent -br -i3 -npcs --no-tabs infile.c -o outfile.c<br>
> >>> </pre><br>
> >>><br>
> >>> -<p><br>
> >>> -Here's the GNU indent command which will best approximate my preferred style:<br>
> >>> -(Note that it won't format switch statements in the preferred way)<br>
> >>> -</p><br>
> >>> +<li>Use comments wherever you think it would be helpful for other developers.<br>
> >>> +Several specific cases and style examples follow. Note that we roughly<br>
> >>> +follow <a href="<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.stack.nl_-7Edimitri_doxygen_&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=PsoDvq4p3p1CKPfE1UV_uawQ3CZ0Z4qqIsPOp3mrKxo&s=ayuYzAhS4g_eIzw-agUVkTRzRxtLxNDBJPHZuoSTyr8&e=">https://urldefense.proofpoint.com/v2/url?u=http-3A__www.stack.nl_-7Edimitri_doxygen_&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=PsoDvq4p3p1CKPfE1UV_uawQ3CZ0Z4qqIsPOp3mrKxo&s=ayuYzAhS4g_eIzw-agUVkTRzRxtLxNDBJPHZuoSTyr8&e=</a> ">Doxygen</a> conventions.<br>
> >>><br>
> >>> +<br><br>
> >>> +<br><br>
> >>> +Single-line comments:<br>
> >>> <pre><br>
> >>> - indent -br -i3 -npcs --no-tabs infile.c -o outfile.c<br>
> >>> + /* null-out pointer to prevent dangling reference below */<br>
> >>> + bufferObj = NULL;<br>
> >>> +</pre><br>
> >>> +Or,<br>
> >>> +<pre><br>
> >>> + bufferObj = NULL; /* prevent dangling reference below */<br>
> >>> +</pre><br>
> >>> +Multi-line comment:<br>
> >>> +<pre><br>
> >>> + /* If this is a new buffer object id, or one which was generated but<br>
> >>> + * never used before, allocate a buffer object now.<br>
> >>> + */<br>
> >>> +</pre><br>
> >>> +We try to quote the OpenGL specification where prudent:<br>
> >>> +<pre><br>
> >>> + /* Page 38 of the PDF of the OpenGL ES 3.0 spec says:<br>
> >>> + *<br>
> >>> + * "An INVALID_OPERATION error is generated for any of the following<br>
> >>> + * conditions:<br>
> >>> + *<br>
> >>> + * * <length> is zero."<br>
> >>> + *<br>
> >>> + * Additionally, page 94 of the PDF of the OpenGL 4.5 core spec<br>
> >>> + * (30.10.2014) also says this, so it's no longer allowed for desktop GL,<br>
> >>> + * either.<br>
> >>> + */<br>
> >>> +</pre><br>
> >>> +Function comment example:<br>
> >>> +<pre><br>
> >>> + /**<br>
> >>> + * Create and initialize a new buffer object. Called via the<br>
> >>> + * ctx->Driver.CreateObject() driver callback function.<br>
> >>> + * \param name integer name of the object<br>
> >>> + * \param type one of GL_FOO, GL_BAR, etc.<br>
> >>> + * \return pointer to new object or NULL if error<br>
> >>> + */<br>
> >>> + struct gl_object *<br>
> >>> + _mesa_create_object(GLuint name, GLenum type)<br>
> >>> </pre><br>
> >>><br>
> >>> +<li>Put the function return type and qualifiers on one line and the function<br>
> >>> +name and parameters on the next, as seen above. This makes it easy to use<br>
> >>> +<code>grep ^function_name dir/*</code> to find function definitions.<br>
> >>><br>
> >><br>
> >> Maybe add that we put the opening brace on a new line for functions?<br>
> >> (and include that in the function definition example above)<br>
> ><br>
> ><br>
> > Done.<br>
> ><br>
><br>
> Nice :-)<br>
><br>
> ><br>
> ><br>
> >> This kinda confused me at the beginning;<br>
> >> why put the brace on the same line as if's/loops,<br>
> >> but on its own line for functions?<br>
> ><br>
> ><br>
> > It's a convention used by many other projects, like Linux. I think it goes back to the K&R book. I think of it as top-level constructs (functions, structs, enums) having the opening brace on its own line.<br>
> ><br>
> ><br>
> ><br>
> >> I got some nits due to that when I first started mesa-hacking.<br>
> >> Having it stated here may just help others avoid that.<br>
> >> It's your call, I don't have a strong opinion.<br>
> >><br>
> >> I'm no expert on how to add extensions, but patch 2 and 3,<br>
> >> and the html of patch one LGTM. (Apart from what Ilia pointed out)<br>
> ><br>
> ><br>
> > Is that a R-b?<br>
> ><br>
> > -Brian<br>
> ><br>
> ><br>
><br>
> Yes,<br>
><br>
> Reviewed-by: Thomas Helland <<a href="mailto:thomashelland90@gmail.com">thomashelland90@gmail.com</a>></p>