class: Class
authorStefan Vogel <sv@exept.de>
Sat, 10 Aug 2013 13:14:10 +0200
changeset 15610 cdec81bdc7a7
parent 15609 36dd250b19f4
child 15611 03984afbeca6
class: Class changed: #comment #getSourceChunkAttribute: (send #position: instead of #position0Based:) #validateSourceStream: use #position/#position: instead of #positionXBased
Class.st
--- a/Class.st	Sat Aug 10 13:13:37 2013 +0200
+++ b/Class.st	Sat Aug 10 13:14:10 2013 +0200
@@ -911,16 +911,16 @@
      position within the classes sourcefile ...
     "
     comment isNumber ifTrue:[
-	classFilename notNil ifTrue:[
-	    stream := self sourceStream.
-	    stream notNil ifTrue:[
-		stream position1Based:comment.
-		string := String readFrom:stream onError:''.
-		stream close.
-		^ string
-	    ].
-	    ^ nil
-	]
+        classFilename notNil ifTrue:[
+            stream := self sourceStream.
+            stream notNil ifTrue:[
+                stream position:comment-1.
+                string := String readFrom:stream onError:''.
+                stream close.
+                ^ string
+            ].
+            ^ nil
+        ]
     ].
     ^ comment
 
@@ -3484,15 +3484,15 @@
 
     pos isNumber ifTrue:[
 "/        classFilename notNil ifTrue:[
-	    stream := self sourceStream.
-	    stream notNil ifTrue:[
-		stream position0Based:pos.
-		string := stream nextChunk.
-		stream close.
-		^ string
-	    ].
+            stream := self sourceStream.
+            stream notNil ifTrue:[
+                stream position:pos.
+                string := stream nextChunk.
+                stream close.
+                ^ string
+            ].
 "/        ].
-	^ nil
+        ^ nil
     ].
 
     ^ pos
@@ -5184,14 +5184,14 @@
      versionFromCode versionFromSource oldPos pos src rev|
 
     ValidateSourceOnlyOnce == true ifTrue:[
-	ValidatedClasses notNil ifTrue:[
-	    (ValidatedClasses includes:self) ifTrue:[
-		Transcript showCR:'trust validated'.
-		^ true
-	    ].
-	] ifFalse:[
-	    ValidatedClasses := WeakIdentitySet new.
-	].
+        ValidatedClasses notNil ifTrue:[
+            (ValidatedClasses includes:self) ifTrue:[
+                Transcript showCR:'trust validated'.
+                ^ true
+            ].
+        ] ifFalse:[
+            ValidatedClasses := WeakIdentitySet new.
+        ].
     ].
 
     meta := self theMetaclass.
@@ -5201,75 +5201,75 @@
 
     versionMethod := self findVersionMethod.
     versionMethod isNil ifTrue:[
-	cannotCheckReason := 'no valid version method'.
+        cannotCheckReason := 'no valid version method'.
     ] ifFalse:[
-	"/
-	"/ if its a method returning the string,
-	"/ thats the returned value
-	"/
-	versionFromCode := versionMethod valueWithReceiver:cls arguments:#().
-	versionFromCode isString ifFalse:[
-	    cannotCheckReason := 'version method does not return a string'
-	].
+        "/
+        "/ if its a method returning the string,
+        "/ thats the returned value
+        "/
+        versionFromCode := versionMethod valueWithReceiver:cls arguments:#().
+        versionFromCode isString ifFalse:[
+            cannotCheckReason := 'version method does not return a string'
+        ].
     ].
 
     versionMethod notNil ifTrue:[
-	pos := versionMethod sourcePosition.
-	pos isInteger ifFalse:[
-	    "/ mhmh - either no version method,
-	    "/ or updated due to a checkin.
-	    "/ in any case, this should be a good source.
-
-	    ^ true.
-	    "/ cannotCheckReason := 'no source position for version-method'
-	]
+        pos := versionMethod sourcePosition.
+        pos isInteger ifFalse:[
+            "/ mhmh - either no version method,
+            "/ or updated due to a checkin.
+            "/ in any case, this should be a good source.
+
+            ^ true.
+            "/ cannotCheckReason := 'no source position for version-method'
+        ]
     ].
 
     cannotCheckReason notNil ifTrue:[
-	('Class [warning]: ' , cannotCheckReason , ' in ' , self name) infoPrintCR.
-	'Class [info]: cannot validate source; trusting source' infoPrintCR.
-	^ true
+        ('Class [warning]: ' , cannotCheckReason , ' in ' , self name) infoPrintCR.
+        'Class [info]: cannot validate source; trusting source' infoPrintCR.
+        ^ true
     ].
 
     oldPos := aStream position.
     Stream positionErrorSignal handle:[:ex |
-	'Class [info]: position error when accessing source' infoPrintCR.
-	^ false
+        'Class [info]: position error when accessing source' infoPrintCR.
+        ^ false
     ] do:[
-	aStream position1Based:pos.
+        aStream position:pos-1.
     ].
     src := aStream nextChunk.
     aStream position:oldPos.
 
     (src isEmptyOrNil) ifTrue:[
-	'Class [info]: empty source for version-method' infoPrintCR.
-	^ false
+        'Class [info]: empty source for version-method' infoPrintCR.
+        ^ false
     ].
     (src startsWith:'version') ifFalse:[
-	'Class [info]: corrupted source (source does not correspond to binary)' infoPrintCR.
-	^ false
+        'Class [info]: corrupted source (source does not correspond to binary)' infoPrintCR.
+        ^ false
     ].
 
     versionFromSource := Class revisionStringFromSource:src.
     versionFromSource = versionFromCode ifTrue:[
-	ValidatedClasses notNil ifTrue:[ ValidatedClasses add:self ].
-	^ true
+        ValidatedClasses notNil ifTrue:[ ValidatedClasses add:self ].
+        ^ true
     ].
 
     versionFromSource isNil ifTrue:[
-	'Class [info]: version-from source is nil' infoPrintCR.
-	^ false
+        'Class [info]: version-from source is nil' infoPrintCR.
+        ^ false
     ].
 
     "/ mhmh - check my binary version ...
 
     info := Class revisionInfoFromString:versionFromSource.
     info notNil ifTrue:[
-	rev := info at:#revision.
-	rev = self binaryRevision ifTrue:[
-	    ValidatedClasses notNil ifTrue:[ ValidatedClasses add:self ].
-	    ^ true
-	].
+        rev := info at:#revision.
+        rev = self binaryRevision ifTrue:[
+            ValidatedClasses notNil ifTrue:[ ValidatedClasses add:self ].
+            ^ true
+        ].
     ].
     'Class [info]: source-version is different from binaryRevision' infoPrintCR.
     ^ false
@@ -5553,11 +5553,11 @@
 !Class class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.628 2013-07-12 13:56:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.629 2013-08-10 11:14:10 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.628 2013-07-12 13:56:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.629 2013-08-10 11:14:10 stefan Exp $'
 !
 
 version_SVN