src/Handles.h
changeset 195 c1ba166f3fc4
parent 191 9d17f29fe16a
child 196 9904633b1dfc
     1.1 --- a/src/Handles.h	Mon Sep 17 00:10:01 2012 -0700
     1.2 +++ b/src/Handles.h	Sat Nov 17 18:41:01 2012 -0800
     1.3 @@ -29,6 +29,11 @@
     1.4  template <typename T> class Local;
     1.5  template <typename T> class ScopedRoot;
     1.6  
     1.7 +struct NullAddress
     1.8 +{
     1.9 +    static void * const Sentinel;
    1.10 +};
    1.11 +
    1.12  /*
    1.13   * Internal handles work differently from API handles. An API handle is a
    1.14   * root, whereas as an internal handle points to a rooted location. This
    1.15 @@ -40,6 +45,12 @@
    1.16  {
    1.17      T * const *thingp_;
    1.18  
    1.19 +  private:
    1.20 +    Handle()
    1.21 +      : thingp_(reinterpret_cast<T * const *>(&NullAddress::Sentinel))
    1.22 +    {
    1.23 +    }
    1.24 +
    1.25    public:
    1.26      Handle(const Handle &other) {
    1.27          thingp_ = other.address();
    1.28 @@ -51,6 +62,10 @@
    1.29      template <typename S> inline Handle(const Local<S> &local);
    1.30      template <typename S> inline Handle(const ScopedRoot<S> &root);
    1.31  
    1.32 +    static inline Handle Null() {
    1.33 +        return Handle();
    1.34 +    }
    1.35 +
    1.36    public:
    1.37      T *operator ->() {
    1.38          return *thingp_;