Commit 3be919f8 authored by Brad King's avatar Brad King
Browse files

ENH: Removing inclusion of windows.h by top VTK headers. This results in a...

ENH: Removing inclusion of windows.h by top VTK headers.  This results in a substantial compile time reduction (~70%) on Windows compilers.  It also avoids forcing windows name mangling on user code.  Preprocessor work-arounds for this mangling has been added for VTK methods.  A new vtkWindows.h has been created for VTK code that really needs the windows API.  A vtkOpenGL.h has been created for VTK code that needs GL/gl.h because this header requires windows.h to be included first on some compilers.  This addresses bug #836.
parent c728297f
......@@ -189,6 +189,9 @@ IF(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv|nmake)")
ENDIF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
ENDIF(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv|nmake)")
# Tell VTK source files they are being built inside VTK.
ADD_DEFINITIONS(-DVTK_IN_VTK)
#-----------------------------------------------------------------------------
# Add compiler flags VTK needs to work on this platform. This must be
# done after the call to CMAKE_EXPORT_BUILD_SETTINGS, but before any
......
......@@ -24,7 +24,8 @@
#if defined(__CYGWIN__)
#include <sys/unistd.h>
#elif defined(_WIN32)
#include <io.h>
# include <io.h>
# include "vtkWindows.h"
#endif
void otherTimerLogTest(ostream& strm)
......
......@@ -17,7 +17,7 @@
#include "vtkMatrix4x4.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkAssemblyNode, "1.6");
vtkCxxRevisionMacro(vtkAssemblyNode, "1.7");
vtkStandardNewMacro(vtkAssemblyNode);
vtkAssemblyNode::vtkAssemblyNode()
......@@ -38,8 +38,27 @@ vtkAssemblyNode::~vtkAssemblyNode()
}
}
//----------------------------------------------------------------------------
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
# undef SetProp
// Define possible mangled names.
void vtkAssemblyNode::SetPropA(vtkProp* prop)
{
this->SetPropInternal(prop);
}
void vtkAssemblyNode::SetPropW(vtkProp* prop)
{
this->SetPropInternal(prop);
}
#endif
void vtkAssemblyNode::SetProp(vtkProp* prop)
{
this->SetPropInternal(prop);
}
//----------------------------------------------------------------------------
// Don't do reference counting
void vtkAssemblyNode::SetProp(vtkProp *prop)
void vtkAssemblyNode::SetPropInternal(vtkProp *prop)
{
this->Prop = prop;
}
......@@ -82,6 +101,32 @@ unsigned long vtkAssemblyNode::GetMTime()
return (propMTime > matrixMTime ? propMTime : matrixMTime);
}
//----------------------------------------------------------------------------
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
# undef GetProp
// Define possible mangled names.
vtkProp* vtkAssemblyNode::GetPropA()
{
return this->GetPropInternal();
}
vtkProp* vtkAssemblyNode::GetPropW()
{
return this->GetPropInternal();
}
#endif
vtkProp* vtkAssemblyNode::GetProp()
{
return this->GetPropInternal();
}
//----------------------------------------------------------------------------
vtkProp* vtkAssemblyNode::GetPropInternal()
{
vtkDebugMacro(<< this->GetClassName() << " (" << this
<< "): returning Prop address " << this->Prop );
return this->Prop;
}
void vtkAssemblyNode::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
......
......@@ -57,11 +57,33 @@ public:
vtkTypeRevisionMacro(vtkAssemblyNode,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
// Avoid windows name mangling.
# define SetPropA SetProp
# define SetPropW SetProp
# define GetPropA GetProp
# define GetPropW GetProp
#endif
// Description:
// Set/Get the prop that this assembly node refers to.
void SetProp(vtkProp *prop);
vtkGetObjectMacro(Prop, vtkProp);
void SetProp(vtkProp* prop);
vtkProp* GetProp();
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
# undef SetPropW
# undef SetPropA
# undef GetPropW
# undef GetPropA
//BTX
// Define possible mangled names.
void SetPropA(vtkProp* prop);
void SetPropW(vtkProp* prop);
vtkProp* GetPropA();
vtkProp* GetPropW();
//ETX
#endif
// Description:
// Specify a transformation matrix associated with the prop.
// Note: if the prop is not a type of vtkProp3D, then the
......@@ -80,6 +102,8 @@ protected:
vtkAssemblyNode();
~vtkAssemblyNode();
void SetPropInternal(vtkProp* prop);
virtual vtkProp* GetPropInternal();
private:
vtkProp *Prop; //reference to vtkProp
vtkMatrix4x4 *Matrix; //associated matrix
......
......@@ -16,7 +16,7 @@
#include "vtkObjectFactory.h"
#include "vtkCollection.h"
vtkCxxRevisionMacro(vtkCollectionIterator, "1.2");
vtkCxxRevisionMacro(vtkCollectionIterator, "1.3");
vtkStandardNewMacro(vtkCollectionIterator);
//----------------------------------------------------------------------------
......@@ -82,7 +82,25 @@ int vtkCollectionIterator::IsDoneWithTraversal()
}
//----------------------------------------------------------------------------
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
# undef GetObject
// Define possible mangled names.
vtkObject* vtkCollectionIterator::GetObjectA()
{
return this->GetObjectInternal();
}
vtkObject* vtkCollectionIterator::GetObjectW()
{
return this->GetObjectInternal();
}
#endif
vtkObject* vtkCollectionIterator::GetObject()
{
return this->GetObjectInternal();
}
//----------------------------------------------------------------------------
vtkObject* vtkCollectionIterator::GetObjectInternal()
{
if(this->Element)
{
......
......@@ -58,12 +58,28 @@ public:
// Test whether the iterator is currently positioned at a valid item.
// Returns 1 for yes, 0 for no.
int IsDoneWithTraversal();
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
// Avoid windows name mangling.
# define GetObjectA GetObject
# define GetObjectW GetObject
#endif
// Description:
// Get the item at the current iterator position. Valid only when
// IsDoneWithTraversal() returns 1.
vtkObject* GetObject();
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
# undef GetObjectW
# undef GetObjectA
//BTX
// Define possible mangled names.
vtkObject* GetObjectA();
vtkObject* GetObjectW();
//ETX
#endif
protected:
vtkCollectionIterator();
~vtkCollectionIterator();
......@@ -73,7 +89,8 @@ protected:
// The current iterator position.
vtkCollectionElement* Element;
vtkObject* GetObjectInternal();
private:
vtkCollectionIterator(const vtkCollectionIterator&); // Not implemented
void operator=(const vtkCollectionIterator&); // Not implemented
......
......@@ -15,7 +15,7 @@
#include "vtkCriticalSection.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkCriticalSection, "1.10");
vtkCxxRevisionMacro(vtkCriticalSection, "1.11");
vtkStandardNewMacro(vtkCriticalSection);
// New for the SimpleCriticalSection
......@@ -92,20 +92,6 @@ void vtkSimpleCriticalSection::Unlock()
#endif
}
int vtkSimpleCriticalSection::IsA(const char *type)
{
if ( !strcmp(this->vtkSimpleCriticalSection::GetClassName(),type) )
{
return 1;
}
return 0;
}
vtkSimpleCriticalSection *vtkSimpleCriticalSection::SafeDownCast(vtkSimpleCriticalSection *o)
{
return (vtkSimpleCriticalSection *)o;
}
void vtkCriticalSection::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
......
......@@ -48,7 +48,7 @@ typedef pthread_mutex_t vtkCritSecType;
#endif
#ifdef VTK_USE_WIN32_THREADS
#include <winbase.h> // Needed for win32 implementation of mutex
# include "vtkWindows.h" // Needed for win32 implementation of mutex
typedef CRITICAL_SECTION vtkCritSecType;
#endif
......@@ -84,12 +84,6 @@ public:
static vtkSimpleCriticalSection *New();
// What's the point of these (here and in MutexLock)? This class
// is not part of the hierarchy!! -CRV
virtual const char *GetClassName() {return "vtkSimpleCriticalSection";};
virtual int IsA(const char *name);
static vtkSimpleCriticalSection *SafeDownCast(vtkSimpleCriticalSection *o);
void Delete() {delete this;}
// Description:
......
......@@ -18,7 +18,7 @@
#include <sys/stat.h>
vtkCxxRevisionMacro(vtkDirectory, "1.23");
vtkCxxRevisionMacro(vtkDirectory, "1.24");
//----------------------------------------------------------------------------
// Needed when we don't use the vtkStandardNewMacro.
......@@ -77,11 +77,10 @@ void vtkDirectory::PrintSelf(ostream& os, vtkIndent indent)
}
}
// First microsoft and borland compilers
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
#include <windows.h>
#include "vtkWindows.h"
#include <io.h>
#include <ctype.h>
#include <direct.h>
......@@ -214,7 +213,26 @@ const char* vtkDirectory::GetCurrentWorkingDirectory(char* buf,
#endif
//----------------------------------------------------------------------------
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
# undef CreateDirectory
// Define possible mangled names.
int vtkDirectory::CreateDirectoryA(const char* dir)
{
return vtkDirectory::CreateDirectoryInternal(dir);
}
int vtkDirectory::CreateDirectoryW(const char* dir)
{
return vtkDirectory::CreateDirectoryInternal(dir);
}
#endif
int vtkDirectory::CreateDirectory(const char* dir)
{
return vtkDirectory::CreateDirectoryInternal(dir);
}
//----------------------------------------------------------------------------
int vtkDirectory::CreateDirectoryInternal(const char* dir)
{
#if defined(_WIN32) && (defined(_MSC_VER) || defined(__BORLANDC__) \
|| defined(__MINGW32__))
......@@ -235,4 +253,3 @@ const char* vtkDirectory::GetFile(int index)
return this->Files[index];
}
......@@ -60,11 +60,27 @@ public:
// Get the current working directory.
static const char* GetCurrentWorkingDirectory(char* buf, unsigned int len);
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
// Avoid windows name mangling.
# define CreateDirectoryA CreateDirectory
# define CreateDirectoryW CreateDirectory
#endif
// Description:
// Create directory. Needs rework to do all the testing and to work
// on all platforms.
static int CreateDirectory(const char* dir);
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
# undef CreateDirectoryW
# undef CreateDirectoryA
//BTX
// Define possible mangled names.
static int CreateDirectoryA(const char* dir);
static int CreateDirectoryW(const char* dir);
//ETX
#endif
protected:
// delete the Files and Path ivars and set
// NumberOfFiles to 0
......@@ -75,7 +91,8 @@ private:
char* Path; // Path to Open'ed directory
char** Files; // Array of Files
int NumberOfFiles; // Number if files in open directory
static int CreateDirectoryInternal(const char* dir);
private:
vtkDirectory(const vtkDirectory&); // Not implemented.
void operator=(const vtkDirectory&); // Not implemented.
......
......@@ -24,7 +24,7 @@
// Each part of the ifdef contains a complete implementation for
// the static methods of vtkDynamicLoader.
vtkCxxRevisionMacro(vtkDynamicLoader, "1.20");
vtkCxxRevisionMacro(vtkDynamicLoader, "1.21");
//----------------------------------------------------------------------------
// Needed when we don't use the vtkStandardNewMacro.
......@@ -158,7 +158,7 @@ const char* vtkDynamicLoader::LastError()
// ---------------------------------------------------------------
// 3. Implementation for Windows win32 code
#ifdef _WIN32
#include <windows.h>
# include "vtkWindows.h"
#define VTKDYNAMICLOADER_DEFINED 1
vtkLibHandle vtkDynamicLoader::OpenLibrary(const char* libname )
......@@ -176,7 +176,7 @@ vtkLibHandle vtkDynamicLoader::OpenLibrary(const char* libname )
int vtkDynamicLoader::CloseLibrary(vtkLibHandle lib)
{
return (int)FreeLibrary(lib);
return (int)FreeLibrary(static_cast<HMODULE>(lib));
}
void* vtkDynamicLoader::GetSymbolAddress(vtkLibHandle lib, const char* sym)
......@@ -191,7 +191,7 @@ void* vtkDynamicLoader::GetSymbolAddress(vtkLibHandle lib, const char* sym)
delete [] wsym;
return ret;
#else
return (void*)GetProcAddress(lib, sym);
return (void*)GetProcAddress(static_cast<HMODULE>(lib), sym);
#endif
}
......
......@@ -29,7 +29,7 @@
# include <dl.h> // Needed for special dynamic loading on hp
typedef shl_t vtkLibHandle;
#elif defined(_WIN32)
typedef HMODULE vtkLibHandle;
typedef void* vtkLibHandle;
#else
typedef void* vtkLibHandle;
#endif
......
......@@ -33,8 +33,6 @@ public:
vtkIndent(int ind=0) {this->Indent=ind;};
static vtkIndent *New();
virtual const char *GetClassName() {return "vtkIndent";};
// Description:
// Determine the next indentation level. Keep indenting by two until the
// max of forty.
......
......@@ -28,9 +28,9 @@
jclass cls = E->GetObjectClass(C);\
jmethodID mid = E->GetMethodID(cls, "hashCode", "()I");\
H = E->CallIntMethod(C, mid); }
#include <windows.h>
# include "vtkWindows.h"
int WJLH_init_check = 0;
#include "vtkstd/map"
# include <vtkstd/map>
vtkstd::map<int,int> WJLH_lock_map;
#endif
......
......@@ -24,6 +24,7 @@
#define _INTEGRAL_MAX_BITS 64
#include "vtkObject.h"
#include "vtkWindows.h"
#ifdef _WIN32
HANDLE vtkGlobalMutex = NULL;
......
......@@ -17,7 +17,7 @@
#include "vtkMutexLock.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkMultiThreader, "1.48");
vtkCxxRevisionMacro(vtkMultiThreader, "1.49");
vtkStandardNewMacro(vtkMultiThreader);
// These are the includes necessary for multithreaded rendering on an SGI
......@@ -40,6 +40,10 @@ extern "C" { typedef void *(*vtkExternCThreadFunctionType)(void *); }
typedef vtkThreadFunctionType vtkExternCThreadFunctionType;
#endif
#ifdef VTK_USE_WIN32_THREADS
# include "vtkWindows.h"
#endif
#ifdef __APPLE__
#include <Carbon/Carbon.h>
#endif
......
......@@ -66,11 +66,11 @@ typedef pthread_t vtkMultiThreaderIDType;
#endif
#ifdef VTK_USE_WIN32_THREADS
typedef LPTHREAD_START_ROUTINE vtkThreadFunctionType;
typedef HANDLE vtkThreadProcessIDType;
typedef vtkWindowsLPTHREAD_START_ROUTINE vtkThreadFunctionType;
typedef vtkWindowsHANDLE vtkThreadProcessIDType;
// #define VTK_THREAD_RETURN_VALUE 0
// #define VTK_THREAD_RETURN_TYPE DWORD __stdcall
typedef DWORD vtkMultiThreaderIDType;
typedef vtkWindowsDWORD vtkMultiThreaderIDType;
#endif
#if !defined(VTK_USE_PTHREADS) && !defined(VTK_USE_WIN32_THREADS)
......
......@@ -15,7 +15,11 @@
#include "vtkMutexLock.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkMutexLock, "1.22");
#ifdef VTK_USE_WIN32_THREADS
# include "vtkWindows.h"
#endif
vtkCxxRevisionMacro(vtkMutexLock, "1.23");
vtkStandardNewMacro(vtkMutexLock);
// New for the SimpleMutex
......@@ -89,20 +93,6 @@ void vtkSimpleMutexLock::Unlock()
#endif
}
int vtkSimpleMutexLock::IsA(const char *type)
{
if ( !strcmp(this->vtkSimpleMutexLock::GetClassName(),type) )
{
return 1;
}
return 0;
}
vtkSimpleMutexLock *vtkSimpleMutexLock::SafeDownCast(vtkSimpleMutexLock *o)
{
return (vtkSimpleMutexLock *)o;
}
void vtkMutexLock::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
......
......@@ -37,8 +37,7 @@ typedef pthread_mutex_t vtkMutexType;
#endif
#ifdef VTK_USE_WIN32_THREADS
#include <winbase.h> // Needed for WIN32 implementation of mutex
typedef HANDLE vtkMutexType;
typedef vtkWindowsHANDLE vtkMutexType;
#endif
#ifndef VTK_USE_SPROC
......@@ -59,10 +58,6 @@ public:
static vtkSimpleMutexLock *New();
virtual const char *GetClassName() {return "vtkSimpleMutexLock";};
virtual int IsA(const char *name);
static vtkSimpleMutexLock *SafeDownCast(vtkSimpleMutexLock *o);
void Delete() {delete this;}
// Description:
......
......@@ -62,6 +62,24 @@ vtkObjectBase::~vtkObjectBase()
}
}
//----------------------------------------------------------------------------
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
# undef GetClassName
// Define possible mangled names.
const char* vtkObjectBase::GetClassNameA() const
{
return this->GetClassNameInternal();
}
const char* vtkObjectBase::GetClassNameW() const
{
return this->GetClassNameInternal();
}
#endif
const char* vtkObjectBase::GetClassName() const
{
return this->GetClassNameInternal();
}
int vtkObjectBase::IsTypeOf(const char *name)
{
if ( !strcmp("vtkObjectBase",name) )
......@@ -134,7 +152,7 @@ void vtkObjectBase::UnRegister(vtkObjectBase* o)
void vtkObjectBase::CollectRevisions(ostream& os)
{
os << "vtkObjectBase 1.11\n";
os << "vtkObjectBase 1.12\n";
}
void vtkObjectBase::PrintRevisions(ostream& os)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment