home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Programming / c-runtime / include / RCS / objc-protoP.h,v < prev    next >
Encoding:
Text File  |  1992-04-13  |  6.9 KB  |  263 lines

  1. head    1.1;
  2. access;
  3. symbols;
  4. locks
  5.     dennisg:1.1; strict;
  6. comment    @ * @;
  7.  
  8.  
  9. 1.1
  10. date    92.04.13.11.40.53;    author dennisg;    state Exp;
  11. branches;
  12. next    ;
  13.  
  14.  
  15. desc
  16. @Prototypes of functions private to the run-time.
  17. @
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/* -*-c-*-
  26.  * This file contains prototype declarations of private
  27.  *  functions provided by the run-time system.
  28.  *
  29.  * Copyright (C) 1991 Threaded Technologies Inc.
  30.  * 
  31.  * This program is free software; you can redistribute it and/or modify
  32.  * it under the terms of the GNU General Public License as published
  33.  * by the Free Software Foundation; either version 1, or any later version.
  34.  * 
  35.  * This program is distributed in the hope that it will be useful,
  36.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  37.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  38.  * General Public License for more details.
  39.  * 
  40.  * You should receive a copy of the GNU General Public License 
  41.  * along with this program; if not, write to the Free Software
  42.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  43.  * 
  44.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/include/RCS/ObjC-proto-private.h,v 0.11 1991/12/31 20:16:08 dennisg Exp dennisg $
  45.   $Author: dennisg $
  46.   $Date: 1991/12/31 20:16:08 $
  47.   $Log: ObjC-proto-private.h,v $
  48.  * Revision 0.11  1991/12/31  20:16:08  dennisg
  49.  * Deleted index variable stuff.  Index variables are a hack to the language.
  50.  * Cleaned up some documentation.
  51.  *
  52.  * Revision 0.10  1991/12/10  12:03:22  dennisg
  53.  * Cleaned up file format for a distribution.
  54.  *
  55.  * Revision 0.9  1991/12/01  01:29:29  dennisg
  56.  * modified to remove changes previously made to
  57.  * implement posing.  posing just got easy.
  58.  *
  59.  * Revision 0.8  1991/11/29  22:00:10  dennisg
  60.  * modified to implement set functions.
  61.  *
  62.  * Revision 0.7  1991/11/29  20:02:01  dennisg
  63.  * fixed several const decls.  bozo.
  64.  *
  65.  * Revision 0.6  1991/11/29  13:32:16  dennisg
  66.  * committed some functions to inline and changes prototypes
  67.  * to match.
  68.  * also added some documentation.
  69.  *
  70.  * Revision 0.5  1991/11/29  00:24:14  dennisg
  71.  * many changes including posing, things to make the compiler
  72.  * happier, structure changes, and things to make it play better.
  73.  *
  74.  * Revision 0.4  1991/11/19  12:37:49  dennisg
  75.  * modified to support changes of run-time.
  76.  *
  77.  * Revision 0.3  1991/11/16  15:56:07  dennisg
  78.  * deleted some prototypes that are no longer part of the
  79.  * implementation.
  80.  * added others.
  81.  *
  82.  * Revision 0.2  1991/11/07  22:31:42  dennisg
  83.  * added copyleft.
  84.  *
  85.  * Revision 0.1  1991/10/24  00:19:24  dennisg
  86.  * Initial check in.  Preliminary development stage.
  87.  *
  88.  */
  89.  
  90.  
  91. #ifndef _objc_protop_INCLUDE_GNU
  92. #define _objc_protop_INCLUDE_GNU
  93.  
  94. #include    <stdio.h>
  95.  
  96. #include    <tm.h>
  97.  
  98. #include  <objc.h>
  99.  
  100.  
  101. /*
  102.  * Add a class to the class hash table and assign it a class number. 
  103.  */
  104. void
  105. addClassToHash(Class_t aClass);
  106.  
  107. /*
  108.  * This function takes a list of methods and adds them to the method list of
  109.  * a class.  The method list must remain intact during the lifetime of the
  110.  * class. 
  111.  */
  112. void  
  113. addMethodsToClass (Class_t, MethodList_t);
  114.  
  115. /*
  116.  * This function creates a new instance of aClass, initializes its isa
  117.  * instance variable to point to the class, and return the new instance.  
  118.  *
  119.  * All other instance variables are initialized to 0. 
  120.  */
  121. static inline id  
  122. class_createInstance( Class_t aClass) {
  123.  
  124.   return (*_alloc)(aClass);
  125. }
  126.  
  127. /*
  128.  * object_dispose() frees the memory occupied by aObject after setting its
  129.  * isa instance variable to nil, and returns nil.  The function it calls to
  130.  * do this work can be changed by reassigning the _dealloc variable. 
  131.  */
  132. static inline id  
  133. object_dispose (id aObject) {
  134.   
  135.   return (*_dealloc)(aObject);
  136. }
  137.  
  138. /*
  139.  * object_copy() creates a new object that's an exact copy of anObject and
  140.  * return the new object.  The second argument, indexedIvarBytes, specifies
  141.  * the number of additional bytes that should be allocated for the copy to
  142.  * accommodate indexed instance variables; it serves the same purpose as the
  143.  * second argument to class_createInstance().  The function that
  144.  * object_copy() calls to do this work can be changed by reassigning the
  145.  * _copy variable. 
  146.  */
  147. static inline id  
  148. object_copy (id aObject) {
  149.  
  150.   return (*_copy)(aObject);
  151. }
  152.  
  153. /*
  154.  * object_realloc() reallocates storage for anObject, adding numBytes if
  155.  * possible.  The memory previously occupied by anObject is freed if it can't
  156.  * be reused, and a pointer to the new location of anObject is returned.  The
  157.  * function that object_realloc() calls to do this work can be changed by
  158.  * reassigning the _realloc variable. 
  159.  */
  160. static inline id  
  161. object_realloc (id aObject, u_int numBytes) {
  162.  
  163.   return (*_realloc)(aObject, numBytes);
  164. }
  165.  
  166. /*
  167.  * This function causes one class to pose as its super class.  Messages sent
  168.  * to the super class will actually be sent to the posing class. 
  169.  *
  170.  * Instance variables should not be declared in the posing class.  The posing
  171.  * class can add new methods to the class or override existing methods in the
  172.  * super class. 
  173.  */
  174. Class_t 
  175. class_poseAs(Class_t, Class_t);
  176.  
  177.  
  178. /* These functions set and return the class version number. */
  179. static inline void 
  180. class_setVersion(Class_t aClass, long theVersion) {
  181.  
  182.   aClass->version = theVersion ;
  183.   aClass->isa->version = theVersion ;
  184. }
  185.  
  186. static inline long
  187. class_getVersion(Class_t aClass) {
  188.  
  189.   return aClass->version ;
  190. }
  191.  
  192.  
  193. /*
  194.  * Class numbers are stored in the class's info variable. This is temporary. 
  195.  * Eventually we will allocate a member to the class so that some efficiency
  196.  * can be gained by not shifting. 
  197.  */
  198. #define    CLASS_LOCATION_SHIFT (BITS_PER_WORD / 2)
  199.  
  200. static inline void
  201. setClassNumber (Class_t aClass, u_int aNumber) {
  202.  
  203.  
  204.   aClass->info |= aNumber << CLASS_LOCATION_SHIFT;
  205. }
  206.  
  207. static inline u_int
  208. getClassNumber (Class_t aClass) {
  209.  
  210.  
  211.   return aClass->info >> CLASS_LOCATION_SHIFT;
  212. }
  213.  
  214.  
  215. /*
  216.  * These functions add and remove methods in a list from a class.  These
  217.  * functions perform the actual work required for those functions.  
  218.  *
  219.  * The appropriate run-time is to provide the user callable functions to
  220.  * perform these functions.  Typically those functions perform something
  221.  * specific to their run-time type and call these functions to perform the 
  222.  * actual work.
  223.  */ 
  224. void  
  225. _class_removeMethods (Class_t aClass, MethodList_t aMethodList);
  226. void  
  227. _addMethodsToClass (Class_t aClass, MethodList_t newList);
  228.  
  229. /*
  230.  * This function implements the core of posing.  Some work must be done by
  231.  * the run-time. 
  232.  */
  233. Class_t 
  234. _class_poseAs (Class_t theImpostor, Class_t theSuperClass);
  235.  
  236. /*
  237.  * Find the named method in a linked list of methods. 
  238.  */
  239. Method_t  
  240. searchForMethodInList (MethodList_t aList, const char* selName);
  241.  
  242. /*
  243.  * fprintf() is used id we're debugging.  If DEBUG isn't defined then this
  244.  * def isn't defined thereby causing the compiler to eliminate the parameter
  245.  * decl. 
  246.  */
  247. #ifdef DEBUG
  248. #define DEBUG_PRINTF  fprintf
  249. #else
  250. #define DEBUG_PRINTF
  251. #endif
  252.  
  253.  
  254. /*
  255.  * Function that dumps information about all of the classes to stdout. 
  256.  */
  257. void
  258. debug_dump_classes(void);
  259.  
  260. #endif
  261.  
  262. @
  263.