diff --git a/distrib/msw/tmake/vcapp.t b/distrib/msw/tmake/vcapp.t new file mode 100644 index 0000000000..afc6a86cea --- /dev/null +++ b/distrib/msw/tmake/vcapp.t @@ -0,0 +1,310 @@ +#! +#! This TMAKE template - Microsoft Visual C++ 6.0 applications +#! +#${ + if ( Config("qt") || Config("opengl") ) { + Project('CONFIG += windows'); + } + if ( Config("qt") ) { + $moc_aware = 1; + AddIncludePath(Project('TMAKE_INCDIR_QT')); + if ( Config("opengl") ) { + Project('TMAKE_LIBS *= $$TMAKE_LIBS_QT_OPENGL'); + } + Project('TMAKE_LIBS *= $$TMAKE_LIBS_QT'); + } + if ( Config("opengl") ) { + Project('TMAKE_LIBS *= $$TMAKE_LIBS_OPENGL'); + } + #! wxWindows specific things (added by VZ) + #! (1) set -I and -L options + #! (2) be sure we have the same project settings as wxWindows.dsp, here it + #! means that we must disable C++ exception handling + #! (3) define the necessary constants + if ( Config("wx") ) { + Project('CONFIG += windows'); + } + if ( Config("wxbase") ) { + Project('CONFIG += wx'); + } + if ( Config("wx") ) { + #! VC 6.0 supports env vars in include path + #! $WXDIR = $ENV{'WX'}; + $WXDIR = "\$(WX)"; + $TMAKE_INCDIR_WX = $WXDIR . "\\include"; + AddIncludePath($TMAKE_INCDIR_WX); + } + + if ( Config("dll") ) { + $DLL="Dll"; + $DLL_OR_LIB="wxWinDll"; + $DLL_FLAGS="/D WXUSINGDLL "; + } + else { + $DLL=""; + $DLL_OR_LIB="wxWindows"; + $DLL_FLAGS=" "; + } + + #! let's be smarter: first of all, if no extension is given, add .lib + #! (this allows for LIBS=libname in project files which map either on + #! -l libname.lib under Windows or on -llibname under Unix). + @libs = split(/\s+/, Project('LIBS')); + foreach $lib (@libs) { + if ( $lib !~ "\.lib\$" ) { $lib .= ".lib"; } + Project('TMAKE_LIBS *= ' . $lib); + } + + if ( Config("windows") ) { + $project{"VC_PROJ_TYPE"} = 'Win32 (x86) Application'; + $project{"VC_PROJ_CODE"} = '0x0101'; + $vc_base_libs = 'kernel32.lib user32.lib gdi32.lib winspool.lib ' . + 'comdlg32.lib advapi32.lib shell32.lib ole32.lib ' . + 'oleaut32.lib uuid.lib odbc32.lib odbccp32.lib '; + if ( Config("wx") ) { + $vc_base_libs .= "comctl32.lib rpcrt4.lib wsock32.lib "; + + $vc_link_release = "$WXDIR\\Release$DLL\\$DLL_OR_LIB.lib $WXDIR\\src\\xpm\\Release\\xpm.lib "; + $vc_link_debug = "$WXDIR\\Debug$DLL\\$DLL_OR_LIB.lib $WXDIR\\src\\xpm\\Debug\\xpm.lib "; + } + $vc_link_release .= '/nologo /subsystem:windows /machine:I386'; + $vc_link_debug .= '/nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept'; + + $vc_cpp_def_common = '/D "WIN32" /D "_WINDOWS" ' . $DLL_FLAGS; + $vc_cpp_def_release = '/D "NDEBUG" ' . $vc_cpp_def_common; + $vc_cpp_def_debug = '/D "_DEBUG" ' . $vc_cpp_def_common; + } else { + $project{"VC_PROJ_TYPE"} = 'Win32 (x86) Console Application'; + $project{"VC_PROJ_CODE"} = '0x0103'; + $vc_base_libs = 'kernel32.lib user32.lib advapi32.lib '; + if ( Config("wx") ) { + $vc_base_libs .= 'wsock32.lib '; + $vc_link_release = "$WXDIR\\Base${DLL}Release\\wxBase$DLL.lib "; + $vc_link_debug = "$WXDIR\\Base${DLL}Debug\\wxBase$DLL.lib "; + } + $vc_link_release .= '/nologo /subsystem:console /machine:I386'; + $vc_link_debug .= '/nologo /subsystem:console /debug /machine:I386 /pdbtype:sept'; + + $vc_cpp_def_common = '/D "WIN32" /D "_CONSOLE" ' . $DLL_FLAGS; + $vc_cpp_def_release = '/D "NDEBUG" ' . $vc_cpp_def_common; + $vc_cpp_def_debug = '/D "_DEBUG" ' . $vc_cpp_def_common; + } + #! define wxWin debug flags in debug build + if ( Config("wx") ) { + $vc_cpp_def_debug .= '/MDd /D "__WXDEBUG__" /D "WXDEBUG=1" '; + $vc_cpp_def_release .= '/MD ' + } + + $project{"VC_BASE_LINK_RELEASE"} = $vc_base_libs . $vc_link_release; + $project{"VC_BASE_LINK_DEBUG"} = $vc_base_libs . $vc_link_debug; + $tmake_libs = Project('TMAKE_LIBS') ? (Project('TMAKE_LIBS') . " ") : ""; + $project{"VC_LINK_RELEASE"} = $vc_base_libs . $tmake_libs . $vc_link_release; + $project{"VC_LINK_DEBUG"} = $vc_base_libs . $tmake_libs . $vc_link_debug; + + $vc_cpp_opt_common1 = '/nologo /W4 '; + if ( !Config("wx") ) { + $vc_cpp_opt_common1 = $vc_cpp_opt_common1 . '/GX '; + } + #! else: disable C++ exception handling for wxWindows + + $vc_cpp_opt_release = $vc_cpp_opt_common1 . '/O2 '; + $vc_cpp_opt_debug = $vc_cpp_opt_common1 . '/Zi /Od '; + $vc_cpp_opt_common = '/YX /FD /c'; + $project{"VC_BASE_CPP_RELEASE"} = $vc_cpp_opt_release . $vc_cpp_def_release . $vc_cpp_opt_common; + $project{"VC_BASE_CPP_DEBUG"} = $vc_cpp_opt_debug . $vc_cpp_def_debug . $vc_cpp_opt_common; + ExpandGlue("INCPATH",'/I "','" /I "','"'); + if ( $text ne "" ) { $vc_inc = $text . " "; $text = ""; } else { $vc_inc = ""; } + ExpandGlue("DEFINES",'/D "','" /D "','"'); + if ( $text ne "" ) { $vc_def = $text . " "; $text = ""; } else { $vc_def = ""; } + if ( Config("wx") ) { + #! define wxWindows compilation flags + $vc_def .= '/D _WIN32 /D __WIN32__ /D WINVER=0x400 /D __WINDOWS__ /D __WXMSW__ /D __WIN95__ /D __WIN32__ /D _MT '; + + if ( Config("wxbase") ) { + $vc_def .= '/D wxUSE_GUI=0 '; + } + else { + $vc_def .= '/D wxUSE_GUI=1 '; + } + } + + $project{"VC_CPP_INCLUDE"} = $vc_inc; + $project{"VC_CPP_RELEASE"} = $vc_cpp_opt_release . $vc_inc . $vc_cpp_def_release . $vc_def . $vc_cpp_opt_common; + $project{"VC_CPP_DEBUG"} = $vc_cpp_opt_debug . $vc_inc . $vc_cpp_def_debug . $vc_def . $vc_cpp_opt_common; + + if ( Project('RES_FILE') ) { + tmake_error(".res files are not supported, use .rc."); + } + + $project{"MAKEFILE"} = $project{"PROJECT"} . ".mak"; + $project{"TARGETAPP"} = $project{"TARGET"} . ".exe"; + Project('TMAKE_FILETAGS = HEADERS SOURCES TARGET DESTDIR $$FILETAGS'); + foreach ( split(/\s/,Project('TMAKE_FILETAGS')) ) { + $project{$_} =~ s-/-\\-g; + } + StdInit(); + if ( defined($project{"DESTDIR"}) ) { + $project{"TARGETAPP"} = $project{"DESTDIR"} . "\\" . $project{"TARGETAPP"}; + $project{"TARGETAPP"} =~ s/\\+/\\/g; + } + %all_files = (); + @files = split(/\s+/,$project{"HEADERS"}); + foreach ( @files ) { $all_files{$_} = "h" }; + @files = split(/\s+/,$project{"SOURCES"}); + foreach ( @files ) { $all_files{$_} = "s" }; + @files = split(/\s+/,$project{"RC_FILE"}); + foreach ( @files ) { $all_files{$_} = "r" }; + + if ( $moc_aware ) { + @files = split(/\s+/,$project{"_HDRMOC"}); + foreach ( @files ) { $all_files{$_} = "m"; } + @files = split(/\s+/,$project{"_SRCMOC"}); + foreach ( @files ) { $all_files{$_} = "i"; } + } + %file_names = (); + foreach $f ( %all_files ) { + $n = $f; + $n =~ s/^.*\\//; + $file_names{$n} = $f; + $file_path{$n} = ".\\" . $f; + $file_path2{$n} = (($f =~ /^\./) ? "" : ".\\") . $f; + } + +#$} +# Microsoft Developer Studio Project File - #$ Substitute('Name="$$TARGET" - Package Owner=<4>'); +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE #$ Substitute('"$$VC_PROJ_TYPE" $$VC_PROJ_CODE'); + +CFG=#$ Substitute('$$TARGET - Win32 Debug'); +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "#$ ExpandGlue('MAKEFILE','','','".'); +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f #$ Substitute('"$$MAKEFILE" CFG="$$TARGET - Win32 Debug"'); +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE #$ Substitute('"$$TARGET - Win32 Release" (based on "$$VC_PROJ_TYPE")'); +!MESSAGE #$ Substitute('"$$TARGET - Win32 Debug" (based on "$$VC_PROJ_TYPE")'); +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +#$ Config("windows") && ($text='MTL=midl.exe'); +RSC=rc.exe + +!IF "$(CFG)" == #$ Substitute('"$$TARGET - Win32 Release"'); + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +#$ Config("windows") && ($text='# PROP Ignore_Export_Lib 0'); +# PROP Target_Dir "" +# ADD BASE CPP #$ Expand("VC_BASE_CPP_RELEASE"); +# ADD CPP #$ Expand("VC_CPP_RELEASE"); +#$ Config("windows") || DisableOutput(); +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +#$ Config("windows") || EnableOutput(); +# ADD BASE RSC /l 0x409 /d "NDEBUG" #$ Expand("VC_CPP_INCLUDE"); +# ADD RSC /l 0x409 /d "NDEBUG" #$ Expand("VC_CPP_INCLUDE"); +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 #$ Expand("VC_BASE_LINK_RELEASE"); +# ADD LINK32 #$ Expand("VC_LINK_RELEASE"); + +!ELSEIF "$(CFG)" == #$ Substitute('"$$TARGET - Win32 Debug"'); + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +#$ Config("windows") && ($text='# PROP Ignore_Export_Lib 0'); +# PROP Target_Dir "" +# ADD BASE CPP #$ Expand("VC_BASE_CPP_DEBUG"); +# ADD CPP #$ Expand("VC_CPP_DEBUG"); +#$ Config("windows") || DisableOutput(); +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 +#$ Config("windows") || EnableOutput(); +# ADD BASE RSC /l 0x409 /d "_DEBUG" #$ Expand("VC_CPP_INCLUDE"); +# ADD RSC /l 0x409 /d "_DEBUG" #$ Expand("VC_CPP_INCLUDE"); +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 #$ Expand("VC_BASE_LINK_DEBUG"); +# ADD LINK32 #$ Expand("VC_LINK_DEBUG"); + +!ENDIF + +# Begin Target + +# Name #$Substitute('"$$TARGET - Win32 Release"'); +# Name #$Substitute('"$$TARGET - Win32 Debug"'); +#${ + foreach $n ( sort keys %file_names ) { + $f = $file_names{$n}; + $p = $file_path{$n}; + $p2 = $file_path2{$n}; + $t = $all_files{$f}; + if ( ($t eq "h") && $moc_output{$f} ) { + my($build); + $build = "\n\n# Begin Custom Build - Running moc...\nInputPath=" . $p2 . "\n\n" + . '"' . $moc_output{$f} . '" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"' + . "\n\tmoc $p2 -o " . $moc_output{$f} . "\n\n" + . "# End Custom Build\n\n"; + $text .= ("# Begin Source File\n\nSOURCE=$p\n\n" + . '!IF "$(CFG)" == "' . $project{"TARGET"} . ' - Win32 Release"' + . $build); + $text .= ('!ELSEIF "$(CFG)" == "' . $project{"TARGET"} . ' - Win32 Debug"' + . $build + . "!ENDIF \n\n# End Source File\n"); + } elsif ( $t eq "i" ) { + my($build,$dn); + $build = "\n\n# Begin Custom Build - Running moc...\nInputPath=" . $p2 . "\n\n" + . '"' . $f . '" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"' + . "\n\tmoc ". $moc_input{$f} . " -o $f\n\n" + . "# End Custom Build\n\n"; + $dn = $n; + $dn =~ s/\..*//; + $dn =~ tr/a-z/A-Z/; + $text .= ("# Begin Source File\n\nSOURCE=$p\n" + . "USERDEP__$dn=" . '"' . $moc_input{$f} . '"' . "\n\n" + . '!IF "$(CFG)" == "' . $project{"TARGET"} . ' - Win32 Release"' + . $build); + $text .= ('!ELSEIF "$(CFG)" == "' . $project{"TARGET"} . ' - Win32 Debug"' + . $build + . "!ENDIF \n\n# End Source File\n"); + } elsif ( $t eq "s" || $t eq "m" || $t eq "h" || $t eq "r" ) { + $text .= "# Begin Source File\n\nSOURCE=$p\n"; + $text .= "# End Source File\n"; + } + } + chop $text; +#$} +# End Target +# End Project + +#! vim:sta:sw=4:ts=8:nolist:noet diff --git a/include/wx/debug.h b/include/wx/debug.h index c7a69752d3..4cb9dd165d 100644 --- a/include/wx/debug.h +++ b/include/wx/debug.h @@ -43,6 +43,10 @@ // ---------------------------------------------------------------------------- //@{ +// Use of these suppresses compiler warnings about testing constant expression +WXDLLEXPORT_DATA(extern const bool) wxTrue; +WXDLLEXPORT_DATA(extern const bool) wxFalse; + /** @name Macros which are completely disabled in 'release' mode */ //@{ #ifdef __WXDEBUG__ @@ -58,15 +62,8 @@ /// generic assert macro #define wxASSERT(cond) if ( !(cond) ) wxOnAssert(__TFILE__, __LINE__) -#if 0 // defined(__BORLANDC__) && defined(__WIN16__) - // Too much text, so make wxASSERT_MSG the same as wxASSERT, - // thus removing the text from the program. - #define wxASSERT_MSG(x, m) if ( !(x) ) wxOnAssert(__TFILE__, __LINE__) -#else /// assert with additional message explaining it's cause #define wxASSERT_MSG(x, m) if ( !(x) ) wxOnAssert(__TFILE__, __LINE__, m) -#endif - #else // nothing to do in release modes (hopefully at this moment there are // no more bugs ;-) @@ -74,17 +71,11 @@ #define wxASSERT_MSG(x, m) #endif //__WXDEBUG__ - /// special form of assert: always triggers it (in debug mode) +/// special form of assert: always triggers it (in debug mode) #define wxFAIL wxASSERT(wxFalse) -#if 0 // defined(__BORLANDC__) && defined(__WIN16__) - // Too much text, so make wxFAIL_MSG the same as wxFAIL, - // thus removing the text from the program. -#define wxFAIL_MSG(msg) wxASSERT(wxFalse) -#else - /// FAIL with some message +/// FAIL with some message #define wxFAIL_MSG(msg) wxASSERT_MSG(wxFalse, msg) -#endif //@} // NB: these macros work also in release mode! diff --git a/include/wx/defs.h b/include/wx/defs.h index 64eee1e849..d4a7b74f56 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -455,8 +455,12 @@ class WXDLLEXPORT wxEvent; #define wxNOT_FOUND (-1) // ---------------------------------------------------------------------------- -/** @name Very common macros */ +// Very common macros // ---------------------------------------------------------------------------- + +// everybody gets the assert and other debug macros +#include "wx/debug.h" + //@{ /// delete pointer if it is not NULL and NULL it afterwards // (checking that it's !NULL before passing it to delete is just a @@ -488,10 +492,6 @@ class WXDLLEXPORT wxEvent; /// size of statically declared array #define WXSIZEOF(array) (sizeof(array)/sizeof(array[0])) -// Use of these suppresses some compiler warnings -WXDLLEXPORT_DATA(extern const bool) wxTrue; -WXDLLEXPORT_DATA(extern const bool) wxFalse; - // ---------------------------------------------------------------------------- // compiler specific settings // ---------------------------------------------------------------------------- diff --git a/include/wx/dynarray.h b/include/wx/dynarray.h index 0ee90cc88b..702df0bad0 100644 --- a/include/wx/dynarray.h +++ b/include/wx/dynarray.h @@ -17,7 +17,6 @@ #endif #include "wx/defs.h" -#include "wx/debug.h" /** @name Dynamic arrays and object arrays (array which own their elements) @memo Arrays which grow on demand and do range checking (only in debug) diff --git a/include/wx/list.h b/include/wx/list.h index 8c76d9b5c5..15a76aa2da 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -34,7 +34,6 @@ // ----------------------------------------------------------------------------- #include "wx/defs.h" -#include "wx/debug.h" #include "wx/object.h" #include "wx/string.h" diff --git a/include/wx/longlong.h b/include/wx/longlong.h index 5ff8a9b01c..3c378859be 100644 --- a/include/wx/longlong.h +++ b/include/wx/longlong.h @@ -21,7 +21,6 @@ #include "wx/defs.h" #include "wx/wxchar.h" -#include "wx/debug.h" #include // for LONG_MAX diff --git a/include/wx/string.h b/include/wx/string.h index f4a26c4e1c..b918b715e0 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -66,7 +66,6 @@ #endif // AIX #include "wx/defs.h" // everybody should include this -#include "wx/debug.h" // for wxASSERT() #include "wx/wxchar.h" // for wxChar #include "wx/buffer.h" // for wxCharBuffer #include "wx/strconv.h" // for wxConvertXXX() macros and wxMBConv classes diff --git a/src/common/filesys.cpp b/src/common/filesys.cpp index ea9f907982..197fec8941 100644 --- a/src/common/filesys.cpp +++ b/src/common/filesys.cpp @@ -89,14 +89,13 @@ wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location) } ft = wxTheMimeTypesManager -> GetFileTypeFromExtension(ext); - if (ft && (ft -> GetMimeType(&mime))) { - delete ft; - return mime; - } - else { - delete ft; - return wxEmptyString; + if ( !ft || !ft -> GetMimeType(&mime) ) { + mime = wxEmptyString; } + + delete ft; + + return mime; } @@ -186,13 +185,15 @@ bool wxLocalFSHandler::CanOpen(const wxString& location) wxFSFile* wxLocalFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location) { wxString right = GetRightLocation(location); - if (wxFileExists(right)) - return new wxFSFile(new wxFileInputStream(right), - right, - GetMimeTypeFromExt(location), - GetAnchor(location), - wxDateTime(wxFileModificationTime(right))); - else return (wxFSFile*) NULL; + if (!wxFileExists(right)) + return (wxFSFile*) NULL; + + return new wxFSFile(new wxFileInputStream(right), + right, + GetMimeTypeFromExt(location), + GetAnchor(location), + wxDateTime(wxFileModificationTime(right))); + } wxString wxLocalFSHandler::FindFirst(const wxString& spec, int flags) diff --git a/src/common/fs_inet.cpp b/src/common/fs_inet.cpp index d3b94f258d..3ebf0d5b10 100644 --- a/src/common/fs_inet.cpp +++ b/src/common/fs_inet.cpp @@ -94,8 +94,8 @@ bool wxInternetFSHandler::CanOpen(const wxString& location) wxURL url(p + wxT(":") + StripProtocolAnchor(location)); return (url.GetError() == wxURL_NOERR); } - else - return FALSE; + + return FALSE; } @@ -140,15 +140,14 @@ wxFSFile* wxInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxStri // Load item from cache: s = new wxFileInputStream(info->GetTemp()); - if (s) - { - return new wxFSFile(s, - right, - info->GetMime(), - GetAnchor(location), - wxDateTime::Now()); - } - else return (wxFSFile*) NULL; + if (!s) + return (wxFSFile*) NULL; + + return new wxFSFile(s, + right, + info->GetMime(), + GetAnchor(location), + wxDateTime::Now()); } diff --git a/src/common/object.cpp b/src/common/object.cpp index 00dfc6aa72..b81454d2ab 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -48,6 +48,11 @@ wxClassInfo wxObject::sm_classwxObject((wxChar *) wxT("wxObject"), (wxChar *) NU wxClassInfo* wxClassInfo::sm_first = (wxClassInfo *) NULL; wxHashTable* wxClassInfo::sm_classTable = (wxHashTable*) NULL; +// These are here so we can avoid 'always true/false' warnings +// by referring to these instead of TRUE/FALSE +const bool wxTrue = TRUE; +const bool wxFalse = FALSE; + /* * wxWindows root object. */ @@ -379,8 +384,3 @@ wxObjectRefData::wxObjectRefData(void) : m_count(1) wxObjectRefData::~wxObjectRefData() { } - -// These are here so we can avoid 'always true/false' warnings -// by referring to these instead of TRUE/FALSE -const bool wxTrue = TRUE; -const bool wxFalse = FALSE;