aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPo-Chuan Hsieh <sunpoet@FreeBSD.org>2024-07-13 20:18:58 +0000
committerVladimir Druzenko <vvd@FreeBSD.org>2024-07-22 18:49:15 +0000
commite22d860943454d8716bb018ca323020a09fdd756 (patch)
tree9e9879a7297d5c1a2ded193865fed1fa625260f2
parent3a3b9d070bfeb8a93c1defb3fc0aa4614bb14059 (diff)
downloadports-e22d860943454d8716bb018ca323020a09fdd756.tar.gz
ports-e22d860943454d8716bb018ca323020a09fdd756.zip
dns/py-ldns: Fix build with swig 4.2.0+
PR: 279489 Obtained from: https://github.com/NLnetLabs/ldns/pull/231 (cherry picked from commit 2db969b4413e91ca9c4ff0a323184fd618e80dec)
-rw-r--r--dns/ldns/files/patch-swig64
1 files changed, 64 insertions, 0 deletions
diff --git a/dns/ldns/files/patch-swig b/dns/ldns/files/patch-swig
new file mode 100644
index 000000000000..4d5ae635fbc4
--- /dev/null
+++ b/dns/ldns/files/patch-swig
@@ -0,0 +1,64 @@
+Obtained from: https://github.com/NLnetLabs/ldns/pull/231
+
+--- contrib/python/ldns_rdf.i.orig 2022-08-15 10:38:22 UTC
++++ contrib/python/ldns_rdf.i
+@@ -50,6 +50,7 @@
+ SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0));
+ }
+
++#if SWIG_VERSION < 0x040200
+ /*
+ * Automatic conversion of const (ldns_rdf *) parameter from string.
+ * Argument default value.
+@@ -95,6 +96,51 @@
+ SWIG_Python_str_DelForPy3($1_str); /* Is a empty macro for Python < 3. */
+ }
+ }
++
++#else
++/*
++ * Automatic conversion of const (ldns_rdf *) parameter from string.
++ * Argument default value.
++ */
++%typemap(arginit, noblock=1) const ldns_rdf *
++{
++ PyObject *$1_bytes = NULL;
++}
++
++/*
++ * Automatic conversion of const (ldns_rdf *) parameter from string.
++ * Preparation of arguments.
++ */
++%typemap(in, noblock=1) const ldns_rdf * (void* argp, $1_ltype tmp = 0, int res)
++{
++ if (Python_str_Check($input)) {
++ const char *$1_str = SWIG_PyUnicode_AsUTF8AndSize($input, NULL, &$1_bytes);
++ if ($1_str == NULL) {
++ %argument_fail(SWIG_TypeError, "char *", $symname, $argnum);
++ }
++ tmp = ldns_dname_new_frm_str($1_str);
++ if (tmp == NULL) {
++ %argument_fail(SWIG_TypeError, "char *", $symname, $argnum);
++ }
++ $1 = ($1_ltype) tmp;
++ } else {
++ res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_ldns_struct_rdf, 0 | 0);
++ if (!SWIG_IsOK(res)) {
++ %argument_fail(res, "ldns_rdf const *", $symname, $argnum);
++ }
++ $1 = ($1_ltype) argp;
++ }
++}
++
++/*
++ * Automatic conversion of const (ldns_rdf *) parameter from string.
++ * Freeing of allocated memory (it's a no op unless compiling for some older versions of the Python stable ABI).
++ */
++%typemap(freearg, noblock=1) const ldns_rdf *
++{
++ Py_XDECREF($1_bytes);
++}
++#endif
+
+ %nodefaultctor ldns_struct_rdf; /* No default constructor. */
+ %nodefaultdtor ldns_struct_rdf; /* No default destructor. */