Added initial String: support.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of JITCraft.
6 * JITCraft is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
11 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * JITCraft. If not, see http://www.gnu.org/licenses/.
18 #ifndef _include_jitcraft_rooting_h_
19 #define _include_jitcraft_rooting_h_
27 template <typename T> class Local;
28 template <typename T> class ScopedRoot;
36 template <typename S> Handle(const Handle<S> &handle) {
38 thingp_ = reinterpret_cast<const T **>(handle.thingp_);
40 template <typename S> inline Handle(const Local<S> &local);
41 template <typename S> inline Handle(const ScopedRoot<S> &root);
50 operator T() { return *thingp_; }
51 operator bool() const {
52 return thingp_ && *thingp_;
79 Local<Object> *prev() {
82 Local<Object> *toRaw() {
83 return reinterpret_cast<Local<Object>*>(this);
87 inline explicit Local(Zone *zone);
88 inline explicit Local(Zone *zone, T *thing);
91 const Local &operator =(T *thing) {
95 T *operator ->() const {
98 T *operator *() const {
101 operator bool () const {
106 return (Object **)&thing_;
108 Object * const *addr() const {
109 return (Object * const *)&thing_;
116 // Disallow heap allocation.
117 void *operator new(size_t size);
118 void *operator new[](size_t size);
120 // Disallow copy construction.
121 Local(const Local<T> &other);
122 Local &operator =(const Local &other);
125 template <typename T> template <typename S> inline
126 Handle<T>::Handle(const Local<S> &local)
129 thingp_ = reinterpret_cast<T * const*>(local.addr());
134 #endif // _include_jitcraft_rooting_h_