home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 415_02 / rtti / src / rtti_entry.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-04  |  1.6 KB  |  73 lines

  1. #ifndef lint
  2. static const char sccsid[] = "%Z%%I%  %G% %U% %W%";
  3. #endif
  4. /*
  5.  * COMPONENT_NAME: (RTTI) Run-Time Type System for C++
  6.  *
  7.  * FUNCTIONS:
  8.  *
  9.  * ORIGINS: 27
  10.  *
  11.  * (C) COPYRIGHT International Business Machines Corp. 1992
  12.  * This work was supported by a grant from International Business
  13.  * Machines, Inc. These procedures are contributed to the public domain
  14.  * by International Business Machines Inc. "AS IS" without any warranty
  15.  * of any kind including the warranty of merchantability or fitness
  16.  * for a particular purpose.
  17.  *
  18.  *
  19.  * This is free software. Feel free to redistribute and/or modify it.
  20.  * Please send us e-mail and let us know if you have any problems
  21.  * or suggestions.
  22.  *
  23.  * Arindam Banerji
  24.  * axb@cse.nd.edu
  25.  *
  26.  */
  27.  
  28.  
  29. #include   "rtti_entry.h"
  30. int   class_count = 0 ;
  31.  
  32. int  do_ptr_cast(const Type_info *a, const Type_info *b)
  33. {
  34.   return (a->can_cast(b)) ;
  35. }
  36.  
  37.  
  38. /*****
  39.    SCAFFOLDING NECESSARY TO SUPPORT RTTI
  40. ******/
  41.  
  42. const hndl_recursion  CLASS::info_obj ;
  43. const Type_info  temporary_base("CLASS", 0 ) ;
  44.  
  45. const Type_info  *
  46. hndl_recursion::convert_type()   const
  47. {
  48.   return ( &temporary_base ) ;
  49. } // returns a void pointer to itself
  50.  
  51. const Type_info  *
  52. hndl_recursion::operator & ()
  53. {
  54.    return (&temporary_base) ;
  55. } // hack
  56.  
  57. // const Type_info CLASS::info_obj("CLASS",0) ;
  58.  
  59. // This is a function that returns the dynamic type of a class.
  60. typeid
  61. CLASS::get_info() const
  62. {
  63.  return ((const Type_info *) (info_obj.convert_type())) ;
  64. } // dynamic_type()
  65.  
  66. // This is a static function that returns the static type of a class.
  67. typeid
  68. CLASS::info()
  69. {
  70.  return ((const Type_info *) (info_obj.convert_type())) ;
  71. } // static_type()
  72.  
  73.