5275 |
5275 |
5276 |cls meta cannotCheckReason versionMethod info |
5276 |cls meta cannotCheckReason versionMethod info |
5277 versionFromCode versionFromSource oldPos pos src rev| |
5277 versionFromCode versionFromSource oldPos pos src rev| |
5278 |
5278 |
5279 ValidateSourceOnlyOnce == true ifTrue:[ |
5279 ValidateSourceOnlyOnce == true ifTrue:[ |
5280 ValidatedClasses notNil ifTrue:[ |
5280 ValidatedClasses notNil ifTrue:[ |
5281 (ValidatedClasses includes:self) ifTrue:[ |
5281 (ValidatedClasses includes:self) ifTrue:[ |
5282 Transcript showCR:'trust validated'. |
5282 Transcript showCR:'trust validated'. |
5283 ^ true |
5283 ^ true |
5284 ]. |
5284 ]. |
5285 ] ifFalse:[ |
5285 ] ifFalse:[ |
5286 ValidatedClasses := WeakIdentitySet new. |
5286 ValidatedClasses := WeakIdentitySet new. |
5287 ]. |
5287 ]. |
5288 ]. |
5288 ]. |
5289 |
5289 |
5290 meta := self theMetaclass. |
5290 meta := self theMetaclass. |
5291 cls := self theNonMetaclass. |
5291 cls := self theNonMetaclass. |
5292 |
5292 |
5293 cannotCheckReason := nil. |
5293 cannotCheckReason := nil. |
5294 |
5294 |
5295 versionMethod := self findVersionMethod. |
5295 versionMethod := self findVersionMethod. |
5296 versionMethod isNil ifTrue:[ |
5296 versionMethod isNil ifTrue:[ |
5297 cannotCheckReason := 'no valid version method'. |
5297 cannotCheckReason := 'no valid version method'. |
5298 ] ifFalse:[ |
5298 ] ifFalse:[ |
5299 "/ |
5299 "/ |
5300 "/ if its a method returning the string, |
5300 "/ if its a method returning the string, |
5301 "/ thats the returned value |
5301 "/ thats the returned value |
5302 "/ |
5302 "/ |
5303 versionFromCode := versionMethod valueWithReceiver:cls arguments:#(). |
5303 versionFromCode := versionMethod valueWithReceiver:cls arguments:#(). |
5304 versionFromCode isString ifFalse:[ |
5304 versionFromCode isString ifFalse:[ |
5305 cannotCheckReason := 'version method does not return a string' |
5305 cannotCheckReason := 'version method does not return a string' |
5306 ]. |
5306 ]. |
5307 ]. |
5307 ]. |
5308 |
5308 |
5309 versionMethod notNil ifTrue:[ |
5309 versionMethod notNil ifTrue:[ |
5310 pos := versionMethod sourcePosition. |
5310 pos := versionMethod sourcePosition. |
5311 pos isInteger ifFalse:[ |
5311 pos isInteger ifFalse:[ |
5312 "/ mhmh - either no version method, |
5312 "/ mhmh - either no version method, |
5313 "/ or updated due to a checkin. |
5313 "/ or updated due to a checkin. |
5314 "/ in any case, this should be a good source. |
5314 "/ in any case, this should be a good source. |
5315 |
5315 |
5316 ^ true. |
5316 ^ true. |
5317 "/ cannotCheckReason := 'no source position for version-method' |
5317 "/ cannotCheckReason := 'no source position for version-method' |
5318 ] |
5318 ] |
5319 ]. |
5319 ]. |
5320 |
5320 |
5321 cannotCheckReason notNil ifTrue:[ |
5321 cannotCheckReason notNil ifTrue:[ |
5322 ('Class [warning]: ' , cannotCheckReason , ' in ' , self name) infoPrintCR. |
5322 ('Class [warning]: ' , cannotCheckReason , ' in ' , self name) infoPrintCR. |
5323 'Class [info]: cannot validate source; trusting source' infoPrintCR. |
5323 'Class [info]: cannot validate source; trusting source' infoPrintCR. |
5324 ^ true |
5324 ^ true |
5325 ]. |
5325 ]. |
5326 |
5326 |
5327 oldPos := aStream position. |
5327 oldPos := aStream position. |
5328 Stream positionErrorSignal handle:[:ex | |
5328 Stream positionErrorSignal handle:[:ex | |
5329 'Class [info]: position error when accessing source' infoPrintCR. |
5329 'Class [info]: position error when accessing source' infoPrintCR. |
5330 ^ false |
5330 ^ false |
5331 ] do:[ |
5331 ] do:[ |
5332 aStream position1Based:pos. |
5332 aStream position:pos-1. |
5333 ]. |
5333 ]. |
5334 src := aStream nextChunk. |
5334 src := aStream nextChunk. |
5335 aStream position:oldPos. |
5335 aStream position:oldPos. |
5336 |
5336 |
5337 (src isEmptyOrNil) ifTrue:[ |
5337 (src isEmptyOrNil) ifTrue:[ |
5338 'Class [info]: empty source for version-method' infoPrintCR. |
5338 'Class [info]: empty source for version-method' infoPrintCR. |
5339 ^ false |
5339 ^ false |
5340 ]. |
5340 ]. |
5341 (src startsWith:'version') ifFalse:[ |
5341 (src startsWith:'version') ifFalse:[ |
5342 'Class [info]: corrupted source (source does not correspond to binary)' infoPrintCR. |
5342 'Class [info]: corrupted source (source does not correspond to binary)' infoPrintCR. |
5343 ^ false |
5343 ^ false |
5344 ]. |
5344 ]. |
5345 |
5345 |
5346 versionFromSource := Class revisionStringFromSource:src. |
5346 versionFromSource := Class revisionStringFromSource:src. |
5347 versionFromSource = versionFromCode ifTrue:[ |
5347 versionFromSource = versionFromCode ifTrue:[ |
5348 ValidatedClasses notNil ifTrue:[ ValidatedClasses add:self ]. |
5348 ValidatedClasses notNil ifTrue:[ ValidatedClasses add:self ]. |
5349 ^ true |
5349 ^ true |
5350 ]. |
5350 ]. |
5351 |
5351 |
5352 versionFromSource isNil ifTrue:[ |
5352 versionFromSource isNil ifTrue:[ |
5353 'Class [info]: version-from source is nil' infoPrintCR. |
5353 'Class [info]: version-from source is nil' infoPrintCR. |
5354 ^ false |
5354 ^ false |
5355 ]. |
5355 ]. |
5356 |
5356 |
5357 "/ mhmh - check my binary version ... |
5357 "/ mhmh - check my binary version ... |
5358 |
5358 |
5359 info := Class revisionInfoFromString:versionFromSource. |
5359 info := Class revisionInfoFromString:versionFromSource. |
5360 info notNil ifTrue:[ |
5360 info notNil ifTrue:[ |
5361 rev := info at:#revision. |
5361 rev := info at:#revision. |
5362 rev = self binaryRevision ifTrue:[ |
5362 rev = self binaryRevision ifTrue:[ |
5363 ValidatedClasses notNil ifTrue:[ ValidatedClasses add:self ]. |
5363 ValidatedClasses notNil ifTrue:[ ValidatedClasses add:self ]. |
5364 ^ true |
5364 ^ true |
5365 ]. |
5365 ]. |
5366 ]. |
5366 ]. |
5367 'Class [info]: source-version is different from binaryRevision' infoPrintCR. |
5367 'Class [info]: source-version is different from binaryRevision' infoPrintCR. |
5368 ^ false |
5368 ^ false |
5369 |
5369 |
5370 "Modified: / 29-09-2011 / 14:29:55 / cg" |
5370 "Modified: / 29-09-2011 / 14:29:55 / cg" |