more porting (but still unfinished)
authorClaus Gittinger <cg@exept.de>
Mon, 26 Oct 2009 16:25:08 +0100
changeset 141 0f1d8459da84
parent 140 a09c40ff0e93
child 142 4a05a68fe582
more porting (but still unfinished)
MCMczReader.st
--- a/MCMczReader.st	Mon Oct 26 16:25:06 2009 +0100
+++ b/MCMczReader.st	Mon Oct 26 16:25:08 2009 +0100
@@ -29,10 +29,17 @@
 associate: tokens
         | result |
         result _ Dictionary new.
-        tokens pairsDo: [:key :valueArg | |value|
+        Smalltalk isSmalltalkX ifTrue:[
+            tokens pairWiseDo: [:key :valueArg | |value|
                                         value := valueArg.        
                                         value isString ifFalse: [value _ value collect: [:ea | self associate: ea]].
                                         result at: key put: value].
+        ] ifFalse:[
+            tokens pairsDo: [:key :valueArg | |value|
+                                        value := valueArg.        
+                                        value isString ifFalse: [value _ value collect: [:ea | self associate: ea]].
+                                        result at: key put: value].
+        ].
         ^ result
 
     "Created: / 16-11-2006 / 16:39:45 / cg"
@@ -54,16 +61,23 @@
 !
 
 extractInfoFrom: dict
-	^ self infoCache at: (dict at: #id) ifAbsentPut:
-		[MCVersionInfo
-			name: (dict at: #name ifAbsent: [''])
-			id: (UUID fromString: (dict at: #id))
-			message: (dict at: #message ifAbsent: [''])
-			date: ([Date fromString: (dict at: #date) ] on: Error do: [ :ex | ex return: nil ])
-			time: ([ Time fromString:(dict at: #time)] on: Error do: [ :ex | ex return: nil ])
-			author: (dict at: #author ifAbsent: [''])
-			ancestors: ((dict at: #ancestors) collect: [:ea | self extractInfoFrom: ea])
-			stepChildren: ((dict at: #stepChildren ifAbsent: [#()]) collect: [:ea | self extractInfoFrom: ea])]
+        ^ self infoCache at: (dict at: #id) ifAbsentPut:
+                [   |uuid|
+
+                    Smalltalk isSmalltalkX ifTrue:[
+                        uuid := (UUID fromBytes: (dict at: #id)).
+                    ] ifFalse:[
+                        uuid := (UUID fromString: (dict at: #id)).
+                    ].                    
+                    MCVersionInfo
+                        name: (dict at: #name ifAbsent: [''])
+                        id: uuid
+                        message: (dict at: #message ifAbsent: [''])
+                        date: ([Date fromString: (dict at: #date) ] on: Error do: [ :ex | ex return: nil ])
+                        time: ([ Time fromString:(dict at: #time)] on: Error do: [ :ex | ex return: nil ])
+                        author: (dict at: #author ifAbsent: [''])
+                        ancestors: ((dict at: #ancestors) collect: [:ea | self extractInfoFrom: ea])
+                        stepChildren: ((dict at: #stepChildren ifAbsent: [#()]) collect: [:ea | self extractInfoFrom: ea])]
 !
 
 infoCache
@@ -71,13 +85,26 @@
 !
 
 loadDefinitions
-	definitions _ OrderedCollection new.
-	(self zip memberNamed: 'snapshot.bin') ifNotNilDo:
-		[:m | [^ definitions _ (DataStream on: m contentStream) next definitions]
-			on: Error do: [:fallThrough ]].
-	"otherwise"
-	(self zip membersMatching: 'snapshot/*')
-		do: [:m | self extractDefinitionsFrom: m].
+        |m|
+
+        definitions _ OrderedCollection new.
+
+        Smalltalk isSmalltalkX ifTrue:[
+            m := self zip extract:'snapshot.bin'.
+            m notNil ifTrue:[
+                [                   
+                    ^ definitions _ (Object fromBinaryStoreBytes:m) definitions
+                ] on: Error do: [:fallThrough ]
+            ].
+        ] ifFalse:[
+            (self zip memberNamed: 'snapshot.bin') ifNotNilDo:
+                [:m | [^ definitions _ (DataStream on: m contentStream) next definitions]
+                        on: Error do: [:fallThrough ]].
+        ].
+
+        "otherwise"
+        (self zip membersMatching: 'snapshot/*')
+                do: [:m | self extractDefinitionsFrom: m].
 !
 
 loadDependencies
@@ -96,9 +123,15 @@
 !
 
 parseMember: fileName
-	| tokens |
-	tokens _ (self scanner scanTokens: (self zip contentsOf: fileName)) first.
-	^ self associate: tokens
+        | contents tokens |
+
+        Smalltalk isSmalltalkX ifTrue:[
+            contents := (self zip extract: fileName) asString.
+        ] ifFalse:[
+            contents := self zip contentsOf: fileName.
+        ].
+        tokens _ (self scanner scanTokens: contents) first.
+        ^ self associate: tokens
 !
 
 scanner
@@ -106,14 +139,19 @@
 !
 
 zip
-	zip ifNil:
-		[zip _ ZipArchive new.
-		zip readFrom: stream].
-	^ zip
+        zip ifNil:[
+            zip _ ZipArchive new.
+            zip readFrom: stream
+        ].
+        ^ zip
 ! !
 
 !MCMczReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCMczReader.st,v 1.1 2006-11-22 13:05:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCMczReader.st,v 1.2 2009-10-26 15:25:08 cg Exp $'
+!
+
+version_CVS
+    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCMczReader.st,v 1.2 2009-10-26 15:25:08 cg Exp $'
 ! !