reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 24977f7f8959989652a3db5577975653c1a475f2
parent b837a5af5fe67b4bb9ba117eb8083473acbbdb00
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Fri,  5 Feb 2021 23:34:01 -0500

api: implement return of double values

Diffstat:
Msrc/api_helper.hpp | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/api_helper.hpp b/src/api_helper.hpp @@ -39,9 +39,15 @@ struct ReaScriptAPI<R(*)(Args...)> std::apply(fn, args); return nullptr; } + else if constexpr (std::is_floating_point_v<R>) { + const auto value { std::apply(fn, args) }; + void *storage { argv[argc - 1] }; + *static_cast<double *>(storage) = value; + return storage; + } else { - // cast integers to have the same size as a pointer to avoid warnings - using IntPtrR = std::conditional_t<std::is_integral_v<R>, intptr_t, R>; + // cast numbers to have the same size as a pointer to avoid warnings + using IntPtrR = std::conditional_t<std::is_pointer_v<R>, R, intptr_t>; const auto value = static_cast<IntPtrR>(std::apply(fn, args)); return reinterpret_cast<void *>(value); }