Skip to content

Foundation Setup and Foundation Info in the universe

Nat! edited this page Sep 27, 2018 · 3 revisions

See the mulle-objc-runtime Wiki about the big bang

MulleObjC provides the main setup routines for Objective-C Foundation setup during the universe big bang. Inside each universe there is a sizeable chunk of memory allocated for Foundation use. It can be retrieved with _mulle_objc_universe_get_foundationdata and it is S_MULLE_OBJC_UNIVERSE_FOUNDATION_SPACE bytes long (currently 1KB).

This space is used to store a struct _mulle_objc_universefoundationinfo that is used to support the following tasks:

  • reference root objects such as singletons
  • maintain a separate exception vector table that can accept objects as arguments
  • UTF8 to string and back conversion vectors used in _mulle_objc_string and _mulle_objc_characters mainly for supporting exceptions and debugging
  • set the NSAutoreleasePool class
  • maintain some information about threads

struct _mulle_objc_universeconfiguration

MulleObjC uses a function mulle_objc_universe_configure to configure the universe and the foundationinfo contained in the universe. A struct _mulle_objc_universeconfiguration contains all the necessary information for that and gets this information passed during the bang.

So the startup routine __register_mulle_objc_universe calls _mulle_objc_universe_bang which will then call mulle_objc_universe_configure with the default configuration gotten from mulle_objc_global_get_default_universeconfiguration.

Inside this default configuration there is a function pointer to "_mulle_objc_universeconfiguration_configure_universe", which is the eventual setup routine, which does all the work.

Though this could probably be simplified, a lot of this indirection is for more high level libraries to patch into these configuration steps.