gecko-dev/js/public/WeakMapPtr.h
Jason Orendorff 50d9e51a7d Bug 1438278 - Part 3: Rename some files into js/src/gc. r=jonco.
jsgc.* -> gc/GC.*
jshashutil.h -> gc/HashUtil.h
jsweakmap.* -> gc/WeakMap.*
vm/WeakMapPtr.cpp -> gc/WeakMapPtr.cpp

--HG--
rename : js/src/jsgcinlines.h => js/src/gc/GC-inl.h
rename : js/src/jsgc.cpp => js/src/gc/GC.cpp
rename : js/src/jsgc.h => js/src/gc/GC.h
rename : js/src/jshashutil.h => js/src/gc/HashUtil.h
rename : js/src/jsweakmap.cpp => js/src/gc/WeakMap.cpp
rename : js/src/jsweakmap.h => js/src/gc/WeakMap.h
rename : js/src/vm/WeakMapPtr.cpp => js/src/gc/WeakMapPtr.cpp
extra : rebase_source : 8435ece63e11545a633ae0cdf6ed4a46cb017457
extra : amend_source : cfb63d098bf2fb27d63221a24457d8aaf8884137
extra : intermediate-source : 2d498c561ba67baf3ad09b6c29f4a8985997928c
extra : source : c1df7b31137da2bbea5ae1169cc07dd0f4974376
2018-02-14 16:00:46 -06:00

48 lines
1.4 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* 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/. */
#ifndef js_WeakMapPtr_h
#define js_WeakMapPtr_h
#include "jspubtd.h"
#include "js/TypeDecls.h"
namespace JS {
// A wrapper around the internal C++ representation of SpiderMonkey WeakMaps,
// usable outside the engine.
//
// The supported template specializations are enumerated in gc/WeakMapPtr.cpp.
// If you want to use this class for a different key/value combination, add it
// to the list and the compiler will generate the relevant machinery.
template <typename K, typename V>
class JS_PUBLIC_API(WeakMapPtr)
{
public:
WeakMapPtr() : ptr(nullptr) {}
bool init(JSContext* cx);
bool initialized() { return ptr != nullptr; }
void destroy();
virtual ~WeakMapPtr() { MOZ_ASSERT(!initialized()); }
void trace(JSTracer* tracer);
V lookup(const K& key);
bool put(JSContext* cx, const K& key, const V& value);
V removeValue(const K& key);
private:
void* ptr;
// WeakMapPtr is neither copyable nor assignable.
WeakMapPtr(const WeakMapPtr& wmp) = delete;
WeakMapPtr& operator=(const WeakMapPtr& wmp) = delete;
};
} /* namespace JS */
#endif /* js_WeakMapPtr_h */