Question & Answer
Question
How is Array type in UML translated to C?
Answer
The component and index sort can be any of the sorts that the "C Code Generator" can handle, but must not directly or indirectly refer to the array type itself. If the index sort is a discrete sort, with a closed value range, then the UML array is translated to a "struct" type containing an element that is an array in C. The discrete sorts are:
· Character
· Boolean
· Octet
· Bit
· A sort that is considered as an enumeration type
· Syntype of any Integer, Character, Boolean, Octet, Bit or enumeration type. (The
subtypes may only have one range condition that specifies a closed interval of
values.)
If the index sort is not one of the sorts in the list above, the UML array is translated to a linked list. The list head contains the default value for all possible indexes, while the list elements contain value pairs, (index_value, component_value), for each index having a component value not equal to the default value.
E.g.
UML
syntype MyInt= Integer constants (1..10);
class Arr {
Array <MyInt, Real> MyArray;
}
C
typedef SDL_Integer MyInt;
typedef struct {
SDL_Real A[10];
} Arr;
Historical Number
KB7696
Was this topic helpful?
Document Information
More support for:
Rational Tau
Software version:
Version Independent
Document number:
364669
Modified date:
16 June 2018
UID
swg21325630