qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cliffjan...@apache.org
Subject svn commit: r1441947 - in /qpid/proton/trunk: ./ proton-c/ proton-c/bindings/python/ proton-c/examples/messenger/c/ proton-c/include/proton/ proton-c/src/ proton-c/src/codec/ proton-c/src/engine/ proton-c/src/message/ proton-c/src/sasl/
Date Sun, 03 Feb 2013 18:27:52 GMT
Author: cliffjansen
Date: Sun Feb  3 18:27:52 2013
New Revision: 1441947

URL: http://svn.apache.org/viewvc?rev=1441947&view=rev
Log:
PROTON-159: BUILD_WITH_CXX.  See https://reviews.apache.org/r/9124/

Modified:
    qpid/proton/trunk/CMakeLists.txt
    qpid/proton/trunk/proton-c/CMakeLists.txt
    qpid/proton/trunk/proton-c/bindings/python/CMakeLists.txt
    qpid/proton/trunk/proton-c/bindings/python/python.i
    qpid/proton/trunk/proton-c/examples/messenger/c/CMakeLists.txt
    qpid/proton/trunk/proton-c/include/proton/engine.h
    qpid/proton/trunk/proton-c/include/proton/ssl.h
    qpid/proton/trunk/proton-c/src/codec/codec.c
    qpid/proton/trunk/proton-c/src/engine/engine.c
    qpid/proton/trunk/proton-c/src/message/message.c
    qpid/proton/trunk/proton-c/src/messenger.c
    qpid/proton/trunk/proton-c/src/proton.c
    qpid/proton/trunk/proton-c/src/sasl/sasl.c
    qpid/proton/trunk/proton-c/src/scanner.c
    qpid/proton/trunk/proton-c/src/types.c

Modified: qpid/proton/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/CMakeLists.txt?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/CMakeLists.txt (original)
+++ qpid/proton/trunk/CMakeLists.txt Sun Feb  3 18:27:52 2013
@@ -18,7 +18,12 @@
 #
 cmake_minimum_required (VERSION 2.6)
 
-project (Proton C)
+option(BUILD_WITH_CXX "Compile Proton using C++" OFF)
+if (BUILD_WITH_CXX)
+  project (Proton C CXX)
+else (BUILD_WITH_CXX)
+  project (Proton C)
+endif (BUILD_WITH_CXX)
 
 set (PN_VERSION_MAJOR 0)
 set (PN_VERSION_MINOR 3)

Modified: qpid/proton/trunk/proton-c/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/CMakeLists.txt?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/CMakeLists.txt (original)
+++ qpid/proton/trunk/proton-c/CMakeLists.txt Sun Feb  3 18:27:52 2013
@@ -187,9 +187,15 @@ if (CMAKE_COMPILER_IS_GNUCC)
   if (ENABLE_WARNING_ERROR)
     set (WERROR "-Werror")
   endif (ENABLE_WARNING_ERROR)
-  set (COMPILE_WARNING_FLAGS "${WERROR} -Wall -pedantic-errors -Wc++-compat -Wwrite-strings
-Wsign-compare -Wvla")
-  set (COMPILE_LANGUAGE_FLAGS "-std=c99")
-  set (COMPILE_PLATFORM_FLAGS "-std=gnu99")
+  set (COMPILE_WARNING_FLAGS "${WERROR} -Wall -pedantic-errors")
+  if (NOT BUILD_WITH_CXX)
+    set (COMPILE_LANGUAGE_FLAGS "-std=c99")
+    set (COMPILE_PLATFORM_FLAGS "-std=gnu99")
+    set (COMPILE_WARNING_FLAGS "${COMPILE_WARNING_FLAGS} -Wc++-compat -Wvla -Wsign-compare
-Wwrite-strings")
+  else (NOT BUILD_WITH_CXX)
+    # allow "%z" format specifier
+    set (COMPILE_WARNING_FLAGS "${COMPILE_WARNING_FLAGS} -Wno-format")
+  endif (NOT BUILD_WITH_CXX)
   if (ENABLE_UNDEFINED_ERROR)
     set (CATCH_UNDEFINED "-Wl,--no-undefined")
     set (ALLOW_UNDEFINED "-Wl,--allow-shlib-undefined")
@@ -276,6 +282,16 @@ set_target_properties (
     COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_PLATFORM_FLAGS}"
 )
 
+if (BUILD_WITH_CXX)
+  # tell CMake to use C++ for proton source files ending in ".c"
+  set(pn_all_sources ${qpid-proton-core} ${qpid-proton-platform} src/proton.c src/proton-dump.c)
+  foreach (src_file ${pn_all_sources})
+    if (${src_file} MATCHES "^.*[.]c$")
+      set_source_files_properties (${src_file} PROPERTIES LANGUAGE CXX)
+    endif (${src_file} MATCHES "^.*[.]c$")
+  endforeach (src_file)
+endif (BUILD_WITH_CXX)
+
 # Install executables and libraries
 install (TARGETS proton proton-dump qpid-proton
          RUNTIME DESTINATION bin

Modified: qpid/proton/trunk/proton-c/bindings/python/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/python/CMakeLists.txt?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/python/CMakeLists.txt (original)
+++ qpid/proton/trunk/proton-c/bindings/python/CMakeLists.txt Sun Feb  3 18:27:52 2013
@@ -19,6 +19,9 @@
 set(CMAKE_SWIG_FLAGS "-threads")
 
 include_directories (${PYTHON_INCLUDE_PATH})
+if (BUILD_WITH_CXX)
+   SET_SOURCE_FILES_PROPERTIES(python.i PROPERTIES CPLUSPLUS ON)
+endif (BUILD_WITH_CXX)
 swig_add_module(cproton python python.i)
 swig_link_libraries(cproton ${BINDING_DEPS} ${PYTHON_LIBRARIES})
 set_target_properties(_cproton

Modified: qpid/proton/trunk/proton-c/bindings/python/python.i
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/python/python.i?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/python/python.i (original)
+++ qpid/proton/trunk/proton-c/bindings/python/python.i Sun Feb  3 18:27:52 2013
@@ -149,7 +149,7 @@ ssize_t pn_transport_input(pn_transport_
 %inline %{
   void wrap_pn_delivery_tag(pn_delivery_t *delivery, char **ALLOC_OUTPUT, size_t *ALLOC_SIZE)
{
     pn_delivery_tag_t tag = pn_delivery_tag(delivery);
-    *ALLOC_OUTPUT = malloc(tag.size);
+    *ALLOC_OUTPUT = (char *) malloc(tag.size);
     *ALLOC_SIZE = tag.size;
     memcpy(*ALLOC_OUTPUT, tag.bytes, tag.size);
   }
@@ -182,7 +182,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_listener_context) wrap_pn_listener_context;
 %inline {
   PyObject *wrap_pn_listener_context(pn_listener_t *l) {
-    PyObject *result = pn_listener_context(l);
+    PyObject *result = (PyObject *) pn_listener_context(l);
     if (result) {
       Py_INCREF(result);
       return result;
@@ -206,7 +206,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_listener_free) wrap_pn_listener_free;
 %inline %{
   void wrap_pn_listener_free(pn_listener_t *l) {
-    PyObject *obj = pn_listener_context(l);
+    PyObject *obj = (PyObject *) pn_listener_context(l);
     Py_XDECREF(obj);
     pn_listener_free(l);
   }
@@ -225,7 +225,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_connector_context) wrap_pn_connector_context;
 %inline {
   PyObject *wrap_pn_connector_context(pn_connector_t *c) {
-    PyObject *result = pn_connector_context(c);
+    PyObject *result = (PyObject *) pn_connector_context(c);
     if (result) {
       Py_INCREF(result);
       return result;
@@ -249,7 +249,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_connector_free) wrap_pn_connector_free;
 %inline %{
   void wrap_pn_connector_free(pn_connector_t *c) {
-    PyObject *obj = pn_connector_context(c);
+    PyObject *obj = (PyObject *) pn_connector_context(c);
     Py_XDECREF(obj);
     pn_connector_free(c);
   }
@@ -259,7 +259,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_connection_get_context) wrap_pn_connection_get_context;
 %inline {
   PyObject *wrap_pn_connection_get_context(pn_connection_t *c) {
-    PyObject *result = pn_connection_get_context(c);
+    PyObject *result = (PyObject *) pn_connection_get_context(c);
     if (result) {
       Py_INCREF(result);
       return result;
@@ -283,7 +283,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_connection_free) wrap_pn_connection_free;
 %inline %{
   void wrap_pn_connection_free(pn_connection_t *c) {
-    PyObject *obj = pn_connection_get_context(c);
+    PyObject *obj = (PyObject *) pn_connection_get_context(c);
     Py_XDECREF(obj);
     pn_connection_free(c);
   }
@@ -293,7 +293,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_session_get_context) wrap_pn_session_get_context;
 %inline {
   PyObject *wrap_pn_session_get_context(pn_session_t *s) {
-    PyObject *result = pn_session_get_context(s);
+    PyObject *result = (PyObject *) pn_session_get_context(s);
     if (result) {
       Py_INCREF(result);
       return result;
@@ -317,7 +317,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_session_free) wrap_pn_session_free;
 %inline %{
   void wrap_pn_session_free(pn_session_t *s) {
-    PyObject *obj = pn_session_get_context(s);
+    PyObject *obj = (PyObject *) pn_session_get_context(s);
     Py_XDECREF(obj);
     pn_session_free(s);
   }
@@ -327,7 +327,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_link_get_context) wrap_pn_link_get_context;
 %inline {
   PyObject *wrap_pn_link_get_context(pn_link_t *l) {
-    PyObject *result = pn_link_get_context(l);
+    PyObject *result = (PyObject *) pn_link_get_context(l);
     if (result) {
       Py_INCREF(result);
       return result;
@@ -351,7 +351,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_link_free) wrap_pn_link_free;
 %inline %{
   void wrap_pn_link_free(pn_link_t *l) {
-    PyObject *obj = pn_link_get_context(l);
+    PyObject *obj = (PyObject *) pn_link_get_context(l);
     Py_XDECREF(obj);
     pn_link_free(l);
   }
@@ -361,7 +361,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_delivery_get_context) wrap_pn_delivery_get_context;
 %inline {
   PyObject *wrap_pn_delivery_get_context(pn_delivery_t *d) {
-    PyObject *result = pn_delivery_get_context(d);
+    PyObject *result = (PyObject *) pn_delivery_get_context(d);
     if (result) {
       Py_INCREF(result);
       return result;
@@ -385,7 +385,7 @@ ssize_t pn_transport_input(pn_transport_
 %rename(pn_delivery_settle) wrap_pn_delivery_settle;
 %inline %{
   void wrap_pn_delivery_settle(pn_delivery_t *d) {
-    PyObject *obj = pn_delivery_get_context(d);
+    PyObject *obj = (PyObject *) pn_delivery_get_context(d);
     Py_XDECREF(obj);
     pn_delivery_settle(d);
   }

Modified: qpid/proton/trunk/proton-c/examples/messenger/c/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/examples/messenger/c/CMakeLists.txt?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/examples/messenger/c/CMakeLists.txt (original)
+++ qpid/proton/trunk/proton-c/examples/messenger/c/CMakeLists.txt Sun Feb  3 18:27:52 2013
@@ -28,3 +28,7 @@ set_target_properties (
   PROPERTIES
   COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_LANGUAGE_FLAGS}"
 )
+
+if (BUILD_WITH_CXX)
+  set_source_files_properties (recv.c send.c PROPERTIES LANGUAGE CXX)
+endif (BUILD_WITH_CXX)

Modified: qpid/proton/trunk/proton-c/include/proton/engine.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/engine.h?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/include/proton/engine.h (original)
+++ qpid/proton/trunk/proton-c/include/proton/engine.h Sun Feb  3 18:27:52 2013
@@ -69,7 +69,10 @@ typedef struct pn_delivery_tag_t {
   const char *bytes;
 } pn_delivery_tag_t;
 
-#define pn_dtag(BYTES, SIZE) ((pn_delivery_tag_t) {(SIZE), (BYTES)})
+static inline pn_delivery_tag_t pn_dtag(const char *bytes, size_t size) {
+  pn_delivery_tag_t dtag = {size, bytes};
+  return dtag;
+}
 
 typedef int pn_state_t;     /**< encodes the state of an endpoint */
 

Modified: qpid/proton/trunk/proton-c/include/proton/ssl.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/ssl.h?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/include/proton/ssl.h (original)
+++ qpid/proton/trunk/proton-c/include/proton/ssl.h Sun Feb  3 18:27:52 2013
@@ -167,7 +167,7 @@ typedef enum {
   PN_SSL_VERIFY_NULL=0,   /**< internal use only */
   PN_SSL_VERIFY_PEER,     /**< require peer to provide a valid identifying certificate
*/
   PN_SSL_ANONYMOUS_PEER,  /**< do not require a certificate nor cipher authorization */
-  PN_SSL_VERIFY_PEER_NAME,/**< require valid certificate and matching name */
+  PN_SSL_VERIFY_PEER_NAME /**< require valid certificate and matching name */
 } pn_ssl_verify_mode_t;
 
 /** Configure the level of verification used on the peer certificate.

Modified: qpid/proton/trunk/proton-c/src/codec/codec.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/codec/codec.c?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/codec/codec.c (original)
+++ qpid/proton/trunk/proton-c/src/codec/codec.c Sun Feb  3 18:27:52 2013
@@ -27,9 +27,9 @@
 #include <string.h>
 #include <stdarg.h>
 #include <stdlib.h>
-#include <inttypes.h>
 #include <ctype.h>
 #include "encodings.h"
+#include "../platform_fmt.h"
 #include "../util.h"
 
 #define PN_DESCRIPTOR (PN_DESCRIBED)
@@ -139,6 +139,12 @@ int pn_bytes_format(pn_bytes_t *bytes, c
   }
 }
 
+static inline void pn_atom_init(pn_iatom_t *atom, pn_type_t type)
+{
+  memset(atom, 0, sizeof(pn_iatom_t));
+  atom->type = type;
+}
+
 int pn_print_atom(pn_iatom_t atom)
 {
   char buf[256];
@@ -322,6 +328,7 @@ int pn_format_atoms_one(pn_bytes_t *byte
   pn_iatom_t *atom = atoms->start;
   pn_atoms_ltrim(atoms, 1);
   int err, count;
+  bool list;
 
   switch (atom->type) {
   case PN_DESCRIPTOR:
@@ -347,7 +354,7 @@ int pn_format_atoms_one(pn_bytes_t *byte
   case PN_LIST:
   case PN_MAP:
     count = atom->u.count;
-    bool list = atom->type == PN_LIST;
+    list = atom->type == PN_LIST;
     if ((err = pn_bytes_format(bytes, "%s",  list ? "[" : "{"))) return err;
     for (int i = 0; i < count; i++)
     {
@@ -568,7 +575,7 @@ int pn_decode_type(pn_bytes_t *bytes, pn
     pn_bytes_ltrim(bytes, 1);
     return 0;
   } else {
-    atoms->start[0] = (pn_iatom_t) {.type=PN_DESCRIPTOR};
+    pn_atom_init(&atoms->start[0], PN_DESCRIPTOR);
     pn_bytes_ltrim(bytes, 1);
     pn_atoms_ltrim(atoms, 1);
     int e = pn_decode_atom(bytes, atoms);
@@ -834,7 +841,7 @@ int pn_decode_value(pn_bytes_t *bytes, p
 
     {
       char *start = (char *) (bytes->start);
-      pn_bytes_t binary = {.size=size, .start=start};
+      pn_bytes_t binary = {size, start};
       switch (code & 0x0F)
       {
       case 0x0:
@@ -888,7 +895,8 @@ int pn_decode_value(pn_bytes_t *bytes, p
     case PNE_ARRAY32:
       {
         if (!atoms->size) return PN_OVERFLOW;
-        atoms->start[0] = (pn_iatom_t) {.type=PN_ARRAY, .u.count=count};
+        pn_atom_init(&atoms->start[0], PN_ARRAY);
+        atoms->start[0].u.count=count;
         pn_atoms_ltrim(atoms, 1);
         uint8_t acode;
         int e = pn_decode_type(bytes, atoms, &acode);
@@ -896,7 +904,8 @@ int pn_decode_value(pn_bytes_t *bytes, p
         if (!atoms->size) return PN_OVERFLOW;
         pn_type_t type = pn_code2type(acode);
         if (type < 0) return type;
-        atoms->start[0] = (pn_iatom_t) {.type=PN_TYPE, .u.type=type};
+        pn_atom_init(&atoms->start[0], (pn_type_t) PN_TYPE);
+        atoms->start[0].u.type=type;
         pn_atoms_ltrim(atoms, 1);
         for (unsigned i = 0; i < count; i++)
         {
@@ -908,13 +917,15 @@ int pn_decode_value(pn_bytes_t *bytes, p
     case PNE_LIST8:
     case PNE_LIST32:
       if (!atoms->size) return PN_OVERFLOW;
-      atoms->start[0] = (pn_iatom_t) {.type=PN_LIST, .u.count=count};
+      pn_atom_init(&atoms->start[0], PN_LIST);
+      atoms->start[0].u.count=count;
       pn_atoms_ltrim(atoms, 1);
       break;
     case PNE_MAP8:
     case PNE_MAP32:
       if (!atoms->size) return PN_OVERFLOW;
-      atoms->start[0] = (pn_iatom_t) {.type=PN_MAP, .u.count=count};
+      pn_atom_init(&atoms->start[0], PN_MAP);
+      atoms->start[0].u.count=count;
       pn_atoms_ltrim(atoms, 1);
       break;
     default:
@@ -1190,7 +1201,7 @@ int pn_data_vfill(pn_data_t *data, const
       {
         pn_node_t *parent = pn_data_node(data, data->parent);
         if (parent->atom.type == PN_ARRAY) {
-          parent->type = va_arg(ap, int);
+          parent->type = (pn_type_t) va_arg(ap, int);
         } else {
           return pn_error_format(data->error, PN_ERR, "naked type");
         }
@@ -1205,7 +1216,7 @@ int pn_data_vfill(pn_data_t *data, const
         } else {
           described = false;
         }
-        err = pn_data_put_array(data, described, 0);
+        err = pn_data_put_array(data, described, (pn_type_t) 0);
         pn_data_enter(data);
       }
       break;
@@ -1322,7 +1333,7 @@ static bool pn_scan_next(pn_data_t *data
       pn_data_exit(data);
       return pn_scan_next(data, type, suspend);
     } else {
-      *type = -1;
+      *type = (pn_type_t) -1;
       return false;
     }
   }
@@ -1548,7 +1559,8 @@ int pn_data_vscan(pn_data_t *data, const
           *bytes = pn_data_get_binary(data);
           scanned = true;
         } else {
-          *bytes = (pn_bytes_t) {0, 0};
+          bytes->start = 0;
+          bytes->size = 0;
           scanned = false;
         }
       }
@@ -1562,7 +1574,8 @@ int pn_data_vscan(pn_data_t *data, const
           *bytes = pn_data_get_string(data);
           scanned = true;
         } else {
-          *bytes = (pn_bytes_t) {0, 0};
+          bytes->start = 0;
+          bytes->size = 0;
           scanned = false;
         }
       }
@@ -1576,7 +1589,8 @@ int pn_data_vscan(pn_data_t *data, const
           *bytes = pn_data_get_symbol(data);
           scanned = true;
         } else {
-          *bytes = (pn_bytes_t) {0, 0};
+          bytes->start = 0;
+          bytes->size = 0;
           scanned = false;
         }
       }
@@ -2000,16 +2014,18 @@ int pn_data_as_atoms(pn_data_t *data, pn
 
     if (node->atom.type == PN_ARRAY) {
       if (node->described) {
-        atoms->start[natoms++] = (pn_iatom_t) {.type=PN_DESCRIPTOR};
+        pn_atom_init(&atoms->start[natoms++], PN_DESCRIPTOR);
       } else {
-        atoms->start[natoms++] = (pn_iatom_t) {.type=PN_TYPE, .u.type=node->type};
+        pn_atom_init(&atoms->start[natoms], (pn_type_t) PN_TYPE);
+        atoms->start[natoms++].u.type = node->type;
       }
     }
 
     pn_node_t *parent = pn_data_node(data, node->parent);
     if (parent && parent->atom.type == PN_ARRAY && parent->described
&&
         parent->down == pn_data_id(data, node)) {
-      atoms->start[natoms++] = (pn_iatom_t) {.type=PN_TYPE, .u.type=parent->type};
+      pn_atom_init(&atoms->start[natoms], (pn_type_t) PN_TYPE);
+      atoms->start[natoms++].u.type = parent->type;
     }
 
     size_t next = 0;
@@ -2346,7 +2362,7 @@ int pn_data_parse_atoms(pn_data_t *data,
     case PN_ARRAY:
       {
         bool described = (atoms.start[i+1].type == PN_DESCRIPTOR);
-        pn_data_put_array(data, described, 0);
+        pn_data_put_array(data, described, (pn_type_t) 0);
         pn_node_t *array = pn_data_current(data);
         pn_data_enter(data);
         if (described) {
@@ -2458,7 +2474,7 @@ int pn_data_put_described(pn_data_t *dat
 int pn_data_put_null(pn_data_t *data)
 {
   pn_node_t *node = pn_data_add(data);
-  node->atom = (pn_iatom_t) {.type=PN_NULL};
+  pn_atom_init(&node->atom, PN_NULL);
   return 0;
 }
 
@@ -2851,7 +2867,8 @@ pn_decimal128_t pn_data_get_decimal128(p
   if (node && node->atom.type == PN_DECIMAL128) {
     return node->atom.u.as_decimal128;
   } else {
-    return (pn_decimal128_t) {{0}};
+    pn_decimal128_t t = {{0}};
+    return t;
   }
 }
 
@@ -2861,7 +2878,8 @@ pn_uuid_t pn_data_get_uuid(pn_data_t *da
   if (node && node->atom.type == PN_UUID) {
     return node->atom.u.as_uuid;
   } else {
-    return (pn_uuid_t) {{0}};
+    pn_uuid_t t = {{0}};
+    return t;
   }
 }
 
@@ -2871,7 +2889,8 @@ pn_bytes_t pn_data_get_binary(pn_data_t 
   if (node && node->atom.type == PN_BINARY) {
     return node->atom.u.as_binary;
   } else {
-    return (pn_bytes_t) {0};
+    pn_bytes_t t = {0};
+    return t;
   }
 }
 
@@ -2881,7 +2900,8 @@ pn_bytes_t pn_data_get_string(pn_data_t 
   if (node && node->atom.type == PN_STRING) {
     return node->atom.u.as_string;
   } else {
-    return (pn_bytes_t) {0};
+    pn_bytes_t t = {0};
+    return t;
   }
 }
 
@@ -2891,7 +2911,8 @@ pn_bytes_t pn_data_get_symbol(pn_data_t 
   if (node && node->atom.type == PN_SYMBOL) {
     return node->atom.u.as_symbol;
   } else {
-    return (pn_bytes_t) {0};
+    pn_bytes_t t = {0};
+    return t;
   }
 }
 
@@ -2903,7 +2924,8 @@ pn_bytes_t pn_data_get_bytes(pn_data_t *
                node->atom.type == PN_SYMBOL)) {
     return node->atom.u.as_binary;
   } else {
-    return (pn_bytes_t) {0};
+    pn_bytes_t t = {0};
+    return t;
   }
 }
 
@@ -2913,7 +2935,8 @@ pn_atom_t pn_data_get_atom(pn_data_t *da
   if (node) {
     return *((pn_atom_t *) &node->atom);
   } else {
-    return (pn_atom_t) {.type=PN_NULL};
+    pn_atom_t t = {PN_NULL};
+    return t;
   }
 }
 

Modified: qpid/proton/trunk/proton-c/src/engine/engine.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/engine/engine.c (original)
+++ qpid/proton/trunk/proton-c/src/engine/engine.c Sun Feb  3 18:27:52 2013
@@ -24,7 +24,6 @@
 #include <string.h>
 #include <proton/framing.h>
 #include "protocol.h"
-#include <inttypes.h>
 
 #include <assert.h>
 #include <stdarg.h>
@@ -32,6 +31,7 @@
 
 #include "../sasl/sasl-internal.h"
 #include "../ssl/ssl-internal.h"
+#include "../platform_fmt.h"
 
 // delivery buffers
 
@@ -397,7 +397,7 @@ void pn_link_set_context(pn_link_t *link
 
 void pn_endpoint_init(pn_endpoint_t *endpoint, int type, pn_connection_t *conn)
 {
-  endpoint->type = type;
+  endpoint->type = (pn_endpoint_type_t) type;
   endpoint->state = PN_LOCAL_UNINIT | PN_REMOTE_UNINIT;
   endpoint->error = pn_error();
   pn_condition_init(&endpoint->condition);
@@ -803,9 +803,8 @@ pn_session_state_t *pn_session_get_state
   PN_ENSURE(transport->sessions, transport->session_capacity, ssn->id + 1, pn_session_state_t);
   for (unsigned i = old_capacity; i < transport->session_capacity; i++)
   {
-    transport->sessions[i] = (pn_session_state_t) {.session=NULL,
-                                                   .local_channel=-1,
-                                                   .remote_channel=-1};
+    pn_session_state_t t = {NULL, -1, -1};
+    transport->sessions[i] = t;
     pn_delivery_buffer_init(&transport->sessions[i].incoming, 0, PN_SESSION_WINDOW);
     pn_delivery_buffer_init(&transport->sessions[i].outgoing, 0, PN_SESSION_WINDOW);
   }
@@ -1078,14 +1077,22 @@ int pn_terminus_copy(pn_terminus_t *term
   return 0;
 }
 
+void pn_link_state_init(pn_link_state_t *ls)
+{
+  ls->link = NULL;
+  ls->local_handle = -1;
+  ls->remote_handle = -1;
+  ls->delivery_count = 0;
+  ls->link_credit = 0;
+}
+
 pn_link_state_t *pn_link_get_state(pn_session_state_t *ssn_state, pn_link_t *link)
 {
   int old_capacity = ssn_state->link_capacity;
   PN_ENSURE(ssn_state->links, ssn_state->link_capacity, link->id + 1, pn_link_state_t);
   for (unsigned i = old_capacity; i < ssn_state->link_capacity; i++)
   {
-    ssn_state->links[i] = (pn_link_state_t) {.link=NULL, .local_handle = -1,
-                                             .remote_handle=-1};
+    pn_link_state_init(&ssn_state->links[i]);
   }
   pn_link_state_t *state = &ssn_state->links[link->id];
   state->link = link;
@@ -1254,7 +1261,7 @@ pn_delivery_tag_t pn_delivery_tag(pn_del
     pn_bytes_t tag = pn_buffer_bytes(delivery->tag);
     return pn_dtag(tag.start, tag.size);
   } else {
-    return (pn_delivery_tag_t) {0};
+    return pn_dtag(0, 0);
   }
 }
 
@@ -1710,7 +1717,7 @@ int pn_do_disposition(pn_dispatcher_t *d
   if (!last_init) last = first;
 
   pn_session_state_t *ssn_state = pn_channel_state(transport, disp->channel);
-  pn_disposition_t dispo = 0;
+  pn_disposition_t dispo = (pn_disposition_t) 0;
   if (code_init) {
     switch (code)
     {

Modified: qpid/proton/trunk/proton-c/src/message/message.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/message/message.c?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/message/message.c (original)
+++ qpid/proton/trunk/proton-c/src/message/message.c Sun Feb  3 18:27:52 2013
@@ -265,7 +265,9 @@ pn_data_t *pn_message_id(pn_message_t *m
 }
 pn_atom_t pn_message_get_id(pn_message_t *msg)
 {
-  return msg ? pn_data_get_atom(msg->id) : (pn_atom_t) {.type=PN_NULL};
+  if (msg) return pn_data_get_atom(msg->id);
+  pn_atom_t atom = {PN_NULL};
+  return atom;
 }
 int pn_message_set_id(pn_message_t *msg, pn_atom_t id)
 {
@@ -366,7 +368,9 @@ pn_data_t *pn_message_correlation_id(pn_
 }
 pn_atom_t pn_message_get_correlation_id(pn_message_t *msg)
 {
-  return msg ? pn_data_get_atom(msg->correlation_id) : (pn_atom_t) {.type=PN_NULL};
+  if (msg) return pn_data_get_atom(msg->correlation_id);
+  pn_atom_t atom = {PN_NULL};
+  return atom;
 }
 int pn_message_set_correlation_id(pn_message_t *msg, pn_atom_t atom)
 {

Modified: qpid/proton/trunk/proton-c/src/messenger.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/messenger.c?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/messenger.c (original)
+++ qpid/proton/trunk/proton-c/src/messenger.c Sun Feb  3 18:27:52 2013
@@ -1021,7 +1021,7 @@ static pn_status_t disp2status(pn_dispos
     assert(0);
   }
 
-  return 0;
+  return (pn_status_t) 0;
 }
 
 pn_status_t pn_messenger_status(pn_messenger_t *messenger, pn_tracker_t tracker)
@@ -1043,7 +1043,7 @@ pn_status_t pn_messenger_status(pn_messe
 int pn_messenger_settle(pn_messenger_t *messenger, pn_tracker_t tracker, int flags)
 {
   pn_queue_t *queue = pn_tracker_queue(messenger, tracker);
-  return pn_queue_update(queue, pn_tracker_sequence(tracker), 0, flags, true, true);
+  return pn_queue_update(queue, pn_tracker_sequence(tracker), (pn_status_t) 0, flags, true,
true);
 }
 
 bool pn_messenger_sent(pn_messenger_t *messenger)
@@ -1184,7 +1184,7 @@ int pn_messenger_accept(pn_messenger_t *
   }
 
   return pn_queue_update(&messenger->incoming, pn_tracker_sequence(tracker),
-                         PN_ACCEPTED, flags, false, false);
+                         (pn_status_t) PN_ACCEPTED, flags, false, false);
 }
 
 int pn_messenger_reject(pn_messenger_t *messenger, pn_tracker_t tracker, int flags)
@@ -1195,7 +1195,7 @@ int pn_messenger_reject(pn_messenger_t *
   }
 
   return pn_queue_update(&messenger->incoming, pn_tracker_sequence(tracker),
-                         PN_REJECTED, flags, false, false);
+                         (pn_status_t) PN_REJECTED, flags, false, false);
 }
 
 int pn_messenger_queued(pn_messenger_t *messenger, bool sender)

Modified: qpid/proton/trunk/proton-c/src/proton.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/proton.c?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/proton.c (original)
+++ qpid/proton/trunk/proton-c/src/proton.c Sun Feb  3 18:27:52 2013
@@ -36,7 +36,7 @@
 #include <proton/codec.h>
 #include <proton/buffer.h>
 #include <proton/parser.h>
-#include <inttypes.h>
+#include "platform_fmt.h"
 #include "protocol.h"
 
 typedef struct {

Modified: qpid/proton/trunk/proton-c/src/sasl/sasl.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/sasl/sasl.c?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/sasl/sasl.c (original)
+++ qpid/proton/trunk/proton-c/src/sasl/sasl.c Sun Feb  3 18:27:52 2013
@@ -400,7 +400,7 @@ int pn_do_outcome(pn_dispatcher_t *disp)
   uint8_t outcome;
   int err = pn_scan_args(disp, "D.[B]", &outcome);
   if (err) return err;
-  sasl->outcome = outcome;
+  sasl->outcome = (pn_sasl_outcome_t) outcome;
   sasl->rcvd_done = true;
   sasl->sent_done = true;
   disp->halt = true;

Modified: qpid/proton/trunk/proton-c/src/scanner.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/scanner.c?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/scanner.c (original)
+++ qpid/proton/trunk/proton-c/src/scanner.c Sun Feb  3 18:27:52 2013
@@ -92,7 +92,8 @@ pn_token_t pn_scanner_token(pn_scanner_t
   if (scanner) {
     return scanner->token;
   } else {
-    return (pn_token_t) {PN_TOK_ERR};
+    pn_token_t tok = {PN_TOK_ERR};
+    return tok;
   }
 }
 

Modified: qpid/proton/trunk/proton-c/src/types.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/types.c?rev=1441947&r1=1441946&r2=1441947&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/types.c (original)
+++ qpid/proton/trunk/proton-c/src/types.c Sun Feb  3 18:27:52 2013
@@ -25,7 +25,8 @@
 
 pn_bytes_t pn_bytes(size_t size, char *start)
 {
-  return (pn_bytes_t) {size, start};
+  pn_bytes_t bytes = {size, start};
+  return bytes;
 }
 
 pn_bytes_t pn_bytes_dup(size_t size, const char *start)



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message