From ea88165b086056bc357e8bc72c10f49620040438 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 8 Jun 2025 14:58:58 +0200 Subject: [PATCH] Fixes for enums --- TactilityC/Include/tt_app.h | 2 +- TactilityC/Include/tt_app_manifest.h | 12 ++++++------ TactilityC/Source/tt_app.cpp | 8 ++++---- TactilityC/Source/tt_timer.cpp | 2 -- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/TactilityC/Include/tt_app.h b/TactilityC/Include/tt_app.h index b1e97bd2..1e5dbbb0 100644 --- a/TactilityC/Include/tt_app.h +++ b/TactilityC/Include/tt_app.h @@ -18,7 +18,7 @@ BundleHandle _Nullable tt_app_get_parameters(AppHandle handle); * @param[in] result the result state to set * @param[in] bundle the result bundle to set */ -void tt_app_set_result(AppHandle handle, Result result, BundleHandle _Nullable bundle); +void tt_app_set_result(AppHandle handle, AppResult result, BundleHandle _Nullable bundle); /** @return true if a result was set for this app context */ bool tt_app_has_result(AppHandle handle); diff --git a/TactilityC/Include/tt_app_manifest.h b/TactilityC/Include/tt_app_manifest.h index 0640b1d3..7551b4f3 100644 --- a/TactilityC/Include/tt_app_manifest.h +++ b/TactilityC/Include/tt_app_manifest.h @@ -9,14 +9,14 @@ extern "C" { /** Important: These values must map to tt::app::Result values exactly */ typedef enum { - AppResultOk = 0, - AppResultCancelled = 1, - AppResultError = 2 -} Result; + APP_RESULT_OK = 0, + APP_RESULT_CANCELLED = 1, + APP_RESULT_ERROR = 2 +} AppResult; typedef void* AppHandle; -typedef unsigned int LaunchId; +typedef unsigned int AppLaunchId; /** Important: These function types must map to t::app types exactly */ typedef void* (*AppCreateData)(); @@ -25,7 +25,7 @@ typedef void (*AppOnCreate)(AppHandle app, void* _Nullable data); typedef void (*AppOnDestroy)(AppHandle app, void* _Nullable data); typedef void (*AppOnShow)(AppHandle app, void* _Nullable data, lv_obj_t* parent); typedef void (*AppOnHide)(AppHandle app, void* _Nullable data); -typedef void (*AppOnResult)(AppHandle app, void* _Nullable data, LaunchId launchId, Result result, BundleHandle resultData); +typedef void (*AppOnResult)(AppHandle app, void* _Nullable data, AppLaunchId launchId, AppResult result, BundleHandle resultData); typedef struct { /** The application's human-readable name */ diff --git a/TactilityC/Source/tt_app.cpp b/TactilityC/Source/tt_app.cpp index bf770720..2a50ddbf 100644 --- a/TactilityC/Source/tt_app.cpp +++ b/TactilityC/Source/tt_app.cpp @@ -10,9 +10,9 @@ BundleHandle _Nullable tt_app_get_parameters(AppHandle handle) { return (BundleHandle)HANDLE_AS_APP_CONTEXT(handle)->getParameters().get(); } -void tt_app_set_result(AppHandle handle, Result result, BundleHandle _Nullable bundle) { - auto shared_bundle = std::unique_ptr((tt::Bundle*)bundle); - HANDLE_AS_APP_CONTEXT(handle)->getApp()->setResult((tt::app::Result)result, std::move(shared_bundle)); +void tt_app_set_result(AppHandle handle, AppResult result, BundleHandle _Nullable bundle) { + auto shared_bundle = std::unique_ptr(static_cast(bundle)); + HANDLE_AS_APP_CONTEXT(handle)->getApp()->setResult(static_cast(result), std::move(shared_bundle)); } bool tt_app_has_result(AppHandle handle) { @@ -24,7 +24,7 @@ void tt_app_start(const char* appId) { } void tt_app_start_with_bundle(const char* appId, BundleHandle parameters) { - tt::app::start(appId, std::shared_ptr((tt::Bundle*)parameters)); + tt::app::start(appId, std::shared_ptr(static_cast(parameters))); } void tt_app_stop() { diff --git a/TactilityC/Source/tt_timer.cpp b/TactilityC/Source/tt_timer.cpp index 62ad2bbb..42143511 100644 --- a/TactilityC/Source/tt_timer.cpp +++ b/TactilityC/Source/tt_timer.cpp @@ -7,7 +7,6 @@ struct TimerWrapper { extern "C" { - TimerHandle tt_timer_alloc(TimerType type, TimerCallback callback, void* callbackContext) { auto wrapper = std::make_shared(); wrapper->timer = std::make_unique((tt::Timer::Type)type, [callback, callbackContext](){ callback(callbackContext); }); @@ -54,4 +53,3 @@ void tt_timer_set_thread_priority(TimerHandle handle, ThreadPriority priority) { } } -