1 /* 2 MIT License 3 4 Copyright (c) 2021 Alexandre BIQUE 5 Copyright (c) 2024 Guillaume PIOLAT 6 7 Permission is hereby granted, free of charge, to any person obtaining 8 a copy of this software and associated documentation files (the 9 "Software"), to deal in the Software without restriction, including 10 without limitation the rights to use, copy, modify, merge, publish, 11 distribute, sublicense, and/or sell copies of the Software, and to 12 permit persons to whom the Software is furnished to do so, subject to 13 the following conditions: 14 15 The above copyright notice and this permission notice shall be 16 included in all copies or substantial portions of the Software. 17 18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 */ 26 module dplug.clap.clapversion; 27 28 nothrow @nogc: 29 version(CLAP): 30 31 // version.h 32 enum uint CLAP_VERSION_MAJOR = 1; 33 enum uint CLAP_VERSION_MINOR = 2; 34 enum uint CLAP_VERSION_REVISION = 2; 35 36 bool CLAP_VERSION_LT(uint maj, uint min, uint rev) 37 { 38 if (CLAP_VERSION_MAJOR < maj) return true; 39 if ((maj == CLAP_VERSION_MAJOR) && (CLAP_VERSION_MINOR < min)) 40 return true; 41 if ((maj == CLAP_VERSION_MAJOR) && (min == CLAP_VERSION_MINOR) 42 && (CLAP_VERSION_REVISION < rev)) 43 return true; 44 return false; 45 } 46 47 bool CLAP_VERSION_EQ(uint maj, uint min, uint rev) 48 { 49 return maj == CLAP_VERSION_MAJOR 50 && min == CLAP_VERSION_MINOR 51 && rev == CLAP_VERSION_REVISION; 52 } 53 54 bool CLAP_VERSION_GE(uint maj, uint min, uint rev) 55 { 56 return ! CLAP_VERSION_LT(maj, min, rev); 57 } 58 59 bool clap_version_is_compatible(T)(T v) 60 { 61 // versions 0.x.y were used during development stage and aren't 62 // compatible 63 return v.major >= 1; 64 } 65 66 struct clap_version_t 67 { 68 // This is the major ABI and API design 69 // Version 0.X.Y correspond to the development stage, API and ABI 70 // are not stable 71 // Version 1.X.Y correspond to the release stage, API and ABI are 72 // stable 73 uint major; 74 uint minor; 75 uint revision; 76 } 77 78 enum CLAP_VERSION = clap_version_t(1, 2, 2);