ObjFW  Check-in [c3e83facc5]

Overview
Comment:Make everything work on macOS Leopard again
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c3e83facc5b775676b0c8959a301376bebefef668e82a6faf7520ac6e845847e
User & Date: js on 2024-02-24 19:40:41
Other Links: manifest | tags
Context
2024-02-24
19:42
runtime: Fix objc_getClassList not unlocking mutex check-in: 39e23d6363 user: js tags: trunk
19:40
Make everything work on macOS Leopard again check-in: c3e83facc5 user: js tags: trunk
17:27
OFLHAArchive: Add support for -pm0- files check-in: f588271db7 user: js tags: trunk
Changes

Modified configure.ac from [914db26e91] to [5be93faa88].

657
658
659
660
661
662
663

664
665
666
667
668
669
670
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671







+








	AC_CHECK_FUNC(objc_autoreleasePoolPush, [], [
		AC_SUBST(RUNTIME_AUTORELEASE_M, "runtime/autorelease.m")
	])
	AC_CHECK_FUNC(objc_constructInstance, [], [
		AC_SUBST(RUNTIME_INSTANCE_M, "runtime/instance.m")
	])
	AC_CHECK_FUNCS(objc_setAssociatedObject)

	OBJCFLAGS="$old_OBJCFLAGS"
	;;
esac

case "$host_os" in
mint*)

Modified src/OFDNSResolver.m from [294ed882f2] to [8ca1f870f4].

874
875
876
877
878
879
880
881
882


883
884
885
886
887
888
889
874
875
876
877
878
879
880


881
882
883
884
885
886
887
888
889







-
-
+
+








	_lastCacheCleanup = now;
	removeList = [OFMutableArray arrayWithCapacity: _cache.count];

	for (OFDNSQuery *query in _cache) {
		OFPair OF_GENERIC(OFDate *, OFDNSResponse *) *entry =
		    [_cache objectForKey: query];
		uint32_t age =
		    (uint32_t)now - [entry.firstObject timeIntervalSince1970];
		uint32_t age = (uint32_t)now -
		    (uint32_t)[entry.firstObject timeIntervalSince1970];
		OFDNSResponse *response = entry.secondObject;

		if (containsExpiredRecord(response.answerRecords, age) ||
		    containsExpiredRecord(response.authorityRecords, age) ||
		    containsExpiredRecord(response.additionalRecords, age))
			[removeList addObject: query];
	}

Modified src/runtime/instance.m from [6c5de971d5] to [bbab5691ed].

98
99
100
101
102
103
104

105

106
107
108
98
99
100
101
102
103
104
105
106
107
108
109
110







+

+



				destruct(object, destructSelector);

			last = destruct;
		} else
			break;
	}

#if defined(OF_OBJFW_RUNTIME) || defined(HAVE_OBJC_SETASSOCIATEDOBJECT)
	objc_removeAssociatedObjects(object);
#endif

	return object;
}

Modified src/test/OTAppDelegate.m from [7e312d3965] to [63fb27780b].

145
146
147
148
149
150
151
152


153
154

155

156
157

158




159
160
161

162
163
164
165
166
167
168

169
170
171
172
173
174
175
176
177


178
179
180
181
182
183
184
145
146
147
148
149
150
151

152
153
154
155
156

157
158
159
160
161
162
163
164
165
166
167

168
169
170
171
172
173
174

175
176
177
178
179
180
181
182


183
184
185
186
187
188
189
190
191







-
+
+


+
-
+


+

+
+
+
+


-
+






-
+







-
-
+
+







	padConfigureInput(1, HidNpadStyleSet_NpadStandard);
	updateConsole(true);
#endif
}

- (OFMutableSet OF_GENERIC(Class) *)testClasses
{
	Class *classes = objc_copyClassList(NULL);
	Class *classes;
	int classesCount;
	OFMutableSet *testClasses;

	classesCount = objc_getClassList(NULL, 0);
	if (classes == NULL)
	if (classesCount < 1)
		return nil;

	classes = OFAllocMemory(classesCount, sizeof(Class));
	@try {
		if ((int)objc_getClassList(classes, classesCount) !=
		    classesCount)
			return nil;

		testClasses = [OFMutableSet set];

		for (Class *iter = classes; *iter != Nil; iter++) {
		for (int i = 0; i < classesCount; i++) {
			/*
			 * Make sure the class is initialized.
			 * Required for the ObjFW runtime, as otherwise
			 * class_getSuperclass() crashes.
			 */
#ifdef OF_OBJFW_RUNTIME
			[*iter class];
			[classes[i] class];
#endif

			/*
			 * Don't use +[isSubclassOfClass:], as the Apple runtime
			 * can return (presumably internal?) classes that don't
			 * implement it, resulting in a crash.
			 */
			if (isSubclassOfClass(*iter, [OTTestCase class]))
				[testClasses addObject: *iter];
			if (isSubclassOfClass(classes[i], [OTTestCase class]))
				[testClasses addObject: classes[i]];
		}
	} @finally {
		OFFreeMemory(classes);
	}

	[testClasses removeObject: [OTTestCase class]];

Modified tests/RuntimeTests.m from [6e0282335c] to [358d865eaa].

82
83
84
85
86
87
88

89
90
91
92
93
94
95
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96







+







	OFMutableString *string = [OFMutableString stringWithString: @"foo"];

	_test.bar = string;
	OTAssertEqual(_test.bar, string);
	OTAssertEqual(string.retainCount, 3);
}

#if defined(OF_OBJFW_RUNTIME) || defined(HAVE_OBJC_SETASSOCIATEDOBJECT)
- (void)testAssociatedObjects
{
	objc_setAssociatedObject(self, testKey, _test, OBJC_ASSOCIATION_ASSIGN);
	OTAssertEqual(_test.retainCount, 1);

	objc_setAssociatedObject(self, testKey, _test, OBJC_ASSOCIATION_RETAIN);
	OTAssertEqual(_test.retainCount, 2);
106
107
108
109
110
111
112

113
114
115
116
117
118
119
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121







+








	OTAssertEqual(objc_getAssociatedObject(self, testKey), _test);
	OTAssertEqual(_test.retainCount, 3);

	objc_removeAssociatedObjects(self);
	OTAssertEqual(_test.retainCount, 2);
}
#endif

#ifdef OF_OBJFW_RUNTIME
- (void)testTaggedPointers
{
	int classID;
	uintmax_t value;
	id object;