Small fixes

* `stdlib` is not used / needed
* `miqt_strdup` doesn't exist
* consistently use nameprefix for `_ret`
This commit is contained in:
Jacek Sieka 2025-01-07 09:29:45 +01:00
parent 4c0d782bd3
commit 765592cca2
2 changed files with 2 additions and 5 deletions

View File

@ -376,7 +376,7 @@ func emitAssignCppToCabi(assignExpression string, p CppParameter, rvalue string)
afterCall += indent + "QByteArray " + namePrefix + "_b = " + namePrefix + "_ret->toUtf8();\n" afterCall += indent + "QByteArray " + namePrefix + "_b = " + namePrefix + "_ret->toUtf8();\n"
} else { } else {
shouldReturn = ifv(p.Const, "const ", "") + "QString " + p.ParameterName + "_ret = " shouldReturn = ifv(p.Const, "const ", "") + "QString " + namePrefix + "_ret = "
afterCall = indent + "// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory\n" afterCall = indent + "// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory\n"
afterCall += indent + "QByteArray " + namePrefix + "_b = " + namePrefix + "_ret.toUtf8();\n" afterCall += indent + "QByteArray " + namePrefix + "_b = " + namePrefix + "_ret.toUtf8();\n"
} }
@ -392,7 +392,7 @@ func emitAssignCppToCabi(assignExpression string, p CppParameter, rvalue string)
// C++ has given us a QByteArray. CABI needs this as a struct miqt_string // C++ has given us a QByteArray. CABI needs this as a struct miqt_string
// Do not free the data, the caller will free it // Do not free the data, the caller will free it
shouldReturn = ifv(p.Const, "const ", "") + "QByteArray " + p.ParameterName + "_qb = " shouldReturn = ifv(p.Const, "const ", "") + "QByteArray " + namePrefix + "_qb = "
afterCall += indent + "struct miqt_string " + namePrefix + "_ms;\n" afterCall += indent + "struct miqt_string " + namePrefix + "_ms;\n"
afterCall += indent + namePrefix + "_ms.len = " + namePrefix + "_qb.length();\n" afterCall += indent + namePrefix + "_ms.len = " + namePrefix + "_qb.length();\n"

View File

@ -3,7 +3,6 @@
#define MIQT_LIBMIQT_LIBMIQT_H #define MIQT_LIBMIQT_LIBMIQT_H
#include <string.h> #include <string.h>
#include <stdlib.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -25,8 +24,6 @@ struct miqt_map {
void* values; void* values;
}; };
struct miqt_string* miqt_strdup(const char* src, size_t len);
typedef const char const_char; typedef const char const_char;
#ifdef __cplusplus #ifdef __cplusplus