This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via fd131ab40d827e66825dfe9202e2e02021ba07c1 (commit) from 526d3b35fea6668250aaf0f6a71303bd46adba45 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/fd131ab40d827e66825dfe9202e2e02021ba0...
commit fd131ab40d827e66825dfe9202e2e02021ba07c1 Author: Cyril Hrubis metan@ucw.cz Date: Mon Dec 31 17:08:21 2012 +0100
doc: Add coding style document.
diff --git a/doc/Makefile b/doc/Makefile index bbb1ab0..23d87e7 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,7 +1,7 @@ SOURCES=general.txt context.txt loaders.txt filters.txt basic_types.txt drawing_api.txt backends.txt gamma.txt grabbers.txt environment_variables.txt debug.txt core.txt api.txt input.txt - gen.txt pixels.txt coordinate_system.txt + gen.txt pixels.txt coordinate_system.txt coding_style.txt
EXAMPLE_SOURCES=$(wildcard example_*.txt)
diff --git a/doc/api.txt b/doc/api.txt index 7d4898a..4a75fd4 100644 --- a/doc/api.txt +++ b/doc/api.txt @@ -80,3 +80,11 @@ GFXprim Internals Describes structure and basic usage of the templating engine (C code generator). + + +Development +----------- + +. link:coding_style.html[Coding Style] + + + C and Python coding style. + + diff --git a/doc/coding_style.txt b/doc/coding_style.txt new file mode 100644 index 0000000..37bb19e --- /dev/null +++ b/doc/coding_style.txt @@ -0,0 +1,129 @@ +Coding Style +------------ + +This document defines coding style for GFXprim. + +C Coding Style +~~~~~~~~~~~~~~ + +GFXprim is written in C. There is no C++ code in and I mean it. A few headers +do contain '#ifndef __cplusplus' so that you can interface GFXprim headers as +'extern C' without problems. If this doesn't work, let us know. + +GFXprim follows mostly Linux Kernel coding style, see +'Documentation/CodingStyle' in the Linux Kernel source or follow this +link:http://www.kernel.org/doc/Documentation/CodingStyle%5Blink] (it's funny and +enligthening reading). + +.Indentation and whitespaces + +* We use tabs for indentation and tab is eight spaces wide. + +* Lines should be maximally 80 chars long. + +* No additional whitespaces (other than newline) at the end of line. + +* Each file must end with newline (most editors do that automatically, beware + of Kate). + +.Braces and Spaces + +* Avoid tricky expressions if possible ;) + +* Do not put multiple statements on a single line. ++ +[source,c] +---- +/* WRONG */ +if (something) do_work(); + do_other(); + +/* RIGHT */ +if (something) + do_work(); + +do_other(); +---- + +* Each block that has more than one line should be enclosed in + curly braces. ++ +Also if one part of if then else is enclosed in +curly braces the other one should be enclosed too. ++ +[source,c] +---- +/* WRONG */ +if (something) + do_other_thing(); + else if (something_else) + do_thing(); + else + return; + +/* RIGHT */ +if (something) { + do_other_thing(); +} else { + if (something_else) + do_thing(); + else + return; +} +---- + +* On the other hand do not use braces unnecesarily. ++ +[source,c] +---- +/* WRONG */ +if (something) { + do_work(); +} + +/* RIGHT */ +if (something) + do_work(); +---- + +* The preffered way of writing switch is as follows: ++ +[source,c] +---- +switch (var) { +case XYZ: + do_something(): +break; +case ABC: + return 1; +default: +break; +} +---- + +TIP: You can use Linux Kernel +scripts/checkpatch.pl+ to check your code. + +GFXprim Specific Rules +^^^^^^^^^^^^^^^^^^^^^^ + +* Library external API uses CamelCase +** Together with mandatory +GP_+ prefix. +** For example +GP_PixelType+, +GP_Context+, etc. +** We will not change that, get over it. (It could have been worse, trust me.) + +* Basic library types are typedefed +** We have +GP_Size+ and +GP_Coord+ integer types to better distinguish + roles of function parameters. +** The basic structures are also typedefed so you can wite +GP_Context+ + instead of +struct GP_Context+. +** Other uses of typedef are frowned upon. + +* When you add a externally symbol visible symbol, i.e. new API function + please add its name into the corresponding file at +build/syms/+. You may + also run the +buld/check_symbols.sh+ script to check that you haven't + accidentally exposed intenal only interfaces. + +Python Coding Style +~~~~~~~~~~~~~~~~~~~ + +TODO
-----------------------------------------------------------------------
Summary of changes: doc/Makefile | 2 +- doc/api.txt | 8 +++ doc/coding_style.txt | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 1 deletions(-) create mode 100644 doc/coding_style.txt
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.