From 9be2e3416d8478b633618c430d69b54ca373ef33 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 24 Mar 2000 01:56:00 +0000 Subject: [PATCH] compilation/linking fixes for DLL build in release mode git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@6914 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- distrib/msw/tmake/vc6bdll.t | 133 ++++++++++++++++++++++ include/wx/confbase.h | 3 +- include/wx/dataobj.h | 2 +- include/wx/datetime.h | 2 +- include/wx/datetime.inl | 171 +++++++++++++++-------------- include/wx/fileconf.h | 2 +- include/wx/hash.h | 13 ++- include/wx/list.h | 20 ++-- include/wx/listimpl.cpp | 8 +- include/wx/menu.h | 4 +- include/wx/module.h | 2 +- include/wx/msw/private.h | 9 +- include/wx/string.h | 6 + include/wx/tbarbase.h | 2 +- include/wx/window.h | 2 +- src/common/config.cpp | 23 ++-- src/common/datetime.cpp | 2 +- src/common/fileconf.cpp | 24 ++-- src/common/filefn.cpp | 213 ++++++++++++++++++------------------ src/common/init.cpp | 2 +- src/common/sckipc.cpp | 18 ++- src/common/variant.cpp | 35 +++--- src/msw/mimetype.cpp | 36 +++--- src/msw/registry.cpp | 17 ++- src/msw/statbr95.cpp | 16 +-- src/msw/utils.cpp | 6 +- src/msw/utilsexc.cpp | 4 + 27 files changed, 465 insertions(+), 310 deletions(-) create mode 100644 distrib/msw/tmake/vc6bdll.t diff --git a/distrib/msw/tmake/vc6bdll.t b/distrib/msw/tmake/vc6bdll.t new file mode 100644 index 0000000000..8ed6d304af --- /dev/null +++ b/distrib/msw/tmake/vc6bdll.t @@ -0,0 +1,133 @@ +#!############################################################################# +#! File: vc6bdll.t +#! Purpose: tmake template file from which wxBaseDll.dsp is generated by running +#! tmake -t vc6bdll wxwin.pro -o wxBaseDll.dsp +#! Author: Vadim Zeitlin +#! Created: 22.03.00 +#! Version: $Id$ +#!############################################################################# +#${ + #! include the code which parses filelist.txt file and initializes + #! %wxCommon, %wxGeneric and %wxMSW hashes. + IncludeTemplate("filelist.t"); + + #! now transform these hashes into $project tags + foreach $file (sort keys %wxCommon) { + next if $wxCommon{$file} !~ /\bB\b/; + + my $tag = $file =~ /\.c$/ ? "WXCSRCS" : "WXCOMMONSRCS"; + $project{$tag} .= $file . " " + } + + foreach $file (sort keys %wxMSW) { + next if $wxMSW{$file} !~ /\bB\b/; + + my $tag = $file =~ /\.c$/ ? "WXMSWCSRCS" : "WXMSWSRCS"; + $project{$tag} .= $file . " " + } + + foreach $file (sort keys %wxBase) { + my $tag = $file =~ /\.c$/ ? "WXCSRCS" : "WXCOMMONSRCS"; + $project{$tag} .= $file . " " + } +#$} +# Microsoft Developer Studio Project File - Name="wxBaseDll" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=wxBaseDll - 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 "wxBaseDll.mak". +!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 "wxBaseDll.mak" CFG="wxBaseDll - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "wxBaseDll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "wxBaseDll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "wxBaseDll - 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 "BaseDllRelease" +# PROP Intermediate_Dir "BaseDllRelease" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXBASEDLL_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W4 /O2 /I "$(wx)\include" /I "$(wx)\src\zlib" /D "NDEBUG" /D wxUSE_GUI=0 /D "__WIN95__" /D "WIN32" /D "_WIN32" /D WINVER=0x400 /D "__WINDOWS__" /D "__WIN32__" /D "__WXMSW__" /D "_MT" /D "WXMAKINGDLL" /Yu"wx/wxprec.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /i "$(wx)\include" /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib advapi32.lib wsock32.lib /nologo /version:2.2 /dll /machine:I386 + +!ELSEIF "$(CFG)" == "wxBaseDll - 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 "BaseDllDebug" +# PROP Intermediate_Dir "BaseDllDebug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXBASEDLL_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /Gm /ZI /Od /I "$(wx)\include" /I "$(wx)\src\zlib" /D "_DEBUG" /D wxUSE_GUI=0 /D "__WIN95__" /D "WIN32" /D "_WIN32" /D WINVER=0x400 /D "__WINDOWS__" /D "__WIN32__" /D "__WXMSW__" /D "_MT" /D "WXMAKINGDLL" /D "__WXDEBUG__" /Yu"wx/wxprec.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /i "$(wx)\include" /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib advapi32.lib wsock32.lib /nologo /version:2.2 /dll /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "wxBaseDll - Win32 Release" +# Name "wxBaseDll - Win32 Debug" +# Begin Source File + +SOURCE=.\src\msw\dummydll.cpp +# ADD CPP /Yc"wx/wxprec.h" +# End Source File +#$ ExpandGlue("WXCOMMONSRCS", "# Begin Source File\n\nSOURCE=.\\src\\common\\", "\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\common\\", "\n# End Source File\n"); +#$ ExpandGlue("WXMSWSRCS", "# Begin Source File\n\nSOURCE=.\\src\\msw\\", "\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\msw\\", "\n# End Source File\n"); +#$ ExpandGlue("WXCSRCS", "# Begin Source File\n\nSOURCE=.\\src\\common\\", "\n# SUBTRACT CPP /YX /Yc /Yu\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\common\\", "\n# SUBTRACT CPP /YX /Yc /Yu\n# End Source File\n"); +#$ ExpandGlue("WXMSWCSRCS", "# Begin Source File\n\nSOURCE=.\\src\\msw\\", "\n# SUBTRACT CPP /YX /Yc /Yu\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\msw\\", "\n# SUBTRACT CPP /YX /Yc /Yu\n# End Source File\n"); +# End Target +# End Project diff --git a/include/wx/confbase.h b/include/wx/confbase.h index 840b5ed9a7..910adb11aa 100644 --- a/include/wx/confbase.h +++ b/include/wx/confbase.h @@ -113,7 +113,7 @@ public: long style = 0); // empty but ensures that dtor of all derived classes is virtual - virtual ~wxConfigBase() { } + virtual ~wxConfigBase(); // path management // set current path: if the first character is '/', it's the absolute path, @@ -226,6 +226,7 @@ public: // misc accessors wxString GetAppName() const { return m_appName; } wxString GetVendorName() const { return m_vendorName; } + // Used wxIniConfig to set members in constructor void SetAppName(const wxString& appName) { m_appName = appName; } void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; } diff --git a/include/wx/dataobj.h b/include/wx/dataobj.h index 544d90ef13..e7042d2b07 100644 --- a/include/wx/dataobj.h +++ b/include/wx/dataobj.h @@ -250,7 +250,7 @@ private: // wxDataObject directly. // ---------------------------------------------------------------------------- -WX_DECLARE_LIST(wxDataObjectSimple, wxSimpleDataObjectList); +WX_DECLARE_EXPORTED_LIST(wxDataObjectSimple, wxSimpleDataObjectList); class WXDLLEXPORT wxDataObjectComposite : public wxDataObject { diff --git a/include/wx/datetime.h b/include/wx/datetime.h index 1d7a329e67..432ad74cba 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -1245,7 +1245,7 @@ private: #include "wx/dynarray.h" -WX_DECLARE_OBJARRAY(wxDateTime, wxDateTimeArray); +WX_DECLARE_EXPORTED_OBJARRAY(wxDateTime, wxDateTimeArray); // ---------------------------------------------------------------------------- // wxDateTimeHolidayAuthority: an object of this class will decide whether a diff --git a/include/wx/datetime.inl b/include/wx/datetime.inl index 8d3112b6a4..6712cc2aa6 100644 --- a/include/wx/datetime.inl +++ b/include/wx/datetime.inl @@ -40,19 +40,19 @@ const long wxDateTime::TIME_T_FACTOR = 1000l; #endif // wxDEFINE_TIME_CONSTANTS -bool wxDateTime::IsInStdRange() const +inline bool wxDateTime::IsInStdRange() const { return m_time >= 0l && (m_time / TIME_T_FACTOR) < LONG_MAX; } /* static */ -wxDateTime wxDateTime::Now() +inline wxDateTime wxDateTime::Now() { return wxDateTime(*GetTmNow()); } /* static */ -wxDateTime wxDateTime::Today() +inline wxDateTime wxDateTime::Today() { struct tm *tm = GetTmNow(); tm->tm_hour = @@ -63,7 +63,7 @@ wxDateTime wxDateTime::Today() } #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400)) -wxDateTime& wxDateTime::Set(time_t timet) +inline wxDateTime& wxDateTime::Set(time_t timet) { // assign first to avoid long multiplication overflow! m_time = timet; @@ -73,56 +73,56 @@ wxDateTime& wxDateTime::Set(time_t timet) } #endif -wxDateTime& wxDateTime::SetToCurrent() +inline wxDateTime& wxDateTime::SetToCurrent() { *this = Now(); return *this; } #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400)) -wxDateTime::wxDateTime(time_t timet) +inline wxDateTime::wxDateTime(time_t timet) { Set(timet); } #endif -wxDateTime::wxDateTime(const struct tm& tm) +inline wxDateTime::wxDateTime(const struct tm& tm) { Set(tm); } -wxDateTime::wxDateTime(const Tm& tm) +inline wxDateTime::wxDateTime(const Tm& tm) { Set(tm); } -wxDateTime::wxDateTime(double jdn) +inline wxDateTime::wxDateTime(double jdn) { Set(jdn); } -wxDateTime& wxDateTime::Set(const Tm& tm) +inline wxDateTime& wxDateTime::Set(const Tm& tm) { wxASSERT_MSG( tm.IsValid(), _T("invalid broken down date/time") ); return Set(tm.mday, (Month)tm.mon, tm.year, tm.hour, tm.min, tm.sec); } -wxDateTime::wxDateTime(wxDateTime_t hour, - wxDateTime_t minute, - wxDateTime_t second, - wxDateTime_t millisec) +inline wxDateTime::wxDateTime(wxDateTime_t hour, + wxDateTime_t minute, + wxDateTime_t second, + wxDateTime_t millisec) { Set(hour, minute, second, millisec); } -wxDateTime::wxDateTime(wxDateTime_t day, - Month month, - int year, - wxDateTime_t hour, - wxDateTime_t minute, - wxDateTime_t second, - wxDateTime_t millisec) +inline wxDateTime::wxDateTime(wxDateTime_t day, + Month month, + int year, + wxDateTime_t hour, + wxDateTime_t minute, + wxDateTime_t second, + wxDateTime_t millisec) { Set(day, month, year, hour, minute, second, millisec); } @@ -131,14 +131,14 @@ wxDateTime::wxDateTime(wxDateTime_t day, // wxDateTime accessors // ---------------------------------------------------------------------------- -wxLongLong wxDateTime::GetValue() const +inline wxLongLong wxDateTime::GetValue() const { wxASSERT_MSG( IsValid(), _T("invalid wxDateTime")); return m_time; } -time_t wxDateTime::GetTicks() const +inline time_t wxDateTime::GetTicks() const { wxASSERT_MSG( IsValid(), _T("invalid wxDateTime")); if ( !IsInStdRange() ) @@ -149,60 +149,61 @@ time_t wxDateTime::GetTicks() const return (time_t)((m_time / (long)TIME_T_FACTOR).GetLo()); } -bool wxDateTime::SetToLastWeekDay(WeekDay weekday, - Month month, - int year) +inline bool wxDateTime::SetToLastWeekDay(WeekDay weekday, + Month month, + int year) { return SetToWeekDay(weekday, -1, month, year); } -wxDateTime wxDateTime::GetWeekDayInSameWeek(WeekDay weekday) const +inline wxDateTime wxDateTime::GetWeekDayInSameWeek(WeekDay weekday) const { MODIFY_AND_RETURN( SetToWeekDayInSameWeek(weekday) ); } -wxDateTime wxDateTime::GetNextWeekDay(WeekDay weekday) const +inline wxDateTime wxDateTime::GetNextWeekDay(WeekDay weekday) const { MODIFY_AND_RETURN( SetToNextWeekDay(weekday) ); } -wxDateTime wxDateTime::GetPrevWeekDay(WeekDay weekday) const +inline wxDateTime wxDateTime::GetPrevWeekDay(WeekDay weekday) const { MODIFY_AND_RETURN( SetToPrevWeekDay(weekday) ); } -wxDateTime wxDateTime::GetWeekDay(WeekDay weekday, - int n, - Month month, - int year) const +inline wxDateTime wxDateTime::GetWeekDay(WeekDay weekday, + int n, + Month month, + int year) const { wxDateTime dt(*this); return dt.SetToWeekDay(weekday, n, month, year) ? dt : wxInvalidDateTime; } -wxDateTime wxDateTime::GetLastWeekDay(WeekDay weekday, - Month month, - int year) +inline wxDateTime wxDateTime::GetLastWeekDay(WeekDay weekday, + Month month, + int year) { wxDateTime dt(*this); return dt.SetToLastWeekDay(weekday, month, year) ? dt : wxInvalidDateTime; } -wxDateTime wxDateTime::GetWeek(wxDateTime_t numWeek, WeekDay weekday) const +inline wxDateTime wxDateTime::GetWeek(wxDateTime_t numWeek, + WeekDay weekday) const { wxDateTime dt(*this); return dt.SetToTheWeek(numWeek, weekday) ? dt : wxInvalidDateTime; } -wxDateTime wxDateTime::GetLastMonthDay(Month month, int year) const +inline wxDateTime wxDateTime::GetLastMonthDay(Month month, int year) const { MODIFY_AND_RETURN( SetToLastMonthDay(month, year) ); } -wxDateTime wxDateTime::GetYearDay(wxDateTime_t yday) const +inline wxDateTime wxDateTime::GetYearDay(wxDateTime_t yday) const { MODIFY_AND_RETURN( SetToYearDay(yday) ); } @@ -211,46 +212,47 @@ wxDateTime wxDateTime::GetYearDay(wxDateTime_t yday) const // wxDateTime comparison // ---------------------------------------------------------------------------- -bool wxDateTime::IsEqualTo(const wxDateTime& datetime) const +inline bool wxDateTime::IsEqualTo(const wxDateTime& datetime) const { wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime")); return m_time == datetime.m_time; } -bool wxDateTime::IsEarlierThan(const wxDateTime& datetime) const +inline bool wxDateTime::IsEarlierThan(const wxDateTime& datetime) const { wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime")); return m_time < datetime.m_time; } -bool wxDateTime::IsLaterThan(const wxDateTime& datetime) const +inline bool wxDateTime::IsLaterThan(const wxDateTime& datetime) const { wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime")); return m_time > datetime.m_time; } -bool wxDateTime::IsStrictlyBetween(const wxDateTime& t1, - const wxDateTime& t2) const +inline bool wxDateTime::IsStrictlyBetween(const wxDateTime& t1, + const wxDateTime& t2) const { // no need for assert, will be checked by the functions we call return IsLaterThan(t1) && IsEarlierThan(t2); } -bool wxDateTime::IsBetween(const wxDateTime& t1, const wxDateTime& t2) const +inline bool wxDateTime::IsBetween(const wxDateTime& t1, + const wxDateTime& t2) const { // no need for assert, will be checked by the functions we call return IsEqualTo(t1) || IsEqualTo(t2) || IsStrictlyBetween(t1, t2); } -bool wxDateTime::IsSameDate(const wxDateTime& dt) const +inline bool wxDateTime::IsSameDate(const wxDateTime& dt) const { return (m_time - dt.m_time).Abs() < MILLISECONDS_PER_DAY; } -bool wxDateTime::IsSameTime(const wxDateTime& dt) const +inline bool wxDateTime::IsSameTime(const wxDateTime& dt) const { // notice that we can't do something like this: // @@ -266,7 +268,8 @@ bool wxDateTime::IsSameTime(const wxDateTime& dt) const tm1.msec == tm2.msec; } -bool wxDateTime::IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const +inline bool wxDateTime::IsEqualUpTo(const wxDateTime& dt, + const wxTimeSpan& ts) const { return IsBetween(dt.Substract(ts), dt.Add(ts)); } @@ -275,14 +278,14 @@ bool wxDateTime::IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const // wxDateTime arithmetics // ---------------------------------------------------------------------------- -wxDateTime wxDateTime::Add(const wxTimeSpan& diff) const +inline wxDateTime wxDateTime::Add(const wxTimeSpan& diff) const { wxASSERT_MSG( IsValid(), _T("invalid wxDateTime")); return wxDateTime(m_time + diff.GetValue()); } -wxDateTime& wxDateTime::Add(const wxTimeSpan& diff) +inline wxDateTime& wxDateTime::Add(const wxTimeSpan& diff) { wxASSERT_MSG( IsValid(), _T("invalid wxDateTime")); @@ -291,19 +294,19 @@ wxDateTime& wxDateTime::Add(const wxTimeSpan& diff) return *this; } -wxDateTime& wxDateTime::operator+=(const wxTimeSpan& diff) +inline wxDateTime& wxDateTime::operator+=(const wxTimeSpan& diff) { return Add(diff); } -wxDateTime wxDateTime::Substract(const wxTimeSpan& diff) const +inline wxDateTime wxDateTime::Substract(const wxTimeSpan& diff) const { wxASSERT_MSG( IsValid(), _T("invalid wxDateTime")); return wxDateTime(m_time - diff.GetValue()); } -wxDateTime& wxDateTime::Substract(const wxTimeSpan& diff) +inline wxDateTime& wxDateTime::Substract(const wxTimeSpan& diff) { wxASSERT_MSG( IsValid(), _T("invalid wxDateTime")); @@ -312,39 +315,39 @@ wxDateTime& wxDateTime::Substract(const wxTimeSpan& diff) return *this; } -wxDateTime& wxDateTime::operator-=(const wxTimeSpan& diff) +inline wxDateTime& wxDateTime::operator-=(const wxTimeSpan& diff) { return Substract(diff); } -wxTimeSpan wxDateTime::Substract(const wxDateTime& datetime) const +inline wxTimeSpan wxDateTime::Substract(const wxDateTime& datetime) const { wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime")); return wxTimeSpan(datetime.GetValue() - GetValue()); } -wxDateTime wxDateTime::Add(const wxDateSpan& diff) const +inline wxDateTime wxDateTime::Add(const wxDateSpan& diff) const { return wxDateTime(*this).Add(diff); } -wxDateTime& wxDateTime::Substract(const wxDateSpan& diff) +inline wxDateTime& wxDateTime::Substract(const wxDateSpan& diff) { return Add(diff.Negate()); } -wxDateTime wxDateTime::Substract(const wxDateSpan& diff) const +inline wxDateTime wxDateTime::Substract(const wxDateSpan& diff) const { return wxDateTime(*this).Substract(diff); } -wxDateTime& wxDateTime::operator-=(const wxDateSpan& diff) +inline wxDateTime& wxDateTime::operator-=(const wxDateSpan& diff) { return Substract(diff); } -wxDateTime& wxDateTime::operator+=(const wxDateSpan& diff) +inline wxDateTime& wxDateTime::operator+=(const wxDateSpan& diff) { return Add(diff); } @@ -353,8 +356,8 @@ wxDateTime& wxDateTime::operator+=(const wxDateSpan& diff) // wxDateTime and timezones // ---------------------------------------------------------------------------- -wxDateTime wxDateTime::ToTimezone(const wxDateTime::TimeZone& tz, - bool noDST) const +inline wxDateTime wxDateTime::ToTimezone(const wxDateTime::TimeZone& tz, + bool noDST) const { MODIFY_AND_RETURN( MakeTimezone(tz, noDST) ); } @@ -363,7 +366,10 @@ wxDateTime wxDateTime::ToTimezone(const wxDateTime::TimeZone& tz, // wxTimeSpan construction // ---------------------------------------------------------------------------- -wxTimeSpan::wxTimeSpan(long hours, long minutes, long seconds, long milliseconds) +inline wxTimeSpan::wxTimeSpan(long hours, + long minutes, + long seconds, + long milliseconds) { // assign first to avoid precision loss m_diff = hours; @@ -379,27 +385,27 @@ wxTimeSpan::wxTimeSpan(long hours, long minutes, long seconds, long milliseconds // wxTimeSpan accessors // ---------------------------------------------------------------------------- -wxLongLong wxTimeSpan::GetSeconds() const +inline wxLongLong wxTimeSpan::GetSeconds() const { return m_diff / 1000l; } -int wxTimeSpan::GetMinutes() const +inline int wxTimeSpan::GetMinutes() const { return (GetSeconds() / 60l).GetLo(); } -int wxTimeSpan::GetHours() const +inline int wxTimeSpan::GetHours() const { return GetMinutes() / 60; } -int wxTimeSpan::GetDays() const +inline int wxTimeSpan::GetDays() const { return GetHours() / 24; } -int wxTimeSpan::GetWeeks() const +inline int wxTimeSpan::GetWeeks() const { return GetDays() / 7; } @@ -408,53 +414,53 @@ int wxTimeSpan::GetWeeks() const // wxTimeSpan arithmetics // ---------------------------------------------------------------------------- -wxTimeSpan wxTimeSpan::Add(const wxTimeSpan& diff) const +inline wxTimeSpan wxTimeSpan::Add(const wxTimeSpan& diff) const { return wxTimeSpan(m_diff + diff.GetValue()); } -wxTimeSpan& wxTimeSpan::Add(const wxTimeSpan& diff) +inline wxTimeSpan& wxTimeSpan::Add(const wxTimeSpan& diff) { m_diff += diff.GetValue(); return *this; } -wxTimeSpan wxTimeSpan::Substract(const wxTimeSpan& diff) const +inline wxTimeSpan wxTimeSpan::Substract(const wxTimeSpan& diff) const { return wxTimeSpan(m_diff - diff.GetValue()); } -wxTimeSpan& wxTimeSpan::Substract(const wxTimeSpan& diff) +inline wxTimeSpan& wxTimeSpan::Substract(const wxTimeSpan& diff) { m_diff -= diff.GetValue(); return *this; } -wxTimeSpan& wxTimeSpan::Multiply(int n) +inline wxTimeSpan& wxTimeSpan::Multiply(int n) { m_diff *= (long)n; return *this; } -wxTimeSpan wxTimeSpan::Multiply(int n) const +inline wxTimeSpan wxTimeSpan::Multiply(int n) const { return wxTimeSpan(m_diff * (long)n); } -wxTimeSpan wxTimeSpan::Abs() const +inline wxTimeSpan wxTimeSpan::Abs() const { return wxTimeSpan(GetValue().Abs()); } -bool wxTimeSpan::IsEqualTo(const wxTimeSpan& ts) const +inline bool wxTimeSpan::IsEqualTo(const wxTimeSpan& ts) const { return GetValue() == ts.GetValue(); } -bool wxTimeSpan::IsLongerThan(const wxTimeSpan& ts) const +inline bool wxTimeSpan::IsLongerThan(const wxTimeSpan& ts) const { return GetValue().Abs() > ts.GetValue().Abs(); } @@ -463,8 +469,7 @@ bool wxTimeSpan::IsLongerThan(const wxTimeSpan& ts) const // wxDateSpan // ---------------------------------------------------------------------------- -wxDateSpan& -wxDateSpan::operator+=(const wxDateSpan& other) +inline wxDateSpan& wxDateSpan::operator+=(const wxDateSpan& other) { m_years += other.m_years; m_months += other.m_months; @@ -474,7 +479,7 @@ wxDateSpan::operator+=(const wxDateSpan& other) return *this; } -wxDateSpan& wxDateSpan::Multiply(int factor) +inline wxDateSpan& wxDateSpan::Multiply(int factor) { m_years *= factor; m_months *= factor; @@ -484,17 +489,17 @@ wxDateSpan& wxDateSpan::Multiply(int factor) return *this; } -wxDateSpan wxDateSpan::Multiply(int factor) const +inline wxDateSpan wxDateSpan::Multiply(int factor) const { return wxDateSpan(*this).Multiply(factor); } -wxDateSpan wxDateSpan::Negate() const +inline wxDateSpan wxDateSpan::Negate() const { return wxDateSpan(-m_years, -m_months, -m_weeks, -m_days); } -wxDateSpan& wxDateSpan::Neg() +inline wxDateSpan& wxDateSpan::Neg() { m_years = -m_years; m_months = -m_months; diff --git a/include/wx/fileconf.h b/include/wx/fileconf.h index 779dc8d4fa..1e41185d89 100644 --- a/include/wx/fileconf.h +++ b/include/wx/fileconf.h @@ -121,7 +121,7 @@ private: *m_pPrev; // previous one }; -class wxFileConfig : public wxConfigBase +class WXDLLEXPORT wxFileConfig : public wxConfigBase { public: // construct the "standard" full name for global (system-wide) and diff --git a/include/wx/hash.h b/include/wx/hash.h index cf10d040c8..af9cbbce94 100644 --- a/include/wx/hash.h +++ b/include/wx/hash.h @@ -200,8 +200,8 @@ private: // defines a new type safe hash table which stores the elements of type eltype // in lists of class listclass -#define WX_DECLARE_HASH(eltype, listclass, hashclass) \ - class WXDLLEXPORT hashclass : public wxHashTableBase \ +#define _WX_DECLARE_HASH(eltype, listclass, hashclass, classexp) \ + classexp hashclass : public wxHashTableBase \ { \ public: \ hashclass(wxKeyType keyType = wxKEY_INTEGER, \ @@ -258,5 +258,14 @@ private: } \ } +// this macro is to be used in the user code +#define WX_DECLARE_HASH(el, list, hash) \ + _WX_DECLARE_HASH(el, list, hash, class) + +// and this one does exactly the same thing but should be used inside the +// library +#define WX_DECLARE_EXPORTED_HASH(el, list, hash) \ + _WX_DECLARE_HASH(el, list, hash, class WXDLLEXPORT) + #endif // _WX_HASH_H__ diff --git a/include/wx/list.h b/include/wx/list.h index ff710bd22c..8c76d9b5c5 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -353,10 +353,10 @@ private: // wxWindowBase pointers are put into the list, but wxWindow pointers are // retrieved from it. -#define WX_DECLARE_LIST_3(T, Tbase, name, nodetype) \ +#define WX_DECLARE_LIST_3(T, Tbase, name, nodetype, classexp) \ typedef int (*wxSortFuncFor_##name)(const T **, const T **); \ \ - class WXDLLEXPORT nodetype : public wxNodeBase \ + classexp nodetype : public wxNodeBase \ { \ public: \ nodetype(wxListBase *list = (wxListBase *)NULL, \ @@ -379,7 +379,7 @@ private: virtual void DeleteData(); \ }; \ \ - class WXDLLEXPORT name : public wxListBase \ + classexp name : public wxListBase \ { \ public: \ typedef nodetype Node; \ @@ -447,12 +447,16 @@ private: } \ } -#define WX_DECLARE_LIST_2(elementtype, listname, nodename) \ - WX_DECLARE_LIST_3(elementtype, elementtype, listname, nodename) +#define WX_DECLARE_LIST_2(elementtype, listname, nodename, classexp) \ + WX_DECLARE_LIST_3(elementtype, elementtype, listname, nodename, classexp) #define WX_DECLARE_LIST(elementtype, listname) \ typedef elementtype _WX_LIST_ITEM_TYPE_##listname; \ - WX_DECLARE_LIST_2(elementtype, listname, wx##listname##Node) + WX_DECLARE_LIST_2(elementtype, listname, wx##listname##Node, class) + +#define WX_DECLARE_EXPORTED_LIST(elementtype, listname) \ + typedef elementtype _WX_LIST_ITEM_TYPE_##listname; \ + WX_DECLARE_LIST_2(elementtype, listname, wx##listname##Node, class WXDLLEXPORT) // this macro must be inserted in your program after // #include @@ -472,7 +476,7 @@ private: // wxList compatibility class: in fact, it's a list of wxObjects // ----------------------------------------------------------------------------- -WX_DECLARE_LIST_2(wxObject, wxObjectList, wxObjectListNode); +WX_DECLARE_LIST_2(wxObject, wxObjectList, wxObjectListNode, class WXDLLEXPORT); class WXDLLEXPORT wxList : public wxObjectList { @@ -489,7 +493,7 @@ public: // wxStringList class for compatibility with the old code // ----------------------------------------------------------------------------- -WX_DECLARE_LIST_2(wxChar, wxStringListBase, wxStringListNode); +WX_DECLARE_LIST_2(wxChar, wxStringListBase, wxStringListNode, class WXDLLEXPORT); class WXDLLEXPORT wxStringList : public wxStringListBase { diff --git a/include/wx/listimpl.cpp b/include/wx/listimpl.cpp index d7ef44dded..5e5214b75d 100644 --- a/include/wx/listimpl.cpp +++ b/include/wx/listimpl.cpp @@ -9,10 +9,10 @@ // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// -#define _DEFINE_LIST(T, name) \ - void wx##name##Node::DeleteData() \ - { \ - delete (T *)GetData(); \ +#define _DEFINE_LIST(T, name) \ + inline void wx##name##Node::DeleteData() \ + { \ + delete (T *)GetData(); \ } // redefine the macro so that now it will generate the class implementation diff --git a/include/wx/menu.h b/include/wx/menu.h index c297b599a6..9d81fea56f 100644 --- a/include/wx/menu.h +++ b/include/wx/menu.h @@ -32,8 +32,8 @@ class WXDLLEXPORT wxMenuBar; class WXDLLEXPORT wxMenuItem; // pseudo template list classes -WX_DECLARE_LIST(wxMenu, wxMenuList); -WX_DECLARE_LIST(wxMenuItem, wxMenuItemList); +WX_DECLARE_EXPORTED_LIST(wxMenu, wxMenuList); +WX_DECLARE_EXPORTED_LIST(wxMenuItem, wxMenuItemList); // ---------------------------------------------------------------------------- // conditional compilation diff --git a/include/wx/module.h b/include/wx/module.h index e15b4de06b..73e913ee1b 100644 --- a/include/wx/module.h +++ b/include/wx/module.h @@ -21,7 +21,7 @@ // declare a linked list of modules class wxModule; -WX_DECLARE_LIST(wxModule, wxModuleList); +WX_DECLARE_EXPORTED_LIST(wxModule, wxModuleList); // declaring a class derived from wxModule will automatically create an // instance of this class on program startup, call its OnInit() method and call diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index 2a27a0287d..127e2b52fd 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -216,6 +216,8 @@ extern LONG APIENTRY _EXPORT #define wxZeroMemory(obj) memset((void*) & obj, 0, sizeof(obj)) #endif +#if wxUSE_GUI + #include // make conversion from wxColour and COLORREF a bit less painful @@ -314,15 +316,12 @@ private: #define GetHcursor() ((HCURSOR)GetHCURSOR()) #define GetHcursorOf(cursor) ((HCURSOR)(cursor).GetHCURSOR()) +#endif // wxUSE_GUI + // --------------------------------------------------------------------------- // global data // --------------------------------------------------------------------------- -#if 0 // where is this?? -// The MakeProcInstance version of the function wxSubclassedGenericControlProc -WXDLLEXPORT_DATA(extern FARPROC) wxGenericControlSubClassProc; -#endif // 0 - WXDLLEXPORT_DATA(extern wxChar*) wxBuffer; WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance; diff --git a/include/wx/string.h b/include/wx/string.h index 1b0c138ea9..afa16e879b 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -205,6 +205,12 @@ struct WXDLLEXPORT wxStringData // lock/unlock void Lock() { if ( !IsEmpty() ) nRefs++; } + + // VC++ will refuse to inline this function but profiling shows that it + // is wrong +#if defined(__VISUALC__) && defined(__WIN32__) + __forceinline +#endif void Unlock() { if ( !IsEmpty() && --nRefs == 0) free(this); } // if we had taken control over string memory (GetWriteBuf), it's diff --git a/include/wx/tbarbase.h b/include/wx/tbarbase.h index e75206df99..863264c290 100644 --- a/include/wx/tbarbase.h +++ b/include/wx/tbarbase.h @@ -206,7 +206,7 @@ protected: }; // a list of toolbar tools -WX_DECLARE_LIST(wxToolBarToolBase, wxToolBarToolsList); +WX_DECLARE_EXPORTED_LIST(wxToolBarToolBase, wxToolBarToolsList); // ---------------------------------------------------------------------------- // the base class for all toolbars diff --git a/include/wx/window.h b/include/wx/window.h index 3a1e9362bb..3410f7d3b5 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -58,7 +58,7 @@ class WXDLLEXPORT wxWindow; // (pseudo)template list classes // ---------------------------------------------------------------------------- -WX_DECLARE_LIST_3(wxWindow, wxWindowBase, wxWindowList, wxWindowListNode); +WX_DECLARE_LIST_3(wxWindow, wxWindowBase, wxWindowList, wxWindowListNode, class WXDLLEXPORT); // ---------------------------------------------------------------------------- // global variables diff --git a/src/common/config.cpp b/src/common/config.cpp index 018b9e01df..40bad1ecc5 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -59,15 +59,22 @@ bool wxConfigBase::ms_bAutoCreate = TRUE; // wxConfigBase // ---------------------------------------------------------------------------- -// Not all args will always be used by derived classes, but -// including them all in each class ensures compatibility. -wxConfigBase::wxConfigBase(const wxString& appName, const wxString& vendorName, - const wxString& WXUNUSED(localFilename), const wxString& WXUNUSED(globalFilename), long style): - m_appName(appName), m_vendorName(vendorName), m_style(style) +// Not all args will always be used by derived classes, but including them all +// in each class ensures compatibility. +wxConfigBase::wxConfigBase(const wxString& appName, + const wxString& vendorName, + const wxString& WXUNUSED(localFilename), + const wxString& WXUNUSED(globalFilename), + long style) + : m_appName(appName), m_vendorName(vendorName), m_style(style) { m_bExpandEnvVars = TRUE; m_bRecordDefaults = FALSE; } +wxConfigBase::~wxConfigBase() +{ +} + wxConfigBase *wxConfigBase::Set(wxConfigBase *pConfig) { wxConfigBase *pOld = ms_pConfig; @@ -130,8 +137,8 @@ bool wxConfigBase::Read(const wxString& key, double* val) const *val = wxAtof(str); return TRUE; } - else - return FALSE; + + return FALSE; } bool wxConfigBase::Read(const wxString& key, double* val, double defVal) const @@ -400,7 +407,7 @@ void wxSplitPath(wxArrayString& aParts, const wxChar *sz) // could log an error here, but we prefer to ignore extra '/' if ( *pc == wxT('\0') ) - return; + break; } else strCurrent += *pc; diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 61ac755d79..62a62f7119 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -3446,7 +3446,7 @@ wxString wxTimeSpan::Format(const wxChar *format) const #include "wx/arrimpl.cpp" -WX_DEFINE_OBJARRAY(wxDateTimeArray) +WX_DEFINE_OBJARRAY(wxDateTimeArray); static int wxCMPFUNC_CONV wxDateTimeCompareFunc(wxDateTime **first, wxDateTime **second) diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index d9ab373bdb..83948f0d41 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -684,10 +684,9 @@ bool wxFileConfig::Read(const wxString& key, if (pEntry == NULL) { return FALSE; } - else { - *pStr = ExpandEnvVars(pEntry->Value()); - return TRUE; - } + + *pStr = ExpandEnvVars(pEntry->Value()); + return TRUE; } bool wxFileConfig::Read(const wxString& key, @@ -696,28 +695,31 @@ bool wxFileConfig::Read(const wxString& key, wxConfigPathChanger path(this, key); ConfigEntry *pEntry = m_pCurrentGroup->FindEntry(path.Name()); + bool ok; if (pEntry == NULL) { if( IsRecordingDefaults() ) ((wxFileConfig *)this)->Write(key,defVal); *pStr = ExpandEnvVars(defVal); - return FALSE; + ok = FALSE; } else { *pStr = ExpandEnvVars(pEntry->Value()); - return TRUE; + ok = TRUE; } + + return ok; } bool wxFileConfig::Read(const wxString& key, long *pl) const { wxString str; - if ( Read(key, & str) ) { - *pl = wxAtol(str); - return TRUE; - } - else { + if ( !Read(key, & str) ) + { return FALSE; } + + *pl = wxAtol(str); + return TRUE; } bool wxFileConfig::Write(const wxString& key, const wxString& szValue) diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 2a1694b0a7..5ed7a5d275 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -570,7 +570,7 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name) /* prefix ~ */ if (nm[1] == SEP || nm[1] == 0) { /* ~/filename */ - // FIXME: wxGetUserHome could return temporary storage in Unicode mode + // FIXME: wxGetUserHome could return temporary storage in Unicode mode if ((s = WXSTRINGCAST wxGetUserHome(wxT(""))) != NULL) { if (*++nm) nm++; @@ -584,7 +584,7 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name) was_sep = (*s == SEP); nnm = *s ? s + 1 : s; *s = 0; - // FIXME: wxGetUserHome could return temporary storage in Unicode mode + // FIXME: wxGetUserHome could return temporary storage in Unicode mode if ((home = WXSTRINGCAST wxGetUserHome(wxString(nm + 1))) == NULL) { if (was_sep) /* replace only if it was there: */ *s = SEP; @@ -836,8 +836,8 @@ static char sMacFileNameConversion[ 1000 ] ; wxString wxMac2UnixFilename (const char *str) { - char *s = sMacFileNameConversion ; - strcpy( s , str ) ; + char *s = sMacFileNameConversion ; + strcpy( s , str ) ; if (s) { memmove( s+1 , s ,strlen( s ) + 1) ; @@ -860,8 +860,8 @@ wxString wxMac2UnixFilename (const char *str) wxString wxUnix2MacFilename (const char *str) { - char *s = sMacFileNameConversion ; - strcpy( s , str ) ; + char *s = sMacFileNameConversion ; + strcpy( s , str ) ; if (s) { if ( *s == '.' ) @@ -882,13 +882,13 @@ wxString wxUnix2MacFilename (const char *str) { if (*s == '/' || *s == '\\') { - // convert any back-directory situations - if ( *(s+1) == '.' && *(s+2) == '.' && ( (*(s+3) == '/' || *(s+3) == '\\') ) ) - { + // convert any back-directory situations + if ( *(s+1) == '.' && *(s+2) == '.' && ( (*(s+3) == '/' || *(s+3) == '\\') ) ) + { *s = ':'; - memmove( s+1 , s+3 ,strlen( s+3 ) + 1 ) ; - } - else + memmove( s+1 , s+3 ,strlen( s+3 ) + 1 ) ; + } + else *s = ':'; } @@ -900,36 +900,36 @@ wxString wxUnix2MacFilename (const char *str) wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) { - Handle myPath ; - short length ; - - FSpGetFullPath( spec , &length , &myPath ) ; - ::SetHandleSize( myPath , length + 1 ) ; - ::HLock( myPath ) ; - (*myPath)[length] = 0 ; - if ( length > 0 && (*myPath)[length-1] ==':' ) - (*myPath)[length-1] = 0 ; - - wxString result( (char*) *myPath ) ; - ::HUnlock( myPath ) ; - ::DisposeHandle( myPath ) ; - return result ; + Handle myPath ; + short length ; + + FSpGetFullPath( spec , &length , &myPath ) ; + ::SetHandleSize( myPath , length + 1 ) ; + ::HLock( myPath ) ; + (*myPath)[length] = 0 ; + if ( length > 0 && (*myPath)[length-1] ==':' ) + (*myPath)[length-1] = 0 ; + + wxString result( (char*) *myPath ) ; + ::HUnlock( myPath ) ; + ::DisposeHandle( myPath ) ; + return result ; } wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) { - return wxMac2UnixFilename( wxMacFSSpec2MacFilename( spec) ) ; + return wxMac2UnixFilename( wxMacFSSpec2MacFilename( spec) ) ; } void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) { - FSpLocationFromFullPath( strlen(path ) , path , spec ) ; + FSpLocationFromFullPath( strlen(path ) , path , spec ) ; } void wxUnixFilename2FSSpec( const char *path , FSSpec *spec ) { - wxString var = wxUnix2MacFilename( path ) ; - wxMacFilename2FSSpec( var , spec ) ; + wxString var = wxUnix2MacFilename( path ) ; + wxMacFilename2FSSpec( var , spec ) ; } #endif @@ -1311,8 +1311,8 @@ wxString wxFindNextFile() nextDir = readdir(gs_dirStream) ) { if (wxMatchWild(name, nextDir->d_name, FALSE) && // RR: added FALSE to find hidden files - strcmp(nextDir->d_name, ".") && - strcmp(nextDir->d_name, "..") ) + strcmp(nextDir->d_name, ".") && + strcmp(nextDir->d_name, "..") ) { result.Empty(); if ( !path.IsEmpty() ) @@ -1360,10 +1360,10 @@ wxString wxFindNextFile() struct MacDirectoryIterator { - CInfoPBRec m_CPB ; - wxInt16 m_index ; - long m_dirId ; - Str255 m_name ; + CInfoPBRec m_CPB ; + wxInt16 m_index ; + long m_dirId ; + Str255 m_name ; } ; static int g_iter_flags ; @@ -1381,57 +1381,57 @@ wxString wxFindFirstFile(const wxChar *spec, int flags) if ( !path.IsEmpty() ) result << path << wxT('\\'); - FSSpec fsspec ; + FSSpec fsspec ; - wxUnixFilename2FSSpec( result , &fsspec ) ; - g_iter.m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ; - g_iter.m_CPB.hFileInfo.ioNamePtr = g_iter.m_name ; - g_iter.m_index = 0 ; - - Boolean isDir ; - FSpGetDirectoryID( &fsspec , &g_iter.m_dirId , &isDir ) ; - if ( !isDir ) - return wxEmptyString ; - - return wxFindNextFile( ) ; + wxUnixFilename2FSSpec( result , &fsspec ) ; + g_iter.m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ; + g_iter.m_CPB.hFileInfo.ioNamePtr = g_iter.m_name ; + g_iter.m_index = 0 ; + + Boolean isDir ; + FSpGetDirectoryID( &fsspec , &g_iter.m_dirId , &isDir ) ; + if ( !isDir ) + return wxEmptyString ; + + return wxFindNextFile( ) ; } wxString wxFindNextFile() { wxString result; - short err = noErr ; - - while ( err == noErr ) - { - g_iter.m_index++ ; - g_iter.m_CPB.dirInfo.ioFDirIndex = g_iter.m_index; - g_iter.m_CPB.dirInfo.ioDrDirID = g_iter.m_dirId; /* we need to do this every time */ - err = PBGetCatInfoSync((CInfoPBPtr)&g_iter.m_CPB); - if ( err != noErr ) - break ; - - if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (g_iter_flags & wxDIR) ) // we have a directory - break ; - - if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(g_iter_flags & wxFILE ) ) - continue ; - - // hit ! - break ; - } - if ( err != noErr ) - { - return wxEmptyString ; - } - FSSpec spec ; - - FSMakeFSSpecCompat(g_iter.m_CPB.hFileInfo.ioVRefNum, - g_iter.m_dirId, - g_iter.m_name, - &spec) ; - - return wxMacFSSpec2UnixFilename( &spec ) ; + short err = noErr ; + + while ( err == noErr ) + { + g_iter.m_index++ ; + g_iter.m_CPB.dirInfo.ioFDirIndex = g_iter.m_index; + g_iter.m_CPB.dirInfo.ioDrDirID = g_iter.m_dirId; /* we need to do this every time */ + err = PBGetCatInfoSync((CInfoPBPtr)&g_iter.m_CPB); + if ( err != noErr ) + break ; + + if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (g_iter_flags & wxDIR) ) // we have a directory + break ; + + if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(g_iter_flags & wxFILE ) ) + continue ; + + // hit ! + break ; + } + if ( err != noErr ) + { + return wxEmptyString ; + } + FSSpec spec ; + + FSMakeFSSpecCompat(g_iter.m_CPB.hFileInfo.ioVRefNum, + g_iter.m_dirId, + g_iter.m_name, + &spec) ; + + return wxMacFSSpec2UnixFilename( &spec ) ; } #elif defined(__WXMSW__) @@ -1485,9 +1485,9 @@ wxString wxFindFirstFile(const wxChar *spec, int flags) result += gs_findDataStruct.cFileName; return result; -#else +#else // !Win32 int flag = _A_NORMAL; - if (flags & wxDIR) /* MATTHEW: [5] Use & */ + if (flags & wxDIR) flag = _A_SUBDIR; #ifdef __BORLANDC__ @@ -1496,7 +1496,6 @@ wxString wxFindFirstFile(const wxChar *spec, int flags) if (_dos_findfirst(WXSTRINGCAST spec, flag, &gs_findDataStruct) == 0) #endif { - /* MATTHEW: [5] Check directory flag */ char attrib; #ifdef __BORLANDC__ @@ -1519,9 +1518,9 @@ wxString wxFindFirstFile(const wxChar *spec, int flags) #endif ; } -#endif // __WIN32__ return result; +#endif // __WIN32__ } @@ -1591,9 +1590,9 @@ try_again: #endif ; } -#endif // Win32/16 return result; +#endif // Win32/16 } #elif defined(__WXPM__) @@ -1654,16 +1653,16 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) #ifdef _MSC_VER if (_getcwd(cbuf, sz) == NULL) { #elif defined( __WXMAC__) - enum - { - SFSaveDisk = 0x214, CurDirStore = 0x398 - }; - FSSpec cwdSpec ; - - FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ; - wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ; - strcpy( buf , res ) ; - if (0) { + enum + { + SFSaveDisk = 0x214, CurDirStore = 0x398 + }; + FSSpec cwdSpec ; + + FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ; + wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ; + strcpy( buf , res ) ; + if (0) { #else if (getcwd(cbuf, sz) == NULL) { #endif @@ -1672,16 +1671,16 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) #ifdef _MSC_VER if (_getcwd(buf, sz) == NULL) { #elif defined( __WXMAC__) - enum - { - SFSaveDisk = 0x214, CurDirStore = 0x398 - }; - FSSpec cwdSpec ; - - FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ; - wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ; - strcpy( buf , res ) ; - if (0) { + enum + { + SFSaveDisk = 0x214, CurDirStore = 0x398 + }; + FSSpec cwdSpec ; + + FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ; + wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ; + strcpy( buf , res ) ; + if (0) { #else if (getcwd(buf, sz) == NULL) { #endif @@ -1771,7 +1770,7 @@ bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFi { // we assume that it's not empty wxCHECK_MSG( !wxIsEmpty(pszFile), FALSE, - _("empty file name in wxFindFileInPath")); + _T("empty file name in wxFindFileInPath")); // skip path separator in the beginning of the file name if present if ( wxIsPathSeparator(*pszFile) ) @@ -1868,8 +1867,6 @@ void WXDLLEXPORT wxSplitPath(const wxChar *pszFileName, } } - - time_t WXDLLEXPORT wxFileModificationTime(const wxString& filename) { struct stat buf; diff --git a/src/common/init.cpp b/src/common/init.cpp index 70c9dafcdb..390dced3de 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -35,7 +35,7 @@ // global vars // ---------------------------------------------------------------------------- -wxApp * WXDLLEXPORT wxTheApp = NULL; +WXDLLEXPORT wxApp *wxTheApp = NULL; wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction)NULL; diff --git a/src/common/sckipc.cpp b/src/common/sckipc.cpp index b116b7f1f1..29662ab789 100644 --- a/src/common/sckipc.cpp +++ b/src/common/sckipc.cpp @@ -220,22 +220,20 @@ bool wxTCPServer::Create(const wxString& serverName) // Create a socket listening on the specified port m_server = new wxSocketServer(addr, SCKIPC_FLAGS); - if (m_server->Ok()) - { - m_server->SetEventHandler(*gs_handler, _SERVER_ONREQUEST_ID); - m_server->SetClientData(this); - m_server->SetNotify(wxSOCKET_CONNECTION_FLAG); - m_server->Notify(TRUE); - - return TRUE; - } - else + if (!m_server->Ok()) { m_server->Destroy(); m_server = NULL; return FALSE; } + + m_server->SetEventHandler(*gs_handler, _SERVER_ONREQUEST_ID); + m_server->SetClientData(this); + m_server->SetNotify(wxSOCKET_CONNECTION_FLAG); + m_server->Notify(TRUE); + + return TRUE; } wxTCPServer::~wxTCPServer() diff --git a/src/common/variant.cpp b/src/common/variant.cpp index f753638730..531c8df511 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -1352,8 +1352,8 @@ bool wxVariant::operator== (const wxString& value) const wxString thisValue; if (!Convert(&thisValue)) return FALSE; - else - return (value == thisValue); + + return value == thisValue; } bool wxVariant::operator!= (const wxString& value) const @@ -1450,8 +1450,8 @@ bool wxVariant::operator== (const wxTime& value) const wxTime thisValue; if (!Convert(&thisValue)) return FALSE; - else - return (value == thisValue); + + return value == thisValue; } bool wxVariant::operator!= (const wxTime& value) const @@ -1478,8 +1478,8 @@ bool wxVariant::operator== (const wxDate& value) const wxDate thisValue; if (!Convert(&thisValue)) return FALSE; - else - return (value == thisValue); + + return (value == thisValue); } bool wxVariant::operator!= (const wxDate& value) const @@ -1668,13 +1668,12 @@ bool wxVariant::GetBool() const wxString wxVariant::GetString() const { wxString value; - if (Convert(& value)) - return value; - else + if (!Convert(& value)) { wxFAIL_MSG(wxT("Could not convert to a string")); - return wxString(""); } + + return value; } // For some reason, Watcom C++ can't link variant.cpp with time/date classes compiled @@ -1682,27 +1681,25 @@ wxString wxVariant::GetString() const wxTime wxVariant::GetTime() const { wxTime value; - if (Convert(& value)) - return value; - else + if (!Convert(& value)) { wxFAIL_MSG(wxT("Could not convert to a time")); - return wxTime(); } + + return value; } wxDate wxVariant::GetDate() const { wxDate value; - if (Convert(& value)) - return value; - else + if (!Convert(& value)) { wxFAIL_MSG(wxT("Could not convert to a date")); - return wxDate(); } + + return value; } -#endif +#endif // wxUSE_TIMEDATE void* wxVariant::GetVoidPtr() const { diff --git a/src/msw/mimetype.cpp b/src/msw/mimetype.cpp index e78a77cac0..a4e3d9d8a1 100644 --- a/src/msw/mimetype.cpp +++ b/src/msw/mimetype.cpp @@ -227,27 +227,23 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const // suppress possible error messages wxLogNull nolog; wxRegKey key(wxRegKey::HKCR, wxT(".") + m_ext); - if ( key.Open() && key.QueryValue(wxT("Content Type"), *mimeType) ) { - return TRUE; - } - else { - return FALSE; - } + + return key.Open() && key.QueryValue(wxT("Content Type"), *mimeType); } bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const { wxString s; - - if (GetMimeType(&s)) + + if ( !GetMimeType(&s) ) { - mimeTypes.Clear(); - mimeTypes.Add(s); - return TRUE; - } - else return FALSE; + } + + mimeTypes.Clear(); + mimeTypes.Add(s); + return TRUE; } @@ -378,18 +374,16 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext) } } - if ( knownExtension ) - { - wxFileType *fileType = new wxFileType; - fileType->m_impl->Init(wxEmptyString, ext); - - return fileType; - } - else + if ( !knownExtension ) { // unknown extension return NULL; } + + wxFileType *fileType = new wxFileType; + fileType->m_impl->Init(wxEmptyString, ext); + + return fileType; } // MIME type -> extension -> file type diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index 50da59b181..06e9b3e976 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -709,12 +709,11 @@ bool wxRegKey::HasValue(const wxChar *szValue) const wxLogNull nolog; #ifdef __WIN32__ - if ( CONST_CAST Open() ) { - return RegQueryValueEx((HKEY) m_hKey, WXSTRINGCAST szValue, RESERVED, - NULL, NULL, NULL) == ERROR_SUCCESS; - } - else - return FALSE; + if ( !CONST_CAST Open() ) + return FALSE; + + return RegQueryValueEx((HKEY) m_hKey, WXSTRINGCAST szValue, RESERVED, + NULL, NULL, NULL) == ERROR_SUCCESS; #else // WIN16 // only unnamed value exists return IsEmpty(szValue); @@ -751,10 +750,10 @@ bool wxRegKey::HasSubKey(const wxChar *szKey) const // this function should be silent, so suppress possible messages from Open() wxLogNull nolog; - if ( CONST_CAST Open() ) - return KeyExists(m_hKey, szKey); - else + if ( !CONST_CAST Open() ) return FALSE; + + return KeyExists(m_hKey, szKey); } wxRegKey::ValueType wxRegKey::GetValueType(const wxChar *szValue) const diff --git a/src/msw/statbr95.cpp b/src/msw/statbr95.cpp index f0a8607c1d..ab57cf40cc 100644 --- a/src/msw/statbr95.cpp +++ b/src/msw/statbr95.cpp @@ -186,21 +186,21 @@ void wxStatusBar95::CopyFieldsWidth(const int widths[]) void wxStatusBar95::SetFieldsCount(int nFields, const int *widths) { - // this is Windows limitation - wxASSERT_MSG( (nFields > 0) && (nFields < 255), _T("too many fields") ); + // this is a Windows limitation + wxASSERT_MSG( (nFields > 0) && (nFields < 255), _T("too many fields") ); - m_nFields = nFields; + m_nFields = nFields; - CopyFieldsWidth(widths); - SetFieldsWidth(); + CopyFieldsWidth(widths); + SetFieldsWidth(); } void wxStatusBar95::SetStatusWidths(int n, const int widths[]) { - wxASSERT_MSG( n == m_nFields, _T("field number mismatch") ); + wxASSERT_MSG( n == m_nFields, _T("field number mismatch") ); - CopyFieldsWidth(widths); - SetFieldsWidth(); + CopyFieldsWidth(widths); + SetFieldsWidth(); } void wxStatusBar95::SetFieldsWidth() diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index f836d8dc4b..f83d0842eb 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -910,8 +910,6 @@ bool wxCheckForInterrupt(wxWindow *wnd) return TRUE; } -#endif // wxUSE_GUI - // MSW only: get user-defined resource from the .res file. // Returns NULL or newly-allocated memory, so use delete[] to clean up. @@ -1052,6 +1050,8 @@ WXWORD WXDLLEXPORT wxGetWindowId(WXHWND hWnd) #endif // Win16/32 } +#endif // wxUSE_GUI + #if 0 //------------------------------------------------------------------------ // wild character routines @@ -1209,7 +1209,7 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special ) return ((*str == '\0') && (*pattern == '\0')); }; -#endif +#endif // 0 #if 0 diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index da7b353200..af035d58aa 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -657,6 +657,8 @@ long wxExecute(char **argv, bool sync, wxProcess *handler) return wxExecute(command, sync, handler); } +#if wxUSE_GUI + // ---------------------------------------------------------------------------- // Metafile helpers // ---------------------------------------------------------------------------- @@ -690,3 +692,5 @@ extern void HIMETRICToPixel(LONG *x, LONG *y) *y *= iHeightPels; *y /= (iHeightMM * 100); } + +#endif // wxUSE_GUI