message: Add raw string stack methods.
diff: @@ -229,6 +229,24 @@ static void StackPushString(const char* value)
  }
  }
  +static void StackPushRawString(const char* value)
  +{
  + auto vm = Globals::VirtualMachine();
  + ASSERT(vm->m_nRecursionLevel >= 0);
  +
  + LOG_DEBUG("Pushing string '%s'.", value);
  + CExoString str(value);
  +
  + if (vm->StackPushString(str))
  + {
  + ++s_pushedCount;
  + }
  + else
  + {
  + LOG_WARNING("Failed to push string '%s' - recursion level %i.", str.m_sString, vm->m_nRecursionLevel);
  + }
  +}
  +
  static void StackPushObject(uint32_t value)
  {
  auto vm = Globals::VirtualMachine();
  @@ -329,6 +347,24 @@ static const char* StackPopString()
  return strdup(String::ToUTF8(value.CStr()).c_str());
  }
  +static const char* StackPopRawString()
  +{
  + auto vm = Globals::VirtualMachine();
  + ASSERT(vm->m_nRecursionLevel >= 0);
  +
  + CExoString value;
  + if (!vm->StackPopString(&value))
  + {
  + LOG_WARNING("Failed to pop string - recursion level %i.", vm->m_nRecursionLevel);
  + return nullptr;
  + }
  +
  + static std::string retVal = value.CStr();
  + LOG_DEBUG("Popped string '%s'.", value.m_sString);
  +
  + return retVal.c_str();
  +}
  +
  static uint32_t StackPopObject()
  {
  auto vm = Globals::VirtualMachine();
  @@ -452,6 +488,11 @@ static void NWNXPushString(const char* s)
  Events::Push(String::FromUTF8(s));
  }
  +static void NWNXPushRawString(const char* s)
  +{
  + Events::Push<std::string>(s);
  +}
  +
  static void NWNXPushEffect(CGameEffect* e)
  {
  Events::Push(e);
  @@ -483,6 +524,20 @@ static const char* NWNXPopString()
  return strdup(String::ToUTF8(str).c_str());
  }
  +static const char* NWNXPopRawString()
  +{
  + auto value = Events::Pop<std::string>();
  + if (value.has_value())
  + {
  + static auto retVal = value.value();
  + return retVal.c_str();
  + }
  + else
  + {
  + return nullptr;
  + }
  +}
  +
  static CGameEffect* NWNXPopEffect()
  {
  return Events::Pop<CGameEffect*>().value_or(nullptr);
  @@ -568,6 +623,10 @@ std::vector<void*> GetExports()
  exports.push_back((void*)&GetNWNXExportedGlobals);
  exports.push_back((void*)&RequestHook);
  exports.push_back((void*)&ReturnHook);
  + exports.push_back((void*)&StackPushRawString);
  + exports.push_back((void*)&StackPopRawString);
  + exports.push_back((void*)&NWNXPushRawString);
  + exports.push_back((void*)&NWNXPopRawString);
  return exports;
  }
  