From b8d0f5a7263abd556fb2605069f63fe0d4aef61d Mon Sep 17 00:00:00 2001 From: casey langen Date: Mon, 27 Jan 2020 09:26:33 -0800 Subject: [PATCH] Added mcsdk_handle_ok() and mcsdk_handle_cast() macros. --- src/core_c/CMakeLists.txt | 2 +- src/core_c/musikcore_c.h | 52 +++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/core_c/CMakeLists.txt b/src/core_c/CMakeLists.txt index f8fdf3c7c..db354d353 100644 --- a/src/core_c/CMakeLists.txt +++ b/src/core_c/CMakeLists.txt @@ -8,7 +8,7 @@ include_directories( .. ) -add_definitions(-DDEFINE_EXPORTS) +add_definitions(-DMCSDK_DEFINE_EXPORTS) add_library(musikcore_c SHARED ${CORE_C_SOURCES}) diff --git a/src/core_c/musikcore_c.h b/src/core_c/musikcore_c.h index 49e286d3e..ede0ba995 100644 --- a/src/core_c/musikcore_c.h +++ b/src/core_c/musikcore_c.h @@ -40,7 +40,7 @@ #include #include -#ifdef DEFINE_EXPORTS +#ifdef MCSDK_DEFINE_EXPORTS #ifdef WIN32 #define mcsdk_export extern "C" __declspec(dllexport) #else @@ -187,33 +187,37 @@ static const char* mcsdk_track_field_external_id = "external_id"; * */ -#define DEFINE_HANDLE(x) \ +#define mcsdk_define_handle(x) \ typedef struct x { \ void* opaque; \ } x; -DEFINE_HANDLE(mcsdk_internal); -DEFINE_HANDLE(mcsdk_resource); -DEFINE_HANDLE(mcsdk_value); -DEFINE_HANDLE(mcsdk_value_list); -DEFINE_HANDLE(mcsdk_map); -DEFINE_HANDLE(mcsdk_track); -DEFINE_HANDLE(mcsdk_map_list); -DEFINE_HANDLE(mcsdk_track_list); -DEFINE_HANDLE(mcsdk_track_list_editor); -DEFINE_HANDLE(mcsdk_svc_metadata); -DEFINE_HANDLE(mcsdk_svc_playback); -DEFINE_HANDLE(mcsdk_prefs); -DEFINE_HANDLE(mcsdk_audio_buffer); -DEFINE_HANDLE(mcsdk_audio_buffer_provider); -DEFINE_HANDLE(mcsdk_data_stream); -DEFINE_HANDLE(mcsdk_device); -DEFINE_HANDLE(mcsdk_device_list); -DEFINE_HANDLE(mcsdk_output); -DEFINE_HANDLE(mcsdk_decoder); -DEFINE_HANDLE(mcsdk_encoder); -DEFINE_HANDLE(mcsdk_blocking_encoder); -DEFINE_HANDLE(mcsdk_streaming_encoder); +#define mcsdk_handle_ok(x) x.opaque != NULL + +#define mcsdk_cast_handle(x) { x.opaque } + +mcsdk_define_handle(mcsdk_internal); +mcsdk_define_handle(mcsdk_resource); +mcsdk_define_handle(mcsdk_value); +mcsdk_define_handle(mcsdk_value_list); +mcsdk_define_handle(mcsdk_map); +mcsdk_define_handle(mcsdk_track); +mcsdk_define_handle(mcsdk_map_list); +mcsdk_define_handle(mcsdk_track_list); +mcsdk_define_handle(mcsdk_track_list_editor); +mcsdk_define_handle(mcsdk_svc_metadata); +mcsdk_define_handle(mcsdk_svc_playback); +mcsdk_define_handle(mcsdk_prefs); +mcsdk_define_handle(mcsdk_audio_buffer); +mcsdk_define_handle(mcsdk_audio_buffer_provider); +mcsdk_define_handle(mcsdk_data_stream); +mcsdk_define_handle(mcsdk_device); +mcsdk_define_handle(mcsdk_device_list); +mcsdk_define_handle(mcsdk_output); +mcsdk_define_handle(mcsdk_decoder); +mcsdk_define_handle(mcsdk_encoder); +mcsdk_define_handle(mcsdk_blocking_encoder); +mcsdk_define_handle(mcsdk_streaming_encoder); /* *