Latest delegate changes removed the need for bindable_object, so

get rid of it across the board.
This commit is contained in:
Aaron Giles 2011-04-29 20:45:40 +00:00
parent 5408498afe
commit 5e964d09ce
14 changed files with 44 additions and 111 deletions

View File

@ -314,7 +314,7 @@ private:
// ======================> cheat_manager
// private machine-global data
class cheat_manager : public bindable_object
class cheat_manager
{
public:
// construction/destruction

View File

@ -147,7 +147,7 @@ private:
typedef delegate<void (void *, drccodeptr)> drc_label_fixup_delegate;
// structure holding a live list of labels
class drc_label_list : public bindable_object
class drc_label_list
{
public:
// construction/destruction

View File

@ -166,7 +166,7 @@ private:
// interface structure for a back-end
class drcbe_interface : public bindable_object
class drcbe_interface
{
public:
// construction/destruction

View File

@ -554,7 +554,7 @@ typedef delegate<void (offs_t, UINT8)> m68k_write8_delegate;
typedef delegate<void (offs_t, UINT16)> m68k_write16_delegate;
typedef delegate<void (offs_t, UINT32)> m68k_write32_delegate;
class m68k_memory_interface : public bindable_object
class m68k_memory_interface
{
public:
void init8(address_space &space);

View File

@ -41,29 +41,6 @@
#include "delegate.h"
//**************************************************************************
// BINDABLE OBJECT
//**************************************************************************
//-------------------------------------------------
// bindable_object - constructor
//-------------------------------------------------
bindable_object::bindable_object()
{
}
//-------------------------------------------------
// ~bindable_object - destructor
//-------------------------------------------------
bindable_object::~bindable_object()
{
}
//**************************************************************************
// INTERNAL DELEGATE HELPERS
//**************************************************************************

View File

@ -140,30 +140,6 @@ class delegate_generic_class;
#endif
// ======================> bindable_object
// define a bindable_object base class that must be at the root of any object
// hierarchy which intends to do late binding
class bindable_object
{
public:
// virtual destructor to ensure this is a polymorphic class
bindable_object();
virtual ~bindable_object();
};
// define a deferred cast helper function that does a proper dynamic_cast
// from a bindable_object to the target class, and returns a delegate_generic_class
template<class _TargetClass>
static delegate_generic_class *deferred_cast(bindable_object &object)
{
return reinterpret_cast<delegate_generic_class *>(dynamic_cast<_TargetClass *>(&object));
}
// we store pointers to these deferred casting helpers, so make a friendly type for it
typedef delegate_generic_class *(*deferred_cast_func)(bindable_object &object);
// ======================> delegate_traits
// delegate_traits is a meta-template that is used to provide a static function pointer
@ -283,16 +259,14 @@ class delegate_base
public:
// generic constructor
delegate_base()
: m_caster(NULL),
m_name(NULL),
: m_name(NULL),
m_function(NULL),
m_object(NULL),
m_callobject(NULL) { }
// copy constructor
delegate_base(const delegate_base &src)
: m_caster(src.m_caster),
m_name(src.m_name),
: m_name(src.m_name),
m_object(src.m_object),
m_callobject(src.is_mfp() ? reinterpret_cast<delegate_generic_class *>(this) : src.m_object),
m_function(src.m_function),
@ -301,47 +275,42 @@ public:
// copy constructor with re-bind
template<class _FunctionClass>
delegate_base(const delegate_base &src, _FunctionClass *object)
: m_caster(src.m_caster),
m_name(src.m_name),
: m_name(src.m_name),
m_object(src.m_object),
m_callobject(src.is_mfp() ? reinterpret_cast<delegate_generic_class *>(this) : src.m_object),
m_function(src.m_function),
m_rawfunction(src.m_rawfunction) { bind(object); }
m_rawfunction(src.m_rawfunction) { bind(reinterpret_cast<delegate_generic_class *>(object)); }
// construct from member function with object pointer
template<class _FunctionClass>
delegate_base(typename delegate_traits<_FunctionClass, _ReturnType, _P1Type, _P2Type, _P3Type, _P4Type>::member_func_type funcptr, const char *name, _FunctionClass *object)
: m_caster(&deferred_cast<_FunctionClass>),
m_name(name),
: m_name(name),
m_function(&delegate_base::method_stub<_FunctionClass>),
m_object(NULL),
m_callobject(reinterpret_cast<delegate_generic_class *>(this)),
m_rawfunction(funcptr) { bind(object); }
m_rawfunction(funcptr) { bind(reinterpret_cast<delegate_generic_class *>(object)); }
// construct from static function with object pointer
template<class _FunctionClass>
delegate_base(typename delegate_traits<_FunctionClass, _ReturnType, _P1Type, _P2Type, _P3Type, _P4Type>::static_func_type funcptr, const char *name, _FunctionClass *object)
: m_caster(&deferred_cast<_FunctionClass>),
m_name(name),
: m_name(name),
m_object(NULL),
m_callobject(NULL),
m_function(reinterpret_cast<generic_static_func>(funcptr)) { bind(object); }
m_function(reinterpret_cast<generic_static_func>(funcptr)) { bind(reinterpret_cast<delegate_generic_class *>(object)); }
// construct from static reference function with object pointer
template<class _FunctionClass>
delegate_base(typename delegate_traits<_FunctionClass, _ReturnType, _P1Type, _P2Type, _P3Type, _P4Type>::static_ref_func_type funcptr, const char *name, _FunctionClass *object)
: m_caster(&deferred_cast<_FunctionClass>),
m_name(name),
: m_name(name),
m_object(NULL),
m_callobject(NULL),
m_function(reinterpret_cast<generic_static_func>(funcptr)) { bind(object); }
m_function(reinterpret_cast<generic_static_func>(funcptr)) { bind(reinterpret_cast<delegate_generic_class *>(object)); }
// copy operator
delegate_base &operator=(const delegate_base &src)
{
if (this != &src)
{
m_caster = src.m_caster;
m_name = src.m_name;
m_object = src.m_object;
m_callobject = src.is_mfp() ? reinterpret_cast<delegate_generic_class *>(this) : src.m_object;
@ -354,13 +323,11 @@ public:
// comparison operator
bool operator==(const delegate_base &rhs) const
{
return (m_caster == rhs.m_caster && m_object == rhs.m_object &&
m_function == m_function && m_rawfunction == m_rawfunction);
return (m_object == rhs.m_object && m_function == m_function && m_rawfunction == m_rawfunction);
}
// getters
bool isnull() const { return (m_caster == NULL); }
bool valid_target(bindable_object &object) const { return ((*m_caster)(object) != NULL); }
bool isnull() const { return (m_function == NULL); }
bool has_object() const { return (m_object != NULL); }
const char *name() const { return m_name; }
@ -373,9 +340,9 @@ public:
protected:
// bind the actual object
void bind(bindable_object *object)
void bind(delegate_generic_class *object)
{
m_object = (object != NULL) ? (*this->m_caster)(*object) : NULL;
m_object = object;
if (!is_mfp()) m_callobject = m_object;
}
@ -429,7 +396,6 @@ protected:
}
// internal state
deferred_cast_func m_caster; // pointer to helper function that does the cast
const char * m_name; // name string
generic_static_func m_function; // generic static function pointer
delegate_raw_mfp m_rawfunction; // copy of raw MFP
@ -508,15 +474,13 @@ class delegate_base
public:
// generic constructor
delegate_base()
: m_caster(NULL),
m_name(NULL),
: m_name(NULL),
m_object(NULL),
m_function(NULL) { }
// copy constructor
delegate_base(const delegate_base &src)
: m_caster(src.m_caster),
m_name(src.m_name),
: m_name(src.m_name),
m_object(src.m_object),
m_function(src.m_function),
m_rawfunction(src.m_rawfunction) { }
@ -524,43 +488,38 @@ public:
// copy constructor with re-bind
template<class _FunctionClass>
delegate_base(const delegate_base &src, _FunctionClass *object)
: m_caster(src.m_caster),
m_name(src.m_name),
: m_name(src.m_name),
m_object(src.m_object),
m_function(src.m_function),
m_rawfunction(src.m_rawfunction) { bind(object); }
m_rawfunction(src.m_rawfunction) { bind(reinterpret_cast<delegate_generic_class *>(object)); }
// construct from member function with object pointer
template<class _FunctionClass>
delegate_base(typename delegate_traits<_FunctionClass, _ReturnType, _P1Type, _P2Type, _P3Type, _P4Type>::member_func_type funcptr, const char *name, _FunctionClass *object)
: m_caster(&deferred_cast<_FunctionClass>),
m_name(name),
: m_name(name),
m_object(NULL),
m_function(NULL),
m_rawfunction(funcptr) { bind(object); }
m_rawfunction(funcptr) { bind(reinterpret_cast<delegate_generic_class *>(object)); }
// construct from static function with object pointer
template<class _FunctionClass>
delegate_base(typename delegate_traits<_FunctionClass, _ReturnType, _P1Type, _P2Type, _P3Type, _P4Type>::static_func_type funcptr, const char *name, _FunctionClass *object)
: m_caster(&deferred_cast<_FunctionClass>),
m_name(name),
: m_name(name),
m_object(NULL),
m_function(reinterpret_cast<generic_static_func>(funcptr)) { bind(object); }
m_function(reinterpret_cast<generic_static_func>(funcptr)) { bind(reinterpret_cast<delegate_generic_class *>(object)); }
// construct from static reference function with object pointer
template<class _FunctionClass>
delegate_base(typename delegate_traits<_FunctionClass, _ReturnType, _P1Type, _P2Type, _P3Type, _P4Type>::static_ref_func_type funcptr, const char *name, _FunctionClass *object)
: m_caster(&deferred_cast<_FunctionClass>),
m_name(name),
: m_name(name),
m_object(NULL),
m_function(reinterpret_cast<generic_static_func>(funcptr)) { bind(object); }
m_function(reinterpret_cast<generic_static_func>(funcptr)) { bind(reinterpret_cast<delegate_generic_class *>(object)); }
// copy operator
delegate_base &operator=(const delegate_base &src)
{
if (this != &src)
{
m_caster = src.m_caster;
m_name = src.m_name;
m_object = src.m_object;
m_function = src.m_function;
@ -572,13 +531,11 @@ public:
// comparison operator
bool operator==(const delegate_base &rhs) const
{
return (m_caster == rhs.m_caster && m_object == rhs.m_object &&
m_function == m_function && m_rawfunction == m_rawfunction);
return (m_object == rhs.m_object && m_function == m_function && m_rawfunction == m_rawfunction);
}
// getters
bool isnull() const { return (m_caster == NULL); }
bool valid_target(bindable_object &object) const { return ((*m_caster)(object) != NULL); }
bool isnull() const { return (m_function == NULL && m_rawfunction.m_function == 0); }
bool has_object() const { return (m_object != NULL); }
const char *name() const { return m_name; }
@ -591,15 +548,14 @@ public:
protected:
// bind the actual object
void bind(bindable_object *object)
void bind(delegate_generic_class *object)
{
m_object = (object != NULL) ? (*this->m_caster)(*object) : NULL;
m_object = object;
if (m_object != NULL && m_rawfunction.m_function != 0)
m_function = reinterpret_cast<generic_static_func>(m_rawfunction.convert_to_generic(m_object));
}
// internal state
deferred_cast_func m_caster; // pointer to helper function that does the cast
const char * m_name; // name string
delegate_generic_class * m_object; // pointer to the post-cast object
generic_static_func m_function; // generic static function pointer

View File

@ -126,7 +126,7 @@ typedef void (*write_line_device_func)(device_t *device, int state);
// ======================> tagged_device_list
// tagged_device_list is a tagged_list with additional searching based on type
class device_list : public tagged_list<device_t>, public bindable_object
class device_list : public tagged_list<device_t>
{
typedef tagged_list<device_t> super;
@ -176,7 +176,7 @@ private:
// ======================> device_t
// device_t represents a device
class device_t : public virtual bindable_object
class device_t
{
DISABLE_COPYING(device_t);
@ -459,7 +459,7 @@ private:
// ======================> device_interface
// device_interface represents runtime information for a particular device interface
class device_interface : public virtual bindable_object
class device_interface
{
DISABLE_COPYING(device_interface);

View File

@ -309,7 +309,7 @@ public:
typedef delegate<void ()> machine_notify_delegate;
// description of the currently-running machine
class running_machine : public bindable_object
class running_machine
{
DISABLE_COPYING(running_machine);

View File

@ -417,7 +417,7 @@ private:
// ======================> handler_entry
// a handler entry contains information about a memory handler
class handler_entry : public bindable_object
class handler_entry
{
DISABLE_COPYING(handler_entry);
@ -669,7 +669,7 @@ private:
// ======================> address_table
// address_table contains information about read/write accesses within an address space
class address_table : public bindable_object
class address_table
{
// address map lookup table definitions
static const int LEVEL1_BITS = 18; // number of address bits in the level 1 table
@ -2039,7 +2039,7 @@ void address_space::populate_from_map()
void address_space::populate_map_entry(const address_map_entry &entry, read_or_write readorwrite)
{
const map_handler_data &data = (readorwrite == ROW_READ) ? entry.m_read : entry.m_write;
bindable_object *object;
void *object;
device_t *device;
// based on the handler type, alter the bits, name, funcptr, and object

View File

@ -291,7 +291,7 @@ public:
// ======================> address_space
// address_space holds live information about an address space
class address_space : public bindable_object
class address_space
{
friend class address_table;
friend class address_table_read;

View File

@ -714,7 +714,7 @@ private:
// ======================> render_manager
// contains machine-global information and operations
class render_manager : public bindable_object
class render_manager
{
friend class render_target;

View File

@ -150,7 +150,7 @@ private:
// ======================> device_scheduler
class device_scheduler : public bindable_object
class device_scheduler
{
friend class device_execute_interface;
friend class emu_timer;

View File

@ -199,7 +199,7 @@ private:
// ======================> sound_manager
class sound_manager : public bindable_object
class sound_manager
{
friend class sound_stream;

View File

@ -70,7 +70,7 @@ typedef struct _avi_file avi_file;
// ======================> video_manager
class video_manager : public bindable_object
class video_manager
{
friend class screen_device;