Objective-C underlying data structure

Source: Internet
Author: User
Objective-C underlying data structure

Objective-C underlying data structure

Class Data Structure

Class (pointer)
Typedef struct objc_class * class;/* this is the data structure generated by the compiler for each class. This structure defines a class. this structure is generated by the compiler during execution and used to send messages during runtime. therefore, some members change the type. the compiler generates a "char * const" string pointer instead of the following member variable "super_class" */struct objc_class {struct objc_class * class_pointer;/* pointer to the metaclass. */struct objc_class * super_class;/* pointer to the parent class. nsobject is null. */const char * Name;/* class name. */long version;/* unknown. */unsigned long Info;/* bit mask. refer to the mask definition of the following class. */long instance_size;/* number of bytes of the class. includes the definition of classes and all parent classes */# ifdef _ win64 long pad; # endif struct objc_ivar_list * ivars;/* points to the list structure of instance variables defined in the class. null indicates that no instance variable exists. does not include the variables of the parent class. */struct objc_method_list * methods;/* The instance method defined in the Link class. */struct sarray * dtable;/* points to the instance method allocation table. */struct objc_class * subclass_list;/* parent class list */struct objc_class * sibling_class; struct objc_protocol_list * protocols;/* Target prototype list */void * gc_object_type ;};
Method (pointer)
Typedef struct objc_method * method;/* the compiler generates one or more such structures for the class based on the methods defined in the class. the implementation of a class can be dispersed in different parts of a file, and classes can be dispersed in different modules. to solve this problem, use a separate method linked list */struct objc_method {sel method_name;/* this variable is the name of the method. the compiler uses a 'Char * 'here. When a method is registered, the name is replaced by a real sel */const char * method_types during runtime; /* List of parameters used to describe the method. used when the selector is registered at runtime. at that time, the method name will contain a list of parameters of the method. */IMP method_imp;/* address of the method execution. */};
Ivar (pointer)
Typedef struct objc_ivar * Ivar;/* the compiler generates one or more such structures for the Class Based on the instance variables defined in the class */struct objc_ivar {const char * ivar_name; /* variable name defined in the class. */const char * ivar_type;/* describes the variable type. debugging is very useful. */INT ivar_offset;/* base address offset byte of the Instance structure */};
Category (pointer)
Typedef struct objc_category * category;/* the compiler generates such a structure for each category. A class can have multiple classes, including both the instance method and the class Method */struct objc_category {const char * category_name;/* class name. define */const char * class_name;/* class name */struct objc_method_list * instance_methods;/* The instance method defined in the Link class. null indicates no instance method. */struct objc_method_list * class_methods;/* class methods defined in the Link class. null indicates no class method. */struct objc_protocol_list * protocols;/* protocol table */};
Objc_property_t
typedef struct objc_property *objc_property_t;
IMP
id (*IMP)(id, SEL, ...)
Sel
typedef struct objc_selector *SEL;  struct objc_selector{  void *sel_id;  const char *sel_types;};
Objc_method_list
Struct objc_method_list {struct objc_method_list * method_next;/* this variable is used to link another independent method linked list */INT method_count; /* Number of methods defined in the Structure */struct objc_method method_list [1];/* variable length structure */};
Objc_cache
struct objc_cache{    unsigned int mask;    unsigned int occupied;    Method buckets[1];};
Objc_protocol_list
struct objc_protocol_list{  struct objc_protocol_list *next;  size_t count;  struct objc_protocol *list[1];};
Data Structure ID of the Instance
typedef struct objc_object *id;
Objc_object
Struct objc_object {/* class pointer is an object-related class. If it is a class object, this pointer points to the Meta class. Class ISA ;};
Objc_super
Struct objc_super {ID self;/* receiver of the Message */class super_class;/* parent class of the receiver */};

Previous

Objective-C underlying data structure

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.