Differences From Artifact [36eb4908b4]:
- File
src/instance.m
— part of check-in
[16ba7ec477]
at
2012-10-10 10:16:22
on branch trunk
— Provide objc_constructInstance() when necessary.
OS X < 10.6 did not have it, so it is built regardless of the selected
runtime now if objc_constructInstance() hasn't been found. (user: js, size: 1916) [annotate] [blame] [check-ins using]
To Artifact [8a19fb2a3a]:
- File
src/instance.m
— part of check-in
[879bf12fd0]
at
2012-10-17 20:39:30
on branch trunk
— 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. (user: js, size: 1860) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
17 18 19 20 21 22 23 | #include "config.h" #import "OFObject.h" static SEL cxx_construct = NULL; static SEL cxx_destruct = NULL; | < < < < < < < < < > > > > > | 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)) { |
︙ | ︙ |