ModuleRoot.h 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 PropertyQueryFlags HasPropertyQuery(PropertyId propertyId, _Inout_opt_ PropertyValueInfo* info) override;
  22. virtual BOOL HasOwnProperty(PropertyId propertyId) override;
  23. virtual BOOL UseDynamicObjectForNoHostObjectAccess() override { return TRUE; }
  24. virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
  25. virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, JavascriptString* propertyNameString, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
  26. _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ 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 PropertyQueryFlags GetPropertyReferenceQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
  33. virtual PropertyQueryFlags HasItemQuery(uint32 index) override;
  34. virtual BOOL HasOwnItem(uint32 index) override;
  35. virtual PropertyQueryFlags GetItemReferenceQuery(Var originalInstance, uint32 index, Var* value, ScriptContext * requestContext) override;
  36. virtual PropertyQueryFlags GetItemQuery(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. protected:
  48. // For module binder, there is only one IDispatch* associated with the name provided
  49. // by the host when we can IActiveScriptSite::GetItemInfo.
  50. ModuleID moduleID;
  51. };
  52. }