JavascriptStringObject.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. namespace Js
  7. {
  8. class JavascriptStringObject : public DynamicObject
  9. {
  10. private:
  11. static PropertyId const specialPropertyIds[];
  12. protected:
  13. Field(JavascriptString*) value;
  14. DEFINE_VTABLE_CTOR(JavascriptStringObject, DynamicObject);
  15. DEFINE_MARSHAL_OBJECT_TO_SCRIPT_CONTEXT(JavascriptStringObject);
  16. JavascriptString* InternalUnwrap();
  17. private:
  18. bool GetPropertyBuiltIns(PropertyId propertyId, Var* value, ScriptContext* requestContext, BOOL* result);
  19. bool SetPropertyBuiltIns(PropertyId propertyId, PropertyOperationFlags flags, bool* result);
  20. bool GetSetterBuiltIns(PropertyId propertyId, PropertyValueInfo* info, DescriptorFlags* descriptorFlags);
  21. bool IsValidIndex(PropertyId propertyId, bool conditionMetBehavior);
  22. public:
  23. JavascriptStringObject(DynamicType * type);
  24. JavascriptStringObject(JavascriptString* value, DynamicType * type);
  25. static bool Is(Var aValue);
  26. static JavascriptStringObject* FromVar(Var aValue);
  27. static JavascriptStringObject* UnsafeFromVar(Var aValue);
  28. void Initialize(JavascriptString* value);
  29. JavascriptString* Unwrap() { return InternalUnwrap(); }
  30. virtual bool HasReadOnlyPropertiesInvisibleToTypeHandler() override { return true; }
  31. virtual DescriptorFlags GetItemSetter(uint32 index, Var* setterValue, ScriptContext* requestContext) override;
  32. virtual PropertyQueryFlags HasPropertyQuery(PropertyId propertyId) override;
  33. virtual BOOL IsConfigurable(PropertyId propertyId) override;
  34. virtual BOOL IsEnumerable(PropertyId propertyId) override;
  35. virtual BOOL IsWritable(PropertyId propertyId) override;
  36. virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
  37. virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, JavascriptString* propertyNameString, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
  38. virtual PropertyQueryFlags GetPropertyReferenceQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
  39. virtual BOOL SetProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
  40. virtual BOOL SetProperty(JavascriptString* propertyNameString, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
  41. virtual BOOL DeleteProperty(PropertyId propertyId, PropertyOperationFlags flags) override;
  42. virtual BOOL DeleteProperty(JavascriptString *propertyNameString, PropertyOperationFlags flags) override;
  43. virtual DescriptorFlags GetSetter(PropertyId propertyId, Var* setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;
  44. virtual DescriptorFlags GetSetter(JavascriptString* propertyNameString, Var* setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;
  45. virtual PropertyQueryFlags HasItemQuery(uint32 index) override;
  46. virtual PropertyQueryFlags GetItemQuery(Var originalInstance, uint32 index, Var* value, ScriptContext * requestContext) override;
  47. virtual PropertyQueryFlags GetItemReferenceQuery(Var originalInstance, uint32 index, Var* value, ScriptContext * requestContext) override;
  48. virtual BOOL SetItem(uint32 index, Var value, PropertyOperationFlags flags) override;
  49. virtual BOOL GetEnumerator(JavascriptStaticEnumerator * enumerator, EnumeratorFlags flags, ScriptContext* requestContext, EnumeratorCache * enumeratorCache = nullptr) override;
  50. virtual BOOL GetDiagValueString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext) override;
  51. virtual BOOL GetDiagTypeString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext) override;
  52. virtual BOOL GetSpecialPropertyName(uint32 index, JavascriptString ** propertyName, ScriptContext * requestContext) override;
  53. virtual uint GetSpecialPropertyCount() const override;
  54. virtual PropertyId const * GetSpecialPropertyIds() const override;
  55. #if ENABLE_TTD
  56. public:
  57. void SetValue_TTD(Js::Var val);
  58. virtual void MarkVisitKindSpecificPtrs(TTD::SnapshotExtractor* extractor) override;
  59. virtual TTD::NSSnapObjects::SnapObjectType GetSnapTag_TTD() const override;
  60. virtual void ExtractSnapObjectDataInto(TTD::NSSnapObjects::SnapObject* objData, TTD::SlabAllocator& alloc) override;
  61. #endif
  62. };
  63. }