NSKeyValueCoding: Safe-Caching for -[NSObject valueForKey:] (#445)

* KVC Caching Implementation

* Do not ignore struct name when comparing type encoding as NSPoint and NSSize have the same layout

* Use fast-path when using Objective-C 2

* Guard old ValueForKey function when using the fast-path

* Add basic NSKeyValueCoding tests

* Update Copyright Years

* NSKeyValueCoding+Caching: Add Versioning to IVar Slot

* safe_caching: Remove Guards

* Add type encoding helper header

* Rename geometry structs (NSRect, NSPoint, NSSize) for toll-free bridging with CoreGraphics

* Move CG struct definitions to CFCGTypes.h

* Update known struct encoding prefixes

* Windows 64-bit is LLP64 and not LP64

* Re-order to avoid complier warning

---------

Co-authored-by: rfm <richardfrithmacdonald@gmail.com>
This commit is contained in:
Hugo Melder 2024-10-29 06:12:34 -07:00 committed by GitHub
parent 4f0a8d60c2
commit 6eef1c3289
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 1549 additions and 49 deletions

View file

@ -25,10 +25,12 @@
#ifndef __NSGeometry_h_GNUSTEP_BASE_INCLUDE
#define __NSGeometry_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#import <CoreFoundation/CFCGTypes.h>
#ifdef __OBJC__
#import <objc/objc.h>
#import <Foundation/NSString.h>
#endif
#if defined(__cplusplus)
extern "C" {
@ -56,12 +58,7 @@ extern "C" {
CGFloat y;
}</example>
<p>Represents a 2-d cartesian position.</p> */
typedef struct _NSPoint NSPoint;
struct _NSPoint
{
CGFloat x;
CGFloat y;
};
typedef struct CGPoint NSPoint;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
/** Array of NSPoint structs. */
@ -76,12 +73,7 @@ typedef NSPoint *NSPointPointer;
CGFloat height;
}</example>
<p>Floating point rectangle size.</p> */
typedef struct _NSSize NSSize;
struct _NSSize
{
CGFloat width;
CGFloat height;
};
typedef struct CGSize NSSize;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
/** Array of NSSize structs. */
@ -97,12 +89,7 @@ typedef NSSize *NSSizePointer;
}</example>
<p>Rectangle.</p> */
typedef struct _NSRect NSRect;
struct _NSRect
{
NSPoint origin;
NSSize size;
};
typedef struct CGRect NSRect;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
/** Array of NSRect structs. */