mirror of
https://github.com/holub/mame
synced 2025-04-24 01:11:11 +03:00
Be consistent about template argument naming.
This commit is contained in:
parent
580b29ee33
commit
932a42eac4
@ -121,7 +121,7 @@ struct drcbe_info
|
||||
// a drcuml_block describes a basic block of instructions
|
||||
class drcuml_block
|
||||
{
|
||||
template<class T> friend class simple_list;
|
||||
friend class simple_list<drcuml_block>;
|
||||
|
||||
public:
|
||||
// construction/destruction
|
||||
@ -232,7 +232,7 @@ private:
|
||||
class symbol
|
||||
{
|
||||
friend class drcuml_state;
|
||||
template<class T> friend class simple_list;
|
||||
friend class simple_list<symbol>;
|
||||
|
||||
// construction/destruction
|
||||
symbol(void *base, UINT32 length, const char *name)
|
||||
|
@ -258,7 +258,7 @@ namespace uml
|
||||
class code_handle
|
||||
{
|
||||
friend class ::drcuml_state;
|
||||
template<class T> friend class ::simple_list;
|
||||
friend class ::simple_list<code_handle>;
|
||||
|
||||
// construction/destruction
|
||||
code_handle(drcuml_state &drcuml, const char *name);
|
||||
|
@ -106,10 +106,10 @@ typedef device_t *(*device_type)(const machine_config &mconfig, const char *tag,
|
||||
|
||||
|
||||
// this template function creates a stub which constructs a device
|
||||
template<class T>
|
||||
template<class _DeviceClass>
|
||||
device_t *device_creator(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
{
|
||||
return global_alloc(T(mconfig, tag, owner, clock));
|
||||
return global_alloc(_DeviceClass(mconfig, tag, owner, clock));
|
||||
}
|
||||
|
||||
|
||||
@ -158,8 +158,8 @@ public:
|
||||
device_t *find(device_type type, int index) const;
|
||||
|
||||
// provide interface-specific overrides
|
||||
template<class I>
|
||||
bool first(I *&intf) const;
|
||||
template<class _InterfaceClass>
|
||||
bool first(_InterfaceClass *&intf) const;
|
||||
|
||||
private:
|
||||
// internal helpers
|
||||
@ -215,9 +215,9 @@ public:
|
||||
device_t *owner() const { return m_owner; }
|
||||
|
||||
// interface helpers
|
||||
template<class T> bool interface(T *&intf) { intf = dynamic_cast<T *>(this); return (intf != NULL); }
|
||||
template<class T> bool interface(T *&intf) const { intf = dynamic_cast<const T *>(this); return (intf != NULL); }
|
||||
template<class T> bool next(T *&intf) const
|
||||
template<class _DeviceClass> bool interface(_DeviceClass *&intf) { intf = dynamic_cast<_DeviceClass *>(this); return (intf != NULL); }
|
||||
template<class _DeviceClass> bool interface(_DeviceClass *&intf) const { intf = dynamic_cast<const _DeviceClass *>(this); return (intf != NULL); }
|
||||
template<class _DeviceClass> bool next(_DeviceClass *&intf) const
|
||||
{
|
||||
for (device_t *cur = m_next; cur != NULL; cur = cur->m_next)
|
||||
if (cur->interface(intf))
|
||||
@ -241,8 +241,8 @@ public:
|
||||
const memory_region *subregion(const char *tag) const;
|
||||
device_t *subdevice(const char *tag) const;
|
||||
device_t *siblingdevice(const char *tag) const;
|
||||
template<class T> inline T *subdevice(const char *tag) { return downcast<T *>(subdevice(tag)); }
|
||||
template<class T> inline T *siblingdevice(const char *tag) { return downcast<T *>(siblingdevice(tag)); }
|
||||
template<class _DeviceClass> inline _DeviceClass *subdevice(const char *tag) { return downcast<_DeviceClass *>(subdevice(tag)); }
|
||||
template<class _DeviceClass> inline _DeviceClass *siblingdevice(const char *tag) { return downcast<_DeviceClass *>(siblingdevice(tag)); }
|
||||
const memory_region *region() const { return m_region; }
|
||||
|
||||
// configuration helpers
|
||||
@ -273,10 +273,10 @@ public:
|
||||
void timer_expired(emu_timer &timer, device_timer_id id, int param, void *ptr) { device_timer(timer, id, param, ptr); }
|
||||
|
||||
// state saving interfaces
|
||||
template<typename T>
|
||||
void save_item(T &value, const char *valname, int index = 0) { assert(m_save != NULL); m_save->save_item(name(), tag(), index, value, valname); }
|
||||
template<typename T>
|
||||
void save_pointer(T *value, const char *valname, UINT32 count, int index = 0) { assert(m_save != NULL); m_save->save_pointer(name(), tag(), index, value, valname, count); }
|
||||
template<typename _ItemType>
|
||||
void save_item(_ItemType &value, const char *valname, int index = 0) { assert(m_save != NULL); m_save->save_item(name(), tag(), index, value, valname); }
|
||||
template<typename _ItemType>
|
||||
void save_pointer(_ItemType *value, const char *valname, UINT32 count, int index = 0) { assert(m_save != NULL); m_save->save_pointer(name(), tag(), index, value, valname, count); }
|
||||
|
||||
// debugging
|
||||
device_debug *debug() const { return m_debug; }
|
||||
@ -477,7 +477,7 @@ public:
|
||||
|
||||
// iteration helpers
|
||||
device_interface *interface_next() const { return m_interface_next; }
|
||||
template<class T> bool next(T *&intf) const { return m_device.next(intf); }
|
||||
template<class _InterfaceClass> bool next(_InterfaceClass *&intf) const { return m_device.next(intf); }
|
||||
|
||||
// optional operation overrides
|
||||
virtual void interface_config_complete();
|
||||
@ -530,8 +530,8 @@ inline astring &device_t::siblingtag(astring &dest, const char *_tag) const
|
||||
}
|
||||
|
||||
|
||||
template<class I>
|
||||
bool device_list::first(I *&intf) const
|
||||
template<class _InterfaceClass>
|
||||
bool device_list::first(_InterfaceClass *&intf) const
|
||||
{
|
||||
for (device_t *cur = super::first(); cur != NULL; cur = cur->next())
|
||||
if (cur->interface(intf))
|
||||
|
@ -205,10 +205,10 @@ deviceclass::deviceclass(const machine_config &mconfig, device_type type, const
|
||||
const device_type name = &legacy_device_creator<deviceclass>
|
||||
|
||||
// this template function creates a stub which constructs a device
|
||||
template<class T>
|
||||
template<class _DeviceClass>
|
||||
device_t *legacy_device_creator(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
{
|
||||
return global_alloc(T(mconfig, &legacy_device_creator<T>, tag, owner, clock));
|
||||
return global_alloc(_DeviceClass(mconfig, &legacy_device_creator<_DeviceClass>, tag, owner, clock));
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,7 +166,7 @@ public:
|
||||
public: // protected eventually
|
||||
|
||||
// add a new state item
|
||||
template<class T> device_state_entry &state_add(int index, const char *symbol, T &data)
|
||||
template<class _ItemType> device_state_entry &state_add(int index, const char *symbol, _ItemType &data)
|
||||
{
|
||||
return state_add(index, symbol, &data, sizeof(data));
|
||||
}
|
||||
|
@ -231,40 +231,41 @@ public:
|
||||
|
||||
|
||||
// a resource_pool_object is a simple object wrapper for the templatized type
|
||||
template<class T> class resource_pool_object : public resource_pool_item
|
||||
template<class _ObjectClass>
|
||||
class resource_pool_object : public resource_pool_item
|
||||
{
|
||||
private:
|
||||
resource_pool_object<T>(const resource_pool_object<T> &);
|
||||
resource_pool_object<T> &operator=(const resource_pool_object<T> &);
|
||||
resource_pool_object<_ObjectClass>(const resource_pool_object<_ObjectClass> &);
|
||||
resource_pool_object<_ObjectClass> &operator=(const resource_pool_object<_ObjectClass> &);
|
||||
|
||||
public:
|
||||
resource_pool_object(T *object)
|
||||
: resource_pool_item(reinterpret_cast<void *>(object), sizeof(T)),
|
||||
resource_pool_object(_ObjectClass *object)
|
||||
: resource_pool_item(reinterpret_cast<void *>(object), sizeof(_ObjectClass)),
|
||||
m_object(object) { }
|
||||
virtual ~resource_pool_object() { delete m_object; }
|
||||
|
||||
private:
|
||||
T * m_object;
|
||||
_ObjectClass * m_object;
|
||||
};
|
||||
|
||||
|
||||
// a resource_pool_array is a simple object wrapper for an allocated array of
|
||||
// the templatized type
|
||||
template<class T> class resource_pool_array : public resource_pool_item
|
||||
template<class _ObjectClass> class resource_pool_array : public resource_pool_item
|
||||
{
|
||||
private:
|
||||
resource_pool_array<T>(const resource_pool_array<T> &);
|
||||
resource_pool_array<T> &operator=(const resource_pool_array<T> &);
|
||||
resource_pool_array<_ObjectClass>(const resource_pool_array<_ObjectClass> &);
|
||||
resource_pool_array<_ObjectClass> &operator=(const resource_pool_array<_ObjectClass> &);
|
||||
|
||||
public:
|
||||
resource_pool_array(T *array, int count)
|
||||
: resource_pool_item(reinterpret_cast<void *>(array), sizeof(T) * count),
|
||||
resource_pool_array(_ObjectClass *array, int count)
|
||||
: resource_pool_item(reinterpret_cast<void *>(array), sizeof(_ObjectClass) * count),
|
||||
m_array(array),
|
||||
m_count(count) { }
|
||||
virtual ~resource_pool_array() { delete[] m_array; }
|
||||
|
||||
private:
|
||||
T * m_array;
|
||||
_ObjectClass * m_array;
|
||||
int m_count;
|
||||
};
|
||||
|
||||
@ -288,8 +289,8 @@ public:
|
||||
bool contains(void *ptrstart, void *ptrend);
|
||||
void clear();
|
||||
|
||||
template<class T> T *add_object(T* object) { add(*EMUALLOC_SELF_NEW resource_pool_object<T>(object)); return object; }
|
||||
template<class T> T *add_array(T* array, int count) { add(*EMUALLOC_SELF_NEW resource_pool_array<T>(array, count)); return array; }
|
||||
template<class _ObjectClass> _ObjectClass *add_object(_ObjectClass* object) { add(*EMUALLOC_SELF_NEW resource_pool_object<_ObjectClass>(object)); return object; }
|
||||
template<class _ObjectClass> _ObjectClass *add_array(_ObjectClass* array, int count) { add(*EMUALLOC_SELF_NEW resource_pool_array<_ObjectClass>(array, count)); return array; }
|
||||
|
||||
private:
|
||||
int m_hash_size;
|
||||
|
@ -51,7 +51,7 @@
|
||||
|
||||
// a simple_list is a singly-linked list whose 'next' pointer is owned
|
||||
// by the object
|
||||
template<class T>
|
||||
template<class _ElementType>
|
||||
class simple_list
|
||||
{
|
||||
// we don't support deep copying
|
||||
@ -69,8 +69,8 @@ public:
|
||||
|
||||
// simple getters
|
||||
resource_pool &pool() const { return m_pool; }
|
||||
T *first() const { return m_head; }
|
||||
T *last() const { return m_tail; }
|
||||
_ElementType *first() const { return m_head; }
|
||||
_ElementType *last() const { return m_tail; }
|
||||
int count() const { return m_count; }
|
||||
|
||||
// remove (free) all objects in the list, leaving an empty list
|
||||
@ -81,7 +81,7 @@ public:
|
||||
}
|
||||
|
||||
// add the given object to the head of the list
|
||||
T &prepend(T &object)
|
||||
_ElementType &prepend(_ElementType &object)
|
||||
{
|
||||
object.m_next = m_head;
|
||||
m_head = &object;
|
||||
@ -92,13 +92,13 @@ public:
|
||||
}
|
||||
|
||||
// add the given list to the head of the list
|
||||
void prepend_list(simple_list<T> &list)
|
||||
void prepend_list(simple_list<_ElementType> &list)
|
||||
{
|
||||
int count = list.count();
|
||||
if (count == 0)
|
||||
return;
|
||||
T *tail = list.last();
|
||||
T *head = list.detach_all();
|
||||
_ElementType *tail = list.last();
|
||||
_ElementType *head = list.detach_all();
|
||||
tail->m_next = m_head;
|
||||
m_head = head;
|
||||
if (m_tail == NULL)
|
||||
@ -107,7 +107,7 @@ public:
|
||||
}
|
||||
|
||||
// add the given object to the tail of the list
|
||||
T &append(T &object)
|
||||
_ElementType &append(_ElementType &object)
|
||||
{
|
||||
object.m_next = NULL;
|
||||
if (m_tail != NULL)
|
||||
@ -119,13 +119,13 @@ public:
|
||||
}
|
||||
|
||||
// add the given list to the tail of the list
|
||||
void append_list(simple_list<T> &list)
|
||||
void append_list(simple_list<_ElementType> &list)
|
||||
{
|
||||
int count = list.count();
|
||||
if (count == 0)
|
||||
return;
|
||||
T *tail = list.last();
|
||||
T *head = list.detach_all();
|
||||
_ElementType *tail = list.last();
|
||||
_ElementType *head = list.detach_all();
|
||||
if (m_tail != NULL)
|
||||
m_tail->m_next = head;
|
||||
else
|
||||
@ -135,7 +135,7 @@ public:
|
||||
}
|
||||
|
||||
// insert the given object after a particular object (NULL means prepend)
|
||||
T &insert_after(T &object, T *insert_after)
|
||||
_ElementType &insert_after(_ElementType &object, _ElementType *insert_after)
|
||||
{
|
||||
if (insert_after == NULL)
|
||||
return prepend(object);
|
||||
@ -146,10 +146,10 @@ public:
|
||||
}
|
||||
|
||||
// replace an item in the list at the same location, and remove it
|
||||
T &replace_and_remove(T &object, T &toreplace)
|
||||
_ElementType &replace_and_remove(_ElementType &object, _ElementType &toreplace)
|
||||
{
|
||||
T *prev = NULL;
|
||||
for (T *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next)
|
||||
_ElementType *prev = NULL;
|
||||
for (_ElementType *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next)
|
||||
if (cur == &toreplace)
|
||||
{
|
||||
if (prev != NULL)
|
||||
@ -166,9 +166,9 @@ public:
|
||||
}
|
||||
|
||||
// detach the head item from the list, but don't free its memory
|
||||
T *detach_head()
|
||||
_ElementType *detach_head()
|
||||
{
|
||||
T *result = m_head;
|
||||
_ElementType *result = m_head;
|
||||
if (result != NULL)
|
||||
{
|
||||
m_head = result->m_next;
|
||||
@ -180,10 +180,10 @@ public:
|
||||
}
|
||||
|
||||
// detach the given item from the list, but don't free its memory
|
||||
T &detach(T &object)
|
||||
_ElementType &detach(_ElementType &object)
|
||||
{
|
||||
T *prev = NULL;
|
||||
for (T *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next)
|
||||
_ElementType *prev = NULL;
|
||||
for (_ElementType *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next)
|
||||
if (cur == &object)
|
||||
{
|
||||
if (prev != NULL)
|
||||
@ -199,35 +199,35 @@ public:
|
||||
}
|
||||
|
||||
// deatch the entire list, returning the head, but don't free memory
|
||||
T *detach_all()
|
||||
_ElementType *detach_all()
|
||||
{
|
||||
T *result = m_head;
|
||||
_ElementType *result = m_head;
|
||||
m_head = m_tail = NULL;
|
||||
m_count = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
// remove the given object and free its memory
|
||||
void remove(T &object)
|
||||
void remove(_ElementType &object)
|
||||
{
|
||||
detach(object);
|
||||
pool_free(m_pool, &object);
|
||||
}
|
||||
|
||||
// find an object by index in the list
|
||||
T *find(int index) const
|
||||
_ElementType *find(int index) const
|
||||
{
|
||||
for (T *cur = m_head; cur != NULL; cur = cur->m_next)
|
||||
for (_ElementType *cur = m_head; cur != NULL; cur = cur->m_next)
|
||||
if (index-- == 0)
|
||||
return cur;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// return the index of the given object in the list
|
||||
int indexof(const T &object) const
|
||||
int indexof(const _ElementType &object) const
|
||||
{
|
||||
int index = 0;
|
||||
for (T *cur = m_head; cur != NULL; cur = cur->m_next)
|
||||
for (_ElementType *cur = m_head; cur != NULL; cur = cur->m_next)
|
||||
{
|
||||
if (cur == &object)
|
||||
return index;
|
||||
@ -238,8 +238,8 @@ public:
|
||||
|
||||
private:
|
||||
// internal state
|
||||
T * m_head; // head of the singly-linked list
|
||||
T * m_tail; // tail of the singly-linked list
|
||||
_ElementType * m_head; // head of the singly-linked list
|
||||
_ElementType * m_tail; // tail of the singly-linked list
|
||||
resource_pool & m_pool; // resource pool where objects are freed
|
||||
int m_count; // number of objects in the list
|
||||
};
|
||||
@ -250,36 +250,36 @@ private:
|
||||
// a simple_list_wrapper wraps an existing object with a next pointer so it
|
||||
// can live in a simple_list without requiring the object to have a next
|
||||
// pointer
|
||||
template<class T>
|
||||
template<class _ObjectType>
|
||||
class simple_list_wrapper
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
simple_list_wrapper(T *object)
|
||||
simple_list_wrapper(_ObjectType *object)
|
||||
: m_next(NULL),
|
||||
m_object(object) { }
|
||||
|
||||
// operators
|
||||
operator T *() { return m_object; }
|
||||
operator T *() const { return m_object; }
|
||||
T *operator *() { return m_object; }
|
||||
T *operator *() const { return m_object; }
|
||||
operator _ObjectType *() { return m_object; }
|
||||
operator _ObjectType *() const { return m_object; }
|
||||
_ObjectType *operator *() { return m_object; }
|
||||
_ObjectType *operator *() const { return m_object; }
|
||||
|
||||
// getters
|
||||
simple_list_wrapper *next() const { return m_next; }
|
||||
T *object() const { return m_object; }
|
||||
_ObjectType *object() const { return m_object; }
|
||||
|
||||
private:
|
||||
// internal state
|
||||
simple_list_wrapper * m_next;
|
||||
T * m_object;
|
||||
_ObjectType * m_object;
|
||||
};
|
||||
|
||||
|
||||
// ======================> fixed_allocator
|
||||
|
||||
// a fixed_allocator is a simple class that maintains a free pool of objects
|
||||
template<class T>
|
||||
template<class _ItemType>
|
||||
class fixed_allocator
|
||||
{
|
||||
// we don't support deep copying
|
||||
@ -291,31 +291,31 @@ public:
|
||||
: m_freelist(pool) { }
|
||||
|
||||
// allocate a new item, either by recycling an old one, or by allocating a new one
|
||||
T *alloc()
|
||||
_ItemType *alloc()
|
||||
{
|
||||
T *result = m_freelist.detach_head();
|
||||
_ItemType *result = m_freelist.detach_head();
|
||||
if (result == NULL)
|
||||
result = m_freelist.pool().add_object(new T);
|
||||
result = m_freelist.pool().add_object(new _ItemType);
|
||||
return result;
|
||||
}
|
||||
|
||||
// reclaim an item by adding it to the free list
|
||||
void reclaim(T *item) { if (item != NULL) m_freelist.append(*item); }
|
||||
void reclaim(T &item) { m_freelist.append(item); }
|
||||
void reclaim(_ItemType *item) { if (item != NULL) m_freelist.append(*item); }
|
||||
void reclaim(_ItemType &item) { m_freelist.append(item); }
|
||||
|
||||
// reclaim all items from a list
|
||||
void reclaim_all(simple_list<T> &list) { m_freelist.append_list(list); }
|
||||
void reclaim_all(simple_list<_ItemType> &list) { m_freelist.append_list(list); }
|
||||
|
||||
private:
|
||||
// internal state
|
||||
simple_list<T> m_freelist; // list of free objects
|
||||
simple_list<_ItemType> m_freelist; // list of free objects
|
||||
};
|
||||
|
||||
|
||||
// ======================> tagged_list
|
||||
|
||||
// a tagged_list is a class that maintains a list of objects that can be quickly looked up by tag
|
||||
template<class T>
|
||||
template<class _ElementType>
|
||||
class tagged_list
|
||||
{
|
||||
// we don't support deep copying
|
||||
@ -328,15 +328,15 @@ public:
|
||||
|
||||
// simple getters
|
||||
resource_pool &pool() const { return m_list.pool(); }
|
||||
T *first() const { return m_list.first(); }
|
||||
T *last() const { return m_list.last(); }
|
||||
_ElementType *first() const { return m_list.first(); }
|
||||
_ElementType *last() const { return m_list.last(); }
|
||||
int count() const { return m_list.count(); }
|
||||
|
||||
// remove (free) all objects in the list, leaving an empty list
|
||||
void reset() { m_list.reset(); m_map.reset(); }
|
||||
|
||||
// add the given object to the head of the list
|
||||
T &prepend(const char *tag, T &object)
|
||||
_ElementType &prepend(const char *tag, _ElementType &object)
|
||||
{
|
||||
if (m_map.add_unique_hash(tag, &object, false) != TMERR_NONE)
|
||||
throw emu_fatalerror("Error adding object named '%s'", tag);
|
||||
@ -344,7 +344,7 @@ public:
|
||||
}
|
||||
|
||||
// add the given object to the tail of the list
|
||||
T &append(const char *tag, T &object)
|
||||
_ElementType &append(const char *tag, _ElementType &object)
|
||||
{
|
||||
if (m_map.add_unique_hash(tag, &object, false) != TMERR_NONE)
|
||||
throw emu_fatalerror("Error adding object named '%s'", tag);
|
||||
@ -352,7 +352,7 @@ public:
|
||||
}
|
||||
|
||||
// insert the given object after a particular object (NULL means prepend)
|
||||
T &insert_after(const char *tag, T &object, T *insert_after)
|
||||
_ElementType &insert_after(const char *tag, _ElementType &object, _ElementType *insert_after)
|
||||
{
|
||||
if (m_map.add_unique_hash(tag, &object, false) != TMERR_NONE)
|
||||
throw emu_fatalerror("Error adding object named '%s'", tag);
|
||||
@ -360,7 +360,7 @@ public:
|
||||
}
|
||||
|
||||
// replace an item in the list at the same location, and remove it
|
||||
T &replace_and_remove(const char *tag, T &object, T &toreplace)
|
||||
_ElementType &replace_and_remove(const char *tag, _ElementType &object, _ElementType &toreplace)
|
||||
{
|
||||
m_map.remove(&toreplace);
|
||||
m_list.replace_and_remove(object, toreplace);
|
||||
@ -370,41 +370,41 @@ public:
|
||||
}
|
||||
|
||||
// detach the given item from the list, but don't free its memory
|
||||
T &detach(T &object)
|
||||
_ElementType &detach(_ElementType &object)
|
||||
{
|
||||
m_map.remove(&object);
|
||||
return m_list.detach(object);
|
||||
}
|
||||
|
||||
// remove the given object and free its memory
|
||||
void remove(T &object)
|
||||
void remove(_ElementType &object)
|
||||
{
|
||||
m_map.remove(&object);
|
||||
return m_list.remove(object);
|
||||
}
|
||||
|
||||
// find an object by index in the list
|
||||
T *find(int index) const
|
||||
_ElementType *find(int index) const
|
||||
{
|
||||
return m_list.find(index);
|
||||
}
|
||||
|
||||
// return the index of the given object in the list
|
||||
int indexof(const T &object) const
|
||||
int indexof(const _ElementType &object) const
|
||||
{
|
||||
return m_list.indexof(object);
|
||||
}
|
||||
|
||||
// operations by tag
|
||||
T &replace_and_remove(const char *tag, T &object) { T *existing = find(tag); return (existing == NULL) ? append(tag, object) : replace_and_remove(tag, object, *existing); }
|
||||
void remove(const char *tag) { T *object = find(tag); if (object != NULL) remove(*object); }
|
||||
T *find(const char *tag) const { return m_map.find_hash_only(tag); }
|
||||
int indexof(const char *tag) const { T *object = find(tag); return (object != NULL) ? m_list.indexof(*object) : NULL; }
|
||||
_ElementType &replace_and_remove(const char *tag, _ElementType &object) { _ElementType *existing = find(tag); return (existing == NULL) ? append(tag, object) : replace_and_remove(tag, object, *existing); }
|
||||
void remove(const char *tag) { _ElementType *object = find(tag); if (object != NULL) remove(*object); }
|
||||
_ElementType *find(const char *tag) const { return m_map.find_hash_only(tag); }
|
||||
int indexof(const char *tag) const { _ElementType *object = find(tag); return (object != NULL) ? m_list.indexof(*object) : NULL; }
|
||||
|
||||
private:
|
||||
// internal state
|
||||
simple_list<T> m_list;
|
||||
tagmap_t<T *> m_map;
|
||||
simple_list<_ElementType> m_list;
|
||||
tagmap_t<_ElementType *> m_map;
|
||||
};
|
||||
|
||||
|
||||
|
@ -340,7 +340,7 @@ public:
|
||||
video_manager &video() const { assert(m_video != NULL); return *m_video; }
|
||||
debug_view_manager &debug_view() const { assert(m_debug_view != NULL); return *m_debug_view; }
|
||||
driver_device *driver_data() const { return m_driver_device; }
|
||||
template<class T> T *driver_data() const { return downcast<T *>(m_driver_device); }
|
||||
template<class _DriverClass> _DriverClass *driver_data() const { return downcast<_DriverClass *>(m_driver_device); }
|
||||
machine_phase phase() const { return m_current_phase; }
|
||||
bool paused() const { return m_paused || (m_current_phase != MACHINE_PHASE_RUNNING); }
|
||||
bool exit_pending() const { return m_exit_pending; }
|
||||
@ -360,7 +360,7 @@ public:
|
||||
|
||||
// fetch items by name
|
||||
inline device_t *device(const char *tag);
|
||||
template<class T> inline T *device(const char *tag) { return downcast<T *>(device(tag)); }
|
||||
template<class _DeviceClass> inline _DeviceClass *device(const char *tag) { return downcast<_DeviceClass *>(device(tag)); }
|
||||
inline const input_port_config *port(const char *tag);
|
||||
inline const memory_region *region(const char *tag);
|
||||
|
||||
@ -588,12 +588,12 @@ protected:
|
||||
|
||||
|
||||
// this template function creates a stub which constructs a device
|
||||
template<class T>
|
||||
template<class _DriverClass>
|
||||
device_t *driver_device_creator(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
{
|
||||
assert(owner == NULL);
|
||||
assert(clock == 0);
|
||||
return global_alloc_clear(T(mconfig, &driver_device_creator<T>, tag));
|
||||
return global_alloc_clear(_DriverClass(mconfig, &driver_device_creator<_DriverClass>, tag));
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,8 +121,8 @@ typedef delegate<void ()> save_prepost_delegate;
|
||||
class save_manager
|
||||
{
|
||||
// type_checker is a set of templates to identify valid save types
|
||||
template<typename T> struct type_checker { static const bool is_atom = false; static const bool is_pointer = false; };
|
||||
template<typename T> struct type_checker<T*> { static const bool is_atom = false; static const bool is_pointer = true; };
|
||||
template<typename _ItemType> struct type_checker { static const bool is_atom = false; static const bool is_pointer = false; };
|
||||
template<typename _ItemType> struct type_checker<_ItemType*> { static const bool is_atom = false; static const bool is_pointer = true; };
|
||||
|
||||
public:
|
||||
// construction/destruction
|
||||
@ -145,43 +145,43 @@ public:
|
||||
void save_memory(const char *module, const char *tag, UINT32 index, const char *name, void *val, UINT32 valsize, UINT32 valcount = 1);
|
||||
|
||||
// templatized wrapper for general objects
|
||||
template<typename T>
|
||||
void save_item(const char *module, const char *tag, int index, T &value, const char *valname)
|
||||
template<typename _ItemType>
|
||||
void save_item(const char *module, const char *tag, int index, _ItemType &value, const char *valname)
|
||||
{
|
||||
if (type_checker<T>::is_pointer) throw emu_fatalerror("Called save_item on a pointer with no count!");
|
||||
if (!type_checker<T>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!");
|
||||
if (type_checker<_ItemType>::is_pointer) throw emu_fatalerror("Called save_item on a pointer with no count!");
|
||||
if (!type_checker<_ItemType>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!");
|
||||
save_memory(module, tag, index, valname, &value, sizeof(value));
|
||||
}
|
||||
|
||||
// templatized wrapper for 1-dimensional arrays
|
||||
template<typename T, std::size_t N>
|
||||
void save_item(const char *module, const char *tag, int index, T (&value)[N], const char *valname)
|
||||
template<typename _ItemType, std::size_t N>
|
||||
void save_item(const char *module, const char *tag, int index, _ItemType (&value)[N], const char *valname)
|
||||
{
|
||||
if (!type_checker<T>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!");
|
||||
if (!type_checker<_ItemType>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!");
|
||||
save_memory(module, tag, index, valname, &value[0], sizeof(value[0]), N);
|
||||
}
|
||||
|
||||
// templatized wrapper for 2-dimensional arrays
|
||||
template<typename T, std::size_t M, std::size_t N>
|
||||
void save_item(const char *module, const char *tag, int index, T (&value)[M][N], const char *valname)
|
||||
template<typename _ItemType, std::size_t M, std::size_t N>
|
||||
void save_item(const char *module, const char *tag, int index, _ItemType (&value)[M][N], const char *valname)
|
||||
{
|
||||
if (!type_checker<T>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!");
|
||||
if (!type_checker<_ItemType>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!");
|
||||
save_memory(module, tag, index, valname, &value[0][0], sizeof(value[0][0]), M * N);
|
||||
}
|
||||
|
||||
// templatized wrapper for pointers
|
||||
template<typename T>
|
||||
void save_pointer(const char *module, const char *tag, int index, T *value, const char *valname, UINT32 count)
|
||||
template<typename _ItemType>
|
||||
void save_pointer(const char *module, const char *tag, int index, _ItemType *value, const char *valname, UINT32 count)
|
||||
{
|
||||
if (!type_checker<T>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!");
|
||||
if (!type_checker<_ItemType>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!");
|
||||
save_memory(module, tag, index, valname, value, sizeof(*value), count);
|
||||
}
|
||||
|
||||
// global memory registration
|
||||
template<typename T>
|
||||
void save_item(T &value, const char *valname, int index = 0) { save_item("global", NULL, index, value, valname); }
|
||||
template<typename T>
|
||||
void save_pointer(T *value, const char *valname, UINT32 count, int index = 0) { save_pointer("global", NULL, index, value, valname, count); }
|
||||
template<typename _ItemType>
|
||||
void save_item(_ItemType &value, const char *valname, int index = 0) { save_item("global", NULL, index, value, valname); }
|
||||
template<typename _ItemType>
|
||||
void save_pointer(_ItemType *value, const char *valname, UINT32 count, int index = 0) { save_pointer("global", NULL, index, value, valname, count); }
|
||||
|
||||
// file processing
|
||||
static save_error check_file(running_machine &machine, emu_file &file, const char *gamename, void (CLIB_DECL *errormsg)(const char *fmt, ...));
|
||||
|
@ -76,14 +76,6 @@ typedef delegate<void (void *, INT32)> timer_expired_delegate;
|
||||
// old-skool callbacks are like this
|
||||
typedef void (*timer_expired_func)(running_machine &machine, void *ptr, INT32 param);
|
||||
|
||||
// stub for when the ptr parameter points to a class
|
||||
template<class T, void (T::*func)(running_machine &machine, INT32 param)>
|
||||
void timer_expired_stub(running_machine &machine, void *ptr, INT32 param)
|
||||
{
|
||||
T *target = reinterpret_cast<T *>(ptr);
|
||||
(target->*func)(machine, param);
|
||||
}
|
||||
|
||||
|
||||
// ======================> emu_timer
|
||||
|
||||
|
@ -3751,23 +3751,23 @@ enum
|
||||
* add and delete may be slow - the focus is on access!
|
||||
*/
|
||||
|
||||
template<class T> struct dynamic_array_t
|
||||
template<class _ElementType> struct dynamic_array_t
|
||||
{
|
||||
public:
|
||||
dynamic_array_t(int initial) {
|
||||
m_count = 0;
|
||||
m_allocated = initial;
|
||||
m_arr = global_alloc_array_clear(T, m_allocated);
|
||||
m_arr = global_alloc_array_clear(_ElementType, m_allocated);
|
||||
}
|
||||
dynamic_array_t() {
|
||||
m_count = 0;
|
||||
m_allocated = 16;
|
||||
m_arr = global_alloc_array_clear(T, m_allocated);
|
||||
m_arr = global_alloc_array_clear(_ElementType, m_allocated);
|
||||
}
|
||||
~dynamic_array_t() {
|
||||
global_free(m_arr);
|
||||
}
|
||||
T& operator [] (unsigned int index) const // get array item
|
||||
_ElementType& operator [] (unsigned int index) const // get array item
|
||||
{
|
||||
return m_arr[index];
|
||||
}
|
||||
@ -3778,7 +3778,7 @@ public:
|
||||
if (m_allocated < 16)
|
||||
m_allocated = 16;
|
||||
m_count = a.count();
|
||||
m_arr = global_alloc_array_clear(T, m_allocated);
|
||||
m_arr = global_alloc_array_clear(_ElementType, m_allocated);
|
||||
for (int i=0; i < m_count; i++)
|
||||
m_arr[i] = a[i];
|
||||
}
|
||||
@ -3789,18 +3789,18 @@ public:
|
||||
if (m_allocated < 16)
|
||||
m_allocated = 16;
|
||||
m_count = a.count();
|
||||
m_arr = global_alloc_array_clear(T, m_allocated);
|
||||
m_arr = global_alloc_array_clear(_ElementType, m_allocated);
|
||||
for (int i=0; i < m_count; i++)
|
||||
m_arr[i] = a[i];
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline T* add(T object)
|
||||
inline _ElementType* add(_ElementType object)
|
||||
{
|
||||
if (m_count >= m_allocated)
|
||||
{
|
||||
m_allocated *= 2;
|
||||
T *newarr = global_alloc_array_clear(T, m_allocated);
|
||||
_ElementType *newarr = global_alloc_array_clear(_ElementType, m_allocated);
|
||||
for (int i=0; i < m_count; i++)
|
||||
newarr[i] = m_arr[i];
|
||||
global_free(m_arr);
|
||||
@ -3818,10 +3818,10 @@ public:
|
||||
}
|
||||
inline void clear(void) { m_count = 0; }
|
||||
inline int count(void) const { return m_count; }
|
||||
inline T *begin_ptr(void) const { return m_arr; }
|
||||
inline T *end_ptr(void) const { return m_arr + (m_count - 1); }
|
||||
inline _ElementType *begin_ptr(void) const { return m_arr; }
|
||||
inline _ElementType *end_ptr(void) const { return m_arr + (m_count - 1); }
|
||||
private:
|
||||
T *m_arr;
|
||||
_ElementType *m_arr;
|
||||
int m_count;
|
||||
int m_allocated;
|
||||
};
|
||||
|
@ -128,7 +128,7 @@ void tagmap_remove_object(tagmap *map, void *object);
|
||||
#ifdef __cplusplus
|
||||
|
||||
/* derived class for C++ */
|
||||
template<class T> class tagmap_t : public tagmap
|
||||
template<class _ElementType> class tagmap_t : public tagmap
|
||||
{
|
||||
private:
|
||||
tagmap_t(const tagmap &);
|
||||
@ -140,14 +140,14 @@ public:
|
||||
|
||||
void reset() { tagmap_reset(this); }
|
||||
|
||||
tagmap_error add(const char *tag, T object, bool replace_if_duplicate = false) { return tagmap_add(this, tag, (void *)object, replace_if_duplicate); }
|
||||
tagmap_error add_unique_hash(const char *tag, T object, bool replace_if_duplicate = false) { return tagmap_add_unique_hash(this, tag, (void *)object, replace_if_duplicate); }
|
||||
tagmap_error add(const char *tag, _ElementType object, bool replace_if_duplicate = false) { return tagmap_add(this, tag, (void *)object, replace_if_duplicate); }
|
||||
tagmap_error add_unique_hash(const char *tag, _ElementType object, bool replace_if_duplicate = false) { return tagmap_add_unique_hash(this, tag, (void *)object, replace_if_duplicate); }
|
||||
void remove(const char *tag) { tagmap_remove(this, tag); }
|
||||
void remove(T object) { tagmap_remove_object(this, object); }
|
||||
void remove(_ElementType object) { tagmap_remove_object(this, object); }
|
||||
|
||||
T find(const char *tag) const { return reinterpret_cast<T>(tagmap_find(this, tag)); }
|
||||
T find(const char *tag, UINT32 hash) const { return reinterpret_cast<T>(tagmap_find_prehashed(this, tag, hash)); }
|
||||
T find_hash_only(const char *tag) const { return reinterpret_cast<T>(tagmap_find_hash_only(this, tag)); }
|
||||
_ElementType find(const char *tag) const { return reinterpret_cast<_ElementType>(tagmap_find(this, tag)); }
|
||||
_ElementType find(const char *tag, UINT32 hash) const { return reinterpret_cast<_ElementType>(tagmap_find_prehashed(this, tag, hash)); }
|
||||
_ElementType find_hash_only(const char *tag) const { return reinterpret_cast<_ElementType>(tagmap_find_hash_only(this, tag)); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -90,7 +90,7 @@
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
template<typename func_ptr>
|
||||
template<typename _FunctionPtr>
|
||||
class dynamic_bind
|
||||
{
|
||||
public:
|
||||
@ -100,17 +100,17 @@ public:
|
||||
{
|
||||
HMODULE module = LoadLibrary(dll);
|
||||
if (module != NULL)
|
||||
m_function = reinterpret_cast<func_ptr>(GetProcAddress(module, symbol));
|
||||
m_function = reinterpret_cast<_FunctionPtr>(GetProcAddress(module, symbol));
|
||||
}
|
||||
|
||||
// bool to test if the function is NULL or not
|
||||
operator bool() const { return (m_function != NULL); }
|
||||
|
||||
// dereference to get the underlying pointer
|
||||
func_ptr operator *() const { return m_function; }
|
||||
_FunctionPtr operator *() const { return m_function; }
|
||||
|
||||
private:
|
||||
func_ptr m_function;
|
||||
_FunctionPtr m_function;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user