--- a/Metaclass.st Sun Jan 16 04:38:33 1994 +0100
+++ b/Metaclass.st Sun Jan 16 04:47:41 1994 +0100
@@ -26,7 +26,7 @@
- this adds support for creating new subclasses or changing the definition
of an already existing class.
-$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.7 1994-01-08 16:27:40 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.8 1994-01-16 03:42:19 claus Exp $
'!
!Metaclass methodsFor:'creating classes'!
@@ -88,6 +88,57 @@
]
].
+ "I dont like the confirmers below - we need a notifying: argument, to give
+ the outer codeview a chance to highlight the error.
+ (but thats how PP defined it in the book - maybe it will change anyway"
+
+ oldClass isNil ifTrue:[
+ "let user confirm, if the classname is no good"
+ newName first isUppercase ifFalse:[
+ (self confirm:'classenames should start with an uppercase letter
+(by convention)
+
+install anyway ?' withCRs)
+ ifFalse:[
+ ^ nil
+ ]
+ ].
+
+ "let user confirm, if any instvarname is no good"
+ (stringOfInstVarNames asCollectionOfWords
+ inject:true
+ into:[:okSoFar :word |
+ okSoFar and:[word first isLowercase]
+ ]
+
+ ) ifFalse:[
+ (self confirm:'instance variable names should start with a lowercase letter
+(by convention only)
+
+install anyway ?' withCRs)
+ ifFalse:[
+ ^ nil
+ ]
+ ].
+
+ "let user confirm, if any classvarname is no good"
+ (stringOfClassVarNames asCollectionOfWords
+ inject:true
+ into:[:okSoFar :word |
+ okSoFar and:[word first isUppercase]
+ ]
+
+ ) ifFalse:[
+ (self confirm:'class variable names should start with an uppercase letter
+(by convention only)
+
+install anyway ?' withCRs)
+ ifFalse:[
+ ^ nil
+ ]
+ ]
+ ].
+
"create the metaclass first"
newMetaclass := Metaclass new.
newMetaclass setSuperclass:(aClass class).
@@ -501,6 +552,9 @@
oldOffsets newOffsets offset changeSet delta
oldToNew newSubMeta newSub oldSubMeta oldSuper|
+ "cleanup needed here: extract common things with name:inEnvironment:...
+ and structure things ... currently way too complex."
+
oldVars := self instanceVariableString.
aString = oldVars ifTrue:[
"
@@ -521,6 +575,28 @@
^ self
].
+ "let user confirm, if any name is no good (and was good before)"
+ (oldNames inject:true
+ into:[:okSoFar :word |
+ okSoFar and:[word first isUppercase]
+ ])
+ ifTrue:[
+ "was ok before"
+ (newNames inject:true
+ into:[:okSoFar :word |
+ okSoFar and:[word first isUppercase]
+ ])
+ ifFalse:[
+ (self confirm:'class instance variable names should start with an uppercase letter
+(by convention only)
+
+install anyway ?' withCRs)
+ ifFalse:[
+ ^ nil
+ ]
+ ]
+ ].
+
nClassInstVars := newNames size.
"