IBM
Contents Index Previous Next



SDL Library for Fundamental C/C++ Types


The SDL declarations that are generated by CPP2SDL will normally not be semantically correct on their own. They typically contain several references to SDL sorts that represent fundamental C/C++ types, for example int, char and bool, and type declarators such as pointers (*) and arrays ([]). The SDL representations of all fundamental C/C++ types and type declarators are defined in a library consisting of a few SDL/PR files. The table below lists these files and their contents.

SDL/PR file Contents

BasicCTypes.pr


Contains SDL representations of fundamental C types. Also contains representations for an untyped pointer (void*) and the array type declarator ([]).

SYNTYPE int = Integer

ENDSYNTYPE int;


SYNTYPE unsigned_int = Integer

ENDSYNTYPE unsigned_int;


SYNTYPE long_int = Integer

ENDSYNTYPE long_int;


SYNTYPE unsigned_long_int = Integer

ENDSYNTYPE unsigned_long_int;


SYNTYPE short_int = Integer

ENDSYNTYPE short_int;


SYNTYPE unsigned_short_int = Integer

ENDSYNTYPE unsigned_short_int;


SYNTYPE char = Character

ENDSYNTYPE char;


SYNTYPE signed_char = Character

ENDSYNTYPE signed_char;


SYNTYPE unsigned_char = Octet

ENDSYNTYPE unsigned_char;


SYNTYPE float = Real

ENDSYNTYPE float;


SYNTYPE double = Real

ENDSYNTYPE double;


NEWTYPE ptr_void

LITERALS Null;

DEFAULT Null;

ENDNEWTYPE ptr_void;


GENERATOR CArray (CONSTANT Length, TYPE
Itemsort)

OPERATORS

modify!: CArray, Integer, Itemsort -> CArray;

extract!: CArray, Integer -> Itemsort;

ENDGENERATOR CArray;

BasicC++Types.pr


Contains SDL representations of fundamental C++ types. Also contains operators representing implicit constructors for fundamental types.


Note that this file includes the files BasicCtypes.pr and ExtraCTypes.pr.


/*#INCLUDE 'BasicCTypes.pr'*/

/*#INCLUDE 'ExtraCTypes.pr'*/


SYNTYPE bool = Boolean

ENDSYNTYPE bool;


NEWTYPE wchar_t

ENDNEWTYPE wchar_t;


NEWTYPE __ConstructorOperators /*#NOTYPE*/

OPERATORS

int: -> int;

int: int -> int;

unsigned_int: -> unsigned_int;

unsigned_int: unsigned_int -> unsigned_int;

long_int: -> long_int;

long_int: long_int -> long_int;

unsigned_long_int: -> unsigned_long_int;

unsigned_long_int: unsigned_long_int -> unsigned_long_int;

short_int: -> short_int;

short_int: short_int -> short_int;

unsigned_short_int: -> unsigned_short_int;

unsigned_short_int: unsigned_short_int -> unsigned_short_int;

char: -> char;

char: char -> char;

signed_char: -> signed_char;

signed_char: signed_char -> signed_char;

unsigned_char: -> unsigned_char;

unsigned_char: unsigned_char -> unsigned_char;

float: -> float;

float: float -> float;

double: -> double;

double: double -> double;

ptr_void: -> ptr_void;

ptr_void: ptr_void -> ptr_void;

bool: -> bool;

bool: bool -> bool;

wchar_t: -> wchar_t;

wchar_t: wchar_t -> wchar_t;

ENDNEWTYPE __ConstructorOperators;EXTERNAL 'C++';

ExtraCTypes.pr


Contains SDL representations of additional fundamental C types.

SYNTYPE long_long_int = Integer

ENDSYNTYPE long_long_int;


SYNTYPE unsigned_long_long_int = Integer

ENDSYNTYPE unsigned_long_long_int;

ExtraC++Types.pr


Contains SDL representations of additional fundamental C++ types.

NEWTYPE__ExtraConstructorOperators

long_long_int : -> long_long_int;

long_long_int : long_long_int -> long_long_int;

unsigned_long_long_int : -> unsigned_long_long_int;

unsigned_long_long_int : unsigned_long_long_int -> unsigned_long_long_int

ENDNEWTYPE__ExtraConstructorOperators

CPointer.pr


Contains SDL representation of the C pointer type declarator (*).

GENERATOR Ref (TYPE Itemsort)

LITERALS Null, Alloc;

OPERATORS

modify! : Ref, Integer, Itemsort -> Ref;

extract! : Ref, Integer -> Itemsort;

"*>" : Ref, Itemsort -> Ref;

"*>" : Ref -> Itemsort;

"&" : Itemsort -> Ref;

make! : Itemsort -> Ref;

free : in/out Ref;

"+" : Ref, Integer -> Ref;

"-" : Ref, Integer -> Ref;

cast : Ref -> ptr_void;

cast : ptr_void -> Ref;

DEFAULT Null;

ENDGENERATOR Ref;

C++Pointer.pr


Contains SDL representation of the C++ pointer type declarator (*).


GENERATOR Ref (TYPE Itemsort)

LITERALS Null;

OPERATORS

modify! : Ref, Integer, Itemsort -> Ref;

extract! : Ref, Integer -> Itemsort;

"*>" : Ref, Itemsort -> Ref;

"*>" : Ref -> Itemsort;

"&" : Itemsort -> Ref;

new : Itemsort -> Ref;

delete : Ref;

new_array : Itemsort, Integer -> Ref;

delete_array : Ref;

"+" : Ref, Integer -> Ref;

"-" : Ref, Integer -> Ref;

cast : Ref -> ptr_void;

cast : ptr_void -> Ref;

DEFAULT Null;

ENDGENERATOR Ref;

If the option -generatecpptypes is set, CPP2SDL will include some of the files from the table above in the SDL translation. Which files that are included depends on if CPP2SDL executes in C or C++ mode (controlled by the -c option).

The following files will be included in C mode:

The following files will be included in C++ mode:

The reason for breaking out the types long long int and unsigned long long int into separate files, is that not all compilers support these types. These files must be manually included if these types are present in the input headers.

Hint:

The syntype definitions of the SDL sorts that represent fundamental C/C++ types can easily be changed. For example, the definitions of the SDL sorts `char' and `unsigned char' could be swapped if the target platform specifies that a simple `char' is unsigned rather than signed.


http://www.ibm.com/rational
Contents Index Previous Next