How does the Objective-C runtime instantiate the root metaclass and other class descriptions?

后端 未结 1 701
渐次进展
渐次进展 2021-01-18 03:59

I\'m trying to implement a basic object-oriented ANSI C runtime and using Objective-C as a guide.

They\'re seems to be three parts. A Class Description, Class Interf

相关标签:
1条回答
  • 2021-01-18 04:28

    The runtime does some initialization via constructor functions that get called before actual program execution. They go by __attribute__((constructor)) in both gcc and clang.

    In the case of Objective-C some of them are embedded in the binary by the compiler. You would have to include them in your headers for similar effect.

    These functions use data automatically embedded by the compiler. They do things such as building hash tables for the class lookup function which are then used for the actual message passing.

    Instances on the other hand are allocated dynamically.

    I am doing something similar, so I don't really know a lot better than that, but this is as deep as I have dug.

    0 讨论(0)
提交回复
热议问题