ModuleRoot.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. // A wrapper corresponds to a named item coming from the host.
  9. // it maintains the IDispatch* pointer of the named item.
  10. // this is used in setting up the scope for scoped operations. see javascriptoperators.cpp
  11. class ModuleRoot : public RootObjectBase
  12. {
  13. protected:
  14. DEFINE_VTABLE_CTOR(ModuleRoot, RootObjectBase);
  15. DEFINE_MARSHAL_OBJECT_TO_SCRIPT_CONTEXT(ModuleRoot);
  16. public:
  17. ModuleRoot(DynamicType * type);
  18. void SetHostObject(ModuleID moduleID, HostObjectBase * hostObject);
  19. virtual BOOL InitPropertyScoped(PropertyId propertyId, Var value) override;
  20. virtual BOOL InitFuncScoped(PropertyId propertyId, Var value) override;
  21. virtual BOOL HasProperty(PropertyId propertyId) override;
  22. virtual BOOL HasOwnProperty(PropertyId propertyId) override;
  23. virtual BOOL UseDynamicObjectForNoHostObjectAccess() override { return TRUE; }
  24. virtual BOOL GetProperty(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
  25. virtual BOOL GetProperty(Var originalInstance, JavascriptString* propertyNameString, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
  26. virtual BOOL GetAccessors(PropertyId propertyId, Var* getter, Var* setter, ScriptContext * requestContext) override;
  27. virtual BOOL DeleteProperty(PropertyId propertyId, PropertyOperationFlags flags) override;
  28. virtual BOOL DeleteProperty(JavascriptString *propertyNameString, PropertyOperationFlags flags) override;
  29. virtual BOOL SetProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
  30. virtual BOOL SetProperty(JavascriptString* propertyNameString, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
  31. virtual BOOL SetAccessors(PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags) override;
  32. virtual BOOL GetPropertyReference(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
  33. virtual BOOL HasItem(uint32 index) override;
  34. virtual BOOL HasOwnItem(uint32 index) override;
  35. virtual BOOL GetItemReference(Var originalInstance, uint32 index, Var* value, ScriptContext * requestContext) override;
  36. virtual BOOL GetItem(Var originalInstance, uint32 index, Var* value, ScriptContext * requestContext) override;
  37. virtual BOOL SetItem(uint32 index, Var value, PropertyOperationFlags flags) override;
  38. virtual BOOL GetDiagValueString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext) override;
  39. virtual BOOL GetDiagTypeString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext) override;
  40. virtual BOOL EnsureProperty(PropertyId propertyId) override sealed;
  41. virtual BOOL HasRootProperty(PropertyId propertyId) override;
  42. virtual BOOL GetRootProperty(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
  43. virtual BOOL GetRootPropertyReference(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
  44. virtual BOOL SetRootProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
  45. virtual BOOL DeleteRootProperty(PropertyId propertyId, PropertyOperationFlags flags) override;
  46. ModuleID GetModuleID() { return moduleID;}
  47. static bool Is(Var aValue);
  48. protected:
  49. // For module binder, there is only one IDispatch* associated with the name provided
  50. // by the host when we can IActiveScriptSite::GetItemInfo.
  51. ModuleID moduleID;
  52. };
  53. }