Releases: beeware/rubicon-objc
Releases · beeware/rubicon-objc
v0.4.0
Features
- Added macOS 10.15 (Catalina) to the test matrix. #145
- Added
517
and518
build system metadata to pyproject.toml. #156 - Added official support for Python 3.8. #162
- Added a
varargs
keyword argument to send_message` to allow calling variadic methods more safely. #174 - Changed
ObjCMethod
to call methods using send_messageinstead of calling IMP
s directly. This is mainly an internal change and should not affect most existing code, although it may improve compatibility with Objective-C code that makes heavy use of runtime reflection and method manipulation (such as swizzling). #177
Bugfixes
- Fixed Objective-C method calls in "flat" syntax accepting more arguments than the method has. The extra arguments were previously silently ignored. An exception is now raised if too many arguments are passed. #123
- Fixed
ObjCInstance.__str__ <rubicon.objc.api.ObjCInstance.__str__>
throwing an exception if the object's Objective-Cdescription
isnil
. #125 - Corrected a slow memory leak caused every time an asyncio timed event handler triggered. #146
- Fixed various minor issues in the build and packaging metadata. #156
- Removed unit test that attempted to pass a struct with bit fields into a C function by value. Although this has worked in the past on x86 and x86_64,
ctypes
never officially supported this, and started generating an error in Python 3.7.6 and 3.8.1 (see bpo-39295). #157 - Corrected the invocation of
NSApplication.terminate()
when the CocoaLifecycle` is ended. #170 - Fixed send_message
not accepting SEL
objects for theselector
parameter. The documentation stated that this is allowed, but actually doing so caused a type error. #177
Improved Documentation
- Added detailed
reference documentation </reference/index>
for all public APIs ofrubicon.objc
. #118 - Added a
how-to guide for calling regular C functions </how-to/c-functions>
usingctypes
andrubicon.objc
. #147
Deprecations and Removals
- Removed the i386 architecture from the test matrix. It is still supported on a best-effort basis, but compatibility is not tested automatically. #139
- Tightened the API of send_message
, removing some previously allowed shortcuts and features that were rarely used, or likely to be used by accident in an unsafe way. In most cases, Rubicon's high-level method call syntax provided by ObjCInstance
can be used instead of send_message. This syntax is almost always more convenient to use, more readable and less error-prone. send_message
should only be used in cases not supported by the high-level syntax. - Disallowed passing class names as
str
/bytes
as thereceiver
argument of send_message. If you need to send a message to a class object (i. e. call a class method), use ObjCClass
or get_classto look up the class, and pass the resulting ObjCClass
or Class` object as the receiver. - Disallowed passing
~ctypes.c_void_p
objects as thereceiver
argument of send_message. The
receiverargument now has to be of type objc_id
, or one of its subclasses (such as Class), or one of its high-level equivalents (such as ObjCInstance
). All Objective-C objects returned by Rubicon's high-level and low-level APIs have one of these types. If you need to send a message to an object pointer stored as~ctypes.c_void_p
,~ctypes.cast
it to objc_id` first. - Removed default values for send_message
's
restypeand
argtypeskeyword arguments. Every send_message
call now needs to have its return and argument types set explicitly. This ensures that all arguments and the return value are converted correctly between (Objective-)C and Python. - Disallowed passing more argument values than there are argument types in
argtypes
. This was previously allowed to support calling variadic methods - any arguments beyond the types set inargtypes
would be passed as varargs. However, this feature was easy to misuse by accident, as it allowed passing extra arguments to any method, even though most Objective-C methods are not variadic. Extra arguments passed this way were silently ignored without causing an error or a crash. To prevent accidentally passing too many arguments like this, the number of arguments now has to exactly match the number ofargtypes
. Variadic methods can still be called, but the varargs now need to be passed as a list into the separatevarargs
keyword arugment. #174 - Removed the
rubicon.objc.core_foundation
module. This was an internal module with few remaining contents and should not have any external uses. If you need to call Core Foundation functions in your code, please load the framework yourself usingload_library('CoreFoundation')
and define the types and functions that you need. #175 - Removed the
ObjCMethod
class from the public API, as there was no good way to use it from external code. #177