linuxonly: always define a stub function

This commit is contained in:
mappu 2024-09-01 18:50:19 +12:00
parent 2cd9fb6cca
commit 86ce4f70aa
3 changed files with 72 additions and 41 deletions

View File

@ -512,25 +512,39 @@ extern "C" {
for i, ctor := range c.Ctors {
if ctor.LinuxOnly {
ret.WriteString("#ifdef Q_OS_LINUX\n\n")
}
preamble, forwarding := emitParametersCABI2CppForwarding(ctor.Parameters)
ret.WriteString(fmt.Sprintf(
"%s* %s_new%s(%s) {\n"+
"%s"+
"\treturn new %s(%s);\n"+
"}\n"+
"\n",
cClassName, cClassName, maybeSuffix(i), emitParametersCabi(ctor, ""),
preamble,
c.ClassName, forwarding,
))
if ctor.LinuxOnly {
ret.WriteString("#endif /* Q_OS_LINUX */\n\n")
ret.WriteString(fmt.Sprintf(
"%s* %s_new%s(%s) {\n"+
"#ifdef Q_OS_LINUX\n"+
"%s"+
"\treturn new %s(%s);\n"+
"#else\n"+
"\treturn nullptr;\n"+
"#endif\n"+
"}\n"+
"\n",
cClassName, cClassName, maybeSuffix(i), emitParametersCabi(ctor, ""),
preamble,
c.ClassName, forwarding,
))
} else {
ret.WriteString(fmt.Sprintf(
"%s* %s_new%s(%s) {\n"+
"%s"+
"\treturn new %s(%s);\n"+
"}\n"+
"\n",
cClassName, cClassName, maybeSuffix(i), emitParametersCabi(ctor, ""),
preamble,
c.ClassName, forwarding,
))
}
}
for _, m := range c.Methods {
@ -667,21 +681,41 @@ extern "C" {
}
if m.LinuxOnly {
ret.WriteString("#ifdef Q_OS_LINUX\n\n")
}
ret.WriteString(fmt.Sprintf(
"%s %s_%s(%s) {\n"+
"#ifdef Q_OS_LINUX\n"+
"%s"+
"\t%s%s%s(%s);\n"+
"%s"+
"#else\n"+
"\t%s _ret_invalidOS;\n"+
"\treturn _ret_invalidOS;\n"+
"#endif\n"+
"}\n"+
"\n",
emitReturnTypeCabi(m.ReturnType), cClassName, m.SafeMethodName(), emitParametersCabi(m, cClassName+"*"),
preamble,
shouldReturn, callTarget, nativeMethodName, forwarding,
afterCall,
emitReturnTypeCabi(m.ReturnType),
))
ret.WriteString(fmt.Sprintf(
"%s %s_%s(%s) {\n"+
"%s"+
"\t%s%s%s(%s);\n"+
"%s"+
"}\n"+
"\n",
emitReturnTypeCabi(m.ReturnType), cClassName, m.SafeMethodName(), emitParametersCabi(m, cClassName+"*"),
preamble,
shouldReturn, callTarget, nativeMethodName, forwarding,
afterCall,
))
} else {
ret.WriteString(fmt.Sprintf(
"%s %s_%s(%s) {\n"+
"%s"+
"\t%s%s%s(%s);\n"+
"%s"+
"}\n"+
"\n",
emitReturnTypeCabi(m.ReturnType), cClassName, m.SafeMethodName(), emitParametersCabi(m, cClassName+"*"),
preamble,
shouldReturn, callTarget, nativeMethodName, forwarding,
afterCall,
))
}
if m.IsSignal && !m.HasHiddenParams {
exactSignal := `static_cast<void (` + c.ClassName + `::*)(` + emitParameterTypesCpp(m) + `)>(&` + c.ClassName + `::` + nativeMethodName + `)`
@ -696,10 +730,6 @@ extern "C" {
)
}
if m.LinuxOnly {
ret.WriteString("#endif /* Q_OS_LINUX */\n\n")
}
}
// Delete

View File

@ -352,14 +352,15 @@ uintptr_t QProcess_State(QProcess* self) {
return static_cast<uintptr_t>(ret);
}
#ifdef Q_OS_LINUX
int64_t QProcess_Pid(QProcess* self) {
#ifdef Q_OS_LINUX
return const_cast<const QProcess*>(self)->pid();
#else
int64_t _ret_invalidOS;
return _ret_invalidOS;
#endif
}
#endif /* Q_OS_LINUX */
long long QProcess_ProcessId(QProcess* self) {
return const_cast<const QProcess*>(self)->processId();
}

View File

@ -108,14 +108,14 @@ QSocketDescriptor* QSocketDescriptor_new2(QSocketDescriptor* param1) {
return new QSocketDescriptor(*param1);
}
#ifdef Q_OS_LINUX
QSocketDescriptor* QSocketDescriptor_new3(uintptr_t descriptor) {
#ifdef Q_OS_LINUX
return new QSocketDescriptor(static_cast<QSocketDescriptor::DescriptorType>(descriptor));
#else
return nullptr;
#endif
}
#endif /* Q_OS_LINUX */
bool QSocketDescriptor_IsValid(QSocketDescriptor* self) {
return const_cast<const QSocketDescriptor*>(self)->isValid();
}