gecko-dev/js/xpconnect/idl/nsIXPCScriptable.idl

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

122 строки
4.6 KiB
Plaintext
Исходник Обычный вид История

2001-09-20 04:02:59 +04:00
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
2012-05-21 15:12:37 +04:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIClassInfo.idl"
%{C++
#ifdef XP_WIN
#undef GetClassName
#endif
#include "js/TypeDecls.h"
namespace JS {
class CallArgs;
}
%}
interface nsIXPConnectWrappedNative;
[ptr] native JSContextPtr(JSContext);
[ptr] native JSObjectPtr(JSObject);
[ptr] native JSValPtr(JS::Value);
[ptr] native JSGCContextPtr(JS::GCContext);
[ref] native JSCallArgsRef(const JS::CallArgs);
[ptr] native JSClassPtr(const JSClass);
Bug 1798068 part 2: Expand JS::MutableHandleIdVector to more verbose typename in nsIXPCScriptable.idl, to satisfy static-analysis rule. r=xpcom-reviewers,mccr8 This patch doesn't change behavior; it's just expanding an abbreviated typename. Without this patch, my local static-analysis build fails with the following error for mozStorageStatementJSHelper.h (which has a class that implements nsIXPCScriptable and is outside of SpiderMonkey): "error: The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey." The error message points to the NS_DECL_NSIXPCSCRIPTABLE macro, and specifically to a usage of this typename inside of that macro. This patch's type-expansion seems to appease this static analysis rule. Before this patch, the type here was `JS::MutableHandleIdVector` which is a typedef for `MutableHandle<StackGCVector<JS::PropertyKey>>` as defined here: https://searchfox.org/mozilla-central/rev/fe5c9c39a879b07d5b629257f63d825c3c8cd0ed/js/public/TypeDecls.h#98 After this patch, the type here is `JS::MutableHandleVector<JS::PropertyKey>` (which I took from the static analysis error message's suggestion). That expands to the same full-qualified type, since `MutableHandleVector<T>` is an alias for `MutableHandle<StackGCVector<T>>` as defined here: https://searchfox.org/mozilla-central/rev/fe5c9c39a879b07d5b629257f63d825c3c8cd0ed/js/public/TypeDecls.h#128 Differential Revision: https://phabricator.services.mozilla.com/D160690
2022-10-29 02:11:46 +03:00
native JSMutableHandleIdVector(JS::MutableHandleVector<JS::PropertyKey>);
Bug 1332172 - Remove XPC_MAP_WANT_*. r=mccr8. nsIXPCScriptable flags handling in xpc_map_end.h is a bit of a mess. - Half the flags relate to whether various functions are defined (PreCreate, GetProperty, etc). These are set using the XPC_MAP_WANT_* macros; for each one xpc_map_end.h inserts the corresponding flag using the preprocessor (see XPC_MAP_CLASSNAME::GetScriptableFlags()). - The other half of the flags relate to other things (IS_GLOBAL_OBJECT, DONT_REFLECT_INTERFACE_NAMES, etc). These are set using the XPC_MAP_FLAGS macro. Having two similar but different mechanisms to set the flags for a class is confusing. (Indeed, until recently we had some classes where a single flag was redundantly specified via both mechanisms.) Note also that the classes done in dom/base/nsIDOMClassInfo.h also specify all the flags in a single value, similar to how XPC_MAP_FLAGS works. This patch removes the XPC_MAP_WANT_* macros. All flags are now set via XPC_MAP_FLAGS. This is a significant simplification to xpc_map_end.h and all the places that use it. The downside of this change is that I had to change the flag constants from class constants (i.e. nsIXPCScriptable::FOO) to macros (i.e. NSIXPCSCRIPTABLE_FOO) because they need to be used in #if statements like this in xpc_map_end.h: #if !((XPC_MAP_FLAGS) & NSIXPCSCRIPTABLE_WANT_PRECREATE) and you can't use a '::'-qualified name inside a #if. I think this downside is outweighed by the simplification described above. Overall the patch removes 80 lines of code. --HG-- extra : rebase_source : 6d5c341d0deba8f1529d81c17bb8819e09620b05
2017-01-23 05:33:58 +03:00
%{ C++
// nsIXPCScriptable flags (only 32 bits available!). They are defined via
// #defines so they can be used in #ifndef guards in xpc_map_end.h.
#define XPC_SCRIPTABLE_WANT_PRECREATE (1 << 0)
// (1 << 1) is unused
// (1 << 2) is unused
// (1 << 3) is unused
Bug 1332172 - Remove XPC_MAP_WANT_*. r=mccr8. nsIXPCScriptable flags handling in xpc_map_end.h is a bit of a mess. - Half the flags relate to whether various functions are defined (PreCreate, GetProperty, etc). These are set using the XPC_MAP_WANT_* macros; for each one xpc_map_end.h inserts the corresponding flag using the preprocessor (see XPC_MAP_CLASSNAME::GetScriptableFlags()). - The other half of the flags relate to other things (IS_GLOBAL_OBJECT, DONT_REFLECT_INTERFACE_NAMES, etc). These are set using the XPC_MAP_FLAGS macro. Having two similar but different mechanisms to set the flags for a class is confusing. (Indeed, until recently we had some classes where a single flag was redundantly specified via both mechanisms.) Note also that the classes done in dom/base/nsIDOMClassInfo.h also specify all the flags in a single value, similar to how XPC_MAP_FLAGS works. This patch removes the XPC_MAP_WANT_* macros. All flags are now set via XPC_MAP_FLAGS. This is a significant simplification to xpc_map_end.h and all the places that use it. The downside of this change is that I had to change the flag constants from class constants (i.e. nsIXPCScriptable::FOO) to macros (i.e. NSIXPCSCRIPTABLE_FOO) because they need to be used in #if statements like this in xpc_map_end.h: #if !((XPC_MAP_FLAGS) & NSIXPCSCRIPTABLE_WANT_PRECREATE) and you can't use a '::'-qualified name inside a #if. I think this downside is outweighed by the simplification described above. Overall the patch removes 80 lines of code. --HG-- extra : rebase_source : 6d5c341d0deba8f1529d81c17bb8819e09620b05
2017-01-23 05:33:58 +03:00
#define XPC_SCRIPTABLE_WANT_NEWENUMERATE (1 << 4)
#define XPC_SCRIPTABLE_WANT_RESOLVE (1 << 5)
#define XPC_SCRIPTABLE_WANT_FINALIZE (1 << 6)
#define XPC_SCRIPTABLE_WANT_CALL (1 << 7)
#define XPC_SCRIPTABLE_WANT_CONSTRUCT (1 << 8)
#define XPC_SCRIPTABLE_WANT_HASINSTANCE (1 << 9)
#define XPC_SCRIPTABLE_USE_JSSTUB_FOR_ADDPROPERTY (1 << 10)
#define XPC_SCRIPTABLE_USE_JSSTUB_FOR_DELPROPERTY (1 << 11)
// (1 << 12) is unused
Bug 1332172 - Remove XPC_MAP_WANT_*. r=mccr8. nsIXPCScriptable flags handling in xpc_map_end.h is a bit of a mess. - Half the flags relate to whether various functions are defined (PreCreate, GetProperty, etc). These are set using the XPC_MAP_WANT_* macros; for each one xpc_map_end.h inserts the corresponding flag using the preprocessor (see XPC_MAP_CLASSNAME::GetScriptableFlags()). - The other half of the flags relate to other things (IS_GLOBAL_OBJECT, DONT_REFLECT_INTERFACE_NAMES, etc). These are set using the XPC_MAP_FLAGS macro. Having two similar but different mechanisms to set the flags for a class is confusing. (Indeed, until recently we had some classes where a single flag was redundantly specified via both mechanisms.) Note also that the classes done in dom/base/nsIDOMClassInfo.h also specify all the flags in a single value, similar to how XPC_MAP_FLAGS works. This patch removes the XPC_MAP_WANT_* macros. All flags are now set via XPC_MAP_FLAGS. This is a significant simplification to xpc_map_end.h and all the places that use it. The downside of this change is that I had to change the flag constants from class constants (i.e. nsIXPCScriptable::FOO) to macros (i.e. NSIXPCSCRIPTABLE_FOO) because they need to be used in #if statements like this in xpc_map_end.h: #if !((XPC_MAP_FLAGS) & NSIXPCSCRIPTABLE_WANT_PRECREATE) and you can't use a '::'-qualified name inside a #if. I think this downside is outweighed by the simplification described above. Overall the patch removes 80 lines of code. --HG-- extra : rebase_source : 6d5c341d0deba8f1529d81c17bb8819e09620b05
2017-01-23 05:33:58 +03:00
#define XPC_SCRIPTABLE_DONT_ENUM_QUERY_INTERFACE (1 << 13)
// (1 << 14) is unused
// (1 << 15) is unused
Bug 1332172 - Remove XPC_MAP_WANT_*. r=mccr8. nsIXPCScriptable flags handling in xpc_map_end.h is a bit of a mess. - Half the flags relate to whether various functions are defined (PreCreate, GetProperty, etc). These are set using the XPC_MAP_WANT_* macros; for each one xpc_map_end.h inserts the corresponding flag using the preprocessor (see XPC_MAP_CLASSNAME::GetScriptableFlags()). - The other half of the flags relate to other things (IS_GLOBAL_OBJECT, DONT_REFLECT_INTERFACE_NAMES, etc). These are set using the XPC_MAP_FLAGS macro. Having two similar but different mechanisms to set the flags for a class is confusing. (Indeed, until recently we had some classes where a single flag was redundantly specified via both mechanisms.) Note also that the classes done in dom/base/nsIDOMClassInfo.h also specify all the flags in a single value, similar to how XPC_MAP_FLAGS works. This patch removes the XPC_MAP_WANT_* macros. All flags are now set via XPC_MAP_FLAGS. This is a significant simplification to xpc_map_end.h and all the places that use it. The downside of this change is that I had to change the flag constants from class constants (i.e. nsIXPCScriptable::FOO) to macros (i.e. NSIXPCSCRIPTABLE_FOO) because they need to be used in #if statements like this in xpc_map_end.h: #if !((XPC_MAP_FLAGS) & NSIXPCSCRIPTABLE_WANT_PRECREATE) and you can't use a '::'-qualified name inside a #if. I think this downside is outweighed by the simplification described above. Overall the patch removes 80 lines of code. --HG-- extra : rebase_source : 6d5c341d0deba8f1529d81c17bb8819e09620b05
2017-01-23 05:33:58 +03:00
#define XPC_SCRIPTABLE_ALLOW_PROP_MODS_DURING_RESOLVE (1 << 16)
// (1 << 17) is unused
Bug 1332172 - Remove XPC_MAP_WANT_*. r=mccr8. nsIXPCScriptable flags handling in xpc_map_end.h is a bit of a mess. - Half the flags relate to whether various functions are defined (PreCreate, GetProperty, etc). These are set using the XPC_MAP_WANT_* macros; for each one xpc_map_end.h inserts the corresponding flag using the preprocessor (see XPC_MAP_CLASSNAME::GetScriptableFlags()). - The other half of the flags relate to other things (IS_GLOBAL_OBJECT, DONT_REFLECT_INTERFACE_NAMES, etc). These are set using the XPC_MAP_FLAGS macro. Having two similar but different mechanisms to set the flags for a class is confusing. (Indeed, until recently we had some classes where a single flag was redundantly specified via both mechanisms.) Note also that the classes done in dom/base/nsIDOMClassInfo.h also specify all the flags in a single value, similar to how XPC_MAP_FLAGS works. This patch removes the XPC_MAP_WANT_* macros. All flags are now set via XPC_MAP_FLAGS. This is a significant simplification to xpc_map_end.h and all the places that use it. The downside of this change is that I had to change the flag constants from class constants (i.e. nsIXPCScriptable::FOO) to macros (i.e. NSIXPCSCRIPTABLE_FOO) because they need to be used in #if statements like this in xpc_map_end.h: #if !((XPC_MAP_FLAGS) & NSIXPCSCRIPTABLE_WANT_PRECREATE) and you can't use a '::'-qualified name inside a #if. I think this downside is outweighed by the simplification described above. Overall the patch removes 80 lines of code. --HG-- extra : rebase_source : 6d5c341d0deba8f1529d81c17bb8819e09620b05
2017-01-23 05:33:58 +03:00
#define XPC_SCRIPTABLE_IS_GLOBAL_OBJECT (1 << 18)
#define XPC_SCRIPTABLE_DONT_REFLECT_INTERFACE_NAMES (1 << 19)
%}
/**
* Note: This is not really an XPCOM interface. For example, callers must
* guarantee that they set the *_retval of the various methods that return a
* boolean to PR_TRUE before making the call. Implementations may skip writing
* to *_retval unless they want to return PR_FALSE.
*/
[uuid(19b70b26-7c3f-437f-a04a-2a8f9e28b617)]
interface nsIXPCScriptable : nsISupports
{
readonly attribute AUTF8String className;
[notxpcom,nostdcall] uint32_t getScriptableFlags();
[notxpcom,nostdcall] JSClassPtr getJSClass();
void preCreate(in nsISupports nativeObj, in JSContextPtr cx,
in JSObjectPtr globalObj, out JSObjectPtr parentObj);
boolean newEnumerate(in nsIXPConnectWrappedNative wrapper,
in JSContextPtr cx, in JSObjectPtr obj,
in JSMutableHandleIdVector properties,
in boolean enumerableOnly);
boolean resolve(in nsIXPConnectWrappedNative wrapper,
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
out boolean resolvedp);
void finalize(in nsIXPConnectWrappedNative wrapper,
in JSGCContextPtr gcx, in JSObjectPtr obj);
boolean call(in nsIXPConnectWrappedNative wrapper,
in JSContextPtr cx, in JSObjectPtr obj,
in JSCallArgsRef args);
boolean construct(in nsIXPConnectWrappedNative wrapper,
in JSContextPtr cx, in JSObjectPtr obj,
in JSCallArgsRef args);
boolean hasInstance(in nsIXPConnectWrappedNative wrapper,
in JSContextPtr cx, in JSObjectPtr obj,
in jsval val, out boolean bp);
%{ C++
Bug 1332172 - Remove XPC_MAP_WANT_*. r=mccr8. nsIXPCScriptable flags handling in xpc_map_end.h is a bit of a mess. - Half the flags relate to whether various functions are defined (PreCreate, GetProperty, etc). These are set using the XPC_MAP_WANT_* macros; for each one xpc_map_end.h inserts the corresponding flag using the preprocessor (see XPC_MAP_CLASSNAME::GetScriptableFlags()). - The other half of the flags relate to other things (IS_GLOBAL_OBJECT, DONT_REFLECT_INTERFACE_NAMES, etc). These are set using the XPC_MAP_FLAGS macro. Having two similar but different mechanisms to set the flags for a class is confusing. (Indeed, until recently we had some classes where a single flag was redundantly specified via both mechanisms.) Note also that the classes done in dom/base/nsIDOMClassInfo.h also specify all the flags in a single value, similar to how XPC_MAP_FLAGS works. This patch removes the XPC_MAP_WANT_* macros. All flags are now set via XPC_MAP_FLAGS. This is a significant simplification to xpc_map_end.h and all the places that use it. The downside of this change is that I had to change the flag constants from class constants (i.e. nsIXPCScriptable::FOO) to macros (i.e. NSIXPCSCRIPTABLE_FOO) because they need to be used in #if statements like this in xpc_map_end.h: #if !((XPC_MAP_FLAGS) & NSIXPCSCRIPTABLE_WANT_PRECREATE) and you can't use a '::'-qualified name inside a #if. I think this downside is outweighed by the simplification described above. Overall the patch removes 80 lines of code. --HG-- extra : rebase_source : 6d5c341d0deba8f1529d81c17bb8819e09620b05
2017-01-23 05:33:58 +03:00
#define GET_IT(f_, c_) \
bool f_() { \
return 0 != (GetScriptableFlags() & XPC_SCRIPTABLE_##c_); \
}
Bug 1332172 - Remove XPC_MAP_WANT_*. r=mccr8. nsIXPCScriptable flags handling in xpc_map_end.h is a bit of a mess. - Half the flags relate to whether various functions are defined (PreCreate, GetProperty, etc). These are set using the XPC_MAP_WANT_* macros; for each one xpc_map_end.h inserts the corresponding flag using the preprocessor (see XPC_MAP_CLASSNAME::GetScriptableFlags()). - The other half of the flags relate to other things (IS_GLOBAL_OBJECT, DONT_REFLECT_INTERFACE_NAMES, etc). These are set using the XPC_MAP_FLAGS macro. Having two similar but different mechanisms to set the flags for a class is confusing. (Indeed, until recently we had some classes where a single flag was redundantly specified via both mechanisms.) Note also that the classes done in dom/base/nsIDOMClassInfo.h also specify all the flags in a single value, similar to how XPC_MAP_FLAGS works. This patch removes the XPC_MAP_WANT_* macros. All flags are now set via XPC_MAP_FLAGS. This is a significant simplification to xpc_map_end.h and all the places that use it. The downside of this change is that I had to change the flag constants from class constants (i.e. nsIXPCScriptable::FOO) to macros (i.e. NSIXPCSCRIPTABLE_FOO) because they need to be used in #if statements like this in xpc_map_end.h: #if !((XPC_MAP_FLAGS) & NSIXPCSCRIPTABLE_WANT_PRECREATE) and you can't use a '::'-qualified name inside a #if. I think this downside is outweighed by the simplification described above. Overall the patch removes 80 lines of code. --HG-- extra : rebase_source : 6d5c341d0deba8f1529d81c17bb8819e09620b05
2017-01-23 05:33:58 +03:00
GET_IT(WantPreCreate, WANT_PRECREATE)
GET_IT(WantNewEnumerate, WANT_NEWENUMERATE)
GET_IT(WantResolve, WANT_RESOLVE)
GET_IT(WantFinalize, WANT_FINALIZE)
GET_IT(WantCall, WANT_CALL)
GET_IT(WantConstruct, WANT_CONSTRUCT)
GET_IT(WantHasInstance, WANT_HASINSTANCE)
GET_IT(UseJSStubForAddProperty, USE_JSSTUB_FOR_ADDPROPERTY)
GET_IT(UseJSStubForDelProperty, USE_JSSTUB_FOR_DELPROPERTY)
GET_IT(DontEnumQueryInterface, DONT_ENUM_QUERY_INTERFACE)
GET_IT(AllowPropModsDuringResolve, ALLOW_PROP_MODS_DURING_RESOLVE)
GET_IT(IsGlobalObject, IS_GLOBAL_OBJECT)
GET_IT(DontReflectInterfaceNames, DONT_REFLECT_INTERFACE_NAMES)
#undef GET_IT
%}
};