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/05/13 14:24:09 UTC

[qpid-proton] 05/09: PROTON-2542: Make the object system a bit clearer

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 0a770196301376069bcddf5c624cb3726b3f4a40
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Tue Apr 26 16:17:06 2022 -0400

    PROTON-2542: Make the object system a bit clearer
    
    Avoid duplicating identical function bodies; Use NULL entries where they
    have the same effect as the function specified.
---
 c/include/proton/object.h  |  9 +++------
 c/src/core/object/map.c    | 10 ++++++----
 c/src/core/object/object.c | 25 ++++++++++++++-----------
 python/cproton.i           | 10 +++-------
 python/setup.py            |  2 +-
 5 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/c/include/proton/object.h b/c/include/proton/object.h
index 0412c393..fb8236db 100644
--- a/c/include/proton/object.h
+++ b/c/include/proton/object.h
@@ -114,9 +114,9 @@ const pn_class_t PN_CLASSCLASS(PREFIX)[] = {{       \
   pn_void_refcount,                                 \
   NULL, /* _finalize */                             \
   NULL, /* _free */                                 \
-  pn_void_hashcode,                                 \
-  pn_void_compare,                                  \
-  pn_void_inspect                                   \
+  NULL, /* _hashcode */                             \
+  NULL, /* _compare */                              \
+  NULL, /* _inspect */                              \
 }};                                                 \
 
 PN_EXTERN pn_cid_t pn_class_id(const pn_class_t *clazz);
@@ -143,9 +143,6 @@ 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 uintptr_t pn_void_hashcode(void *object);
-PN_EXTERN intptr_t pn_void_compare(void *a, void *b);
-PN_EXTERN int pn_void_inspect(void *object, pn_string_t *dst);
 
 PN_EXTERN void *pn_object_new(const pn_class_t *clazz, size_t size);
 PN_EXTERN void pn_object_incref(void *object);
diff --git a/c/src/core/object/map.c b/c/src/core/object/map.c
index 38d64547..9ee154c8 100644
--- a/c/src/core/object/map.c
+++ b/c/src/core/object/map.c
@@ -397,12 +397,14 @@ static bool pni_identity_equals(void *a, void *b)
 
 #define CID_pni_uintptr CID_pn_void
 #define pni_uintptr_new NULL
-#define pni_uintptr_free NULL
 #define pni_uintptr_initialize NULL
-static void pni_uintptr_incref(void *object) {}
-static void pni_uintptr_decref(void *object) {}
-static int pni_uintptr_refcount(void *object) { return -1; }
 #define pni_uintptr_finalize NULL
+#define pni_uintptr_free NULL
+
+#define pni_uintptr_incref pn_void_incref
+#define pni_uintptr_decref pn_void_decref
+#define pni_uintptr_refcount pn_void_refcount
+
 #define pni_uintptr_hashcode NULL
 #define pni_uintptr_compare NULL
 #define pni_uintptr_inspect NULL
diff --git a/c/src/core/object/object.c b/c/src/core/object/object.c
index a664150d..040f4113 100644
--- a/c/src/core/object/object.c
+++ b/c/src/core/object/object.c
@@ -29,21 +29,23 @@
 #define pn_object_initialize NULL
 #define pn_object_finalize NULL
 #define pn_object_inspect NULL
-uintptr_t pn_object_hashcode(void *object) { return (uintptr_t) object; }
-intptr_t pn_object_compare(void *a, void *b) { return (intptr_t) a - (intptr_t) b; }
+#define pn_object_hashcode NULL
+#define pn_object_compare NULL
 
 const pn_class_t PN_OBJECT[] = {PN_CLASS(pn_object)};
 
-#define pn_void_initialize NULL
 void *pn_void_new(const pn_class_t *clazz, size_t size) { return pni_mem_allocate(clazz, size); }
+#define pn_void_initialize NULL
+#define pn_void_finalize NULL
+static void pn_void_free(void *object) { pni_mem_deallocate(PN_VOID, object); }
+
 void pn_void_incref(void* p) {}
 void pn_void_decref(void* p) {}
 int pn_void_refcount(void *object) { return -1; }
-#define pn_void_finalize NULL
-static void pn_void_free(void *object) { pni_mem_deallocate(PN_VOID, object); }
-uintptr_t pn_void_hashcode(void *object) { return (uintptr_t) object; }
-intptr_t pn_void_compare(void *a, void *b) { return (intptr_t) a - (intptr_t) b; }
-int pn_void_inspect(void *object, pn_string_t *dst) { return pn_string_addf(dst, "%p", object); }
+
+#define pn_void_hashcode NULL
+#define pn_void_compare NULL
+#define pn_void_inspect NULL
 
 const pn_class_t PN_VOID[] = {PN_METACLASS(pn_void)};
 
@@ -352,9 +354,10 @@ int pn_inspect(void *object, pn_string_t *dst)
 #define pn_weakref_finalize NULL
 #define pn_weakref_free NULL
 
-static void pn_weakref_incref(void *object) {}
-static void pn_weakref_decref(void *object) {}
-static int pn_weakref_refcount(void *object) { return -1; }
+#define pn_weakref_incref pn_void_incref
+#define pn_weakref_decref pn_void_decref
+#define pn_weakref_refcount pn_void_refcount
+
 static uintptr_t pn_weakref_hashcode(void *object) {
   return pn_hashcode(object);
 }
diff --git a/python/cproton.i b/python/cproton.i
index f12271df..6bb68e4b 100644
--- a/python/cproton.i
+++ b/python/cproton.i
@@ -422,9 +422,9 @@ int pn_ssl_get_cert_fingerprint(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_S
   #define pn_pyref_initialize NULL
   #define pn_pyref_finalize NULL
   #define pn_pyref_free NULL
-  #define pn_pyref_hashcode pn_void_hashcode
-  #define pn_pyref_compare pn_void_compare
-  #define pn_pyref_inspect pn_void_inspect
+  #define pn_pyref_hashcode NULL
+  #define pn_pyref_compare NULL
+  #define pn_pyref_inspect NULL
 
   static void pn_pyref_incref(void *object) {
     PyObject* p = (PyObject*) object;
@@ -444,10 +444,6 @@ int pn_ssl_get_cert_fingerprint(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_S
     return 1;
   }
 
-  static const pn_class_t *pn_pyref_reify(void *object) {
-    return PN_PYREF;
-  }
-
   const pn_class_t PN_PYREF[] = {PN_METACLASS(pn_pyref)};
 
   void *pn_py2void(PyObject *object) {
diff --git a/python/setup.py b/python/setup.py
index f677570a..5e7d0722 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -155,7 +155,7 @@ class BuildExtension(build_ext):
         """Check to see if the proper version of the Proton development library
         and headers are already installed
         """
-        return misc.pkg_config_version_installed('libqpid-proton-core', atleast='0')
+        return misc.pkg_config_version_installed('libqpid-proton-core', atleast='0.38')
 
     def use_installed_proton(self):
         """The Proton development headers and library are installed, update the


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