Skip to content

Commit

Permalink
Fix windows warning about integer size
Browse files Browse the repository at this point in the history
Signed-off-by: Emerson Knapp <eknapp@amazon.com>
  • Loading branch information
Emerson Knapp committed May 13, 2019
1 parent f6e96be commit 560911b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 51 deletions.
37 changes: 2 additions & 35 deletions rclpy/src/rclpy/_rclpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,39 +39,6 @@
#include "rclpy_common/common.h"
#include "./_rclpy_qos_event.c"

typedef struct
{
// Important: a pointer to a structure is also a pointer to its first member.
// The subscription must be first in the struct to compare sub.handle.pointer to an address
// in a wait set.
rcl_subscription_t subscription;
rcl_node_t * node;
} rclpy_subscription_t;

typedef struct
{
rcl_publisher_t publisher;
rcl_node_t * node;
} rclpy_publisher_t;

typedef struct
{
// Important: a pointer to a structure is also a pointer to its first member.
// The client must be first in the struct to compare cli.handle.pointer to an address
// in a wait set.
rcl_client_t client;
rcl_node_t * node;
} rclpy_client_t;

typedef struct
{
// Important: a pointer to a structure is also a pointer to its first member.
// The service must be first in the struct to compare srv.handle.pointer to an address
// in a wait set.
rcl_service_t service;
rcl_node_t * node;
} rclpy_service_t;

void
_rclpy_context_capsule_destructor(PyObject * capsule)
{
Expand Down Expand Up @@ -3641,9 +3608,9 @@ rclpy_assert_liveliness(PyObject * Py_UNUSED(self), PyObject * args)
return NULL;
}
} else if (PyCapsule_IsValid(pyentity, "rclpy_publisher_t")) {
rcl_publisher_t * publisher = (rcl_publisher_t *)PyCapsule_GetPointer(
rclpy_publisher_t * publisher = (rclpy_publisher_t *)PyCapsule_GetPointer(
pyentity, "rclpy_publisher_t");
if (RCL_RET_OK != rcl_publisher_assert_liveliness(publisher)) {
if (RCL_RET_OK != rcl_publisher_assert_liveliness(&publisher->publisher)) {
PyErr_Format(PyExc_RuntimeError,
"Failed to assert liveliness on the Publisher: %s", rcl_get_error_string().str);
rcl_reset_error();
Expand Down
22 changes: 6 additions & 16 deletions rclpy/src/rclpy/_rclpy_qos_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,6 @@ _is_pycapsule_rcl_publisher(PyObject * pycapsule)
return PyCapsule_IsValid(pycapsule, "rclpy_publisher_t");
}

static
rcl_subscription_t *
_pycapsule_to_rcl_subscription(PyObject * pycapsule)
{
return (rcl_subscription_t *)PyCapsule_GetPointer(pycapsule, "rclpy_subscription_t");
}

static
rcl_publisher_t *
_pycapsule_to_rcl_publisher(PyObject * pycapsule)
{
return (rcl_publisher_t *)PyCapsule_GetPointer(pycapsule, "rclpy_publisher_t");
}

static
rcl_event_t *
_pycapsule_to_rcl_event(PyObject * pycapsule)
Expand Down Expand Up @@ -264,9 +250,13 @@ rclpy_create_event(PyObject * Py_UNUSED(self), PyObject * args)
}

if (_is_pycapsule_rcl_subscription(pyparent)) {
subscription = _pycapsule_to_rcl_subscription(pyparent);
rclpy_subscription_t * py_subscription =
(rclpy_subscription_t *)PyCapsule_GetPointer(pyparent, "rclpy_subscription_t");
subscription = py_subscription ? &py_subscription->subscription : NULL;
} else if (_is_pycapsule_rcl_publisher(pyparent)) {
publisher = _pycapsule_to_rcl_publisher(pyparent);
rclpy_publisher_t * py_publisher =
(rclpy_publisher_t *)PyCapsule_GetPointer(pyparent, "rclpy_publisher_t");
publisher = py_publisher ? &py_publisher->publisher : NULL;
} else {
PyErr_Format(PyExc_TypeError, "Event parent was not a valid Publisher or Subscription.");
return NULL;
Expand Down
33 changes: 33 additions & 0 deletions rclpy/src/rclpy_common/include/rclpy_common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <Python.h>

#include <rcl/graph.h> // rcl_names_and_types_t
#include <rcl/rcl.h>
#include <rmw/types.h>

#include "rclpy_common/visibility_control.h"
Expand All @@ -26,6 +27,38 @@ typedef void destroy_ros_message_signature (void *);
typedef bool convert_from_py_signature (PyObject *, void *);
typedef PyObject * convert_to_py_signature (void *);

typedef struct
{
// Important: a pointer to a structure is also a pointer to its first member.
// The subscription must be first in the struct to compare sub.handle.pointer to an address
// in a wait set.
rcl_subscription_t subscription;
rcl_node_t * node;
} rclpy_subscription_t;

typedef struct
{
rcl_publisher_t publisher;
rcl_node_t * node;
} rclpy_publisher_t;

typedef struct
{
// Important: a pointer to a structure is also a pointer to its first member.
// The client must be first in the struct to compare cli.handle.pointer to an address
// in a wait set.
rcl_client_t client;
rcl_node_t * node;
} rclpy_client_t;

typedef struct
{
// Important: a pointer to a structure is also a pointer to its first member.
// The service must be first in the struct to compare srv.handle.pointer to an address
// in a wait set.
rcl_service_t service;
rcl_node_t * node;
} rclpy_service_t;

/// Finalize names and types struct with error setting.
/**
Expand Down

0 comments on commit 560911b

Please sign in to comment.