Skip to content

Commit

Permalink
CommonAPI-D-Bus-Tools 3.1.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Nov 14, 2016
1 parent 6db8237 commit 64b0e52
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2;
import org.genivi.commonapi.core.preferences.PreferenceConstants;
import org.genivi.commonapi.core.ui.handler.GenerationCommand;
import org.genivi.commonapi.dbus.preferences.FPreferencesDBus;
import org.genivi.commonapi.dbus.preferences.PreferenceConstantsDBus;
Expand All @@ -26,7 +25,7 @@ public class DBusGenerationCommand extends GenerationCommand {
/**
* Init dbus preferences
* @param page
* @param project
* @param projects
*/
@Override
protected void setupPreferences(IFile file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*******************************************************************************/
package org.genivi.commonapi.dbus;

import org.eclipse.emf.ecore.EObject;
import org.franca.core.franca.FInterface;
import org.franca.core.franca.FField;
import org.franca.core.franca.FArgument;
import org.eclipse.emf.ecore.EObject;
import org.franca.core.franca.FAttribute;
import org.franca.core.franca.FField;
import org.franca.core.franca.FInterface;
import org.franca.deploymodel.core.FDeployedInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package org.genivi.commonapi.dbus;

import org.eclipse.emf.ecore.EObject;
import org.franca.core.franca.FInterface;
import org.franca.core.franca.FField;
import org.franca.core.franca.FInterface;
import org.franca.deploymodel.core.FDeployedTypeCollection;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ class FInterfaceDBusStubAdapterGenerator {
> «fInterface.dbusStubAdapterClassNameInternal»<_Stub, _Stubs...>::«fBroadcast.dbusStubDispatcherVariableUnsubscribe»(&«fInterface.stubAdapterClassName + "::" + fBroadcast.unsubscribeSelectiveMethodName», "");
'''
def private getInterfaceHierarchy(FInterface fInterface) {
def private String getInterfaceHierarchy(FInterface fInterface) {
if (fInterface.base == null) {
fInterface.stubFullClassName
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ import org.eclipse.core.resources.IResource
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.xtext.generator.IFileSystemAccess
import org.eclipse.xtext.generator.IGenerator

import org.franca.core.dsl.FrancaPersistenceManager
import org.franca.core.franca.FInterface
import org.franca.core.franca.FModel
import org.franca.core.franca.FTypeCollection
import org.franca.deploymodel.core.FDeployedInterface
import org.franca.deploymodel.core.FDeployedTypeCollection
import org.franca.deploymodel.dsl.fDeploy.FDInterface
import org.franca.deploymodel.dsl.fDeploy.FDModel
import org.franca.deploymodel.dsl.fDeploy.FDProvider
import org.franca.deploymodel.dsl.fDeploy.FDTypes
import org.franca.deploymodel.dsl.fDeploy.FDeployFactory
import org.genivi.commonapi.core.generator.FDeployManager
import org.genivi.commonapi.core.generator.FrancaGeneratorExtensions
import org.genivi.commonapi.dbus.deployment.PropertyAccessor
Expand Down Expand Up @@ -55,6 +57,9 @@ class FrancaDBusGenerator implements IGenerator {
val String CORE_SPECIFICATION_TYPE = "core.deployment"
val String DBUS_SPECIFICATION_TYPE = "dbus.deployment"

val String CORE_SPECIFICATION_NAME = "org.genivi.commonapi.core.deployment"
val String DBUS_SPECIFICATION_NAME = "org.genivi.commonapi.dbus.deployment"

var rootModel = fDeployManager.loadModel(input.URI, input.URI)

generatedFiles_ = new HashSet<String>()
Expand All @@ -72,31 +77,110 @@ class FrancaDBusGenerator implements IGenerator {
models.put(input.URI.toString, rootModel)
}

var allCoreInterfaces = new LinkedList<FDInterface>()
var allCoreTypeCollections = new LinkedList<FDTypes>()
for (itsEntry : deployments.entrySet) {
val itsDeployment = itsEntry.value

// Get Core deployments
val itsCoreInterfaces = getFDInterfaces(itsDeployment, CORE_SPECIFICATION_TYPE)
val itsCoreTypeCollections = getFDTypesList(itsDeployment, CORE_SPECIFICATION_TYPE)

allCoreInterfaces.addAll(itsCoreInterfaces)
allCoreTypeCollections.addAll(itsCoreTypeCollections)
}

// Get DBus deployments
val itsDBusInterfaces = getFDInterfaces(itsDeployment, DBUS_SPECIFICATION_TYPE)
val itsDBusTypeCollections = getFDTypesList(itsDeployment, DBUS_SPECIFICATION_TYPE)
val itsDBusProviders = getFDProviders(itsDeployment, DBUS_SPECIFICATION_TYPE)

// Merge Core deployments for interfaces to their DBus deployments
for (itsDBusDeployment : itsDBusInterfaces)
for (itsCoreDeployment : itsCoreInterfaces)
mergeDeployments(itsCoreDeployment, itsDBusDeployment)

// Merge Core deployments for type collections to their DBus deployments
for (itsDBusDeployment : itsDBusTypeCollections)
for (itsCoreDeployment : itsCoreTypeCollections)
mergeDeployments(itsCoreDeployment, itsDBusDeployment)
// Check whether there do exist models without deployment. If yes, create deployment for them.
var missingCoreInterfaces = new LinkedList<FDInterface>()
var missingCoreTypeCollections = new LinkedList<FDTypes>()
val itsCoreSpecification = fDeployManager.getDeploymentSpecification(CORE_SPECIFICATION_NAME)
if (itsCoreSpecification != null) {
for (itsEntry : models.entrySet) {
val itsModel = itsEntry.value

if (itsModel instanceof FModel) {
for (i : itsModel.interfaces) {
if (!i.isDeployed(allCoreInterfaces)) {
val itsNewDeployment = FDeployFactory.eINSTANCE.createFDInterface()
itsNewDeployment.target = i
itsNewDeployment.spec = itsCoreSpecification

missingCoreInterfaces.add(itsNewDeployment)
}
}

for (i : itsModel.typeCollections) {
if (!i.isDeployed(allCoreTypeCollections)) {
val itsNewDeployment = FDeployFactory.eINSTANCE.createFDTypes()
itsNewDeployment.target = i
itsNewDeployment.spec = itsCoreSpecification

missingCoreTypeCollections.add(itsNewDeployment)
}
}
}
}
}

deployedInterfaces.addAll(itsDBusInterfaces)
deployedTypeCollections.addAll(itsDBusTypeCollections)
deployedProviders.addAll(itsDBusProviders)
allCoreInterfaces.addAll(missingCoreInterfaces)
allCoreTypeCollections.addAll(missingCoreTypeCollections)

// Finally check/create/merge the DBus deployment
var itsDBusSpecification = fDeployManager.getDeploymentSpecification(DBUS_SPECIFICATION_NAME)
if (itsDBusSpecification == null)
itsDBusSpecification = fDeployManager.getDeploymentSpecification(CORE_SPECIFICATION_NAME)
if (itsDBusSpecification != null) {
for (itsEntry : deployments.entrySet) {
val itsDeployment = itsEntry.value

// Get DBus deployments
val itsDBusInterfaces = getFDInterfaces(itsDeployment, DBUS_SPECIFICATION_TYPE)
val itsDBusTypeCollections = getFDTypesList(itsDeployment, DBUS_SPECIFICATION_TYPE)
val itsDBusProviders = getFDProviders(itsDeployment, DBUS_SPECIFICATION_TYPE)

// Create DBus deployments for interfaces/type collections without
if (rootModel instanceof FDModel) {
for (m : models.entrySet) {
for (i : m.value.interfaces) {
if (!i.isDeployed(itsDBusInterfaces) && !i.isDeployed(deployedInterfaces)) {
val itsNewDeployment = FDeployFactory.eINSTANCE.createFDInterface()
itsNewDeployment.target = i
itsNewDeployment.spec = itsDBusSpecification

rootModel.deployments.add(itsNewDeployment)
itsDBusInterfaces.add(itsNewDeployment)
}
}
for (i : m.value.typeCollections) {
if (!i.isDeployed(itsDBusTypeCollections) && !i.isDeployed(deployedTypeCollections)) {
val itsNewDeployment = FDeployFactory.eINSTANCE.createFDTypes()
itsNewDeployment.target = i
itsNewDeployment.spec = itsDBusSpecification

rootModel.deployments.add(itsNewDeployment)
itsDBusTypeCollections.add(itsNewDeployment)
}
}
}
}

// Merge Core deployments for interfaces to their DBus deployments
for (itsDBusDeployment : itsDBusInterfaces) {
for (itsCoreDeployment : allCoreInterfaces)
mergeDeployments(itsCoreDeployment, itsDBusDeployment)
for (itsCoreDeployment : allCoreTypeCollections)
mergeDeployments(itsCoreDeployment, itsDBusDeployment)
}

// Merge Core deployments for type collections to their DBus deployments
for (itsDBusDeployment : itsDBusTypeCollections)
for (itsCoreDeployment : allCoreTypeCollections)
mergeDeploymentsExt(itsCoreDeployment, itsDBusDeployment)

deployedInterfaces.addAll(itsDBusInterfaces)
deployedTypeCollections.addAll(itsDBusTypeCollections)
deployedProviders.addAll(itsDBusProviders)
}
}

if (rootModel instanceof FDModel) {
Expand All @@ -113,6 +197,24 @@ class FrancaDBusGenerator implements IGenerator {
fDeployManager.clearDeploymentModels
}

def private boolean isDeployed(FInterface _iface, List<FDInterface> _deployments) {
for (d : _deployments) {
if (d.target == _iface) {
return true
}
}
return false
}

def private boolean isDeployed(FTypeCollection _tc, List<FDTypes> _deployments) {
for (d : _deployments) {
if (d.target == _tc) {
return true
}
}
return false
}

def private void doGenerateDeployment(FDModel _deployment,
Map<String, FDModel> _deployments,
Map<String, FModel> _models,
Expand Down Expand Up @@ -242,13 +344,15 @@ class FrancaDBusGenerator implements IGenerator {

interfacesToGenerate.forEach [
val currentInterface = it
var PropertyAccessor deploymentAccessor
if (_interfaces.exists[it.target == currentInterface]) {
deploymentAccessor = new PropertyAccessor(
new FDeployedInterface(_interfaces.filter[it.target == currentInterface].last))
} else {
deploymentAccessor = new PropertyAccessor()
}
var PropertyAccessor deploymentAccessor = getAccessor(it);
if (null == deploymentAccessor) {
if (_interfaces.exists[it.target == currentInterface]) {
deploymentAccessor = new PropertyAccessor(
new FDeployedInterface(_interfaces.filter[it.target == currentInterface].last))
} else {
deploymentAccessor = new PropertyAccessor()
}
}
if (FPreferencesDBus::instance.getPreference(PreferenceConstantsDBus::P_GENERATE_PROXY_DBUS, "true").
equals("true")) {
it.generateDBusProxy(_access, deploymentAccessor, _providers, _res)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.genivi.commonapi.dbus.generator

import javax.inject.Inject
import java.util.Collection
import java.util.HashMap
import java.util.Map
import java.util.HashSet
import java.util.Map
import java.util.Set

import org.eclipse.core.resources.IResource
import org.franca.core.franca.FArrayType
import javax.inject.Inject
import org.eclipse.emf.common.util.EList
import org.eclipse.emf.ecore.EObject
import org.franca.core.franca.FArgument
import org.franca.core.franca.FArrayType
import org.franca.core.franca.FAttribute
import org.franca.core.franca.FBasicTypeId
import org.franca.core.franca.FBroadcast
Expand All @@ -25,21 +26,18 @@ import org.franca.core.franca.FMethod
import org.franca.core.franca.FModelElement
import org.franca.core.franca.FStructType
import org.franca.core.franca.FType
import org.franca.core.franca.FTypeCollection
import org.franca.core.franca.FTypeDef
import org.franca.core.franca.FTypeRef
import org.franca.core.franca.FTypedElement
import org.franca.core.franca.FUnionType
import org.genivi.commonapi.core.generator.FrancaGeneratorExtensions
import org.genivi.commonapi.dbus.deployment.PropertyAccessor
import org.genivi.commonapi.dbus.preferences.FPreferencesDBus
import org.genivi.commonapi.dbus.preferences.PreferenceConstantsDBus
import org.osgi.framework.FrameworkUtil
import java.util.Collection
import org.franca.core.franca.FTypeCollection
import org.eclipse.emf.common.util.EList
import org.eclipse.emf.ecore.EObject

import static com.google.common.base.Preconditions.*
import org.genivi.commonapi.dbus.preferences.FPreferencesDBus
import org.genivi.commonapi.dbus.preferences.PreferenceConstantsDBus

class FrancaDBusGeneratorExtensions {
@Inject private extension FrancaGeneratorExtensions
Expand Down Expand Up @@ -166,6 +164,7 @@ class FrancaDBusGeneratorExtensions {

def private dispatch dbusFTypeSignature(FEnumerationType fEnumerationType, PropertyAccessor deploymentAccessor) {
val FBasicTypeId backingType = fEnumerationType.getBackingType(deploymentAccessor)

if (backingType == FBasicTypeId.UNDEFINED)
return FBasicTypeId.INT32.dbusSignature

Expand Down

0 comments on commit 64b0e52

Please sign in to comment.