1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<TITLE>Basic Rules for Naming Functions and Variables</TITLE> 8<LINK rel="stylesheet" href="TwlSDKstandard.css" type="text/css"> 9</HEAD> 10<BODY> 11<H1>Basic Rules for Naming Functions and Variables</H1> 12<H2>Categories</H2> 13<P>TWL-SDK functions can be grouped into categories according to their purpose. They have been given names that help make these categories clear.</P> 14<DL> 15 <DT>Categories 16 <DD>A category is indicated with two or more uppercase letters. (Numerals can also be used starting in the second position, but only for items related to graphics.) 17 <DD> 18 <BLOCKQUOTE>Syntax: [A-Z][A-Z0-9]+</BLOCKQUOTE> 19</DL> 20<TABLE border="1" width="100%"> 21 <COL span="1" width="100"> 22 <TBODY> 23 <TR> 24 <TH align="left">OS</TH> 25 <TD>Items related to the operating system.</TD> 26 </TR> 27 <TR> 28 <TH align="left">G2,G3,GX...</TH> 29 <TD>Items related to graphics. (Numerals are also included.)</TD> 30 </TR> 31 <TR> 32 <TH align="left">MI</TH> 33 <TD>Items related to memory exchange, such as DMA.</TD> 34 </TR> 35 <TR> 36 <TH align="left">SVC</TH> 37 <TD>Items related to system calls.</TD> 38 </TR> 39 </TBODY> 40</TABLE> 41<P align="right">(03/11/13)</P> 42<P align="left">Note: The distinction in the main processor and subprocessor categories was eliminated. Uppercase letters are used uniformly and consistently.</P> 43<P align="right">(04/01/18)</P> 44<H2>Functions</H2> 45<P>Functions are named as follows: Subject and object are connected without an underscore. The first letter of each separate word is capitalized.</P> 46<DL> 47 <DT>Public functions 48 <DD>[Category name]_[verb] [object, and so on] 49 <DD> 50 <BLOCKQUOTE>Examples: OS_SetInterruptMask, OS_IsLocked</BLOCKQUOTE> 51</DL> 52<DL> 53 <DT>Private functions 54 <DD>[Category name]i_[verb] [object, etc] 55 <DD> 56 <BLOCKQUOTE>Example: OSi_SetInterruptMaskBase</BLOCKQUOTE> 57</DL> 58<DL> 59 <DT>Static functions 60 <DD>Free form 61</DL> 62<P>However, there are some functions that do not follow these rules, such as <CODE>OS_InterruptHandler</CODE>. </P> 63<P align="right">(03/11/13)</P> 64<P>There are two different names that can be given to a function that generates or initializes objects: <CODE>Create</CODE> or <CODE>Init</CODE>. <CODE>Create</CODE> is used when a function must later be called to explicitly destroy the object. <CODE>Init</CODE> is used when when the object does not need to be destroyed.</P> 65<P align="right">(03/12/15)</P> 66<H2>Variable Type Name</H2> 67<P>Functions and types are the same since the name used in typedefs fundamentally adhere to Nintendo GameCube conventions. Note that a verb is not used after the category name.</P> 68<DL> 69 <DT>Variable type name 70 <DD>[Category name] [noun] 71 <DD> 72 <BLOCKQUOTE>Example: OSInterruptCallback</BLOCKQUOTE> 73</DL> 74<DL> 75 <DT>Variable name exceptions 76 <DD>[Category name] [verb] Mode 77 <DD> 78 <BLOCKQUOTE>Example: OSCopyMode</BLOCKQUOTE> 79</DL> 80<P>As an exception, names such as <CODE>OSCopyMode</CODE> are given to functions used to control the operations of the API itself. This particular function, for example, is likely to control the operation of a function with a name like <CODE>GXCopy</CODE>. Names such as <CODE>GXCopyStatus</CODE> and <CODE>GXCopyType</CODE> are other possibilities. Although this is recognized as a natural way to name such functions, do not take this concept too far.</P> 81<P align="right">(03/11/13)</P> 82<H2>Enumerator Names and Macro Names</H2> 83<P>Constants defined by <CODE>enum</CODE>, <CODE>define</CODE>, and <CODE>const</CODE> have the format shown below.</P> 84<DL> 85 <DT>Constant Name 86 <DD>[Category name] _ [A-Z0-9_]+ 87 <DD> 88 <BLOCKQUOTE>Examples: OS_INTERRUPT_MAX, OS_INTERRUPT_MAX</BLOCKQUOTE> 89</DL> 90<P align="right">(04/01/18)</P> 91<hr><p>TWL-06-0011-001-B<br>CONFIDENTIAL</p></body> 92</HTML>