Author: veithm
Date: Tue Mar 18 14:03:01 2014
New Revision: 1578907
URL: http://svn.apache.org/r1578907
Log:
Enabling support for arrays of custom types
Till now it was not possible to use arrays of custom types as parameters.
This support is now added by adding new functionality to the valuefactory
and the value factory code generation.
Change-Id: Id20ec86a55a821289727c7dc00653797ad509129
Modified:
etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm
etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_h.vm
etch/trunk/binding-cpp/runtime/include/serialization/EtchDefaultValueFactory.h
etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h
etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp
etch/trunk/binding-cpp/runtime/src/main/serialization/EtchTaggedData.cpp
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchAuthenticationExceptionSerializerTest.cpp
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchBinaryTaggedDataInputOutputTest.cpp
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchDateSerializerTest.cpp
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchHashTableSerializerTest.cpp
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchListSerializerTest.cpp
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchRuntimeExceptionSerializerTest.cpp
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchSetSerializerTest.cpp
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchStructValueTest.cpp
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchValidatorStructValueTest.cpp
etch/trunk/binding-cpp/runtime/src/test/transport/EtchMessageTest.cpp
etch/trunk/examples/helloworld/cpp/src/main/include/ImplHelloWorldServer.h
etch/trunk/examples/helloworld/cpp/src/main/src/ImplHelloWorldServer.cpp
Modified:
etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm
(original)
+++
etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm
Tue Mar 18 14:03:01 2014
@@ -426,3 +426,16 @@ status_t $vf::InitValueFactory(EtchRunti
return ETCH_OK;
}
+
+status_t $vf::getNativeArrayForComponentType(const EtchObjectType *objectType,
capu::SmartPointer<EtchNativeArrayBase> &nativeArray, capu::int32_t length,
capu::int32_t dim) {
+#foreach ( $n in $intf.iterator() )
+#if ($n.isStruct())
+#set( $tname = $n.efqname( $helper ) )
+ if (objectType == $i::${tname}::TYPE()) {
+ nativeArray = new EtchNativeArray<capu::SmartPointer<$i::${tname}>
>(length, dim);
+ return ETCH_OK;
+ }
+#end
+#end
+ return ETCH_ERROR;
+}
\ No newline at end of file
Modified:
etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_h.vm
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_h.vm?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_h.vm
(original)
+++
etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_h.vm
Tue Mar 18 14:03:01 2014
@@ -91,6 +91,9 @@ namespace $namespace {
#end
static status_t InitImportExport(EtchRuntime* runtime);
+ status_t getNativeArrayForComponentType(const EtchObjectType *objectType,
capu::SmartPointer<EtchNativeArrayBase> &nativeArray, capu::int32_t length,
capu::int32_t dim);
+
+
/**
* Static Initialization-Helper
*/
Modified:
etch/trunk/binding-cpp/runtime/include/serialization/EtchDefaultValueFactory.h
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/include/serialization/EtchDefaultValueFactory.h?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/runtime/include/serialization/EtchDefaultValueFactory.h
(original)
+++
etch/trunk/binding-cpp/runtime/include/serialization/EtchDefaultValueFactory.h
Tue Mar 18 14:03:01 2014
@@ -182,6 +182,8 @@ public:
status_t getCustomStructType(const EtchObjectType *c, EtchType *& type);
+ virtual status_t getNativeArrayForComponentType(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim);
+
/////////////////////
// STRING ENCODING //
/////////////////////
Modified:
etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
--- etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h
(original)
+++ etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h Tue
Mar 18 14:03:01 2014
@@ -27,6 +27,7 @@
class EtchStructValue;
class EtchMessage;
class EtchType;
+class EtchNativeArrayBase;
/**
* Interface which defines the value factory which helps
@@ -221,6 +222,17 @@ public:
*/
virtual EtchLevel setLevel(EtchLevel level) = 0;
+ /**
+ * @param objectType the component's objectType of the EtchNativeArray
+ * @param nativeArray the created native array for the given component type
+ * @param length the length of the array
+ * @param dim the dimension of the array
+ * @return ETCH_OK if the type is found correctly.
+ * ETCH_EUNIMPL if no type information for arrays has been generated
+ * ETCH_ERROR if the array for the given object type cannot be
generated
+ */
+ virtual status_t getNativeArrayForComponentType(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim) = 0;
+
};
#endif /* ETCHVALUEFACTORY_H */
Modified:
etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp
(original)
+++
etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp
Tue Mar 18 14:03:01 2014
@@ -317,6 +317,10 @@ status_t EtchDefaultValueFactory::getCus
return ETCH_EINVAL;
}
+status_t EtchDefaultValueFactory::getNativeArrayForComponentType(const
EtchObjectType *objectType, capu::SmartPointer<EtchNativeArrayBase>
&nativeArray, capu::int32_t length, capu::int32_t dim) {
+ return ETCH_EUNIMPL;
+}
+
EtchString EtchDefaultValueFactory::getStringEncoding() {
return EtchString("utf-8");
}
Modified:
etch/trunk/binding-cpp/runtime/src/main/serialization/EtchTaggedData.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchTaggedData.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
--- etch/trunk/binding-cpp/runtime/src/main/serialization/EtchTaggedData.cpp
(original)
+++ etch/trunk/binding-cpp/runtime/src/main/serialization/EtchTaggedData.cpp
Tue Mar 18 14:03:01 2014
@@ -96,10 +96,11 @@ status_t EtchTaggedData::allocNativeArra
break;
default:
- //TODO: user definded types are not support yet. The have to be provided
by the value factory
- //EtchNativeArray<capu::SmartPointer<EtchObject> > * res = new
EtchNativeArray<capu::SmartPointer<EtchObject> >(length, dim);
- //res->mType = componentType;
- //result = res;
+ status_t status = mVf->getNativeArrayForComponentType(componentType,
result, length, dim);
+ if (status != ETCH_OK) {
+ return ETCH_ERROR;
+ }
+
break;
}
return ETCH_OK;
Modified:
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchAuthenticationExceptionSerializerTest.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchAuthenticationExceptionSerializerTest.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchAuthenticationExceptionSerializerTest.cpp
(original)
+++
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchAuthenticationExceptionSerializerTest.cpp
Tue Mar 18 14:03:01 2014
@@ -58,6 +58,8 @@ public:
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType *c, EtchType
*& type));
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
+
EtchLevel getLevel() {
return LEVEL_FULL;
}
Modified:
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchBinaryTaggedDataInputOutputTest.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchBinaryTaggedDataInputOutputTest.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchBinaryTaggedDataInputOutputTest.cpp
(original)
+++
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchBinaryTaggedDataInputOutputTest.cpp
Tue Mar 18 14:03:01 2014
@@ -69,6 +69,8 @@ public:
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType* c, EtchType
*& type));
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
+
EtchLevel getLevel() {
return LEVEL_FULL;
}
Modified:
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchDateSerializerTest.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchDateSerializerTest.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchDateSerializerTest.cpp
(original)
+++
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchDateSerializerTest.cpp
Tue Mar 18 14:03:01 2014
@@ -58,6 +58,8 @@ public:
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType *c, EtchType
*& type));
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
+
EtchLevel getLevel() {
return LEVEL_FULL;
}
Modified:
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchHashTableSerializerTest.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchHashTableSerializerTest.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchHashTableSerializerTest.cpp
(original)
+++
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchHashTableSerializerTest.cpp
Tue Mar 18 14:03:01 2014
@@ -58,6 +58,8 @@ public:
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType *c, EtchType
*& type));
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
+
EtchLevel getLevel() {
return LEVEL_FULL;
}
Modified:
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchListSerializerTest.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchListSerializerTest.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchListSerializerTest.cpp
(original)
+++
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchListSerializerTest.cpp
Tue Mar 18 14:03:01 2014
@@ -59,6 +59,8 @@ public:
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType *c, EtchType
*& type));
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
+
EtchLevel getLevel() {
return LEVEL_FULL;
}
Modified:
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchRuntimeExceptionSerializerTest.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchRuntimeExceptionSerializerTest.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchRuntimeExceptionSerializerTest.cpp
(original)
+++
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchRuntimeExceptionSerializerTest.cpp
Tue Mar 18 14:03:01 2014
@@ -60,6 +60,8 @@ public:
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType *c, EtchType
*& type));
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
+
EtchLevel getLevel() {
return LEVEL_FULL;
}
Modified:
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchSetSerializerTest.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchSetSerializerTest.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchSetSerializerTest.cpp
(original)
+++
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchSetSerializerTest.cpp
Tue Mar 18 14:03:01 2014
@@ -57,6 +57,8 @@ public:
MOCK_METHOD0(get_mt__exception, EtchType*());
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType *c, EtchType
*& type));
+
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
EtchLevel getLevel() {
return LEVEL_FULL;
Modified:
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchStructValueTest.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchStructValueTest.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchStructValueTest.cpp
(original)
+++
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchStructValueTest.cpp
Tue Mar 18 14:03:01 2014
@@ -60,6 +60,8 @@ public:
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType *c, EtchType
*& type));
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
+
EtchLevel getLevel() {
return LEVEL_FULL;
}
@@ -104,6 +106,8 @@ public:
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType *c, EtchType
*& type));
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
+
EtchLevel getLevel() {
return LEVEL_MISSING_OK;
}
@@ -148,6 +152,8 @@ public:
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType *c, EtchType
*& type));
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
+
EtchLevel getLevel() {
return LEVEL_NONE;
}
Modified:
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchValidatorStructValueTest.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchValidatorStructValueTest.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
---
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchValidatorStructValueTest.cpp
(original)
+++
etch/trunk/binding-cpp/runtime/src/test/serialization/EtchValidatorStructValueTest.cpp
Tue Mar 18 14:03:01 2014
@@ -66,6 +66,8 @@ public:
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType *c, EtchType
*& type));
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
+
EtchLevel getLevel() {
return LEVEL_FULL;
}
Modified: etch/trunk/binding-cpp/runtime/src/test/transport/EtchMessageTest.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/test/transport/EtchMessageTest.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
--- etch/trunk/binding-cpp/runtime/src/test/transport/EtchMessageTest.cpp
(original)
+++ etch/trunk/binding-cpp/runtime/src/test/transport/EtchMessageTest.cpp Tue
Mar 18 14:03:01 2014
@@ -63,6 +63,8 @@ public:
MOCK_METHOD2(getCustomStructType, status_t(const EtchObjectType *c, EtchType
*& type));
+ MOCK_METHOD4(getNativeArrayForComponentType, status_t(const EtchObjectType
*objectType, capu::SmartPointer<EtchNativeArrayBase> &nativeArray,
capu::int32_t length, capu::int32_t dim));
+
EtchLevel getLevel() {
return LEVEL_FULL;
}
Modified:
etch/trunk/examples/helloworld/cpp/src/main/include/ImplHelloWorldServer.h
URL:
http://svn.apache.org/viewvc/etch/trunk/examples/helloworld/cpp/src/main/include/ImplHelloWorldServer.h?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
--- etch/trunk/examples/helloworld/cpp/src/main/include/ImplHelloWorldServer.h
(original)
+++ etch/trunk/examples/helloworld/cpp/src/main/include/ImplHelloWorldServer.h
Tue Mar 18 14:03:01 2014
@@ -37,7 +37,7 @@ namespace org_apache_etch_examples_hello
// TODO insert methods here to provide declarations of HelloWorldServer
// messages from the mClient.
- say_helloAsyncResultPtr say_hello(HelloWorld::userPtr to_whom);
+ say_helloAsyncResultPtr say_hello(HelloWorld::EtchNativeArrayuserPtr
to_whom);
virtual status_t _sessionNotify(capu::SmartPointer<EtchObject> event ) {
if (event->getObjectType() == EtchString::TYPE()) {
Modified:
etch/trunk/examples/helloworld/cpp/src/main/src/ImplHelloWorldServer.cpp
URL:
http://svn.apache.org/viewvc/etch/trunk/examples/helloworld/cpp/src/main/src/ImplHelloWorldServer.cpp?rev=1578907&r1=1578906&r2=1578907&view=diff
==============================================================================
--- etch/trunk/examples/helloworld/cpp/src/main/src/ImplHelloWorldServer.cpp
(original)
+++ etch/trunk/examples/helloworld/cpp/src/main/src/ImplHelloWorldServer.cpp
Tue Mar 18 14:03:01 2014
@@ -21,7 +21,7 @@ using namespace org_apache_etch_examples
// TODO insert methods here to provide implementations of HelloWorldServer
// messages from the mClient.
- ImplHelloWorldServer::say_helloAsyncResultPtr
ImplHelloWorldServer::say_hello(HelloWorld::userPtr to_whom)
+ ImplHelloWorldServer::say_helloAsyncResultPtr
ImplHelloWorldServer::say_hello(HelloWorld::EtchNativeArrayuserPtr to_whom)
{
say_helloAsyncResultPtr res = new EtchAsyncResult<EtchString>();
res->setResult(new EtchString("Hi From C++ Server!"));