Texas Instruments TMS320 DSP Computer Hardware User Manual


 
www.ti.com
3.1.2NamingConventions
3.1.3ModuleInitializationandFinalization
3.1.4ModuleInstanceObjects
InterfacesandModules
TosimplifythewayeXpressDSP-compliantclientCodeiswritten,itisvaluabletomaintainasingle
consistentnamingconvention.Inadditiontobeingproperlyprefixed(Rule8),allexternaldeclarations
disclosedtotheusermustconformtotheeXpressDSPnamingconventions.
Rule10
AllmodulesmustfollowtheeXpressDSP-compliantnamingconventionsforthoseexternaldeclarations
disclosedtotheclient.
Notethatthenamingconventionsonlyapplytoexternalidentifiers.InternalnamesandexistingCode
neednotchangeunlessanidentifierisexternallyvisibletoaclientapplication.TheeXpressDSPnaming
conventionsaresummarizedinthetablebelow.
ConventionDescriptionExample
Variablesandfunctionsbeginwith
VariablesandfunctionsFIR_apply()
lowercase(aftertheprefix).
ConstantsConstantsarealluppercaseG729_FRAMELEN
Datatypesareintitlecase(afterthe
TypesFIR_Handle
prefix)
StructurefieldsStructurefieldsbeginwithlowercasebuffer
Macrosfollowtheconventionsofconstants
macrosFIR_create()
orfunctionsasappropriate
Inadditiontotheseconventions,itisimportantthatmulti-wordidentifiersneverusethe'_'characterto
separatethewords.Toimprovereadabilityusetitlecase;forexample,FIR_getBuffer()shouldbeusedin
lieuofFIR_get_buffer().Thisavoidsambiguitywhenparsingmoduleandvendorprefixes.
Beforeamodulecanbeusedbyanapplication,itmustfirstbe"initialized";i.e.,themodule'sinit()method
mustberun.Similarly,whenanapplicationterminates,anymodulethatwasinitializedmustbe"finalized,"
i.e.,itsexit()methodmustbeexecuted.Initializationmethodsareoftenusedtoinitializeglobaldataused
bythemodulethat,duetolimitationsoftheClanguage,cannotbestaticallyinitialized.Finalization
methodsareoftenusedtoperformrun-timedebugassertions;forexample,itmightcheckforobjectsthat
werecreatedbutneverdeleted.Thefinalizationmethodofanon-debugversionofamoduleisoftenthe
emptyfunction.
Althoughsomemoduleshavenoneedforinitializationorfinalization,itiseasierfortheclientsofmodules
toassumethatallmoduleshavethem.Thisallowsframeworkstoeasilyimplementwell-definedstartup
andshutdownsequences,forexample.
Rule11
Allmodulesmustsupplyaninitializationandfinalizationmethod.
Modulesoptionallymanageinstanceobjects.AlleXpressDSP-compliantmodulesmanageinstance
objects.Objectssimplyencapsulatethepersistentstatethatismanipulatedbytheotherfunctionsor
methodsprovidedbythemodule.
Amodulemanagesonlyonetypeofobject.Thus,amodulethatmanagesobjectsroughlycorrespondsto
aC++classthatfollowsastandardnamingconventionforitsconfigurationparameters,interfaceheader,
andallexternalidentifiersasshowninFigure3-2.
28AlgorithmComponentModelSPRU352GJune2005RevisedFebruary2007
SubmitDocumentationFeedback