2012-12-25 14:00:15 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
|
|
|
/* vim: set ts=2 sw=2 et tw=79: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A header for declaring various things that binding implementation headers
|
|
|
|
* might need. The idea is to make binding implementation headers safe to
|
|
|
|
* include anywhere without running into include hell like we do with
|
|
|
|
* BindingUtils.h
|
|
|
|
*/
|
|
|
|
#ifndef mozilla_dom_BindingDeclarations_h__
|
|
|
|
#define mozilla_dom_BindingDeclarations_h__
|
|
|
|
|
|
|
|
#include "nsStringGlue.h"
|
2013-08-17 15:50:18 -07:00
|
|
|
#include "js/Value.h"
|
|
|
|
#include "js/RootingAPI.h"
|
2013-08-27 15:10:28 -07:00
|
|
|
#include "mozilla/Maybe.h"
|
2012-12-03 08:07:49 -08:00
|
|
|
#include "nsCOMPtr.h"
|
2013-02-06 01:56:15 -08:00
|
|
|
#include "nsTArray.h"
|
2013-04-17 13:17:44 -07:00
|
|
|
#include "nsAutoPtr.h" // for nsRefPtr member variables
|
2013-10-11 09:28:23 -07:00
|
|
|
#include "mozilla/dom/DOMString.h"
|
2013-09-10 09:06:46 -07:00
|
|
|
#include "mozilla/dom/OwningNonNull.h"
|
2012-12-25 14:00:15 -08:00
|
|
|
|
2013-03-17 07:42:59 -07:00
|
|
|
class nsWrapperCache;
|
|
|
|
|
2012-12-25 14:00:15 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2013-05-16 09:36:55 -07:00
|
|
|
// Struct that serves as a base class for all dictionaries. Particularly useful
|
|
|
|
// so we can use IsBaseOf to detect dictionary template arguments.
|
|
|
|
struct DictionaryBase
|
|
|
|
{
|
2014-02-06 18:08:28 -08:00
|
|
|
protected:
|
|
|
|
bool ParseJSON(JSContext* aCx, const nsAString& aJSON,
|
|
|
|
JS::MutableHandle<JS::Value> aVal);
|
2014-07-31 20:50:19 -07:00
|
|
|
|
|
|
|
bool StringifyToJSON(JSContext* aCx,
|
|
|
|
JS::MutableHandle<JS::Value> aValue,
|
2014-09-09 11:00:22 -07:00
|
|
|
nsAString& aJSON) const;
|
2014-07-31 20:50:19 -07:00
|
|
|
private:
|
|
|
|
// aString is expected to actually be an nsAString*. Should only be
|
|
|
|
// called from StringifyToJSON.
|
2014-07-21 21:43:21 -07:00
|
|
|
static bool AppendJSONToString(const char16_t* aJSONData,
|
|
|
|
uint32_t aDataLength, void* aString);
|
2013-05-16 09:36:55 -07:00
|
|
|
};
|
|
|
|
|
2013-08-05 10:40:02 -07:00
|
|
|
// Struct that serves as a base class for all typed arrays and array buffers and
|
|
|
|
// array buffer views. Particularly useful so we can use IsBaseOf to detect
|
|
|
|
// typed array/buffer/view template arguments.
|
|
|
|
struct AllTypedArraysBase {
|
|
|
|
};
|
|
|
|
|
2014-03-14 11:51:22 -07:00
|
|
|
// Struct that serves as a base class for all owning unions.
|
|
|
|
// Particularly useful so we can use IsBaseOf to detect owning union
|
|
|
|
// template arguments.
|
|
|
|
struct AllOwningUnionBase {
|
|
|
|
};
|
|
|
|
|
2013-08-05 10:40:02 -07:00
|
|
|
|
2012-12-25 14:00:15 -08:00
|
|
|
struct EnumEntry {
|
|
|
|
const char* value;
|
|
|
|
size_t length;
|
|
|
|
};
|
|
|
|
|
2013-04-11 20:20:18 -07:00
|
|
|
class MOZ_STACK_CLASS GlobalObject
|
2012-12-03 08:07:49 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
GlobalObject(JSContext* aCx, JSObject* aObject);
|
|
|
|
|
|
|
|
JSObject* Get() const
|
|
|
|
{
|
|
|
|
return mGlobalJSObject;
|
|
|
|
}
|
2013-08-22 22:17:08 -07:00
|
|
|
|
|
|
|
nsISupports* GetAsSupports() const;
|
|
|
|
|
2012-12-03 08:07:49 -08:00
|
|
|
// The context that this returns is not guaranteed to be in the compartment of
|
|
|
|
// the object returned from Get(), in fact it's generally in the caller's
|
|
|
|
// compartment.
|
2014-06-16 11:08:00 -07:00
|
|
|
JSContext* Context() const
|
2012-12-03 08:07:49 -08:00
|
|
|
{
|
|
|
|
return mCx;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Failed() const
|
|
|
|
{
|
|
|
|
return !Get();
|
|
|
|
}
|
|
|
|
|
2013-08-22 22:17:08 -07:00
|
|
|
protected:
|
2013-11-11 00:04:41 -08:00
|
|
|
JS::Rooted<JSObject*> mGlobalJSObject;
|
2012-12-03 08:07:49 -08:00
|
|
|
JSContext* mCx;
|
2013-08-22 22:17:08 -07:00
|
|
|
mutable nsISupports* mGlobalObject;
|
2012-12-03 08:07:49 -08:00
|
|
|
};
|
|
|
|
|
2013-02-06 01:56:15 -08:00
|
|
|
// Class for representing optional arguments.
|
2013-05-16 09:36:56 -07:00
|
|
|
template<typename T, typename InternalType>
|
|
|
|
class Optional_base
|
2013-02-06 01:56:15 -08:00
|
|
|
{
|
|
|
|
public:
|
2013-05-16 09:36:56 -07:00
|
|
|
Optional_base()
|
2013-02-06 01:56:15 -08:00
|
|
|
{}
|
|
|
|
|
2013-05-16 09:36:56 -07:00
|
|
|
explicit Optional_base(const T& aValue)
|
2013-04-24 05:36:10 -07:00
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
mImpl.emplace(aValue);
|
2013-04-24 05:36:10 -07:00
|
|
|
}
|
|
|
|
|
2013-05-16 09:36:56 -07:00
|
|
|
template<typename T1, typename T2>
|
|
|
|
explicit Optional_base(const T1& aValue1, const T2& aValue2)
|
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
mImpl.emplace(aValue1, aValue2);
|
2013-05-16 09:36:56 -07:00
|
|
|
}
|
|
|
|
|
2013-02-06 01:56:15 -08:00
|
|
|
bool WasPassed() const
|
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
return mImpl.isSome();
|
2013-02-06 01:56:15 -08:00
|
|
|
}
|
|
|
|
|
2014-04-09 23:03:29 -07:00
|
|
|
// Return InternalType here so we can work with it usefully.
|
|
|
|
InternalType& Construct()
|
2013-02-06 01:56:15 -08:00
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
mImpl.emplace();
|
|
|
|
return *mImpl;
|
2013-02-06 01:56:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class T1>
|
2014-04-09 23:03:29 -07:00
|
|
|
InternalType& Construct(const T1 &t1)
|
2013-02-06 01:56:15 -08:00
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
mImpl.emplace(t1);
|
|
|
|
return *mImpl;
|
2013-02-06 01:56:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class T1, class T2>
|
2014-04-09 23:03:29 -07:00
|
|
|
InternalType& Construct(const T1 &t1, const T2 &t2)
|
2013-02-06 01:56:15 -08:00
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
mImpl.emplace(t1, t2);
|
|
|
|
return *mImpl;
|
2013-02-06 01:56:15 -08:00
|
|
|
}
|
|
|
|
|
2013-09-13 10:21:59 -07:00
|
|
|
void Reset()
|
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
mImpl.reset();
|
2013-09-13 10:21:59 -07:00
|
|
|
}
|
|
|
|
|
2013-06-19 11:48:43 -07:00
|
|
|
const T& Value() const
|
2013-02-06 01:56:15 -08:00
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
return *mImpl;
|
2013-02-06 01:56:15 -08:00
|
|
|
}
|
|
|
|
|
2013-06-19 11:48:43 -07:00
|
|
|
// Return InternalType here so we can work with it usefully.
|
2013-05-16 09:36:56 -07:00
|
|
|
InternalType& Value()
|
2013-02-06 01:56:15 -08:00
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
return *mImpl;
|
2013-02-06 01:56:15 -08:00
|
|
|
}
|
|
|
|
|
2013-06-19 11:48:43 -07:00
|
|
|
// And an explicit way to get the InternalType even if we're const.
|
|
|
|
const InternalType& InternalValue() const
|
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
return *mImpl;
|
2013-06-19 11:48:43 -07:00
|
|
|
}
|
|
|
|
|
2013-02-06 01:56:15 -08:00
|
|
|
// If we ever decide to add conversion operators for optional arrays
|
|
|
|
// like the ones Nullable has, we'll need to ensure that Maybe<> has
|
|
|
|
// the boolean before the actual data.
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Forbid copy-construction and assignment
|
2013-05-16 09:36:56 -07:00
|
|
|
Optional_base(const Optional_base& other) MOZ_DELETE;
|
|
|
|
const Optional_base &operator=(const Optional_base &other) MOZ_DELETE;
|
|
|
|
|
2013-06-19 11:48:43 -07:00
|
|
|
protected:
|
2013-05-16 09:36:56 -07:00
|
|
|
Maybe<InternalType> mImpl;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
class Optional : public Optional_base<T, T>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Optional() :
|
|
|
|
Optional_base<T, T>()
|
|
|
|
{}
|
|
|
|
|
|
|
|
explicit Optional(const T& aValue) :
|
|
|
|
Optional_base<T, T>(aValue)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
class Optional<JS::Handle<T> > :
|
|
|
|
public Optional_base<JS::Handle<T>, JS::Rooted<T> >
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Optional() :
|
|
|
|
Optional_base<JS::Handle<T>, JS::Rooted<T> >()
|
|
|
|
{}
|
2013-02-06 01:56:15 -08:00
|
|
|
|
2014-07-28 10:17:51 -07:00
|
|
|
explicit Optional(JSContext* cx) :
|
2013-06-11 18:41:21 -07:00
|
|
|
Optional_base<JS::Handle<T>, JS::Rooted<T> >()
|
|
|
|
{
|
|
|
|
this->Construct(cx);
|
|
|
|
}
|
|
|
|
|
2013-05-16 09:36:56 -07:00
|
|
|
Optional(JSContext* cx, const T& aValue) :
|
|
|
|
Optional_base<JS::Handle<T>, JS::Rooted<T> >(cx, aValue)
|
|
|
|
{}
|
2013-06-19 11:48:43 -07:00
|
|
|
|
|
|
|
// Override the const Value() to return the right thing so we're not
|
|
|
|
// returning references to temporaries.
|
|
|
|
JS::Handle<T> Value() const
|
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
return *this->mImpl;
|
2013-06-19 11:48:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// And we have to override the non-const one too, since we're
|
|
|
|
// shadowing the one on the superclass.
|
|
|
|
JS::Rooted<T>& Value()
|
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
return *this->mImpl;
|
2013-06-19 11:48:43 -07:00
|
|
|
}
|
2013-02-06 01:56:15 -08:00
|
|
|
};
|
|
|
|
|
2013-05-21 11:15:30 -07:00
|
|
|
// A specialization of Optional for JSObject* to make sure that when someone
|
|
|
|
// calls Construct() on it we will pre-initialized the JSObject* to nullptr so
|
|
|
|
// it can be traced safely.
|
|
|
|
template<>
|
|
|
|
class Optional<JSObject*> : public Optional_base<JSObject*, JSObject*>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Optional() :
|
|
|
|
Optional_base<JSObject*, JSObject*>()
|
|
|
|
{}
|
|
|
|
|
|
|
|
explicit Optional(JSObject* aValue) :
|
|
|
|
Optional_base<JSObject*, JSObject*>(aValue)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// Don't allow us to have an uninitialized JSObject*
|
2014-04-09 23:03:29 -07:00
|
|
|
JSObject*& Construct()
|
2013-05-21 11:15:30 -07:00
|
|
|
{
|
|
|
|
// The Android compiler sucks and thinks we're trying to construct
|
|
|
|
// a JSObject* from an int if we don't cast here. :(
|
2014-04-09 23:03:29 -07:00
|
|
|
return Optional_base<JSObject*, JSObject*>::Construct(
|
2013-05-21 11:15:30 -07:00
|
|
|
static_cast<JSObject*>(nullptr));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T1>
|
2014-04-09 23:03:29 -07:00
|
|
|
JSObject*& Construct(const T1& t1)
|
2013-05-21 11:15:30 -07:00
|
|
|
{
|
2014-04-09 23:03:29 -07:00
|
|
|
return Optional_base<JSObject*, JSObject*>::Construct(t1);
|
2013-05-21 11:15:30 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-19 07:13:38 -08:00
|
|
|
// A specialization of Optional for JS::Value to make sure no one ever uses it.
|
2013-05-21 11:15:30 -07:00
|
|
|
template<>
|
2014-02-19 07:13:38 -08:00
|
|
|
class Optional<JS::Value>
|
2013-05-21 11:15:30 -07:00
|
|
|
{
|
2014-02-19 07:13:38 -08:00
|
|
|
private:
|
|
|
|
Optional() MOZ_DELETE;
|
2013-05-21 11:15:30 -07:00
|
|
|
|
2014-02-19 07:13:38 -08:00
|
|
|
explicit Optional(JS::Value aValue) MOZ_DELETE;
|
2013-05-21 11:15:30 -07:00
|
|
|
};
|
|
|
|
|
2013-06-19 11:48:43 -07:00
|
|
|
// A specialization of Optional for NonNull that lets us get a T& from Value()
|
|
|
|
template<typename U> class NonNull;
|
|
|
|
template<typename T>
|
|
|
|
class Optional<NonNull<T> > : public Optional_base<T, NonNull<T> >
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// We want our Value to actually return a non-const reference, even
|
|
|
|
// if we're const. At least for things that are normally pointer
|
|
|
|
// types...
|
|
|
|
T& Value() const
|
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
return *this->mImpl->get();
|
2013-06-19 11:48:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// And we have to override the non-const one too, since we're
|
|
|
|
// shadowing the one on the superclass.
|
|
|
|
NonNull<T>& Value()
|
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
return *this->mImpl;
|
2013-06-19 11:48:43 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// A specialization of Optional for OwningNonNull that lets us get a
|
|
|
|
// T& from Value()
|
|
|
|
template<typename T>
|
|
|
|
class Optional<OwningNonNull<T> > : public Optional_base<T, OwningNonNull<T> >
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// We want our Value to actually return a non-const reference, even
|
|
|
|
// if we're const. At least for things that are normally pointer
|
|
|
|
// types...
|
|
|
|
T& Value() const
|
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
return *this->mImpl->get();
|
2013-06-19 11:48:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// And we have to override the non-const one too, since we're
|
|
|
|
// shadowing the one on the superclass.
|
|
|
|
OwningNonNull<T>& Value()
|
|
|
|
{
|
2014-08-13 15:39:41 -07:00
|
|
|
return *this->mImpl;
|
2013-06-19 11:48:43 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-06 01:56:15 -08:00
|
|
|
// Specialization for strings.
|
2014-07-03 01:03:56 -07:00
|
|
|
// XXXbz we can't pull in FakeString here, because it depends on internal
|
|
|
|
// strings. So we just have to forward-declare it and reimplement its
|
2013-02-06 01:56:15 -08:00
|
|
|
// ToAStringPtr.
|
|
|
|
|
2014-01-22 11:37:10 -08:00
|
|
|
namespace binding_detail {
|
2014-07-03 01:03:56 -07:00
|
|
|
struct FakeString;
|
2014-01-22 11:37:10 -08:00
|
|
|
} // namespace binding_detail
|
2013-02-06 01:56:15 -08:00
|
|
|
|
|
|
|
template<>
|
|
|
|
class Optional<nsAString>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Optional() : mPassed(false) {}
|
|
|
|
|
|
|
|
bool WasPassed() const
|
|
|
|
{
|
|
|
|
return mPassed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator=(const nsAString* str)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(str);
|
|
|
|
mStr = str;
|
|
|
|
mPassed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this code ever goes away, remove the comment pointing to it in the
|
2014-07-03 01:03:56 -07:00
|
|
|
// FakeString class in BindingUtils.h.
|
|
|
|
void operator=(const binding_detail::FakeString* str)
|
2013-02-06 01:56:15 -08:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(str);
|
2014-07-03 01:03:56 -07:00
|
|
|
mStr = reinterpret_cast<const nsString*>(str);
|
2013-02-06 01:56:15 -08:00
|
|
|
mPassed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsAString& Value() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(WasPassed());
|
|
|
|
return *mStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Forbid copy-construction and assignment
|
|
|
|
Optional(const Optional& other) MOZ_DELETE;
|
|
|
|
const Optional &operator=(const Optional &other) MOZ_DELETE;
|
|
|
|
|
|
|
|
bool mPassed;
|
|
|
|
const nsAString* mStr;
|
|
|
|
};
|
|
|
|
|
2013-06-19 07:24:37 -07:00
|
|
|
template<class T>
|
|
|
|
class NonNull
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NonNull()
|
|
|
|
#ifdef DEBUG
|
|
|
|
: inited(false)
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
|
2014-06-23 13:03:57 -07:00
|
|
|
// This is no worse than get() in terms of const handling.
|
|
|
|
operator T&() const {
|
2013-06-19 07:24:37 -07:00
|
|
|
MOZ_ASSERT(inited);
|
|
|
|
MOZ_ASSERT(ptr, "NonNull<T> was set to null");
|
|
|
|
return *ptr;
|
|
|
|
}
|
|
|
|
|
2014-06-23 13:03:57 -07:00
|
|
|
operator T*() const {
|
2013-12-20 00:51:03 -08:00
|
|
|
MOZ_ASSERT(inited);
|
|
|
|
MOZ_ASSERT(ptr, "NonNull<T> was set to null");
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2013-06-19 07:24:37 -07:00
|
|
|
void operator=(T* t) {
|
|
|
|
ptr = t;
|
|
|
|
MOZ_ASSERT(ptr);
|
|
|
|
#ifdef DEBUG
|
|
|
|
inited = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename U>
|
|
|
|
void operator=(U* t) {
|
|
|
|
ptr = t->ToAStringPtr();
|
|
|
|
MOZ_ASSERT(ptr);
|
|
|
|
#ifdef DEBUG
|
|
|
|
inited = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
T** Slot() {
|
|
|
|
#ifdef DEBUG
|
|
|
|
inited = true;
|
|
|
|
#endif
|
|
|
|
return &ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
T* Ptr() {
|
|
|
|
MOZ_ASSERT(inited);
|
|
|
|
MOZ_ASSERT(ptr, "NonNull<T> was set to null");
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make us work with smart-ptr helpers that expect a get()
|
|
|
|
T* get() const {
|
|
|
|
MOZ_ASSERT(inited);
|
|
|
|
MOZ_ASSERT(ptr);
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
T* ptr;
|
|
|
|
#ifdef DEBUG
|
|
|
|
bool inited;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2013-03-01 22:07:43 -08:00
|
|
|
// Class for representing sequences in arguments. We use a non-auto array
|
|
|
|
// because that allows us to use sequences of sequences and the like. This
|
|
|
|
// needs to be fallible because web content controls the length of the array,
|
|
|
|
// and can easily try to create very large lengths.
|
2013-02-06 01:56:15 -08:00
|
|
|
template<typename T>
|
2013-03-01 22:07:43 -08:00
|
|
|
class Sequence : public FallibleTArray<T>
|
2013-02-06 01:56:15 -08:00
|
|
|
{
|
|
|
|
public:
|
2013-03-01 22:07:43 -08:00
|
|
|
Sequence() : FallibleTArray<T>()
|
2013-02-06 01:56:15 -08:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2013-03-17 07:42:59 -07:00
|
|
|
inline nsWrapperCache*
|
|
|
|
GetWrapperCache(nsWrapperCache* cache)
|
|
|
|
{
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsWrapperCache*
|
|
|
|
GetWrapperCache(void* p)
|
|
|
|
{
|
2013-10-28 07:04:12 -07:00
|
|
|
return nullptr;
|
2013-03-17 07:42:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Helper template for smart pointers to resolve ambiguity between
|
|
|
|
// GetWrappeCache(void*) and GetWrapperCache(const ParentObject&).
|
|
|
|
template <template <typename> class SmartPtr, typename T>
|
|
|
|
inline nsWrapperCache*
|
|
|
|
GetWrapperCache(const SmartPtr<T>& aObject)
|
|
|
|
{
|
|
|
|
return GetWrapperCache(aObject.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ParentObject {
|
|
|
|
template<class T>
|
|
|
|
ParentObject(T* aObject) :
|
|
|
|
mObject(aObject),
|
2014-03-19 09:35:45 -07:00
|
|
|
mWrapperCache(GetWrapperCache(aObject)),
|
|
|
|
mUseXBLScope(false)
|
2013-03-17 07:42:59 -07:00
|
|
|
{}
|
|
|
|
|
|
|
|
template<class T, template<typename> class SmartPtr>
|
|
|
|
ParentObject(const SmartPtr<T>& aObject) :
|
|
|
|
mObject(aObject.get()),
|
2014-03-19 09:35:45 -07:00
|
|
|
mWrapperCache(GetWrapperCache(aObject.get())),
|
|
|
|
mUseXBLScope(false)
|
2013-03-17 07:42:59 -07:00
|
|
|
{}
|
|
|
|
|
|
|
|
ParentObject(nsISupports* aObject, nsWrapperCache* aCache) :
|
|
|
|
mObject(aObject),
|
2014-03-19 09:35:45 -07:00
|
|
|
mWrapperCache(aCache),
|
|
|
|
mUseXBLScope(false)
|
2013-03-17 07:42:59 -07:00
|
|
|
{}
|
|
|
|
|
|
|
|
nsISupports* const mObject;
|
|
|
|
nsWrapperCache* const mWrapperCache;
|
2014-03-19 09:35:45 -07:00
|
|
|
bool mUseXBLScope;
|
2013-03-17 07:42:59 -07:00
|
|
|
};
|
|
|
|
|
2012-12-25 14:00:15 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-10-11 09:28:23 -07:00
|
|
|
#endif // mozilla_dom_BindingDeclarations_h__
|