From 65e74b65cd04ccff8b832994652a86a356a70af5 Mon Sep 17 00:00:00 2001 From: Brian Heim Date: Sun, 15 Dec 2019 12:21:33 -0600 Subject: [PATCH] SC: implement getResultAsInt --- src/SuperColliderEngine.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/SuperColliderEngine.cpp b/src/SuperColliderEngine.cpp index 3324b7d..801b2f8 100644 --- a/src/SuperColliderEngine.cpp +++ b/src/SuperColliderEngine.cpp @@ -161,6 +161,20 @@ void SC_VcvPrototypeClient::evaluateProcessBlock(ProcessBlock* block) noexcept { // END TIMING } +int SC_VcvPrototypeClient::getResultAsInt(const char* text) noexcept { + interpret(text); + + auto* resultSlot = &scGlobals()->result; + if (IsInt(resultSlot)) { + auto intResult = slotRawInt(resultSlot); + printf("%s: %d\n", text, intResult); + return intResult; + } + + FAIL(std::string("Result of '") + text + "' was not int as expected"); + return -1; +} + __attribute__((constructor(1000))) static void constructor() { addScriptEngine("sc");