Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2026-11-22 Gregory John Casamento <greg.casamento@gmail.com>

* Source/NSObjectScripting.m: Provide dummy implementations of the
methods.
* Headers/Foundation/NSObjectScripting.h: Properly declare the category
on NSObject.

2026-11-19 Richard Frith-Macdonald <rfm@gnu.org>

* Source/GSTLS.m:
Expand Down
6 changes: 6 additions & 0 deletions Documentation/ReleaseNotes.gsdoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ notice and this notice are preserved.
<section>
<heading>Version 1.32.0</heading>
<p>
<strong>NSObjectScripting:</strong>
Replaced the erroneous empty NSObjectScripting class with Cocoa's
NSScripting category on NSObject and its method declarations.
The methods remain unimplemented and raise exceptions unless
overridden. Code using the former placeholder class must use
NSObject instead and be rebuilt.
</p>

<p>
Expand Down
35 changes: 32 additions & 3 deletions Headers/Foundation/NSObjectScripting.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**Definition of class NSObjectScripting
/** Scripting additions to NSObject
Copyright (C) 2019 Free Software Foundation, Inc.

By: Gregory John Casamento <greg.casamento@gmail.com>
Expand Down Expand Up @@ -32,8 +32,37 @@
extern "C" {
#endif

GS_EXPORT_CLASS
@interface NSObjectScripting : NSObject
@class NSDictionary, NSScriptObjectSpecifier, NSString;

/**
* Cocoa scripting hooks for scriptable objects. These methods are currently
* unimplemented in GNUstep and raise an exception unless overridden.
*/
@interface NSObject (NSScripting)

#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
/** Returns the receiver's scriptable properties. */
- (NSDictionary *) scriptingProperties;

/** Sets the supplied scriptable properties of the receiver. */
- (void) setScriptingProperties: (NSDictionary *)properties;
#endif

#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
/** Evaluates an object specifier in the receiving container. */
- (id) scriptingValueForSpecifier: (NSScriptObjectSpecifier *)objectSpecifier;

/** Copies a scripting value and sets the supplied properties on the copies. */
- (id) copyScriptingValue: (id)value
forKey: (NSString *)key
withProperties: (NSDictionary *)properties;

/** Creates a scriptable object with the supplied contents and properties. */
- (id) newScriptingObjectOfClass: (Class)objectClass
forValueForKey: (NSString *)key
withContentsValue: (id)contentsValue
properties: (NSDictionary *)properties;
#endif

@end

Expand Down
35 changes: 33 additions & 2 deletions Source/NSObjectScripting.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Implementation of class NSObjectScripting
/* Implementation of NSObject scripting additions
Copyright (C) 2019 Free Software Foundation, Inc.

By: heron
Expand All @@ -22,8 +22,39 @@
*/

#import "Foundation/NSObjectScripting.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"

@implementation NSObjectScripting
@implementation NSObject (NSScripting)

- (NSDictionary *) scriptingProperties
{
return [self notImplemented: _cmd];
}

- (void) setScriptingProperties: (NSDictionary *)properties
{
[self notImplemented: _cmd];
}

- (id) scriptingValueForSpecifier: (NSScriptObjectSpecifier *)objectSpecifier
{
return [self notImplemented: _cmd];
}

- (id) copyScriptingValue: (id)value
forKey: (NSString *)key
withProperties: (NSDictionary *)properties
{
return [self notImplemented: _cmd];
}

- (id) newScriptingObjectOfClass: (Class)objectClass
forValueForKey: (NSString *)key
withContentsValue: (id)contentsValue
properties: (NSDictionary *)properties
{
return [self notImplemented: _cmd];
}

@end

52 changes: 52 additions & 0 deletions Tests/base/NSObject/scripting.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#import <Foundation/NSObjectScripting.h>
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSException.h>
#import <Foundation/NSString.h>
#import "Testing.h"

@interface ScriptingObject : NSObject

@end

@implementation ScriptingObject

@end

int
main (void)
{
ENTER_POOL
ScriptingObject *object = AUTORELEASE([[ScriptingObject alloc] init]);

PASS(NSClassFromString(@"NSObjectScripting") == Nil,
"NSObjectScripting is not a standalone class");
PASS([object respondsToSelector: @selector(scriptingProperties)]
&& [object respondsToSelector: @selector(setScriptingProperties:)]
&& [object respondsToSelector: @selector(scriptingValueForSpecifier:)]
&& [object respondsToSelector:
@selector(copyScriptingValue:forKey:withProperties:)]
&& [object respondsToSelector:
@selector(newScriptingObjectOfClass:forValueForKey:withContentsValue:properties:)],
"NSObject subclasses inherit Cocoa's scripting category methods");

#ifdef GNUSTEP
PASS_EXCEPTION([object scriptingProperties], NSInvalidArgumentException,
"unimplemented scriptingProperties raises an exception");
PASS_EXCEPTION([object setScriptingProperties: nil], NSInvalidArgumentException,
"unimplemented setScriptingProperties: raises an exception");
PASS_EXCEPTION([object scriptingValueForSpecifier: nil],
NSInvalidArgumentException,
"unimplemented specifier evaluation raises an exception");
PASS_EXCEPTION([object copyScriptingValue: nil forKey: @"items"
withProperties: nil], NSInvalidArgumentException,
"unimplemented scripting copy raises an exception");
PASS_EXCEPTION([object newScriptingObjectOfClass: [NSObject class]
forValueForKey: @"items" withContentsValue: nil properties: nil],
NSInvalidArgumentException,
"unimplemented scripting creation raises an exception");
#endif

LEAVE_POOL
return 0;
}

1 change: 0 additions & 1 deletion Tools/classes.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
"NSNumber",
"NSNumberFormatter",
"NSObject",
"NSObjectScripting",
"NSOperation",
"NSOperationQueue",
"NSOrderedSet",
Expand Down
Loading