You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2022/06/08 20:36:41 UTC

[qpid-proton] branch main updated (5aaa655cb -> d1bcaa3a9)

This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


    from 5aaa655cb PROTON-2544: temporary warning-as-error disable for DH_xxx calls in openssl related code
     new 0ad20092e PROTON-2556: Removed gratuitous use of pn_string from reactor-send
     new d9ccd2923 PROTON-2557: Introduce pn_tostring in place of pn_inspect
     new 839cdee1c PROTON-2557: Go change for introduction of pn_tostring
     new eea52fd02 PROTON-2557: Ruby change for introduction of pn_tostring
     new b18da5915 PROTON-2558: Add make class operation to hide class details
     new 447f518bf PROTON-2556: Remove unnecessary active connection list from reactor-recv
     new 4641f1c34 PROTON-2559: Rearrange using object.h
     new d1bcaa3a9 NO-JIRA: Use C99 syntax for default logger initialization

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 c/benchmarks/connection-driver.cpp     | 18 ++++++++---------
 c/benchmarks/message-encoding_list.cpp | 24 +++++++++++------------
 c/benchmarks/message-encoding_map.cpp  | 31 ++++++++++++++---------------
 c/examples/broker.c                    |  1 +
 c/examples/direct.c                    |  8 ++++----
 c/examples/receive.c                   |  8 ++++----
 c/include/proton/codec.h               |  1 -
 c/include/proton/event.h               |  2 +-
 c/include/proton/link.h                |  1 -
 c/include/proton/logger.h              |  1 -
 c/include/proton/object.h              | 13 ++++++++----
 c/include/proton/reactor.h             |  1 +
 c/include/proton/selectable.h          |  1 -
 c/include/proton/session.h             |  1 -
 c/include/proton/types.h               | 15 ++++++++++++++
 c/src/core/decoder.c                   |  1 -
 c/src/core/encoder.c                   |  1 -
 c/src/core/error.c                     |  1 -
 c/src/core/logger.c                    |  9 ++++-----
 c/src/core/object/object.c             | 36 +++++++++++++++++++++++++++++++++-
 c/src/messenger/subscription.h         |  1 +
 c/src/reactor/io/windows/iocp.c        |  1 -
 c/src/reactor/io/windows/iocp.h        |  1 +
 c/src/reactor/selectable.c             |  1 +
 c/src/reactor/selectable.h             |  1 +
 c/tests/fuzz/fuzz-connection-driver.c  |  8 ++++----
 c/tests/fuzz/fuzz-proactor-receive.c   |  8 ++++----
 c/tests/object_test.cpp                | 11 +++++------
 c/tests/pn_test.cpp                    |  7 ++++---
 c/tests/pn_test.hpp                    |  6 ++----
 c/tools/reactor-recv.c                 | 16 ---------------
 c/tools/reactor-send.c                 | 30 +++++++++++++---------------
 cpp/src/contexts.cpp                   | 11 +++--------
 cpp/src/contexts.hpp                   |  2 ++
 cpp/src/object.cpp                     |  7 +++----
 cpp/src/object_test.cpp                |  2 ++
 cpp/src/proton_bits.cpp                |  7 +++----
 go/pkg/proton/wrappers.go              |  7 +++----
 python/cproton.i                       | 17 +++++-----------
 ruby/cproton.i                         | 17 ++++++++--------
 ruby/lib/util/wrapper.rb               |  8 +-------
 41 files changed, 178 insertions(+), 165 deletions(-)


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


[qpid-proton] 07/08: PROTON-2559: Rearrange using object.h

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 4641f1c3490496e8d81edaffc94c5417745adcb8
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Fri Apr 8 18:10:15 2022 -0400

    PROTON-2559: Rearrange using object.h
    
    This is in preparation for removing the pn_object_t pn_class_t internals
    from the public API of proton.
---
 c/examples/broker.c                   |  1 +
 c/examples/direct.c                   |  1 +
 c/examples/receive.c                  |  1 +
 c/include/proton/codec.h              |  1 -
 c/include/proton/event.h              |  2 +-
 c/include/proton/link.h               |  1 -
 c/include/proton/logger.h             |  1 -
 c/include/proton/object.h             |  3 ---
 c/include/proton/reactor.h            |  1 +
 c/include/proton/selectable.h         |  1 -
 c/include/proton/session.h            |  1 -
 c/include/proton/types.h              | 15 +++++++++++++++
 c/src/core/decoder.c                  |  1 -
 c/src/core/encoder.c                  |  1 -
 c/src/core/error.c                    |  1 -
 c/src/messenger/subscription.h        |  1 +
 c/src/reactor/io/windows/iocp.c       |  1 -
 c/src/reactor/io/windows/iocp.h       |  1 +
 c/src/reactor/selectable.c            |  1 +
 c/src/reactor/selectable.h            |  1 +
 c/tests/fuzz/fuzz-connection-driver.c |  1 +
 c/tests/pn_test.hpp                   |  2 ++
 cpp/src/contexts.hpp                  |  2 ++
 cpp/src/object_test.cpp               |  2 ++
 24 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/c/examples/broker.c b/c/examples/broker.c
index fd6aba2ab..b2843d3c6 100644
--- a/c/examples/broker.c
+++ b/c/examples/broker.c
@@ -22,6 +22,7 @@
 #include <proton/engine.h>
 #include <proton/listener.h>
 #include <proton/netaddr.h>
+#include <proton/object.h>
 #include <proton/proactor.h>
 #include <proton/sasl.h>
 #include <proton/ssl.h>
diff --git a/c/examples/direct.c b/c/examples/direct.c
index 977b85c8d..0cbda0998 100644
--- a/c/examples/direct.c
+++ b/c/examples/direct.c
@@ -26,6 +26,7 @@
 #include <proton/listener.h>
 #include <proton/netaddr.h>
 #include <proton/message.h>
+#include <proton/object.h>
 #include <proton/proactor.h>
 #include <proton/sasl.h>
 #include <proton/session.h>
diff --git a/c/examples/receive.c b/c/examples/receive.c
index c6f31f433..8e83a999e 100644
--- a/c/examples/receive.c
+++ b/c/examples/receive.c
@@ -24,6 +24,7 @@
 #include <proton/delivery.h>
 #include <proton/link.h>
 #include <proton/message.h>
+#include <proton/object.h>
 #include <proton/proactor.h>
 #include <proton/session.h>
 #include <proton/transport.h>
diff --git a/c/include/proton/codec.h b/c/include/proton/codec.h
index 5cd54ad5f..6a2fb0945 100644
--- a/c/include/proton/codec.h
+++ b/c/include/proton/codec.h
@@ -23,7 +23,6 @@
  */
 
 #include <proton/import_export.h>
-#include <proton/object.h>
 #include <proton/types.h>
 #include <proton/error.h>
 #include <proton/type_compat.h>
diff --git a/c/include/proton/event.h b/c/include/proton/event.h
index 048a60eea..a506e8d72 100644
--- a/c/include/proton/event.h
+++ b/c/include/proton/event.h
@@ -23,8 +23,8 @@
  */
 
 #include <proton/import_export.h>
+#include <proton/types.h>
 #include <proton/type_compat.h>
-#include <proton/object.h>
 #include <stddef.h>
 
 #ifdef __cplusplus
diff --git a/c/include/proton/link.h b/c/include/proton/link.h
index 014397643..9a17a4aa7 100644
--- a/c/include/proton/link.h
+++ b/c/include/proton/link.h
@@ -27,7 +27,6 @@
 #include <proton/condition.h>
 #include <proton/terminus.h>
 #include <proton/types.h>
-#include <proton/object.h>
 #include <stddef.h>
 
 #ifdef __cplusplus
diff --git a/c/include/proton/logger.h b/c/include/proton/logger.h
index cfc670642..f5ce9147c 100644
--- a/c/include/proton/logger.h
+++ b/c/include/proton/logger.h
@@ -29,7 +29,6 @@
  */
 
 #include <proton/import_export.h>
-#include <proton/object.h>
 
 #include <stdarg.h>
 #include <stdint.h>
diff --git a/c/include/proton/object.h b/c/include/proton/object.h
index 11f039624..771c692c3 100644
--- a/c/include/proton/object.h
+++ b/c/include/proton/object.h
@@ -37,17 +37,14 @@ extern "C" {
  * @cond INTERNAL
  */
 
-typedef const void* pn_handle_t;
 typedef intptr_t pn_shandle_t;
 
-typedef struct pn_class_t pn_class_t;
 typedef struct pn_string_t pn_string_t;
 typedef struct pn_list_t pn_list_t;
 typedef struct pn_map_t pn_map_t;
 typedef struct pn_hash_t pn_hash_t;
 typedef void *(*pn_iterator_next_t)(void *state);
 typedef struct pn_iterator_t pn_iterator_t;
-typedef struct pn_record_t pn_record_t;
 
 struct pn_class_t {
   const char *name;
diff --git a/c/include/proton/reactor.h b/c/include/proton/reactor.h
index e8a886467..fc96fa9e7 100644
--- a/c/include/proton/reactor.h
+++ b/c/include/proton/reactor.h
@@ -26,6 +26,7 @@
 #include <proton/type_compat.h>
 #include <proton/error.h>
 #include <proton/event.h>
+#include <proton/object.h>
 #include <proton/selectable.h>
 #include <proton/ssl.h>
 
diff --git a/c/include/proton/selectable.h b/c/include/proton/selectable.h
index c6d1722fd..2ca9588d2 100644
--- a/c/include/proton/selectable.h
+++ b/c/include/proton/selectable.h
@@ -23,7 +23,6 @@
  */
 
 #include <proton/import_export.h>
-#include <proton/object.h>
 #include <proton/event.h>
 #include <proton/type_compat.h>
 
diff --git a/c/include/proton/session.h b/c/include/proton/session.h
index 8cbdb5b76..e09d41113 100644
--- a/c/include/proton/session.h
+++ b/c/include/proton/session.h
@@ -25,7 +25,6 @@
 #include <proton/import_export.h>
 #include <proton/type_compat.h>
 #include <proton/types.h>
-#include <proton/object.h>
 #include <proton/error.h>
 #include <proton/condition.h>
 #include <stddef.h>
diff --git a/c/include/proton/types.h b/c/include/proton/types.h
index f4f496e1c..becf3fa63 100644
--- a/c/include/proton/types.h
+++ b/c/include/proton/types.h
@@ -461,6 +461,21 @@ typedef struct pn_raw_connection_t pn_raw_connection_t;
  */
 typedef struct pn_event_batch_t pn_event_batch_t;
 
+/**
+ * A type to represent the internal navigational state of a proton object
+ */
+typedef const void* pn_handle_t;
+
+/**
+ * A type representing the type of a proton internal object
+ */
+typedef struct pn_class_t pn_class_t;
+
+/**
+ * A type representing attached context information
+ */
+typedef struct pn_record_t pn_record_t;
+
 /**
  * @cond INTERNAL
  *
diff --git a/c/src/core/decoder.c b/c/src/core/decoder.c
index 6fe02bf7c..b487c96a7 100644
--- a/c/src/core/decoder.c
+++ b/c/src/core/decoder.c
@@ -20,7 +20,6 @@
  */
 
 #include <proton/error.h>
-#include <proton/object.h>
 #include <proton/codec.h>
 #include "encodings.h"
 #include "decoder.h"
diff --git a/c/src/core/encoder.c b/c/src/core/encoder.c
index 111ae25bd..8fb7acfc1 100644
--- a/c/src/core/encoder.c
+++ b/c/src/core/encoder.c
@@ -20,7 +20,6 @@
  */
 
 #include <proton/error.h>
-#include <proton/object.h>
 #include <proton/codec.h>
 #include "encodings.h"
 #include "encoder.h"
diff --git a/c/src/core/error.c b/c/src/core/error.c
index 9ebe90d7b..2d0d9b3fd 100644
--- a/c/src/core/error.c
+++ b/c/src/core/error.c
@@ -20,7 +20,6 @@
  */
 
 #include <proton/error.h>
-#include <proton/object.h>
 
 #include "memory.h"
 #include "platform/platform.h"
diff --git a/c/src/messenger/subscription.h b/c/src/messenger/subscription.h
index 8325c4df3..382b25a9c 100644
--- a/c/src/messenger/subscription.h
+++ b/c/src/messenger/subscription.h
@@ -23,6 +23,7 @@
  */
 
 #include <proton/messenger.h>
+#include <proton/object.h>
 
 extern const pn_class_t PN_CLASSCLASS(pn_subscription);
 
diff --git a/c/src/reactor/io/windows/iocp.c b/c/src/reactor/io/windows/iocp.c
index aeac84149..21fe46d5a 100644
--- a/c/src/reactor/io/windows/iocp.c
+++ b/c/src/reactor/io/windows/iocp.c
@@ -36,7 +36,6 @@
 #include "platform/platform.h"
 #include "core/util.h"
 
-#include <proton/object.h>
 #include <proton/error.h>
 #include <proton/transport.h>
 
diff --git a/c/src/reactor/io/windows/iocp.h b/c/src/reactor/io/windows/iocp.h
index 8f18d6962..327e89d3c 100644
--- a/c/src/reactor/io/windows/iocp.h
+++ b/c/src/reactor/io/windows/iocp.h
@@ -23,6 +23,7 @@
  */
 
 #include <proton/import_export.h>
+#include <proton/object.h>
 #include <proton/selectable.h>
 #include <proton/type_compat.h>
 
diff --git a/c/src/reactor/selectable.c b/c/src/reactor/selectable.c
index 3ecdc3f6c..220d1c9da 100644
--- a/c/src/reactor/selectable.c
+++ b/c/src/reactor/selectable.c
@@ -22,6 +22,7 @@
 #include "selectable.h"
 
 #include <proton/error.h>
+#include <proton/object.h>
 
 #include "io.h"
 
diff --git a/c/src/reactor/selectable.h b/c/src/reactor/selectable.h
index 2024a8ce6..251e6e238 100644
--- a/c/src/reactor/selectable.h
+++ b/c/src/reactor/selectable.h
@@ -27,6 +27,7 @@
 #endif
 
 #include <proton/selectable.h>
+#include <proton/object.h>
 
 extern const pn_class_t PN_CLASSCLASS(pn_selectable);
 
diff --git a/c/tests/fuzz/fuzz-connection-driver.c b/c/tests/fuzz/fuzz-connection-driver.c
index 8f8459fac..278dc69af 100644
--- a/c/tests/fuzz/fuzz-connection-driver.c
+++ b/c/tests/fuzz/fuzz-connection-driver.c
@@ -28,6 +28,7 @@
 #include "proton/engine.h"
 #include "proton/logger.h"
 #include "proton/message.h"
+#include "proton/object.h"
 
 #include "libFuzzingEngine.h"
 
diff --git a/c/tests/pn_test.hpp b/c/tests/pn_test.hpp
index c3dcf0176..b14012b16 100644
--- a/c/tests/pn_test.hpp
+++ b/c/tests/pn_test.hpp
@@ -30,6 +30,8 @@
 #include <proton/event.h>
 #include <proton/message.h>
 
+#include <proton/object.h>
+
 #include <iosfwd>
 #include <string>
 #include <vector>
diff --git a/cpp/src/contexts.hpp b/cpp/src/contexts.hpp
index dbba31dc4..4694ca969 100644
--- a/cpp/src/contexts.hpp
+++ b/cpp/src/contexts.hpp
@@ -27,6 +27,8 @@
 #include "proton/work_queue.hpp"
 #include "proton/message.hpp"
 
+#include "proton/object.h"
+
 #include <memory>
 
 struct pn_record_t;
diff --git a/cpp/src/object_test.cpp b/cpp/src/object_test.cpp
index 4c2737e88..3627a8539 100644
--- a/cpp/src/object_test.cpp
+++ b/cpp/src/object_test.cpp
@@ -22,6 +22,8 @@
 // for pn_data
 #include <proton/codec.h>
 
+#include <proton/object.h>
+
 namespace {
 
 TEST_CASE("pn_ptr_base(pn_data)", "[object]") {


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


[qpid-proton] 06/08: PROTON-2556: Remove unnecessary active connection list from reactor-recv

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 447f518bf5a6c37ee765fb70f332b59148f7bf28
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Thu Jun 2 12:30:26 2022 -0400

    PROTON-2556: Remove unnecessary active connection list from reactor-recv
    
    I suspect this was added as a workaround long ago when proton didn't
    properly cleanup listening connections.
---
 c/tools/reactor-recv.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/c/tools/reactor-recv.c b/c/tools/reactor-recv.c
index 2463a95ad..0d2fb5b55 100644
--- a/c/tools/reactor-recv.c
+++ b/c/tools/reactor-recv.c
@@ -80,7 +80,6 @@ typedef struct {
   char *encoded_data;
   size_t encoded_data_size;
   int connections;
-  pn_list_t *active_connections;
   bool shutting_down;
   pn_handler_t *listener_handler;
   int quiesce_count;
@@ -113,13 +112,6 @@ void global_shutdown(global_context_t *gc)
   if (gc->shutting_down) return;
   gc->shutting_down = true;
   pn_acceptor_close(gc->acceptor);
-  size_t n = pn_list_size(gc->active_connections);
-  for (size_t i = 0; i < n; i++) {
-    pn_connection_t *conn = (pn_connection_t *) pn_list_get(gc->active_connections, i);
-    if (!(pn_connection_state(conn) & PN_LOCAL_CLOSED)) {
-      pn_connection_close(conn);
-    }
-  }
 }
 
 connection_context_t *connection_context(pn_handler_t *h)
@@ -157,10 +149,6 @@ void connection_dispatch(pn_handler_t *h, pn_event_t *event, pn_event_type_t typ
         check(cc->recv_link == NULL, "Multiple incoming links on one connection");
         cc->recv_link = link;
         pn_connection_t *conn = pn_event_connection(event);
-        if (!cc->global->active_connections) {
-          cc->global->active_connections = pn_list(pn_class(conn), 1);
-        }
-        pn_list_add(cc->global->active_connections, conn);
         if (cc->global->shutting_down) {
           pn_connection_close(conn);
           break;
@@ -250,9 +238,6 @@ void connection_dispatch(pn_handler_t *h, pn_event_t *event, pn_event_type_t typ
   case PN_CONNECTION_UNBOUND:
     {
       pn_connection_t *conn = pn_event_connection(event);
-      if (cc->global->active_connections) {
-        pn_list_remove(cc->global->active_connections, conn);
-      }
       pn_connection_release(conn);
     }
     break;
@@ -313,7 +298,6 @@ void listener_cleanup(pn_handler_t *h)
   global_context_t *gc = global_context(h);
   pn_message_free(gc->message);
   free(gc->encoded_data);
-  pn_free(gc->active_connections);
 }
 
 void listener_dispatch(pn_handler_t *h, pn_event_t *event, pn_event_type_t type)


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


[qpid-proton] 02/08: PROTON-2557: Introduce pn_tostring in place of pn_inspect

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit d9ccd2923be628ac85e8a8da45090d981f0585cd
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Wed Jun 1 19:25:58 2022 -0400

    PROTON-2557: Introduce pn_tostring in place of pn_inspect
    
    Introduce and use a new API pn_tostring which produces a string
    representation of a Proton object in a char* string. It allocates this
    string with malloc and the application must free it.
    
    This replaces pn_inspect which requires the application to use the
    pn_string_t type purely to receive the string output. But we really
    don't want or need to expose this type outside the library itself.
---
 c/benchmarks/connection-driver.cpp     | 18 +++++++++---------
 c/benchmarks/message-encoding_list.cpp | 24 ++++++++++++------------
 c/benchmarks/message-encoding_map.cpp  | 31 +++++++++++++++----------------
 c/examples/direct.c                    |  7 +++----
 c/examples/receive.c                   |  7 +++----
 c/include/proton/object.h              |  1 +
 c/src/core/object/object.c             | 16 +++++++++++++++-
 c/tests/fuzz/fuzz-connection-driver.c  |  7 +++----
 c/tests/fuzz/fuzz-proactor-receive.c   |  8 ++++----
 c/tests/object_test.cpp                | 11 +++++------
 c/tests/pn_test.cpp                    |  7 ++++---
 c/tests/pn_test.hpp                    |  4 ----
 cpp/src/object.cpp                     |  7 +++----
 cpp/src/proton_bits.cpp                |  7 +++----
 14 files changed, 80 insertions(+), 75 deletions(-)

diff --git a/c/benchmarks/connection-driver.cpp b/c/benchmarks/connection-driver.cpp
index e2fdad16e..f3bef928a 100644
--- a/c/benchmarks/connection-driver.cpp
+++ b/c/benchmarks/connection-driver.cpp
@@ -19,24 +19,25 @@
  *
  */
 
-#include <unistd.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include <wait.h>
 
 #include <benchmark/benchmark.h>
 
 #include "proton/connection_driver.h"
 #include "proton/engine.h"
+#include "proton/listener.h"
 #include "proton/log.h"
 #include "proton/message.h"
+#include "proton/netaddr.h"
+#include "proton/object.h"
+#include "proton/proactor.h"
+#include "proton/sasl.h"
 #include "proton/transport.h"
-#include <proton/listener.h>
-#include <proton/netaddr.h>
-#include <proton/proactor.h>
-#include <proton/sasl.h>
 
 
 // variant of the receive.c proactor example
@@ -475,11 +476,10 @@ static void decode_message(pn_delivery_t *dlv) {
       // decode it into a proton message
       pn_message_t *m = pn_message();
       if (PN_OK == pn_message_decode(m, buffer, len)) {
-        pn_string_t *s = pn_string(NULL);
-        pn_inspect(pn_message_body(m), s);
+        char *s = pn_tostring(pn_message_body(m));
         if (VERBOSE)
-          printf("%s\n", pn_string_get(s));
-        pn_free(s);
+          printf("%s\n", s);
+        free(s);
       }
       pn_message_free(m);
     }
diff --git a/c/benchmarks/message-encoding_list.cpp b/c/benchmarks/message-encoding_list.cpp
index 51e8cebd0..1b4954fa1 100644
--- a/c/benchmarks/message-encoding_list.cpp
+++ b/c/benchmarks/message-encoding_list.cpp
@@ -18,24 +18,25 @@
  * under the License.
  *
  */
-#include <unistd.h>
 
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
+#include <wait.h>
+
+#include <benchmark/benchmark.h>
 
 #include "proton/connection_driver.h"
 #include "proton/engine.h"
+#include "proton/listener.h"
 #include "proton/log.h"
 #include "proton/message.h"
-
-#include <benchmark/benchmark.h>
-#include <proton/listener.h>
-#include <proton/netaddr.h>
-#include <proton/proactor.h>
-#include <proton/sasl.h>
-#include <wait.h>
+#include "proton/netaddr.h"
+#include "proton/object.h"
+#include "proton/proactor.h"
+#include "proton/sasl.h"
 
 const bool VERBOSE = false;
 const bool ERRORS = true;
@@ -45,13 +46,12 @@ static void decode_message_buffer(pn_rwbytes_t data) {
   int err = pn_message_decode(m, data.start, data.size);
   if (!err) {
     /* Print the decoded message */
-    pn_string_t *s = pn_string(NULL);
-    pn_inspect(pn_message_body(m), s);
+    char *s = pn_tostring(pn_message_body(m));
     if (VERBOSE) {
-      printf("%s\n", pn_string_get(s));
+      printf("%s\n", s);
       fflush(stdout);
     }
-    pn_free(s);
+    free(s);
     pn_message_free(m);
     free(data.start);
   } else {
diff --git a/c/benchmarks/message-encoding_map.cpp b/c/benchmarks/message-encoding_map.cpp
index 86f8e1deb..d58746c73 100644
--- a/c/benchmarks/message-encoding_map.cpp
+++ b/c/benchmarks/message-encoding_map.cpp
@@ -18,24 +18,25 @@
  * under the License.
  *
  */
-#include <unistd.h>
 
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
+#include <wait.h>
+
+#include <benchmark/benchmark.h>
 
 #include "proton/connection_driver.h"
 #include "proton/engine.h"
+#include "proton/listener.h"
 #include "proton/log.h"
 #include "proton/message.h"
-
-#include <benchmark/benchmark.h>
-#include <proton/listener.h>
-#include <proton/netaddr.h>
-#include <proton/proactor.h>
-#include <proton/sasl.h>
-#include <wait.h>
+#include "proton/netaddr.h"
+#include "proton/object.h"
+#include "proton/proactor.h"
+#include "proton/sasl.h"
 
 #define MAX_SIZE 1024
 
@@ -49,13 +50,12 @@ static void decode_message_buffer(pn_rwbytes_t data) {
   int err = pn_message_decode(m, data.start, data.size);
   if (!err) {
     /* Print the decoded message */
-    pn_string_t *s = pn_string(NULL);
-    pn_inspect(pn_message_body(m), s);
+    char *s = pn_tostring(pn_message_body(m));
     if (VERBOSE) {
-      printf("%s\n", pn_string_get(s));
+      printf("%s\n", s);
       fflush(stdout);
     }
-    pn_free(s);
+    free(s);
     pn_message_free(m);
     free(data.start);
   } else {
@@ -152,11 +152,10 @@ static void decode_message(pn_delivery_t *dlv) {
       // decode it into a proton message
       pn_message_t *m = pn_message();
       if (PN_OK == pn_message_decode(m, buffer, len)) {
-        pn_string_t *s = pn_string(NULL);
-        pn_inspect(pn_message_body(m), s);
+        char *s = pn_tostring(pn_message_body(m));
         if (VERBOSE)
-          printf("%s\n", pn_string_get(s));
-        pn_free(s);
+          printf("%s\n", s);
+        free(s);
       }
       pn_message_free(m);
     }
diff --git a/c/examples/direct.c b/c/examples/direct.c
index ceaaf2379..977b85c8d 100644
--- a/c/examples/direct.c
+++ b/c/examples/direct.c
@@ -98,11 +98,10 @@ static void decode_message(pn_rwbytes_t data) {
   int err = pn_message_decode(m, data.start, data.size);
   if (!err) {
     /* Print the decoded message */
-    pn_string_t *s = pn_string(NULL);
-    pn_inspect(pn_message_body(m), s);
-    printf("%s\n", pn_string_get(s));
+    char *s = pn_tostring(pn_message_body(m));
+    printf("%s\n", s);
     fflush(stdout);
-    pn_free(s);
+    free(s);
     pn_message_free(m);
     free(data.start);
   } else {
diff --git a/c/examples/receive.c b/c/examples/receive.c
index c70e0d8e3..c6f31f433 100644
--- a/c/examples/receive.c
+++ b/c/examples/receive.c
@@ -61,10 +61,9 @@ static void decode_message(pn_rwbytes_t data) {
   int err = pn_message_decode(m, data.start, data.size);
   if (!err) {
     /* Print the decoded message */
-    pn_string_t *s = pn_string(NULL);
-    pn_inspect(pn_message_body(m), s);
-    printf("%s\n", pn_string_get(s));
-    pn_free(s);
+    char *s = pn_tostring(pn_message_body(m));
+    printf("%s\n", s);
+    free(s);
     pn_message_free(m);
     free(data.start);
   } else {
diff --git a/c/include/proton/object.h b/c/include/proton/object.h
index 3db656406..ce76c6941 100644
--- a/c/include/proton/object.h
+++ b/c/include/proton/object.h
@@ -156,6 +156,7 @@ PN_EXTERN uintptr_t pn_hashcode(void *object);
 PN_EXTERN intptr_t pn_compare(void *a, void *b);
 PN_EXTERN bool pn_equals(void *a, void *b);
 PN_EXTERN int pn_inspect(void *object, pn_string_t *dst);
+PN_EXTERN char *pn_tostring(void *object);
 
 PN_EXTERN pn_list_t *pn_list(const pn_class_t *clazz, size_t capacity);
 PN_EXTERN size_t pn_list_size(pn_list_t *list);
diff --git a/c/src/core/object/object.c b/c/src/core/object/object.c
index 318b3d95f..a3ee2cbfd 100644
--- a/c/src/core/object/object.c
+++ b/c/src/core/object/object.c
@@ -23,8 +23,9 @@
 
 #include "core/memory.h"
 
-#include <stdlib.h>
 #include <assert.h>
+#include <stdlib.h>
+#include <string.h>
 
 #define CID_pn_default CID_pn_object
 #define pn_default_initialize NULL
@@ -369,6 +370,19 @@ int pn_inspect(void *object, pn_string_t *dst)
   return pn_string_addf(dst, "%s<%p>", name, object);
 }
 
+char *pn_tostring(void *object)
+{
+  pn_string_t *s = pn_string(NULL);
+  pn_inspect(object, s);
+
+  const char *sc = pn_string_get(s);
+  int l = pn_string_size(s)+1; // include final null
+  char *r = malloc(l);
+  strncpy(r, sc, l);
+  pn_decref(s);
+  return r;
+}
+
 #define pn_weakref_new NULL
 #define pn_weakref_initialize NULL
 #define pn_weakref_finalize NULL
diff --git a/c/tests/fuzz/fuzz-connection-driver.c b/c/tests/fuzz/fuzz-connection-driver.c
index ba0650896..8f8459fac 100644
--- a/c/tests/fuzz/fuzz-connection-driver.c
+++ b/c/tests/fuzz/fuzz-connection-driver.c
@@ -181,11 +181,10 @@ static void decode_message(pn_delivery_t *dlv) {
       // decode it into a proton message
       pn_message_t *m = pn_message();
       if (PN_OK == pn_message_decode(m, buffer, len)) {
-        pn_string_t *s = pn_string(NULL);
-        pn_inspect(pn_message_body(m), s);
+        char *s = pn_tostring(pn_message_body(m));
         if (ERRORS)
-          printf("%s\n", pn_string_get(s));
-        pn_free(s);
+          printf("%s\n", s);
+        free(s);
       }
       pn_message_free(m);
     }
diff --git a/c/tests/fuzz/fuzz-proactor-receive.c b/c/tests/fuzz/fuzz-proactor-receive.c
index 499c439c2..b81160424 100644
--- a/c/tests/fuzz/fuzz-proactor-receive.c
+++ b/c/tests/fuzz/fuzz-proactor-receive.c
@@ -26,6 +26,7 @@
 #include <proton/delivery.h>
 #include <proton/link.h>
 #include <proton/message.h>
+#include <proton/object.h>
 #include <proton/proactor.h>
 #include <proton/session.h>
 #include <proton/transport.h>
@@ -91,10 +92,9 @@ static void decode_message(pn_delivery_t *dlv) {
       // decode it into a proton message
       pn_message_t *m = pn_message();
       if (PN_OK == pn_message_decode(m, buffer, len)) {
-        pn_string_t *s = pn_string(NULL);
-        pn_inspect(pn_message_body(m), s);
-        printf("%s\n", pn_string_get(s));
-        pn_free(s);
+        char *s = pn_tostring(pn_message_body(m));
+        printf("%s\n", s);
+        free(s);
       }
       pn_message_free(m);
     }
diff --git a/c/tests/object_test.cpp b/c/tests/object_test.cpp
index c5a30237e..bd9d27eeb 100644
--- a/c/tests/object_test.cpp
+++ b/c/tests/object_test.cpp
@@ -714,12 +714,11 @@ TEST_CASE("map_iteration") {
   pn_decref(pairs);
 }
 
-#define test_inspect(o, expected)                                              \
-  do {                                                                         \
-    pn_string_t *dst = pn_string(NULL);                                        \
-    pn_inspect(o, dst);                                                        \
-    CHECK_THAT(expected, Equals(pn_string_get(dst)));                          \
-    pn_free(dst);                                                              \
+#define test_inspect(o, expected)                               \
+  do {                                                          \
+    char  *dst = pn_tostring(o);                                \
+    CHECK_THAT(expected, Equals(dst));                          \
+    free(dst);                                                  \
   } while (0)
 
 TEST_CASE("list_inspect") {
diff --git a/c/tests/pn_test.cpp b/c/tests/pn_test.cpp
index 37e5199dc..03a2526d5 100644
--- a/c/tests/pn_test.cpp
+++ b/c/tests/pn_test.cpp
@@ -60,9 +60,10 @@ std::ostream &operator<<(std::ostream &o, const pn_error_t &const_err) {
 namespace pn_test {
 
 std::string inspect(void *obj) {
-  auto_free<pn_string_t, pn_string_free> s(pn_string(NULL));
-  pn_inspect(obj, s);
-  return pn_string_get(s);
+  char* s = pn_tostring(obj);
+  std::string r(s);
+  free(s);
+  return r;
 }
 
 etypes make_etypes_(int first, ...) {
diff --git a/c/tests/pn_test.hpp b/c/tests/pn_test.hpp
index 249451ba7..c3dcf0176 100644
--- a/c/tests/pn_test.hpp
+++ b/c/tests/pn_test.hpp
@@ -56,10 +56,6 @@ public:
   operator T *() const { return ptr_; } // not marking explicit for convenience
 };
 
-// pn_free() works for some, but not all pn_xxx_t* types.
-// Add typed pn_string_free() so we can be consistent and safe.
-inline void pn_string_free(pn_string_t *s) { pn_free(s); }
-
 // Call pn_inspect(), return std::string
 std::string inspect(void *);
 
diff --git a/cpp/src/object.cpp b/cpp/src/object.cpp
index 2732d5d0e..b3c82cc31 100644
--- a/cpp/src/object.cpp
+++ b/cpp/src/object.cpp
@@ -33,10 +33,9 @@ void pn_ptr_base::decref(void *p) {
 
 std::string pn_ptr_base::inspect(void* p) {
     if (!p) return std::string();
-    ::pn_string_t* s = ::pn_string(NULL);
-    (void) ::pn_inspect(p, s);
-    std::string tmp = std::string(pn_string_get(s));
-    pn_free(s);
+    char* s =  ::pn_tostring(p);
+    std::string tmp(s);
+    free(s);
     return tmp;
 }
 }}
diff --git a/cpp/src/proton_bits.cpp b/cpp/src/proton_bits.cpp
index 3e1b27f7e..517f7456d 100644
--- a/cpp/src/proton_bits.cpp
+++ b/cpp/src/proton_bits.cpp
@@ -54,10 +54,9 @@ std::string error_str(pn_error_t* err, long code) {
 }
 
 std::ostream& operator<<(std::ostream& o, const inspectable& object) {
-    pn_string_t* str = pn_string("");
-    pn_inspect(object.value, str);
-    o << pn_string_get(str);
-    pn_free(str);
+    char* str = pn_tostring(object.value);
+    o << str;
+    free(str);
     return o;
 }
 


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


[qpid-proton] 01/08: PROTON-2556: Removed gratuitous use of pn_string from reactor-send

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 0ad20092eb68e08a784a988af31dfc2be500e7f5
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Wed Jun 1 08:22:43 2022 -0400

    PROTON-2556: Removed gratuitous use of pn_string from reactor-send
---
 c/tools/reactor-send.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/c/tools/reactor-send.c b/c/tools/reactor-send.c
index 1b7870f79..5929ddc3d 100644
--- a/c/tools/reactor-send.c
+++ b/c/tools/reactor-send.c
@@ -85,9 +85,9 @@ typedef struct {
   char *encoded_data;
   size_t encoded_data_size;
   pn_url_t *send_url;
-  pn_string_t *hostname;
-  pn_string_t *container_id;
-  pn_string_t *reply_to;
+  char hostname[256];
+  char reply_to[256]; // This should be large enough for the return address
+  const char *container_id;
 } sender_context_t;
 
 void sender_context_init(sender_context_t *sc, Options_t *opts, Statistics_t *stats)
@@ -101,14 +101,13 @@ void sender_context_init(sender_context_t *sc, Options_t *opts, Statistics_t *st
   sc->encoded_data_size = sc->opts->msg_size + 4096;
   sc->encoded_data = (char *)calloc(1, sc->encoded_data_size);
   check(sc->encoded_data, "failed to allocate encoding buffer");
-  sc->container_id = pn_string("reactor-send"); // prefer uuid-like name
+  sc->container_id = "reactor-send"; // prefer uuid-like name
 
   sc->reply_message = (sc->opts->get_replies) ? pn_message() : 0;
   sc->message = pn_message();
   check(sc->message, "failed to allocate a message");
-  sc->reply_to = pn_string("amqp://");
-  pn_string_addf(sc->reply_to, "%s", pn_string_get(sc->container_id));
-  pn_message_set_reply_to(sc->message, pn_string_get(sc->reply_to));
+  snprintf(sc->reply_to, sizeof(sc->reply_to), "amqp://%s", sc->container_id);
+  pn_message_set_reply_to(sc->message, sc->reply_to);
   pn_data_t *body = pn_message_body(sc->message);
   // borrow the encoding buffer this one time
   char *data = sc->encoded_data;
@@ -118,9 +117,11 @@ void sender_context_init(sender_context_t *sc, Options_t *opts, Statistics_t *st
   sc->send_url = pn_url_parse(sc->opts->targets.addresses[0]);
   const char *host = pn_url_get_host(sc->send_url);
   const char *port = pn_url_get_port(sc->send_url);
-  sc->hostname = pn_string(host);
-  if (port && strlen(port))
-    pn_string_addf(sc->hostname, ":%s", port);
+  if (port && strlen(port)) {
+    snprintf(sc->hostname, sizeof(sc->hostname), "%s:%s", host, port);
+  } else {
+    snprintf(sc->hostname, sizeof(sc->hostname), "%s", host);
+  }
 }
 
 sender_context_t *sender_context(pn_handler_t *h)
@@ -134,9 +135,6 @@ void sender_cleanup(pn_handler_t *h)
   pn_message_free(sc->message);
   pn_message_free(sc->reply_message);
   pn_url_free(sc->send_url);
-  pn_free(sc->hostname);
-  pn_free(sc->container_id);
-  pn_free(sc->reply_to);
   free(sc->encoded_data);
 }
 
@@ -147,7 +145,7 @@ pn_message_t* get_message(sender_context_t *sc, bool sending) {
     pn_message_t *m = pn_message();
     check(m, "failed to allocate a message");
     if (sending) {
-      pn_message_set_reply_to(m, pn_string_get(sc->reply_to));
+      pn_message_set_reply_to(m, sc->reply_to);
       // copy the data
       pn_data_t *body = pn_message_body(m);
       pn_data_t *template_body = pn_message_body(sc->message);
@@ -172,8 +170,8 @@ void sender_dispatch(pn_handler_t *h, pn_event_t *event, pn_event_type_t type)
   case PN_CONNECTION_INIT:
     {
       pn_connection_t *conn = pn_event_connection(event);
-      pn_connection_set_container(conn, pn_string_get(sc->container_id));
-      pn_connection_set_hostname(conn, pn_string_get(sc->hostname));
+      pn_connection_set_container(conn, sc->container_id);
+      pn_connection_set_hostname(conn, sc->hostname);
       pn_connection_open(conn);
       pn_session_t *ssn = pn_session(conn);
       pn_session_open(ssn);


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


[qpid-proton] 08/08: NO-JIRA: Use C99 syntax for default logger initialization

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit d1bcaa3a9f3100609fe55336ca1f18d3831acaa1
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Tue Jun 7 17:44:14 2022 -0400

    NO-JIRA: Use C99 syntax for default logger initialization
---
 c/src/core/logger.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/c/src/core/logger.c b/c/src/core/logger.c
index c4042d4fe..e81dc172c 100644
--- a/c/src/core/logger.c
+++ b/c/src/core/logger.c
@@ -37,11 +37,10 @@ static void pni_default_log_sink(intptr_t logger, pn_log_subsystem_t subsystem,
 }
 
 static pn_logger_t the_default_logger = {
-  pni_default_log_sink,
-  (intptr_t) &the_default_logger,
-  NULL,
-  PN_SUBSYSTEM_ALL,
-  PN_LEVEL_CRITICAL
+  .sink = pni_default_log_sink,
+  .sink_context = (intptr_t) &the_default_logger,
+  .sub_mask = PN_SUBSYSTEM_ALL,
+  .sev_mask = PN_LEVEL_CRITICAL
 };
 
 void pni_logger_init(pn_logger_t *logger)


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


[qpid-proton] 04/08: PROTON-2557: Ruby change for introduction of pn_tostring

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit eea52fd02c66dae3ff510298dc1fa8c6cb9c8a42
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Wed Jun 1 20:39:38 2022 -0400

    PROTON-2557: Ruby change for introduction of pn_tostring
---
 ruby/lib/util/wrapper.rb | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/ruby/lib/util/wrapper.rb b/ruby/lib/util/wrapper.rb
index 795c0022d..e2f8592bb 100644
--- a/ruby/lib/util/wrapper.rb
+++ b/ruby/lib/util/wrapper.rb
@@ -129,13 +129,7 @@ module Qpid::Proton
 
       def inspect
         return "#{self.class}<nil>" unless @impl
-        pstr = Cproton.pn_string("")
-        begin
-          Cproton.pn_inspect(@impl, pstr)
-          return Cproton.pn_string_get(pstr)
-        ensure
-          Cproton.pn_free(pstr)
-        end
+        return Cproton.pn_tostring(@impl)
       end
 
       def to_s() inspect; end


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


[qpid-proton] 05/08: PROTON-2558: Add make class operation to hide class details

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit b18da591521709102d3957b7407706d8060796cf
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Mon May 16 23:06:25 2022 -0400

    PROTON-2558: Add make class operation to hide class details
    
    The new operation is used by the bindings to create proton objects
    without needing to know the details of the pn_class_t struct.
---
 c/include/proton/object.h  |  9 ++++++++-
 c/src/core/object/object.c | 20 ++++++++++++++++++++
 cpp/src/contexts.cpp       | 11 +++--------
 python/cproton.i           | 17 +++++------------
 ruby/cproton.i             | 17 +++++++++--------
 5 files changed, 45 insertions(+), 29 deletions(-)

diff --git a/c/include/proton/object.h b/c/include/proton/object.h
index ce76c6941..11f039624 100644
--- a/c/include/proton/object.h
+++ b/c/include/proton/object.h
@@ -51,7 +51,7 @@ typedef struct pn_record_t pn_record_t;
 
 struct pn_class_t {
   const char *name;
-  const pn_cid_t cid;
+  pn_cid_t cid;
   void *(*newinst)(const pn_class_t *, size_t);
   void (*initialize)(void *);
   void (*incref)(void *);
@@ -105,6 +105,13 @@ PN_EXTERN void pn_object_incref(void *object);
     PREFIX ## _inspect                          \
 }
 
+PN_EXTERN pn_class_t *pn_class_create(const char *name,
+                                      void (*initialize)(void*),
+                                      void (*finalize)(void*),
+                                      void (*incref)(void*),
+                                      void (*decref)(void*),
+                                      int (*refcount)(void*));
+
 PN_EXTERN void *pn_void_new(const pn_class_t *clazz, size_t size);
 PN_EXTERN void pn_void_incref(void *object);
 PN_EXTERN void pn_void_decref(void *object);
diff --git a/c/src/core/object/object.c b/c/src/core/object/object.c
index a3ee2cbfd..e498f9fb0 100644
--- a/c/src/core/object/object.c
+++ b/c/src/core/object/object.c
@@ -59,6 +59,26 @@ typedef struct {
 #define pni_head(PTR) \
 (((pni_head_t *) (PTR)) - 1)
 
+pn_class_t *pn_class_create(const char *name,
+                            void (*initialize)(void*),
+                            void (*finalize)(void*),
+                            void (*incref)(void*),
+                            void (*decref)(void*),
+                            int (*refcount)(void*))
+{
+  pn_class_t *clazz = malloc(sizeof( pn_class_t));
+  *clazz = (pn_class_t) {
+    .name = name,
+    .cid = CID_pn_void,
+    .initialize = initialize,
+    .finalize = finalize,
+    .incref = incref,
+    .decref = decref,
+    .refcount = refcount
+  };
+  return clazz;
+}
+
 const char *pn_class_name(const pn_class_t *clazz)
 {
   return clazz->name;
diff --git a/cpp/src/contexts.cpp b/cpp/src/contexts.cpp
index 7bc6c3f01..9dc13dbf0 100644
--- a/cpp/src/contexts.cpp
+++ b/cpp/src/contexts.cpp
@@ -42,12 +42,7 @@ namespace proton {
 
 namespace {
 void cpp_context_finalize(void* v) { reinterpret_cast<context*>(v)->~context(); }
-#define CID_cpp_context CID_pn_object
-#define cpp_context_initialize NULL
-#define cpp_context_hashcode NULL
-#define cpp_context_compare NULL
-#define cpp_context_inspect NULL
-pn_class_t cpp_context_class = PN_CLASS(cpp_context);
+pn_class_t* cpp_context_class = pn_class_create("cpp_context", nullptr, cpp_context_finalize, nullptr, nullptr, nullptr);
 
 // Handles
 PN_HANDLE(CONNECTION_CONTEXT)
@@ -64,9 +59,9 @@ T* get_context(pn_record_t* record, pn_handle_t handle) {
 
 context::~context() {}
 
-void *context::alloc(size_t n) { return pn_class_new(&cpp_context_class, n); }
+void *context::alloc(size_t n) { return pn_class_new(cpp_context_class, n); }
 
-pn_class_t* context::pn_class() { return &cpp_context_class; }
+pn_class_t* context::pn_class() { return cpp_context_class; }
 
 connection_context::connection_context() :
     container(0), default_session(0), link_gen(0), handler(0), listener_context_(0)
diff --git a/python/cproton.i b/python/cproton.i
index 6bb68e4b9..7a3407ee1 100644
--- a/python/cproton.i
+++ b/python/cproton.i
@@ -415,16 +415,7 @@ int pn_ssl_get_cert_fingerprint(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_S
 
 %immutable PN_PYREF;
 %inline %{
-  extern const pn_class_t PN_PYREF[];
-
-  #define CID_pn_pyref CID_pn_void
-  #define pn_pyref_new NULL
-  #define pn_pyref_initialize NULL
-  #define pn_pyref_finalize NULL
-  #define pn_pyref_free NULL
-  #define pn_pyref_hashcode NULL
-  #define pn_pyref_compare NULL
-  #define pn_pyref_inspect NULL
+  pn_class_t* PN_PYREF;
 
   static void pn_pyref_incref(void *object) {
     PyObject* p = (PyObject*) object;
@@ -444,8 +435,6 @@ int pn_ssl_get_cert_fingerprint(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_S
     return 1;
   }
 
-  const pn_class_t PN_PYREF[] = {PN_METACLASS(pn_pyref)};
-
   void *pn_py2void(PyObject *object) {
     return object;
   }
@@ -501,4 +490,8 @@ int pn_ssl_get_cert_fingerprint(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_S
 
 %}
 
+%init %{
+  PN_PYREF = pn_class_create("pn_pyref", NULL, NULL, pn_pyref_incref, pn_pyref_decref, pn_pyref_refcount);
+%}
+
 %include "proton/cproton.i"
diff --git a/ruby/cproton.i b/ruby/cproton.i
index f8a0f3d77..00b3593dc 100644
--- a/ruby/cproton.i
+++ b/ruby/cproton.i
@@ -510,19 +510,14 @@ void Pn_rbkey_finalize(void *vp_rbkey) {
   }
 }
 
-/* NOTE: no macro or preprocessor definitions in %inline sections */
-#define CID_Pn_rbkey CID_pn_void
-#define Pn_rbkey_inspect NULL
-#define Pn_rbkey_compare NULL
-#define Pn_rbkey_hashcode NULL
+static pn_class_t *Pn_rbkey_class;
 
 pn_class_t* Pn_rbkey__class(void) {
-    static pn_class_t clazz = PN_CLASS(Pn_rbkey);
-    return &clazz;
+    return Pn_rbkey_class;
 }
 
 Pn_rbkey_t *Pn_rbkey_new(void) {
-    return (Pn_rbkey_t *) pn_class_new(Pn_rbkey__class(), sizeof(Pn_rbkey_t));
+    return (Pn_rbkey_t *) pn_class_new(Pn_rbkey_class, sizeof(Pn_rbkey_t));
 }
 %}
 
@@ -674,6 +669,12 @@ int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE);
 
 %}
 
+%init
+%{
+Pn_rbkey_class =
+  pn_class_create("Pn_rbkey", Pn_rbkey_initialize, Pn_rbkey_finalize, NULL, NULL, NULL);
+%}
+
 %include "proton/cproton.i"
 
 %include "proton/url.h"


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


[qpid-proton] 03/08: PROTON-2557: Go change for introduction of pn_tostring

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 839cdee1c091eacce7e2c91b6f60f205669a5521
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Wed Jun 1 20:38:46 2022 -0400

    PROTON-2557: Go change for introduction of pn_tostring
---
 go/pkg/proton/wrappers.go | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/go/pkg/proton/wrappers.go b/go/pkg/proton/wrappers.go
index 724f6934b..467d94480 100644
--- a/go/pkg/proton/wrappers.go
+++ b/go/pkg/proton/wrappers.go
@@ -126,10 +126,9 @@ func (d Data) Error() error         { return PnError(C.pn_data_error(d.pn)) }
 func (d Data) Empty() bool          { return C.pn_data_size(d.pn) == 0 }
 
 func (d Data) String() string {
-	str := C.pn_string(C.CString(""))
-	defer C.pn_free(unsafe.Pointer(str))
-	C.pn_inspect(unsafe.Pointer(d.pn), str)
-	return C.GoString(C.pn_string_get(str))
+	str := C.pn_tostring(unsafe.Pointer(d.pn))
+	defer C.free(unsafe.Pointer(str))
+	return C.GoString(str)
 }
 
 // Unmarshal the value of d into value pointed at by ptr, see amqp.Unmarshal() for details


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