A winter project to update Rik.theme to work with modern ObjC and clang-18.
- Original code relied on categories to override base class method definitions.
- GSTheme "override" mechanism had a bug.
Much of the code used a pattern that looked like the following to override a method in an NSWidget
.
@implementation NSWidget (RikTheme)
- (void) method:(type)foo { ... }
@end
If a base class of NSWidget
implemented the method, this worked because the category essentially adds the method to the class. If NSWidget
implemented the method itself, there was a collision and the result is undefined.
The solution was to use the "override" facility of GSTheme
to override the method in NSWidget
and then to trampoline into the method in the category. Also, by giving it a new name.
The above code then becomes this.
// a forward declaration of the category, now with methods renamed
@interface NSWidget (RikTheme)
- (void) RIKmethod:(type)foo;
@end
// put an override in the Rik class so that GSTheme finds it
@implementation Rik(NSWidget)
- (void) _overrideNSWidgetMethod_method:(type)foo {
(NSWidget*) xself = (NSWidget*)self; // cast self
[xself RIKmethod:foo];
}
@end
@implementation NSWidget (RikTheme)
- (void) RIKmethod:(type)foo { ... }
@end
(Note: This is now fixed in gnustep/libs-gui#325 Jan 2, 2025.)
For the _overrideXXXMethod_yyy
facility to work, GSTheme.m
needs to be fixed.
The following two lines
memcpy(buf, name + 9, (ptr - name) + 9);
buf[(ptr - name) + 9] = '\0';
should be
memcpy(buf, name + 9, (ptr - name) - 9);
buf[(ptr - name) - 9] = '\0';
a gnustep theme based on osx maverick.
UNDER DEVELOPMENT!!
====================
The main theme purpose, is to demonstrate that:
- GNUstep is themable.
- GNUstep can looks modern
- GNUstep is not OPENSTEP, it follows Cocoa, and it is a Cocoa free and open source reimplementation
Soon, more infos. Enjoy!
====================
A pre-release screenshot.