[openbeosnetteam] Re: question about coding style

Hi Axel,

On 2006-07-25 at 16:08:30 [+0200], Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> 
wrote:
> Oliver Tappe <openbeos@xxxxxxxxxxxxxxx> wrote:
> > are there any coding style guidelines for haiku apart from the ones
> > from
> > OpenTracker (which are mentioned on haiku's website)?
> > 
> > I am asking because I am a bit confused as to what coding style is
> > actually
> > applying to haiku kernel code, as the code I read seemingly violates
> > the
> > OpenTracker guidelines here and there:
> > 
> > according to the guidelines...
> > -    'udp_protocol' should be 'UdpProtocol'
> 
> Well, we're following the Be style too :)
> C structures and methods are lower case with '_', while C++ classes are
> UpperCaseAndCombined. C structure members are lower case, too, while C+
> + members have the 'f' prefix. 

Ok. So would it be ok to change udp.cpp from the C-style to the C++-style? I 
mean udp_protocol is a C++ struct, although it inherits from a C-struct. A 
bit of a mixture, really.
Would you object to me using UdpProtocol instead of udp_protocol (and of 
course then use the f-prefix for struct members)?

[...]

> > -    method declarations should be lined up (with lots of space to the
> > left)
> 
> Not sure what you mean here.

I mean this:

struct udp_protocol : net_protocol {
                  udp_protocol();

    static int    Compare(void *_udpProtocol, const void *_key);
    static uint32 ComputeHash(uint16 ourPort, uint16 peerPort, 
                      in_addr_t peerIP);
    static uint32 Hash(void *_udpProtocol, const void *_key, uint32 range);
};

instead of that:

struct udp_protocol : net_protocol {
    udp_protocol();

    static int Compare(void *_udpProtocol, const void *_key);
    static uint32 ComputeHash(uint16 ourPort, uint16 peerPort, 
        in_addr_t peerIP);
    static uint32 Hash(void *_udpProtocol, const void *_key, uint32 range);
};

> > Is there some specific coding style for the kernel?
> > 
> > I am very willing to follow any coding guidelines, but it *is* easier
> > if you
> > know precisely what guidelines to adhere to >;o)
> 
> Yes, the OpenTracker style guide doesn't include the C case. When you
> look at the Be headers, the C naming style seems to be consistent, but
> also different from the C++ naming style.

Yes, both are consistent, but we seem to be using C-style in .cpp files and 
that confuses me (network/stack/stack.cpp is an example).

cheers,
        Oliver


Other related posts: