Datatype Element
Aus ExpeccoWiki
A datatype element is used to define additional datatypes which are not available in the default set of provided datatypes. They can be modified in the datatype editor.
Inhaltsverzeichnis |
Standard (Predefined) Types
A number of types are already built into and well-known to expecco. These are:
Common Types
- Address
- represents a pointer to external data (C-pointer)
- Any
- any object, exact type is not known/not relevant
- BitString
- an array of bits
- Boolean
- boolean truth values: true and false
- ByteArray
- a collection of bytes
- Collection
- a collection of any other object (possibly unordered)
- Date
- represents a date (dd-mm-yy)
- DateTime
- represents both date and time (aka: timestamp) with millisecond resolution
- Dictionary (HashTable)
- a mapped collection, where the key/index may be any arbitrary object
- Filename
- represents a path/file name
- Float
- a rational number with double-precision (64bit)
- Fraction
- an exact fraction
- Handle
- a handle as returned by some operating-system calls
- HexString
- IPAddress
- Integer
- an arbitrarysize integer
- Number
- any numeric value (integer, float or fraction)
- OctedString
- OrderedCollection
- a growable collection, with integral index
- SequenceableCollection
- any collection, with integral index (possibly non-growing)
- Set
- an unordered collection, where every object occurrs at most once
- Socket
- represents a socket connection stream
- Stream
- any stream
- String
- a collection of 8-bit characters
- StringCollection
- a collection of lines, as read from a file
- StringOrFilename
- a union either a fileName object, or a string
- Time
- represents the time of the day (hh:mm:ss)
- TimeDuration
- represents a time-delta (10m, 1h or 3d)
- URL
- UUID
- UnicodeString
Expecco Types
- ActivityLog
- Datatype
- Error
- Exception
- GUI Aspect
- Library
- Performer
- Report Template
- Resource
- SUnit TestResult
- Symbol
- Verdict
User Defined Types
New user defined types can be constructed by a number of different mechanisms:
Primary Types
Primary types represent existing classes of the underlying VM (virtual machine). These are the classes as described in the Smalltalk/X Online Documentation in addition to any classes which have been loaded dynamically via the plugin mechanism.
Compound Types
A compound type consists of a number of named fields, each defined by its type. For example, a customer record could be represented by a compound type instance as a structure consisting of individual fields:
compound type:
{
firstName: String
lastName: String
zip: Integer
age: Integer
}
when instantiated, an anonymous class is created for instances of compound types. These objects provide virtual accessor functions (getters and setters), which are named as the field names. Thus, given a compound type T, it can be instanciated with:
inst = T.new();
and the fields can be set with:
inst.firstName( "Andy" );
inst.lastName( "Miller" );
inst.age ( 41 );
Enumeration Types
An instance of an enumerated type can take a valuefrom a defined list of values. For example, a test-outcome could be defined as an enumerated type:
enum type:
(
pass | fail | inconclusive
}
(notice, that there is already a Verdict type present in the set of standard types).
Subrange Types
A subrange of the set of values of either the integer- or the character type. A subrange type defines the minimum and maximum values from the base type's set of values.
For example, a type to describe byte-valued integers could be described as:
range( Integer : 0 .. 255 )
Union Types
A union type represents a number of alternative fields. The selection of which field is actually valid within a union must be done elsewhere (or, via reflection, by asking the object dynamically).
For example, a type to describe an object which is either numeric or a string, could be described as:
union type:
(
String | Integer
)
CTypes (1.7.4)
A cType is similar to a compound type; however, a data representation is used, which is compatible to structures of the C-programming language. Also, the definition is given in C-syntax. For example, the above customer record could be represented as the following C-structure:
cType type:
/* C: */
struct {
char firstName[20];
char lastName[20];
int zip;
short age;
}
Notice the explicit dimension of the strings. These are required to define the C-structures exact size. When instantiated, an object is created, which has the underlying C-structure layout, and which is not moved in memory by the garbage collector (i.e. its address remains constant). It can therefore be passed to a called c-functions, for example in a dll call. Similar to compound types, isntnaces of cTypes understand accessor functions. Given a ctype type T, it can be instanciated with:
inst = T.new();
and the fields can be set with:
inst.firstName( "Andy" );
inst.lastName( "Miller" );
inst.age ( 41 );
Notice that cTypes are not supported by expecco releases before 1.7.4. Also notice, that C-structures are allocated using malloc on the C-heap. The overhead in terms of memory use and processing power is therefore much higher when compared to normal compound- or primary instances. Only use cType instances when data has to be exchanged with C-programs.
Special Types
For editors see: Editors
For other tree elements see: Tree Elements
The full online documentation can be found under: Online Documentation