Search in sources :

Example 1 with SignatureDefinition

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

the class Signature_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String genName = getGenNameOwn();
    final ArrayList<SignatureParameter> parameters = new ArrayList<SignatureParameter>();
    for (int i = 0; i < formalParList.getNofParameters(); i++) {
        final SignatureFormalParameter formalPar = formalParList.getParameterByIndex(i);
        final Type type = formalPar.getType();
        SignatureGenerator.signatureParamaterDirection direction;
        switch(formalPar.getDirection()) {
            case PARAM_OUT:
                direction = signatureParamaterDirection.PAR_OUT;
                break;
            case PARAM_INOUT:
                direction = signatureParamaterDirection.PAR_INOUT;
                break;
            default:
                direction = signatureParamaterDirection.PAR_IN;
                break;
        }
        final SignatureParameter temp = new SignatureParameter(direction, type.getGenNameValue(aData, source, myScope), type.getGenNameTemplate(aData, source, myScope), formalPar.getIdentifier().getName());
        parameters.add(temp);
    }
    SignatureReturnType signatueReturnType = null;
    if (returnType != null) {
        signatueReturnType = new SignatureReturnType(returnType.getGenNameValue(aData, source, myScope), returnType.getGenNameTemplate(aData, source, myScope));
    }
    final ArrayList<SignatureException> signatureExceptions = new ArrayList<SignatureGenerator.SignatureException>();
    if (exceptions != null) {
        for (int i = 0; i < exceptions.getNofExceptions(); i++) {
            final Type exceptionType = exceptions.getExceptionByIndex(i);
            final IType last = exceptionType.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
            final SignatureException temp = new SignatureException(last.getGenNameValue(aData, source, myScope), last.getGenNameTemplate(aData, source, myScope), last.getFullName());
            signatureExceptions.add(temp);
        }
    }
    final SignatureDefinition def = new SignatureDefinition(genName, getFullName(), parameters, signatueReturnType, noBlock, signatureExceptions);
    SignatureGenerator.generateClasses(aData, source, def);
    if (hasDoneAttribute()) {
        generateCodeDone(aData, source);
    }
    if (subType != null) {
        subType.generateCode(aData, source);
    }
    generateCodeForCodingHandlers(aData, source);
}
Also used : SignatureDefinition(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureDefinition) ArrayList(java.util.ArrayList) SignatureException(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureException) IType(org.eclipse.titan.designer.AST.IType) SignatureReturnType(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureReturnType) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) SignatureParameter(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureParameter) SignatureGenerator.signatureParamaterDirection(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.signatureParamaterDirection) SignatureReturnType(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureReturnType)

Aggregations

ArrayList (java.util.ArrayList)1 IType (org.eclipse.titan.designer.AST.IType)1 SignatureDefinition (org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureDefinition)1 SignatureException (org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureException)1 SignatureParameter (org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureParameter)1 SignatureReturnType (org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureReturnType)1 SignatureGenerator.signatureParamaterDirection (org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.signatureParamaterDirection)1 Type (org.eclipse.titan.designer.AST.Type)1