From 634522da69b14b38c15b14d6b717b1289812e9bb Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 19 Jun 2017 08:47:23 -0700 Subject: Allow for automatic importing of Slang code The basic idea of this change is that user code can just write: #include "foo.h" and then if `foo.h` gets found in a list of registered directories for "auto-import," then it actually gets interpreted as if the user had writte, more or less: __import foo; That is, the code in `foo.h` will be treated as Slang, and will be fully parsed and checked (no matter what the source language had been), and the scoping rules will be those of `__import` instead of `#include`. This is a really big hammer, and I could imagine it smashing fingers if used poorly. I'm not sure this feature will pan out, but we need to try things to know. One big piece of that that I'll likely keep in either case is an overhaul of command-line options parsing for `slangc`. In particular, this logic has been moved into the core `slang` library (so that users can just pass options in via the API), and it is all done on UTF-8 strings rather than wide strings (which was always going to be Windows-specific). --- source/core/slang-io.h | 5 +---- source/core/slang-string.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'source/core') diff --git a/source/core/slang-io.h b/source/core/slang-io.h index 869fad873..2f140c3ad 100644 --- a/source/core/slang-io.h +++ b/source/core/slang-io.h @@ -20,11 +20,8 @@ namespace Slang class Path { public: -#ifdef _WIN32 - static const char PathDelimiter = '\\'; -#else static const char PathDelimiter = '/'; -#endif + static String TruncateExt(const String & path); static String ReplaceExt(const String & path, const char * newExt); static String GetFileName(const String & path); diff --git a/source/core/slang-string.h b/source/core/slang-string.h index 80eb00605..448b351aa 100644 --- a/source/core/slang-string.h +++ b/source/core/slang-string.h @@ -141,6 +141,16 @@ namespace Slang memcpy(buffer.Ptr(), str, length + 1); } } + String(const char* textBegin, char const* textEnd) + { + if (textBegin != textEnd) + { + length = (int)(textEnd - textBegin); + buffer = new char[length + 1]; + memcpy(buffer.Ptr(), textBegin, length + 1); + buffer.Ptr()[length] = 0; + } + } String(char chr) { if (chr) -- cgit v1.2.3