Skip to content

Commit

Permalink
Rename rcljava_common cpp headers to have .hpp suffix (#93)
Browse files Browse the repository at this point in the history
* Fix service and action interface generation

Before, we were not generating code for the messages and services that make up service and action
interfaces.

Due to issues with duplicate definitions caused by instantiating the msg.cpp.em template
multiple times, I've opted to generate separate files for each service, action, and the interfaces
that they are made of. This is similar to what we are doing with the generated Java code.

I've added a test confirming that generated service code can be used. Adding a test for actions is
difficult at the moment due to a circular dependency with action_msgs.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add missing header include

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Rename top level generated cpp file

This avoids name clashing with other generated files. Similar to what we do with generated Java files.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix JNI name mangling function so it works for service and action subtypes

For example, 'example_interfaces/srv/AddTwoInts_Request' should be mangled to 'example_1interfaces_srv_AddTwoInts_1Request'.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Remove vestigal references to jni_package_name

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add comment about action and service headers

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Simplify include logic

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Rename cpp headers to have .hpp suffix

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update files to reflect new header suffix

This resolves a cppcheck linter error complaining about "is invalid C code".
Changing the suffix causes cppcheck to treat the files as C++ code.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

Co-authored-by: Esteve Fernandez <esteve@apache.org>
  • Loading branch information
jacobperron and esteve committed May 17, 2021
1 parent 5305522 commit a86bd0f
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions rcljava/src/main/cpp/org_ros2_rcljava_RCLJava.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/signatures.h"
#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"

#include "org_ros2_rcljava_RCLJava.h"

Expand Down
2 changes: 1 addition & 1 deletion rcljava/src/main/cpp/org_ros2_rcljava_Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "rcl/error_handling.h"
#include "rcl/rcl.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/exceptions.hpp"

#include "org_ros2_rcljava_Time.h"

Expand Down
4 changes: 2 additions & 2 deletions rcljava/src/main/cpp/org_ros2_rcljava_client_ClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/signatures.h"
#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"

#include "org_ros2_rcljava_client_ClientImpl.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "rcl/error_handling.h"
#include "rcl/init.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/signatures.h"
#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"

#include "org_ros2_rcljava_contexts_ContextImpl.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/signatures.h"
#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"

#include "org_ros2_rcljava_executors_BaseExecutor.h"

Expand Down
4 changes: 2 additions & 2 deletions rcljava/src/main/cpp/org_ros2_rcljava_node_NodeImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/signatures.h"
#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"

#include "org_ros2_rcljava_node_NodeImpl.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "rcl/rcl.h"
#include "rmw/rmw.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/signatures.h"
#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"

#include "org_ros2_rcljava_publisher_PublisherImpl.h"

Expand Down
4 changes: 2 additions & 2 deletions rcljava/src/main/cpp/org_ros2_rcljava_service_ServiceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/signatures.h"
#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"

#include "org_ros2_rcljava_service_ServiceImpl.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/signatures.h"
#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"

#include "org_ros2_rcljava_subscription_SubscriptionImpl.h"

Expand Down
4 changes: 2 additions & 2 deletions rcljava/src/main/cpp/org_ros2_rcljava_time_Clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "rcl/error_handling.h"
#include "rcl/time.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/signatures.h"
#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"

#include "org_ros2_rcljava_time_Clock.h"

Expand Down
4 changes: 2 additions & 2 deletions rcljava/src/main/cpp/org_ros2_rcljava_timer_WallTimerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "rcl/rcl.h"
#include "rmw/rmw.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/signatures.h"
#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"

#include "org_ros2_rcljava_timer_WallTimerImpl.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef RCLJAVA_COMMON__EXCEPTIONS_H_
#define RCLJAVA_COMMON__EXCEPTIONS_H_
#ifndef RCLJAVA_COMMON__EXCEPTIONS_HPP_
#define RCLJAVA_COMMON__EXCEPTIONS_HPP_
#include <jni.h>

#include <string>

#include "rcljava_common/visibility_control.h"
#include "rcljava_common/visibility_control.hpp"

namespace rcljava_common
{
Expand All @@ -31,4 +31,4 @@ void rcljava_throw_exception(JNIEnv *, const char *, const std::string &);
} // namespace exceptions
} // namespace rcljava_common

#endif // RCLJAVA_COMMON__EXCEPTIONS_H_
#endif // RCLJAVA_COMMON__EXCEPTIONS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef RCLJAVA_COMMON__SIGNATURES_H_
#define RCLJAVA_COMMON__SIGNATURES_H_
#ifndef RCLJAVA_COMMON__SIGNATURES_HPP_
#define RCLJAVA_COMMON__SIGNATURES_HPP_
#include <jni.h>

#include <string>
Expand All @@ -29,4 +29,4 @@ using destroy_ros_message_signature = void (*)(void *);
} // namespace signatures
} // namespace rcljava_common

#endif // RCLJAVA_COMMON__SIGNATURES_H_
#endif // RCLJAVA_COMMON__SIGNATURES_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RCLJAVA_COMMON__VISIBILITY_CONTROL_H_
#define RCLJAVA_COMMON__VISIBILITY_CONTROL_H_
#ifndef RCLJAVA_COMMON__VISIBILITY_CONTROL_HPP_
#define RCLJAVA_COMMON__VISIBILITY_CONTROL_HPP_

#ifdef __cplusplus
extern "C"
Expand Down Expand Up @@ -55,4 +55,4 @@ extern "C"
}
#endif

#endif // RCLJAVA_COMMON__VISIBILITY_CONTROL_H_
#endif // RCLJAVA_COMMON__VISIBILITY_CONTROL_HPP_
2 changes: 1 addition & 1 deletion rcljava_common/src/main/cpp/rcljava_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <cassert>
#include <string>

#include "rcljava_common/exceptions.h"
#include "rcljava_common/exceptions.hpp"

namespace rcljava_common
{
Expand Down
4 changes: 2 additions & 2 deletions rosidl_generator_java/resource/msg.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ elif message_c_include_prefix.endswith('__feedback'):

#include "rosidl_generator_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.h"
#include "rcljava_common/signatures.h"
#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"

@[for include in member_includes]@
#include "@(include)"
Expand Down

0 comments on commit a86bd0f

Please sign in to comment.