codegen: CallError out-param instead of throwing wrappers

Per review, the generated sync wrappers expose the error channel as an
optional trailing parameter — add(a, b, &err) — rather than throwing:
explicit, stateless, works on temporaries, and existing call sites
compile unchanged (they keep default-on-failure, now with a qWarning so
failures are visible in the module log). The dispatch catch-all from the
previous commit stays: it contains author exceptions, it doesn't
introduce any.
This commit is contained in:
Dario Gabriel Lipicar
2026-06-12 09:32:07 -03:00
parent 8adb023863
commit bd24fb61ea
7 changed files with 48 additions and 33 deletions
+4 -4
View File
@@ -94,8 +94,8 @@ TEST(MakeHeaderTest, ContainsMethodDeclarations)
QJsonArray methods = makeTestMethods();
QString h = makeHeader("test_mod", "TestMod", methods);
EXPECT_TRUE(h.contains("int add(int a, int b)"));
EXPECT_TRUE(h.contains("void reset()"));
EXPECT_TRUE(h.contains("int add(int a, int b, logos::CallError* err = nullptr)"));
EXPECT_TRUE(h.contains("void reset(logos::CallError* err = nullptr)"));
// Non-invokable should not appear
EXPECT_FALSE(h.contains("internal"));
}
@@ -197,7 +197,7 @@ TEST(MakeHeaderTest, QVariantListAsyncOverload)
}
QString h = makeHeader("mod", "Mod", methods);
EXPECT_TRUE(h.contains("QVariantList getItems()"));
EXPECT_TRUE(h.contains("QVariantList getItems(logos::CallError* err = nullptr)"));
EXPECT_TRUE(h.contains("getItemsAsync("));
EXPECT_TRUE(h.contains("std::function<void(QVariantList)> callback"));
}
@@ -215,7 +215,7 @@ TEST(MakeHeaderTest, QVariantMapAsyncOverload)
}
QString h = makeHeader("mod", "Mod", methods);
EXPECT_TRUE(h.contains("QVariantMap getData()"));
EXPECT_TRUE(h.contains("QVariantMap getData(logos::CallError* err = nullptr)"));
EXPECT_TRUE(h.contains("getDataAsync("));
EXPECT_TRUE(h.contains("std::function<void(QVariantMap)> callback"));
}