8 Template Naming Conventions

For SRecode to work across languages reliably, templates need to follow a predictable pattern. For every language of similar nature (OO, functional, doc based) if they all provide the same base templates, then an application can be written against the base templates, and it will work in each of the supported language.

Having consistent templates also makes it easy to use those templates from a user perspective during basic interactive insertion via srecode-minor-mode.

NOTES ON THIS CHAPTER:

These conventions are being worked on. Check with CEDET-DEVEL mailing list if you want to support a language, or write an application and provide your opinions on this topic. Any help is appreciated.

8.1 Context: File

Each language should support the file:empty template. This will generally use the default copyright insertion mechanism.

8.2 Context: Declaration

Functional languages should attempt to support the following:

function

A standalone function. Not a method, external method, or other.

method

A method belonging to some class declared outside the textual bounds of that class’ declaration.

variable

A global variable.

type

A data type. If the language supports several types of datatypes then do not use this, use more specific ones instead.

class

For OO languages, use this instead of type.

include

Include files.

For any Semantic tag class in your language, you will likely want to have a corresponding template.

In order for the SRecode function srecode-semantic-insert-tag to work, you can create templates similar to those mentioned above, except with -tag appended to the end. This lets a template like function have user conveniences when referencing function-tag, while also allowing the tag inserter to do its job with a simpler template.

8.3 Context: Classdef

Inside a class definition. These are to be inserted inside the textual bounds of a class declaration.

function

This would be a method of the class being inserted into.

constructor
destructor

Like function but specific to alloc/delete of an object.

variable

This would be a field of the class being inserted into.

8.4 Context: Code

Inside a body of code, such as a function or method body.

—no conventions yet.

8.5 Standard Dictionary Values

For these variables to be useful, standard names should be used. These values could be provided directly from a Semantic tag, or by an application.

NAME

The name of the declaration being created.

PARENT

If the item belongs to some parent type, it would be the full name of that type, including namespaces.

TYPE

A datatype name for a variable, or the return value of a function.

DOC

If there is some documentation associated with the item, then DOC should contain the value. (Optional)

ARGS

The ARGS variable defines a section for 0 or more arguments to a function or method. Each entry in ARGS will follow the rest of these naming conventions, such as for NAME and TYPE.

For templates used by srecode-semantic-insert-tag, there is also the following useful dictionary values.

TAG

A special insertion value TAG. You can use semantic functions to turn the tag into a string.

HAVEDEFAULT
DEFAULT

Default value for a variable.