From 23e69cb9b86787e0025f831f0f92e48e4410b60e Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 9 Mar 2016 21:10:08 -0800 Subject: [PATCH] Some cleanup and comments --- TODO.txt | 45 ------------------------------------ src/wacky_ints.sip | 8 +++++++ unittests/test_wacky_ints.py | 1 - 3 files changed, 8 insertions(+), 46 deletions(-) diff --git a/TODO.txt b/TODO.txt index 1da21a1b..effcce46 100644 --- a/TODO.txt +++ b/TODO.txt @@ -193,48 +193,3 @@ other dev stuff - * Come up with a workaround for types like size_t which can be - equivalent to long on some platforms, and long long on others. If - we tell SIP to treat them as longs but they really are long long - then in some situations on a 64bit build we can end up with the - upper 32bits of the variable not getting initialized. If we say - that they are long longs then on a 32bit build we can get - tuncation warnings or perhaps errors for some. - - See etg/defs.py and http://trac.wxwidgets.org/ticket/16561 - - Current idea: Replace the instances of size_t (and etc.) in the - API with some custom type, such that passing that type to a - parameter expecting size_t will not complain and will work - correctly. For example, if we use unsigned long instead of - size_t, then when passing that value to a method expecting size_t - the compiler will automatically promote the value and there will - be no sizeof issues when fetching the value from Python and - initializing the local variable. This will work for things that - don't really need 64bit values, (like the number of pages in a - notebook) but will likely fail when those values are being use to - hold pointers. - - Probably better idea: Use some SIP magic to deal with the - bitness at runtime instead of build time... Make size_t and - others be custom types with conversions from/to Python done with - a %MappedType. - - osx-64: - **** sizeof(int): 4 - **** sizeof(long): 8 - **** sizeof(long long): 8 - **** sizeof(size_t): 8 - - win-32: - **** sizeof(int): 4 - **** sizeof(long): 4 - **** sizeof(long long): 8 - **** sizeof(size_t): 4 - - win-64 - **** sizeof(int): 4 - **** sizeof(long): 4 - **** sizeof(long long): 8 - **** sizeof(size_t): 8 - diff --git a/src/wacky_ints.sip b/src/wacky_ints.sip index e8b03609..bd3facc4 100644 --- a/src/wacky_ints.sip +++ b/src/wacky_ints.sip @@ -13,6 +13,10 @@ //-------------------------------------------------------------------------- +// size_t will either be equivallent to an unsigned long, or to an +// unsigned long long. wxWidgets' configure script has already figured out +// which it is, so we can make it conditional on those results. + %MappedType size_t { %TypeHeaderCode @@ -46,6 +50,8 @@ }; +// This type is a signed integer value that is large enough to hold a +// pointer. Again we'll use the results of wxWidgets configuration. %MappedType wxIntPtr { %TypeHeaderCode @@ -79,6 +85,8 @@ }; +// This type is an unsigned integer value that is large enough to hold a +// pointer. Again we'll use the results of wxWidgets configuration. %MappedType wxUIntPtr { %TypeHeaderCode diff --git a/unittests/test_wacky_ints.py b/unittests/test_wacky_ints.py index 1756e653..2eba3d46 100644 --- a/unittests/test_wacky_ints.py +++ b/unittests/test_wacky_ints.py @@ -2,7 +2,6 @@ import imp_unittest, unittest import wtc import wx -import wx.lib.six as six #---------------------------------------------------------------------------