Misc. stubs, fixes, and implementations for Xcode

This commit is contained in:
Ariel Abreu 2023-10-13 10:18:19 -04:00
parent 1efc3b97de
commit bd843143fb
No known key found for this signature in database
GPG Key ID: 5B88AAAF4280706F
27 changed files with 191 additions and 7 deletions

View File

@ -39,6 +39,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@implementation NSCell
@synthesize identifier = _identifier;
@synthesize truncatesLastVisibleLine = _truncatesLastVisibleLine;
@synthesize allowsUndo = _allowsUndo;
@synthesize userInterfaceLayoutDirection = _userInterfaceLayoutDirection;
#pragma mark -
#pragma mark Class Methods

View File

@ -42,6 +42,9 @@ NSString *const NSControlTextDidEndEditingNotification =
@implementation NSControl
@synthesize allowsExpansionToolTips = _allowsExpansionToolTips;
@synthesize allowsLogicalLayoutDirection = _allowsLogicalLayoutDirection;
static NSMutableDictionary *cellClassDictionary = nil;
+ (void) initialize {
@ -693,6 +696,14 @@ static NSMutableDictionary *cellClassDictionary = nil;
}
}
- (BOOL) _setsMaxLayoutWidthAtFirstLayout {
return _setsMaxLayoutWidthAtFirstLayout;
}
- (void) _setSetsMaxLayoutWidthAtFirstLayout: (BOOL) setsMaxLayoutWidthAtFirstLayout {
_setsMaxLayoutWidthAtFirstLayout = setsMaxLayoutWidthAtFirstLayout;
}
// NSEditor methods
- (BOOL) commitEditing {

View File

@ -198,7 +198,17 @@ static int untitled_document_number = 0;
}
- (NSString *) fileType {
return _fileType;
NSString *result = _fileType;
if (result == nil) {
// when `_fileType` is `nil`, it seems this method returns the first element of `[self writableTypesForSaveOperation: NSSaveOperation]`.
// i initially thought that `_fileType` was merely initialized to this value in `init`, but it turns out that setting it to `nil` and then
// querying it returns the default value again. checking for it here is simpler than initializing it in `init` + resetting it in `setFileType:`.
// plus, it seems that certain programs (Xcode, of course) depend on this being checked here rather than in `init` (and without ever calling `setFileType:`).
result = [self writableTypesForSaveOperation: NSSaveOperation].firstObject;
}
return [[result retain] autorelease];
}
- (BOOL) hasUndoManager {

View File

@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSWindow.h>
#import <Foundation/NSDate.h>
#import <Foundation/NSException.h>
#import <Foundation/NSRaise.h>
@implementation NSEvent
@ -348,6 +349,17 @@ static NSTimer *_periodicTimer = nil;
return 0;
}
+ (id) addLocalMonitorForEventsMatchingMask: (NSEventMask) mask
handler: (NSEvent * (^)(NSEvent *event)) block
{
NSUnimplementedMethod();
return nil;
}
+ (void) removeMonitor: (id) eventMonitor {
NSUnimplementedMethod();
}
@end
NSEventMask NSEventMaskFromType(NSEventType type) {

View File

@ -691,7 +691,7 @@ static NSLock *_cacheLock = nil;
- (NSFont *) screenFontWithRenderingMode: (NSFontRenderingMode) mode {
NSUnimplementedMethod();
return nil;
return [[self copy] autorelease];
}
- (NSRect) boundingRectForFont {
@ -891,6 +891,11 @@ static NSLock *_cacheLock = nil;
stringWithFormat: @"<%@ %@ %f>", [self class], _name, _pointSize];
}
- (id) _metaType {
NSUnimplementedMethod();
return nil;
}
NSInteger NSConvertGlyphsToPackedGlyphs(NSGlyph *glyphs, NSInteger length,
NSMultibyteGlyphPacking packing,
char *outputX)

View File

@ -296,4 +296,9 @@ static void evaluate(void *info, CGFloat const *input, CGFloat *output) {
alpha: output[3]];
}
- (instancetype) copyWithZone: (NSZone *) zone {
// NSGradient is immutable
return [self retain];
}
@end

View File

@ -37,6 +37,7 @@ NSString *const _NSWindowsMenuName = @"Window";
@implementation NSMenu
@synthesize showsStateColumn = _showsStateColumn;
@synthesize identifier = _identifier;
+ (void) popUpContextMenu: (NSMenu *) menu
@ -76,6 +77,8 @@ NSString *const _NSWindowsMenuName = @"Window";
}
- initWithCoder: (NSCoder *) coder {
_showsStateColumn = YES; // TODO: figure out the right coding for this
if ([coder allowsKeyedCoding]) {
NSKeyedUnarchiver *keyed = (NSKeyedUnarchiver *) coder;
@ -156,6 +159,7 @@ NSString *const _NSWindowsMenuName = @"Window";
_title = [title copy];
_itemArray = [NSMutableArray new];
_autoenablesItems = YES;
_showsStateColumn = YES;
return self;
}
@ -479,6 +483,12 @@ BOOL itemIsEnabled(NSMenuItem *item) {
return _name;
}
- (void) _setMenuName: (NSString *) name {
NSString* copied = [name copy];
[_name release];
_name = copied;
}
- (NSMenu *) _menuWithName: (NSString *) name {
if ([_name isEqual: name])
return self;

View File

@ -30,6 +30,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@implementation NSMenuItem
@synthesize alternate = _alternate;
@synthesize allowsKeyEquivalentWhenHidden = _allowsKeyEquivalentWhenHidden;
@synthesize identifier = _identifier;
+ (NSMenuItem *) separatorItem {

View File

@ -39,6 +39,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@implementation NSTextField
@synthesize preferredMaxLayoutWidth = _preferredMaxLayoutWidth;
+ (Class) cellClass {
return [NSTextFieldCell class];
}
@ -63,7 +65,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
_errorAction = NSSelectorFromString(
[keyed decodeObjectForKey: @"NSErrorAction"]);
double maxLayoutWidth =
_preferredMaxLayoutWidth =
[keyed decodeDoubleForKey: @"NSPreferredMaxLayoutWidth"];
// TODO
} else {

View File

@ -35,6 +35,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@implementation NSTextFieldCell
@synthesize allowedInputSourceLocales = _allowedInputSourceLocales;
- (void) encodeWithCoder: (NSCoder *) coder {
NSUnimplementedMethod();
}
@ -130,6 +132,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
- (void) dealloc {
[_backgroundColor release];
[_textColor release];
[_placeholder release];
[_allowedInputSourceLocales release];
[super dealloc];
}

View File

@ -45,6 +45,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <Onyx2D/O2Context.h>
#import <QuartzCore/CALayerContext.h>
#import <QuartzCore/CATransaction.h>
#import <AppKit/NSLayoutConstraint.h>
@class IBMetricsTable;
@ -70,6 +71,7 @@ const NSViewFullScreenModeOptionKey NSFullScreenModeApplicationPresentationOptio
@implementation NSView
@synthesize identifier = _identifier;
@synthesize translatesAutoresizingMaskIntoConstraints = _translatesAutoresizingMaskIntoConstraints;
static BOOL NSViewLayersEnabled = YES;
static BOOL NSShowAllViews = NO;
@ -80,6 +82,10 @@ static BOOL NSShowAllViews = NO;
NSShowAllViews = [defaults boolForKey: @"NSShowAllViews"];
}
+ (BOOL) requiresConstraintBasedLayout {
return NO;
}
- (NSColor *) _borderColorForNSShowAllViews {
return [NSColor orangeColor];
}
@ -154,6 +160,9 @@ typedef struct __VFlags {
- initWithCoder: (NSCoder *) coder {
[super initWithCoder: coder];
// TODO: decode this
_translatesAutoresizingMaskIntoConstraints = YES;
if ([coder allowsKeyedCoding]) {
NSKeyedUnarchiver *keyed = (NSKeyedUnarchiver *) coder;
unsigned vFlags = [keyed decodeIntForKey: @"NSvFlags"];
@ -379,6 +388,8 @@ typedef struct __VFlags {
// thus, we might have a layer context already but with an incorrect frame.
[_layerContext setFrame: _frame];
_translatesAutoresizingMaskIntoConstraints = YES;
return self;
}
@ -2841,4 +2852,40 @@ static NSView *viewBeingPrinted = nil;
return nil;
}
- (void) _nsib_setUsesPointIntegralizationForLayout: (BOOL) usesPointIntegralizationForLayout {
NSUnimplementedMethod();
}
- (NSLayoutPriority) contentHuggingPriorityForOrientation: (NSLayoutConstraintOrientation) orientation {
if (orientation == NSLayoutConstraintOrientationHorizontal) {
return _horizontalContentHuggingPriority;
} else {
return _verticalContentHuggingPriority;
}
}
- (void) setContentHuggingPriority: (NSLayoutPriority) contentHuggingPriority forOrientation: (NSLayoutConstraintOrientation) orientation {
if (orientation == NSLayoutConstraintOrientationHorizontal) {
_horizontalContentHuggingPriority = contentHuggingPriority;
} else {
_verticalContentHuggingPriority = contentHuggingPriority;
}
}
- (NSLayoutPriority) contentCompressionResistancePriorityForOrientation: (NSLayoutConstraintOrientation) orientation {
if (orientation == NSLayoutConstraintOrientationHorizontal) {
return _horizontalContentCompressionResistancePriority;
} else {
return _verticalContentCompressionResistancePriority;
}
}
- (void) setContentCompressionResistancePriority: (NSLayoutPriority) contentCompressionResistancePriority forOrientation: (NSLayoutConstraintOrientation) orientation {
if (orientation == NSLayoutConstraintOrientationHorizontal) {
_horizontalContentCompressionResistancePriority = contentCompressionResistancePriority;
} else {
_verticalContentCompressionResistancePriority = contentCompressionResistancePriority;
}
}
@end

View File

@ -90,6 +90,11 @@ typedef enum {
NSPrintingFailure,
} NSApplicationPrintReply;
typedef NS_ENUM(NSInteger, NSUserInterfaceLayoutDirection) {
NSUserInterfaceLayoutDirectionLeftToRight = 0,
NSUserInterfaceLayoutDirectionRightToLeft = 1,
};
@interface NSApplication : NSResponder {
NSDisplay *_display;
id _delegate;

View File

@ -21,6 +21,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSParagraphStyle.h>
#import <AppKit/NSText.h>
#import <AppKit/NSUserInterfaceItemIdentification.h>
#import <AppKit/NSApplication.h>
@class NSFont, NSImage, NSView;
@ -131,8 +132,15 @@ enum {
BOOL _sendsActionOnEndEditing;
BOOL _hasValidObjectValue;
BOOL _usesSingleLineMode;
BOOL _truncatesLastVisibleLine;
BOOL _allowsUndo;
NSUserInterfaceLayoutDirection _userInterfaceLayoutDirection;
}
@property BOOL truncatesLastVisibleLine;
@property BOOL allowsUndo;
@property NSUserInterfaceLayoutDirection userInterfaceLayoutDirection;
#pragma mark -
#pragma mark Class Methods

View File

@ -31,8 +31,14 @@ APPKIT_EXPORT const NSNotificationName NSControlTextDidEndEditingNotification;
NSControlAuxiliary *_aux;
id _cell;
NSText *_currentEditor;
BOOL _allowsExpansionToolTips;
BOOL _setsMaxLayoutWidthAtFirstLayout;
BOOL _allowsLogicalLayoutDirection;
}
@property BOOL allowsExpansionToolTips;
@property BOOL allowsLogicalLayoutDirection;
+ (Class) cellClass;
+ (void) setCellClass: (Class) aClass;

View File

@ -27,7 +27,7 @@ typedef enum {
NSGradientDrawsAfterEndingLocation = (1 << 1),
} NSGradientDrawingOptions;
@interface NSGradient : NSObject {
@interface NSGradient : NSObject <NSCopying> {
NSColorSpace *_colorSpace;
NSInteger _numberOfColors;
NSInteger _numberOfComponents;

View File

@ -21,5 +21,12 @@
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/NSString.h>
typedef float NSLayoutPriority;
typedef NS_ENUM(NSInteger, NSLayoutConstraintOrientation) {
NSLayoutConstraintOrientationHorizontal = 0,
NSLayoutConstraintOrientationVertical = 1,
};
APPKIT_EXPORT const CGFloat NSViewNoInstrinsicMetric;
APPKIT_EXPORT const CGFloat NSViewNoIntrinsicMetric;

View File

@ -35,9 +35,12 @@ APPKIT_EXPORT const NSNotificationName NSMenuDidEndTrackingNotification;
NSMutableArray *_itemArray;
BOOL _autoenablesItems;
id<NSMenuDelegate> _delegate;
BOOL _showsStateColumn;
NSUserInterfaceItemIdentifier _identifier;
}
@property BOOL showsStateColumn;
+ (void) popUpContextMenu: (NSMenu *) menu
withEvent: (NSEvent *) event
forView: (NSView *) view;

View File

@ -45,9 +45,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
NSImage *_onStateImage;
NSImage *_offStateImage;
NSImage *_mixedStateImage;
BOOL _alternate;
BOOL _allowsKeyEquivalentWhenHidden;
NSUserInterfaceItemIdentifier _identifier;
}
@property(getter=isAlternate) BOOL alternate;
@property BOOL allowsKeyEquivalentWhenHidden;
+ (NSMenuItem *) separatorItem;
- (instancetype) initWithTitle: (NSString *) title

View File

@ -22,8 +22,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@interface NSTextField : NSControl {
id _delegate;
SEL _errorAction;
CGFloat _preferredMaxLayoutWidth;
}
@property CGFloat preferredMaxLayoutWidth;
- delegate;
- (void) setDelegate: delegate;

View File

@ -30,8 +30,11 @@ typedef enum {
BOOL _drawsBackground;
NSTextFieldBezelStyle _bezelStyle;
id _placeholder;
NSArray<NSString *> *_allowedInputSourceLocales;
}
@property(copy) NSArray<NSString *> *allowedInputSourceLocales;
- (NSColor *) backgroundColor;
- (NSColor *) textColor;
- (BOOL) drawsBackground;

View File

@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSResponder.h>
#import <ApplicationServices/ApplicationServices.h>
#import <AppKit/NSUserInterfaceItemIdentification.h>
#import <AppKit/NSLayoutConstraint.h>
@class NSWindow, NSMenu, NSMenuItem, NSCursor, NSClipView, NSPasteboard,
NSTextInputContext, NSImage, NSBitmapImageRep, NSScrollView,
@ -129,8 +130,16 @@ APPKIT_EXPORT const NSViewFullScreenModeOptionKey NSFullScreenModeApplicationPre
CALayerContext *_layerContext;
id __remove;
NSUserInterfaceItemIdentifier _identifier;
NSLayoutPriority _horizontalContentHuggingPriority;
NSLayoutPriority _verticalContentHuggingPriority;
NSLayoutPriority _horizontalContentCompressionResistancePriority;
NSLayoutPriority _verticalContentCompressionResistancePriority;
BOOL _translatesAutoresizingMaskIntoConstraints;
}
@property(class, readonly) BOOL requiresConstraintBasedLayout;
@property BOOL translatesAutoresizingMaskIntoConstraints;
+ (NSView *) focusView;
+ (NSMenu *) defaultMenu;
+ (NSFocusRingType) defaultFocusRingType;

View File

@ -25,4 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
id _object;
}
@property(copy) NSString *className;
@property(strong, nonatomic) id template;
@end

View File

@ -25,8 +25,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@implementation NSClassSwapper
@synthesize className = _className;
@synthesize template = _object;
// TODO: replace the cell for the object too
- (instancetype) init {
_className = @"NSObject";
return self;
}
- (id) initWithCoder: (NSCoder *) coder {
_className = [[coder decodeObjectForKey: @"NSClassName"] retain];
_originalClassName =
@ -66,6 +74,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
[super dealloc];
}
- (void) setTemplate: (id) template {
[template retain];
[_object release];
_object = template;
// also update the original class name
[_originalClassName release];
_originalClassName = [[_object className] copy];
}
- (void) encodeWithCoder: (NSCoder *) coder {
NSUnimplementedMethod();
}

View File

@ -24,6 +24,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
id extension;
}
@property(copy) NSString *className;
- (id) createCustomInstance;
@end

View File

@ -27,6 +27,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@implementation NSCustomObject
@synthesize className = _className;
- initWithCoder: (NSCoder *) coder {
if ([coder allowsKeyedCoding]) {
NSKeyedUnarchiver *keyed = (NSKeyedUnarchiver *) coder;

View File

@ -34,6 +34,8 @@
#import <Foundation/NSSet.h>
#import <Foundation/NSString.h>
NSString *const IBCocoaFramework = @"IBCocoaFramework";
@interface NSKeyedUnarchiver (private)
- (void) replaceObject: object withObject: replacement;
@end

View File

@ -32,9 +32,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
NSString *const NSNibOwner = @"NSOwner";
NSString *const NSNibTopLevelObjects = @"NSNibTopLevelObjects";
// IB = Interface Builder; i'm guessing this subproject is a good place for it
NSString *const IBCocoaFramework = @"IBCocoaFramework";
@implementation NSNib
- initWithCoder: (NSCoder *) coder {