Metaclass.st
changeset 4398 df208587581f
parent 4348 c3c08808bfb6
child 4399 b2ef9e2347bd
--- a/Metaclass.st	Fri Jul 16 19:24:42 1999 +0200
+++ b/Metaclass.st	Fri Jul 16 20:05:56 1999 +0200
@@ -587,19 +587,24 @@
         aSystemDictionaryOrClass autoload
     ].
 
-    "
-     Check for invalid variable names (duplicates)
-    "
-    (self 
-        checkValidVarNamesFor:newName
-        subClassOf:aClass
-        instVarNames:stringOfInstVarNames 
-        classVarNames:stringOfClassVarNames) 
-    ifFalse:[
-        ^ nil
+    (stringOfInstVarNames size > 0
+    or:[stringOfClassVarNames size > 0]) ifTrue:[
+        "
+         Check for invalid variable names (duplicates)
+        "
+        (self 
+            checkValidVarNamesFor:newName
+            subClassOf:aClass
+            instVarNames:stringOfInstVarNames 
+            classVarNames:stringOfClassVarNames) 
+        ifFalse:[
+            ^ nil
+        ].
+        nInstVars := stringOfInstVarNames countWords.
+    ] ifFalse:[
+        nInstVars := 0.
     ].
 
-    nInstVars := stringOfInstVarNames countWords.
     nameString := newName asString.
     classSymbol := newName asSymbol.
     newComment := commentString.
@@ -752,22 +757,25 @@
     "/ - or use upQueries in future versions.
 
     oldClass isNil ifTrue:[
-        (self 
-            checkConventionsFor:newName
-            subClassOf:aClass
-            instVarNames:stringOfInstVarNames 
-            classVarNames:stringOfClassVarNames) 
-        ifFalse:[
-            ^ nil
-        ]
+        (stringOfInstVarNames size > 0
+        or:[stringOfClassVarNames size > 0]) ifTrue:[
+            (self 
+                checkConventionsFor:newName
+                subClassOf:aClass
+                instVarNames:stringOfInstVarNames 
+                classVarNames:stringOfClassVarNames) 
+            ifFalse:[
+                ^ nil
+            ]
+        ].
+
+        (self
+            checkInstvarRedefsWith:stringOfInstVarNames 
+            subclassOf:aClass 
+            old:oldClass 
+            name:newName) ifFalse:[^ nil].
     ].
 
-    (self
-        checkInstvarRedefsWith:stringOfInstVarNames 
-        subclassOf:aClass 
-        old:oldClass 
-        name:newName) ifFalse:[^ nil].
-
     stringOfClassInstVarNamesOrNil isNil ifTrue:[
         oldClass isNil ifTrue:[
             stringOfClassInstVarNames := ''
@@ -812,11 +820,13 @@
 
     (namespace notNil 
     and:[namespace ~~ Smalltalk]) ifTrue:[
+realNewName printCR.
+(namespace name , '::' , nameKey) printCR.
         newClass setName:(namespace name , '::' , nameKey) asSymbol.
         "/
         "/ if that key exists in smalltalk,
         "/ must recompile everything in that nameSpace,
-        "/ which referes to the global.
+        "/ which refers to the unprefixed global.
         "/
         recompileGlobalAccessTo := nameKey.
     ] ifFalse:[
@@ -986,18 +996,17 @@
             ]
         ].
 
-"/        namespace isNamespace ifTrue:[
-            "/ be very careful, when adding classes
-            "/ to a namespace. When adding, all methods within the
-            "/ same namespace which access the unprefixed-global
-            "/ must be recompiled (so they access the new class)
+        "/ be very careful, when adding classes
+        "/ to a namespace or adding a privateClass. 
+        "/ When adding, all methods within that namespace/owning class
+        "/ which access the unprefixed-global,
+        "/ must be recompiled (so they access the new class)
 
-            recompileGlobalAccessTo notNil ifTrue:[
-                self recompileGlobalAccessorsTo:recompileGlobalAccessTo
-                     in:namespace
-                     except:newClass
-            ].
-"/        ].
+        recompileGlobalAccessTo notNil ifTrue:[
+            self recompileGlobalAccessorsTo:recompileGlobalAccessTo
+                 in:namespace
+                 except:newClass
+        ].
 
         ^ newClass
     ].
@@ -1660,22 +1669,21 @@
 
     "check for instvar redefs within local instvars"
     names keysAndValuesDo:[:index :aName |
-	(names indexOf:aName startingAt:index+1) ~~ 0 ifTrue:[
-	    self warn:'instance variable ''' , aName , '''\occurs multiple times in instVarString.\\Class not installed.' withCRs.
-	    ^ false.
-	]
+        (names indexOf:aName startingAt:index+1) ~~ 0 ifTrue:[
+            self warn:'instance variable ''' , aName , '''\occurs multiple times in instVarString.\\Class not installed.' withCRs.
+            ^ false.
+        ]
     ].
 
     names := classVarNameString asCollectionOfWords. 
 
     "check for classvar redefs within local instvars"
     names keysAndValuesDo:[:index :aName |
-	(names indexOf:aName startingAt:index+1) ~~ 0 ifTrue:[
-	    self warn:'class variable ''' , aName , '''\occurs multiple times in classVarString.\\Class not installed.' withCRs.
-	    ^ false.
-	]
+        (names indexOf:aName startingAt:index+1) ~~ 0 ifTrue:[
+            self warn:'class variable ''' , aName , '''\occurs multiple times in classVarString.\\Class not installed.' withCRs.
+            ^ false.
+        ]
     ].
-
     ^ true
 
     "Created: 8.1.1997 / 21:09:14 / cg"
@@ -2026,6 +2034,6 @@
 !Metaclass class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.145 1999-07-07 17:26:17 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.146 1999-07-16 18:05:56 cg Exp $'
 ! !
 Metaclass initialize!