[Scummvm-cvs-logs] SF.net SVN: scummvm:[40765] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Thu May 21 19:12:33 CEST 2009


Revision: 40765
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40765&view=rev
Author:   drmccoy
Date:     2009-05-21 17:12:33 +0000 (Thu, 21 May 2009)

Log Message:
-----------
Splitting a few helper functions out of gob.h

Modified Paths:
--------------
    scummvm/trunk/engines/gob/dataio.cpp
    scummvm/trunk/engines/gob/demos/demoplayer.cpp
    scummvm/trunk/engines/gob/detection.cpp
    scummvm/trunk/engines/gob/draw_v1.cpp
    scummvm/trunk/engines/gob/draw_v2.cpp
    scummvm/trunk/engines/gob/game.cpp
    scummvm/trunk/engines/gob/game_v1.cpp
    scummvm/trunk/engines/gob/game_v2.cpp
    scummvm/trunk/engines/gob/game_v6.cpp
    scummvm/trunk/engines/gob/gob.h
    scummvm/trunk/engines/gob/goblin.cpp
    scummvm/trunk/engines/gob/inter_v1.cpp
    scummvm/trunk/engines/gob/inter_v2.cpp
    scummvm/trunk/engines/gob/inter_v4.cpp
    scummvm/trunk/engines/gob/inter_v6.cpp
    scummvm/trunk/engines/gob/sound/cdrom.cpp
    scummvm/trunk/engines/gob/variables.cpp
    scummvm/trunk/engines/gob/video.h
    scummvm/trunk/engines/gob/videoplayer.cpp

Added Paths:
-----------
    scummvm/trunk/engines/gob/helper.h

Modified: scummvm/trunk/engines/gob/dataio.cpp
===================================================================
--- scummvm/trunk/engines/gob/dataio.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/dataio.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -27,6 +27,7 @@
 
 #include "gob/gob.h"
 #include "gob/dataio.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/util.h"
 

Modified: scummvm/trunk/engines/gob/demos/demoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/demos/demoplayer.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/demos/demoplayer.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -28,6 +28,7 @@
 
 #include "gob/gob.h"
 #include "gob/demos/demoplayer.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/util.h"
 #include "gob/draw.h"

Modified: scummvm/trunk/engines/gob/detection.cpp
===================================================================
--- scummvm/trunk/engines/gob/detection.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/detection.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -27,6 +27,7 @@
 #include "engines/advancedDetector.h"
 
 #include "gob/gob.h"
+#include "gob/helper.h"
 
 namespace Gob {
 

Modified: scummvm/trunk/engines/gob/draw_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw_v1.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/draw_v1.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -28,6 +28,7 @@
 
 #include "gob/gob.h"
 #include "gob/draw.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/util.h"
 #include "gob/game.h"

Modified: scummvm/trunk/engines/gob/draw_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw_v2.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/draw_v2.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -28,6 +28,7 @@
 
 #include "gob/gob.h"
 #include "gob/draw.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/util.h"
 #include "gob/game.h"

Modified: scummvm/trunk/engines/gob/game.cpp
===================================================================
--- scummvm/trunk/engines/gob/game.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/game.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -27,6 +27,7 @@
 
 #include "gob/gob.h"
 #include "gob/game.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/util.h"
 #include "gob/dataio.h"

Modified: scummvm/trunk/engines/gob/game_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v1.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/game_v1.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -28,6 +28,7 @@
 
 #include "gob/gob.h"
 #include "gob/game.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/util.h"
 #include "gob/dataio.h"

Modified: scummvm/trunk/engines/gob/game_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v2.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/game_v2.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -28,6 +28,7 @@
 
 #include "gob/gob.h"
 #include "gob/game.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/util.h"
 #include "gob/dataio.h"

Modified: scummvm/trunk/engines/gob/game_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v6.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/game_v6.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -29,6 +29,7 @@
 
 #include "gob/gob.h"
 #include "gob/game.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/inter.h"
 #include "gob/draw.h"

Modified: scummvm/trunk/engines/gob/gob.h
===================================================================
--- scummvm/trunk/engines/gob/gob.h	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/gob.h	2009-05-21 17:12:33 UTC (rev 40765)
@@ -26,7 +26,6 @@
 #ifndef GOB_GOB_H
 #define GOB_GOB_H
 
-
 #include "common/system.h"
 #include "common/savefile.h"
 
@@ -129,77 +128,6 @@
 	kDebugDemo       = 1 << 11
 };
 
-inline char *strncpy0(char *dest, const char *src, size_t n) {
-	strncpy(dest, src, n);
-	dest[n] = 0;
-	return dest;
-}
-
-inline char *strdupcpy(const char *str) {
-	if (!str)
-		return 0;
-
-	size_t len = strlen(str) + 1;
-
-	char *nstr = new char[len];
-
-	memcpy(nstr, str, len);
-
-	return nstr;
-}
-
-// A "smart" reference counting templated class
-template<typename T>
-class ReferenceCounter {
-public:
-	class Ptr {
-	public:
-		bool operator==(const Ptr &p) const { return _p == p._p; }
-		bool operator==(const ReferenceCounter *p) const { return _p == p; }
-
-		T *operator-> () { return _p; }
-		T &operator* () { return *_p; }
-		operator T*() { return _p; }
-
-		Ptr(T *p) : _p(p) { ++_p->_references; }
-		Ptr() : _p(0) { }
-
-		~Ptr() {
-			if (_p && (--_p->_references == 0))
-				delete _p;
-		}
-
-		Ptr(const Ptr &p) : _p(p._p) { ++_p->_references; }
-
-		Ptr &operator= (const Ptr &p) {
-			++p._p->_references;
-			if (_p && (--_p->_references == 0))
-				delete _p;
-			_p = p._p;
-			return *this;
-		}
-		Ptr *operator= (const Ptr *p) {
-			if (p)
-				++p->_p->_references;
-			if (_p && (--_p->_references == 0))
-				delete _p;
-
-			_p = p ? p->_p : 0;
-			return this;
-		}
-
-	private:
-		T *_p;
-	};
-
-	ReferenceCounter() : _references(0) { }
-	virtual ~ReferenceCounter() {}
-
-private:
-	unsigned _references;
-	friend class Ptr;
-};
-
 struct GOBGameDescription;
 
 class GobEngine : public Engine {

Modified: scummvm/trunk/engines/gob/goblin.cpp
===================================================================
--- scummvm/trunk/engines/gob/goblin.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/goblin.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -25,6 +25,7 @@
 
 #include "gob/gob.h"
 #include "gob/goblin.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/util.h"
 #include "gob/draw.h"

Added: scummvm/trunk/engines/gob/helper.h
===================================================================
--- scummvm/trunk/engines/gob/helper.h	                        (rev 0)
+++ scummvm/trunk/engines/gob/helper.h	2009-05-21 17:12:33 UTC (rev 40765)
@@ -0,0 +1,106 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef GOB_HELPER_H
+#define GOB_HELPER_H
+
+namespace Gob {
+
+/** A strncpy that forces the final \0. */
+inline char *strncpy0(char *dest, const char *src, size_t n) {
+	strncpy(dest, src, n);
+	dest[n] = 0;
+	return dest;
+}
+
+/** A strdup that new[]s the buffer. */
+inline char *strdupcpy(const char *str) {
+	if (!str)
+		return 0;
+
+	size_t len = strlen(str) + 1;
+
+	char *nstr = new char[len];
+
+	memcpy(nstr, str, len);
+
+	return nstr;
+}
+
+/** A "smart" reference counting templated class. */
+template<typename T>
+class ReferenceCounter {
+public:
+	class Ptr {
+	public:
+		bool operator==(const Ptr &p) const { return _p == p._p; }
+		bool operator==(const ReferenceCounter *p) const { return _p == p; }
+
+		T *operator-> () { return _p; }
+		T &operator* () { return *_p; }
+		operator T*() { return _p; }
+
+		Ptr(T *p) : _p(p) { ++_p->_references; }
+		Ptr() : _p(0) { }
+
+		~Ptr() {
+			if (_p && (--_p->_references == 0))
+				delete _p;
+		}
+
+		Ptr(const Ptr &p) : _p(p._p) { ++_p->_references; }
+
+		Ptr &operator= (const Ptr &p) {
+			++p._p->_references;
+			if (_p && (--_p->_references == 0))
+				delete _p;
+			_p = p._p;
+			return *this;
+		}
+		Ptr *operator= (const Ptr *p) {
+			if (p)
+				++p->_p->_references;
+			if (_p && (--_p->_references == 0))
+				delete _p;
+
+			_p = p ? p->_p : 0;
+			return this;
+		}
+
+	private:
+		T *_p;
+	};
+
+	ReferenceCounter() : _references(0) { }
+	virtual ~ReferenceCounter() {}
+
+private:
+	unsigned _references;
+	friend class Ptr;
+};
+
+} // End of namespace Gob
+
+#endif // GOB_HELPER_H


Property changes on: scummvm/trunk/engines/gob/helper.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: scummvm/trunk/engines/gob/inter_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v1.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/inter_v1.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -28,6 +28,7 @@
 
 #include "gob/gob.h"
 #include "gob/inter.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/util.h"
 #include "gob/dataio.h"

Modified: scummvm/trunk/engines/gob/inter_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v2.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/inter_v2.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -30,6 +30,7 @@
 
 #include "gob/gob.h"
 #include "gob/inter.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/util.h"
 #include "gob/dataio.h"

Modified: scummvm/trunk/engines/gob/inter_v4.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v4.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/inter_v4.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -28,6 +28,7 @@
 
 #include "gob/gob.h"
 #include "gob/inter.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/draw.h"
 #include "gob/game.h"

Modified: scummvm/trunk/engines/gob/inter_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v6.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/inter_v6.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -29,6 +29,7 @@
 
 #include "gob/gob.h"
 #include "gob/inter.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/game.h"
 #include "gob/parse.h"

Modified: scummvm/trunk/engines/gob/sound/cdrom.cpp
===================================================================
--- scummvm/trunk/engines/gob/sound/cdrom.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/sound/cdrom.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -29,6 +29,7 @@
 
 #include "gob/gob.h"
 #include "gob/sound/cdrom.h"
+#include "gob/helper.h"
 
 namespace Gob {
 

Modified: scummvm/trunk/engines/gob/variables.cpp
===================================================================
--- scummvm/trunk/engines/gob/variables.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/variables.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -27,6 +27,7 @@
 
 #include "gob/gob.h"
 #include "gob/variables.h"
+#include "gob/helper.h"
 
 namespace Gob {
 

Modified: scummvm/trunk/engines/gob/video.h
===================================================================
--- scummvm/trunk/engines/gob/video.h	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/video.h	2009-05-21 17:12:33 UTC (rev 40765)
@@ -30,6 +30,7 @@
 #include "common/rect.h"
 
 #include "gob/gob.h"
+#include "gob/helper.h"
 
 namespace Graphics {
 	class PaletteLUT;

Modified: scummvm/trunk/engines/gob/videoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.cpp	2009-05-21 17:00:25 UTC (rev 40764)
+++ scummvm/trunk/engines/gob/videoplayer.cpp	2009-05-21 17:12:33 UTC (rev 40765)
@@ -25,6 +25,7 @@
 
 
 #include "gob/videoplayer.h"
+#include "gob/helper.h"
 #include "gob/global.h"
 #include "gob/util.h"
 #include "gob/dataio.h"


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list