StringCopyInfo.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. template <class T> class LargeStack;
  7. namespace Js
  8. {
  9. #pragma region StringCopyInfo
  10. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  11. class StringCopyInfo
  12. {
  13. private:
  14. JavascriptString *sourceString;
  15. wchar_t *destinationBuffer;
  16. #if DBG
  17. bool isInitialized;
  18. #endif
  19. public:
  20. StringCopyInfo();
  21. StringCopyInfo(JavascriptString *const sourceString, _Inout_count_(sourceString->m_charLength) wchar_t *const destinationBuffer);
  22. public:
  23. JavascriptString *SourceString() const;
  24. wchar_t *DestinationBuffer() const;
  25. private:
  26. static void InstantiateForceInlinedMembers();
  27. };
  28. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  29. #pragma endregion
  30. #pragma region StringCopyInfoStack
  31. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  32. class StringCopyInfoStack
  33. {
  34. private:
  35. ScriptContext *const scriptContext;
  36. TempArenaAllocatorObject *allocator;
  37. LargeStack<StringCopyInfo> *stack;
  38. public:
  39. StringCopyInfoStack(ScriptContext *const scriptContext);
  40. ~StringCopyInfoStack();
  41. public:
  42. bool IsEmpty();
  43. void Push(const StringCopyInfo copyInfo);
  44. const StringCopyInfo Pop();
  45. private:
  46. void CreateStack();
  47. PREVENT_COPY(StringCopyInfoStack);
  48. };
  49. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  50. #pragma endregion
  51. }