summaryrefslogtreecommitdiff
path: root/slang.h
diff options
context:
space:
mode:
Diffstat (limited to 'slang.h')
-rw-r--r--slang.h95
1 files changed, 84 insertions, 11 deletions
diff --git a/slang.h b/slang.h
index 8085bf15c..5ea1d13f8 100644
--- a/slang.h
+++ b/slang.h
@@ -192,19 +192,25 @@ convention for interface methods.
#define SLANG_DYNAMIC
#endif
+#if defined(_MSC_VER)
+# define SLANG_DLL_EXPORT __declspec(dllexport)
+#else
+# define SLANG_DLL_EXPORT __attribute__((__visibility__("default")))
+#endif
+
#if defined(SLANG_DYNAMIC)
- #if defined(_MSC_VER)
- #ifdef SLANG_DYNAMIC_EXPORT
- #define SLANG_API __declspec(dllexport)
- #else
- #define SLANG_API __declspec(dllimport)
- #endif
- #else
+# if defined(_MSC_VER)
+# ifdef SLANG_DYNAMIC_EXPORT
+# define SLANG_API SLANG_DLL_EXPORT
+# else
+# define SLANG_API __declspec(dllimport)
+# endif
+# else
// TODO: need to consider compiler capabilities
-// #ifdef SLANG_DYNAMIC_EXPORT
- #define SLANG_API __attribute__((__visibility__("default")))
-// #endif
- #endif
+//# ifdef SLANG_DYNAMIC_EXPORT
+# define SLANG_API SLANG_DLL_EXPORT
+//# endif
+# endif
#endif
#ifndef SLANG_API
@@ -283,6 +289,13 @@ convention for interface methods.
# define SLANG_UINT64(x) (x##ull)
#endif
+
+#ifdef __cplusplus
+# define SLANG_EXTERN_C extern "C"
+#else
+# define SLANG_EXTERN_C
+#endif
+
#ifdef __cplusplus
// C++ specific macros
// Gcc
@@ -339,6 +352,8 @@ convention for interface methods.
#include <stddef.h>
#endif // ! SLANG_NO_STDDEF
+#include <stdarg.h>
+
#ifdef __cplusplus
extern "C"
{
@@ -354,6 +369,8 @@ extern "C"
typedef uint32_t SlangUInt32;
typedef intptr_t SlangInt;
typedef uintptr_t SlangUInt;
+
+ typedef bool SlangBool;
/*!
@brief Severity of a diagnostic generated by the compiler.
@@ -634,6 +651,8 @@ extern "C"
#define SLANG_E_CANNOT_OPEN SLANG_MAKE_CORE_ERROR(4)
//! Indicates a file/resource could not be found
#define SLANG_E_NOT_FOUND SLANG_MAKE_CORE_ERROR(5)
+ //! An unhandled internal failure (typically from unhandled exception)
+#define SLANG_E_INTERNAL_FAIL SLANG_MAKE_CORE_ERROR(6)
/** A "Universally Unique Identifier" (UUID)
@@ -810,6 +829,51 @@ extern "C"
#define SLANG_UUID_ISlangFileSystemExt { 0x5fb632d2, 0x979d, 0x4481, { 0x9f, 0xee, 0x66, 0x3c, 0x3f, 0x14, 0x49, 0xe1 } }
+ /* Identifies different types of writer target*/
+ typedef unsigned int SlangWriterChannel;
+ enum
+ {
+ SLANG_WRITER_CHANNEL_DIAGNOSTIC,
+ SLANG_WRITER_CHANNEL_STD_OUTPUT,
+ SLANG_WRITER_CHANNEL_STD_ERROR,
+ SLANG_WRITER_CHANNEL_COUNT_OF,
+ };
+
+ typedef unsigned int SlangWriterMode;
+ enum
+ {
+ SLANG_WRITER_MODE_TEXT,
+ SLANG_WRITER_MODE_BINARY,
+ };
+
+ /** A stream typically of text, used for outputting diagnostic as well as other information.
+ */
+ struct ISlangWriter : public ISlangUnknown
+ {
+ public:
+ /** Write the formatted string with the used args. If returns SLANG_E_NOT_IMPLEMENTED, will use a default internal implementation, and call write with result
+ @param format Format string
+ @param args The arguments
+ @return SLANG_E_NOT_IMPLEMENTED if not implemented, SLANG_OK on success */
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL writeVaList(const char* format, va_list args) = 0;
+ /** Write text to the writer
+ @param chars The characters to write out
+ @param numChars The amount of characters
+ @returns SLANG_OK on success */
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL write(const char* chars, size_t numChars) = 0;
+ /** Flushes any content to the ouput */
+ virtual SLANG_NO_THROW void SLANG_MCALL flush() = 0;
+ /** Determines if the writer stream is to the console, and can be used to alter the output
+ @returns Returns true if is a console writer */
+ virtual SLANG_NO_THROW SlangBool SLANG_MCALL isConsole() = 0;
+ /** Set the mode for the writer to use
+ @param mode The mode to use
+ @returns SLANG_OK on success */
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL setMode(SlangWriterMode mode) = 0;
+ };
+
+ #define SLANG_UUID_ISlangWriter { 0xec457f0e, 0x9add, 0x4e6b,{ 0x85, 0x1c, 0xd7, 0xfa, 0x71, 0x6d, 0x15, 0xfd } };
+
/*!
@brief An instance of the Slang library.
*/
@@ -984,6 +1048,15 @@ extern "C"
SlangDiagnosticCallback callback,
void const* userData);
+ SLANG_API void spSetWriter(
+ SlangCompileRequest* request,
+ SlangWriterChannel channel,
+ ISlangWriter* writer);
+
+ SLANG_API ISlangWriter* spGetWriter(
+ SlangCompileRequest* request,
+ SlangWriterChannel channel);
+
/*!
@brief Add a path to use when searching for referenced files.
This will be used for both `#include` directives and also for explicit `__import` declarations.