Skip to content

Commit

Permalink
consistently use feature dependent ignore if appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
mcorino committed Nov 11, 2023
1 parent 0254db4 commit 0dbc859
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 78 deletions.
2 changes: 1 addition & 1 deletion lib/wx/doc/gc_dc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GCDC < Wx::DC
# @param [Wx::PrinterDC] target DC to draw on
# @yieldparam [Wx::GCDC] dc GCDC instance to draw on
# @return [Object] result from block
# @wxrb_require USE_PRINTING_ARCHITECTURE,WXMSW|WXOSX
# @wxrb_require USE_PRINTING_ARCHITECTURE,WXMSW|WXOSX|USE_GTKPRINT
# @overload draw_on(gc)
# @param [Wx::GraphicsContext] gc GraphicsContext to draw on
# @yieldparam [Wx::GCDC] dc GCDC instance to draw on
Expand Down
1 change: 1 addition & 0 deletions lib/wx/doc/graphics_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class GraphicsContext
# @see Printing Under Unix (GTK+)
# @param printerDC [Wx::PrinterDC]
# @return [Wx::GraphicsContext]
# @wxrb_require USE_PRINTING_ARCHITECTURE,WXMSW|WXOSX|USE_GTKPRINT
# @overload self.draw_on(image)
# Creates a {Wx::GraphicsContext} associated with a {Wx::Image} and passes that object to the given block.
# Deletes the gc object after the block returns.
Expand Down
4 changes: 4 additions & 0 deletions lib/wx/doc/textctrl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module Wx
# ````
#
# This class is only available if `Wx.has_feature?(:USE_SPELLCHECK)` returns true.
# @wxrb_require USE_SPELLCHECK
class TextProofOptions
def initialize(schk=false, gchk=false, lang='')end

Expand Down Expand Up @@ -79,6 +80,7 @@ def each_line; end
# When using WXGTK, this method only works if gspell library was available during the wxWidgets library build.
# @param [Wx::TextProofOptions] text_proof_options A Wx::TextProofOptions object specifying the desired behaviour of the proof checker (e.g. language to use, spell check, grammar check, etc.) and whether the proof checks should be enabled at all. By default, spelling checks for the current language are enabled. Passing Wx::TextProofOptions.disable disables all the checks.
# @return [Boolean] true if proof checking has been successfully enabled or disabled, false otherwise (usually because the corresponding functionality is not available under the current platform or for this type of text control).
# @wxrb_require USE_SPELLCHECK
# @overload enable_proof_check(spell_checking, grammar_checking, language)
# Enable or disable native spell checking on this text control if it is available on the current platform.
# Currently this is supported in WXMSW (when running under Windows 8 or later), WXGTK when using GTK 3 and wxOSX.
Expand All @@ -89,11 +91,13 @@ def each_line; end
# @param [Boolean] grammar_checking
# @param [String] language
# @return [Boolean] true if proof checking has been successfully enabled or disabled, false otherwise (usually because the corresponding functionality is not available under the current platform or for this type of text control).
# @wxrb_require USE_SPELLCHECK
def enable_proof_check(*opts) end

# Returns the current text proofing options.
# Only available if `Wx.has_feature?(:USE_SPELLCHECK)` returns true.
# @return [Wx::TextProofOptions]
# @wxrb_require USE_SPELLCHECK
def get_proof_check_options; end

end
Expand Down
11 changes: 7 additions & 4 deletions rakelib/lib/director/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ class App < EvtHandler

def setup
spec.items << 'wxAppConsole' << 'wxEventFilter'
if Config.platform == :mingw && Config.instance.wx_version >= '3.3.0'
if Config.instance.wx_version >= '3.3.0'
spec.items << 'wxDarkModeSettings'
spec.disown 'wxDarkModeSettings *settings'
# wxDarkModeSettings does has have virt dtor; it's just not documented
spec.suppress_warning(514, 'wxDarkModeSettings')
spec.ignore_unless('WXMSW', 'wxDarkModeSettings', 'wxMenuColour')
if Config.instance.features_set?('WXMSW')
spec.disown 'wxDarkModeSettings *settings'
# wxDarkModeSettings does has have virt dtor; it's just not documented
spec.suppress_warning(514, 'wxDarkModeSettings')
end
end
spec.fold_bases('wxApp' => 'wxAppConsole', 'wxAppConsole' => 'wxEventFilter')
spec.override_inheritance_chain('wxApp', %w[wxEvtHandler wxObject])
Expand Down
18 changes: 8 additions & 10 deletions rakelib/lib/director/app_traits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,14 @@ def setup
end
spec.map_apply 'int * OUTPUT' => ['int *major', 'int *minor', 'int *micro']

unless Config.platform == :mingw
spec.ignore 'wxStandardPaths::DontIgnoreAppSubDir',
'wxStandardPaths::IgnoreAppSubDir',
'wxStandardPaths::IgnoreAppBuildSubDirs',
'wxStandardPaths::MSWGetShellDir'
end
unless Config.platform == :linux
spec.ignore 'wxStandardPaths::SetInstallPrefix',
'wxStandardPaths::GetInstallPrefix'
end
spec.ignore_unless('WXMSW',
'wxStandardPaths::DontIgnoreAppSubDir',
'wxStandardPaths::IgnoreAppSubDir',
'wxStandardPaths::IgnoreAppBuildSubDirs',
'wxStandardPaths::MSWGetShellDir')
spec.ignore_unless('WXGTK',
'wxStandardPaths::SetInstallPrefix',
'wxStandardPaths::GetInstallPrefix')
end
end

Expand Down
2 changes: 1 addition & 1 deletion rakelib/lib/director/data_format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setup
# The formal signature for these is NativeFormat; this is required on
# MSVC as otherwise an impermissible implicit cast is tried, and so
# doesn't compile
spec.ignore 'wxDataFormat::GetType'
spec.ignore 'wxDataFormat::GetType', ignore_doc: false
spec.extend_interface 'wxDataFormat',
'typedef unsigned short NativeFormat',
'wxDataFormat::NativeFormat GetType() const'
Expand Down
2 changes: 1 addition & 1 deletion rakelib/lib/director/derived_dc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def setup
# like all DC this should best always be a temporary stack object
# we do not allow creation in Ruby but rather provide class
# methods for block execution on a temp dc
if Config.instance.features_set?('USE_PRINTING_ARCHITECTURE', Director.AnyOf(*%w[WXMSW WXOSX]))
if Config.instance.features_set?('USE_PRINTING_ARCHITECTURE', Director.AnyOf(*%w[WXMSW WXOSX USE_GTKPRINT]))
spec.add_extend_code 'wxGCDC', <<~__HEREDOC
static VALUE draw_on(const wxPrinterDC& dc)
{
Expand Down
1 change: 1 addition & 0 deletions rakelib/lib/director/dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def setup
when 'wxDialog'
spec.items << 'wxDialogLayoutAdapter'
spec.gc_as_object 'wxDialogLayoutAdapter'
spec.suppress_warning(514, 'wxDialogLayoutAdapter')
spec.disown 'wxDialogLayoutAdapter* adapter'
spec.new_object 'wxDialog::SetLayoutAdapter'
spec.ignore('wxDialog::GetContentWindow',
Expand Down
18 changes: 8 additions & 10 deletions rakelib/lib/director/gdicommon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@ def setup
wxPoint::x wxPoint::y
wxRealPoint::x wxRealPoint::y
]
spec.ignore('wxStockCursor.wxCURSOR_DEFAULT') unless Config.instance.features_set?('WXGTK')
unless Config.instance.features_set?('WXX11')
spec.ignore %w{
wxStockCursor.wxCURSOR_CROSS_REVERSE
wxStockCursor.wxCURSOR_DOUBLE_ARROW
wxStockCursor.wxCURSOR_BASED_ARROW_UP
wxStockCursor.wxCURSOR_BASED_ARROW_DOWN
}
end
spec.ignore('wxStockCursor.wxCURSOR_COPY_ARROW') unless Config.instance.features_set?('WXOSX')
spec.ignore_unless('WXGTK', 'wxStockCursor.wxCURSOR_DEFAULT')
spec.ignore_unless 'WXX11', %w{
wxStockCursor.wxCURSOR_CROSS_REVERSE
wxStockCursor.wxCURSOR_DOUBLE_ARROW
wxStockCursor.wxCURSOR_BASED_ARROW_UP
wxStockCursor.wxCURSOR_BASED_ARROW_DOWN
}
spec.ignore_unless('WXOSX', 'wxStockCursor.wxCURSOR_COPY_ARROW')
spec.add_extend_code 'wxRect', <<~__HEREDOC
wxRect add(const wxRect &rect) const {
return (*(const wxRect*)$self) + rect;
Expand Down
6 changes: 2 additions & 4 deletions rakelib/lib/director/graphics_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def setup
'wxGraphicsContext::DrawLines(size_t, const wxPoint2DDouble *, wxPolygonFillMode)',
'wxGraphicsContext::StrokeLines(size_t, const wxPoint2DDouble *)',
'wxGraphicsContext::StrokeLines (size_t, const wxPoint2DDouble *, const wxPoint2DDouble *)'
if Config.platform == :linux
spec.ignore 'wxGraphicsContext::Create(const wxPrinterDC &)'
end
spec.ignore_unless(Config::AnyOf.new('WXMSW', 'WXOSX', 'USE_GTKPRINT'), 'wxGraphicsContext::Create(const wxPrinterDC &)')
spec.add_header_code <<~__HEREDOC
// special free funcs are needed to clean up Dashes array if it has been
// set; wxWidgets does not do this automatically so will leak if not
Expand Down Expand Up @@ -229,7 +227,7 @@ def setup
__CODE
end
# add convenience method providing efficient gc memory management
if Config.platform != :linux && Config.instance.features_set?('USE_PRINTING_ARCHITECTURE')
if Config.instance.features_set?('USE_PRINTING_ARCHITECTURE', Director.AnyOf(*%w[WXMSW WXOSX USE_GTKPRINT]))
spec.add_extend_code 'wxGraphicsContext', <<~__HEREDOC
static VALUE draw_on(const wxPrinterDC& dc)
{
Expand Down
11 changes: 5 additions & 6 deletions rakelib/lib/director/list_ctrl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ def setup
(void)self->EditLabel(item);
}
__HEREDOC
unless Config.instance.features_set?('HAS_LISTCTRL_COLUMN_ORDER')
spec.ignore %w[wxListCtrl::GetColumnIndexFromOrder
wxListCtrl::GetColumnOrder
wxListCtrl::GetColumnsOrder
wxListCtrl::SetColumnsOrder]
end
spec.ignore_unless 'HAS_LISTCTRL_COLUMN_ORDER',
%w[wxListCtrl::GetColumnIndexFromOrder
wxListCtrl::GetColumnOrder
wxListCtrl::GetColumnsOrder
wxListCtrl::SetColumnsOrder]
# these are protected so ignored by default but we want them here
spec.regard %w[
wxListCtrl::OnGetItemAttr
Expand Down
4 changes: 1 addition & 3 deletions rakelib/lib/director/locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def setup
wxLanguageInfo::DescriptionNative
wxLanguageInfo::LayoutDirection
]
if Config.instance.features_set?('WXMSW')
spec.regard('wxLanguageInfo::WinLang', 'wxLanguageInfo::WinSublang')
end
spec.ignore_unless('WXMSW', 'wxLanguageInfo::WinLang', 'wxLanguageInfo::WinSublang')
end
end # class Locale

Expand Down
4 changes: 2 additions & 2 deletions rakelib/lib/director/menu_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def setup
spec.ignore(%w[wxMenuItem::GetLabel wxMenuItem::GetName wxMenuItem::GetText wxMenuItem::SetText wxMenuItem::GetLabelFromText])
# ignore this as there is no implementation anymore
spec.ignore 'wxMenuItem::GetAccelFromString'
spec.ignore('wxMenuItem::GetAccel') unless Config.instance.features_set?('USE_ACCEL')
spec.ignore_unless('USE_ACCEL', 'wxMenuItem::GetAccel')
spec.no_proxy 'wxMenuItem::GetAccel'
spec.ignore 'wxMenuItem::GetBitmap(bool)' # not portable
if Config.instance.wx_version >= '3.3.0'
spec.ignore('wxMenuItem::SetBackgroundColour','wxMenuItem::SetFont','wxMenuItem::SetTextColour') unless Config.instance.features_set?('WXMSW')
spec.ignore_unless('WXMSW', 'wxMenuItem::SetBackgroundColour','wxMenuItem::SetFont','wxMenuItem::SetTextColour')
end
super
end
Expand Down
15 changes: 5 additions & 10 deletions rakelib/lib/director/property_grid_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,11 @@ def setup
spec.extend_interface 'wxPropertyGridInterface',
'void SetPropertyValues(const wxVariant &list, const wxPGPropArgCls& defaultCategory = 0)'
# optionals
unless Config.instance.features_set?('USE_LONGLONG')
spec.ignore 'wxPropertyGridInterface::GetPropertyValueAsLongLong',
'wxPropertyGridInterface::GetPropertyValueAsULongLong'
end
unless Config.instance.features_set?('USE_DATETIME')
spec.ignore 'wxPropertyGridInterface::GetPropertyValueAsDateTime'
end
unless Config.instance.features_set?('USE_VALIDATORS')
spec.ignore 'wxPropertyGridInterface::GetPropertyValidator'
end
spec.ignore_unless 'USE_LONGLONG',
'wxPropertyGridInterface::GetPropertyValueAsLongLong',
'wxPropertyGridInterface::GetPropertyValueAsULongLong'
spec.ignore_unless 'USE_DATETIME', 'wxPropertyGridInterface::GetPropertyValueAsDateTime'
spec.ignore_unless 'USE_VALIDATORS', 'wxPropertyGridInterface::GetPropertyValidator'
# fix incorrect XML documentation
spec.ignore 'wxPropertyGridInterface::SetPropertyImage', ignore_doc: false # ignore non-const BitmapBundle arg decl
# and add correct decl
Expand Down
4 changes: 1 addition & 3 deletions rakelib/lib/director/richtext_ctrl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ def setup
wxRichTextCtrl::ProcessMouseMovement
wxRichTextCtrl::ProcessBackKey
]
unless Config.instance.features_set?('USE_DATETIME')
spec.ignore %w[wxRichTextCtrl::GetDragStartTime wxRichTextCtrl::SetDragStartTime]
end
spec.ignore_unless 'USE_DATETIME', %w[wxRichTextCtrl::GetDragStartTime wxRichTextCtrl::SetDragStartTime]
spec.add_header_code 'extern VALUE wxRuby_RichTextObject2Ruby(const wxRichTextObject *wx_rto, int own);'
spec.swig_import('swig/classes/include/wxTextAttr.h',
'swig/classes/include/wxRichTextObject.h',
Expand Down
12 changes: 7 additions & 5 deletions rakelib/lib/director/richtext_formatting_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ def setup
wxRichTextFormattingDialog::SetStyle
wxRichTextFormattingDialog::SetStyleDefinition
]
# add undocumented methods
spec.extend_interface 'wxRichTextFormattingDialog',
'wxRichTextObject* GetObject() const',
'void SetObject(wxRichTextObject* obj)',
'virtual bool ApplyStyle(wxRichTextCtrl* ctrl, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO)'
if Config.instance.wx_version < '3.3.0'
# add undocumented methods
spec.extend_interface 'wxRichTextFormattingDialog',
'wxRichTextObject* GetObject() const',
'void SetObject(wxRichTextObject* obj)',
'virtual bool ApplyStyle(wxRichTextCtrl* ctrl, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO)'
end
spec.add_header_code 'extern VALUE wxRuby_RichTextObject2Ruby(const wxRichTextObject *wx_rto, int own);'
spec.disown 'wxRichTextFormattingDialogFactory *factory'
spec.suppress_warning(473, 'wxRichTextFormattingDialogFactory::CreatePage')
Expand Down
9 changes: 4 additions & 5 deletions rakelib/lib/director/static_box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ class StaticBox < Window

def setup
super
if Config.instance.wx_port == :wxqt || Config.platform == :macosx
# missing from implementation currently
spec.ignore 'wxStaticBox::wxStaticBox(wxWindow *, wxWindowID, wxWindow *, const wxPoint &, const wxSize &, long, const wxString &)',
'wxStaticBox::Create(wxWindow *, wxWindowID, wxWindow *, const wxPoint &, const wxSize &, long, const wxString &)'
end
# missing from implementation currently for WXOSX (and WXQT)
spec.ignore_unless(Config::AnyOf.new(*%w[WXMSW WXGTK]),
'wxStaticBox::wxStaticBox(wxWindow *, wxWindowID, wxWindow *, const wxPoint &, const wxSize &, long, const wxString &)',
'wxStaticBox::Create(wxWindow *, wxWindowID, wxWindow *, const wxPoint &, const wxSize &, long, const wxString &)')
end
end # class StaticBox

Expand Down
2 changes: 1 addition & 1 deletion rakelib/lib/director/tool_tip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Director
class ToolTip < Director

def setup
spec.ignore('wxToolTip::SetMaxWidth') unless Config.instance.features_set?('WXMSW')
spec.ignore_unless('WXMSW', 'wxToolTip::SetMaxWidth')
super
end
end # class ToolTip
Expand Down
9 changes: 4 additions & 5 deletions rakelib/lib/director/top_level_window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ def setup
wxTopLevelWindow::RestoreToGeometry
wxTopLevelWindow::GeometrySerializer
}
unless Config.instance.features_set?('WXUNIVERSAL')
spec.ignore %w{
# #ignore_unless if wxRuby one day supports 'WXUNIVERSAL'
spec.ignore %w{
wxTopLevelWindow::IsUsingNativeDecorations
wxTopLevelWindow::UseNativeDecorations
wxTopLevelWindow::UseNativeDecorationsByDefault
}
end
spec.ignore('wxTopLevelWindow::MSWGetSystemMenu') unless Config.instance.features_set?('WXMSW')
spec.ignore('wxTopLevelWindow::OSXSetModified','wxTopLevelWindow::OSXIsModified') unless Config.instance.features_set?('WXOSX')
spec.ignore_unless('WXMSW', 'wxTopLevelWindow::MSWGetSystemMenu')
spec.ignore_unless('WXOSX', 'wxTopLevelWindow::OSXSetModified','wxTopLevelWindow::OSXIsModified')
spec.swig_import 'swig/classes/include/wxDefs.h'
# incorrectly documented here
spec.override_events 'wxTopLevelWindow',
Expand Down
7 changes: 3 additions & 4 deletions rakelib/lib/director/tree_ctrl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ class WxRubyTreeCtrl : public wxTreeCtrl
(void)self->EditLabel(item);
}
__HEREDOC
if [:wxmsw, :wxqt].include?(Config.instance.wx_port)
spec.ignore('wxTreeCtrl::SetButtonsImageList')
spec.ignore('wxTreeCtrl::GetButtonsImageList')
end
spec.ignore_unless(Config::AnyOf.new(*%w[WXGTK WXOSX]),
'wxTreeCtrl::SetButtonsImageList',
'wxTreeCtrl::GetButtonsImageList')
# these reimplemented window base methods need to be properly wrapped but
# are missing from the XML docs
spec.extend_interface('wxTreeCtrl',
Expand Down
4 changes: 2 additions & 2 deletions rakelib/lib/director/window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ def setup
spec.ignore 'wxWindow::EnableTouchEvents'
end
if Config.instance.wx_version >= '3.3.0'
spec.ignore('wxWindow::MSWDisableComposited') unless Config.instance.features_set?('WXMSW')
spec.ignore_unless('WXMSW', 'wxWindow::MSWDisableComposited')
end
if Config.instance.features_set?('USE_ACCESSIBILITY')
spec.disown 'wxAccessible *accessible'
else
spec.ignore('wxWindow::SetAccessible',
'wxWindow::GetAccessible')
end
spec.ignore(%w[wxWindow::RegisterHotKey wxWindow::UnregisterHotKey]) unless Config.instance.features_set?('USE_HOTKEY')
spec.ignore_unless('USE_HOTKEY', %w[wxWindow::RegisterHotKey wxWindow::UnregisterHotKey])
spec.ignore('wxWindow::SetSize(int, int)') # not useful as the wxSize variant will also accept an array
spec.swig_import %w{
swig/classes/include/wxObject.h
Expand Down
2 changes: 1 addition & 1 deletion rakelib/lib/specs/interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ module WXRuby3
}

Director.Package('Wx::PRT', 'USE_PRINTING_ARCHITECTURE') do |pkg|
Director.Spec(pkg, 'wxPrinterDC', director: Director::DerivedDC, requirements: Director.AnyOf(*%w[WXMSW WXOSX]))
Director.Spec(pkg, 'wxPrinterDC', director: Director::DerivedDC, requirements: Director.AnyOf(*%w[WXMSW WXOSX USE_GTKPRINT]))
Director.Spec(pkg, 'wxPostScriptDC', director: Director::DerivedDC)
Director.Spec(pkg, 'wxPrintData')
Director.Spec(pkg, 'wxPrintDialog')
Expand Down

0 comments on commit 0dbc859

Please sign in to comment.