All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.joynr.generator.cpp.communicationmodel.CommunicationModelGenerator Maven / Gradle / Ivy

There is a newer version: 0.9.3
Show newest version
package io.joynr.generator.cpp.communicationmodel;

import com.google.common.base.Objects;
import com.google.inject.Inject;
import io.joynr.generator.cpp.communicationmodel.EnumHTemplate;
import io.joynr.generator.cpp.communicationmodel.InterfaceCppTemplate;
import io.joynr.generator.cpp.communicationmodel.InterfaceHTemplate;
import io.joynr.generator.cpp.communicationmodel.TypeCppTemplate;
import io.joynr.generator.cpp.communicationmodel.TypeHTemplate;
import io.joynr.generator.cpp.util.JoynrCppGeneratorExtensions;
import java.io.File;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Extension;
import org.franca.core.franca.FCompoundType;
import org.franca.core.franca.FEnumerationType;
import org.franca.core.franca.FInterface;
import org.franca.core.franca.FModel;
import org.franca.core.franca.FType;

@SuppressWarnings("all")
public class CommunicationModelGenerator {
  @Inject
  @Extension
  private JoynrCppGeneratorExtensions _joynrCppGeneratorExtensions;
  
  @Inject
  private InterfaceHTemplate interfaceH;
  
  @Inject
  private InterfaceCppTemplate interfaceCpp;
  
  @Inject
  private EnumHTemplate enumh;
  
  @Inject
  private TypeHTemplate typeH;
  
  @Inject
  private TypeCppTemplate typeCpp;
  
  public void doGenerate(final FModel fModel, final IFileSystemAccess sourceFileSystem, final IFileSystemAccess headerFileSystem, final String sourceContainerPath, final String headerContainerPath) {
    String _plus = (sourceContainerPath + "datatypes");
    final String dataTypePath = (_plus + File.separator);
    String _xifexpression = null;
    boolean _equals = Objects.equal(sourceFileSystem, headerFileSystem);
    if (_equals) {
      String _plus_1 = (headerContainerPath + "datatypes");
      String _plus_2 = (_plus_1 + File.separator);
      _xifexpression = _plus_2;
    } else {
      _xifexpression = headerContainerPath;
    }
    final String headerDataTypePath = _xifexpression;
    Iterable _complexDataTypes = this._joynrCppGeneratorExtensions.getComplexDataTypes(fModel);
    for (final FType type : _complexDataTypes) {
      if ((type instanceof FCompoundType)) {
        String _packageSourceDirectory = this._joynrCppGeneratorExtensions.getPackageSourceDirectory(type);
        String _plus_3 = (dataTypePath + _packageSourceDirectory);
        final String sourcepath = (_plus_3 + File.separator);
        String _packagePathWithJoynrPrefix = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(type, File.separator);
        String _plus_4 = (headerDataTypePath + _packagePathWithJoynrPrefix);
        final String headerpath = (_plus_4 + File.separator);
        String _joynrName = this._joynrCppGeneratorExtensions.joynrName(type);
        String _plus_5 = (headerpath + _joynrName);
        String _plus_6 = (_plus_5 + ".h");
        CharSequence _generate = this.typeH.generate(type);
        String _string = _generate.toString();
        headerFileSystem.generateFile(_plus_6, _string);
        String _joynrName_1 = this._joynrCppGeneratorExtensions.joynrName(type);
        String _plus_7 = (sourcepath + _joynrName_1);
        String _plus_8 = (_plus_7 + ".cpp");
        CharSequence _generate_1 = this.typeCpp.generate(type);
        String _string_1 = _generate_1.toString();
        sourceFileSystem.generateFile(_plus_8, _string_1);
      }
    }
    Iterable _enumDataTypes = this._joynrCppGeneratorExtensions.getEnumDataTypes(fModel);
    for (final FType type_1 : _enumDataTypes) {
      {
        String _packagePathWithJoynrPrefix_1 = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(type_1, File.separator);
        String _plus_9 = (headerDataTypePath + _packagePathWithJoynrPrefix_1);
        final String headerpath_1 = (_plus_9 + File.separator);
        String _joynrName_2 = this._joynrCppGeneratorExtensions.joynrName(type_1);
        String _plus_10 = (headerpath_1 + _joynrName_2);
        String _plus_11 = (_plus_10 + ".h");
        CharSequence _generate_2 = this.enumh.generate(((FEnumerationType) type_1));
        String _string_2 = _generate_2.toString();
        headerFileSystem.generateFile(_plus_11, _string_2);
      }
    }
    String _plus_9 = (sourceContainerPath + "interfaces");
    final String interfacePath = (_plus_9 + File.separator);
    String _xifexpression_1 = null;
    boolean _equals_1 = Objects.equal(sourceFileSystem, headerFileSystem);
    if (_equals_1) {
      String _plus_10 = (headerContainerPath + "interfaces");
      String _plus_11 = (_plus_10 + File.separator);
      _xifexpression_1 = _plus_11;
    } else {
      _xifexpression_1 = headerContainerPath;
    }
    final String headerInterfacePath = _xifexpression_1;
    EList _interfaces = fModel.getInterfaces();
    for (final FInterface serviceInterface : _interfaces) {
      {
        String _packageSourceDirectory_1 = this._joynrCppGeneratorExtensions.getPackageSourceDirectory(serviceInterface);
        String _plus_12 = (interfacePath + _packageSourceDirectory_1);
        final String sourcepath_1 = (_plus_12 + File.separator);
        String _packagePathWithJoynrPrefix_1 = this._joynrCppGeneratorExtensions.getPackagePathWithJoynrPrefix(serviceInterface, File.separator);
        String _plus_13 = (headerInterfacePath + _packagePathWithJoynrPrefix_1);
        final String headerpath_1 = (_plus_13 + File.separator);
        String _plus_14 = (headerpath_1 + "I");
        String _joynrName_2 = this._joynrCppGeneratorExtensions.joynrName(serviceInterface);
        String _plus_15 = (_plus_14 + _joynrName_2);
        String _plus_16 = (_plus_15 + ".h");
        CharSequence _generate_2 = this.interfaceH.generate(serviceInterface);
        String _string_2 = _generate_2.toString();
        headerFileSystem.generateFile(_plus_16, _string_2);
        String _plus_17 = (sourcepath_1 + "I");
        String _joynrName_3 = this._joynrCppGeneratorExtensions.joynrName(serviceInterface);
        String _plus_18 = (_plus_17 + _joynrName_3);
        String _plus_19 = (_plus_18 + ".cpp");
        CharSequence _generate_3 = this.interfaceCpp.generate(serviceInterface);
        String _string_3 = _generate_3.toString();
        sourceFileSystem.generateFile(_plus_19, _string_3);
      }
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy