X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=docs%2Fcodingstyle.html;h=686d6a3ddf47e2afab0f123d11af78a38d43a697;hb=c1c346f1667375e9330aa3f729b97e4a6ece0320;hp=7e9f470a1005d39320e0fdc8be75fea945a9832b;hpb=077879cf5e6b90023fb495e36d05bb9d0960bbd0;p=mesa.git diff --git a/docs/codingstyle.html b/docs/codingstyle.html index 7e9f470a100..686d6a3ddf4 100644 --- a/docs/codingstyle.html +++ b/docs/codingstyle.html @@ -8,7 +8,7 @@
-

The Mesa 3D Graphics Library

+ The Mesa 3D Graphics Library
@@ -48,19 +48,19 @@ For example: } -
  • Put a space before/after operators. For example, a = b + c; -and not a=b+c; +
  • Put a space before/after operators. For example, a = b + c; +and not a=b+c;
  • This GNU indent command generally does the right thing for formatting:
        indent -br -i3 -npcs --no-tabs infile.c -o outfile.c
     
    -
  • Use comments wherever you think it would be helpful for other developers. +
  • +

    Use comments wherever you think it would be helpful for other developers. Several specific cases and style examples follow. Note that we roughly -follow Doxygen conventions. -
    -
    +follow Doxygen conventions. +

    Single-line comments:
        /* null-out pointer to prevent dangling reference below */
    @@ -83,7 +83,7 @@ We try to quote the OpenGL specification where prudent:
         *     "An INVALID_OPERATION error is generated for any of the following
         *     conditions:
         *
    -    *     *  is zero."
    +    *     * <length> is zero."
         *
         * Additionally, page 94 of the PDF of the OpenGL 4.5 core spec
         * (30.10.2014) also says this, so it's no longer allowed for desktop GL,
    @@ -94,7 +94,7 @@ Function comment example:
     
        /**
         * Create and initialize a new buffer object.  Called via the
    -    * ctx->Driver.CreateObject() driver callback function.
    +    * ctx->Driver.CreateObject() driver callback function.
         * \param  name  integer name of the object
         * \param  type  one of GL_FOO, GL_BAR, etc.
         * \return  pointer to new object or NULL if error
    @@ -120,22 +120,23 @@ the opening brace goes on the next line by itself (see above.)
        _mesa_foo_bar()  - an internal non-static Mesa function
     
    -
  • Constants, macros and enum names are ALL_UPPERCASE, with _ between -words. -
  • Mesa usually uses camel case for local variables (Ex: "localVarname") -while gallium typically uses underscores (Ex: "local_var_name"). +
  • Constants, macros and enum names are ALL_UPPERCASE, with _ +between words. +
  • Mesa usually uses camel case for local variables (Ex: +localVarname) while gallium typically uses underscores (Ex: +local_var_name).
  • Global variables are almost never used because Mesa should be thread-safe.
  • Booleans. Places that are not directly visible to the GL API -should prefer the use of bool, true, and -false over GLboolean, GL_TRUE, and -GL_FALSE. In C code, this may mean that -#include <stdbool.h> needs to be added. The -try_emit_* methods in src/mesa/program/ir_to_mesa.cpp and -src/mesa/state_tracker/st_glsl_to_tgsi.cpp can serve as examples. +should prefer the use of bool, true, and +false over GLboolean, GL_TRUE, and +GL_FALSE. In C code, this may mean that +#include <stdbool.h> needs to be added. The +try_emit_* methods in src/mesa/program/ir_to_mesa.cpp +and src/mesa/state_tracker/st_glsl_to_tgsi.cpp can serve as +examples. -