2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This file defines enum values for all of the DOM objects which have
|
|
|
|
* an entry in nsDOMClassInfo.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsDOMClassInfoID_h__
|
|
|
|
#define nsDOMClassInfoID_h__
|
|
|
|
|
2011-08-11 06:29:50 -07:00
|
|
|
#include "nsIXPCScriptable.h"
|
|
|
|
|
2010-01-12 06:24:00 -08:00
|
|
|
#define DOMCI_CLASS(_dom_class) \
|
2010-01-12 05:08:43 -08:00
|
|
|
eDOMClassInfo_##_dom_class##_id,
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-01-12 05:08:43 -08:00
|
|
|
enum nsDOMClassInfoID {
|
2009-12-23 11:10:31 -08:00
|
|
|
|
2010-01-12 05:08:43 -08:00
|
|
|
#include "nsDOMClassInfoClasses.h"
|
2010-02-24 21:58:18 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// This one better be the last one in this list
|
|
|
|
eDOMClassInfoIDCount
|
|
|
|
};
|
|
|
|
|
2010-01-12 05:08:43 -08:00
|
|
|
#undef DOMCI_CLASS
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* nsIClassInfo helper macros
|
|
|
|
*/
|
|
|
|
|
2010-01-12 06:24:00 -08:00
|
|
|
/**
|
2012-09-26 07:17:46 -07:00
|
|
|
* !! THIS MECHANISM IS DEPRECATED, DO NOT ADD MORE INTERFACE TO THESE LISTS !!
|
|
|
|
*
|
2010-01-12 06:24:00 -08:00
|
|
|
* DOMCI_CASTABLE_INTERFACES contains the list of interfaces that we have a bit
|
|
|
|
* for in nsDOMClassInfo's mInterfacesBitmap. To use it you need to define
|
|
|
|
* DOMCI_CASTABLE_INTERFACE(interface, bit, extra) and then call
|
|
|
|
* DOMCI_CASTABLE_INTERFACES(extra). For every interface there will be one
|
|
|
|
* call to DOMCI_CASTABLE_INTERFACE with the bit that it corresponds to and
|
|
|
|
* the extra argument that was passed in to DOMCI_CASTABLE_INTERFACES.
|
|
|
|
*
|
|
|
|
* WARNING: Be very careful when adding interfaces to this list. Every object
|
|
|
|
* that implements one of these interfaces must be directly castable
|
2012-06-01 09:24:52 -07:00
|
|
|
* to that interface from the *canonical* nsISupports! Also, none of
|
|
|
|
* the objects that implement these interfaces may use the new DOM
|
|
|
|
* bindings.
|
2010-01-12 06:24:00 -08:00
|
|
|
*/
|
2010-08-02 06:52:12 -07:00
|
|
|
#undef DOMCI_CASTABLE_INTERFACE
|
2010-01-12 06:24:00 -08:00
|
|
|
#define DOMCI_CASTABLE_INTERFACES(_extra) \
|
2010-04-19 08:41:39 -07:00
|
|
|
DOMCI_CASTABLE_INTERFACE(nsINode, nsINode, 0, _extra) \
|
2012-11-14 14:10:07 -08:00
|
|
|
DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::Element, mozilla::dom::Element,\
|
|
|
|
1, _extra) \
|
2012-12-06 17:39:51 -08:00
|
|
|
/* If this is ever removed, the IID for EventTarget can go away */ \
|
|
|
|
DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::EventTarget, \
|
|
|
|
mozilla::dom::EventTarget, 2, _extra) \
|
2013-03-09 03:34:29 -08:00
|
|
|
DOMCI_CASTABLE_INTERFACE(nsDOMEvent, nsIDOMEvent, 3, _extra) \
|
2012-12-23 14:33:33 -08:00
|
|
|
DOMCI_CASTABLE_INTERFACE(nsIDocument, nsIDocument, 4, _extra) \
|
2011-05-20 22:21:28 -07:00
|
|
|
DOMCI_CASTABLE_INTERFACE(nsDocument, nsIDocument, 5, _extra) \
|
2013-08-07 13:23:08 -07:00
|
|
|
DOMCI_CASTABLE_INTERFACE(nsGenericHTMLElement, nsIContent, 6, _extra) \
|
2011-05-20 22:21:28 -07:00
|
|
|
DOMCI_CASTABLE_INTERFACE(nsHTMLDocument, nsIDocument, 7, _extra) \
|
|
|
|
DOMCI_CASTABLE_INTERFACE(nsStyledElement, nsStyledElement, 8, _extra) \
|
2013-04-12 07:51:25 -07:00
|
|
|
DOMCI_CASTABLE_INTERFACE(nsSVGElement, nsIContent, 9, _extra) \
|
|
|
|
/* NOTE: When removing the casts below, remove the nsDOMEventBase class */ \
|
|
|
|
DOMCI_CASTABLE_INTERFACE(nsDOMMouseEvent, nsDOMEventBase, 10, _extra) \
|
|
|
|
DOMCI_CASTABLE_INTERFACE(nsDOMUIEvent, nsDOMEventBase, 11, _extra)
|
2012-12-23 00:22:22 -08:00
|
|
|
|
2010-04-09 13:48:38 -07:00
|
|
|
// Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES
|
|
|
|
// have been declared.
|
2012-11-14 14:10:07 -08:00
|
|
|
#define DOMCI_CASTABLE_NODECL_INTERFACE(_interface, _u1, _u2, _u3) /* Nothing */
|
2010-04-19 08:41:39 -07:00
|
|
|
#define DOMCI_CASTABLE_INTERFACE(_interface, _u1, _u2, _u3) class _interface;
|
2010-04-09 13:48:38 -07:00
|
|
|
DOMCI_CASTABLE_INTERFACES(unused)
|
|
|
|
#undef DOMCI_CASTABLE_INTERFACE
|
2012-11-14 14:10:07 -08:00
|
|
|
#undef DOMCI_CASTABLE_NODECL_INTERFACE
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Element;
|
2012-12-06 17:39:51 -08:00
|
|
|
class EventTarget;
|
2012-11-14 14:10:07 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#define DOMCI_CASTABLE_NODECL_INTERFACE DOMCI_CASTABLE_INTERFACE
|
2010-01-12 06:24:00 -08:00
|
|
|
|
2013-03-15 21:31:38 -07:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2009-02-17 06:08:08 -08:00
|
|
|
|
2010-01-12 06:24:00 -08:00
|
|
|
#define DOMCI_CLASS(_dom_class) \
|
2012-08-22 08:56:38 -07:00
|
|
|
extern const uint32_t kDOMClassInfo_##_dom_class##_interfaces;
|
2010-01-12 06:24:00 -08:00
|
|
|
|
|
|
|
#include "nsDOMClassInfoClasses.h"
|
|
|
|
|
|
|
|
#undef DOMCI_CLASS
|
|
|
|
|
|
|
|
/**
|
2010-04-09 13:48:38 -07:00
|
|
|
* Provide a general "does class C implement interface I" predicate.
|
|
|
|
* This is not as sophisticated as e.g. boost's is_base_of template,
|
|
|
|
* but it does the job adequately for our purposes.
|
2010-01-12 06:24:00 -08:00
|
|
|
*/
|
|
|
|
|
2012-12-18 10:22:28 -08:00
|
|
|
#if defined(__GNUC__) || _MSC_FULL_VER >= 140050215
|
2010-01-12 06:24:00 -08:00
|
|
|
|
2010-04-09 13:48:38 -07:00
|
|
|
/* Use a compiler intrinsic if one is available. */
|
|
|
|
|
|
|
|
#define DOMCI_CASTABLE_TO(_interface, _class) __is_base_of(_interface, _class)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/* The generic version of this predicate relies on the overload resolution
|
|
|
|
* rules. If |_class| inherits from |_interface|, the |_interface*|
|
|
|
|
* overload of DOMCI_CastableTo<_interface>::p() will be chosen, otherwise
|
|
|
|
* the |void*| overload will be chosen. There is no definition of these
|
|
|
|
* functions; we determine which overload was selected by inspecting the
|
|
|
|
* size of the return type.
|
|
|
|
*/
|
|
|
|
|
|
|
|
template <typename Interface> struct DOMCI_CastableTo {
|
|
|
|
struct false_type { int x[1]; };
|
|
|
|
struct true_type { int x[2]; };
|
|
|
|
static false_type p(void*);
|
|
|
|
static true_type p(Interface*);
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DOMCI_CASTABLE_TO(_interface, _class) \
|
|
|
|
(sizeof(DOMCI_CastableTo<_interface>::p(static_cast<_class*>(0))) == \
|
|
|
|
sizeof(DOMCI_CastableTo<_interface>::true_type))
|
|
|
|
|
|
|
|
#endif
|
2010-01-12 06:24:00 -08:00
|
|
|
|
|
|
|
/**
|
2010-04-09 13:48:38 -07:00
|
|
|
* Here we calculate the bitmap for a given class.
|
2010-01-12 06:24:00 -08:00
|
|
|
*/
|
2010-04-19 08:41:39 -07:00
|
|
|
#define DOMCI_CASTABLE_INTERFACE(_interface, _base, _bit, _class) \
|
2010-04-09 13:48:38 -07:00
|
|
|
(DOMCI_CASTABLE_TO(_interface, _class) ? 1 << _bit : 0) +
|
2010-01-12 06:24:00 -08:00
|
|
|
|
|
|
|
#define DOMCI_DATA(_dom_class, _class) \
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint32_t kDOMClassInfo_##_dom_class##_interfaces = \
|
2010-01-12 06:24:00 -08:00
|
|
|
DOMCI_CASTABLE_INTERFACES(_class) \
|
|
|
|
0;
|
2010-01-12 05:08:43 -08:00
|
|
|
|
2009-09-28 14:00:35 -07:00
|
|
|
class nsIClassInfo;
|
|
|
|
class nsXPCClassInfo;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
extern nsIClassInfo*
|
|
|
|
NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID);
|
|
|
|
|
|
|
|
#define NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(_class) \
|
2009-09-28 14:00:35 -07:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIClassInfo)) || \
|
|
|
|
aIID.Equals(NS_GET_IID(nsXPCClassInfo))) { \
|
2007-03-22 10:30:00 -07:00
|
|
|
foundInterface = NS_GetDOMClassInfoInstance(eDOMClassInfo_##_class##_id); \
|
|
|
|
if (!foundInterface) { \
|
2012-07-30 07:20:58 -07:00
|
|
|
*aInstancePtr = nullptr; \
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY; \
|
|
|
|
} \
|
|
|
|
} else
|
|
|
|
|
2010-10-13 16:25:33 -07:00
|
|
|
#define NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(_class, condition) \
|
|
|
|
if ((condition) && \
|
|
|
|
(aIID.Equals(NS_GET_IID(nsIClassInfo)) || \
|
|
|
|
aIID.Equals(NS_GET_IID(nsXPCClassInfo)))) { \
|
|
|
|
foundInterface = NS_GetDOMClassInfoInstance(eDOMClassInfo_##_class##_id); \
|
|
|
|
if (!foundInterface) { \
|
2012-07-30 07:20:58 -07:00
|
|
|
*aInstancePtr = nullptr; \
|
2010-10-13 16:25:33 -07:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY; \
|
|
|
|
} \
|
|
|
|
} else
|
|
|
|
|
2009-02-17 06:08:08 -08:00
|
|
|
#else
|
|
|
|
|
|
|
|
// See nsIDOMClassInfo.h
|
|
|
|
|
2013-03-15 21:31:38 -07:00
|
|
|
#endif // MOZILLA_INTERNAL_API
|
2009-02-17 06:08:08 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // nsDOMClassInfoID_h__
|