Directives

Sip has a number of directives that control the way C++ code is generated. Since sip is essentially completely undocumented, it was impossible to clearly describe all directives, or even to be sure that this is an exhaustive list. Still, this list come in useful. The directives are grouped according to function: Documentation, Modules, Conditional Elements, C++ and Header Code, Python Code sections, Mapped Classes, Special Python methods and Other.

Documentation

Table of Contents
%Copying -- Start of software license _block_
%Doc -- Start of a documentation _block_
%ExportedDoc -- Start of an exported documentation _block_

Modules

Table of Contents
%Module -- Definition of the (main) modules name
%Include -- Include a file
%Import -- Import module (dynamic library)

Conditional Elements

Table of Contents
%If -- start of a conditional _block_
%End -- Terminate _block_
Version() -- Condition function for %If directive
%Version -- Define version value(s) and evaluation methods
%PrimaryVersions -- Define list of primary versions
%VersionCode -- Start of a version code _block_

C++ and Header Code Sections

Table of Contents
%HeaderCode -- Start of a C++ header code _block_
%ExportedHeaderCode -- Start of an exported C++ header code _block_

Mapped Classes

A mapped class

Special Python methods

Table of Contents
PyMethods -- Implement additional Python special methods
PyNumberMethods -- Implement numerical Python special methods
PySequenceMethods -- Implement Python sequence special methods
PyMappingMethods -- Implement Python mapping special methods

Python special methods can be implemented, but code must be supplied. The following directives define additional sections in a class declaration (like public, private etc.). A typical sip file section is as follows:

    class X
    {
        ...     
        PyMethods:
            __str__
    %MemberCode
                C++ code (no enclosing braces needed).
                Number and kind of arguments and return value depend on method
                (see specialPyMethod in sip.h).
    %End
        ...
    }
      

Other

Table of Contents
%Makefile -- The start of a Makefile code _block_