From: Willem Toorop Date: Fri, 12 Jul 2024 12:17:38 +0000 (+0200) Subject: Merge pull request #231 from wsfulton/swig-4.2.0-support X-Git-Tag: release-1.8.4-rc1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34fdb482e0142628f67deb526076c6c4f219d162;p=thirdparty%2Fldns.git Merge pull request #231 from wsfulton/swig-4.2.0-support const ldns_rdf * typemap fixes to support swig-4.2.0 --- 34fdb482e0142628f67deb526076c6c4f219d162 diff --cc contrib/python/ldns_rdf.i index 60daf1a7,4924b979..39f9af18 --- a/contrib/python/ldns_rdf.i +++ b/contrib/python/ldns_rdf.i @@@ -110,9 -95,53 +111,54 @@@ /* Is not NULL only when a conversion form string occurred. */ SWIG_Python_str_DelForPy3($1_str); /* Is a empty macro for Python < 3. */ } +#endif } + #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. */