René Beckmann 7 роки тому
батько
коміт
74eaff2005

+ 105 - 4
plugins/org.yakindu.sct.doc.user/src/user-guide/c-domain.textile

@@ -11,7 +11,7 @@ The YAKINDU Statechart Tools Professional Edition comes with a _Deep C/C++ Integ
 
 Making your self-defined C/C++ types, structs, and unions available in your YAKINDU statecharts saves you a lot of time and hassle that would otherwise be needed to map data from your C-type variables to statechart variables and vice versa.
 
-
+The C Domain offers one more feature: The annotation @ShortIdentifiers@ changes the naming scheme used by the code generator and activates more checks in the statechart validation to ensure that no identifiers produced by the code generator are longer than 31 characters. 
 
 
 h2(#cdom_what_can_you_do_with_deep_ccpp_integration). What can you do with Deep C/C++ Integration?
@@ -61,7 +61,7 @@ The subsequent sections will explain how to use Deep C/C++ Integration in practi
 
 
 
-h2(#cdom_creating_a_new_c_project). Creating a new C project
+h3(#cdom_creating_a_new_c_project). Creating a new C project
 
 # In the Eclipse main menu, select _File → New → Project…_. The _New Project_ wizard opens.
 # Select _C/C++ → C Project_.<br/>!images/cdom_geometry_010_new_c_project_010.png(Creating a new C project)!
@@ -79,7 +79,7 @@ h2(#cdom_creating_a_new_c_project). Creating a new C project
 
 
 
-h2(#cdom_creating_a_c_header_file). Creating a C header file
+h3(#cdom_creating_a_c_header_file). Creating a C header file
 
 Now we can create a C header file specifying our own C type definitions which we can use in a state machine later. In order to create the file, let's proceed as follows:
 
@@ -92,7 +92,7 @@ Now we can create a C header file specifying our own C type definitions which we
 
 
 
-h2(#cdom_defining_a_c_struct). Defining a C struct
+h3(#cdom_defining_a_c_struct). Defining a C struct
 
 In the created header file we define a struct type named _Point_, which we will later use in a statechart. A (two-dimensional) point consists of an _x_ and a _y_ coordinate. We choose _int16_t_ to represent a coordinate, i.e., a 16-bit signed integer. The complete header file containing the struct definition looks like this:
 
@@ -768,6 +768,107 @@ static void statechart_enact_main_region_Check(Statechart* handle)
 }
 
 
+h2(#cdom_annotations_short_identifiers). The @ShortIdentifiers annotation
+
+It is possible to add annotations to a statechart's specification to alter their or the code generator's behavior, see "Statechart Annotations":../user-guide/statechart_language.textile#sclang_annotations.
+
+The C Domain offers one more annotation: @ShortIdentifiers helps you to keep the generated code compliant to rules which require identifiers to be shorter than 31 characters.
+
+This is mainly done by:
+
+# Using only the actual state's name to identify it and forcing you to use individual names for _all_ states
+# Checking all names that will be generated by constructs in the statecharts and providing you with feedback if any of them will be longer than 31 characters
+# An intelligent name shortening strategy is applied to the static functions in the statechart's source file that keeps a good balance between readability and shortness
+
+Keep in mind that all public functions and types of the statechart are prefixed with its name, so keeping that one short helps a lot.
+
+h3(#cdom_annotations_short_identifiers_example). Example
+
+See the following example:
+
+!images/shortidentifiers_errors.png(Unambiguous state names produce errors)!
+
+p=. State names that are not globally unique produce errors.
+
+!images/shortidentifiers_warnings.png(Warnings for elements in the definition section)!
+
+p=. The name of some elements in the definition section produces warnings because resulting identifiers in the source code will be longer than 31 characters.
+
+!images/shortidentifiers_fixed.png(All issues resolved)!
+
+p=. All issues resolved: the states were renamed to be globally unique and some identifiers as well as the statechart's name were shortened to keep everything short.
+
+The state's names need to be globally unique because of a change in the naming scheme of the state enum.
+
+Enum without @ShortIdentifiers:
+
+bc. /*! Enumeration of all states */ 
+typedef enum
+{
+	House_last_state,
+	House_main_region_Idle,
+	House_main_region_Automation,
+	House_main_region_Automation_heater_Manual,
+	House_main_region_Automation_heater_Auto,
+	House_main_region_Automation_heater_Auto_modes_Normal,
+	House_main_region_Automation_heater_Auto_modes_Absence,
+	House_main_region_Automation_lights_Lights_Off,
+	House_main_region_Automation_lights_Lights_On,
+	House_main_region_Automation_pond_Pond_Off,
+	House_main_region_Automation_pond_Pond_On
+} HouseStates;
+
+Enum with @ShortIdentifiers:
+
+bc. /*! Enumeration of all states */ 
+typedef enum
+{
+	House_last_state,
+	House_Idle,
+	House_Automation,
+	House_Manual,
+	House_Auto,
+	House_Normal,
+	House_Absence,
+	House_Lights_Off,
+	House_Lights_On,
+	House_Pond_Off,
+	House_Pond_On
+} HouseStates;
+
+Notice how the state's names are not prefixed with their containing regions anymore to save characters.
+
+p. The name shortening algorithm for the static functions works like this, again without @ShortIdentifiers:
+
+bc. /* prototypes of all internal functions */
+static sc_boolean check_main_region_Idle_tr0_tr0(const House* handle);
+static sc_boolean check_main_region_Automation_tr0_tr0(const House* handle);
+static sc_boolean check_main_region_Automation_heater_Manual_tr0_tr0(const House* handle);
+static sc_boolean check_main_region_Automation_heater_Auto_tr0_tr0(const House* handle);
+static sc_boolean check_main_region_Automation_heater_Auto_modes_Normal_lr0_lr0(const House* handle);
+static sc_boolean check_main_region_Automation_heater_Auto_modes_Normal_tr0_tr0(const House* handle);
+static sc_boolean check_main_region_Automation_heater_Auto_modes_Absence_lr0_lr0(const House* handle);
+static sc_boolean check_main_region_Automation_heater_Auto_modes_Absence_tr0_tr0(const House* handle);
+static sc_boolean check_main_region_Automation_lights_Lights_Off_tr0_tr0(const House* handle);
+static sc_boolean check_main_region_Automation_lights_Lights_On_tr0_tr0(const House* handle);
+static sc_boolean check_main_region_Automation_pond_Pond_Off_tr0_tr0(const House* handle);
+static sc_boolean check_main_region_Automation_pond_Pond_On_tr0_tr0(const House* handle);
+
+p. With @ShortIdentifiers annotation:
+
+bc. /* prototypes of all internal functions */
+static sc_boolean Idle_tr0_check(const House* handle);
+static sc_boolean Automation_tr0_check(const House* handle);
+static sc_boolean Manual_tr0_check(const House* handle);
+static sc_boolean Auto_tr0_check(const House* handle);
+static sc_boolean Normal_lr0_check(const House* handle);
+static sc_boolean Normal_tr0_check(const House* handle);
+static sc_boolean Absence_lr0_check(const House* handle);
+static sc_boolean Absence_tr0_check(const House* handle);
+static sc_boolean Lights_Off_tr0_check(const House* handle);
+static sc_boolean Lights_On_tr0_check(const House* handle);
+static sc_boolean Pond_Off_tr0_check(const House* handle);
+static sc_boolean Pond_On_tr0_check(const House* handle);
 
 
 h2(#cdom_currently_supported_primitive_types). Currently supported primitive types

+ 2 - 4
plugins/org.yakindu.sct.doc.user/src/user-guide/generating_code.textile

@@ -363,10 +363,10 @@ h4(#codegen_c_identifiersettings_feature). IdentifierSettings feature
 The *IdentifierSettings* feature allows the configuration of module names and identifier character length:
 
 * _moduleName_ (String, optional): Name for header and implementation. Default: statechart name.
-* _statemachinePrefix_ (Boolean, optional): Prefix that is prepended to function, state, and type names.
-* _maxIdentifierLength_ (Integer, optional): Maximum number of characters of an identifier. Default: 31 characters, which is complying with the ANSI C99 standard.
 * _separator_ (String, optional): Character to replace whitespace and otherwise illegal characters in names.
 
+Please note that the two options _statemachinePrefix_ and _maxIdentifierLength_ that existed in older versions of YAKINDU Statechart Tools were removed in favor of a statechart annotation that is only available in C Domain bundled with YAKINDU Statechart Tools Professional Edition, see "@ShortIdentifiers":../user-guide/c_domain.textile#cdom_annotations_short_identifiers .
+
 
 ==<div class="example">==
 
@@ -374,8 +374,6 @@ Example:
 
 bc. feature IdentifierSettings {
     moduleName = "MyStatechart"
-    statemachinePrefix = "myStatechart"
-    maxIdentifierLength = 31
     separator = "_"
 }
 

BIN
plugins/org.yakindu.sct.doc.user/src/user-guide/images/shortidentifiers_errors.png


BIN
plugins/org.yakindu.sct.doc.user/src/user-guide/images/shortidentifiers_fixed.png


BIN
plugins/org.yakindu.sct.doc.user/src/user-guide/images/shortidentifiers_warnings.png