ObjFW  Check-in [8eedb5a39a]

Overview
Comment:OFApplication: Add property for the active sandbox
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8eedb5a39a8f0f7139b972bbfd777e97bba608b007e0e49e5113f6983f64fc46
User & Date: js on 2018-06-30 00:41:19
Other Links: manifest | tags
Context
2018-07-01
15:14
OFSystemInfo: Add ObjFW version check-in: 06cf4cc15f user: js tags: trunk
2018-06-30
00:41
OFApplication: Add property for the active sandbox check-in: 8eedb5a39a user: js tags: trunk
2018-06-27
23:32
platform.h: Add RISC-V check-in: b43e14f47c user: js tags: trunk
Changes

Modified src/OFApplication.h from [b452a90958] to [b60367bda7].

133
134
135
136
137
138
139

140
141
142
143
144
145
146
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147







+







	id <OFApplicationDelegate> _Nullable _delegate;
	void (*_Nullable _SIGINTHandler)(id, SEL);
#ifndef OF_WINDOWS
	void (*_Nullable _SIGHUPHandler)(id, SEL);
	void (*_Nullable _SIGUSR1Handler)(id, SEL);
	void (*_Nullable _SIGUSR2Handler)(id, SEL);
#endif
	OFSandbox *_Nullable _activeSandbox;
}

#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nullable, nonatomic)
    OFApplication *sharedApplication;
@property (class, readonly, nullable, nonatomic) OFString *programName;
@property (class, readonly, nullable, nonatomic)
167
168
169
170
171
172
173





174
175
176
177
178
179
180
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186







+
+
+
+
+








/*!
 * @brief The delegate of the application.
 */
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
    id <OFApplicationDelegate> delegate;

/*!
 * @brief The sandbox currently active for this application.
 */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFSandbox *activeSandbox;

/*!
 * @brief Returns the only OFApplication instance in the application.
 *
 * @return The only OFApplication instance in the application
 */
+ (nullable OFApplication *)sharedApplication;

Modified src/OFApplication.m from [732a9e097e] to [0c7540771a].

143
144
145
146
147
148
149
150

151
152
153
154
155
156
157
143
144
145
146
147
148
149

150
151
152
153
154
155
156
157







-
+







	[delegate release];

	return 0;
}

@implementation OFApplication
@synthesize programName = _programName, arguments = _arguments;
@synthesize environment = _environment;
@synthesize environment = _environment, activeSandbox = _activeSandbox;

+ (OFApplication *)sharedApplication
{
	return app;
}

+ (OFString *)programName
568
569
570
571
572
573
574

575
576
577
578
579
580
581




582
583
584
585
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590







+







+
+
+
+




#ifdef OF_HAVE_SANDBOX
- (void)activateSandbox: (OFSandbox *)sandbox
{
# ifdef OF_HAVE_PLEDGE
	void *pool = objc_autoreleasePoolPush();
	const char *promises = [[sandbox pledgeString]
	    cStringWithEncoding: [OFLocalization encoding]];
	OFSandbox *oldSandbox;

	if (pledge(promises, NULL) != 0)
		@throw [OFSandboxActivationFailedException
		    exceptionWithSandbox: sandbox
				   errNo: errno];

	objc_autoreleasePoolPop(pool);

	oldSandbox = _activeSandbox;
	_activeSandbox = [sandbox retain];
	[oldSandbox release];
# endif
}
#endif
@end