Skip to content

Commit

Permalink
corba: added cmake cache variable PLUGINS_CORBA_NO_CHECK_OPERATIONS t…
Browse files Browse the repository at this point in the history
…o disable operation signature checking

If PLUGINS_CORBA_NO_CHECK_OPERATIONS is set to ON, producing call and send handles for remote operations
will not check the argument types. Instead, calling or sending operations with an incompatible signature
will trigger an exception at runtime.

Signed-off-by: Johannes Meyer <[email protected]>
  • Loading branch information
meyerj committed Dec 15, 2015
1 parent 49b59ba commit 3ef27b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rtt/transports/corba/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ IF(ENABLE_CORBA)
ADD_DEFINITIONS( -DCORBA_SEND_ONEWAY_OPERATIONS )
endif (PLUGINS_CORBA_SEND_ONEWAY_OPERATIONS)

OPTION(PLUGINS_CORBA_NO_CHECK_OPERATIONS "Check operation signature when constructing remote operation callers." OFF)
if (PLUGINS_CORBA_NO_CHECK_OPERATIONS)
MESSAGE("Disabled operation signature checking in CORBA Transport library.")
ADD_DEFINITIONS( -DCORBA_NO_CHECK_OPERATIONS )
endif (PLUGINS_CORBA_NO_CHECK_OPERATIONS)

# Clang 2.9 needs this in order to get around undefined symbols of inlined operator>>= functions !
GET_FILENAME_COMPONENT(CORBA_CXX_NAME "${CMAKE_CXX_COMPILER}" NAME)
if ( ${CORBA_CXX_NAME} STREQUAL "clang++")
Expand Down
9 changes: 9 additions & 0 deletions rtt/transports/corba/CorbaOperationCallerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class CorbaOperationCallerCall: public ActionInterface
};

base::DataSourceBase::shared_ptr CorbaOperationCallerFactory::produce(const std::vector<base::DataSourceBase::shared_ptr>& args, ExecutionEngine* caller) const {
#ifndef CORBA_NO_CHECK_OPERATIONS
corba::CAnyArguments_var nargs = new corba::CAnyArguments();
nargs->length( args.size() );

Expand All @@ -287,10 +288,14 @@ base::DataSourceBase::shared_ptr CorbaOperationCallerFactory::produce(const std:
DataSourceBase::shared_ptr tryout = ti->buildValue();
ctt->updateAny(tryout, nargs[i]);
}
#endif // CORBA_NO_CHECK_OPERATIONS

// check argument types and produce:
try {
#ifndef CORBA_NO_CHECK_OPERATIONS
// will throw if wrong args.
mfact->checkOperation(method.c_str(), nargs.in() );
#endif // CORBA_NO_CHECK_OPERATIONS
// convert returned any to local type:
const types::TypeInfo* ti = this->getArgumentType(0);
if ( ti ) {
Expand Down Expand Up @@ -321,6 +326,7 @@ base::DataSourceBase::shared_ptr CorbaOperationCallerFactory::produce(const std:
}

base::DataSourceBase::shared_ptr CorbaOperationCallerFactory::produceSend(const std::vector<base::DataSourceBase::shared_ptr>& args, ExecutionEngine* caller) const {
#ifndef CORBA_NO_CHECK_OPERATIONS
corba::CAnyArguments_var nargs = new corba::CAnyArguments();
nargs->length( args.size() );
for (size_t i=0; i < args.size(); ++i ) {
Expand All @@ -331,9 +337,12 @@ base::DataSourceBase::shared_ptr CorbaOperationCallerFactory::produceSend(const
DataSourceBase::shared_ptr tryout = ti->buildValue();
ctt->updateAny(tryout, nargs[i]);
}
#endif // CORBA_NO_CHECK_OPERATIONS
try {
#ifndef CORBA_NO_CHECK_OPERATIONS
// will throw if wrong args.
mfact->checkOperation(method.c_str(), nargs.inout() );
#endif // CORBA_NO_CHECK_OPERATIONS
// Will return a CSendHandle_var:
DataSource<CSendHandle_var>::shared_ptr result = new ValueDataSource<CSendHandle_var>();
#ifdef CORBA_SEND_ONEWAY_OPERATIONS
Expand Down

0 comments on commit 3ef27b9

Please sign in to comment.