From f0243659d29e1906bf606f387fb342ad511d1011 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 21 Feb 2021 13:16:24 +0100 Subject: [PATCH] ID result: use constexpr instead of #defines --- src/merge/id_result.h | 18 +++++++++--------- tests/test.d/simple_test.rb | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/merge/id_result.h b/src/merge/id_result.h index d47951d5e..f1d489f2b 100644 --- a/src/merge/id_result.h +++ b/src/merge/id_result.h @@ -17,14 +17,14 @@ #include "common/id_info.h" -#define ID_RESULT_TRACK_AUDIO "audio" -#define ID_RESULT_TRACK_VIDEO "video" -#define ID_RESULT_TRACK_SUBTITLES "subtitles" -#define ID_RESULT_TRACK_BUTTONS "buttons" -#define ID_RESULT_TRACK_UNKNOWN "unknown" -#define ID_RESULT_CHAPTERS "chapters" -#define ID_RESULT_TAGS "tags" -#define ID_RESULT_GLOBAL_TAGS_ID -1 +constexpr auto ID_RESULT_TRACK_AUDIO = "audio"; +constexpr auto ID_RESULT_TRACK_VIDEO = "video"; +constexpr auto ID_RESULT_TRACK_SUBTITLES = "subtitles"; +constexpr auto ID_RESULT_TRACK_BUTTONS = "buttons"; +constexpr auto ID_RESULT_TRACK_UNKNOWN = "unknown"; +constexpr auto ID_RESULT_CHAPTERS = "chapters"; +constexpr auto ID_RESULT_TAGS = "tags"; +constexpr auto ID_RESULT_GLOBAL_TAGS_ID = -1; // When bumping the schema version: // • increase `ID_JSON_FORMAT_VERSION` here @@ -33,7 +33,7 @@ // 1. `id` // 2. `properties` → `identification_format_version` → `minimum` and `maximum` // • adjust the link in `doc/man/mkvmerge.xml` -#define ID_JSON_FORMAT_VERSION 14 +constexpr auto ID_JSON_FORMAT_VERSION = 14; struct id_result_t { int64_t id; diff --git a/tests/test.d/simple_test.rb b/tests/test.d/simple_test.rb index 181beaff4..ef06f9224 100644 --- a/tests/test.d/simple_test.rb +++ b/tests/test.d/simple_test.rb @@ -342,7 +342,7 @@ class SimpleTest json_store = JsonSchema::DocumentStore.new parser = JsonSchema::Parser.new expander = JsonSchema::ReferenceExpander.new - version = IO.readlines("../src/merge/id_result.h").detect { |line| /#define +ID_JSON_FORMAT_VERSION\b/.match line }.gsub(/.* .* /, '').chop + version = IO.readlines("../src/merge/id_result.h").detect { |line| /^constexpr.*\bID_JSON_FORMAT_VERSION\b/.match line }.gsub(/.*= *|;/, '').chop schema = parser.parse JSON.load(File.read("../doc/json-schema/mkvmerge-identification-output-schema-v#{version}.json")) expander.expand(schema, store: json_store)