From 36eb9a0d91ea5aa19b41e0b35f959f102b1a4243 Mon Sep 17 00:00:00 2001 From: Ming Li Date: Tue, 8 Sep 2020 15:01:04 +0200 Subject: [PATCH 1/2] rename function names related to versions. The current function name is quite generic and it's easy to conflict with other functions in a project since they're C functions --- easy_profiler_core/include/easy/profiler.h | 20 ++++++++++---------- easy_profiler_core/profiler.cpp | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/easy_profiler_core/include/easy/profiler.h b/easy_profiler_core/include/easy/profiler.h index 7a735ba..d8bd570 100644 --- a/easy_profiler_core/include/easy/profiler.h +++ b/easy_profiler_core/include/easy/profiler.h @@ -670,19 +670,19 @@ namespace profiler { \ingroup profiler */ - PROFILER_API uint8_t versionMajor(); + PROFILER_API uint8_t apiVersionMajor(); /** Returns current minor version. \ingroup profiler */ - PROFILER_API uint8_t versionMinor(); + PROFILER_API uint8_t apiVersionMinor(); /** Returns current version patch. \ingroup profiler */ - PROFILER_API uint16_t versionPatch(); + PROFILER_API uint16_t apiVersionPatch(); /** Returns current version in 32-bit integer format. @@ -691,7 +691,7 @@ namespace profiler { \ingroup profiler */ - PROFILER_API uint32_t version(); + PROFILER_API uint32_t apiVersion(); /** Returns current version string. @@ -699,7 +699,7 @@ namespace profiler { \ingroup profiler */ - PROFILER_API const char* versionName(); + PROFILER_API const char* apiVersionName(); /** Returns true if current thread has been marked as Main. Otherwise, returns false. @@ -790,11 +790,11 @@ namespace profiler { inline void startListen(uint16_t = ::profiler::DEFAULT_PORT) { } inline void stopListen() { } inline EASY_CONSTEXPR_FCN bool isListening() { return false; } - inline EASY_CONSTEXPR_FCN uint8_t versionMajor() { return 0; } - inline EASY_CONSTEXPR_FCN uint8_t versionMinor() { return 0; } - inline EASY_CONSTEXPR_FCN uint16_t versionPatch() { return 0; } - inline EASY_CONSTEXPR_FCN uint32_t version() { return 0; } - inline EASY_CONSTEXPR_FCN const char* versionName() { return "v0.0.0_disabled"; } + inline EASY_CONSTEXPR_FCN uint8_t apiVersionMajor() { return 0; } + inline EASY_CONSTEXPR_FCN uint8_t apiVersionMinor() { return 0; } + inline EASY_CONSTEXPR_FCN uint16_t apiVersionPatch() { return 0; } + inline EASY_CONSTEXPR_FCN uint32_t apiVersion() { return 0; } + inline EASY_CONSTEXPR_FCN const char* apiVersionName() { return "v0.0.0_disabled"; } inline EASY_CONSTEXPR_FCN bool isMainThread() { return false; } inline EASY_CONSTEXPR_FCN timestamp_t this_thread_frameTime(Duration = ::profiler::MICROSECONDS) { return 0; } inline EASY_CONSTEXPR_FCN timestamp_t this_thread_frameTimeLocalMax(Duration = ::profiler::MICROSECONDS) { return 0; } diff --git a/easy_profiler_core/profiler.cpp b/easy_profiler_core/profiler.cpp index cb13be2..4dd8b86 100644 --- a/easy_profiler_core/profiler.cpp +++ b/easy_profiler_core/profiler.cpp @@ -85,7 +85,7 @@ extern const uint32_t EASY_PROFILER_VERSION = (static_cast(EASY_PROFIL extern "C" { -PROFILER_API uint8_t versionMajor() +PROFILER_API uint8_t apiVersionMajor() { static_assert(0 <= EASY_PROFILER_VERSION_MAJOR && EASY_PROFILER_VERSION_MAJOR <= 255, "EASY_PROFILER_VERSION_MAJOR must be defined in range [0, 255]"); @@ -93,7 +93,7 @@ PROFILER_API uint8_t versionMajor() return EASY_PROFILER_VERSION_MAJOR; } -PROFILER_API uint8_t versionMinor() +PROFILER_API uint8_t apiVersionMinor() { static_assert(0 <= EASY_PROFILER_VERSION_MINOR && EASY_PROFILER_VERSION_MINOR <= 255, "EASY_PROFILER_VERSION_MINOR must be defined in range [0, 255]"); @@ -101,7 +101,7 @@ PROFILER_API uint8_t versionMinor() return EASY_PROFILER_VERSION_MINOR; } -PROFILER_API uint16_t versionPatch() +PROFILER_API uint16_t apiVersionPatch() { static_assert(0 <= EASY_PROFILER_VERSION_PATCH && EASY_PROFILER_VERSION_PATCH <= 65535, "EASY_PROFILER_VERSION_PATCH must be defined in range [0, 65535]"); @@ -109,12 +109,12 @@ PROFILER_API uint16_t versionPatch() return EASY_PROFILER_VERSION_PATCH; } -PROFILER_API uint32_t version() +PROFILER_API uint32_t apiVersion() { return EASY_PROFILER_VERSION; } -PROFILER_API const char* versionName() +PROFILER_API const char* apiVersionName() { #ifdef EASY_PROFILER_API_DISABLED return EASY_PROFILER_PRODUCT_VERSION "_disabled"; From 67edc2d77fa0c75749273a43d5772f4d7914d74c Mon Sep 17 00:00:00 2001 From: Ming Li Date: Wed, 28 Aug 2024 20:55:26 +0200 Subject: [PATCH 2/2] Rename the function now() as well --- easy_profiler_core/include/easy/profiler.h | 6 +++--- easy_profiler_core/profiler.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/easy_profiler_core/include/easy/profiler.h b/easy_profiler_core/include/easy/profiler.h index d8bd570..ac4b530 100644 --- a/easy_profiler_core/include/easy/profiler.h +++ b/easy_profiler_core/include/easy/profiler.h @@ -464,7 +464,7 @@ namespace profiler { \ingroup profiler */ - PROFILER_API timestamp_t now(); + PROFILER_API timestamp_t timeNow(); /** Convert ticks to nanoseconds. @@ -766,7 +766,7 @@ namespace profiler { } #else - inline EASY_CONSTEXPR_FCN timestamp_t now() { return 0; } + inline EASY_CONSTEXPR_FCN timestamp_t timeNow() { return 0; } inline EASY_CONSTEXPR_FCN timestamp_t toNanoseconds(timestamp_t) { return 0; } inline EASY_CONSTEXPR_FCN timestamp_t toMicroseconds(timestamp_t) { return 0; } inline const BaseBlockDescriptor* registerDescription(EasyBlockStatus, const char*, const char*, const char*, int, block_type_t, color_t, bool = false) @@ -898,7 +898,7 @@ namespace profiler { \ingroup profiler */ - EASY_FORCE_INLINE timestamp_t currentTime() { return now(); } + EASY_FORCE_INLINE timestamp_t currentTime() { return timeNow(); } ////////////////////////////////////////////////////////////////////// diff --git a/easy_profiler_core/profiler.cpp b/easy_profiler_core/profiler.cpp index 4dd8b86..c331391 100644 --- a/easy_profiler_core/profiler.cpp +++ b/easy_profiler_core/profiler.cpp @@ -127,7 +127,7 @@ PROFILER_API const char* apiVersionName() #if !defined(EASY_PROFILER_API_DISABLED) -PROFILER_API profiler::timestamp_t now() +PROFILER_API profiler::timestamp_t timeNow() { return profiler::clock::now(); } @@ -295,7 +295,7 @@ PROFILER_API profiler::timestamp_t main_thread_frameTimeLocalAvg(profiler::Durat #else // EASY_PROFILER_API_DISABLED -PROFILER_API profiler::timestamp_t now() { return 0; } +PROFILER_API profiler::timestamp_t timeNow() { return 0; } PROFILER_API profiler::timestamp_t toNanoseconds(profiler::timestamp_t) { return 0; } PROFILER_API profiler::timestamp_t toMicroseconds(profiler::timestamp_t) { return 0; }