static wxString KindString(wxDbgHelpDLL::DataKind kind) { static const wxChar *kinds[] = { _T("unknown"), _T("local"), _T("static local"), _T("param"), _T("object ptr"), _T("file static"), _T("global"), _T("member"), _T("static member"), _T("constant"), }; wxCOMPILE_TIME_ASSERT( WXSIZEOF(kinds) == wxDbgHelpDLL::DATA_MAX, DataKindStringMismatch ); wxString s; if ( kind < WXSIZEOF(kinds) ) s = kinds[kind]; else s.Printf(_T("unrecognized kind (%d)"), kind); return s; }
wxCriticalSection::wxCriticalSection( wxCriticalSectionType WXUNUSED(critSecType) ) { wxCOMPILE_TIME_ASSERT( sizeof(CRITICAL_SECTION) <= sizeof(wxCritSectBuffer), wxCriticalSectionBufferTooSmall ); ::InitializeCriticalSection((CRITICAL_SECTION *)m_buffer); }
int wxEpollDispatcher::DoPoll(epoll_event *events, int numEvents, int timeout) const { // the code below relies on TIMEOUT_INFINITE being -1 so that we can pass // timeout value directly to epoll_wait() which interprets -1 as meaning to // wait forever and would need to be changed if the value of // TIMEOUT_INFINITE ever changes wxCOMPILE_TIME_ASSERT( TIMEOUT_INFINITE == -1, UpdateThisCode ); wxMilliClock_t timeEnd; if ( timeout > 0 ) timeEnd = wxGetLocalTimeMillis(); int rc; for ( ;; ) { rc = epoll_wait(m_epollDescriptor, events, numEvents, timeout); if ( rc != -1 || errno != EINTR ) break; // we got interrupted, update the timeout and restart if ( timeout > 0 ) { timeout = wxMilliClockToLong(timeEnd - wxGetLocalTimeMillis()); if ( timeout < 0 ) return 0; } } return rc; }
wxString wxPlatformInfo::GetEndiannessName(wxEndianness end) { wxCOMPILE_TIME_ASSERT( WXSIZEOF(wxEndiannessNames) == wxENDIAN_MAX, wxEndiannessNamesMismatch ); return wxEndiannessNames[end]; }
wxString wxPlatformInfo::GetArchName(wxArchitecture arch) { wxCOMPILE_TIME_ASSERT( WXSIZEOF(wxArchitectureNames) == wxARCH_MAX, wxArchitectureNamesMismatch ); return wxArchitectureNames[arch]; }
void CodeEdit::ShowToolTip(int position, const wxString& text) { bool showToolTip = true; // There doesn't seem to be a way to determine the window that the mouse is inside // in wxWidgets. If we port to another platform, we'll need to handle this. #ifdef __WXMSW__ POINT cursorPos; GetCursorPos(&cursorPos); HWND hActiveWindow = WindowFromPoint(cursorPos); showToolTip = hActiveWindow == GetHandle(); #else wxCOMPILE_TIME_ASSERT(0, "Unportable code"); #endif HideToolTip(); if (showToolTip) { m_tipWindow = new ToolTipWindow(this, text); } }
void wxTarHeaderBlock::check() { #if 0 wxCOMPILE_TIME_ASSERT( WXSIZEOF(fields) == TAR_NUMFIELDS + 1, Wrong_number_of_elements_in_fields_table ); #endif }
wxColour wxSystemSettings::GetColour(wxSystemColour index) { // the elements of this enum must be kept in sync with wxSystemColour static const wxColourScheme::StdColour s_mapSysToThemeCol[] = { wxColourScheme::SCROLLBAR /* wxSYS_COLOUR_SCROLLBAR */, wxColourScheme::WINDOW /* wxSYS_COLOUR_BACKGROUND */, wxColourScheme::TITLEBAR_ACTIVE_TEXT /* wxSYS_COLOUR_ACTIVECAPTION */, wxColourScheme::TITLEBAR_TEXT /* wxSYS_COLOUR_INACTIVECAPTION */, wxColourScheme::MAX /* wxSYS_COLOUR_MENU */, wxColourScheme::MAX /* wxSYS_COLOUR_WINDOW */, wxColourScheme::MAX /* wxSYS_COLOUR_WINDOWFRAME */, wxColourScheme::CONTROL_TEXT /* wxSYS_COLOUR_MENUTEXT */, wxColourScheme::CONTROL_TEXT /* wxSYS_COLOUR_WINDOWTEXT */, wxColourScheme::CONTROL_TEXT /* wxSYS_COLOUR_CAPTIONTEXT */, wxColourScheme::MAX /* wxSYS_COLOUR_ACTIVEBORDER */, wxColourScheme::MAX /* wxSYS_COLOUR_INACTIVEBORDER */, wxColourScheme::FRAME /* wxSYS_COLOUR_APPWORKSPACE */, wxColourScheme::HIGHLIGHT /* wxSYS_COLOUR_HIGHLIGHT */, wxColourScheme::HIGHLIGHT_TEXT /* wxSYS_COLOUR_HIGHLIGHTTEXT */, wxColourScheme::CONTROL /* wxSYS_COLOUR_BTNFACE */, wxColourScheme::SHADOW_DARK /* wxSYS_COLOUR_BTNSHADOW */, wxColourScheme::CONTROL_TEXT_DISABLED /* wxSYS_COLOUR_GRAYTEXT */, wxColourScheme::CONTROL_TEXT /* wxSYS_COLOUR_BTNTEXT */, wxColourScheme::MAX /* wxSYS_COLOUR_INACTIVECAPTIONTEXT */, wxColourScheme::SHADOW_HIGHLIGHT /* wxSYS_COLOUR_BTNHIGHLIGHT */, wxColourScheme::SHADOW_DARK /* wxSYS_COLOUR_3DDKSHADOW */, wxColourScheme::SHADOW_OUT /* wxSYS_COLOUR_3DLIGHT */, wxColourScheme::MAX /* wxSYS_COLOUR_INFOTEXT */, wxColourScheme::MAX /* wxSYS_COLOUR_INFOBK */, wxColourScheme::WINDOW /* wxSYS_COLOUR_LISTBOX */, wxColourScheme::MAX /* wxSYS_COLOUR_HOTLIGHT */, wxColourScheme::TITLEBAR_ACTIVE_TEXT /* wxSYS_COLOUR_GRADIENTACTIVECAPTION */, wxColourScheme::TITLEBAR_TEXT /* wxSYS_COLOUR_GRADIENTINACTIVECAPTION */, wxColourScheme::MAX /* wxSYS_COLOUR_MENUHILIGHT */, wxColourScheme::MAX /* wxSYS_COLOUR_MENUBAR */, wxColourScheme::CONTROL_TEXT /* wxSYS_COLOUR_LISTBOXTEXT */, wxColourScheme::HIGHLIGHT_TEXT /* wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT */ }; wxCOMPILE_TIME_ASSERT( WXSIZEOF(s_mapSysToThemeCol) == wxSYS_COLOUR_MAX, StdColDefsMismatch ); wxCHECK_MSG( index < (int)WXSIZEOF(s_mapSysToThemeCol), wxNullColour, wxT("invalid wxSystemColour") ); wxColourScheme::StdColour col = s_mapSysToThemeCol[index]; if ( col == wxColourScheme::MAX ) { // we don't have theme-equivalent for this colour return wxSystemSettingsNative::GetColour(index); } return wxTheme::Get()->GetColourScheme()->Get(col); }
static wxString TypeString(wxDbgHelpDLL::BasicType bt) { static const wxChar *types[] = { _T("no type"), _T("void"), _T("char"), _T("wchar"), _T(""), _T(""), _T("int"), _T("uint"), _T("float"), _T("bcd"), _T("bool"), _T(""), _T(""), _T("long"), _T("ulong"), _T(""), _T(""), _T(""), _T(""), _T(""), _T(""), _T(""), _T(""), _T(""), _T(""), _T("CURRENCY"), _T("DATE"), _T("VARIANT"), _T("complex"), _T("bit"), _T("BSTR"), _T("HRESULT"), }; wxCOMPILE_TIME_ASSERT( WXSIZEOF(types) == wxDbgHelpDLL::BASICTYPE_MAX, BasicTypeStringMismatch ); wxString s; if ( bt < WXSIZEOF(types) ) s = types[bt]; if ( s.empty() ) s.Printf(_T("unrecognized type (%d)"), bt); return s; }
static wxString TagString(wxDbgHelpDLL::SymbolTag tag) { static const wxChar *tags[] = { _T("null"), _T("exe"), _T("compiland"), _T("compiland details"), _T("compiland env"), _T("function"), _T("block"), _T("data"), _T("annotation"), _T("label"), _T("public symbol"), _T("udt"), _T("enum"), _T("function type"), _T("pointer type"), _T("array type"), _T("base type"), _T("typedef"), _T("base class"), _T("friend"), _T("function arg type"), _T("func debug start"), _T("func debug end"), _T("using namespace"), _T("vtable shape"), _T("vtable"), _T("custom"), _T("thunk"), _T("custom type"), _T("managed type"), _T("dimension"), }; wxCOMPILE_TIME_ASSERT( WXSIZEOF(tags) == wxDbgHelpDLL::SYMBOL_TAG_MAX, SymbolTagStringMismatch ); wxString s; if ( tag < WXSIZEOF(tags) ) s = tags[tag]; else s.Printf(_T("unrecognized tag (%d)"), tag); return s; }
/* static */ int wxFontBase::AdjustToSymbolicSize(wxFontSymbolicSize size, int base) { // Using a fixed factor (1.2, from CSS2) is a bad idea as explained at // http://www.w3.org/TR/CSS21/fonts.html#font-size-props so use the values // from http://style.cleverchimp.com/font_size_intervals/altintervals.html // instead. static const float factors[] = { 0.60f, 0.75f, 0.89f, 1.f, 1.2f, 1.5f, 2.f }; wxCOMPILE_TIME_ASSERT ( WXSIZEOF(factors) == wxFONTSIZE_XX_LARGE - wxFONTSIZE_XX_SMALL + 1, WrongFontSizeFactorsSize ); return wxRound(factors[size - wxFONTSIZE_XX_SMALL]*base); }
// String conversions String::String(const wxString& wxstr) { #if !wxUSE_UNICODE #error "This code only works in Unicode build of wxWidgets" #endif // ICU's UChar is 16bit wide, UTF-16, and the code below counts on it, so // it would break if the definition changed: wxCOMPILE_TIME_ASSERT(sizeof(UChar) == 2, UCharSizeMustBe16Bit); #if SIZEOF_WCHAR_T == 2 // wchar_t==UChar const UChar* str = wxstr.wc_str(); const size_t len = wxstr.length(); #else // SIZEOF_WCHAR_T == 4 // NB: we can't simply use wxstr.mb_str(wxMBConvUTF16()) here because // the number of characters in UTF-16 encoding of the string may differ // from the number of UTF-32 values and we can't get the length from // returned buffer: #if defined(wxUSE_UNICODE_UTF8) && wxUSE_UNICODE_UTF8 // in wx3's UTF8 mode, wc_str() returns a buffer, not raw pointer wxWCharBuffer widestr(wxstr.wc_str()); #else const wxChar *widestr = wxstr.wc_str(); #endif const size_t widelen = wxstr.length(); // allocate buffer for the UTF-16 string: wxMBConvUTF16 conv; const size_t utf16bufLen = conv.FromWChar(NULL, 0, widestr, widelen); wxCharBuffer utf16buf(utf16bufLen); // and convert wxString to UTF-16 (=UChar*): const UChar* str = (const UChar*)utf16buf.data(); size_t len = conv.FromWChar(utf16buf.data(), utf16bufLen, widestr, widelen) / 2; #endif // SIZEOF_WCHAR_T == 4 // conversion to UTF-16 or getting internal buffer isn't supposed to fail: wxASSERT_MSG(str != NULL, _T("failed string conversion?")); m_impl = StringImpl::create(str, len); }
// Get the range of the given field in character positions ("from" is // inclusive, "to" exclusive). static CharRange GetFieldRange(Field field) { // Currently we can just hard code the ranges as they are the same for // both supported formats, if we want to support arbitrary formats in // the future, we'd need to determine them dynamically by examining the // format here. static const CharRange ranges[] = { { 0, 2 }, { 3, 5 }, { 6, 8 }, { 9, 11}, }; wxCOMPILE_TIME_ASSERT( WXSIZEOF(ranges) == Field_Max, FieldRangesMismatch ); return ranges[field]; }
static wxString UdtKindString(wxDbgHelpDLL::UdtKind kind) { static const wxChar *kinds[] = { _T("struct"), _T("class"), _T("union"), }; wxCOMPILE_TIME_ASSERT( WXSIZEOF(kinds) == wxDbgHelpDLL::UDT_MAX, UDTKindStringMismatch ); wxString s; if ( kind < WXSIZEOF(kinds) ) s = kinds[kind]; else s.Printf(_T("unrecognized UDT (%d)"), kind); return s; }