Pyrogenesis  trunk
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ObjectIdCache< T > Class Template Reference

Providing a map-like structure with JSObject pointers (actually their hash) as keys with correct garbage collection handling (JSObjects can move in memory). More...

#include <ObjectToIDMap.h>

Collaboration diagram for ObjectIdCache< T >:
Collaboration graph
[legend]

Public Member Functions

 ObjectIdCache (shared_ptr< ScriptRuntime > rt)
 
 ~ObjectIdCache ()
 
bool init ()
 
void trace (JSTracer *trc)
 
bool find (JSObject *obj, T &ret)
 
bool add (JSContext *cx, JSObject *obj, T id)
 
void remove (JSObject *obj)
 
bool empty ()
 
bool has (JSObject *obj)
 

Private Types

typedef js::PointerHasher< JSObject *, 3 > Hasher
 
typedef js::HashMap< JSObject *, T, Hasher, js::SystemAllocPolicy > Table
 

Private Member Functions

 NONCOPYABLE (ObjectIdCache)
 

Static Private Member Functions

static void keyMarkCallback (JSTracer *trc, JSObject *key, void *data)
 
static void Trace (JSTracer *trc, void *data)
 
static void DeleteTable (void *table)
 

Private Attributes

shared_ptr< ScriptRuntimem_rt
 
Tabletable_
 

Detailed Description

template<typename T>
class ObjectIdCache< T >

Providing a map-like structure with JSObject pointers (actually their hash) as keys with correct garbage collection handling (JSObjects can move in memory).

The code in this class was copied from here and modified to work in our environment.

When updating SpiderMonkey, you most likely have to reintegrate an updated version of the class(es) in this file. The best way is probably to get a diff between the original files and integrate that because this file is heavily modified from the original version.

Member Typedef Documentation

template<typename T>
typedef js::PointerHasher<JSObject*, 3> ObjectIdCache< T >::Hasher
private
template<typename T>
typedef js::HashMap<JSObject*, T, Hasher, js::SystemAllocPolicy> ObjectIdCache< T >::Table
private

Constructor & Destructor Documentation

template<typename T>
ObjectIdCache< T >::ObjectIdCache ( shared_ptr< ScriptRuntime rt)
inline
template<typename T>
ObjectIdCache< T >::~ObjectIdCache ( )
inline

Member Function Documentation

template<typename T>
bool ObjectIdCache< T >::add ( JSContext *  cx,
JSObject *  obj,
T  id 
)
inline
template<typename T>
static void ObjectIdCache< T >::DeleteTable ( void *  table)
inlinestaticprivate
template<typename T>
bool ObjectIdCache< T >::empty ( )
inline
template<typename T>
bool ObjectIdCache< T >::find ( JSObject *  obj,
T ret 
)
inline
template<typename T>
bool ObjectIdCache< T >::has ( JSObject *  obj)
inline
template<typename T>
bool ObjectIdCache< T >::init ( )
inline
template<typename T>
static void ObjectIdCache< T >::keyMarkCallback ( JSTracer *  trc,
JSObject *  key,
void *  data 
)
inlinestaticprivate
template<typename T>
ObjectIdCache< T >::NONCOPYABLE ( ObjectIdCache< T )
private
template<typename T>
void ObjectIdCache< T >::remove ( JSObject *  obj)
inline
template<typename T>
void ObjectIdCache< T >::trace ( JSTracer *  trc)
inline
template<typename T>
static void ObjectIdCache< T >::Trace ( JSTracer *  trc,
void *  data 
)
inlinestaticprivate

Member Data Documentation

template<typename T>
shared_ptr<ScriptRuntime> ObjectIdCache< T >::m_rt
private
template<typename T>
Table* ObjectIdCache< T >::table_
private

The documentation for this class was generated from the following file: