From efa2c8f41aa5cd2c27990fd9b57ea0eff06976e7 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 21 Dec 2018 11:00:28 -0500 Subject: Feature/remove app context (#765) * Remove AppContext. Use StdChannels to hold writers, and TestToolUtil to hold test tool specific functionality. * StdChannels -> StdWriters * getStdOut -> getOut, getStdError -> getError --- source/core/slang-app-context.cpp | 67 --------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 source/core/slang-app-context.cpp (limited to 'source/core/slang-app-context.cpp') diff --git a/source/core/slang-app-context.cpp b/source/core/slang-app-context.cpp deleted file mode 100644 index 2b3f32cbc..000000000 --- a/source/core/slang-app-context.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -#include "slang-app-context.h" - -#include "slang-writer.h" - -namespace Slang -{ - -/* static */AppContext* AppContext::s_singleton = nullptr; - - -/* static */AppContext* AppContext::getDefault() -{ - static AppContext* s_context = nullptr; - - if (!s_context) - { - static FileWriter s_stdError(stderr, WriterFlag::IsStatic | WriterFlag::IsUnowned | WriterFlag::AutoFlush); - static FileWriter s_stdOut(stdout, WriterFlag::IsStatic | WriterFlag::IsUnowned | WriterFlag::AutoFlush); - - static AppContext s_contextVar; - s_context = &s_contextVar; - - s_context->setWriter(SLANG_WRITER_CHANNEL_STD_ERROR, &s_stdError); - s_context->setWriter(SLANG_WRITER_CHANNEL_STD_OUTPUT, &s_stdOut); - } - return s_context; -} - -/* static */AppContext* AppContext::initDefault() -{ - AppContext* context = getDefault(); - setSingleton(context); - return context; -} - -/* static */int AppContext::getReturnCode(SlangResult res) -{ - if (SLANG_SUCCEEDED(res)) - { - return 0; - } - else if (res == SLANG_E_INTERNAL_FAIL) - { - return -1; - } - return 1; -} - -void AppContext::setRequestWriters(SlangCompileRequest* request) -{ - for (int i = 0; i < SLANG_WRITER_CHANNEL_COUNT_OF; ++i) - { - if (m_replaceWriterFlags & (1 << i)) - { - spSetWriter(request, SlangWriterChannel(i), m_writers[i]); - } - } -} - -void AppContext::configureRequest(SlangCompileRequest* request) -{ - setRequestWriters(request); -} - -} - -- cgit v1.2.3