Datatype Editor/en

Aus expecco Wiki (Version 2.x)
Version vom 1. April 2014, 09:54 Uhr von Cg (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „==Introduction== This editor is used to define new datatypes. Datatypes are attached to pins and environment variables, and usually presented by name in a data…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen

Introduction[Bearbeiten]

This editor is used to define new datatypes. Datatypes are attached to pins and environment variables, and usually presented by name in a datatype definition pull-down menu. User defined datatypes are shown in those pull-down lists at the bottom of the menu.

There are multiple conceptional ways to define a datatype:

  • as a subtype of an existing type (enum, range types)
  • by combining elements of existing types (tuple, array, structure or union types)
  • be explicit definition as a class or datastructure (C-type, ST/X-class type)

Also, there are various syntactical representations, in which a type may be entered:

  • Internal expecco Syntax
  • XML / DTD / IDL
  • C language struct syntax
  • Copybook, SUNRPC-IDL, COM-IDL, ASN1

The set of options avalable in the editor depends on the expecco version (basic, pro, enterprise) and the set of available plugins (SWIFT, ASN1, etc.).

To define a type, choose an appropriate representation in the "type-Kind" list to get a template. Change the template and press "Accept" to install the type.

TypeEditor1.png

Type Kinds (Semantic)[Bearbeiten]

Primary Types[Bearbeiten]

These are builtin types of the underlying execution framework. For example, "String", "Array", "Set", "Btree", "Dictionary" to name a few. There are thousands of classes available, but you will usually get along happily with only a few. The most common primary types are shortly listed in the Datatype documentation. For more details, please refer to the "Basic Classes Introduction" and the "Online Class Documentation" (containing full lists and documentation of all classes).

A number of primary types is available directly via the datatype menus. In a textual definition, the underlying typeclass is placed in angle brackets, as in:

    <String>

or:

    <Socket>

Array Types[Bearbeiten]

Are defined as a homogenous collection of a elements, which are all of the same baseType. The number of elements is variable among instances. The elements are accessable by index (1..).

In a textual definition, array types consist of a basetype followed by "[]", as in:

    <String>[]    -- an array of Strings

or:

    <Number>[]    -- an array of Numbers

Tuple Types[Bearbeiten]

Are defined as a non-homogenous, fixed size vector of a elements. Each element has a predefined type. The types may be different among elements, but all instances of the tuple type have the same type of element at corresponding positions. The elements are accessable by index (1..). Tuples are similar to compound types as described below. The difference is that tuples address the eleemnts by index, whereas compounds address them by name. Tuples are also similar to array types, however, the number of elements is fixed in a tuple, whereas arrays can have an arbitrary number of elements.

In a textual description, a tuple is defined by listing the individual element types in parenthesis. For example, a tuple which might represent a 3D coordinate, could be defined as:

    ( <Number> <Number> <Number> )

or, a tuple which associates a name with an age and gender might be:

    ( <String> <Integer> enum(M | F) )

For the last example, it would probably be better to use a compound, which names the slots.

Class Types[Bearbeiten]

A user defined class. Includes the instance's private slots (also called "instance variables"), and a set of operations (usually called "methods" or "virtual functions"). All of this information is stored with the test suite. Instance slots are accessable by getter/setter method invocations. Class types are defined by entering the class definition in a programming language (either the JavaScript-like dialect or Smalltalk).

Private class definitions allow for almost any functionality to be defined, but require some programming skills. For an introduction to programming, please refer to the "Online Documentation", the "Beginners Introduction & Tutorial", and the "Smalltalk Tutorial",.

Compound Types[Bearbeiten]

A collection of named slots. Is similar to a Class Type without operations (actually, that is how the system represents them internally). The elements are accessable by name.

In a textual definition, list the names and types of the individual elements in braces; for example, a person record might be defined as:

    {
        firstame : String
        lastName : String
        age      : Integer
        gender   : enum(M | F)
    }

Compound type definitions can also be imported from various other formats, such as DTD, XML, C-header files etc.

Enumeration Types[Bearbeiten]

A single symbolic value from a list of enumerated values. Typical examples are:

    enum( red | green | blue)

or:

    enum( male | female)

Range Types[Bearbeiten]

A subrange of Integer values. Used to limit the set of valid elements. For example, a byte could be defined as:

    range( <Integer> : 0 .. 255 )

Union Types[Bearbeiten]

The instance can be an instance from a number of other types. In a textual definition, list the possible element types, separated by a vetical bar, as in:

    <Filename> | <String> | <URL>

there is no explicit discriminator stored with the value. However, due to the run-time type information, it is possible in an elementary block to determine the type of value passed in, via the class or isXXX or isKindOf: protocols.

Type Representation (Syntax)[Bearbeiten]

Various textual representations are possible; some are already built into the base expecco system, others are addons and present if certain plugins are installed.

Formal Description of the Expecco Type Syntax[Bearbeiten]

Expecco provides its own native type-description language, with an easy to understand and use syntax:

type ::= <nonArrayType> | <arrayType>
arrayType ::= <nonArrayType> '[' ']'
nonArrayType ::= <tupleType> | <unionType> | <compoundType> 
                             | <enumType> | <rangeType> | <monitorType> 
                             | <primaryType> | <simpleType>
tupleType ::= '(' <elementType1> [','] <elementType2> .. <elementTypeN> ')'
elementType ::= <type>
unionType ::= '(' <alternativeType1> '|' <alternativeType2 > '|' .. <alternativeTypeN> ')'
alternativeType ::= <type>
enumType ::= 'enum' '(' <enumValue1> <enumValue2> .. <enumValueN> ')'
enumValue ::= <identifier> | <quoted-string> | <dquoted-string>
rangeType ::= 'range' '(' <baseType> ':' minValue .. <maxValue> ')'
minValue ::= <constant>
maxValue ::= <constant>
monitorType ::= 'monitor' '(' <baseType>')'
portType ::= 'port' '(' <baseType>')'
compoundType ::= '{' <fieldSpec1> <fieldSpec2> .. <fieldSpecN> '}'
fieldSpec ::= <fieldIdentifier> ':' <fieldType> [ '=' <defaultValue> ] [',']
fieldType ::= <type>
primaryType ::= '<' <BuiltIn-Classname> '>'
BuiltIn-Classname ::= <identifier>
simpleType ::= <anyType> | <templateType> | <constraintTemplateType> | <namedType>
anyType ::= '*'
templateType ::= '#' <templateIdentifier>

constraintTemplateType ::= '#' <templateIdentifier> <setOfConstraintTypes>
setOfConstraintTypes ::= <unionType>
<namedType> ::= 'any' | 'struct' | <typeName_in_project> | <Smalltalk-Classname>
typeName_in_project ::= <identifier>

Notes:
The separating commas in the tuple- and compound definitions are optional (vsn 2.1).
The "struct" named type is only supported by vsn 2.1 and newer.
This format is used if you select "Defined" type in the editor. It is also expected if you select "Define..." in one of the type menus (Pin-Type, Veriable-Type, Skill-Type). Support for this representation is part of the base expecco system.

DTD Type Definition[Bearbeiten]

A DTD-Defintion can also be used to specify a compound type. For this, choose "Compound (DTD-Defined)", and paste the DTD into the text area. Support for this representation is part of the base expecco system.

C-Language Type Definition[Bearbeiten]

A C-Language code fragment can also be used to specify a compound or union type. For this, choose "CType-C-Defined)", and paste the C-type definition into the text area. Instances of this type are especially useful when calling external DLL functions. Support for this representation is part of the base expecco system.

A typical C-Language definition looks like:

struct {
   int i1;
   float f1;
   double d1;
   char c[20];
}

XSD Type Definition[Bearbeiten]

A definition in XML. <usage: to be defined>

COBOL CopyBook Definition[Bearbeiten]

Parses a Cobol-CopyBook type-definition. This is only avaliable as plugin. Please read the corresponding plugin documentation for details.

ASN1 Type Definiton[Bearbeiten]

Parses an ASN1 type-definition. This is only avaliable as plugin. Please read the corresponding plugin documentation for details.

SunRPC-IDL Type Definiton[Bearbeiten]

Parses a SunRPC type-definition, which is used for example in the NFS file-system or in VISA lab equipment interfaces. This is only avaliable as plugin. Please read the corresponding plugin documentation for details.

COM/DCOM-IDL Type Definiton[Bearbeiten]

Parses a COM/DCOM IDL type-definition. This is only avaliable as plugin. Please read the corresponding plugin documentation for details.



Copyright © 2014-2024 eXept Software AG