modular-worm/doc/coding_style.html

37 lines
1.5 KiB
HTML

<h1 id="coding-style">Coding Style</h1>
<h2 id="naming">Naming</h2>
<h3 id="generic">Generic</h3>
<h4 id="structures-and-typedefs">Structures and typedefs</h4>
<ul>
<li>no structure without typedef</li>
<li>every typedef is <strong>suffixed</strong> with **_t**</li>
</ul>
<h3 id="module">Module</h3>
<h4 id="variable-globals">Variable Globals</h4>
<ul>
<li><p>every global in a module must be static and <strong>prefixed</strong> with a **p{n}_** wher en is the id of the plgin</p>
<p>static int p3_server;</p></li>
</ul>
<h4 id="structure-and-typedefs">Structure and typedefs</h4>
<ul>
<li><p>every typedef of a module must be prefixed with **p{n}_** where n is the id of the plugin</p>
<p>typedef struct { unsigned id : 16; usigned flag: 1; } p3_data_t;</p></li>
</ul>
<h4 id="functions">Functions</h4>
<ul>
<li>every function of a module must be prefixed with **p{n}_** where n is the id of the plugin</li>
<li><p>exception: <code>run</code> and <code>run_instant</code></p>
<p>static void p3_add_state(api_msg_t *msgp, ...) { ... } void run() { ... }</p></li>
</ul>
<h3 id="api">API</h3>
<h4 id="function">Function</h4>
<ul>
<li><p>every function of the API is <strong>prefixed</strong> with <strong>api_</strong></p>
<p>static int api_send_message(...);</p></li>
</ul>
<h4 id="structure-and-typedef">Structure and typedef</h4>
<ul>
<li><p>every structure and typedef of the API is <strong>prefixed</strong> with <strong>api_</strong></p>
<p>typedef struct { unsigned stuff1 : 8; int stuff2: 4; } api_stuff_t;</p></li>
</ul>