ObjFW  Check-in [879bf12fd0]

Overview
Comment:Small fix in instance.m.

It's possible the constructor gets called too late, thus the check makes
more sense in objc_constructInstance(). This is safe, because even if
there is a data race, sel_registerName() always returns the same result.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 879bf12fd0bef09c38a4b286b63a93739dfcf00f6b42956f0079f3c1e68545bb
User & Date: js on 2012-10-17 20:39:30
Other Links: manifest | tags
Context
2012-10-18
17:33
Fix missing #else. check-in: 7169decdef user: js tags: trunk
2012-10-17
20:39
Small fix in instance.m. check-in: 879bf12fd0 user: js tags: trunk
20:16
Pass exceptions on async I/O. check-in: 6343e04dcd user: js tags: trunk
Changes

Modified src/instance.m from [36eb4908b4] to [8a19fb2a3a].

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
#include "config.h"

#import "OFObject.h"

static SEL cxx_construct = NULL;
static SEL cxx_destruct = NULL;

static void __attribute__((constructor))
init(void)
{
	if (cxx_construct == NULL)
		cxx_construct = sel_registerName(".cxx_construct");
	if (cxx_destruct == NULL)
		cxx_destruct = sel_registerName(".cxx_destruct");
}

id
objc_constructInstance(Class cls, void *bytes)
{
	id obj = (id)bytes;
	BOOL (*last)(id, SEL) = NULL;

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






	object_setClass(obj, cls);

	/* FIXME: Constructors of superclasses should be called first */
	for (; cls != Nil; cls = class_getSuperclass(cls)) {
		BOOL (*ctor)(id, SEL);

		if (class_respondsToSelector(cls, cxx_construct)) {







<
<
<
<
<
<
<
<
<









>
>
>
>
>







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
#include "config.h"

#import "OFObject.h"

static SEL cxx_construct = NULL;
static SEL cxx_destruct = NULL;










id
objc_constructInstance(Class cls, void *bytes)
{
	id obj = (id)bytes;
	BOOL (*last)(id, SEL) = NULL;

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

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

	object_setClass(obj, cls);

	/* FIXME: Constructors of superclasses should be called first */
	for (; cls != Nil; cls = class_getSuperclass(cls)) {
		BOOL (*ctor)(id, SEL);

		if (class_respondsToSelector(cls, cxx_construct)) {