add universal qt-free provider interface#67
Merged
Conversation
83ca549 to
45c32cc
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a “universal” (std/nlohmann::json-based) provider-side interface alongside the existing Qt (QString/QVariant) provider interface, and factors Qt↔︎nlohmann JSON conversion helpers into a shared utility to support Qt-free provider implementations.
Changes:
- Added
LogosProviderObject“Std” virtuals (callMethodStd/getMethodsStd/setEventListenerStd) plus Qt-bridge helpers to delegate between Qt and universal APIs. - Introduced
logos_json_convert.{h,cpp}to centralize QVariant↔︎nlohmann and method-metadata-to-JSON conversion. - Updated build/packaging (CMake + Nix) and refactored
logos_api_client.cppto use the shared conversion helpers.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
nix/include.nix |
Adds the new json conversion source/header to the Nix packaging file list. |
cpp/logos_provider_object.h |
Extends the provider interface with universal (std/json) virtuals and bridge helpers. |
cpp/logos_provider_object.cpp |
Implements default universal virtuals and the Qt↔︎Std bridge helper logic. |
cpp/logos_json_convert.h |
Declares shared Qt↔︎nlohmann conversion APIs and LogosMethodMetadata. |
cpp/logos_json_convert.cpp |
Implements shared conversion functions and method metadata JSON formatting. |
cpp/logos_api_client.cpp |
Replaces local helper implementations with calls into logos_json_convert. |
cpp/CMakeLists.txt |
Adds the new conversion files to the build and installs the header. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| virtual ~LogosProviderObject() = default; | ||
|
|
||
| using EventCallback = std::function<void(const QString&, const QVariantList&)>; | ||
| using UniversalEventCallback = std::function<void(const std::string&, const std::string&)>; |
Comment on lines
+50
to
+58
| QVariantList qData; | ||
| QJsonDocument doc = QJsonDocument::fromJson( | ||
| QByteArray::fromStdString(data)); | ||
| if (doc.isArray()) { | ||
| for (const QJsonValue& v : doc.array()) | ||
| qData.append(v.toVariant()); | ||
| } else { | ||
| qData.append(QString::fromStdString(data)); | ||
| } |
Comment on lines
22
to
+30
| // Module authors do NOT implement this directly — they inherit LogosProviderBase. | ||
| // | ||
| // Two parallel virtual interfaces: | ||
| // Qt interface: callMethod / getMethods / setEventListener (pure virtual) | ||
| // Universal interface: callMethodStd / getMethodsStd / setEventListenerStd (defaulted) | ||
| // | ||
| // Providers override ONE set. Those going Qt-free override the Std versions | ||
| // and delegate the Qt ones via the provided callMethodStdBridge / getMethodsStdBridge | ||
| // helpers (one-line overrides). |
Comment on lines
+60
to
+70
| if (j.is_null()) | ||
| return QVariant(); | ||
| if (j.is_boolean()) | ||
| return QVariant(j.get<bool>()); | ||
| if (j.is_number_integer()) | ||
| return QVariant(static_cast<qlonglong>(j.get<int64_t>())); | ||
| if (j.is_number_float()) | ||
| return QVariant(j.get<double>()); | ||
| if (j.is_string()) | ||
| return QVariant(QString::fromStdString(j.get<std::string>())); | ||
| if (j.is_object()) { |
Comment on lines
+88
to
+96
| if (arg.is_string()) | ||
| result.append(QString::fromStdString(arg.get<std::string>())); | ||
| else if (arg.is_boolean()) | ||
| result.append(arg.get<bool>()); | ||
| else if (arg.is_number_integer()) | ||
| result.append(static_cast<qlonglong>(arg.get<int64_t>())); | ||
| else if (arg.is_number_float()) | ||
| result.append(arg.get<double>()); | ||
| else if (arg.is_null()) |
add universal qt-free provider interface address review
45c32cc to
92e6f99
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.