From 5bf9ca0b55a040b58f7fea76a38d0a01602dbc2d Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 11 Dec 2023 22:10:37 +0800 Subject: [PATCH] QofIdType and QofIdTypeConst: handle similarly to const char* Previous swigged function- note the `new` is never deleted. Because they are both const char*, they must be swigged similarly to strings. static SCM _wrap_QOF_ID_BOOK_SCM () { #define FUNC_NAME "QOF-ID-BOOK-SCM" SCM gswig_result; SWIGUNUSED int gswig_list_p = 0; QofIdTypeConst result; result = QOF_ID_BOOK_SCM(); { QofIdTypeConst * resultptr; resultptr = new QofIdTypeConst((const QofIdTypeConst &) result); gswig_result = SWIG_NewPointerObj (resultptr, SWIGTYPE_p_QofIdTypeConst, 1); } return gswig_result; #undef FUNC_NAME } After this change: static SCM _wrap_QOF_ID_BOOK_SCM () { #define FUNC_NAME "QOF-ID-BOOK-SCM" SCM gswig_result; SWIGUNUSED int gswig_list_p = 0; QofIdType result; result = QOF_ID_BOOK_SCM(); gswig_result = result ? scm_from_utf8_string (result) : SCM_BOOL_F; return gswig_result; #undef FUNC_NAME } --- common/base-typemaps.i | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/base-typemaps.i b/common/base-typemaps.i index e70a365a56..5b807f0005 100644 --- a/common/base-typemaps.i +++ b/common/base-typemaps.i @@ -69,6 +69,16 @@ typedef char gchar; %typemap(in) time64 * (time64 t) "t = scm_to_int64($input); $1 = &t;" %typemap(out) time64 * " $result = ($1) ? scm_from_int64(*($1)) : SCM_BOOL_F; " +%typemap(in) QofIdType " $1 = scm_to_utf8_string ($input); " +%typemap(out) QofIdType " $result = $1 ? scm_from_utf8_string ($1) : SCM_BOOL_F; " +%typemap(freearg) QofIdType " g_free ((gpointer)$1); " +%typemap(newfree) QofIdType " g_free ((gpointer)$1); " + +%typemap(in) QofIdTypeConst " $1 = scm_to_utf8_string ($input); " +%typemap(out) QofIdTypeConst " $result = $1 ? scm_from_utf8_string ($1) : SCM_BOOL_F; " +%typemap(freearg) QofIdTypeConst " g_free ((gpointer)$1); " +%typemap(newfree) QofIdTypeConst " g_free ((gpointer)$1); " + %typemap(in) struct tm * (struct tm t, char *tzone) { SCM tm = $input; t.tm_sec = scm_to_int(SCM_SIMPLE_VECTOR_REF(tm, 0));