]> git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/c++/OSMetaClass.h
9bfd3475cf0c33a54e42f3ee1cde8e94d6f00c24
[apple/xnu.git] / libkern / libkern / c++ / OSMetaClass.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 #ifndef _LIBKERN_OSMETACLASS_H
23 #define _LIBKERN_OSMETACLASS_H
24
25 #include <sys/types.h>
26
27 #include <libkern/OSReturn.h>
28
29 class OSMetaClass;
30 class OSObject;
31 class OSString;
32 class OSSymbol;
33 class OSDictionary;
34 class OSSerialize;
35
36 class OSMetaClassBase
37 {
38 public:
39 /*! @function OSTypeID
40 @abstract Given the name of a class return it's typeID
41 @param type Name of the desired type, eg. OSObject.
42 @result 'this' if object is of desired type, otherwise 0.
43 */
44 #define OSTypeID(type) (type::metaClass)
45
46 /*! @function OSTypeIDInst
47 @abstract Given a pointer to an object return it's typeID
48 @param typeinst An instance of an OSObject subclass.
49 @result The typeID, ie. OSMetaClass *.
50 */
51 #define OSTypeIDInst(typeinst) ((typeinst)->getMetaClass())
52
53 /*! @function OSDynamicCast
54 @abstract Roughly analogous to (type *) inst, but check if valid first.
55 @discussion OSDynamicCast is an attempt to implement a rudimentary equivalent to rtti's dynamic_cast<T> operator. Embedded-C++ doesn't allow the use of rtti. OSDynamicCast is build on the OSMetaClass mechanism. Note it is safe to call this with a 0 parameter.
56 @param type name of desired class name. Notice that it is assumed that you desire to cast to a pointer to an object of this type. Also type qualifiers, like const, are not recognized and will cause an, usually obscure, compile error.
57 @param inst Pointer to object that you wish to attempt to type cast. May be 0.
58 @result inst if object non-zero and it is of the desired type, otherwise 0.
59 */
60 #define OSDynamicCast(type, inst) \
61 ((type *) OSMetaClassBase::safeMetaCast((inst), OSTypeID(type)))
62
63 /*! @function OSCheckTypeInst
64 @abstract Is the target object a subclass of the reference object?
65 @param typeinst Reference instance of an object, desired type.
66 @param inst Instance of object to check for type compatibility.
67 @result false if typeinst or inst are 0 or inst is not a subclass of typeinst's class. true otherwise.
68 */
69 #define OSCheckTypeInst(typeinst, inst) \
70 OSMetaClassBase::checkTypeInst(inst, typeinst)
71
72
73 protected:
74 OSMetaClassBase();
75 virtual ~OSMetaClassBase();
76
77 private:
78 // Disable copy constructors of OSMetaClassBase based objects
79 /*! @function operator =
80 @abstract Disable implicit copy constructor by making private
81 @param src Reference to source object that isn't allowed to be copied
82 */
83 void operator =(OSMetaClassBase &src);
84
85 /*! @function OSMetaClassBase
86 @abstract Disable implicit copy constructor by making private
87 @param src Reference to source object that isn't allowed to be copied
88 */
89 OSMetaClassBase(OSMetaClassBase &src);
90
91 public:
92 /*! @function release
93 @abstract Primary implementation of the release mechanism.
94 @discussion If $link retainCount <= the when argument then call $link free(). This indirect implementation of $link release allows the developer to break reference circularity. An example of this sort of problem is a parent/child mutual reference, either the parent or child can implement: void release() { release(2); } thus breaking the cirularity.
95 @param when When retainCount == when then call free(). */
96 virtual void release(int when) const = 0;
97
98 /*! @function getRetainCount
99 @abstract How many times has this object been retained?
100 @result Current retain count
101 */
102 virtual int getRetainCount() const = 0;
103
104 /*! @function retain
105 @abstract Retain a reference in this object.
106 */
107 virtual void retain() const = 0;
108 /*! @function release
109 @abstract Release a reference to this object
110 */
111 virtual void release() const = 0;
112
113 /*! @function serialize
114 @abstract
115 @discussion
116 @param s
117 @result
118 */
119 virtual bool serialize(OSSerialize *s) const = 0;
120
121 virtual const OSMetaClass * getMetaClass() const = 0;
122
123 /*! @function isEqualTo
124 @abstract Is this == anObj?
125 @discussion OSMetaClassBase::isEqualTo implements this as a shallow pointer comparison. The OS container classes do a more meaningful comparison. Your mileage may vary.
126 @param anObj Object to compare 'this' to.
127 @result true if the objects are equivalent, false otherwise.
128 */
129 virtual bool isEqualTo(const OSMetaClassBase *anObj) const;
130
131 /*! @function metaCast
132 @abstract Check to see if this object is or inherits from the given type.
133 @discussion This function is the guts of the OSMetaClass system. IODynamicCast, qv, is implemented using this function.
134 @param toMeta Pointer to a constant OSMetaClass for the desired target type.
135 @result 'this' if object is of desired type, otherwise 0.
136 */
137 OSMetaClassBase *metaCast(const OSMetaClass *toMeta) const;
138
139
140 /*! @function metaCast
141 @abstract See OSMetaClassBase::metaCast(const OSMetaClass *)
142 @param toMeta OSSymbol of the desired class' name.
143 @result 'this' if object is of desired type, otherwise 0.
144 */
145 OSMetaClassBase *metaCast(const OSSymbol *toMeta) const;
146
147 /*! @function metaCast
148 @abstract See OSMetaClassBase::metaCast(const OSMetaClass *)
149 @param toMeta OSString of the desired class' name.
150 @result 'this' if object is of desired type, otherwise 0.
151 */
152 OSMetaClassBase *metaCast(const OSString *toMeta) const;
153
154 /*! @function metaCast
155 @abstract See OSMetaClassBase::metaCast(const OSMetaClass *)
156 @param toMeta const char * C String of the desired class' name.
157 @result 'this' if object is of desired type, otherwise 0.
158 */
159 OSMetaClassBase *metaCast(const char *toMeta) const;
160
161 // Helper inlines for runtime type preprocessor macros
162 static OSMetaClassBase *
163 safeMetaCast(const OSMetaClassBase *me, const OSMetaClass *toType)
164 { return (me)? me->metaCast(toType) : 0; }
165
166 static bool
167 checkTypeInst(const OSMetaClassBase *inst, const OSMetaClassBase *typeinst)
168 {
169 const OSMetaClass *toType = OSTypeIDInst(typeinst);
170 return typeinst && inst && (0 != inst->metaCast(toType));
171 }
172
173 private:
174 // Virtual Padding
175 virtual void _RESERVEDOSMetaClassBase0();
176 virtual void _RESERVEDOSMetaClassBase1();
177 virtual void _RESERVEDOSMetaClassBase2();
178 virtual void _RESERVEDOSMetaClassBase3();
179 virtual void _RESERVEDOSMetaClassBase4();
180 virtual void _RESERVEDOSMetaClassBase5();
181 virtual void _RESERVEDOSMetaClassBase6();
182 virtual void _RESERVEDOSMetaClassBase7();
183 };
184
185 /*!
186 @class OSMetaClass : OSMetaClassBase
187 @abstract An instance of a OSMetaClass represents one class then the kernel's runtime type information system is aware of.
188 */
189 class OSMetaClass : private OSMetaClassBase
190 {
191
192 private:
193 static void *operator new(size_t size);
194
195 struct ExpansionData { };
196
197 /*! @var reserved Reserved for future use. (Internal use only) */
198 ExpansionData *reserved;
199
200 /*! @var superClass Handle to the superclass' meta class. */
201 const OSMetaClass *superClassLink;
202
203 /*! @var className OSSymbol of the class' name. */
204 const OSSymbol *className;
205
206 /*! @var classSize How big is a single instancde of this class. */
207 unsigned int classSize;
208
209 /*! @var instanceCount Roughly number of instances of the object. Used primarily as a code in use flag. */
210 mutable unsigned int instanceCount;
211
212 /*! @function OSMetaClass
213 @abstract Private the default constructor */
214 OSMetaClass();
215
216 // Called by postModLoad
217 /*! @function logError
218 @abstract Given an error code log an error string using printf */
219 static void logError(OSReturn result);
220
221 /*! @function getMetaClassWithName
222 @abstract Lookup a meta-class in the runtime type information system
223 @param name Name of the desired class's meta-class.
224 @result pointer to a meta-class object if found, 0 otherwise. */
225
226 static const OSMetaClass *getMetaClassWithName(const OSSymbol *name);
227
228 protected:
229 /*! @function retain
230 @abstract Implement abstract but should no dynamic allocation is allowed */
231 virtual void retain() const;
232
233 /*! @function release
234 @abstract Implement abstract but should no dynamic allocation is allowed */
235 virtual void release() const;
236
237 /*! @function release
238 @abstract Implement abstract but should no dynamic allocation is allowed
239 @param when ignored. */
240 virtual void release(int when) const;
241
242 /*! @function getRetainCount
243 @abstract Implement abstract but should no dynamic allocation is allowed */
244 virtual int getRetainCount() const;
245
246 virtual const OSMetaClass * getMetaClass() const;
247
248 /*! @function OSMetaClass
249 @abstract Constructor for OSMetaClass objects
250 @discussion This constructor is protected and cannot not be used to instantiate an OSMetaClass object, i.e. OSMetaClass is an abstract class. This function stores the currently constructing OSMetaClass instance away for later processing. See preModLoad and postModLoad.
251 @param inClassName cString of the name of the class this meta-class represents.
252 @param inSuperClassName cString of the name of the super class.
253 @param inClassSize sizeof the class. */
254 OSMetaClass(const char *inClassName,
255 const OSMetaClass *inSuperClass,
256 unsigned int inClassSize);
257
258 /*! @function ~OSMetaClass
259 @abstract Destructor for OSMetaClass objects
260 @discussion If this function is called it means that the object code that implemented this class is actually in the process of unloading. The destructor removes all reference's to the subclass from the runtime type information system. */
261 virtual ~OSMetaClass();
262
263 static void operator delete(void *mem, size_t size);
264
265 public:
266 static const OSMetaClass * const metaClass;
267
268 /*! @function preModLoad
269 @abstract Prepare the runtime type system for the load of a module.
270 @discussion Prepare the runtime type information system for the loading of new all meta-classes constructed between now and the next postModLoad. preModLoad grab's a lock so that the runtime type information system loading can be protected, the lock is released by the postModLoad function. Any OSMetaClass that is constructed between the bracketing pre and post calls will be assosiated with the module name.
271 @param kmodName globally unique cString name of the kernel module being loaded.
272 @result If success full return a handle to be used in later calls 0 otherwise. */
273 static void *preModLoad(const char *kmodName);
274
275 /*! @function failModLoad
276 @abstract Record an error during the loading of an kernel module.
277 @discussion As constructor's can't return errors nor can they through exceptions in embedded-c++ an indirect error mechanism is necessary. Check mod load returns a bool to indicate the current error state of the runtime type information system. During object construction a call to failModLoad will cause an error code to be recorded. Once an error has been set the continuing construction will be ignored until the end of the pre/post load.
278 @param error Code of the error. */
279 static void failModLoad(OSReturn error);
280
281 /*! @function checkModLoad
282 @abstract Check if the current load attempt is still OK.
283 @param loadHandle Handle returned when a successful call to preModLoad is made.
284 @result true if no error's are outstanding and the system is primed to recieve more objects. */
285 static bool checkModLoad(void *loadHandle);
286
287 /*! @function postModLoad
288 @abstract Finish postprocessing on a kernel module's meta-classes.
289 @discussion As the order of static object construction is undefined it is necessary to process the constructors in two phases. These phases rely on global information that is created be the preparation step, preModLoad, which also guarantees single threading between multiple modules. Phase one was the static construction of each meta-class object one by one withing the context prepared by the preModLoad call. postModLoad is the second phase of processing. Inserts links all of the super class inheritance chains up, inserts the meta-classes into the global register of classes and records for each meta-class which kernel module caused it's construction. Finally it cleans up the temporary storage and releases the single threading lock and returns whatever error has been recorded in during the construction phase or the post processing phase.
290 @param loadHandle Handle returned when a successful call to preModLoad is made.
291 @result Error code of the first error encountered. */
292 static OSReturn postModLoad(void *loadHandle);
293
294 /*! @function modHasInstance
295 @abstract Do any of the objects represented by OSMetaClass and associated with the given kernel module name have instances?
296 @discussion Check all meta-classes associated with the module name and check their instance counts. This function is used to check to see if a module can be unloaded. Obviously if an instance is still outstanding it isn't safe to unload the code that relies on that object.
297 @param kmodName cString of the kernel module name.
298 @result true if there are any current instances of any class in the module.
299 */
300 static bool modHasInstance(const char *kmodName);
301
302 /*! @function reportModInstances
303 @abstract Log any object that has instances in a module.
304 @discussion When a developer ask for a module to be unloaded but the unload fails due to outstanding instances. This function will report which classes still have instances. It is intended mostly for developers to find problems with unloading classes and will be called automatically by 'verbose' unloads.
305 @param kmodName cString of the kernel module name. */
306 static void reportModInstances(const char *kmodName);
307
308 /*! @function considerUnloads
309 @abstract Schedule module unloading.
310 @discussion Schedule unused modules to be unloaded; called when IOKit matching goes idle. */
311
312 static void considerUnloads();
313
314 /*! @function allocClassWithName
315 @abstract Lookup a meta-class in the runtime type information system and return the results of an alloc call.
316 @param name Name of the desired class.
317 @result pointer to an new object, 0 if not found or so memory. */
318 static OSObject *allocClassWithName(const OSSymbol *name);
319
320 /*! @function allocClassWithName
321 @abstract Lookup a meta-class in the runtime type information system and return the results of an alloc call.
322 @param name Name of the desired class.
323 @result pointer to an new object, 0 if not found or so memory. */
324 static OSObject *allocClassWithName(const OSString *name);
325
326 /*! @function allocClassWithName
327 @abstract Lookup a meta-class in the runtime type information system and return the results of an alloc call.
328 @param name Name of the desired class.
329 @result pointer to an new object, 0 if not found or so memory. */
330 static OSObject *allocClassWithName(const char *name);
331
332 /*! @function checkMetaCastWithName
333 @abstract Introspect an objects inheritance tree looking for a class of the given name. Basis of MacOSX's kernel dynamic casting mechanism.
334 @param name Name of the desired class or super class.
335 @param in object to be introspected.
336 @result in parameter if cast valid, 0 otherwise. */
337 static OSMetaClassBase *
338 checkMetaCastWithName(const OSSymbol *name, const OSMetaClassBase *in);
339
340 /*! @function checkMetaCastWithName
341 @abstract Introspect an objects inheritance tree looking for a class of the given name. Basis of MacOSX's kernel dynamic casting mechanism.
342 @param name Name of the desired class or super class.
343 @param in object to be introspected.
344 @result in parameter if cast valid, 0 otherwise. */
345 static OSMetaClassBase *
346 checkMetaCastWithName(const OSString *name, const OSMetaClassBase *in);
347
348 /*! @function checkMetaCastWithName
349 @abstract Introspect an objects inheritance tree looking for a class of the given name. Basis of MacOSX's kernel dynamic casting mechanism.
350 @param name Name of the desired class or super class.
351 @param in object to be introspected.
352 @result in parameter if cast valid, 0 otherwise. */
353 static OSMetaClassBase *
354 checkMetaCastWithName(const char *name, const OSMetaClassBase *in);
355
356
357 /*! @function instanceConstructed
358 @abstract Counts the instances of the class behind this metaclass.
359 @discussion Every non-abstract class that inherits from OSObject has a default constructor that calls it's own meta-class' instanceConstructed function. This constructor is defined by the OSDefineMetaClassAndStructors macro (qv) that all OSObject subclasses must use. Also if the instance count goes from 0 to 1, ie the first instance, then increment the instance count of the super class */
360 void instanceConstructed() const;
361
362 /*! @function instanceDestructed
363 @abstract Removes one instance of the class behind this metaclass.
364 @discussion OSObject's free function calls this method just before it does a 'delete this' on itself. If the instance count transitions from 1 to 0, i.e. the last object, then one instance of the superclasses is also removed. */
365 void instanceDestructed() const;
366
367
368 /*! @function checkMetaCast
369 @abstract Ask a OSMetaClass instance if the given object is either an instance of it or an instance of a subclass of it.
370 @param check Pointer of object to introspect.
371 @result check parameter if cast valid, 0 otherwise. */
372 OSMetaClassBase *checkMetaCast(const OSMetaClassBase *check) const;
373
374
375 /*! @function getInstanceCount
376 @abstract How many instances of the class have been created.
377 @result Count of the number of instances. */
378 unsigned int getInstanceCount() const;
379
380
381 /*! @function getSuperClass
382 @abstract 'Get'ter for the super class.
383 @result Pointer to superclass, chain ends with 0 for OSObject. */
384 const OSMetaClass *getSuperClass() const;
385
386 /*! @function getClassName
387 @abstract 'Get'ter for class name.
388 @result cString of the class name. */
389 const char *getClassName() const;
390
391 /*! @function getClassSize
392 @abstract 'Get'ter for sizeof(class).
393 @result sizeof of class that this OSMetaClass instance represents. */
394 unsigned int getClassSize() const;
395
396 /*! @function alloc
397 @abstract Allocate an instance of the class that this OSMetaClass instance represents.
398 @discussion This alloc function is analogous to the old ObjC class alloc method. Typically not used by clients as the static function allocClassWithName is more generally useful. Infact that function is implemented in terms of this virtual function. All subclass's of OSMetaClass must implement this function but that is what the OSDefineMetaClassAndStructor's families of macros does for the developer automatically.
399 @result Pointer to a new object with a retain count of 1. */
400 virtual OSObject *alloc() const = 0;
401
402 /*! @function OSDeclareCommonStructors
403 @abstract Basic helper macro for the OSDeclare for Default and Abstract macros, qv. DO NOT USE.
404 @param className Name of class. NO QUOTES. */
405 #define OSDeclareCommonStructors(className) \
406 private: \
407 static const OSMetaClass * const superClass; \
408 public: \
409 static const OSMetaClass * const metaClass; \
410 static class MetaClass : public OSMetaClass { \
411 public: \
412 MetaClass(); \
413 virtual OSObject *alloc() const; \
414 } gMetaClass; \
415 friend class className ## ::MetaClass; \
416 virtual const OSMetaClass * getMetaClass() const; \
417 protected: \
418 className ## (const OSMetaClass *); \
419 virtual ~ ## className ## ()
420
421
422 /*! @function OSDeclareDefaultStructors
423 @abstract One of the macro's used in the class declaration of all subclasses of OSObject, declares runtime type information data and interfaces.
424 @discussion Macro used in the class declaration all subclasses of OSObject, declares runtime type information data and interfaces. By convention it should be 'called' immediately after the opening brace in a class declaration. It leaves the current privacy state as 'protected:'.
425 @param className Name of class. NO QUOTES. */
426 #define OSDeclareDefaultStructors(className) \
427 OSDeclareCommonStructors(className); \
428 public: \
429 className ## (); \
430 protected:
431
432
433 /*! @function OSDeclareAbstractStructors
434 @abstract One of the macro's used in the class declaration of all subclasses of OSObject, declares runtime type information data and interfaces.
435 @discussion This macro is used when the class being declared has one or more '= 0' pure virtual methods and thus it is illegal to create an instance of this class. It leaves the current privacy state as 'protected:'.
436 @param className Name of class. NO QUOTES. */
437 #define OSDeclareAbstractStructors(className) \
438 OSDeclareCommonStructors(className); \
439 private: \
440 className ## (); /* Make primary constructor private in abstract */ \
441 protected:
442
443 /*! @function OSDefineMetaClassWithInit
444 @abstract Basic helper macro for the OSDefineMetaClass for the default and Abstract macros, qv. DO NOT USE.
445 @param className Name of class. NO QUOTES and NO MACROS.
446 @param superClassName Name of super class. NO QUOTES and NO MACROS.
447 @param init Name of a function to call after the OSMetaClass is constructed. */
448 #define OSDefineMetaClassWithInit(className, superClassName, init) \
449 /* Class global data */ \
450 className ## ::MetaClass className ## ::gMetaClass; \
451 const OSMetaClass * const className ## ::metaClass = \
452 & ## className ## ::gMetaClass; \
453 const OSMetaClass * const className ## ::superClass = \
454 & ## superClassName ## ::gMetaClass; \
455 /* Class member functions */ \
456 className ## :: ## className(const OSMetaClass *meta) \
457 : superClassName ## (meta) { } \
458 className ## ::~ ## className() { } \
459 const OSMetaClass * className ## ::getMetaClass() const \
460 { return &gMetaClass; } \
461 /* The ::MetaClass constructor */ \
462 className ## ::MetaClass::MetaClass() \
463 : OSMetaClass(#className, className::superClass, sizeof(className)) \
464 { init; }
465
466 /*! @function OSDefineAbstractStructors
467 @abstract Basic helper macro for the OSDefineMetaClass for the default and Abstract macros, qv. DO NOT USE.
468 @param className Name of class. NO QUOTES and NO MACROS.
469 @param superClassName Name of super class. NO QUOTES and NO MACROS. */
470 #define OSDefineAbstractStructors(className, superClassName) \
471 OSObject * ## className ## ::MetaClass::alloc() const { return 0; }
472
473 /*! @function OSDefineDefaultStructors
474 @abstract Basic helper macro for the OSDefineMetaClass for the default and Abstract macros, qv. DO NOT USE.
475 @param className Name of class. NO QUOTES and NO MACROS.
476 @param superClassName Name of super class. NO QUOTES and NO MACROS. */
477 #define OSDefineDefaultStructors(className, superClassName) \
478 OSObject * ## className ## ::MetaClass::alloc() const \
479 { return new className; } \
480 className ## :: ## className () : superClassName ## (&gMetaClass) \
481 { gMetaClass.instanceConstructed(); }
482
483
484 /*! @function OSDefineMetaClassAndAbstractStructorsWithInit
485 @abstract Primary definition macro for all abstract classes that a subclasses of OSObject.
486 @discussion Define an OSMetaClass subclass and the primary constructors and destructors for a subclass of OSObject that is an abstract class. In general this 'function' is 'called' at the top of the file just before the first function is implemented for a particular class. Once the OSMetaClass has been constructed, at load time, call the init routine. NB you can not rely on the order of execution of the init routines.
487 @param className Name of class. NO QUOTES and NO MACROS.
488 @param superClassName Name of super class. NO QUOTES and NO MACROS.
489 @param init Name of a function to call after the OSMetaClass is constructed. */
490 #define OSDefineMetaClassAndAbstractStructorsWithInit(className, superClassName, init) \
491 OSDefineMetaClassWithInit(className, superClassName, init) \
492 OSDefineAbstractStructors(className, superClassName)
493
494 /*! @function OSDefineMetaClassAndStructorsWithInit
495 @abstract See OSDefineMetaClassAndStructors
496 @discussion Define an OSMetaClass subclass and the primary constructors and destructors for a subclass of OSObject that isn't an abstract class. In general this 'function' is 'called' at the top of the file just before the first function is implemented for a particular class. Once the OSMetaClass has been constructed, at load time, call the init routine. NB you can not rely on the order of execution of the init routines.
497 @param className Name of class. NO QUOTES and NO MACROS.
498 @param superClassName Name of super class. NO QUOTES and NO MACROS.
499 @param init Name of a function to call after the OSMetaClass is constructed. */
500 #define OSDefineMetaClassAndStructorsWithInit(className, superClassName, init) \
501 OSDefineMetaClassWithInit(className, superClassName, init) \
502 OSDefineDefaultStructors(className, superClassName)
503
504 /* Helpers */
505 /*! @function OSDefineMetaClass
506 @abstract Define an OSMetaClass instance, used for backward compatiblility only.
507 @param className Name of class. NO QUOTES and NO MACROS.
508 @param superClassName Name of super class. NO QUOTES and NO MACROS. */
509 #define OSDefineMetaClass(className, superClassName) \
510 OSDefineMetaClassWithInit(className, superClassName, )
511
512 /*! @function OSDefineMetaClassAndStructors
513 @abstract Define an OSMetaClass subclass and the runtime system routines.
514 @discussion Define an OSMetaClass subclass and the primary constructors and destructors for a subclass of OSObject that isn't an abstract class. In general this 'function' is 'called' at the top of the file just before the first function is implemented for a particular class.
515 @param className Name of class. NO QUOTES and NO MACROS.
516 @param superClassName Name of super class. NO QUOTES and NO MACROS. */
517 #define OSDefineMetaClassAndStructors(className, superClassName) \
518 OSDefineMetaClassAndStructorsWithInit(className, superClassName, )
519
520 /*! @function OSDefineMetaClassAndAbstractStructors
521 @abstract Define an OSMetaClass subclass and the runtime system routines.
522 @discussion Define an OSMetaClass subclass and the primary constructors and destructors for a subclass of OSObject that is an abstract class. In general this 'function' is 'called' at the top of the file just before the first function is implemented for a particular class.
523 @param className Name of class. NO QUOTES and NO MACROS.
524 @param superClassName Name of super class. NO QUOTES and NO MACROS. */
525 #define OSDefineMetaClassAndAbstractStructors(className, superClassName) \
526 OSDefineMetaClassAndAbstractStructorsWithInit (className, superClassName, )
527
528 // Dynamic vtable patchup support routines and types
529 void reservedCalled(int ind) const;
530
531 #define OSMetaClassDeclareReservedUnused(classname, index) \
532 private: \
533 virtual void _RESERVED ## classname ## index ()
534
535 #define OSMetaClassDeclareReservedUsed(classname, index)
536
537 #define OSMetaClassDefineReservedUnused(classname, index) \
538 void classname ## ::_RESERVED ## classname ## index () \
539 { gMetaClass.reservedCalled(index); }
540
541 #define OSMetaClassDefineReservedUsed(classname, index)
542
543 // IOKit debug internal routines.
544 static void printInstanceCounts();
545 static OSDictionary *getClassDictionary();
546 virtual bool serialize(OSSerialize *s) const;
547
548 // Virtual Padding functions for MetaClass's
549 OSMetaClassDeclareReservedUnused(OSMetaClass, 0);
550 OSMetaClassDeclareReservedUnused(OSMetaClass, 1);
551 OSMetaClassDeclareReservedUnused(OSMetaClass, 2);
552 OSMetaClassDeclareReservedUnused(OSMetaClass, 3);
553 OSMetaClassDeclareReservedUnused(OSMetaClass, 4);
554 OSMetaClassDeclareReservedUnused(OSMetaClass, 5);
555 OSMetaClassDeclareReservedUnused(OSMetaClass, 6);
556 OSMetaClassDeclareReservedUnused(OSMetaClass, 7);
557 };
558
559 #endif /* !_LIBKERN_OSMETACLASS_H */