summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Laner <laner@itestra.de>2014-02-24 11:03:22 +0100
committerStefan Laner <laner@itestra.de>2014-02-24 11:09:21 +0100
commit44a533744c214bd15d36805c96239264348fe01b (patch)
treea6406920b396a2b16faf866ed2ec03e632573831
parent8f52a01bd3db8583ebc2e8d53769b5a8480798e8 (diff)
downloadgenivi-common-api-runtime-44a533744c214bd15d36805c96239264348fe01b.tar.gz
generator now creates windows compatible code
Change-Id: I918cf1be2d8165c8a5c3a0f927ce4ebe18e193f1
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend13
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend17
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend76
3 files changed, 78 insertions, 28 deletions
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend
index f21ce39..aec3e6a 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend
@@ -262,6 +262,12 @@ class FInterfaceProxyGenerator {
std::shared_ptr<«fInterface.proxyBaseClassName»> delegate_;
};
+ #ifdef WIN32
+ typedef «fInterface.proxyClassName»<CommonAPI::WINDummyAttributeExtension<CommonAPI::WINDummyAttribute>> «fInterface.proxyDefaultClassName»;
+ #else
+ typedef «fInterface.proxyClassName»<> «fInterface.proxyDefaultClassName»;
+ #endif
+
«IF fInterface.hasAttributes»
namespace «fInterface.extensionsSubnamespace» {
«FOR attribute : fInterface.attributes»
@@ -375,6 +381,9 @@ class FInterfaceProxyGenerator {
static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<«fInterface.proxyBaseClassName»::«fAttribute.className»>, extension_type>::value,
"Not CommonAPI Attribute Extension!");
+ #ifdef WIN32
+ «fAttribute.extensionClassName»() {}
+ #endif
«fAttribute.extensionClassName»(«fInterface.proxyBaseClassName»& proxy): attributeExtension_(proxy.get«fAttribute.className»()) {
}
@@ -430,6 +439,10 @@ class FInterfaceProxyGenerator {
fInterface.elementName + 'Proxy'
}
+ def private getProxyDefaultClassName(FInterface fInterface) {
+ fInterface.proxyClassName + 'Default'
+ }
+
def private getExtensionClassName(FAttribute fAttribute) {
return fAttribute.className + 'Extension'
}
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend
index a5e01ce..b2f93c4 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend
@@ -62,7 +62,7 @@ class FInterfaceStubGenerator {
* and attribute-changed-notifications of observable attributes as defined by this service.
* An application developer should not need to bother with this class.
*/
- class «fInterface.stubAdapterClassName»: virtual public CommonAPI::StubAdapter, public «fInterface.elementName» {
+ class «fInterface.stubAdapterClassName»: virtual public CommonAPI::StubAdapter, public «fInterface.elementName»«IF fInterface.base != null», public virtual «fInterface.base.stubAdapterClassName»«ENDIF» {
public:
«FOR attribute : fInterface.attributes»
«IF attribute.isObservable»
@@ -123,7 +123,7 @@ class FInterfaceStubGenerator {
* This class and the one below are the ones an application developer needs to have
* a look at if he wants to implement a service.
*/
- class «fInterface.stubRemoteEventClassName» {
+ class «fInterface.stubRemoteEventClassName»«IF fInterface.base != null»: public virtual «fInterface.base.stubRemoteEventClassName»«ENDIF» {
public:
virtual ~«fInterface.stubRemoteEventClassName»() { }
@@ -145,7 +145,7 @@ class FInterfaceStubGenerator {
* This class and the one above are the ones an application developer needs to have
* a look at if he wants to implement a service.
*/
- class «fInterface.stubClassName» : public virtual «fInterface.stubCommonAPIClassName»«IF fInterface.base != null», public virtual «fInterface.base.stubClassName»«ENDIF» {
+ class «fInterface.stubClassName»: public virtual «fInterface.stubCommonAPIClassName»«IF fInterface.base != null», public virtual «fInterface.base.stubClassName»«ENDIF» {
public:
virtual ~«fInterface.stubClassName»() { }
virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0;
@@ -190,6 +190,8 @@ class FInterfaceStubGenerator {
using «fInterface.stubCommonAPIClassName»::initStubAdapter;
typedef «fInterface.stubCommonAPIClassName»::StubAdapterType StubAdapterType;
typedef «fInterface.stubCommonAPIClassName»::RemoteEventHandlerType RemoteEventHandlerType;
+ typedef «fInterface.stubRemoteEventClassName» RemoteEventType;
+ typedef «fInterface.elementName» StubInterface;
};
«fInterface.model.generateNamespaceEndDeclaration»
@@ -276,8 +278,7 @@ class FInterfaceStubGenerator {
virtual void «attribute.stubRemoteEventClassChangedMethodName»();
«ENDIF»
«ENDFOR»
- private:
- class RemoteEventHandler: public «fInterface.stubRemoteEventClassName» {
+ class RemoteEventHandler: public virtual «fInterface.stubRemoteEventClassName»«IF fInterface.base != null», public virtual «fInterface.base.stubDefaultClassName»::RemoteEventHandler«ENDIF» {
public:
RemoteEventHandler(«fInterface.stubDefaultClassName»* defaultStub);
@@ -294,8 +295,8 @@ class FInterfaceStubGenerator {
private:
«fInterface.stubDefaultClassName»* defaultStub_;
};
-
- RemoteEventHandler remoteEventHandler_;
+ private:
+ «fInterface.stubDefaultClassName»::RemoteEventHandler remoteEventHandler_;
«IF !fInterface.managedInterfaces.empty»
uint32_t autoInstanceCounter_;
«ENDIF»
@@ -332,6 +333,7 @@ class FInterfaceStubGenerator {
}
«fInterface.stubRemoteEventClassName»* «fInterface.stubDefaultClassName»::initStubAdapter(const std::shared_ptr<«fInterface.stubAdapterClassName»>& stubAdapter) {
+ «IF fInterface.base != null»«fInterface.base.stubDefaultClassName»::initStubAdapter(stubAdapter);«ENDIF»
«fInterface.stubCommonAPIClassName»::stubAdapter_ = stubAdapter;
return &remoteEventHandler_;
}
@@ -447,6 +449,7 @@ class FInterfaceStubGenerator {
«ENDFOR»
«fInterface.stubDefaultClassName»::RemoteEventHandler::RemoteEventHandler(«fInterface.stubDefaultClassName»* defaultStub):
+ «IF fInterface.base != null»«fInterface.base.stubDefaultClassName»::RemoteEventHandler(defaultStub),«ENDIF»
defaultStub_(defaultStub) {
}
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend
index 1ecae0b..ebee483 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend
@@ -10,11 +10,15 @@ import com.google.common.base.Charsets
import com.google.common.hash.Hasher
import com.google.common.hash.Hashing
import com.google.common.primitives.Ints
+import java.util.Collection
import java.util.List
+import org.eclipse.core.resources.IResource
import org.eclipse.core.resources.ResourcesPlugin
import org.eclipse.core.runtime.Path
import org.eclipse.core.runtime.preferences.DefaultScope
import org.eclipse.core.runtime.preferences.InstanceScope
+import org.eclipse.emf.common.util.BasicEList
+import org.eclipse.emf.common.util.EList
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.util.EcoreUtil
@@ -23,6 +27,7 @@ import org.franca.core.franca.FAttribute
import org.franca.core.franca.FBasicTypeId
import org.franca.core.franca.FBroadcast
import org.franca.core.franca.FEnumerationType
+import org.franca.core.franca.FField
import org.franca.core.franca.FInterface
import org.franca.core.franca.FMapType
import org.franca.core.franca.FMethod
@@ -33,20 +38,16 @@ 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.deployment.DeploymentInterfacePropertyAccessor
-import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor$DefaultEnumBackingType
-import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor$EnumBackingType
+import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor.DefaultEnumBackingType
+import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor.EnumBackingType
+import org.genivi.commonapi.core.preferences.FPreferences
import org.genivi.commonapi.core.preferences.PreferenceConstants
+import org.osgi.framework.FrameworkUtil
import static com.google.common.base.Preconditions.*
-import org.franca.core.franca.FTypedElement
-import java.util.Collection
-import org.genivi.commonapi.core.preferences.FPreferences
-import org.osgi.framework.FrameworkUtil
-import org.eclipse.core.resources.IResource
-import org.osgi.framework.Version
-import org.franca.core.franca.FField
class FrancaGeneratorExtensions {
@@ -947,13 +948,13 @@ class FrancaGeneratorExtensions {
}
def boolean hasDerivedFStructTypes(FStructType fStructType) {
- return EcoreUtil$UsageCrossReferencer::find(fStructType, fStructType.model.eResource.resourceSet).exists [
+ return EcoreUtil.UsageCrossReferencer::find(fStructType, fStructType.model.eResource.resourceSet).exists [
EObject instanceof FStructType && (EObject as FStructType).base == fStructType
]
}
def getDerivedFStructTypes(FStructType fStructType) {
- return EcoreUtil$UsageCrossReferencer::find(fStructType, fStructType.model.eResource.resourceSet).map[EObject].
+ return EcoreUtil.UsageCrossReferencer::find(fStructType, fStructType.model.eResource.resourceSet).map[EObject].
filter[it instanceof FStructType].map[it as FStructType].filter[base == fStructType]
}
@@ -1043,40 +1044,73 @@ class FrancaGeneratorExtensions {
}
return builder.toString()
}
-
+
def stubManagedSetName(FInterface fInterface) {
'registered' + fInterface.elementName + 'Instances'
}
-
+
def stubManagedSetGetterName(FInterface fInterface) {
'get' + fInterface.elementName + 'Instances'
}
-
+
def stubRegisterManagedName(FInterface fInterface) {
'registerManagedStub' + fInterface.elementName
}
-
+
def stubRegisterManagedAutoName(FInterface fInterface) {
'registerManagedStub' + fInterface.elementName + 'AutoInstance'
}
-
+
def stubRegisterManagedMethod(FInterface fInterface) {
'bool ' + fInterface.stubRegisterManagedName + '(std::shared_ptr<' + fInterface.stubClassName + '>, const std::string&)'
}
-
+
def stubRegisterManagedMethodImpl(FInterface fInterface) {
fInterface.stubRegisterManagedName + '(std::shared_ptr<' + fInterface.stubClassName + '> stub, const std::string& instance)'
}
-
+
def stubDeregisterManagedName(FInterface fInterface) {
'deregisterManagedStub' + fInterface.elementName
}
-
+
def proxyManagerGetterName(FInterface fInterface) {
'getProxyManager' + fInterface.elementName
}
-
+
def proxyManagerMemberName(FInterface fInterface) {
'proxyManager' + fInterface.elementName + '_'
}
-}
+
+ def EList<FMethod> getInheritedMethods(FInterface fInterface) {
+ if(fInterface.base == null) {
+ return new BasicEList()
+ }
+
+ val methods = fInterface.base.methods
+ methods.addAll(fInterface.base.inheritedMethods)
+
+ return methods
+ }
+
+ def EList<FAttribute> getInheritedAttributes(FInterface fInterface) {
+ if(fInterface.base == null) {
+ return new BasicEList()
+ }
+
+ val attributes = fInterface.base.attributes
+ attributes.addAll(fInterface.base.inheritedAttributes)
+
+ return attributes
+ }
+
+ def EList<FBroadcast> getInheritedBroadcasts(FInterface fInterface) {
+ if(fInterface.base == null) {
+ return new BasicEList()
+ }
+
+ val broadcasts = fInterface.base.broadcasts
+ broadcasts.addAll(fInterface.base.inheritedBroadcasts)
+
+ return broadcasts
+ }
+} \ No newline at end of file