From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Scripting/ICallString.cpp | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Runtime/Scripting/ICallString.cpp (limited to 'Runtime/Scripting/ICallString.cpp') diff --git a/Runtime/Scripting/ICallString.cpp b/Runtime/Scripting/ICallString.cpp new file mode 100644 index 0000000..ad1cceb --- /dev/null +++ b/Runtime/Scripting/ICallString.cpp @@ -0,0 +1,40 @@ +#include "UnityPrefix.h" + +#if ENABLE_SCRIPTING + +#if !UNITY_FLASH +#include "ICallString.h" +#include "Runtime/Scripting/Backend/ScriptingBackendApi.h" + + +#if ENABLE_MONO +std::string ICallString::AsUTF8() const +{ + return scripting_cpp_string_for(str).c_str(); +} +#elif UNITY_WINRT +#include "PlatformDependent/MetroPlayer/MetroUtils.h" +std::string ICallString::AsUTF8() const +{ + return ConvertStringToUtf8(str); +} +#endif + +#if ENABLE_MONO +// todo: remove this useless include once we figure out where to take mono_string_length from. +#include "Runtime/Scripting/ScriptingUtility.h" +#endif + +int ICallString::Length() +{ +#if ENABLE_MONO + return mono_string_length(str); +#elif UNITY_WINRT + return wcslen(str); + //return safe_cast(str)->Length(); +#endif +} +#endif + +#endif + -- cgit v1.1-26-g67d0