Zippy-Egoboo Home EgoWiki > Documentation > StyleConventions EgoWiki webs:
Main | TWiki | Know | Sandbox
Documentation . { Changes | Index | Search | Go }

Style Conventions for the Zippy-Egoboo Codebase

These conventions should be followed whenever new code is added to the engine. If you disagree or aren't sure what to do in a particular instance, e-mail the ZippyEgobooDevelList.

The Module Paradigm

The engine is broken into modules, each of which does some combination of the following things:

Module Headers

Module header files have lowercase names without punctuation (e.g. LuaList -> lualist.h), and follow the following pattern:

// filename.h: short description

MACRO GUARD

STRUCTURE DECLARATIONS, INCLUDING:
struct ModName_State;
typedef struct ModName_State ModName_State;

INCLUDES NEEDED FOR PROTOTYPES

MACRO INVOCATIONS AND DEFINITIONS

STRUCTURE DEFINITIONS (or see implementation file)

METHODS, INCLUDING:

ModName_State *ModName_Initialize(AI_State *ai, /* ... */);

void ModName_Finalize(ModName_State *bla);

#endif // FILENAME_H

Further, all modules that define types should have the following macro invocation for each type:

DECLARE_ADATA_CONVERTERS(...)

And optionally (if the type is to be lua-accessible):

DECLARE_LUA_STACKOPS(...)

Plus the following method:

int ModName_ConvertType(lua_State *L)

Methods are of the form Type_MethodName(ModName_State * bla, /* ... */).

If the module defines an update function, it should be of the form void ModName_Update(ModName_State *bla).

Header files (should) only be included in other headers if they declare types that are referred to in those files.

Module Implementations

The implementation file is of the following form:

// filename.c

#include "filename.h"

OTHER INCLUDES

STRUCTURE DEFINITIONS (if not in header)

int ModName_ConvertType(lua_State *L)
{}

TAG METHODS

CLASS/LUA METHODS

INITIALIZE/FINALIZE

PUBLIC METHODS

Tag methods are of the form "static int Type_LuaBlaTagMethod(lua_State *L)".

Class Tag methods are of the form "static int Type_BlaClassTagMethod(...)".

Lua methods are of the form "static int Type_MethodName(lua_State *L)".

Class methods are of the form "static int Type_MethodNameMethod(...)".

Indenting Style

Indenting style is pretty much universally with braces on their own lines; I break long lines before the operator (but after '=') and indent twice the first time, one additional time for each set of parentheses. Indents should be three spaces or something similar, and actual spaces should be used.

Adding types

New types need to be added to luascript/data.{c,h} and luadata.c (see WhatIsAData)

-- ElminI - 04 May 2004

Topic StyleConventions . { Edit | Attach | Ref-By | Printable | Diffs | r1.3 | > | r1.2 | > | r1.1 | More }
Revision r1.3 - 06 Sep 2004 - 19:09 GMT - ElminI
Parents: WebHome
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding EgoWiki? Send feedback.