Search in sources :

Example 1 with Enum_field

use of org.eclipse.titan.designer.AST.TTCN3.types.EnumeratedGenerator.Enum_field in project titan.EclipsePlug-ins by eclipse.

the class ASN1_Enumerated_Type method generateCode.

/**
 * Add generated java code on this level.
 * @param aData only used to update imports if needed
 * @param source the source code generated
 */
@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String ownName = getGenNameOwn();
    final String displayName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final List<EnumItem> items = new ArrayList<EnumItem>();
    if (enumerations != null) {
        if (enumerations.enumItems1 != null) {
            items.addAll(enumerations.enumItems1.getItems());
        }
        if (enumerations.enumItems2 != null) {
            items.addAll(enumerations.enumItems2.getItems());
        }
    }
    final boolean hasRaw = getGenerateCoderFunctions(MessageEncoding_type.RAW);
    final ArrayList<Enum_field> fields = new ArrayList<EnumeratedGenerator.Enum_field>(items.size());
    for (int i = 0; i < items.size(); i++) {
        final EnumItem tempItem = items.get(i);
        fields.add(new Enum_field(tempItem.getId().getName(), tempItem.getId().getDisplayName(), ((Integer_Value) tempItem.getValue()).getValue()));
    }
    final Enum_Defs e_defs = new Enum_Defs(fields, ownName, displayName, getGenNameTemplate(aData, source, myScope), hasRaw);
    EnumeratedGenerator.generateValueClass(aData, source, e_defs);
    EnumeratedGenerator.generateTemplateClass(aData, source, e_defs);
    generateCodeForCodingHandlers(aData, source);
}
Also used : Enum_field(org.eclipse.titan.designer.AST.TTCN3.types.EnumeratedGenerator.Enum_field) ArrayList(java.util.ArrayList) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) EnumeratedGenerator(org.eclipse.titan.designer.AST.TTCN3.types.EnumeratedGenerator) Enum_Defs(org.eclipse.titan.designer.AST.TTCN3.types.EnumeratedGenerator.Enum_Defs) EnumItem(org.eclipse.titan.designer.AST.TTCN3.types.EnumItem)

Example 2 with Enum_field

use of org.eclipse.titan.designer.AST.TTCN3.types.EnumeratedGenerator.Enum_field in project titan.EclipsePlug-ins by eclipse.

the class TTCN3_Enumerated_Type method generateCode.

/**
 * Add generated java code on this level.
 * @param aData only used to update imports if needed
 * @param source the source code generated
 */
@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String ownName = getGenNameOwn();
    final String displayName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final boolean hasRaw = getGenerateCoderFunctions(MessageEncoding_type.RAW);
    final ArrayList<Enum_field> fields = new ArrayList<EnumeratedGenerator.Enum_field>(items.getItems().size());
    for (int i = 0; i < items.getItems().size(); i++) {
        final EnumItem tempItem = items.getItems().get(i);
        fields.add(new Enum_field(tempItem.getId().getName(), tempItem.getId().getDisplayName(), ((Integer_Value) tempItem.getValue()).getValue()));
    }
    final Enum_Defs e_defs = new Enum_Defs(fields, ownName, displayName, getGenNameTemplate(aData, source, myScope), hasRaw);
    EnumeratedGenerator.generateValueClass(aData, source, e_defs);
    EnumeratedGenerator.generateTemplateClass(aData, source, e_defs);
    if (hasDoneAttribute()) {
        generateCodeDone(aData, source);
    }
    if (subType != null) {
        subType.generateCode(aData, source);
    }
    generateCodeForCodingHandlers(aData, source);
}
Also used : Enum_field(org.eclipse.titan.designer.AST.TTCN3.types.EnumeratedGenerator.Enum_field) ArrayList(java.util.ArrayList) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) Enum_Defs(org.eclipse.titan.designer.AST.TTCN3.types.EnumeratedGenerator.Enum_Defs)

Aggregations

ArrayList (java.util.ArrayList)2 Enum_Defs (org.eclipse.titan.designer.AST.TTCN3.types.EnumeratedGenerator.Enum_Defs)2 Enum_field (org.eclipse.titan.designer.AST.TTCN3.types.EnumeratedGenerator.Enum_field)2 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)2 EnumItem (org.eclipse.titan.designer.AST.TTCN3.types.EnumItem)1 EnumeratedGenerator (org.eclipse.titan.designer.AST.TTCN3.types.EnumeratedGenerator)1