IBM Support

How is Array type in UML translated to C?

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;

TAU/DEVELOPERTAUDEV-FAQ-50AnswerProduct versionPartner ContentInternal ContentCategoryReference ID
[{"Product":{"code":"SSYQGX","label":"Rational Tau"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"General Information","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Historical Number

KB7696

Document Information

More support for:
Rational Tau

Software version:
Version Independent

Document number:
364669

Modified date:
16 June 2018

UID

swg21325630