[svn] / trunk / xvidcore / CodingStyle Repository:
ViewVC logotype

Diff of /trunk/xvidcore/CodingStyle

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 196, Wed Jun 12 21:18:52 2002 UTC revision 1918, Wed Dec 22 16:52:52 2010 UTC
# Line 1  Line 1 
1  ----------------------------------------------------------------------  CodingStyle
2                          XviD Core coding style  ===========
   
               Inspired by the Linux Kernel Coding Style  
   
 ----------------------------------------------------------------------  
3    
4    
5  This is a short document describing the preferred coding style for the  This is a short document describing the preferred coding style for the
6  XviD  core library.   Coding  style  is very  personal,  and we  won't  Xvid  core library.   Coding  style  is very  personal,  and we  won't
7  _force_  our   views  on  anybody.   But  if   everybody  who  submits  _force_  our   views  on  anybody.   But  if   everybody  who  submits
8  patches/codes to the  CVS respect this coding style,  the whole source  patches/codes to the  CVS respect this coding style,  the whole source
9  would be easier to read/understand for all the others developers.  would be easier to read/understand for all the others developers.
# Line 22  Line 18 
18    
19  In short,  8-char indents would have  made things easier  to read, and  In short,  8-char indents would have  made things easier  to read, and
20  would have the  added benefit of warning you  when you're nesting your  would have the  added benefit of warning you  when you're nesting your
21  functions too deep. But because of  some parts of the XviD code source  functions too deep. But because of  some parts of the Xvid code source
22  has to use  lot of if/else/for statements together,  we have chosen to  has to use  lot of if/else/for statements together,  we have chosen to
23  set the standard tab length to 4 characters.  set the standard tab length to 4 characters.
24    
# Line 58  Line 54 
54    
55          struct foo_t          struct foo_t
56          {          {
57              body of the strcuture              body of the structure
58          }          }
59    
60  Note that the closing brace is empty on a line of its own, _except_ in  Note that the closing brace is empty on a line of its own, _except_ in
# Line 76  Line 72 
72              ..              ..
73          } else if (x > y) {          } else if (x > y) {
74              ...              ...
75          }          } else {
         else {  
76              ....              ....
77          }          }
78    
# Line 99  Line 94 
94  function that counts the number  of active users, you should call that  function that counts the number  of active users, you should call that
95  "count_active_users()"   or  similar,   you  should   _not_   call  it  "count_active_users()"   or  similar,   you  should   _not_   call  it
96  "cntusr()". Try not  to use global variables as  they break reentrancy  "cntusr()". Try not  to use global variables as  they break reentrancy
97  and XviD aims to be (in a long term) a threadable library.  and Xvid aims to be (in a long term) a threadable library.
98    
99    
100  Encoding the  type of  a function into  the name  (so-called Hungarian  Encoding the  type of  a function into  the name  (so-called Hungarian
# Line 145  Line 140 
140  and it gets confused.  You know you're brilliant, but maybe you'd like  and it gets confused.  You know you're brilliant, but maybe you'd like
141  to understand what you did 2 weeks from now.  to understand what you did 2 weeks from now.
142    
143  NB :  This chapter does  not apply very  well to some XviD  parts, but  NB :  This chapter does  not apply very  well to some Xvid  parts, but
144  keep this "philosphy" in mind anyway.  keep this "philosphy" in mind anyway.
145    
146    
# Line 180  Line 175 
175  file:  file:
176    
177  (defun xvid-c-mode ()  (defun xvid-c-mode ()
178    "C mode with adjusted defaults for use with the XviD Sources."    "C mode with adjusted defaults for use with the Xvid Sources."
179    (interactive)    (interactive)
180    (c-mode)    (c-mode)
181    (message "Loading xvid-c-mode")    (message "Loading xvid-c-mode")
# Line 232  Line 227 
227    
228                          Chapter 8: Reentrance                          Chapter 8: Reentrance
229    
230  Well, at  the moment, XviD is  not a reentrant  library because during  Well, at  the moment, Xvid is  not a reentrant  library because during
231  its development, some mistakes have  been comited. But reentrance is a  its development, some mistakes have  been comited. But reentrance is a
232  long term aim  for this project so you should not  write code which is  long term aim  for this project so you should not  write code which is
233  not reentrant.  not reentrant.
# Line 259  Line 254 
254  64bit on 64 bit CPUs (ultra sparc, AMD hammer, Intel Itanium, Motorola  64bit on 64 bit CPUs (ultra sparc, AMD hammer, Intel Itanium, Motorola
255  powerpc64)  powerpc64)
256    
257  But  don't forget  that  the  minimum platform  targeted  by the  XviD  But  don't forget  that  the  minimum platform  targeted  by the  Xvid
258  library is a  32bit cpu. So a  'int' should (never say 'is'  in such a  library is a  32bit cpu. So a  'int' should (never say 'is'  in such a
259  case) always be 32bit long (or bigger)  case) always be 32bit long (or bigger)
260    
# Line 268  Line 263 
263    
264  The  code  _must_ be  portable.  Don't  use  specific functions  to  a  The  code  _must_ be  portable.  Don't  use  specific functions  to  a
265  compiler/OS/libC.  Don't  use  specific  compiler pragmas,  or  syntax  compiler/OS/libC.  Don't  use  specific  compiler pragmas,  or  syntax
266  extensions.  extensions. The code _must_ be ANSI C  compliant  to ease  portability
267    on exotic platforms with only ANSI C compilers, much  more  widespread
268    than ISO C99 compilers.
269    
270  Btw, if you  have to use those deprecated/not  portable features, then  Btw, if you  have to use those deprecated/not  portable features, then
271  use the src/portab.h to write a wrapper for each targeted system.  use the src/portab.h to write a wrapper for each targeted system.
# Line 276  Line 273 
273  For the moment, the supported platforms are :  For the moment, the supported platforms are :
274    - Win32 family (x86) with VC++    - Win32 family (x86) with VC++
275    - Cygwin env (bypassing the cygwin.dll with -mno-cygwin flag)    - Cygwin env (bypassing the cygwin.dll with -mno-cygwin flag)
276    - Mingw ???    - Mingw + Minsys
277    - GNU/Linux (x86 and  ppc for optimized code, or  any other arch for    - GNU/Linux (x86 and  ppc for optimized code, or  any other arch for
278      the pure C version of the library)      the pure C version of the library)
279    - *BSD (same archs as GNU/Linux)    - *BSD (same archs as GNU/Linux)
280      - Solaris.
281    
282    Last edited: $Date: 2010-12-22 16:52:52 $

Legend:
Removed from v.196  
changed lines
  Added in v.1918

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4