Chic documentation
Houlder Technologies


Layout of generated files
Home
Features
Tutorial
Examples
FAQ
Reference
Download
Mailing list
Contact

At the beginning of all generated files, Chic inserts a special comment with the version of Chic the file was generated. The string signals that this is a Chic generated file. Chic will for example not delete a file that does not have this string.

After the version string, Chic inserts the "copyright string" if the user has defined that parameter. The start of a generated file could thus look something like:

//chic version 1.0

// Copyright 2001 SomeCompany Inc.
// All rights reserved.

What follows are the additional fields inserted into the header and the implementation files respectively.

Header file

A header file consists of an include guard, a section of generated include directives and declarations, the class and functions declarations from the hic-file, and eventually an include directive for the inline file.

Include guard

The macro name in the include guard is created from the base name of the hic-file (without the suffix) and the name of the first namespace found (if any) in the hic-file. A digit or a capital letter is prepended by an underscore. All lower case letters are capitalized. A character that's not a letter, digit or underscore is replaced by an underscore. Finally the string "INCLUDED_" is prepended and the string "_H" is appended.

The guard is created by an #ifndef, #define, #endif sequence as in the following example:

File MyFile-3.hic:
  namespace MySpace
  {
  }
yields the include guard:
  #ifndef INCLUDED_MY_FILE__3_MY_SPACE_H
  #define INCLUDED_MY_FILE__3_MY_SPACE_H

  // Rest of header goes here.

  #endif // INCLUDED_MY_FILE__3_MY_SPACE_H

Generated include directives and declarations

The order of include directives is intentionally unspecified, but directives with apostrophes always come before directives with angle brackets. Directives with apostrophes most often include higher level code than directives with angle brackets so this helps us discover incomplete headers as early as possible.

After the include directives follow the forward declarations needed to compile the header file. These are in a compact form so that only one namespace is used for two or more declarations in the same scope.

After the forward declarations, Chic inserts the typedefs needed to compile the header, and finally it inserts all the using declarations.

Class definitions and function declarations

The generated include directives and declarations are followed by the contents of the hic-file stripped of definitions. This is explained in further details in the statements section.

If an inline file was generated, Chic inserts an include directive for the inline file at the end of the header.

Implementation files

After the copyright string both implementation files contain an include directive for the header file. In the ii-file the directive is guarded in order to speed up preprocessing for some compilers and also for Chic itself. The guard uses the same name as the header file guard. An inline file for the above example would be:

File MyFile-3.ii:
#ifndef INCLUDED_MY_FILE__3_MY_SPACE_H
#include "MyFile-3.hh"
#endif // INCLUDED_MY_FILE__3_MY_SPACE_H

// Rest of file goes here.
The cc-file also includes the header but the directive is not guarded:

File MyFile-3.cc:

#include "MyFile-3.hh"

// Rest of file goes here.

The rest of both implementation files contain the definitions found in the hic-file. The definitions are added in the order they were found. Depending on the parameters set for the file the definitions might be qualified or wrapped in namespaces. A class's eventual hidden data is put in front of the first definition of the class.



Home