1*4fee23f9Smrg 2*4fee23f9SmrgGNU Objective C notes 3*4fee23f9Smrg********************* 4*4fee23f9Smrg 5*4fee23f9SmrgThis document is to explain what has been done, and a little about how 6*4fee23f9Smrgspecific features differ from other implementations. The runtime has 7*4fee23f9Smrgbeen completely rewritten in gcc 2.4. The earlier runtime had several 8*4fee23f9Smrgsevere bugs and was rather incomplete. The compiler has had several 9*4fee23f9Smrgnew features added as well. 10*4fee23f9Smrg 11*4fee23f9SmrgThis is not documentation for Objective C, it is usable to someone 12*4fee23f9Smrgwho knows Objective C from somewhere else. 13*4fee23f9Smrg 14*4fee23f9Smrg 15*4fee23f9SmrgRuntime API functions 16*4fee23f9Smrg===================== 17*4fee23f9Smrg 18*4fee23f9SmrgThe runtime is modeled after the NeXT Objective C runtime. That is, 19*4fee23f9Smrgmost functions have semantics as it is known from the NeXT. The 20*4fee23f9Smrgnames, however, have changed. All runtime API functions have names 21*4fee23f9Smrgof lowercase letters and underscores as opposed to the 22*4fee23f9Smrg`traditional' mixed case names. 23*4fee23f9Smrg The runtime api functions are not documented as of now. 24*4fee23f9SmrgSomeone offered to write it, and did it, but we were not allowed to 25*4fee23f9Smrguse it by his university (Very sad story). We have started writing 26*4fee23f9Smrgthe documentation over again. This will be announced in appropriate 27*4fee23f9Smrgplaces when it becomes available. 28*4fee23f9Smrg 29*4fee23f9Smrg 30*4fee23f9SmrgProtocols 31*4fee23f9Smrg========= 32*4fee23f9Smrg 33*4fee23f9SmrgProtocols are now fully supported. The semantics is exactly as on the 34*4fee23f9SmrgNeXT. There is a flag to specify how protocols should be typechecked 35*4fee23f9Smrgwhen adopted to classes. The normal typechecker requires that all 36*4fee23f9Smrgmethods in a given protocol must be implemented in the class that 37*4fee23f9Smrgadopts it -- it is not enough to inherit them. The flag 38*4fee23f9Smrg`-Wno-protocol' causes it to allow inherited methods, while 39*4fee23f9Smrg`-Wprotocols' is the default which requires them defined. 40*4fee23f9Smrg 41*4fee23f9Smrg 42*4fee23f9Smrg+load 43*4fee23f9Smrg=========== 44*4fee23f9SmrgThis method, if defined, is called for each class and category 45*4fee23f9Smrgimplementation when the class is loaded into the runtime. This method 46*4fee23f9Smrgis not inherited, and is thus not called for a subclass that doesn't 47*4fee23f9Smrgdefine it itself. Thus, each +load method is called exactly once by 48*4fee23f9Smrgthe runtime. The runtime invocation of this method is thread safe. 49*4fee23f9Smrg 50*4fee23f9Smrg 51*4fee23f9Smrg+initialize 52*4fee23f9Smrg=========== 53*4fee23f9Smrg 54*4fee23f9SmrgThis method, if defined, is called before any other instance or class 55*4fee23f9Smrgmethods of that particular class. For the GNU runtime, this method is 56*4fee23f9Smrgnot inherited, and is thus not called as initializer for a subclass that 57*4fee23f9Smrgdoesn't define it itself. Thus, each +initialize method is called exactly 58*4fee23f9Smrgonce by the runtime (or never if no methods of that particular class is 59*4fee23f9Smrgnever called). It is wise to guard against multiple invocations anyway 60*4fee23f9Smrgto remain portable with the NeXT runtime. The runtime invocation of 61*4fee23f9Smrgthis method is thread safe. 62*4fee23f9Smrg 63*4fee23f9Smrg 64*4fee23f9SmrgPassivation/Activation/Typedstreams 65*4fee23f9Smrg=================================== 66*4fee23f9Smrg 67*4fee23f9SmrgThis is supported in the style of NeXT TypedStream's. Consult the 68*4fee23f9Smrgheaderfile Typedstreams.h for api functions. I (Kresten) have 69*4fee23f9Smrgrewritten it in Objective C, but this implementation is not part of 70*4fee23f9Smrg2.4, it is available from the GNU Objective C prerelease archive. 71*4fee23f9Smrg There is one difference worth noting concerning objects stored with 72*4fee23f9Smrgobjc_write_object_reference (aka NXWriteObjectReference). When these 73*4fee23f9Smrgare read back in, their object is not guaranteed to be available until 74*4fee23f9Smrgthe `-awake' method is called in the object that requests that object. 75*4fee23f9SmrgTo objc_read_object you must pass a pointer to an id, which is valid 76*4fee23f9Smrgafter exit from the function calling it (like e.g. an instance 77*4fee23f9Smrgvariable). In general, you should not use objects read in until the 78*4fee23f9Smrg-awake method is called. 79*4fee23f9Smrg 80*4fee23f9Smrg 81*4fee23f9SmrgAcknowledgements 82*4fee23f9Smrg================ 83*4fee23f9Smrg 84*4fee23f9SmrgThe GNU Objective C team: Geoffrey Knauth <gsk@marble.com> (manager), 85*4fee23f9SmrgTom Wood <wood@next.com> (compiler) and Kresten Krab Thorup 86*4fee23f9Smrg<krab@iesd.auc.dk> (runtime) would like to thank a some people for 87*4fee23f9Smrgparticipating in the development of the present GNU Objective C. 88*4fee23f9Smrg 89*4fee23f9SmrgPaul Burchard <burchard@geom.umn.edu> and Andrew McCallum 90*4fee23f9Smrg<mccallum@cs.rochester.edu> has been very helpful debugging the 91*4fee23f9Smrgruntime. Eric Herring <herring@iesd.auc.dk> has been very helpful 92*4fee23f9Smrgcleaning up after the documentation-copyright disaster and is now 93*4fee23f9Smrghelping with the new documentation. 94*4fee23f9Smrg 95*4fee23f9SmrgSteve Naroff <snaroff@next.com> and Richard Stallman 96*4fee23f9Smrg<rms@gnu.ai.mit.edu> has been very helpful with implementation details 97*4fee23f9Smrgin the compiler. 98*4fee23f9Smrg 99*4fee23f9Smrg 100*4fee23f9SmrgBug Reports 101*4fee23f9Smrg=========== 102*4fee23f9Smrg 103*4fee23f9SmrgPlease read the section `Submitting Bugreports' of the gcc manual 104*4fee23f9Smrgbefore you submit any bugs. 105