Skip to content

Commit

Permalink
Fixed: Applied DENG2_PIMPL macros to private instances
Browse files Browse the repository at this point in the history
When using DENG2_PRIVATE, it is mandatory to derive the private
Instance from de::IPrivate or de::Private<>.
  • Loading branch information
skyjake committed Mar 6, 2013
1 parent e3ee05b commit 841f883
Show file tree
Hide file tree
Showing 33 changed files with 62 additions and 64 deletions.
2 changes: 2 additions & 0 deletions doomsday/client/include/dd_pinit.h
Expand Up @@ -43,11 +43,13 @@ void DD_ShutdownAll(void);

int DD_CheckArg(char const *tag, const char** value);

#ifdef __CLIENT__
/**
* Compose the title for the main window.
* @param title Title text for the window.
*/
void DD_ComposeMainWindowTitle(char* title);
#endif

/**
* Called early on during the startup process so that we can get the console
Expand Down
3 changes: 2 additions & 1 deletion doomsday/client/include/uri.hh
Expand Up @@ -325,7 +325,8 @@ public:
void operator << (Reader &from);

private:
DENG2_PRIVATE(d)
struct Instance;
Instance *d;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(Uri::ComposeAsTextFlags)
Expand Down
8 changes: 5 additions & 3 deletions doomsday/client/src/dd_pinit.cpp
Expand Up @@ -70,18 +70,20 @@ int DD_CheckArg(char const *tag, const char** value)
return 1;
}

#ifdef __CLIENT__
void DD_ComposeMainWindowTitle(char* title)
{
if(App_GameLoaded() && gx.GetVariable)
{
sprintf(title, DOOMSDAY_NICENAME " " DOOMSDAY_VERSION_TEXT "%s - %s",
(isDedicated? " (Dedicated)" : ""), Str_Text(App_CurrentGame().title()));
sprintf(title, "%s - "DOOMSDAY_NICENAME " " DOOMSDAY_VERSION_TEXT,
Str_Text(App_CurrentGame().title()));
}
else
{
sprintf(title, DOOMSDAY_NICENAME " " DOOMSDAY_VERSION_TEXT "%s", (isDedicated? " (Dedicated)" : ""));
strcpy(title, DOOMSDAY_NICENAME " " DOOMSDAY_VERSION_TEXT);
}
}
#endif

void DD_InitAPI(void)
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/include/de/data/reader.h
Expand Up @@ -279,7 +279,7 @@ class DENG2_PUBLIC Reader
ByteOrder const &byteOrder() const;

inline void swap(Reader &other) {
std::swap(d, other.d);
d.swap(other.d);
}

private:
Expand Down
5 changes: 0 additions & 5 deletions doomsday/libdeng2/include/de/data/stringpool.h
Expand Up @@ -82,11 +82,6 @@ class DENG2_PUBLIC StringPool : public ISerializable
*/
StringPool(String *strings, uint count);

/**
* Destroys the stringpool.
*/
~StringPool();

/**
* Clear the string pool. All strings in the pool will be destroyed.
*/
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/include/de/data/writer.h
Expand Up @@ -209,7 +209,7 @@ class DENG2_PUBLIC Writer
void seek(dint count);

inline void swap(Writer &other) {
std::swap(d, other.d);
d.swap(other.d);
}

private:
Expand Down
2 changes: 0 additions & 2 deletions doomsday/libdeng2/include/de/filesys/filesystem.h
Expand Up @@ -117,8 +117,6 @@ class DENG2_PUBLIC FileSystem : public System
*/
FileSystem();

virtual ~FileSystem();

void printIndex();

Folder &root();
Expand Down
22 changes: 21 additions & 1 deletion doomsday/libdeng2/include/de/libdeng2.h
Expand Up @@ -229,6 +229,9 @@
typedef ClassName Public; \
struct ClassName::Instance : public de::Private<ClassName>

#define DENG2_PIMPL_NOREF(ClassName) \
struct ClassName::Instance : public de::IPrivate

/**
* Macro for publicly declaring a pointer to the private implementation.
*/
Expand All @@ -241,6 +244,11 @@ namespace de {

struct IPrivate {
virtual ~IPrivate() {}
#ifdef DENG2_DEBUG
unsigned int _privateInstVerification;
IPrivate() : _privateInstVerification(0xdeadbeef) {}
unsigned int specialVerification() const { return _privateInstVerification; }
#endif
};

template <typename InstType>
Expand All @@ -253,7 +261,12 @@ class PrivateAutoPtr
InstType &operator * () const { return *ptr; }
InstType *operator -> () const { return ptr; }
void reset(InstType *p = 0) {
delete reinterpret_cast<IPrivate *>(ptr);
IPrivate *ip = reinterpret_cast<IPrivate *>(ptr);
if(ip)
{
DENG2_ASSERT(ip->specialVerification() == 0xdeadbeef);
delete ip;
}
ptr = p;
}
InstType *get() const {
Expand All @@ -264,8 +277,15 @@ class PrivateAutoPtr
ptr = 0;
return p;
}
void swap(PrivateAutoPtr &other) {
std::swap(ptr, other.ptr);
}

private:
InstType *ptr;

PrivateAutoPtr &operator = (PrivateAutoPtr const &other); // no assign
PrivateAutoPtr(PrivateAutoPtr const &other); // no copy
};

/**
Expand Down
2 changes: 0 additions & 2 deletions doomsday/libdeng2/include/de/net/beacon.h
Expand Up @@ -41,8 +41,6 @@ class DENG2_PUBLIC Beacon : public QObject
public:
Beacon(duint16 port);

virtual ~Beacon();

/**
* Port the beacon uses for listening.
* @return Port.
Expand Down
1 change: 0 additions & 1 deletion doomsday/libdeng2/include/de/widgets/rootwidget.h
Expand Up @@ -42,7 +42,6 @@ class DENG2_PUBLIC RootWidget : public Widget
{
public:
RootWidget();
~RootWidget();

Vector2i viewSize() const;

Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/core/config.cpp
Expand Up @@ -31,7 +31,7 @@

namespace de {

struct Config::Instance
DENG2_PIMPL_NOREF(Config)
{
/// Configuration file name.
Path configPath;
Expand Down
6 changes: 3 additions & 3 deletions doomsday/libdeng2/src/core/library.cpp
Expand Up @@ -34,7 +34,7 @@ using namespace de;

char const *Library::DEFAULT_TYPE = "library/generic";

struct Library::Instance
DENG2_PIMPL(Library)
{
/// Handle to the shared library.
Handle library;
Expand All @@ -46,7 +46,7 @@ struct Library::Instance
/// Queried by calling deng_LibraryType(), if one is exported in the library.
String type;

Instance() : library(0), type(DEFAULT_TYPE)
Instance(Public *i) : Base(i), library(0), type(DEFAULT_TYPE)
{}

#ifdef DENG2_USE_DLOPEN
Expand All @@ -62,7 +62,7 @@ struct Library::Instance
#endif
};

Library::Library(NativePath const &nativePath) : d(new Instance)
Library::Library(NativePath const &nativePath) : d(new Instance(this))
{
LOG_AS("Library");
LOG_TRACE("Loading \"%s\"") << nativePath.pretty();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/core/logbuffer.cpp
Expand Up @@ -39,7 +39,7 @@ namespace de {

TimeDelta const FLUSH_INTERVAL = .2; // seconds

struct LogBuffer::Instance
DENG2_PIMPL_NOREF(LogBuffer)
{
typedef QList<LogEntry *> EntryList;
typedef QSet<LogSink *> Sinks;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/core/unixinfo.cpp
Expand Up @@ -75,7 +75,7 @@ class Infos

using namespace internal;

struct UnixInfo::Instance
DENG2_PIMPL_NOREF(UnixInfo)
{
Infos *paths;
Infos *defaults;
Expand Down
6 changes: 2 additions & 4 deletions doomsday/libdeng2/src/data/archive.cpp
Expand Up @@ -20,10 +20,8 @@

namespace de {

struct Archive::Instance
DENG2_PIMPL(Archive)
{
Archive &self;

/// Source data provided at construction.
IByteArray const *source;

Expand All @@ -34,7 +32,7 @@ struct Archive::Instance
/// Contents of the archive have been modified.
bool modified;

Instance(Archive &a, IByteArray const *src) : self(a), source(src), index(0), modified(false)
Instance(Public &a, IByteArray const *src) : Base(a), source(src), index(0), modified(false)
{}

~Instance()
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/data/info.cpp
Expand Up @@ -26,7 +26,7 @@ const static QString WHITESPACE = " \t\r\n";
const static QString WHITESPACE_OR_COMMENT = " \t\r\n#";
const static QString TOKEN_BREAKING_CHARS = "#:=(){}<>,\"" + WHITESPACE;

struct Info::Instance
DENG2_PIMPL_NOREF(Info)
{
DENG2_ERROR(OutOfElements);
DENG2_ERROR(EndOfFile);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/data/lockable.cpp
Expand Up @@ -22,7 +22,7 @@

namespace de {

struct Lockable::Instance
DENG2_PIMPL_NOREF(Lockable)
{
mutable QMutex mutex;

Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/data/pathtreenode.cpp
Expand Up @@ -23,7 +23,7 @@

namespace de {

struct PathTree::Node::Instance
DENG2_PIMPL_NOREF(PathTree::Node)
{
/// PathTree which owns this node.
PathTree &tree;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/data/reader.cpp
Expand Up @@ -31,7 +31,7 @@

namespace de {

struct Reader::Instance
DENG2_PIMPL_NOREF(Reader)
{
ByteOrder const &convert;
duint version;
Expand Down
5 changes: 2 additions & 3 deletions doomsday/libdeng2/src/data/record.cpp
Expand Up @@ -44,16 +44,15 @@ namespace de {
*/
static duint32 recordIdCounter = 0;

struct Record::Instance
DENG2_PIMPL(Record)
{
Record &self;
Record::Members members;
duint32 uniqueId; ///< Identifier to track serialized references.
duint32 oldUniqueId;

typedef QMap<duint32, Record *> RefMap;

Instance(Record &r) : self(r), uniqueId(++recordIdCounter), oldUniqueId(0)
Instance(Public &r) : Base(r), uniqueId(++recordIdCounter), oldUniqueId(0)
{}

bool isSubrecord(Variable const &var) const
Expand Down
5 changes: 1 addition & 4 deletions doomsday/libdeng2/src/data/stringpool.cpp
Expand Up @@ -149,7 +149,7 @@ typedef std::set<CaselessStringRef> Interns;
typedef std::vector<CaselessString *> IdMap;
typedef std::list<InternalId> AvailableIds;

struct StringPool::Instance
DENG2_PIMPL_NOREF(StringPool)
{
/// Interned strings (owns the CaselessString instances).
Interns interns;
Expand Down Expand Up @@ -290,9 +290,6 @@ StringPool::StringPool(String *strings, uint count) : d(new Instance)
}
}

StringPool::~StringPool()
{}

void StringPool::clear()
{
d->clear();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/data/writer.cpp
Expand Up @@ -30,7 +30,7 @@

namespace de {

struct Writer::Instance
DENG2_PIMPL_NOREF(Writer)
{
ByteOrder const &convert;
IByteArray *destination;
Expand Down
10 changes: 4 additions & 6 deletions doomsday/libdeng2/src/filesys/archivefeed.cpp
Expand Up @@ -30,10 +30,8 @@

namespace de {

struct ArchiveFeed::Instance
DENG2_PIMPL(ArchiveFeed)
{
ArchiveFeed &self;

/// File where the archive is stored (in a serialized format).
File &file;

Expand All @@ -49,7 +47,7 @@ struct ArchiveFeed::Instance
/// The feed whose archive this feed is using.
ArchiveFeed *parentFeed;

Instance(ArchiveFeed *feed, File &f) : self(*feed), file(f), arch(0), parentFeed(0)
Instance(Public *feed, File &f) : Base(feed), file(f), arch(0), parentFeed(0)
{
/// @todo Observe the file for deletion.

Expand All @@ -75,8 +73,8 @@ struct ArchiveFeed::Instance
}
}

Instance(ArchiveFeed *feed, ArchiveFeed &parentFeed, String const &path)
: self(*feed), file(parentFeed.d->file), arch(0), basePath(path), parentFeed(&parentFeed)
Instance(Public *feed, ArchiveFeed &parentFeed, String const &path)
: Base(feed), file(parentFeed.d->file), arch(0), basePath(path), parentFeed(&parentFeed)
{}

~Instance()
Expand Down
5 changes: 1 addition & 4 deletions doomsday/libdeng2/src/filesys/filesystem.cpp
Expand Up @@ -31,7 +31,7 @@ namespace de {

static FileSystem::Index const emptyIndex;

struct FileSystem::Instance
DENG2_PIMPL_NOREF(FileSystem)
{
/// The main index to all files in the file system.
FileSystem::Index index;
Expand All @@ -48,9 +48,6 @@ struct FileSystem::Instance
FileSystem::FileSystem() : d(new Instance)
{}

FileSystem::~FileSystem()
{}

void FileSystem::refresh()
{
LOG_AS("FS::refresh");
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/legacy/legacycore.cpp
Expand Up @@ -33,7 +33,7 @@ namespace de {

LegacyCore *LegacyCore::_appCore;

struct LegacyCore::Instance
DENG2_PIMPL_NOREF(LegacyCore)
{
App *app;

Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/net/address.cpp
Expand Up @@ -24,7 +24,7 @@

namespace de {

struct Address::Instance
DENG2_PIMPL_NOREF(Address)
{
QHostAddress host;
duint16 port;
Expand Down

0 comments on commit 841f883

Please sign in to comment.