summaryrefslogtreecommitdiff
path: root/plugins/FreeImage/src/DeprecationManager
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-10-12 10:49:29 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-10-12 10:49:29 +0000
commit557f2816f5cd30705dec989c97a8a67c026d36d1 (patch)
tree4900789ab5d52219bf065744a61f9ea5863b3428 /plugins/FreeImage/src/DeprecationManager
parent69fe21d6e2262d6fb2b14278b7a20364468cbdcf (diff)
FreeImage: folders restructurization
git-svn-id: http://svn.miranda-ng.org/main/trunk@1884 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/FreeImage/src/DeprecationManager')
-rw-r--r--plugins/FreeImage/src/DeprecationManager/Deprecated.cpp36
-rw-r--r--plugins/FreeImage/src/DeprecationManager/DeprecationMgr.cpp103
-rw-r--r--plugins/FreeImage/src/DeprecationManager/DeprecationMgr.h83
3 files changed, 222 insertions, 0 deletions
diff --git a/plugins/FreeImage/src/DeprecationManager/Deprecated.cpp b/plugins/FreeImage/src/DeprecationManager/Deprecated.cpp
new file mode 100644
index 0000000000..8ca5e71c5c
--- /dev/null
+++ b/plugins/FreeImage/src/DeprecationManager/Deprecated.cpp
@@ -0,0 +1,36 @@
+// ==========================================================
+// Deprecated functions
+//
+// Design and implementation by
+// - Floris van den Berg (flvdberg@wxs.nl)
+// - Hervé Drolon (drolon@infonie.fr)
+//
+// This file is part of FreeImage 3
+//
+// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
+// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
+// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
+// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
+// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
+// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
+// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
+// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
+// THIS DISCLAIMER.
+//
+// Use at your own risk!
+// ==========================================================
+
+#include "FreeImage.h"
+
+#include "../DeprecationManager/DeprecationMgr.h"
+
+// ----------------------------------------------------------
+
+FIBITMAP *DLL_CALLCONV
+FreeImage_RotateClassic(FIBITMAP *dib, double angle) {
+#ifdef _WIN32
+ DEPRECATE("FreeImage_RotateClassic()", "FreeImage_Rotate()")
+#endif // _WIN32
+ return FreeImage_Rotate(dib, angle, NULL);
+}
+
diff --git a/plugins/FreeImage/src/DeprecationManager/DeprecationMgr.cpp b/plugins/FreeImage/src/DeprecationManager/DeprecationMgr.cpp
new file mode 100644
index 0000000000..bf82dfa33b
--- /dev/null
+++ b/plugins/FreeImage/src/DeprecationManager/DeprecationMgr.cpp
@@ -0,0 +1,103 @@
+// ==========================================================
+// Deprecation Manager
+//
+// Design and implementation by
+// - Noel Llopis (Game Programming Gems II)
+//
+// This file is part of FreeImage 3
+//
+// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
+// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
+// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
+// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
+// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
+// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
+// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
+// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
+// THIS DISCLAIMER.
+//
+// Use at your own risk!
+// ==========================================================
+
+#ifdef _MSC_VER
+#pragma warning (disable : 4786) // identifier was truncated to 'number' characters
+#endif
+
+#ifdef _WIN32
+#include <windows.h>
+#endif // _WIN32
+#include "FreeImage.h"
+#include "Utilities.h"
+#include "DeprecationMgr.h"
+
+// ==========================================================
+
+DeprecationMgr::DeprecationMgr() {
+}
+
+DeprecationMgr::~DeprecationMgr() {
+#ifdef _WIN32
+ if (!m_functions.empty()) {
+ OutputDebugString( "*************************************************************************************\n" );
+ OutputDebugString( "This is a warning, because you use one or more deprecated functions.\nContinuing to use these functions might eventually render your program uncompilable.\nThe following functions are deprecated:\n\n" );
+
+ for (std::map<const char *, DeprecatedFunction>::iterator i = m_functions.begin(); i != m_functions.end(); ++i) {
+ DeprecatedFunction *function = &((*i).second);
+
+ char txt[255];
+
+ sprintf(txt, " * %s called from %i different places. Instead use %s.\n", function->old_function_name, function->called_from.size(), function->new_function_name);
+
+ OutputDebugString(txt);
+ }
+
+ OutputDebugString( "*************************************************************************************\n" );
+
+ m_functions.clear();
+ }
+#endif // _WIN32
+}
+
+// ==========================================================
+
+DeprecationMgr *
+DeprecationMgr::GetInstance() {
+ static DeprecationMgr Instance;
+ return &Instance;
+}
+
+// ==========================================================
+
+void
+DeprecationMgr::AddDeprecatedFunction(const char *old_function_name, const char *new_function_name, const void *frame_ptr) {
+#ifdef _WIN32
+ int *preturn = (int *)frame_ptr + 1; // usual return address @ [ebp+4]
+ int called_from = IsBadReadPtr(preturn, 4) ? 0 : *preturn;
+
+ // check if this function was already listed as deprecated
+ // if it wasn't, make a new entry for it
+ // if it was, keep track of where it's called from.
+
+ std::map<const char *, DeprecatedFunction>::iterator existing_function = m_functions.find(old_function_name);
+
+ if (existing_function == m_functions.end()) {
+ DeprecatedFunction function;
+
+ function.old_function_name = old_function_name;
+ function.new_function_name = new_function_name;
+ function.called_from.insert(called_from);
+
+ m_functions[old_function_name] = function;
+ } else {
+ // since we're keeping track of the addresses this function
+ // was called from in a set, we don't need to check whether we've
+ // already added the address.
+
+ DeprecatedFunction *function = &((*existing_function).second);
+
+ function->called_from.insert(called_from);
+ }
+#endif // _WIN32
+}
+
+
diff --git a/plugins/FreeImage/src/DeprecationManager/DeprecationMgr.h b/plugins/FreeImage/src/DeprecationManager/DeprecationMgr.h
new file mode 100644
index 0000000000..9141f23a05
--- /dev/null
+++ b/plugins/FreeImage/src/DeprecationManager/DeprecationMgr.h
@@ -0,0 +1,83 @@
+// ==========================================================
+// Deprecation Manager
+//
+// Design and implementation by
+// - Noel Llopis (Game Programming Gems II)
+//
+// This file is part of FreeImage 3
+//
+// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
+// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
+// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
+// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
+// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
+// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
+// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
+// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
+// THIS DISCLAIMER.
+//
+// Use at your own risk!
+// ==========================================================
+
+#ifndef DEPRECATIONMGR_H
+#define DEPRECATIONMGR_H
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4786 ) // identifier was truncated to 'number' characters
+#endif
+
+#include "Utilities.h"
+
+// ==========================================================
+
+#if !defined(_M_X64) && defined(_MSC_VER)
+ #define DEPRECATE(a,b) \
+ { \
+ void *fptr; \
+ _asm { mov fptr, ebp } \
+ DeprecationMgr::GetInstance()->AddDeprecatedFunction(a, b, fptr); \
+ }
+
+#elif defined(__i386__) && defined(__GNUC__)
+ #define DEPRECATE(a,b) \
+ { \
+ void *fptr; \
+ __asm__("movl %%ebp, %0" : "=m" (fptr)); \
+ DeprecationMgr::GetInstance()->AddDeprecatedFunction(a, b, fptr); \
+ }
+
+#else
+ // default fallback case, which does not use the ebp register's content
+ #define DEPRECATE(a,b) \
+ { \
+ void *fptr = NULL; \
+ DeprecationMgr::GetInstance()->AddDeprecatedFunction(a, b, fptr); \
+ }
+#endif
+
+// ==========================================================
+
+class DeprecationMgr {
+#if (_MSC_VER == 1100) // VC 5.0 need to look into the docs for the compiler for the value of each version
+public:
+#else
+private:
+#endif
+
+ struct DeprecatedFunction {
+ const char *old_function_name;
+ const char *new_function_name;
+ std::set<int> called_from;
+ };
+
+ std::map<const char *, DeprecatedFunction> m_functions;
+
+public:
+ DeprecationMgr();
+ ~DeprecationMgr();
+
+ static DeprecationMgr * GetInstance ( void );
+ void AddDeprecatedFunction(const char *old_function_name, const char *new_function_name, const void *frame_ptr);
+};
+
+#endif //DEPRECATIONMGR_H