diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Scripting/ICallString.h |
Diffstat (limited to 'Runtime/Scripting/ICallString.h')
-rw-r--r-- | Runtime/Scripting/ICallString.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/Runtime/Scripting/ICallString.h b/Runtime/Scripting/ICallString.h new file mode 100644 index 0000000..6c096d2 --- /dev/null +++ b/Runtime/Scripting/ICallString.h @@ -0,0 +1,91 @@ +#pragma once + +#if ENABLE_SCRIPTING + +#include "Runtime/Scripting/Backend/ScriptingTypes.h" +#include <string> + +#if ENABLE_MONO +struct ICallString +{ + MonoString* str; + + EXPORT_COREMODULE std::string AsUTF8() const; + operator std::string () const { return AsUTF8(); } + int Length(); + bool IsNull () {return !str;} + + MonoString* GetNativeString() {return str;} +}; +#endif + +#if UNITY_FLASH +struct ICallString +{ + const char* utf8stream; + + std::string AsUTF8() const { return utf8stream; } + operator std::string () const { return AsUTF8(); } + + int Length() { return strlen(utf8stream); } + bool IsNull () {return !utf8stream;} + const char* GetNativeString() {return utf8stream;} +}; +#endif + +#if UNITY_WINRT +struct ICallString +{ +private: + const wchar_t* str; + //Platform::Object^ str; + + ICallString(const ICallString& other){} + ICallString& operator = (const ICallString& rhs) + { + return *this; + } +public: + ICallString(){} + ICallString(const wchar_t* _str) + : str(_str) + { + } + std::string AsUTF8() const; + operator std::string () const { return AsUTF8(); } + + int Length(); + bool IsNull () {return (str == SCRIPTING_NULL);} + + ScriptingStringPtr GetNativeString() {return ref new Platform::String(str);} +}; +#endif + +/* +//For the next step + +struct structwithsomename +{ +char buf[256]; +char* fallback; + +structwithsomename(ICallString& ics) +{ + + +} + +~structwithsomename() +{ +delete fallback; +} + +const char* Get() +{ +fastutf8into(buf); +} + +const char* operator () { return Get(); } +};*/ + +#endif |