ObjFW  Check-in [7f1acf9221]

Overview
Comment:Move objc_{con,de}structInstance to runtime
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7f1acf92218812941e4d676ec1a50b4ef29ff1fcdabfe6852616338594d9e31e
User & Date: js on 2020-01-02 01:35:38
Other Links: manifest | tags
Context
2020-01-02
01:51
Update copyright check-in: c7f0229795 user: js tags: trunk
01:35
Move objc_{con,de}structInstance to runtime check-in: 7f1acf9221 user: js tags: trunk
2019-12-27
21:43
OFSecureData: Fix #ifdefs check-in: d5c4dedada user: js tags: trunk
Changes

Modified configure.ac from [5044e32c21] to [1384cb82b0].

626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
			AC_MSG_ERROR([libobjc not found!])
		])
		;;
esac

AC_CHECK_FUNCS(_Unwind_Backtrace)

AC_CHECK_FUNC(objc_constructInstance, [], [
	AC_SUBST(INSTANCE_M, "instance.m")
])

AC_CHECK_FUNC(objc_autoreleasePoolPush, [], [
	AC_SUBST(AUTORELEASE_M, "autorelease.m")
])

case "$host_os" in
	darwin*)
		AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"])







<
<
<
<







626
627
628
629
630
631
632




633
634
635
636
637
638
639
			AC_MSG_ERROR([libobjc not found!])
		])
		;;
esac

AC_CHECK_FUNCS(_Unwind_Backtrace)





AC_CHECK_FUNC(objc_autoreleasePoolPush, [], [
	AC_SUBST(AUTORELEASE_M, "autorelease.m")
])

case "$host_os" in
	darwin*)
		AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"])

Modified src/Makefile from [0e590d4099] to [3a17fda84f].

176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
	    OFLocking.h				\
	    OFMessagePackRepresentation.h	\
	    OFSerialization.h			\
	    OFTLSSocket.h			\
	    ObjFW.h				\
	    autorelease.h			\
	    block.h				\
	    instance.h				\
	    macros.h				\
	    objfw-defs.h			\
	    platform.h				\
	    ${USE_INCLUDES_ATOMIC}

SRCS += OFAdjacentArray.m		\
	OFAdjacentSubarray.m		\







<







176
177
178
179
180
181
182

183
184
185
186
187
188
189
	    OFLocking.h				\
	    OFMessagePackRepresentation.h	\
	    OFSerialization.h			\
	    OFTLSSocket.h			\
	    ObjFW.h				\
	    autorelease.h			\
	    block.h				\

	    macros.h				\
	    objfw-defs.h			\
	    platform.h				\
	    ${USE_INCLUDES_ATOMIC}

SRCS += OFAdjacentArray.m		\
	OFAdjacentSubarray.m		\
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
	OFPointerValue.m		\
	OFRangeCharacterSet.m		\
	OFRangeValue.m			\
	OFRectangleValue.m		\
	OFSubarray.m			\
	OFUTF8String.m			\
	${AUTORELEASE_M}		\
	${INSTANCE_M}			\
	${LIBBASES_M}
SRCS_FILES += OFFileURLHandler.m	\
	      OFINIFileSettings.m
SRCS_SOCKETS += OFDNSResolverSettings.m			\
		OFHTTPURLHandler.m			\
		OFHostAddressResolver.m			\
		OFKernelEventObserver.m			\







<







204
205
206
207
208
209
210

211
212
213
214
215
216
217
	OFPointerValue.m		\
	OFRangeCharacterSet.m		\
	OFRangeValue.m			\
	OFRectangleValue.m		\
	OFSubarray.m			\
	OFUTF8String.m			\
	${AUTORELEASE_M}		\

	${LIBBASES_M}
SRCS_FILES += OFFileURLHandler.m	\
	      OFINIFileSettings.m
SRCS_SOCKETS += OFDNSResolverSettings.m			\
		OFHTTPURLHandler.m			\
		OFHostAddressResolver.m			\
		OFKernelEventObserver.m			\

Modified src/OFObject.m from [507689f6ed] to [6644c9c215].

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

#ifdef OF_AMIGAOS
# include <proto/exec.h>
#endif

#import "OFString.h"

#import "instance.h"
#if defined(OF_HAVE_ATOMIC_OPS)
# import "atomic.h"
#elif defined(OF_HAVE_THREADS)
# import "mutex.h"
#endif

#if defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR)







<







56
57
58
59
60
61
62

63
64
65
66
67
68
69

#ifdef OF_AMIGAOS
# include <proto/exec.h>
#endif

#import "OFString.h"


#if defined(OF_HAVE_ATOMIC_OPS)
# import "atomic.h"
#elif defined(OF_HAVE_THREADS)
# import "mutex.h"
#endif

#if defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR)

Modified src/ObjFW.h from [771661c2a9] to [a8a20bb516].

263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# import "OFCondition.h"
#endif

#import "base64.h"
#import "crc16.h"
#import "crc32.h"
#import "huffman_tree.h"
#import "instance.h"
#import "of_asprintf.h"
#import "of_strptime.h"
#import "pbkdf2.h"
#import "scrypt.h"
#ifdef OF_HAVE_UNICODE_TABLES
# import "unicode.h"
#endif







<







263
264
265
266
267
268
269

270
271
272
273
274
275
276
# import "OFCondition.h"
#endif

#import "base64.h"
#import "crc16.h"
#import "crc32.h"
#import "huffman_tree.h"

#import "of_asprintf.h"
#import "of_strptime.h"
#import "pbkdf2.h"
#import "scrypt.h"
#ifdef OF_HAVE_UNICODE_TABLES
# import "unicode.h"
#endif

Deleted src/instance.h version [41bebb0c3d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
 *               2018, 2019
 *   Jonathan Schleifer <js@heap.zone>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "macros.h"

OF_ASSUME_NONNULL_BEGIN

#ifdef __cplusplus
extern "C" {
#endif
extern id objc_constructInstance(Class _Nullable, void *_Nullable);
extern void *objc_destructInstance(id _Nullable);
#ifdef __cplusplus
}
#endif

OF_ASSUME_NONNULL_END
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































Deleted src/instance.m version [77311e8f90].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
 *               2018, 2019
 *   Jonathan Schleifer <js@heap.zone>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFObject.h"

static SEL constructSelector = NULL;
static SEL destructSelector = NULL;

static bool
callConstructors(Class class, id object)
{
	Class super = class_getSuperclass(class);
	id (*construct)(id, SEL);
	id (*last)(id, SEL);

	if (super != nil)
		if (!callConstructors(super, object))
			return false;

	if (constructSelector == NULL)
		constructSelector = sel_registerName(".cxx_construct");

	if (!class_respondsToSelector(class, constructSelector))
		return true;

	construct = (id (*)(id, SEL))
	    class_getMethodImplementation(class, constructSelector);
	last = (id (*)(id, SEL))
	    class_getMethodImplementation(super, constructSelector);

	if (construct == last)
		return true;

	return (construct(object, constructSelector) != nil);
}

id
objc_constructInstance(Class class, void *bytes)
{
	id object = (id)bytes;

	if (class == Nil || bytes == NULL)
		return nil;

	object_setClass(object, class);

	if (!callConstructors(class, object))
		return nil;

	return object;
}

void *
objc_destructInstance(id object)
{
	Class class;
	void (*last)(id, SEL) = NULL;

	if (object == nil)
		return NULL;

#ifdef OF_OBJFW_RUNTIME
	objc_zero_weak_references(object);
#endif

	if (destructSelector == NULL)
		destructSelector = sel_registerName(".cxx_destruct");

	for (class = object_getClass(object); class != Nil;
	    class = class_getSuperclass(class)) {
		void (*destruct)(id, SEL);

		if (class_respondsToSelector(class, destructSelector)) {
			if ((destruct = (void (*)(id, SEL))
			    class_getMethodImplementation(class,
			    destructSelector)) != last)
				destruct(object, destructSelector);

			last = destruct;
		} else
			break;
	}

	return object;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































Modified src/runtime/Makefile from [461ba255ad] to [c147b029c7].

14
15
16
17
18
19
20

21
22
23
24
25
26
27
SRCS = arc.m			\
       category.m		\
       class.m			\
       dtable.m			\
       exception.m		\
       hashtable.m		\
       init.m			\

       ivar.m			\
       lookup.m			\
       method.m			\
       misc.m			\
       property.m		\
       protocol.m		\
       selector.m		\







>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
SRCS = arc.m			\
       category.m		\
       class.m			\
       dtable.m			\
       exception.m		\
       hashtable.m		\
       init.m			\
       instance.m		\
       ivar.m			\
       lookup.m			\
       method.m			\
       misc.m			\
       property.m		\
       protocol.m		\
       selector.m		\

Modified src/runtime/ObjFWRT.h from [b950544256] to [2ea1bdc677].

144
145
146
147
148
149
150


151
152
153
154
155
156
157
158
extern _Nullable objc_uncaught_exception_handler_t
    objc_setUncaughtExceptionHandler(
    objc_uncaught_exception_handler_t _Nullable handler);
extern void objc_setForwardHandler(IMP _Nullable forward,
    IMP _Nullable stretForward);
extern void objc_setEnumerationMutationHandler(
    objc_enumeration_mutation_handler_t _Nullable handler);


extern void objc_zero_weak_references(id _Nonnull value);

/*
 * Used by the compiler, but can also be called manually.
 *
 * These declarations are also required to prevent Clang's implicit
 * declarations which include __declspec(dllimport) on Windows.
 */







>
>
|







144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
extern _Nullable objc_uncaught_exception_handler_t
    objc_setUncaughtExceptionHandler(
    objc_uncaught_exception_handler_t _Nullable handler);
extern void objc_setForwardHandler(IMP _Nullable forward,
    IMP _Nullable stretForward);
extern void objc_setEnumerationMutationHandler(
    objc_enumeration_mutation_handler_t _Nullable handler);
extern id _Nullable objc_constructInstance(Class _Nullable class_,
    void *_Nullable bytes);
extern void *_Nullable objc_destructInstance(id _Nullable object);

/*
 * Used by the compiler, but can also be called manually.
 *
 * These declarations are also required to prevent Clang's implicit
 * declarations which include __declspec(dllimport) on Windows.
 */

Modified src/runtime/amiga-glue.m from [066d6109b5] to [7339df8c50].

616
617
618
619
620
621
622
623
624
625
626

627
628
629
630
631
632
633
634
635
    objc_enumeration_mutation_handler_t handler)
{
	M68K_ARG(objc_enumeration_mutation_handler_t, handler, a0)

	objc_setEnumerationMutationHandler(handler);
}

void __saveds
glue_objc_zero_weak_references PPC_PARAMS(id value)
{
	M68K_ARG(id, value, a0)


	objc_zero_weak_references(value);
}

void __saveds
glue_objc_exit(void)
{
	objc_exit();
}







|
|

|
>

|







616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
    objc_enumeration_mutation_handler_t handler)
{
	M68K_ARG(objc_enumeration_mutation_handler_t, handler, a0)

	objc_setEnumerationMutationHandler(handler);
}

id __saveds
glue_objc_constructInstance PPC_PARAMS(Class class, void *bytes)
{
	M68K_ARG(Class, class, a0)
	M68K_ARG(void *, bytes, a1)

	return objc_constructInstance(class, bytes);
}

void __saveds
glue_objc_exit(void)
{
	objc_exit();
}
714
715
716
717
718
719
720








    const char *name)
{
	M68K_ARG(objc_property_t, property, a0)
	M68K_ARG(const char *, name, a1)

	return property_copyAttributeValue(property, name);
}















>
>
>
>
>
>
>
>
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
    const char *name)
{
	M68K_ARG(objc_property_t, property, a0)
	M68K_ARG(const char *, name, a1)

	return property_copyAttributeValue(property, name);
}

void *__saveds
glue_objc_destructInstance PPC_PARAMS(id object)
{
	M68K_ARG(id, object, a0)

	return objc_destructInstance(object);
}

Modified src/runtime/amiga-library.m from [947d91885b] to [95fa06b1cc].

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

141
142
143
144
145
146
147
extern const char *glue_protocol_getName(void);
extern bool glue_protocol_isEqual(void);
extern bool glue_protocol_conformsToProtocol(void);
extern objc_uncaught_exception_handler_t
    glue_objc_setUncaughtExceptionHandler(void);
extern void glue_objc_setForwardHandler(void);
extern void glue_objc_setEnumerationMutationHandler(void);
extern void glue_objc_zero_weak_references(void);
extern void glue_objc_exit(void);
extern Ivar *glue_class_copyIvarList(void);
extern const char *glue_ivar_getName(void);
extern const char *glue_ivar_getTypeEncoding(void);
extern ptrdiff_t glue_ivar_getOffset(void);
extern Method *glue_class_copyMethodList(void);
extern SEL glue_method_getName(void);
extern const char *glue_method_getTypeEncoding(void);
extern objc_property_t *glue_class_copyPropertyList(void);
extern const char *glue_property_getName(void);
extern char *glue_property_copyAttributeValue(void);


#ifdef OF_MORPHOS
const ULONG __abox__ = 1;
#endif
struct ExecBase *SysBase;
struct objc_libc libc;
FILE *stdout;







|











>







122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
extern const char *glue_protocol_getName(void);
extern bool glue_protocol_isEqual(void);
extern bool glue_protocol_conformsToProtocol(void);
extern objc_uncaught_exception_handler_t
    glue_objc_setUncaughtExceptionHandler(void);
extern void glue_objc_setForwardHandler(void);
extern void glue_objc_setEnumerationMutationHandler(void);
extern id glue_objc_constructInstance(void);
extern void glue_objc_exit(void);
extern Ivar *glue_class_copyIvarList(void);
extern const char *glue_ivar_getName(void);
extern const char *glue_ivar_getTypeEncoding(void);
extern ptrdiff_t glue_ivar_getOffset(void);
extern Method *glue_class_copyMethodList(void);
extern SEL glue_method_getName(void);
extern const char *glue_method_getTypeEncoding(void);
extern objc_property_t *glue_class_copyPropertyList(void);
extern const char *glue_property_getName(void);
extern char *glue_property_copyAttributeValue(void);
extern void *glue_objc_destructInstance(void);

#ifdef OF_MORPHOS
const ULONG __abox__ = 1;
#endif
struct ExecBase *SysBase;
struct objc_libc libc;
FILE *stdout;
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657

658
659
660
661
662
663
664
	(CONST_APTR)glue_object_getClassName,
	(CONST_APTR)glue_protocol_getName,
	(CONST_APTR)glue_protocol_isEqual,
	(CONST_APTR)glue_protocol_conformsToProtocol,
	(CONST_APTR)glue_objc_setUncaughtExceptionHandler,
	(CONST_APTR)glue_objc_setForwardHandler,
	(CONST_APTR)glue_objc_setEnumerationMutationHandler,
	(CONST_APTR)glue_objc_zero_weak_references,
	(CONST_APTR)glue_objc_exit,
	(CONST_APTR)glue_class_copyIvarList,
	(CONST_APTR)glue_ivar_getName,
	(CONST_APTR)glue_ivar_getTypeEncoding,
	(CONST_APTR)glue_ivar_getOffset,
	(CONST_APTR)glue_class_copyMethodList,
	(CONST_APTR)glue_method_getName,
	(CONST_APTR)glue_method_getTypeEncoding,
	(CONST_APTR)glue_class_copyPropertyList,
	(CONST_APTR)glue_property_getName,
	(CONST_APTR)glue_property_copyAttributeValue,

	(CONST_APTR)-1,
#ifdef OF_MORPHOS
	(CONST_APTR)FUNCARRAY_END
#endif
};
#pragma GCC diagnostic pop








|











>







640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
	(CONST_APTR)glue_object_getClassName,
	(CONST_APTR)glue_protocol_getName,
	(CONST_APTR)glue_protocol_isEqual,
	(CONST_APTR)glue_protocol_conformsToProtocol,
	(CONST_APTR)glue_objc_setUncaughtExceptionHandler,
	(CONST_APTR)glue_objc_setForwardHandler,
	(CONST_APTR)glue_objc_setEnumerationMutationHandler,
	(CONST_APTR)glue_objc_constructInstance,
	(CONST_APTR)glue_objc_exit,
	(CONST_APTR)glue_class_copyIvarList,
	(CONST_APTR)glue_ivar_getName,
	(CONST_APTR)glue_ivar_getTypeEncoding,
	(CONST_APTR)glue_ivar_getOffset,
	(CONST_APTR)glue_class_copyMethodList,
	(CONST_APTR)glue_method_getName,
	(CONST_APTR)glue_method_getTypeEncoding,
	(CONST_APTR)glue_class_copyPropertyList,
	(CONST_APTR)glue_property_getName,
	(CONST_APTR)glue_property_copyAttributeValue,
	(CONST_APTR)glue_objc_destructInstance,
	(CONST_APTR)-1,
#ifdef OF_MORPHOS
	(CONST_APTR)FUNCARRAY_END
#endif
};
#pragma GCC diagnostic pop

Modified src/runtime/amigaos3.sfd from [49f4c1e562] to [4e4fca08ce].

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

84
const char *_Nullable glue_object_getClassName(id _Nullable object)(a0)
const char *_Nonnull glue_protocol_getName(Protocol *_Nonnull protocol)(a0)
bool glue_protocol_isEqual(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2)(a0,a1)
bool glue_protocol_conformsToProtocol(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2)(a0,a1)
_Nullable objc_uncaught_exception_handler_t glue_objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler_t _Nullable handler)(a0)
void glue_objc_setForwardHandler(IMP _Nullable forward, IMP _Nullable stretForward)(a0,a1)
void glue_objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t _Nullable handler)(a0)
void glue_objc_zero_weak_references(id _Nonnull value)(a0)
void glue_objc_exit(void)()
Ivar _Nullable *_Nullable glue_class_copyIvarList(Class _Nullable class_, unsigned int *_Nullable outCount)(a0,a1)
const char *_Nonnull glue_ivar_getName(Ivar _Nonnull ivar)(a0)
const char *_Nonnull glue_ivar_getTypeEncoding(Ivar _Nonnull ivar)(a0)
ptrdiff_t glue_ivar_getOffset(Ivar _Nonnull ivar)(a0)
Method _Nullable *_Nullable glue_class_copyMethodList(Class _Nullable class_, unsigned int *_Nullable outCount)(a0,a1)
SEL _Nonnull glue_method_getName(Method _Nonnull method)(a0)
const char *_Nullable glue_method_getTypeEncoding(Method _Nonnull method)(a0)
objc_property_t _Nullable *_Nullable glue_class_copyPropertyList(Class _Nullable class_, unsigned int *_Nullable outCount)(a0,a1)
const char *_Nonnull glue_property_getName(objc_property_t _Nonnull property)(a0)
char *_Nullable glue_property_copyAttributeValue(objc_property_t _Nonnull property, const char *_Nonnull name)(a0,a1)

==end







|











>

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const char *_Nullable glue_object_getClassName(id _Nullable object)(a0)
const char *_Nonnull glue_protocol_getName(Protocol *_Nonnull protocol)(a0)
bool glue_protocol_isEqual(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2)(a0,a1)
bool glue_protocol_conformsToProtocol(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2)(a0,a1)
_Nullable objc_uncaught_exception_handler_t glue_objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler_t _Nullable handler)(a0)
void glue_objc_setForwardHandler(IMP _Nullable forward, IMP _Nullable stretForward)(a0,a1)
void glue_objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t _Nullable handler)(a0)
id _Nullable glue_objc_constructInstance(Class _Nullable class_, void *_Nullable bytes)(a0,a1)
void glue_objc_exit(void)()
Ivar _Nullable *_Nullable glue_class_copyIvarList(Class _Nullable class_, unsigned int *_Nullable outCount)(a0,a1)
const char *_Nonnull glue_ivar_getName(Ivar _Nonnull ivar)(a0)
const char *_Nonnull glue_ivar_getTypeEncoding(Ivar _Nonnull ivar)(a0)
ptrdiff_t glue_ivar_getOffset(Ivar _Nonnull ivar)(a0)
Method _Nullable *_Nullable glue_class_copyMethodList(Class _Nullable class_, unsigned int *_Nullable outCount)(a0,a1)
SEL _Nonnull glue_method_getName(Method _Nonnull method)(a0)
const char *_Nullable glue_method_getTypeEncoding(Method _Nonnull method)(a0)
objc_property_t _Nullable *_Nullable glue_class_copyPropertyList(Class _Nullable class_, unsigned int *_Nullable outCount)(a0,a1)
const char *_Nonnull glue_property_getName(objc_property_t _Nonnull property)(a0)
char *_Nullable glue_property_copyAttributeValue(objc_property_t _Nonnull property, const char *_Nonnull name)(a0,a1)
void *_Nullable glue_objc_destructInstance(id _Nullable object)(a0)
==end

Added src/runtime/instance.m version [c540a6e694].













































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
 *               2018, 2019
 *   Jonathan Schleifer <js@heap.zone>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "ObjFWRT.h"
#import "private.h"

static SEL constructSelector = NULL;
static SEL destructSelector = NULL;

static bool
callConstructors(Class class, id object)
{
	Class super = class_getSuperclass(class);
	id (*construct)(id, SEL);
	id (*last)(id, SEL);

	if (super != nil)
		if (!callConstructors(super, object))
			return false;

	if (constructSelector == NULL)
		constructSelector = sel_registerName(".cxx_construct");

	if (!class_respondsToSelector(class, constructSelector))
		return true;

	construct = (id (*)(id, SEL))
	    class_getMethodImplementation(class, constructSelector);
	last = (id (*)(id, SEL))
	    class_getMethodImplementation(super, constructSelector);

	if (construct == last)
		return true;

	return (construct(object, constructSelector) != nil);
}

id
objc_constructInstance(Class class, void *bytes)
{
	id object = (id)bytes;

	if (class == Nil || bytes == NULL)
		return nil;

	object_setClass(object, class);

	if (!callConstructors(class, object))
		return nil;

	return object;
}

void *
objc_destructInstance(id object)
{
	Class class;
	void (*last)(id, SEL) = NULL;

	if (object == nil)
		return NULL;

#ifdef OF_OBJFW_RUNTIME
	objc_zero_weak_references(object);
#endif

	if (destructSelector == NULL)
		destructSelector = sel_registerName(".cxx_destruct");

	for (class = object_getClass(object); class != Nil;
	    class = class_getSuperclass(class)) {
		void (*destruct)(id, SEL);

		if (class_respondsToSelector(class, destructSelector)) {
			if ((destruct = (void (*)(id, SEL))
			    class_getMethodImplementation(class,
			    destructSelector)) != last)
				destruct(object, destructSelector);

			last = destruct;
		} else
			break;
	}

	return object;
}

Modified src/runtime/linklib/linklib.m from [df8b8ee743] to [38ecc37c23].

576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593

void
objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t handler)
{
	glue_objc_setEnumerationMutationHandler(handler);
}

void
objc_zero_weak_references(id value)
{
	glue_objc_zero_weak_references(value);
}

void
objc_exit(void)
{
	glue_objc_exit();
}







|
|

|







576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593

void
objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t handler)
{
	glue_objc_setEnumerationMutationHandler(handler);
}

id
objc_constructInstance(Class class, void *_Nullable bytes)
{
	return glue_objc_constructInstance(class, bytes);
}

void
objc_exit(void)
{
	glue_objc_exit();
}
647
648
649
650
651
652
653






}

char *
property_copyAttributeValue(objc_property_t property, const char *name)
{
	return glue_property_copyAttributeValue(property, name);
}













>
>
>
>
>
>
647
648
649
650
651
652
653
654
655
656
657
658
659
}

char *
property_copyAttributeValue(objc_property_t property, const char *name)
{
	return glue_property_copyAttributeValue(property, name);
}

void *
objc_destructInstance(id object)
{
	return glue_objc_destructInstance(object);
}

Modified src/runtime/morphos-clib.h from [ad80976596] to [c45411ce53].

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

const char *glue_object_getClassName(id);
const char *glue_protocol_getName(Protocol *);
bool glue_protocol_isEqual(Protocol *, Protocol *);
bool glue_protocol_conformsToProtocol(Protocol *, Protocol *);
objc_uncaught_exception_handler_t glue_objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler_t);
void glue_objc_setForwardHandler(IMP, IMP);
void glue_objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t);
void glue_objc_zero_weak_references(id);
void glue_objc_exit(void);
Ivar *glue_class_copyIvarList(Class class_, unsigned int *outCount);
const char *glue_ivar_getName(Ivar ivar);
const char *glue_ivar_getTypeEncoding(Ivar ivar);
ptrdiff_t glue_ivar_getOffset(Ivar ivar);
Method *glue_class_copyMethodList(Class class_, unsigned int *outCount);
SEL glue_method_getName(Method method);
const char *glue_method_getTypeEncoding(Method method);
objc_property_t *glue_class_copyPropertyList(Class class_, unsigned int *outCount);
const char *glue_property_getName(objc_property_t property);
char *glue_property_copyAttributeValue(objc_property_t property, const char *name);








|











>
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const char *glue_object_getClassName(id);
const char *glue_protocol_getName(Protocol *);
bool glue_protocol_isEqual(Protocol *, Protocol *);
bool glue_protocol_conformsToProtocol(Protocol *, Protocol *);
objc_uncaught_exception_handler_t glue_objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler_t);
void glue_objc_setForwardHandler(IMP, IMP);
void glue_objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t);
id _Nullable glue_objc_constructInstance(Class class_, void *bytes);
void glue_objc_exit(void);
Ivar *glue_class_copyIvarList(Class class_, unsigned int *outCount);
const char *glue_ivar_getName(Ivar ivar);
const char *glue_ivar_getTypeEncoding(Ivar ivar);
ptrdiff_t glue_ivar_getOffset(Ivar ivar);
Method *glue_class_copyMethodList(Class class_, unsigned int *outCount);
SEL glue_method_getName(Method method);
const char *glue_method_getTypeEncoding(Method method);
objc_property_t *glue_class_copyPropertyList(Class class_, unsigned int *outCount);
const char *glue_property_getName(objc_property_t property);
char *glue_property_copyAttributeValue(objc_property_t property, const char *name);
void *glue_objc_destructInstance(id object);

Modified src/runtime/morphos.fd from [826761c847] to [7d9c1b57f3].

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

80
glue_object_getClassName(object)(sysv,r12base)
glue_protocol_getName(protocol)(sysv,r12base)
glue_protocol_isEqual(protocol1,protocol2)(sysv,r12base)
glue_protocol_conformsToProtocol(protocol1,protocol2)(sysv,r12base)
glue_objc_setUncaughtExceptionHandler(handler)(sysv,r12base)
glue_objc_setForwardHandler(forward,stretForward)(sysv,r12base)
glue_objc_setEnumerationMutationHandler(handler)(sysv,r12base)
glue_objc_zero_weak_references(value)(sysv,r12base)
glue_objc_exit()(sysv,r12base)
glue_class_copyIvarList(class_,outCount)(sysv,r12base)
glue_ivar_getName(ivar)(sysv,r12base)
glue_ivar_getTypeEncoding(ivar)(sysv,r12base)
glue_ivar_getOffset(ivar)(sysv,r12base)
glue_class_copyMethodList(class_,outCount)(sysv,r12base)
glue_method_getName(method)(sysv,r12base)
glue_method_getTypeEncoding(method)(sysv,r12base)
glue_class_copyPropertyList(class_,outCount)(sysv,r12base)
glue_property_getName(property)(sysv,r12base)
glue_property_copyAttributeValue(property,name)(sysv,r12base)

##end







|











>

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
glue_object_getClassName(object)(sysv,r12base)
glue_protocol_getName(protocol)(sysv,r12base)
glue_protocol_isEqual(protocol1,protocol2)(sysv,r12base)
glue_protocol_conformsToProtocol(protocol1,protocol2)(sysv,r12base)
glue_objc_setUncaughtExceptionHandler(handler)(sysv,r12base)
glue_objc_setForwardHandler(forward,stretForward)(sysv,r12base)
glue_objc_setEnumerationMutationHandler(handler)(sysv,r12base)
glue_objc_constructInstance(class_,bytes)(sysv,r12base)
glue_objc_exit()(sysv,r12base)
glue_class_copyIvarList(class_,outCount)(sysv,r12base)
glue_ivar_getName(ivar)(sysv,r12base)
glue_ivar_getTypeEncoding(ivar)(sysv,r12base)
glue_ivar_getOffset(ivar)(sysv,r12base)
glue_class_copyMethodList(class_,outCount)(sysv,r12base)
glue_method_getName(method)(sysv,r12base)
glue_method_getTypeEncoding(method)(sysv,r12base)
glue_class_copyPropertyList(class_,outCount)(sysv,r12base)
glue_property_getName(property)(sysv,r12base)
glue_property_copyAttributeValue(property,name)(sysv,r12base)
glue_objc_destructInstance(object)(sysv,r12base)
##end

Modified src/runtime/private.h from [4747c0153c] to [793195e825].

302
303
304
305
306
307
308

309
310
311
312
313
314
315
    struct objc_dtable *_Nonnull);
extern void objc_dtable_set(struct objc_dtable *_Nonnull, uint32_t,
    IMP _Nullable);
extern void objc_dtable_free(struct objc_dtable *_Nonnull);
extern void objc_dtable_cleanup(void);
extern void objc_init_static_instances(struct objc_symtab *_Nonnull);
extern void objc_forget_pending_static_instances(void);

#ifdef OF_HAVE_THREADS
extern void objc_global_mutex_lock(void);
extern void objc_global_mutex_unlock(void);
extern void objc_global_mutex_free(void);
#else
# define objc_global_mutex_lock()
# define objc_global_mutex_unlock()







>







302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
    struct objc_dtable *_Nonnull);
extern void objc_dtable_set(struct objc_dtable *_Nonnull, uint32_t,
    IMP _Nullable);
extern void objc_dtable_free(struct objc_dtable *_Nonnull);
extern void objc_dtable_cleanup(void);
extern void objc_init_static_instances(struct objc_symtab *_Nonnull);
extern void objc_forget_pending_static_instances(void);
extern void objc_zero_weak_references(id _Nonnull);
#ifdef OF_HAVE_THREADS
extern void objc_global_mutex_lock(void);
extern void objc_global_mutex_unlock(void);
extern void objc_global_mutex_free(void);
#else
# define objc_global_mutex_lock()
# define objc_global_mutex_unlock()