// generated from rosidl_generator_py/resource/_idl_support.c.em
// with input from g29_msg:msg/G29Msg.idl
// generated code does not contain a copyright notice
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <Python.h>
#include <stdbool.h>
#ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-function"
#endif
#include "numpy/ndarrayobject.h"
#ifndef _WIN32
# pragma GCC diagnostic pop
#endif
#include "rosidl_runtime_c/visibility_control.h"
#include "g29_msg/msg/detail/g29_msg__struct.h"
#include "g29_msg/msg/detail/g29_msg__functions.h"


ROSIDL_GENERATOR_C_EXPORT
bool g29_msg__msg__g29_msg__convert_from_py(PyObject * _pymsg, void * _ros_message)
{
  // check that the passed message is of the expected Python class
  {
    char full_classname_dest[28];
    {
      char * class_name = NULL;
      char * module_name = NULL;
      {
        PyObject * class_attr = PyObject_GetAttrString(_pymsg, "__class__");
        if (class_attr) {
          PyObject * name_attr = PyObject_GetAttrString(class_attr, "__name__");
          if (name_attr) {
            class_name = (char *)PyUnicode_1BYTE_DATA(name_attr);
            Py_DECREF(name_attr);
          }
          PyObject * module_attr = PyObject_GetAttrString(class_attr, "__module__");
          if (module_attr) {
            module_name = (char *)PyUnicode_1BYTE_DATA(module_attr);
            Py_DECREF(module_attr);
          }
          Py_DECREF(class_attr);
        }
      }
      if (!class_name || !module_name) {
        return false;
      }
      snprintf(full_classname_dest, sizeof(full_classname_dest), "%s.%s", module_name, class_name);
    }
    assert(strncmp("g29_msg.msg._g29_msg.G29Msg", full_classname_dest, 27) == 0);
  }
  g29_msg__msg__G29Msg * ros_message = _ros_message;
  {  // heartbeat
    PyObject * field = PyObject_GetAttrString(_pymsg, "heartbeat");
    if (!field) {
      return false;
    }
    assert(PyLong_Check(field));
    ros_message->heartbeat = (int32_t)PyLong_AsLong(field);
    Py_DECREF(field);
  }
  {  // axis0
    PyObject * field = PyObject_GetAttrString(_pymsg, "axis0");
    if (!field) {
      return false;
    }
    assert(PyLong_Check(field));
    ros_message->axis0 = (int32_t)PyLong_AsLong(field);
    Py_DECREF(field);
  }
  {  // axis1
    PyObject * field = PyObject_GetAttrString(_pymsg, "axis1");
    if (!field) {
      return false;
    }
    assert(PyLong_Check(field));
    ros_message->axis1 = (int32_t)PyLong_AsLong(field);
    Py_DECREF(field);
  }
  {  // axis2
    PyObject * field = PyObject_GetAttrString(_pymsg, "axis2");
    if (!field) {
      return false;
    }
    assert(PyLong_Check(field));
    ros_message->axis2 = (int32_t)PyLong_AsLong(field);
    Py_DECREF(field);
  }
  {  // axis3
    PyObject * field = PyObject_GetAttrString(_pymsg, "axis3");
    if (!field) {
      return false;
    }
    assert(PyLong_Check(field));
    ros_message->axis3 = (int32_t)PyLong_AsLong(field);
    Py_DECREF(field);
  }
  {  // axis4
    PyObject * field = PyObject_GetAttrString(_pymsg, "axis4");
    if (!field) {
      return false;
    }
    assert(PyLong_Check(field));
    ros_message->axis4 = (int32_t)PyLong_AsLong(field);
    Py_DECREF(field);
  }
  {  // axis5
    PyObject * field = PyObject_GetAttrString(_pymsg, "axis5");
    if (!field) {
      return false;
    }
    assert(PyLong_Check(field));
    ros_message->axis5 = (int32_t)PyLong_AsLong(field);
    Py_DECREF(field);
  }
  {  // button0
    PyObject * field = PyObject_GetAttrString(_pymsg, "button0");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button0 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button1
    PyObject * field = PyObject_GetAttrString(_pymsg, "button1");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button1 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button2
    PyObject * field = PyObject_GetAttrString(_pymsg, "button2");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button2 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button3
    PyObject * field = PyObject_GetAttrString(_pymsg, "button3");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button3 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button4
    PyObject * field = PyObject_GetAttrString(_pymsg, "button4");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button4 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button5
    PyObject * field = PyObject_GetAttrString(_pymsg, "button5");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button5 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button6
    PyObject * field = PyObject_GetAttrString(_pymsg, "button6");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button6 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button7
    PyObject * field = PyObject_GetAttrString(_pymsg, "button7");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button7 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button8
    PyObject * field = PyObject_GetAttrString(_pymsg, "button8");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button8 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button9
    PyObject * field = PyObject_GetAttrString(_pymsg, "button9");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button9 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button10
    PyObject * field = PyObject_GetAttrString(_pymsg, "button10");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button10 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button11
    PyObject * field = PyObject_GetAttrString(_pymsg, "button11");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button11 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button12
    PyObject * field = PyObject_GetAttrString(_pymsg, "button12");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button12 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button13
    PyObject * field = PyObject_GetAttrString(_pymsg, "button13");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button13 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button14
    PyObject * field = PyObject_GetAttrString(_pymsg, "button14");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button14 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button15
    PyObject * field = PyObject_GetAttrString(_pymsg, "button15");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button15 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button16
    PyObject * field = PyObject_GetAttrString(_pymsg, "button16");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button16 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button17
    PyObject * field = PyObject_GetAttrString(_pymsg, "button17");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button17 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button18
    PyObject * field = PyObject_GetAttrString(_pymsg, "button18");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button18 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button19
    PyObject * field = PyObject_GetAttrString(_pymsg, "button19");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button19 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button20
    PyObject * field = PyObject_GetAttrString(_pymsg, "button20");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button20 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button21
    PyObject * field = PyObject_GetAttrString(_pymsg, "button21");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button21 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button22
    PyObject * field = PyObject_GetAttrString(_pymsg, "button22");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button22 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button23
    PyObject * field = PyObject_GetAttrString(_pymsg, "button23");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button23 = (Py_True == field);
    Py_DECREF(field);
  }
  {  // button24
    PyObject * field = PyObject_GetAttrString(_pymsg, "button24");
    if (!field) {
      return false;
    }
    assert(PyBool_Check(field));
    ros_message->button24 = (Py_True == field);
    Py_DECREF(field);
  }

  return true;
}

ROSIDL_GENERATOR_C_EXPORT
PyObject * g29_msg__msg__g29_msg__convert_to_py(void * raw_ros_message)
{
  /* NOTE(esteve): Call constructor of G29Msg */
  PyObject * _pymessage = NULL;
  {
    PyObject * pymessage_module = PyImport_ImportModule("g29_msg.msg._g29_msg");
    assert(pymessage_module);
    PyObject * pymessage_class = PyObject_GetAttrString(pymessage_module, "G29Msg");
    assert(pymessage_class);
    Py_DECREF(pymessage_module);
    _pymessage = PyObject_CallObject(pymessage_class, NULL);
    Py_DECREF(pymessage_class);
    if (!_pymessage) {
      return NULL;
    }
  }
  g29_msg__msg__G29Msg * ros_message = (g29_msg__msg__G29Msg *)raw_ros_message;
  {  // heartbeat
    PyObject * field = NULL;
    field = PyLong_FromLong(ros_message->heartbeat);
    {
      int rc = PyObject_SetAttrString(_pymessage, "heartbeat", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // axis0
    PyObject * field = NULL;
    field = PyLong_FromLong(ros_message->axis0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "axis0", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // axis1
    PyObject * field = NULL;
    field = PyLong_FromLong(ros_message->axis1);
    {
      int rc = PyObject_SetAttrString(_pymessage, "axis1", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // axis2
    PyObject * field = NULL;
    field = PyLong_FromLong(ros_message->axis2);
    {
      int rc = PyObject_SetAttrString(_pymessage, "axis2", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // axis3
    PyObject * field = NULL;
    field = PyLong_FromLong(ros_message->axis3);
    {
      int rc = PyObject_SetAttrString(_pymessage, "axis3", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // axis4
    PyObject * field = NULL;
    field = PyLong_FromLong(ros_message->axis4);
    {
      int rc = PyObject_SetAttrString(_pymessage, "axis4", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // axis5
    PyObject * field = NULL;
    field = PyLong_FromLong(ros_message->axis5);
    {
      int rc = PyObject_SetAttrString(_pymessage, "axis5", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button0
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button0 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button0", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button1
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button1 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button1", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button2
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button2 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button2", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button3
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button3 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button3", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button4
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button4 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button4", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button5
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button5 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button5", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button6
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button6 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button6", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button7
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button7 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button7", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button8
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button8 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button8", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button9
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button9 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button9", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button10
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button10 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button10", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button11
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button11 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button11", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button12
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button12 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button12", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button13
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button13 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button13", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button14
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button14 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button14", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button15
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button15 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button15", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button16
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button16 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button16", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button17
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button17 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button17", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button18
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button18 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button18", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button19
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button19 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button19", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button20
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button20 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button20", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button21
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button21 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button21", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button22
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button22 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button22", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button23
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button23 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button23", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }
  {  // button24
    PyObject * field = NULL;
    field = PyBool_FromLong(ros_message->button24 ? 1 : 0);
    {
      int rc = PyObject_SetAttrString(_pymessage, "button24", field);
      Py_DECREF(field);
      if (rc) {
        return NULL;
      }
    }
  }

  // ownership of _pymessage is transferred to the caller
  return _pymessage;
}
