nsIXPCScriptable.idl 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #include "nsISupports.idl"
  7. #include "nsIClassInfo.idl"
  8. %{C++
  9. #ifdef XP_WIN
  10. #undef GetClassName
  11. #endif
  12. #include "js/TypeDecls.h"
  13. struct JSFreeOp;
  14. namespace js {
  15. struct Class;
  16. }
  17. %}
  18. interface nsIXPConnectWrappedNative;
  19. [ptr] native JSContextPtr(JSContext);
  20. [ptr] native JSObjectPtr(JSObject);
  21. [ptr] native JSValPtr(JS::Value);
  22. [ptr] native JSFreeOpPtr(JSFreeOp);
  23. [ref] native JSCallArgsRef(const JS::CallArgs);
  24. [ref] native JSAutoIdVector(JS::AutoIdVector);
  25. [ptr] native jsClassPtr(const js::Class);
  26. /**
  27. * Note: This is not really an XPCOM interface. For example, callers must
  28. * guarantee that they set the *_retval of the various methods that return a
  29. * boolean to PR_TRUE before making the call. Implementations may skip writing
  30. * to *_retval unless they want to return PR_FALSE.
  31. */
  32. [uuid(19b70b26-7c3f-437f-a04a-2a8f9e28b617)]
  33. interface nsIXPCScriptable : nsISupports
  34. {
  35. /* bitflags used for 'flags' (only 32 bits available!) */
  36. const uint32_t WANT_PRECREATE = 1 << 0;
  37. // unused bit here
  38. // unused bit here
  39. const uint32_t WANT_ADDPROPERTY = 1 << 3;
  40. // unused bit here
  41. const uint32_t WANT_GETPROPERTY = 1 << 5;
  42. const uint32_t WANT_SETPROPERTY = 1 << 6;
  43. const uint32_t WANT_ENUMERATE = 1 << 7;
  44. const uint32_t WANT_NEWENUMERATE = 1 << 8;
  45. const uint32_t WANT_RESOLVE = 1 << 9;
  46. // unused bit here
  47. const uint32_t WANT_FINALIZE = 1 << 11;
  48. // unused bit here!
  49. const uint32_t WANT_CALL = 1 << 13;
  50. const uint32_t WANT_CONSTRUCT = 1 << 14;
  51. const uint32_t WANT_HASINSTANCE = 1 << 15;
  52. // Unused bit here!
  53. const uint32_t USE_JSSTUB_FOR_ADDPROPERTY = 1 << 17;
  54. const uint32_t USE_JSSTUB_FOR_DELPROPERTY = 1 << 18;
  55. const uint32_t USE_JSSTUB_FOR_SETPROPERTY = 1 << 19;
  56. // Unused bit here!
  57. const uint32_t DONT_ENUM_QUERY_INTERFACE = 1 << 21;
  58. const uint32_t DONT_ASK_INSTANCE_FOR_SCRIPTABLE = 1 << 22;
  59. const uint32_t CLASSINFO_INTERFACES_ONLY = 1 << 23;
  60. const uint32_t ALLOW_PROP_MODS_DURING_RESOLVE = 1 << 24;
  61. const uint32_t ALLOW_PROP_MODS_TO_PROTOTYPE = 1 << 25;
  62. const uint32_t IS_GLOBAL_OBJECT = 1 << 26;
  63. const uint32_t DONT_REFLECT_INTERFACE_NAMES = 1 << 27;
  64. // The high order bit is RESERVED for consumers of these flags.
  65. // No implementor of this interface should ever return flags
  66. // with this bit set.
  67. const uint32_t RESERVED = 1 << 31;
  68. readonly attribute string className;
  69. [notxpcom,nostdcall] uint32_t getScriptableFlags();
  70. [notxpcom,nostdcall] jsClassPtr getClass();
  71. void preCreate(in nsISupports nativeObj, in JSContextPtr cx,
  72. in JSObjectPtr globalObj, out JSObjectPtr parentObj);
  73. boolean addProperty(in nsIXPConnectWrappedNative wrapper,
  74. in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
  75. in jsval val);
  76. boolean getProperty(in nsIXPConnectWrappedNative wrapper,
  77. in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
  78. in JSValPtr vp);
  79. boolean setProperty(in nsIXPConnectWrappedNative wrapper,
  80. in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
  81. in JSValPtr vp);
  82. boolean enumerate(in nsIXPConnectWrappedNative wrapper,
  83. in JSContextPtr cx, in JSObjectPtr obj);
  84. boolean newEnumerate(in nsIXPConnectWrappedNative wrapper,
  85. in JSContextPtr cx, in JSObjectPtr obj,
  86. in JSAutoIdVector properties);
  87. boolean resolve(in nsIXPConnectWrappedNative wrapper,
  88. in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
  89. out boolean resolvedp);
  90. void finalize(in nsIXPConnectWrappedNative wrapper,
  91. in JSFreeOpPtr fop, in JSObjectPtr obj);
  92. boolean call(in nsIXPConnectWrappedNative wrapper,
  93. in JSContextPtr cx, in JSObjectPtr obj,
  94. in JSCallArgsRef args);
  95. boolean construct(in nsIXPConnectWrappedNative wrapper,
  96. in JSContextPtr cx, in JSObjectPtr obj,
  97. in JSCallArgsRef args);
  98. boolean hasInstance(in nsIXPConnectWrappedNative wrapper,
  99. in JSContextPtr cx, in JSObjectPtr obj,
  100. in jsval val, out boolean bp);
  101. void postCreatePrototype(in JSContextPtr cx, in JSObjectPtr proto);
  102. };
  103. %{ C++
  104. #include "nsAutoPtr.h"
  105. #define NS_XPCCLASSINFO_IID \
  106. { 0x43b67f01, 0xd4ce, 0x4b82, \
  107. { 0xb3, 0xf8, 0xeb, 0xf2, 0x13, 0x60, 0xfb, 0x7e } }
  108. class NS_NO_VTABLE nsXPCClassInfo : public nsIClassInfo,
  109. public nsIXPCScriptable
  110. {
  111. public:
  112. NS_DECLARE_STATIC_IID_ACCESSOR(NS_XPCCLASSINFO_IID)
  113. NS_IMETHOD_(MozExternalRefCountType) AddRef() override = 0;
  114. NS_IMETHOD_(MozExternalRefCountType) Release() override = 0;
  115. virtual void PreserveWrapper(nsISupports *aNative) = 0;
  116. };
  117. NS_DEFINE_STATIC_IID_ACCESSOR(nsXPCClassInfo, NS_XPCCLASSINFO_IID)
  118. inline
  119. nsresult
  120. CallQueryInterface(nsISupports* aSourcePtr,
  121. RefPtrGetterAddRefs<nsXPCClassInfo> aDestPtr)
  122. {
  123. return CallQueryInterface(aSourcePtr,
  124. static_cast<nsXPCClassInfo**>(aDestPtr));
  125. }
  126. %}