XSLT存档  

不及格的程序员-八神

 查看分类:  ASP.NET XML/XSLT JavaScripT   我的MSN空间Blog
  1 /* Basic data types for Objective C.
  2    Copyright (C) 1993, 1995, 1996, 2004 Free Software Foundation, Inc.
  3 
  4 This file is part of GCC.
  5 
  6 GCC is free software; you can redistribute it and/or modify
  7 it under the terms of the GNU General Public License as published by
  8 the Free Software Foundation; either version 2, or (at your option)
  9 any later version.
 10 
 11 GCC is distributed in the hope that it will be useful,
 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14 GNU General Public License for more details.
 15 
 16 You should have received a copy of the GNU General Public License
 17 along with GCC; see the file COPYING.  If not, write to
 18 the Free Software Foundation, 59 Temple Place - Suite 330,
 19 Boston, MA 02111-1307, USA.  */
 20 
 21 /* As a special exception, if you link this library with files
 22    compiled with GCC to produce an executable, this does not cause
 23    the resulting executable to be covered by the GNU General Public License.
 24    This exception does not however invalidate any other reasons why
 25    the executable file might be covered by the GNU General Public License.  */
 26 
 27 #ifndef __objc_INCLUDE_GNU
 28 #define __objc_INCLUDE_GNU
 29 
 30 #ifdef __cplusplus
 31 extern "C" {
 32 #endif
 33 
 34 #include <stddef.h>
 35 
 36 /*
 37 ** Definition of the boolean type.  
 38 */
 39 #ifdef __vxworks
 40 typedef int BOOL;
 41 #else
 42 typedef unsigned char  BOOL;
 43 #endif
 44 #define YES   (BOOL)1
 45 #define NO    (BOOL)0
 46 
 47 /*
 48 ** Definition of a selector.  Selectors themselves are not unique, but
 49 ** the sel_id is a unique identifier.
 50 */
 51 typedef const struct objc_selector 
 52 {
 53   void *sel_id;
 54   const char *sel_types;
 55 } *SEL;
 56 
 57 inline static BOOL
 58 sel_eq (SEL s1, SEL s2)
 59 {
 60   if (s1 == 0 || s2 == 0)
 61     return s1 == s2;
 62   else
 63     return s1->sel_id == s2->sel_id;
 64 }
 65 
 66 
 67 /*
 68 ** ObjC uses this typedef for untyped instances.
 69 */
 70 typedef struct objc_object {
 71   struct objc_class*  class_pointer;
 72 } *id;
 73 
 74 /*
 75 ** Definition of method type.  When retrieving the implementation of a
 76 ** method, this is type of the pointer returned.  The idea of the
 77 ** definition of IMP is to represent a 'pointer to a general function
 78 ** taking an id, a SEL, followed by other unspecified arguments'.  You
 79 ** must always cast an IMP to a pointer to a function taking the
 80 ** appropriate, specific types for that function, before calling it -
 81 ** to make sure the appropriate arguments are passed to it.  The code
 82 ** generated by the compiler to perform method calls automatically
 83 ** does this cast inside method calls.
 84 */
 85 typedef id (*IMP)(id, SEL, ...); 
 86 
 87 /*
 88 ** More simple types...
 89 */
 90 #define nil (id)0                               /* id of Nil instance */
 91 #define Nil (Class)0                            /* id of Nil class */
 92 typedef char *STR;                              /* String alias */
 93 
 94 /*
 95 ** The compiler generates one of these structures for each class.  
 96 ** 
 97 ** This structure is the definition for classes. 
 98 ** 
 99 ** This structure is generated by the compiler in the executable and used by
100 ** the run-time during normal messaging operations.  Therefore some members
101 ** change type. The compiler generates "char* const" and places a string in
102 ** the following member variables:  super_class. 
103 */
104 typedef struct objc_class *MetaClass;
105 typedef struct objc_class *Class;
106 struct objc_class {     
107   MetaClass           class_pointer;          /* Pointer to the class's
108                                                 meta class. */
109   struct objc_class*  super_class;            /* Pointer to the super 
110                                                 class. NULL for class 
111                                                 Object. */
112   const char*         name;                   /* Name of the class. */
113   long                version;                /* Unknown. */
114   unsigned long       info;                   /* Bit mask.  See class masks 
115                                                 defined above. */
116   long                instance_size;          /* Size in bytes of the class.  
117                                                 The sum of the class 
118                         definition and all super 
119                         class definitions. */
120   struct objc_ivar_list* ivars;               /* Pointer to a structure that
121                                                 describes the instance 
122                                                 variables in the class
123                                                 definition.  NULL indicates
124                                                 no instance variables.  Does
125                                                 not include super class
126                                                 variables. */
127   struct objc_method_list*  methods;          /* Linked list of instance
128                                                 methods defined for the 
129                                                 class. */
130   struct sarray *    dtable;                  /* Pointer to instance 
131                              method dispatch table. */  
132   struct objc_class* subclass_list;           /* Subclasses */
133   struct objc_class* sibling_class;
134 
135   struct objc_protocol_list *protocols;          /* Protocols conformed to */
136   void* gc_object_type;
137 };
138 
139 #ifndef __OBJC__
140 typedef struct objc_protocol {
141   struct objc_class* class_pointer;
142   char *protocol_name;
143   struct objc_protocol_list *protocol_list;
144   struct objc_method_description_list *instance_methods, *class_methods; 
145 } Protocol; 
146 
147 #else /* __OBJC__ */
148 @class Protocol;
149 #endif 
150 
151 typedef void* retval_t;        /* return value */
152 typedef void(*apply_t)(void);    /* function pointer */
153 typedef union arglist {
154   char *arg_ptr;
155   char arg_regs[sizeof (char*)];
156 } *arglist_t;            /* argument frame */
157 
158 
159 IMP objc_msg_lookup(id receiver, SEL op);
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #endif /* not __objc_INCLUDE_GNU */
 1 struct objc_class {
 2 
 3     struct objc_class super_class;  /*父类*/
 4 
 5     const char *name;                 /*类名字*/
 6 
 7     long version;                   /*版本信息*/
 8 
 9     long info;                        /*类信息*/
10 
11     long instance_size;               /*实例大小*/
12 
13     struct objc_ivar_list *ivars;     /*实例参数链表*/
14 
15     struct objc_method_list **methodLists;  /*方法链表*/
16 
17     struct objc_cache *cache;               /*方法缓存*/
18 
19     struct objc_protocol_list *protocols;   /*协议链表*/
20 
21 };
 1 typedef struct objc_method *Method;
 2 
 3 typedef struct objc_ method {
 4 
 5     SEL method_name;
 6 
 7     char *method_types;
 8 
 9     IMP method_imp;
10 
11 };
 1 void (*setter)(id, SEL, BOOL);
 2 
 3 int i;
 4 
 5  
 6 
 7 setter = (void(*)(id, SEL, BOOL))[target methodForSelector:@selector(setFilled:)];
 8 
 9  
10 
11 for (i = 0; i < 1000; i++)
12 
13     setter(targetList[i], @selector(setFilled:), YES);

 

posted on 2013-01-31 09:43  不及格的程序员-八神  阅读(540)  评论(0编辑  收藏  举报