Commit Graph

119 Commits

Author SHA1 Message Date
lojack5
e84d7abcba Possible way to handle enums.
Named enums with 'Flags' in the name use `enum.IntFlag`, all other enums
use `enum.IntEnum`.  We have to bring the enum members into the containing
scope to match the original behaviour. Further, since these enums are typing
information only, and not actually in wx proper, we prevent them from appearing
to leak the the user by marking as non-exported (prepend '_' to the name), then
make a TypeAlias to the enum or an int.  This way type signatures still claim
to accept integers as appropriate.

I like this solution best, because we preserved the information about which
enum members are expected for method/function parameters, while not leaking
non-existant classes out of the type-stubs, and not complaining about using
integers.

There's still a few undefined but referenced enums (ex:
richtext.TextAttrDimensionFlags). These are most likely a union of some of
the other flags/enum types already defined, but the work to pull that information
from the C++ source is probably too much.
2023-10-18 12:27:00 -06:00
lojack5
e14be4fbb4 Edge case on type-conversions: typdef int wxCoord 2023-10-18 12:26:59 -06:00
lojack5
7f74a5fd65 Prepare for changes in generated #define and global variables
These will be changing to annotation statements, so FixWxPrefix needs to
be able to detect this still (proper thing to look for in this case is
`ast.AnnAssign`).
2023-10-18 12:26:58 -06:00
lojack5
fa2bde419f Extract type information in makePyArgsString
One unexpected type of '...' required adding a new transformation
that modifies both the name and the type to just '*args', so added
a preferred method `FixWxPrefix.parseNameAndType` which processes
both strings at once.

Also fixes cleanType to recursively call cleanType on sub-types
(was improperly calling cleanName).

With this, method and function signatures now have type annotations
which are mostly correct (100% correct in the "it compiles" sense).
Thankfully, the incorrect type-hints don't cause errors due to using
stringized annotations (by importing annotations from __future__).

Importantly, the overload signatures now have been fully sanitized.
Before this, there was one instance of a variable named `is`, and another
named `/Transfer/` - both invalid identifiers. I stopped looking after
those. Since theses signatures are valid Python code, this opens up the
opportunity to use `typing.overload` to fully expose those.

Edge-cases in type-hints will be addressed in later commits.
2023-10-18 12:26:58 -06:00
lojack5
d303548d43 Move local _cleanName to FixWxPrefix.cleanName
This allows for building `FixWxPrefix.cleanType` on top of it, for use
in processing type-hint strings in the future. It also exposes the method
to `FunctionDef.makePyArgString` in the future, which has easier access to
the types of arguments and returns. And possibly further in the future,
other `***Def` classes can make use of it (constant definitions, etc).
2023-10-18 12:19:00 -06:00
Scott Talbert
aa1ef7bd75 Update ETG scripts to support wxWidgets 3.1.6 functionality
Fixes #2136.
2022-05-02 22:33:58 -04:00
Robin Dunn
12db41dad1 Ensure SIP knows about the item container pure virtuals. 2020-12-29 18:11:05 -08:00
Stefan Brüns
08c895a379 Do not strip wx prefix from parameter names
Parameter names should not be mangled, as this causes mismatches between
extractor and xml data:

```
SEVERE: Incompatibility between function/method signature and list of parameters in `wx.html.HtmlHelpWindow.__init__`:
The parameter `WindowID` appears in the method signature but could not be found in the parameter list.
  ==> Function/Method signature from `extractors`: __init__(parent, WindowID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL|wx.BORDER_NONE, helpStyle=HF_DEFAULT_STYLE, data=None)
  ==> Parameter list from wxWidgets XML items:     ['parent', 'wxWindowID', 'pos', 'size', 'style', 'helpStyle', 'data']
```
```
  ==> Function/Method signature from `extractors`: SetAssertMode(AppAssertMode)
  ==> Parameter list from wxWidgets XML items:     ['wxAppAssertMode']
```
2020-10-02 00:12:08 +02:00
Robin Dunn
4b9b8ad93e Add the EnableVisibleFocus virtual method to all window classes 2020-09-10 13:06:31 -07:00
Robin Dunn
92f8cd2d55 Fix lots of misspelled words 2020-07-14 11:38:32 -07:00
Stefan Brüns
b45ec07194 Use explicit wxString::c_str conversion for sipFindType(const char*) 2020-07-01 15:13:07 +02:00
Robin Dunn
06b08ecc05 Move fixDialogProperty to tweaker_tools, and use it on more property classes 2020-04-23 15:13:40 -07:00
Robin Dunn
a263e02639 Some additional default typeVal items for the stubs generator 2020-03-24 18:39:20 -07:00
Robin Dunn
799d94b50f Enable adding extra TypeHeader text in wxListWrapperTemplate 2020-03-24 17:36:22 -07:00
Robin Dunn
b503793e5e Add ability to make global name strings from a wchar_t constant 2020-03-17 17:46:56 -07:00
Robin Dunn
9f2cc54b48 Update copyright years 2020-03-10 11:41:39 -07:00
Robin Dunn
54dc9ac457 Add EnableSystemTheme method to the classes which support it 2019-06-12 13:33:26 -07:00
Robin Dunn
5d078557bf Lots of updates to get caught up with wxWidgets master (3.1.3+) 2019-05-23 21:43:40 -07:00
Robin Dunn
b24dc5088b Give char pointers a value in stubbed code
(cherry picked from commit fc14b8ecc4)
2019-05-21 16:14:29 -07:00
Robin Dunn
0378328d45 Merge pull request #1201 from RobinD42/fix-issue1198
Fix access to members of transient wx.VisualAttributes

(cherry picked from commit d6324a0578)
2019-04-13 16:25:55 -07:00
Robin Dunn
94ce8fc74a Merge pull request #1124 from RobinD42/fix-issue1123
Generate optional stubs for the wxFileSystemWatcher* classes
(cherry picked from commit 792d32a1c4)
2019-01-03 22:16:08 -08:00
Robin Dunn
2f540a91e6 Merge pull request #1034 from RobinD42/fix-issue958-291-wxAccessible
Add wxAccessible and a tool to generate C++ stubs

(cherry picked from commit 3a9f37f2aa)
2018-10-10 19:40:59 -07:00
Robin Dunn
41be300c46 Merge pull request #1022 from RobinD42/fix-issue972
Declare DeleteAllPages in the notebook subclasses

(cherry picked from commit 4b0f0e82c2)
2018-09-27 21:13:04 -07:00
Mesalu
d1262c44e2 Silently ignore missing methods. 2018-08-07 17:37:16 -07:00
Mesalu
e91ae38e90 Refactor tweaks into a tweaker_tools method, apply to wx.TextEntry, wx.ComboBox, and wx.RichTextCtrl 2018-08-07 17:22:55 -07:00
Robin Dunn
b77c88a280 Merge tag 'wxPython-4.0.2' into wxPy-4.0.x
(cherry picked from commit 4c56c39e52)
2018-06-17 22:04:22 -07:00
Metallicow
c76384d458 Trim trailing whitespace *.py files 2018-01-16 08:47:07 -06:00
Robin Dunn
92468c7a87 Merge branch 'master' into port-gizmos 2018-01-08 20:32:33 -08:00
Mesalu
24a6db6cd9 Add similar tactics to wxArray (and variants)
According to RobinD42, use cases in wxPython should be limited to Arrays that are full (no gaps)
2018-01-06 11:36:39 -08:00
Mesalu
af084599a6 Allow Py-like reverse indexing of wxList 2018-01-06 02:04:41 -08:00
Robin Dunn
4120f3b56c fix typo 2017-11-01 16:04:58 -07:00
Robin Dunn
66b4a7966d Enable wxArray wrappers to return copy from __getitem__.
This solves problems where an array that is the return value of some method call is indexed immediately and a reference to the array is not held, which could result in garbage values for the indexed item. Currently this is turned on for just GridCellCoordsArray, but others can be switched in the future if needed.
2017-10-12 14:33:15 -07:00
Robin Dunn
c76880a6c3 Ensure all window classes declare GetClassDefaultAttributes.
Many do not actually have it, but the docs only declare it in wx.Window so we will miss the ones that really do have one unless we let sip know about them.
2017-09-12 16:07:44 -07:00
Robin Dunn
678d6d897f Ensure wx.Notebook (and other bookctrls) declare all the base virtual methods 2017-09-05 16:38:27 -07:00
Robin Dunn
6bf050289f Virtualize Get/SetProperty 2017-07-21 13:23:09 -07:00
Robin Dunn
2e706e7aba Set wx.RefCounter objects to be owned by C++.
Set the /Transfer/ annotation on the ctors, because the C++ objects will always own themselves and will delete themselves when their C++ refcount drops to zero.
2017-05-23 13:18:53 -07:00
Robin Dunn
efa81882e3 Also allow numpy arrays for sequence conversions to value types 2017-04-17 17:22:50 -07:00
Robin Dunn
0b57a79ab0 Merge branch 'master' into release-prep 2017-04-15 10:30:48 -07:00
Robin Dunn
52facb4d7f Add a GetIM() method to Colour, Point, Size, Rect and other ‘value’ types.
GetIM() returns a replicant of the original object that is immutable, so it can be used as a dictionary key, or etc., but still gives access to the properties by name, which using the Get() method to get a tuple of the values does not do.
2017-04-14 19:19:26 -07:00
Robin Dunn
a4e226c7fd Merge branch 'master' into release-prep 2017-04-13 20:51:26 -07:00
Robin Dunn
708e2487dc Since we know it is a Tuple or List we can use PySequence_Fast_GET_ITEM 2017-04-12 14:32:50 -07:00
Robin Dunn
b01729f4ef Tighten up allowed types in auto sequence conversions
Instead of allowing generic sequences to be convertible to wxPoint, wxSize, and others, explicitly allow only tuples and lists.  This is needed because these types also have methods that make them look like sequences, which meant that you could pass a wxSize where a wxPoint is expected, and so on.

Even worse is nonsense stuff like:

    wx.Point(10,20) == wx.Size(10,20)

evaluating to True.
2017-04-12 13:57:08 -07:00
Robin Dunn
9c87092819 Turn off the generation of the .pi files. The new official standard is .pyi files. 2017-02-13 21:24:54 -08:00
Robin Dunn
9d172ddc8a Update copyright in etgtools 2017-02-13 16:18:47 -08:00
Robin Dunn
c2a63a93f4 Using the NoTypeName annotation solves the wxLongLong_t issue 2017-01-22 19:50:45 -08:00
Robin Dunn
a69601c7c4 Set mustHaveApp for all window classes 2017-01-21 19:07:59 -08:00
Metallicow
067569d785 Trim trailing space etgtools directory 2016-12-05 16:26:04 -06:00
Robin Dunn
efa9c5982a Also check for ‘winid’ in fixTopLevelWindowClass 2016-11-11 19:40:39 -08:00
Robin Dunn
5268ebbc73 Add the rest of the AUI modules and classes 2016-10-27 18:49:41 -07:00
Robin Dunn
981c05d968 Enable arraywWrapperTemplate to also be able to handle arrays of pointers to objects. 2016-10-27 08:38:02 -07:00