Resolve some Linux/GCC errors.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1976 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine committed 2009-10-07 20:50:39 +00:00
1 parent eda5d1d834
commit d30673c5ca
3 files changed
+39 -29

No files matched your search

+3 -2
View File
@@ -1,6 +1,6 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2009 PCSX2 Dev Team
*
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
@@ -64,7 +64,7 @@ protected:
// Use this macro/class as a base to seal a class from being derived from.
// This macro works by providing a unique base class with a protected constructor
// for every class that derives from it.
// for every class that derives from it.
#define Sealed private virtual __BaseSealed<__COUNTER__>
@@ -94,5 +94,6 @@ class wxString;
#include <cstring> // string.h under c++
#include <cstdio> // stdio.h under c++
#include <cstdlib>
#include <list>
#include "Utilities/Assertions.h"
+35 -27
View File
@@ -15,6 +15,7 @@
#pragma once
#include <list>
#include <wx/event.h>
template< typename EvtType >
@@ -24,7 +25,7 @@ struct EventListener
void* object;
FuncType* OnEvent;
EventListener( FuncType* fnptr )
{
object = NULL;
@@ -36,12 +37,12 @@ struct EventListener
object = objhandle;
OnEvent = fnptr;
}
bool operator ==( const EventListener& right ) const
{
return (object == right.object) && (OnEvent == right.OnEvent);
}
bool operator !=( const EventListener& right ) const
{
return this->operator ==(right);
@@ -52,10 +53,10 @@ template< typename EvtType >
class EventSource
{
public:
typedef typename EventListener<EvtType> ListenerType;
typedef EventListener< EvtType > ListenerType;
typedef typename std::list< ListenerType > ListenerList;
typedef typename ListenerList::const_iterator Handle;
typedef typename ListenerList::iterator Handle;
protected:
ListenerList m_listeners;
@@ -103,9 +104,9 @@ public:
}
catch( Exception::RuntimeError& ex )
{
Console::Error( L"Ignoring runtime error thrown from event listener: " + ex.FormatDiagnosticMessage() );
Console.Error( L"Ignoring runtime error thrown from event listener: " + ex.FormatDiagnosticMessage() );
}
catch( BaseException& ex )
catch( Exception::BaseException& ex )
{
}
}
@@ -125,10 +126,10 @@ public:
typedef typename EventSource<EvtType>::Handle ConstIterator;
protected:
EventSource<EvtType>& m_source;
const ListenerHandle m_listener;
ConstIterator m_iter;
bool m_attached;
EventSource<EvtType>& m_source;
const ListenerHandle m_listener;
ConstIterator m_iter;
bool m_attached;
public:
EventListenerBinding( EventSource<EvtType>& source, const ListenerHandle& listener, bool autoAttach=true ) :
@@ -141,12 +142,12 @@ public:
//if( !pxAssertDev( listener.OnEvent != NULL, "NULL listener callback function." ) ) return;
if( autoAttach ) Attach();
}
virtual ~EventListenerBinding() throw()
{
Detach();
}
void Detach()
{
if( !m_attached ) return;
@@ -182,23 +183,30 @@ void EventSource<EvtType>::Add( const ListenerType& listener )
AddFast( listener );
}
template< typename EvtType >
class PredicatesAreTheThingsOfNightmares
{
typedef EventListener< EvtType > ListenerType;
protected:
const void* const m_object_match;
public:
PredicatesAreTheThingsOfNightmares( const void* objmatch ) : m_object_match( objmatch ) { }
bool operator()( const ListenerType& src ) const
{
return src.object == m_object_match;
}
};
// removes all listeners which reference the given object. Use for assuring object deletion.
template< typename EvtType >
void EventSource<EvtType>::RemoveObject( const void* object )
{
class PredicatesAreTheThingsOfNightmares
{
protected:
const void* const m_object_match;
// Iso C++ rules regarding temporaries, specifically that non-const temporaries are disallowed,
// also removes any actual convenience factor that unary predicates may have actually offered. >_<
public:
PredicatesAreTheThingsOfNightmares( const void* objmatch ) : m_object_match( objmatch ) { }
bool operator()( const ListenerType& src )
{
return src.object == m_object_match;
}
};
m_listeners.remove_if( PredicatesAreTheThingsOfNightmares( object ) );
m_listeners.remove_if( PredicatesAreTheThingsOfNightmares<EvtType>( object ) );
}
+1
View File
@@ -41,6 +41,7 @@
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <sstream>
#include <cstring> // string.h under c++
#include <cstdio> // stdio.h under c++