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/07/06 12:13:05 UTC
[qpid-proton] 02/04: PROTON-2559: making object.h mostly private
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 5ebd13fe8b29566eac7fdc07e824c87262b3a443
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Wed Apr 13 14:39:53 2022 -0400
PROTON-2559: making object.h mostly private
---
c/include/proton/object.h | 220 +++------------------
c/include/proton/reactor.h | 3 +-
c/src/core/buffer.h | 3 +-
c/src/core/event.c | 7 +-
c/src/core/memory.h | 2 +-
c/src/core/object/object.c | 6 +-
.../proton/object.h => src/core/object_private.h} | 152 +++++---------
c/src/core/value_dump.h | 2 +
c/src/handlers/handshaker.c | 6 +-
c/src/handlers/iohandler.c | 7 +-
c/src/messenger/subscription.c | 6 +-
c/src/messenger/subscription.h | 2 +
c/src/reactor/acceptor.c | 2 +
c/src/reactor/connection.c | 10 +-
c/src/reactor/handler.c | 4 +-
c/src/reactor/io/posix/io.c | 5 +-
c/src/reactor/io/windows/iocp.h | 3 +-
c/src/reactor/reactor.c | 2 +-
c/src/reactor/selectable.c | 2 +-
c/src/reactor/selectable.h | 2 +
c/src/reactor/timer.c | 4 +-
c/tests/event_test.cpp | 5 +-
c/tests/object_test.cpp | 5 +-
c/tools/reactor-recv.c | 1 +
python/cproton.i | 2 +-
ruby/cproton.i | 1 +
26 files changed, 135 insertions(+), 329 deletions(-)
diff --git a/c/include/proton/object.h b/c/include/proton/object.h
index 771c692c3..a97d01f16 100644
--- a/c/include/proton/object.h
+++ b/c/include/proton/object.h
@@ -24,9 +24,6 @@
#include <proton/cid.h>
#include <proton/types.h>
-#include <stdarg.h>
-#include <proton/type_compat.h>
-#include <stddef.h>
#include <proton/import_export.h>
#ifdef __cplusplus
@@ -36,72 +33,6 @@ extern "C" {
/**
* @cond INTERNAL
*/
-
-typedef intptr_t pn_shandle_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;
-
-struct pn_class_t {
- const char *name;
- pn_cid_t cid;
- void *(*newinst)(const pn_class_t *, size_t);
- void (*initialize)(void *);
- void (*incref)(void *);
- void (*decref)(void *);
- int (*refcount)(void *);
- void (*finalize)(void *);
- void (*free)(void *);
- uintptr_t (*hashcode)(void *);
- intptr_t (*compare)(void *, void *);
- int (*inspect)(void *, pn_string_t *);
-};
-
-/* Hack alert: Declare these as arrays so we can treat the name of the single
- object as the address */
-PN_EXTERN extern const pn_class_t PN_DEFAULT[];
-PN_EXTERN extern const pn_class_t PN_OBJECT[];
-PN_EXTERN extern const pn_class_t PN_VOID[];
-PN_EXTERN extern const pn_class_t PN_WEAKREF[];
-
-PN_EXTERN void pn_object_incref(void *object);
-
-#define PN_CLASSCLASS(PREFIX) PREFIX ## __class
-
-#define PN_CLASS(PREFIX) { \
- #PREFIX, \
- CID_ ## PREFIX, \
- NULL, \
- PREFIX ## _initialize, \
- NULL, \
- NULL, \
- NULL, \
- PREFIX ## _finalize, \
- NULL, \
- PREFIX ## _hashcode, \
- PREFIX ## _compare, \
- PREFIX ## _inspect \
-}
-
-#define PN_METACLASS(PREFIX) { \
- #PREFIX, \
- CID_ ## PREFIX, \
- PREFIX ## _new, \
- PREFIX ## _initialize, \
- PREFIX ## _incref, \
- PREFIX ## _decref, \
- PREFIX ## _refcount, \
- PREFIX ## _finalize, \
- PREFIX ## _free, \
- PREFIX ## _hashcode, \
- PREFIX ## _compare, \
- PREFIX ## _inspect \
-}
-
PN_EXTERN pn_class_t *pn_class_create(const char *name,
void (*initialize)(void*),
void (*finalize)(void*),
@@ -109,147 +40,42 @@ PN_EXTERN pn_class_t *pn_class_create(const char *name,
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);
-PN_EXTERN int pn_void_refcount(void *object);
-
-/* Class to identify a plain C struct in a pn_event_t. No refcounting or memory management. */
-#define PN_STRUCT_CLASSDEF(PREFIX) \
-const pn_class_t PN_CLASSCLASS(PREFIX)[] = {{ \
- #PREFIX, \
- CID_ ## PREFIX, \
- NULL, /*_new*/ \
- NULL, /*_initialize*/ \
- pn_void_incref, \
- pn_void_decref, \
- pn_void_refcount, \
- NULL, /* _finalize */ \
- NULL, /* _free */ \
- NULL, /* _hashcode */ \
- NULL, /* _compare */ \
- NULL, /* _inspect */ \
-}}; \
-
-PN_EXTERN pn_cid_t pn_class_id(const pn_class_t *clazz);
-PN_EXTERN const char *pn_class_name(const pn_class_t *clazz);
PN_EXTERN void *pn_class_new(const pn_class_t *clazz, size_t size);
+PN_EXTERN const char *pn_class_name(const pn_class_t *clazz);
+PN_EXTERN pn_cid_t pn_class_id(const pn_class_t *clazz);
-PN_EXTERN void *pn_class_incref(const pn_class_t *clazz, void *object);
-PN_EXTERN int pn_class_refcount(const pn_class_t *clazz, void *object);
-PN_EXTERN int pn_class_decref(const pn_class_t *clazz, void *object);
-
-PN_EXTERN void pn_class_free(const pn_class_t *clazz, void *object);
-
-PN_EXTERN intptr_t pn_class_compare(const pn_class_t *clazz, void *a, void *b);
-PN_EXTERN bool pn_class_equals(const pn_class_t *clazz, void *a, void *b);
-PN_EXTERN int pn_class_inspect(const pn_class_t *clazz, void *object, pn_string_t *dst);
-
-/* pn_incref, pn_decref and pn_refcount are for internal use by the proton
- * library, the should not be called by application code. Application code
- * should use the appropriate pn_*_free function (pn_link_free, pn_session_free
- * etc.) when it is finished with a proton value. Proton values should only be
- * used when handling a pn_event_t that refers to them.
- */
+PN_EXTERN const pn_class_t *pn_class(void* object);
PN_EXTERN void *pn_incref(void *object);
PN_EXTERN int pn_decref(void *object);
PN_EXTERN int pn_refcount(void *object);
PN_EXTERN void pn_free(void *object);
-PN_EXTERN const pn_class_t *pn_class(void* object);
-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);
-PN_EXTERN void *pn_list_get(pn_list_t *list, int index);
-PN_EXTERN void pn_list_set(pn_list_t *list, int index, void *value);
-PN_EXTERN int pn_list_add(pn_list_t *list, void *value);
-PN_EXTERN void *pn_list_pop(pn_list_t *list);
-PN_EXTERN ssize_t pn_list_index(pn_list_t *list, void *value);
-PN_EXTERN bool pn_list_remove(pn_list_t *list, void *value);
-PN_EXTERN void pn_list_del(pn_list_t *list, int index, int n);
-PN_EXTERN void pn_list_clear(pn_list_t *list);
-PN_EXTERN void pn_list_iterator(pn_list_t *list, pn_iterator_t *iter);
-PN_EXTERN void pn_list_minpush(pn_list_t *list, void *value);
-PN_EXTERN void *pn_list_minpop(pn_list_t *list);
-
-PN_EXTERN pn_map_t *pn_map(const pn_class_t *key, const pn_class_t *value,
- size_t capacity, float load_factor);
-PN_EXTERN size_t pn_map_size(pn_map_t *map);
-PN_EXTERN int pn_map_put(pn_map_t *map, void *key, void *value);
-PN_EXTERN void *pn_map_get(pn_map_t *map, void *key);
-PN_EXTERN void pn_map_del(pn_map_t *map, void *key);
-PN_EXTERN pn_handle_t pn_map_head(pn_map_t *map);
-PN_EXTERN pn_handle_t pn_map_next(pn_map_t *map, pn_handle_t entry);
-PN_EXTERN void *pn_map_key(pn_map_t *map, pn_handle_t entry);
-PN_EXTERN void *pn_map_value(pn_map_t *map, pn_handle_t entry);
-
-PN_EXTERN pn_hash_t *pn_hash(const pn_class_t *clazz, size_t capacity, float load_factor);
-PN_EXTERN size_t pn_hash_size(pn_hash_t *hash);
-PN_EXTERN int pn_hash_put(pn_hash_t *hash, uintptr_t key, void *value);
-PN_EXTERN void *pn_hash_get(pn_hash_t *hash, uintptr_t key);
-PN_EXTERN void pn_hash_del(pn_hash_t *hash, uintptr_t key);
-PN_EXTERN pn_handle_t pn_hash_head(pn_hash_t *hash);
-PN_EXTERN pn_handle_t pn_hash_next(pn_hash_t *hash, pn_handle_t entry);
-PN_EXTERN uintptr_t pn_hash_key(pn_hash_t *hash, pn_handle_t entry);
-PN_EXTERN void *pn_hash_value(pn_hash_t *hash, pn_handle_t entry);
-
-PN_EXTERN pn_string_t *pn_string(const char *bytes);
-PN_EXTERN pn_string_t *pn_stringn(const char *bytes, size_t n);
-PN_EXTERN const char *pn_string_get(pn_string_t *string);
-PN_EXTERN size_t pn_string_size(pn_string_t *string);
-PN_EXTERN int pn_string_set(pn_string_t *string, const char *bytes);
-PN_EXTERN int pn_string_setn(pn_string_t *string, const char *bytes, size_t n);
-PN_EXTERN ssize_t pn_string_put(pn_string_t *string, char *dst);
-PN_EXTERN void pn_string_clear(pn_string_t *string);
-PN_EXTERN int pn_string_format(pn_string_t *string, const char *format, ...)
-#ifdef __GNUC__
- __attribute__ ((format (printf, 2, 3)))
-#endif
- ;
-PN_EXTERN int pn_string_vformat(pn_string_t *string, const char *format, va_list ap);
-PN_EXTERN int pn_string_addf(pn_string_t *string, const char *format, ...)
-#ifdef __GNUC__
- __attribute__ ((format (printf, 2, 3)))
-#endif
- ;
-PN_EXTERN int pn_string_vaddf(pn_string_t *string, const char *format, va_list ap);
-PN_EXTERN int pn_string_grow(pn_string_t *string, size_t capacity);
-PN_EXTERN char *pn_string_buffer(pn_string_t *string);
-PN_EXTERN size_t pn_string_capacity(pn_string_t *string);
-PN_EXTERN int pn_string_resize(pn_string_t *string, size_t size);
-PN_EXTERN int pn_string_copy(pn_string_t *string, pn_string_t *src);
-
-PN_EXTERN pn_iterator_t *pn_iterator(void);
-PN_EXTERN void *pn_iterator_start(pn_iterator_t *iterator,
- pn_iterator_next_t next, size_t size);
-PN_EXTERN void *pn_iterator_next(pn_iterator_t *iterator);
-
#define PN_LEGCTX ((pn_handle_t) 0)
/**
- PN_HANDLE is a trick to define a unique identifier by using the address of a static variable.
- You MUST NOT use it in a .h file, since it must be defined uniquely in one compilation unit.
- Your .h file can provide access to the handle (if needed) via a function. For example:
-
- /// my_thing.h
- pn_handle_t get_my_thing(void);
-
- /// my_thing.c
- PN_HANDLE(MY_THING);
- pn_handle_t get_my_thing(void) { return MY_THING; }
-
- Note that the name "MY_THING" is not exported and is not required to be
- unique except in the .c file. The linker will guarantee that the *address* of
- MY_THING, as returned by get_my_thing() *is* unique across the entire linked
- executable.
+ * PN_HANDLE is a trick to define a unique identifier by using the address of a static variable.
+ * You MUST NOT use it in a .h file, since it must be defined uniquely in one compilation unit.
+ * Your .h file can provide access to the handle (if needed) via a function. For example:
+ *
+ * /// my_thing.h
+ * pn_handle_t get_my_thing(void);
+ *
+ * /// my_thing.c
+ * PN_HANDLE(MY_THING);
+ * pn_handle_t get_my_thing(void) { return MY_THING; }
+ *
+ * Note that the name "MY_THING" is not exported and is not required to be
+ * unique except in the .c file. The linker will guarantee that the *address* of
+ * MY_THING, as returned by get_my_thing() *is* unique across the entire linked
+ * executable.
*/
#define PN_HANDLE(name) \
- static const char _PN_HANDLE_ ## name = 0; \
- static const pn_handle_t name = ((pn_handle_t) &_PN_HANDLE_ ## name);
+static const char _PN_HANDLE_ ## name = 0; \
+static const pn_handle_t name = ((pn_handle_t) &_PN_HANDLE_ ## name);
+
+PN_EXTERN extern const pn_class_t *PN_OBJECT;
+PN_EXTERN extern const pn_class_t *PN_VOID;
PN_EXTERN pn_record_t *pn_record(void);
PN_EXTERN void pn_record_def(pn_record_t *record, pn_handle_t key, const pn_class_t *clazz);
diff --git a/c/include/proton/reactor.h b/c/include/proton/reactor.h
index fc96fa9e7..4fcd1997a 100644
--- a/c/include/proton/reactor.h
+++ b/c/include/proton/reactor.h
@@ -42,6 +42,7 @@ typedef struct pn_reactor_t pn_reactor_t;
typedef struct pn_acceptor_t pn_acceptor_t;
typedef struct pn_timer_t pn_timer_t;
typedef struct pn_task_t pn_task_t;
+struct pn_list_t;
PNX_EXTERN pn_handler_t *pn_handler(void (*dispatch)(pn_handler_t *, pn_event_t *, pn_event_type_t));
PNX_EXTERN pn_handler_t *pn_handler_new(void (*dispatch)(pn_handler_t *, pn_event_t *, pn_event_type_t), size_t size,
@@ -65,7 +66,7 @@ PNX_EXTERN pn_handler_t *pn_reactor_get_global_handler(pn_reactor_t *reactor);
PNX_EXTERN void pn_reactor_set_global_handler(pn_reactor_t *reactor, pn_handler_t *handler);
PNX_EXTERN pn_handler_t *pn_reactor_get_handler(pn_reactor_t *reactor);
PNX_EXTERN void pn_reactor_set_handler(pn_reactor_t *reactor, pn_handler_t *handler);
-PNX_EXTERN pn_list_t *pn_reactor_children(pn_reactor_t *reactor);
+PNX_EXTERN struct pn_list_t *pn_reactor_children(pn_reactor_t *reactor);
PNX_EXTERN pn_selectable_t *pn_reactor_selectable(pn_reactor_t *reactor);
PNX_EXTERN void pn_reactor_update(pn_reactor_t *reactor, pn_selectable_t *selectable);
PNX_EXTERN pn_acceptor_t *pn_reactor_acceptor(pn_reactor_t *reactor, const char *host, const char *port,
diff --git a/c/src/core/buffer.h b/c/src/core/buffer.h
index b9bd7573d..0b3f8fa77 100644
--- a/c/src/core/buffer.h
+++ b/c/src/core/buffer.h
@@ -23,9 +23,10 @@
*/
#include <proton/import_export.h>
-#include <proton/object.h>
#include <proton/types.h>
+#include "core/object_private.h"
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/c/src/core/event.c b/c/src/core/event.c
index 3f81f7075..13eefdd41 100644
--- a/c/src/core/event.c
+++ b/c/src/core/event.c
@@ -18,11 +18,14 @@
* under the License.
*
*/
-#include <stdio.h>
+
#include <proton/object.h>
#include <proton/event.h>
-#include <proton/reactor.h>
+
+#include "core/object_private.h"
+
#include <assert.h>
+#include <stdio.h>
struct pn_collector_t {
pn_list_t *pool;
diff --git a/c/src/core/memory.h b/c/src/core/memory.h
index 23a448ad3..d9818fc22 100644
--- a/c/src/core/memory.h
+++ b/c/src/core/memory.h
@@ -22,7 +22,7 @@
*
*/
-#include <proton/object.h>
+#include "core/object_private.h"
#include <stddef.h>
diff --git a/c/src/core/object/object.c b/c/src/core/object/object.c
index e498f9fb0..2b2eadf23 100644
--- a/c/src/core/object/object.c
+++ b/c/src/core/object/object.c
@@ -49,7 +49,8 @@ int pn_void_refcount(void *object) { return -1; }
#define pn_void_compare NULL
#define pn_void_inspect NULL
-const pn_class_t PN_VOID[] = {PN_METACLASS(pn_void)};
+static const pn_class_t PN_VOID_S = PN_METACLASS(pn_void);
+const pn_class_t *PN_VOID = &PN_VOID_S;
typedef struct {
const pn_class_t *clazz;
@@ -461,4 +462,5 @@ int pn_strongref_refcount(void *object)
#define pn_strongref_compare pn_compare
#define pn_strongref_inspect pn_inspect
-const pn_class_t PN_OBJECT[] = {PN_METACLASS(pn_strongref)};
+static const pn_class_t PN_OBJECT_S = PN_METACLASS(pn_strongref);
+const pn_class_t *PN_OBJECT = &PN_OBJECT_S;
diff --git a/c/include/proton/object.h b/c/src/core/object_private.h
similarity index 64%
copy from c/include/proton/object.h
copy to c/src/core/object_private.h
index 771c692c3..9b277c28a 100644
--- a/c/include/proton/object.h
+++ b/c/src/core/object_private.h
@@ -1,5 +1,5 @@
-#ifndef PROTON_OBJECT_H
-#define PROTON_OBJECT_H 1
+#ifndef PROTON_OBJECT_PRIVATE_H
+#define PROTON_OBJECT_PRIVATE_H 1
/*
*
@@ -22,7 +22,8 @@
*
*/
-#include <proton/cid.h>
+#include "proton/object.h"
+
#include <proton/types.h>
#include <stdarg.h>
#include <proton/type_compat.h>
@@ -39,39 +40,28 @@ extern "C" {
typedef intptr_t pn_shandle_t;
-typedef struct pn_string_t pn_string_t;
typedef struct pn_list_t pn_list_t;
+typedef struct pn_string_t pn_string_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;
struct pn_class_t {
- const char *name;
- pn_cid_t cid;
- void *(*newinst)(const pn_class_t *, size_t);
- void (*initialize)(void *);
- void (*incref)(void *);
- void (*decref)(void *);
- int (*refcount)(void *);
- void (*finalize)(void *);
- void (*free)(void *);
- uintptr_t (*hashcode)(void *);
- intptr_t (*compare)(void *, void *);
- int (*inspect)(void *, pn_string_t *);
+ const char *name;
+ pn_cid_t cid;
+ void *(*newinst)(const pn_class_t *, size_t);
+ void (*initialize)(void *);
+ void (*incref)(void *);
+ void (*decref)(void *);
+ int (*refcount)(void *);
+ void (*finalize)(void *);
+ void (*free)(void *);
+ uintptr_t (*hashcode)(void *);
+ intptr_t (*compare)(void *, void *);
+ int (*inspect)(void *, pn_string_t *);
};
-/* Hack alert: Declare these as arrays so we can treat the name of the single
- object as the address */
-PN_EXTERN extern const pn_class_t PN_DEFAULT[];
-PN_EXTERN extern const pn_class_t PN_OBJECT[];
-PN_EXTERN extern const pn_class_t PN_VOID[];
-PN_EXTERN extern const pn_class_t PN_WEAKREF[];
-
-PN_EXTERN void pn_object_incref(void *object);
-
-#define PN_CLASSCLASS(PREFIX) PREFIX ## __class
-
#define PN_CLASS(PREFIX) { \
#PREFIX, \
CID_ ## PREFIX, \
@@ -102,17 +92,12 @@ 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*));
+/* Hack alert: Declare these as arrays so we can treat the name of the single
+ object as the address */
+PN_EXTERN extern const pn_class_t PN_DEFAULT[];
+PN_EXTERN extern const pn_class_t PN_WEAKREF[];
-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);
-PN_EXTERN int pn_void_refcount(void *object);
+#define PN_CLASSCLASS(PREFIX) PREFIX ## __class
/* Class to identify a plain C struct in a pn_event_t. No refcounting or memory management. */
#define PN_STRUCT_CLASSDEF(PREFIX) \
@@ -131,10 +116,6 @@ const pn_class_t PN_CLASSCLASS(PREFIX)[] = {{ \
NULL, /* _inspect */ \
}}; \
-PN_EXTERN pn_cid_t pn_class_id(const pn_class_t *clazz);
-PN_EXTERN const char *pn_class_name(const pn_class_t *clazz);
-PN_EXTERN void *pn_class_new(const pn_class_t *clazz, size_t size);
-
PN_EXTERN void *pn_class_incref(const pn_class_t *clazz, void *object);
PN_EXTERN int pn_class_refcount(const pn_class_t *clazz, void *object);
PN_EXTERN int pn_class_decref(const pn_class_t *clazz, void *object);
@@ -145,34 +126,29 @@ PN_EXTERN intptr_t pn_class_compare(const pn_class_t *clazz, void *a, void *b);
PN_EXTERN bool pn_class_equals(const pn_class_t *clazz, void *a, void *b);
PN_EXTERN int pn_class_inspect(const pn_class_t *clazz, void *object, pn_string_t *dst);
-/* pn_incref, pn_decref and pn_refcount are for internal use by the proton
- * library, the should not be called by application code. Application code
- * should use the appropriate pn_*_free function (pn_link_free, pn_session_free
- * etc.) when it is finished with a proton value. Proton values should only be
- * used when handling a pn_event_t that refers to them.
- */
-PN_EXTERN void *pn_incref(void *object);
-PN_EXTERN int pn_decref(void *object);
-PN_EXTERN int pn_refcount(void *object);
-PN_EXTERN void pn_free(void *object);
-PN_EXTERN const pn_class_t *pn_class(void* object);
+PN_EXTERN void pn_object_incref(void *object);
+
+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);
+PN_EXTERN int pn_void_refcount(void *object);
+
+PN_EXTERN int pn_inspect(void *object, pn_string_t *dst);
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);
PN_EXTERN void *pn_list_get(pn_list_t *list, int index);
-PN_EXTERN void pn_list_set(pn_list_t *list, int index, void *value);
PN_EXTERN int pn_list_add(pn_list_t *list, void *value);
-PN_EXTERN void *pn_list_pop(pn_list_t *list);
-PN_EXTERN ssize_t pn_list_index(pn_list_t *list, void *value);
PN_EXTERN bool pn_list_remove(pn_list_t *list, void *value);
+void pn_list_set(pn_list_t *list, int index, void *value);
+void *pn_list_pop(pn_list_t *list);
+PN_EXTERN ssize_t pn_list_index(pn_list_t *list, void *value);
PN_EXTERN void pn_list_del(pn_list_t *list, int index, int n);
-PN_EXTERN void pn_list_clear(pn_list_t *list);
-PN_EXTERN void pn_list_iterator(pn_list_t *list, pn_iterator_t *iter);
+void pn_list_clear(pn_list_t *list);
+void pn_list_iterator(pn_list_t *list, pn_iterator_t *iter);
PN_EXTERN void pn_list_minpush(pn_list_t *list, void *value);
PN_EXTERN void *pn_list_minpop(pn_list_t *list);
@@ -198,66 +174,36 @@ PN_EXTERN uintptr_t pn_hash_key(pn_hash_t *hash, pn_handle_t entry);
PN_EXTERN void *pn_hash_value(pn_hash_t *hash, pn_handle_t entry);
PN_EXTERN pn_string_t *pn_string(const char *bytes);
-PN_EXTERN pn_string_t *pn_stringn(const char *bytes, size_t n);
PN_EXTERN const char *pn_string_get(pn_string_t *string);
+PN_EXTERN pn_string_t *pn_stringn(const char *bytes, size_t n);
PN_EXTERN size_t pn_string_size(pn_string_t *string);
PN_EXTERN int pn_string_set(pn_string_t *string, const char *bytes);
PN_EXTERN int pn_string_setn(pn_string_t *string, const char *bytes, size_t n);
-PN_EXTERN ssize_t pn_string_put(pn_string_t *string, char *dst);
-PN_EXTERN void pn_string_clear(pn_string_t *string);
+ssize_t pn_string_put(pn_string_t *string, char *dst);
+void pn_string_clear(pn_string_t *string);
PN_EXTERN int pn_string_format(pn_string_t *string, const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
#endif
;
-PN_EXTERN int pn_string_vformat(pn_string_t *string, const char *format, va_list ap);
+int pn_string_vformat(pn_string_t *string, const char *format, va_list ap);
PN_EXTERN int pn_string_addf(pn_string_t *string, const char *format, ...)
#ifdef __GNUC__
- __attribute__ ((format (printf, 2, 3)))
+__attribute__ ((format (printf, 2, 3)))
#endif
- ;
-PN_EXTERN int pn_string_vaddf(pn_string_t *string, const char *format, va_list ap);
-PN_EXTERN int pn_string_grow(pn_string_t *string, size_t capacity);
-PN_EXTERN char *pn_string_buffer(pn_string_t *string);
-PN_EXTERN size_t pn_string_capacity(pn_string_t *string);
-PN_EXTERN int pn_string_resize(pn_string_t *string, size_t size);
-PN_EXTERN int pn_string_copy(pn_string_t *string, pn_string_t *src);
+;
+int pn_string_vaddf(pn_string_t *string, const char *format, va_list ap);
+int pn_string_grow(pn_string_t *string, size_t capacity);
+char *pn_string_buffer(pn_string_t *string);
+size_t pn_string_capacity(pn_string_t *string);
+int pn_string_resize(pn_string_t *string, size_t size);
+int pn_string_copy(pn_string_t *string, pn_string_t *src);
PN_EXTERN pn_iterator_t *pn_iterator(void);
PN_EXTERN void *pn_iterator_start(pn_iterator_t *iterator,
- pn_iterator_next_t next, size_t size);
+ pn_iterator_next_t next, size_t size);
PN_EXTERN void *pn_iterator_next(pn_iterator_t *iterator);
-#define PN_LEGCTX ((pn_handle_t) 0)
-
-/**
- PN_HANDLE is a trick to define a unique identifier by using the address of a static variable.
- You MUST NOT use it in a .h file, since it must be defined uniquely in one compilation unit.
- Your .h file can provide access to the handle (if needed) via a function. For example:
-
- /// my_thing.h
- pn_handle_t get_my_thing(void);
-
- /// my_thing.c
- PN_HANDLE(MY_THING);
- pn_handle_t get_my_thing(void) { return MY_THING; }
-
- Note that the name "MY_THING" is not exported and is not required to be
- unique except in the .c file. The linker will guarantee that the *address* of
- MY_THING, as returned by get_my_thing() *is* unique across the entire linked
- executable.
- */
-#define PN_HANDLE(name) \
- static const char _PN_HANDLE_ ## name = 0; \
- static const pn_handle_t name = ((pn_handle_t) &_PN_HANDLE_ ## name);
-
-PN_EXTERN pn_record_t *pn_record(void);
-PN_EXTERN void pn_record_def(pn_record_t *record, pn_handle_t key, const pn_class_t *clazz);
-PN_EXTERN bool pn_record_has(pn_record_t *record, pn_handle_t key);
-PN_EXTERN void *pn_record_get(pn_record_t *record, pn_handle_t key);
-PN_EXTERN void pn_record_set(pn_record_t *record, pn_handle_t key, void *value);
-PN_EXTERN void pn_record_clear(pn_record_t *record);
-
/**
* @endcond
*/
@@ -266,4 +212,4 @@ PN_EXTERN void pn_record_clear(pn_record_t *record);
}
#endif
-#endif /* object.h */
+#endif // PROTON_OBJECT_PRIVATE_H
diff --git a/c/src/core/value_dump.h b/c/src/core/value_dump.h
index 0f6418f5a..3da41249c 100644
--- a/c/src/core/value_dump.h
+++ b/c/src/core/value_dump.h
@@ -24,6 +24,8 @@
#include "proton/types.h"
+#include "core/object_private.h"
+
struct pn_fixed_string_t;
size_t pni_value_dump(pn_bytes_t frame, struct pn_fixed_string_t *output);
diff --git a/c/src/handlers/handshaker.c b/c/src/handlers/handshaker.c
index f52ed86da..6bf42150c 100644
--- a/c/src/handlers/handshaker.c
+++ b/c/src/handlers/handshaker.c
@@ -19,10 +19,14 @@
*
*/
+#include <proton/handlers.h>
+
#include <proton/connection.h>
#include <proton/session.h>
#include <proton/link.h>
-#include <proton/handlers.h>
+
+#include "core/object_private.h"
+
#include <assert.h>
static void pn_handshaker_dispatch(pn_handler_t *handler, pn_event_t *event, pn_event_type_t type) {
diff --git a/c/src/handlers/iohandler.c b/c/src/handlers/iohandler.c
index f8357c5b0..86d767a82 100644
--- a/c/src/handlers/iohandler.c
+++ b/c/src/handlers/iohandler.c
@@ -19,12 +19,15 @@
*
*/
+#include <proton/handlers.h>
+
+#include <proton/transport.h>
+
+#include "core/object_private.h"
#include "reactor/io.h"
#include "reactor/reactor.h"
#include "reactor/selector.h"
-#include <proton/handlers.h>
-#include <proton/transport.h>
#include <assert.h>
static const char pni_selector_handle = 0;
diff --git a/c/src/messenger/subscription.c b/c/src/messenger/subscription.c
index c10d3c7cb..b692e1a17 100644
--- a/c/src/messenger/subscription.c
+++ b/c/src/messenger/subscription.c
@@ -22,11 +22,13 @@
#include "subscription.h"
#include <proton/messenger.h>
-#include <proton/object.h>
+
+#include "core/object_private.h"
+#include "messenger.h"
+
#include <assert.h>
#include <string.h>
-#include "messenger.h"
struct pn_subscription_t {
pn_messenger_t *messenger;
diff --git a/c/src/messenger/subscription.h b/c/src/messenger/subscription.h
index 382b25a9c..38ff4cdae 100644
--- a/c/src/messenger/subscription.h
+++ b/c/src/messenger/subscription.h
@@ -25,6 +25,8 @@
#include <proton/messenger.h>
#include <proton/object.h>
+#include "core/object_private.h"
+
extern const pn_class_t PN_CLASSCLASS(pn_subscription);
pn_subscription_t *pn_subscription(pn_messenger_t *messenger,
diff --git a/c/src/reactor/acceptor.c b/c/src/reactor/acceptor.c
index cc3b7d3ee..9fb3fda69 100644
--- a/c/src/reactor/acceptor.c
+++ b/c/src/reactor/acceptor.c
@@ -28,6 +28,8 @@
#include "selectable.h"
#include "selector.h"
+#include "core/object_private.h"
+
#include <string.h>
pn_selectable_t *pn_reactor_selectable_transport(pn_reactor_t *reactor, pn_socket_t sock, pn_transport_t *transport);
diff --git a/c/src/reactor/connection.c b/c/src/reactor/connection.c
index 390a9fa2f..9189d954f 100644
--- a/c/src/reactor/connection.c
+++ b/c/src/reactor/connection.c
@@ -22,18 +22,20 @@
#define PN_USE_DEPRECATED_API 1
#include <proton/connection.h>
-#include <proton/object.h>
#include <proton/sasl.h>
#include <proton/ssl.h>
#include <proton/transport.h>
#include <proton/url.h>
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
+
+#include "core/object_private.h"
#include "io.h"
#include "selectable.h"
#include "reactor.h"
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
// XXX: overloaded for both directions
PN_HANDLE(PN_TRANCTX)
PN_HANDLE(PNI_CONN_PEER_ADDRESS)
diff --git a/c/src/reactor/handler.c b/c/src/reactor/handler.c
index 5cb3fe101..0bd2965ef 100644
--- a/c/src/reactor/handler.c
+++ b/c/src/reactor/handler.c
@@ -19,9 +19,11 @@
*
*/
-#include <proton/object.h>
#include <proton/reactor.h>
#include <proton/event.h>
+
+#include "core/object_private.h"
+
#include <string.h>
#include <assert.h>
diff --git a/c/src/reactor/io/posix/io.c b/c/src/reactor/io/posix/io.c
index 2ddb5c0c1..1c70b8c96 100644
--- a/c/src/reactor/io/posix/io.c
+++ b/c/src/reactor/io/posix/io.c
@@ -19,11 +19,10 @@
*
*/
+#include "core/object_private.h"
+#include "platform/platform.h" // pn_i_error_from_errno
#include "reactor/io.h"
#include "reactor/selector.h"
-#include "platform/platform.h" // pn_i_error_from_errno
-
-#include <proton/object.h>
#include <ctype.h>
#include <errno.h>
diff --git a/c/src/reactor/io/windows/iocp.h b/c/src/reactor/io/windows/iocp.h
index 327e89d3c..1a6bef76b 100644
--- a/c/src/reactor/io/windows/iocp.h
+++ b/c/src/reactor/io/windows/iocp.h
@@ -23,10 +23,11 @@
*/
#include <proton/import_export.h>
-#include <proton/object.h>
#include <proton/selectable.h>
#include <proton/type_compat.h>
+#include "core/object_private.h"
+
typedef struct pni_acceptor_t pni_acceptor_t;
typedef struct write_result_t write_result_t;
typedef struct read_result_t read_result_t;
diff --git a/c/src/reactor/reactor.c b/c/src/reactor/reactor.c
index df92cbe05..dbb9e8e26 100644
--- a/c/src/reactor/reactor.c
+++ b/c/src/reactor/reactor.c
@@ -19,12 +19,12 @@
*
*/
+#include "core/object_private.h"
#include "io.h"
#include "reactor.h"
#include "selectable.h"
#include "platform/platform.h" // pn_i_now
-#include <proton/object.h>
#include <proton/handlers.h>
#include <proton/event.h>
#include <proton/transport.h>
diff --git a/c/src/reactor/selectable.c b/c/src/reactor/selectable.c
index 220d1c9da..257989f3e 100644
--- a/c/src/reactor/selectable.c
+++ b/c/src/reactor/selectable.c
@@ -22,8 +22,8 @@
#include "selectable.h"
#include <proton/error.h>
-#include <proton/object.h>
+#include "core/object_private.h"
#include "io.h"
#include <assert.h>
diff --git a/c/src/reactor/selectable.h b/c/src/reactor/selectable.h
index 251e6e238..433d6656b 100644
--- a/c/src/reactor/selectable.h
+++ b/c/src/reactor/selectable.h
@@ -29,6 +29,8 @@
#include <proton/selectable.h>
#include <proton/object.h>
+#include "core/object_private.h"
+
extern const pn_class_t PN_CLASSCLASS(pn_selectable);
void *pni_selectable_get_context(pn_selectable_t *selectable);
diff --git a/c/src/reactor/timer.c b/c/src/reactor/timer.c
index 5283a8fea..1f552b349 100644
--- a/c/src/reactor/timer.c
+++ b/c/src/reactor/timer.c
@@ -19,8 +19,10 @@
*
*/
-#include <proton/object.h>
#include <proton/reactor.h>
+
+#include "core/object_private.h"
+
#include <assert.h>
struct pn_task_t {
diff --git a/c/tests/event_test.cpp b/c/tests/event_test.cpp
index 3d2faf695..4045a8fd7 100644
--- a/c/tests/event_test.cpp
+++ b/c/tests/event_test.cpp
@@ -19,10 +19,11 @@
*
*/
-#include "./pn_test.hpp"
+#include "pn_test.hpp"
#include <proton/event.h>
-#include <proton/object.h>
+
+#include "core/object_private.h"
TEST_CASE("event_collector") {
pn_collector_t *collector = pn_collector();
diff --git a/c/tests/object_test.cpp b/c/tests/object_test.cpp
index bd9d27eeb..52fbab9e6 100644
--- a/c/tests/object_test.cpp
+++ b/c/tests/object_test.cpp
@@ -19,9 +19,10 @@
*
*/
-#include "./pn_test.hpp"
+#include "pn_test.hpp"
+
+#include "core/object_private.h"
-#include <proton/object.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/c/tools/reactor-recv.c b/c/tools/reactor-recv.c
index 0d2fb5b55..649337cd4 100644
--- a/c/tools/reactor-recv.c
+++ b/c/tools/reactor-recv.c
@@ -33,6 +33,7 @@
#include "proton/url.h"
#include "msgr-common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/python/cproton.i b/python/cproton.i
index 7a3407ee1..125999ca8 100644
--- a/python/cproton.i
+++ b/python/cproton.i
@@ -26,11 +26,11 @@
/* TODO: Remove once pn_work_head() and related have been removed from Proton */
#define PN_USE_DEPRECATED_API 1
+#include <proton/cid.h>
#include <proton/engine.h>
#include <proton/message.h>
#include <proton/object.h>
#include <proton/sasl.h>
-#include <proton/messenger.h>
#include <proton/ssl.h>
/*
diff --git a/ruby/cproton.i b/ruby/cproton.i
index 00b3593dc..ae2a7ef7b 100644
--- a/ruby/cproton.i
+++ b/ruby/cproton.i
@@ -22,6 +22,7 @@
#define PN_USE_DEPRECATED_API 1
#include <proton/connection_driver.h>
+#include <proton/cid.h>
#include <proton/engine.h>
#include <proton/handlers.h>
#include <proton/message.h>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org