home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / AmigaTalk / general / Class.st < prev    next >
Encoding:
Text File  |  2004-01-31  |  3.4 KB  |  144 lines

  1. " ----------------------------------------------------------"
  2. " Added getByteArray: methodString  method on 09/26/98.     "
  3. "-----------------------------------------------------------"
  4.  
  5. Class Class
  6. [
  7.   edit
  8.  
  9.     <primitive 150 self>
  10. |
  11.   list
  12.  
  13.     <primitive 157 self>
  14. |
  15.   basicNew        ! superclass newinstance !
  16.  
  17.     amigatalk tracingOff.
  18.     
  19.     superclass <- <primitive 151 self>.         " Get the Parent Class. "
  20.  
  21.     <primitive 3 superclass>                    " Parent respondsTo: new?? "
  22.       ifTrue: [newinstance <- superclass new].
  23.  
  24.     newinstance <- <primitive 153 self newinstance>. "Make a new instance"
  25.  
  26.     <primitive 155 self #new>                   "new object respondsTo: new???" 
  27.       ifTrue: [newinstance <- newinstance new].
  28.  
  29.     amigatalk tracingOn.
  30.     
  31.     ^ newinstance
  32. |
  33.   new ! newObject test !
  34.  
  35.     amigatalk tracingOff.
  36.     
  37.     (<primitive 91 #Singleton_Class <primitive 250 4 0 self>>)
  38.  
  39.        ifTrue: [ " This Class is a Singleton Class, so see if it's
  40.                  * been initialized yet:
  41.                  "
  42.                  test <- <primitive 250 4 3 self>.
  43.         
  44.                  (test == nil)
  45.                    ifTrue: [ " Initialize this Singleton Class: "
  46.                              newObject <- self basicNew.
  47.  
  48.                              <primitive 250 4 4 self newObject>.
  49.  
  50.                              ^ newObject
  51.                            ].
  52.  
  53.                  " Singleton Class is already initialized: "
  54.                  ^ test
  55.                ].
  56.  
  57.     " This Class is an Ordinary Class: "
  58.     amigatalk tracingOn.
  59.  
  60.     ^ self basicNew 
  61. |
  62.   basicNew: aValue  ! superclass newinstance !
  63.  
  64.     amigatalk tracingOff.
  65.     
  66.     superclass <- <primitive 151 self>.
  67.  
  68.     <primitive 3 superclass>
  69.       ifTrue: [newinstance <- superclass new ]. 
  70.  
  71.     newinstance <- <primitive 153 self newinstance>.
  72.  
  73.     <primitive 155 self #new:>
  74.       ifTrue: [newinstance <- newinstance new: aValue].
  75.  
  76.     amigatalk tracingOn.
  77.     
  78.     ^ newinstance
  79. |
  80.   new: aValue ! newObject test ! 
  81.  
  82.     amigatalk tracingOff.
  83.     
  84.     (<primitive 91 #Singleton_Class <primitive 250 4 0 self>>)
  85.  
  86.        ifTrue: [ " This Class is a Singleton Class, so see if it's
  87.                  * been initialized yet:
  88.                  "
  89.                  test <- <primitive 250 4 3 self>.
  90.         
  91.                  (test == nil)
  92.                    ifTrue: [ " Initialize this Singleton Class: "
  93.                              newObject <- self basicNew: aValue.
  94.                              
  95.                              <primitive 250 4 4 self newObject>.
  96.                              
  97.                              ^ newObject
  98.                            ].
  99.  
  100.                  " Singleton Class is already initialized: "
  101.                  ^ test
  102.                ].
  103.        
  104.     " This Class is an Ordinary Class: "
  105.     amigatalk tracingOn.
  106.     
  107.     ^ self basicNew: aValue
  108. |
  109.   printClassString
  110.  
  111.     ^ <primitive 152 self>
  112. |
  113.   respondsTo
  114.  
  115.     <primitive 154 self>
  116. |
  117.   respondsTo: aSymbol ! aClass !
  118.  
  119.     aClass <- self.
  120.  
  121.     [aClass notNil] 
  122.        whileTrue: [ <primitive 155 aClass aSymbol> 
  123.                      ifTrue: [ ^ true ].
  124.              
  125.                     aClass <- aClass superClass ].
  126.     ^ false
  127. |
  128.   superClass
  129.  
  130.     ^ <primitive 151 self>
  131. |
  132.   variables
  133.  
  134.     ^ <primitive 158 self>
  135. |
  136.   view
  137.  
  138.     <primitive 156 self>
  139. |
  140.   getByteArray: methodString
  141.  
  142.     ^ <primitive 159 self methodString> "159 was an unused primitive."
  143. ]
  144.