Class.st
changeset 1113 840b03d131d7
parent 1107 e0411b74b808
child 1116 a3c136969f7c
equal deleted inserted replaced
1112:0d8dd47d386a 1113:840b03d131d7
    13 ClassDescription subclass:#Class
    13 ClassDescription subclass:#Class
    14 	instanceVariableNames:'classvars comment subclasses classFilename package revision
    14 	instanceVariableNames:'classvars comment subclasses classFilename package revision
    15 		history'
    15 		history'
    16 	classVariableNames:'UpdatingChanges LockChangesFile FileOutErrorSignal
    16 	classVariableNames:'UpdatingChanges LockChangesFile FileOutErrorSignal
    17 		CatchMethodRedefinitions MethodRedefinitionSignal
    17 		CatchMethodRedefinitions MethodRedefinitionSignal
    18 		UpdateChangeFileQuerySignal TryLocalSourceFirst'
    18 		UpdateChangeFileQuerySignal TryLocalSourceFirst
       
    19 		ChangeFileAccessLock'
    19 	poolDictionaries:''
    20 	poolDictionaries:''
    20 	category:'Kernel-Classes'
    21 	category:'Kernel-Classes'
    21 !
    22 !
    22 
    23 
    23 !Class class methodsFor:'documentation'!
    24 !Class class methodsFor:'documentation'!
   125     LockChangesFile := false.
   126     LockChangesFile := false.
   126     CatchMethodRedefinitions := true.
   127     CatchMethodRedefinitions := true.
   127     TryLocalSourceFirst := false.
   128     TryLocalSourceFirst := false.
   128 
   129 
   129     FileOutErrorSignal isNil ifTrue:[
   130     FileOutErrorSignal isNil ifTrue:[
   130 	FileOutErrorSignal := ErrorSignal newSignalMayProceed:false.
   131         FileOutErrorSignal := ErrorSignal newSignalMayProceed:false.
   131 	FileOutErrorSignal nameClass:self message:#fileOutErrorSignal.
   132         FileOutErrorSignal nameClass:self message:#fileOutErrorSignal.
   132 	FileOutErrorSignal notifierString:'error during fileOut'.
   133         FileOutErrorSignal notifierString:'error during fileOut'.
   133 
   134 
   134 	MethodRedefinitionSignal := ErrorSignal newSignalMayProceed:true.
   135         MethodRedefinitionSignal := ErrorSignal newSignalMayProceed:true.
   135 	MethodRedefinitionSignal nameClass:self message:#methodRedefinitionSignal.
   136         MethodRedefinitionSignal nameClass:self message:#methodRedefinitionSignal.
   136 	MethodRedefinitionSignal notifierString:'attempt to redefine method from different package'.
   137         MethodRedefinitionSignal notifierString:'attempt to redefine method from different package'.
   137 
   138 
   138 	UpdateChangeFileQuerySignal := QuerySignal new mayProceed:true.
   139         UpdateChangeFileQuerySignal := QuerySignal new mayProceed:true.
   139 	UpdateChangeFileQuerySignal nameClass:self message:#updateChangeFileQuerySignal.
   140         UpdateChangeFileQuerySignal nameClass:self message:#updateChangeFileQuerySignal.
   140 	UpdateChangeFileQuerySignal notifierString:'asking if changeFile update is wanted'.
   141         UpdateChangeFileQuerySignal notifierString:'asking if changeFile update is wanted'.
   141 	UpdateChangeFileQuerySignal handlerBlock:[:ex | ex proceedWith:UpdatingChanges].
   142         UpdateChangeFileQuerySignal handlerBlock:[:ex | ex proceedWith:UpdatingChanges].
   142     ]
   143 
       
   144         ChangeFileAccessLock := Semaphore forMutualExclusion.
       
   145     ]
       
   146 
       
   147     "Modified: 21.3.1996 / 16:31:30 / cg"
   143 ! !
   148 ! !
   144 
   149 
   145 !Class class methodsFor:'Signal constants'!
   150 !Class class methodsFor:'Signal constants'!
   146 
   151 
   147 fileOutErrorSignal
   152 fileOutErrorSignal
  1286     "add a category change record to the changes file"
  1291     "add a category change record to the changes file"
  1287 
  1292 
  1288     self writingChangePerform:#addChangeRecordForChangeCategory:to: with:category.
  1293     self writingChangePerform:#addChangeRecordForChangeCategory:to: with:category.
  1289 !
  1294 !
  1290 
  1295 
  1291 addChangeRecordForChangeCategory:category to:aStream
       
  1292     "append a category change record to aStream"
       
  1293 
       
  1294     self printClassNameOn:aStream.
       
  1295     aStream nextPutAll:(' category:' , category storeString).
       
  1296     aStream nextPutChunkSeparator.
       
  1297 
       
  1298     "this test allows a smalltalk without Projects/ChangeSets"
       
  1299     Project notNil ifTrue:[
       
  1300 	Project addClassDefinitionChangeFor:self
       
  1301     ]
       
  1302 
       
  1303     "Created: 3.12.1995 / 13:43:33 / cg"
       
  1304     "Modified: 3.12.1995 / 14:10:34 / cg"
       
  1305 !
       
  1306 
       
  1307 addChangeRecordForClass:aClass
  1296 addChangeRecordForClass:aClass
  1308     "add a class-definition-record to the changes file"
  1297     "add a class-definition-record to the changes file"
  1309 
  1298 
  1310     self writingChangePerform:#addChangeRecordForClass:to: with:aClass.
  1299     self writingChangePerform:#addChangeRecordForClass:to: with:aClass.
  1311 !
  1300 !
  1312 
  1301 
  1313 addChangeRecordForClass:aClass to:aStream
       
  1314     "append a class-definition-record to aStream"
       
  1315 
       
  1316     aClass isLoaded ifTrue:[
       
  1317 	aClass fileOutDefinitionOn:aStream.
       
  1318 	aStream nextPutChunkSeparator.
       
  1319 	Project notNil ifTrue:[
       
  1320 	    Project addClassDefinitionChangeFor:aClass 
       
  1321 	]
       
  1322     ]
       
  1323 
       
  1324     "Created: 3.12.1995 / 13:57:44 / cg"
       
  1325     "Modified: 3.12.1995 / 14:11:26 / cg"
       
  1326 !
       
  1327 
       
  1328 addChangeRecordForClassCheckIn:aClass
  1302 addChangeRecordForClassCheckIn:aClass
  1329     "append a class-was-checkedIn-record to the changes file"
  1303     "append a class-was-checkedIn-record to the changes file"
  1330 
  1304 
  1331     self addInfoRecord:('checkin ' , aClass name , ' (' , aClass revision , ')')
  1305     self addInfoRecord:('checkin ' , aClass name , ' (' , aClass revision , ')')
  1332 
  1306 
  1338     "add a class-comment-record to the changes file"
  1312     "add a class-comment-record to the changes file"
  1339 
  1313 
  1340     self writingChangePerform:#addChangeRecordForClassComment:to: with:aClass.
  1314     self writingChangePerform:#addChangeRecordForClassComment:to: with:aClass.
  1341 !
  1315 !
  1342 
  1316 
  1343 addChangeRecordForClassComment:aClass to:aStream
       
  1344     "append a class-comment-record to aStream"
       
  1345 
       
  1346     aClass fileOutCommentOn:aStream.
       
  1347 
       
  1348     "Modified: 4.3.1996 / 16:49:08 / cg"
       
  1349 !
       
  1350 
       
  1351 addChangeRecordForClassFileOut:aClass
  1317 addChangeRecordForClassFileOut:aClass
  1352     "append a class-was-filedOut-record to the changes file"
  1318     "append a class-was-filedOut-record to the changes file"
  1353 
  1319 
  1354     self addInfoRecord:('fileOut ' , aClass name) 
  1320     self addInfoRecord:('fileOut ' , aClass name) 
  1355 !
  1321 !
  1358     "add a class-instvars-record to the changes file"
  1324     "add a class-instvars-record to the changes file"
  1359 
  1325 
  1360     self writingChangePerform:#addChangeRecordForClassInstvars:to: with:aClass.
  1326     self writingChangePerform:#addChangeRecordForClassInstvars:to: with:aClass.
  1361 !
  1327 !
  1362 
  1328 
  1363 addChangeRecordForClassInstvars:aClass to:aStream
       
  1364     "append a class-instvars-record to aStream"
       
  1365 
       
  1366     aClass fileOutClassInstVarDefinitionOn:aStream.
       
  1367     aStream nextPutChunkSeparator.
       
  1368 !
       
  1369 
       
  1370 addChangeRecordForClassRemove:oldName
  1329 addChangeRecordForClassRemove:oldName
  1371     "add a class-remove-record to the changes file"
  1330     "add a class-remove-record to the changes file"
  1372 
  1331 
  1373     self writingChangePerform:#addChangeRecordForClassRemove:to: with:oldName.
  1332     self writingChangePerform:#addChangeRecordForClassRemove:to: with:oldName.
  1374 !
  1333 !
  1375 
  1334 
  1376 addChangeRecordForClassRemove:oldName to:aStream
       
  1377     "append a class-remove-record to aStream"
       
  1378 
       
  1379     aStream nextPutAll:('Smalltalk removeClass:' , oldName).
       
  1380     aStream nextPutChunkSeparator.
       
  1381 !
       
  1382 
       
  1383 addChangeRecordForClassRename:oldName to:newName
  1335 addChangeRecordForClassRename:oldName to:newName
  1384     "add a class-rename-record to the changes file"
  1336     "add a class-rename-record to the changes file"
  1385 
  1337 
  1386     self writingChangeDo:[:aStream |
  1338     self writingChangeDo:[:aStream |
  1387 	self addChangeRecordForClassRename:oldName to:newName to:aStream
  1339 	self addChangeRecordForClassRename:oldName to:newName to:aStream
  1388     ]
  1340     ]
  1389 !
       
  1390 
       
  1391 addChangeRecordForClassRename:oldName to:newName to:aStream
       
  1392     "append a class-rename-record to aStream"
       
  1393 
       
  1394     aStream nextPutAll:('Smalltalk renameClass:' , oldName , ' to:''' , newName , '''').
       
  1395     aStream nextPutChunkSeparator.
       
  1396 !
  1341 !
  1397 
  1342 
  1398 addChangeRecordForMethod:aMethod
  1343 addChangeRecordForMethod:aMethod
  1399     "add a method-change-record to the changes file"
  1344     "add a method-change-record to the changes file"
  1400 
  1345 
  1405 	    Project addMethodChange:aMethod in:self
  1350 	    Project addMethodChange:aMethod in:self
  1406 	]
  1351 	]
  1407     ]
  1352     ]
  1408 !
  1353 !
  1409 
  1354 
  1410 addChangeRecordForMethod:aMethod to:aStream
       
  1411     "append a method-change-record to aStream"
       
  1412 
       
  1413     self fileOutMethod:aMethod on:aStream.
       
  1414 !
       
  1415 
       
  1416 addChangeRecordForMethodCategory:aMethod category:aString
  1355 addChangeRecordForMethodCategory:aMethod category:aString
  1417     "add a methodCategory-change-record to the changes file"
  1356     "add a methodCategory-change-record to the changes file"
  1418 
  1357 
  1419     self askIfUpdatingChanges ifTrue:[
  1358     self askIfUpdatingChanges ifTrue:[
  1420 	self writingChangeDo:[:aStream |
  1359 	self writingChangeDo:[:aStream |
  1423 
  1362 
  1424 	"this test allows a smalltalk without Projects/ChangeSets"
  1363 	"this test allows a smalltalk without Projects/ChangeSets"
  1425 	Project notNil ifTrue:[
  1364 	Project notNil ifTrue:[
  1426 	    Project addMethodCategoryChange:aMethod category:aString in:self
  1365 	    Project addMethodCategoryChange:aMethod category:aString in:self
  1427 	]
  1366 	]
  1428     ]
       
  1429 !
       
  1430 
       
  1431 addChangeRecordForMethodCategory:aMethod category:newCategory to:aStream
       
  1432     "append a methodCategory-change-record to aStream"
       
  1433 
       
  1434     |selector|
       
  1435 
       
  1436     selector := aMethod selector.
       
  1437     selector notNil ifTrue:[
       
  1438 	aStream nextPutAll:'('.
       
  1439 	self printClassNameOn:aStream.
       
  1440 	aStream nextPutAll:(' compiledMethodAt:' , selector storeString).
       
  1441 	aStream nextPutAll:(') category:' , newCategory storeString).
       
  1442 	aStream nextPutChunkSeparator.
       
  1443     ]
  1367     ]
  1444 !
  1368 !
  1445 
  1369 
  1446 addChangeRecordForMethodPrivacy:aMethod
  1370 addChangeRecordForMethodPrivacy:aMethod
  1447     "add a method-privacy-change-record to the changes file"
  1371     "add a method-privacy-change-record to the changes file"
  1455     ]
  1379     ]
  1456 
  1380 
  1457     "Modified: 27.8.1995 / 22:47:32 / claus"
  1381     "Modified: 27.8.1995 / 22:47:32 / claus"
  1458 !
  1382 !
  1459 
  1383 
  1460 addChangeRecordForMethodPrivacy:aMethod to:aStream
       
  1461     "append a method-privacy-change-record to aStream"
       
  1462 
       
  1463     |selector|
       
  1464 
       
  1465     selector := aMethod selector.
       
  1466     selector notNil ifTrue:[
       
  1467 	aStream nextPutAll:'('.
       
  1468 	self printClassNameOn:aStream.
       
  1469 	aStream nextPutAll:(' compiledMethodAt:' , selector storeString).
       
  1470 	aStream nextPutAll:(') privacy:' , aMethod privacy storeString).
       
  1471 	aStream nextPutChunkSeparator.
       
  1472     ]
       
  1473 
       
  1474     "Modified: 27.8.1995 / 22:59:56 / claus"
       
  1475 !
       
  1476 
       
  1477 addChangeRecordForPrimitiveDefinitions:aClass
  1384 addChangeRecordForPrimitiveDefinitions:aClass
  1478     "add a primitiveDefinitions-record to the changes file"
  1385     "add a primitiveDefinitions-record to the changes file"
  1479 
  1386 
  1480     self askIfUpdatingChanges ifTrue:[
  1387     self askIfUpdatingChanges ifTrue:[
  1481 	self writingChangePerform:#addChangeRecordForPrimitiveDefinitions:to: with:aClass.
  1388 	self writingChangePerform:#addChangeRecordForPrimitiveDefinitions:to: with:aClass.
  1483 	    Project addPrimitiveDefinitionsChangeFor:aClass
  1390 	    Project addPrimitiveDefinitionsChangeFor:aClass
  1484 	]
  1391 	]
  1485     ]
  1392     ]
  1486 !
  1393 !
  1487 
  1394 
  1488 addChangeRecordForPrimitiveDefinitions:aClass to:aStream
       
  1489     "append a primitiveDefinitions-record to aStream"
       
  1490 
       
  1491     aStream nextPutAll:aClass name; nextPutAll:' primitiveDefinitions:'''; cr; 
       
  1492 	    nextPutAll:(aClass primitiveDefinitionsString storeString copyFrom:2).
       
  1493     aStream nextPutChunkSeparator.
       
  1494 !
       
  1495 
       
  1496 addChangeRecordForPrimitiveFunctions:aClass
  1395 addChangeRecordForPrimitiveFunctions:aClass
  1497     "add a primitiveFunctions-record to the changes file"
  1396     "add a primitiveFunctions-record to the changes file"
  1498 
  1397 
  1499     self askIfUpdatingChanges ifTrue:[
  1398     self askIfUpdatingChanges ifTrue:[
  1500 	self writingChangePerform:#addChangeRecordForPrimitiveFunctions:to: with:aClass.
  1399 	self writingChangePerform:#addChangeRecordForPrimitiveFunctions:to: with:aClass.
  1502 	    Project addPrimitiveFunctionsChangeFor:aClass
  1401 	    Project addPrimitiveFunctionsChangeFor:aClass
  1503 	]
  1402 	]
  1504     ]
  1403     ]
  1505 !
  1404 !
  1506 
  1405 
  1507 addChangeRecordForPrimitiveFunctions:aClass to:aStream
       
  1508     "append a primitiveFunctions-record to aStream"
       
  1509 
       
  1510     aStream nextPutAll:aClass name; nextPutAll:' primitiveFunctions:'''; cr; 
       
  1511 	    nextPutAll:(aClass primitiveFunctionsString storeString copyFrom:2).
       
  1512     aStream nextPutChunkSeparator.
       
  1513 !
       
  1514 
       
  1515 addChangeRecordForPrimitiveVariables:aClass
  1406 addChangeRecordForPrimitiveVariables:aClass
  1516     "add a primitiveVariables-record to the changes file"
  1407     "add a primitiveVariables-record to the changes file"
  1517 
  1408 
  1518     self askIfUpdatingChanges ifTrue:[
  1409     self askIfUpdatingChanges ifTrue:[
  1519 	self writingChangePerform:#addChangeRecordForPrimitiveVariables:to: with:aClass.
  1410 	self writingChangePerform:#addChangeRecordForPrimitiveVariables:to: with:aClass.
  1521 	    Project addPrimitiveVariablesChangeFor:aClass
  1412 	    Project addPrimitiveVariablesChangeFor:aClass
  1522 	]
  1413 	]
  1523     ]
  1414     ]
  1524 !
  1415 !
  1525 
  1416 
  1526 addChangeRecordForPrimitiveVariables:aClass to:aStream
       
  1527     "append a primitiveVariables-record to aStream"
       
  1528 
       
  1529     aStream nextPutAll:aClass name; nextPutAll:' primitiveVariables:'''; cr; 
       
  1530 	    nextPutAll:(aClass primitiveVariablesString storeString copyFrom:2).
       
  1531     aStream nextPutChunkSeparator.
       
  1532 !
       
  1533 
       
  1534 addChangeRecordForRemoveSelector:aSelector
  1417 addChangeRecordForRemoveSelector:aSelector
  1535     "add a method-remove-record to the changes file"
  1418     "add a method-remove-record to the changes file"
  1536 
  1419 
  1537     self writingChangePerform:#addChangeRecordForRemoveSelector:to: with:aSelector.
  1420     self writingChangePerform:#addChangeRecordForRemoveSelector:to: with:aSelector.
  1538 !
  1421 !
  1539 
  1422 
  1540 addChangeRecordForRemoveSelector:aSelector to:aStream
       
  1541     "append a method-remove-record to aStream"
       
  1542 
       
  1543     self printClassNameOn:aStream.
       
  1544     aStream nextPutAll:(' removeSelector:#' , aSelector).
       
  1545     aStream nextPutChunkSeparator.
       
  1546 !
       
  1547 
       
  1548 addChangeRecordForRenameCategory:oldCategory to:newCategory
  1423 addChangeRecordForRenameCategory:oldCategory to:newCategory
  1549     "add a category-rename record to the changes file"
  1424     "add a category-rename record to the changes file"
  1550 
  1425 
  1551     self writingChangeDo:[:aStream |
  1426     self writingChangeDo:[:aStream |
  1552 	self addChangeRecordForRenameCategory:oldCategory to:newCategory to:aStream.
  1427 	self addChangeRecordForRenameCategory:oldCategory to:newCategory to:aStream.
  1553     ]
  1428     ]
  1554 !
  1429 !
  1555 
  1430 
  1556 addChangeRecordForRenameCategory:oldCategory to:newCategory to:aStream
       
  1557     "append a category-rename record to aStream"
       
  1558 
       
  1559     self printClassNameOn:aStream.
       
  1560     aStream nextPutAll:(' renameCategory:' , oldCategory storeString).
       
  1561     aStream nextPutAll:(' to:' , newCategory storeString).
       
  1562     aStream nextPutChunkSeparator.
       
  1563 !
       
  1564 
       
  1565 addChangeRecordForSnapshot:aFileName
  1431 addChangeRecordForSnapshot:aFileName
  1566     "add a snapshot-record to the changes file"
  1432     "add a snapshot-record to the changes file"
  1567 
  1433 
  1568     self addInfoRecord:('snapshot ' , aFileName) 
  1434     self addInfoRecord:('snapshot ' , aFileName) 
  1569 !
  1435 !
  1589     "add an info-record (snapshot, class fileOut etc.) to the changes file"
  1455     "add an info-record (snapshot, class fileOut etc.) to the changes file"
  1590 
  1456 
  1591     self writingChangeWithTimeStamp:false perform:#addInfoRecord:to: with:aMessage.
  1457     self writingChangeWithTimeStamp:false perform:#addInfoRecord:to: with:aMessage.
  1592 
  1458 
  1593     "Modified: 18.11.1995 / 15:45:10 / cg"
  1459     "Modified: 18.11.1995 / 15:45:10 / cg"
  1594 !
       
  1595 
       
  1596 addInfoRecord:aMessage to:aStream
       
  1597     "append an info-record (snapshot, class fileOut etc.) to aStream"
       
  1598 
       
  1599     aStream nextPutAll:('''---- ' , aMessage , ' ',
       
  1600 			Date today printString , ' ' ,
       
  1601 			Time now printString ,
       
  1602 			' ----''').
       
  1603     aStream nextPutChunkSeparator.
       
  1604 !
  1460 !
  1605 
  1461 
  1606 changesStream
  1462 changesStream
  1607     "return a Stream for the writing changes file - or nil if no update is wanted"
  1463     "return a Stream for the writing changes file - or nil if no update is wanted"
  1608 
  1464 
  1663     UpdateChangeFileQuerySignal handle:[:ex | 
  1519     UpdateChangeFileQuerySignal handle:[:ex | 
  1664 	ex proceedWith:false
  1520 	ex proceedWith:false
  1665     ] do:[
  1521     ] do:[
  1666 	aBlock value
  1522 	aBlock value
  1667     ].
  1523     ].
  1668 !
       
  1669 
       
  1670 writingChangeDo:aBlock
       
  1671     "common helper to write a change record.
       
  1672      Opens the changefile and executes aBlock passing the stream
       
  1673      as argument. WriteErrors are cought and will lead to a warning.
       
  1674      The changefile is not kept open, to force the change to go to disk
       
  1675      as soon as possible - thus, in case of a crash, no changes should
       
  1676      be lost due to buffering."
       
  1677 
       
  1678     self writingChangeWithTimeStamp:true do:aBlock
       
  1679 
       
  1680     "Modified: 18.11.1995 / 15:43:36 / cg"
       
  1681 !
       
  1682 
       
  1683 writingChangePerform:aSelector with:anArgument
       
  1684     self writingChangeWithTimeStamp:true perform:aSelector with:anArgument
       
  1685 
       
  1686     "Created: 28.10.1995 / 16:50:48 / cg"
       
  1687     "Modified: 18.11.1995 / 15:44:53 / cg"
       
  1688 !
       
  1689 
       
  1690 writingChangeWithTimeStamp:doStampIt do:aBlock
       
  1691     "common helper to write a change record.
       
  1692      Opens the changefile and executes aBlock passing the stream
       
  1693      as argument. WriteErrors are cought and will lead to a warning.
       
  1694      The changefile is not kept open, to force the change to go to disk
       
  1695      as soon as possible - thus, in case of a crash, no changes should
       
  1696      be lost due to buffering."
       
  1697 
       
  1698     |aStream|
       
  1699 
       
  1700     aStream := self changesStream.
       
  1701     aStream notNil ifTrue:[
       
  1702 	FileStream writeErrorSignal handle:[:ex |
       
  1703 	    self warn:('could not update the changes-file\\' , ex errorString) withCRs.
       
  1704 	    ex return
       
  1705 	] do:[
       
  1706 	    doStampIt ifTrue:[self addChangeTimeStampTo:aStream].
       
  1707 	    aBlock value:aStream.
       
  1708 	    aStream cr.
       
  1709 	].
       
  1710 	aStream close
       
  1711     ]
       
  1712 
       
  1713     "Created: 18.11.1995 / 15:36:02 / cg"
       
  1714 !
       
  1715 
       
  1716 writingChangeWithTimeStamp:stampIt perform:aSelector with:anArgument
       
  1717     self writingChangeWithTimeStamp:stampIt do:[:stream |
       
  1718 	self perform:aSelector with:anArgument with:stream.
       
  1719     ]
       
  1720 
       
  1721     "Created: 18.11.1995 / 15:44:28 / cg"
       
  1722 ! !
  1524 ! !
  1723 
  1525 
  1724 !Class methodsFor:'compiling'!
  1526 !Class methodsFor:'compiling'!
  1725 
  1527 
  1726 compile:code
  1528 compile:code
  3003     "
  2805     "
  3004       Float printOutProtocolOn:Stdout 
  2806       Float printOutProtocolOn:Stdout 
  3005     "
  2807     "
  3006 ! !
  2808 ! !
  3007 
  2809 
  3008 !Class methodsFor:'private'!
  2810 !Class methodsFor:'private changes management'!
       
  2811 
       
  2812 addChangeRecordForChangeCategory:category to:aStream
       
  2813     "append a category change record to aStream"
       
  2814 
       
  2815     self printClassNameOn:aStream.
       
  2816     aStream nextPutAll:(' category:' , category storeString).
       
  2817     aStream nextPutChunkSeparator.
       
  2818 
       
  2819     "this test allows a smalltalk without Projects/ChangeSets"
       
  2820     Project notNil ifTrue:[
       
  2821 	Project addClassDefinitionChangeFor:self
       
  2822     ]
       
  2823 
       
  2824     "Created: 3.12.1995 / 13:43:33 / cg"
       
  2825     "Modified: 3.12.1995 / 14:10:34 / cg"
       
  2826 !
       
  2827 
       
  2828 addChangeRecordForClass:aClass to:aStream
       
  2829     "append a class-definition-record to aStream"
       
  2830 
       
  2831     aClass isLoaded ifTrue:[
       
  2832 	aClass fileOutDefinitionOn:aStream.
       
  2833 	aStream nextPutChunkSeparator.
       
  2834 	Project notNil ifTrue:[
       
  2835 	    Project addClassDefinitionChangeFor:aClass 
       
  2836 	]
       
  2837     ]
       
  2838 
       
  2839     "Created: 3.12.1995 / 13:57:44 / cg"
       
  2840     "Modified: 3.12.1995 / 14:11:26 / cg"
       
  2841 !
       
  2842 
       
  2843 addChangeRecordForClassComment:aClass to:aStream
       
  2844     "append a class-comment-record to aStream"
       
  2845 
       
  2846     aClass fileOutCommentOn:aStream.
       
  2847 
       
  2848     "Modified: 4.3.1996 / 16:49:08 / cg"
       
  2849 !
       
  2850 
       
  2851 addChangeRecordForClassInstvars:aClass to:aStream
       
  2852     "append a class-instvars-record to aStream"
       
  2853 
       
  2854     aClass fileOutClassInstVarDefinitionOn:aStream.
       
  2855     aStream nextPutChunkSeparator.
       
  2856 !
       
  2857 
       
  2858 addChangeRecordForClassRemove:oldName to:aStream
       
  2859     "append a class-remove-record to aStream"
       
  2860 
       
  2861     aStream nextPutAll:('Smalltalk removeClass:' , oldName).
       
  2862     aStream nextPutChunkSeparator.
       
  2863 !
       
  2864 
       
  2865 addChangeRecordForClassRename:oldName to:newName to:aStream
       
  2866     "append a class-rename-record to aStream"
       
  2867 
       
  2868     aStream nextPutAll:('Smalltalk renameClass:' , oldName , ' to:''' , newName , '''').
       
  2869     aStream nextPutChunkSeparator.
       
  2870 !
       
  2871 
       
  2872 addChangeRecordForMethod:aMethod to:aStream
       
  2873     "append a method-change-record to aStream"
       
  2874 
       
  2875     self fileOutMethod:aMethod on:aStream.
       
  2876 !
       
  2877 
       
  2878 addChangeRecordForMethodCategory:aMethod category:newCategory to:aStream
       
  2879     "append a methodCategory-change-record to aStream"
       
  2880 
       
  2881     |selector|
       
  2882 
       
  2883     selector := aMethod selector.
       
  2884     selector notNil ifTrue:[
       
  2885 	aStream nextPutAll:'('.
       
  2886 	self printClassNameOn:aStream.
       
  2887 	aStream nextPutAll:(' compiledMethodAt:' , selector storeString).
       
  2888 	aStream nextPutAll:(') category:' , newCategory storeString).
       
  2889 	aStream nextPutChunkSeparator.
       
  2890     ]
       
  2891 !
       
  2892 
       
  2893 addChangeRecordForMethodPrivacy:aMethod to:aStream
       
  2894     "append a method-privacy-change-record to aStream"
       
  2895 
       
  2896     |selector|
       
  2897 
       
  2898     selector := aMethod selector.
       
  2899     selector notNil ifTrue:[
       
  2900 	aStream nextPutAll:'('.
       
  2901 	self printClassNameOn:aStream.
       
  2902 	aStream nextPutAll:(' compiledMethodAt:' , selector storeString).
       
  2903 	aStream nextPutAll:(') privacy:' , aMethod privacy storeString).
       
  2904 	aStream nextPutChunkSeparator.
       
  2905     ]
       
  2906 
       
  2907     "Modified: 27.8.1995 / 22:59:56 / claus"
       
  2908 !
       
  2909 
       
  2910 addChangeRecordForPrimitiveDefinitions:aClass to:aStream
       
  2911     "append a primitiveDefinitions-record to aStream"
       
  2912 
       
  2913     aStream nextPutAll:aClass name; nextPutAll:' primitiveDefinitions:'''; cr; 
       
  2914 	    nextPutAll:(aClass primitiveDefinitionsString storeString copyFrom:2).
       
  2915     aStream nextPutChunkSeparator.
       
  2916 !
       
  2917 
       
  2918 addChangeRecordForPrimitiveFunctions:aClass to:aStream
       
  2919     "append a primitiveFunctions-record to aStream"
       
  2920 
       
  2921     aStream nextPutAll:aClass name; nextPutAll:' primitiveFunctions:'''; cr; 
       
  2922 	    nextPutAll:(aClass primitiveFunctionsString storeString copyFrom:2).
       
  2923     aStream nextPutChunkSeparator.
       
  2924 !
       
  2925 
       
  2926 addChangeRecordForPrimitiveVariables:aClass to:aStream
       
  2927     "append a primitiveVariables-record to aStream"
       
  2928 
       
  2929     aStream nextPutAll:aClass name; nextPutAll:' primitiveVariables:'''; cr; 
       
  2930 	    nextPutAll:(aClass primitiveVariablesString storeString copyFrom:2).
       
  2931     aStream nextPutChunkSeparator.
       
  2932 !
       
  2933 
       
  2934 addChangeRecordForRemoveSelector:aSelector to:aStream
       
  2935     "append a method-remove-record to aStream"
       
  2936 
       
  2937     self printClassNameOn:aStream.
       
  2938     aStream nextPutAll:(' removeSelector:#' , aSelector).
       
  2939     aStream nextPutChunkSeparator.
       
  2940 !
       
  2941 
       
  2942 addChangeRecordForRenameCategory:oldCategory to:newCategory to:aStream
       
  2943     "append a category-rename record to aStream"
       
  2944 
       
  2945     self printClassNameOn:aStream.
       
  2946     aStream nextPutAll:(' renameCategory:' , oldCategory storeString).
       
  2947     aStream nextPutAll:(' to:' , newCategory storeString).
       
  2948     aStream nextPutChunkSeparator.
       
  2949 !
       
  2950 
       
  2951 addInfoRecord:aMessage to:aStream
       
  2952     "append an info-record (snapshot, class fileOut etc.) to aStream"
       
  2953 
       
  2954     aStream nextPutAll:('''---- ' , aMessage , ' ',
       
  2955 			Date today printString , ' ' ,
       
  2956 			Time now printString ,
       
  2957 			' ----''').
       
  2958     aStream nextPutChunkSeparator.
       
  2959 !
       
  2960 
       
  2961 writingChangeDo:aBlock
       
  2962     "common helper to write a change record.
       
  2963      Opens the changefile and executes aBlock passing the stream
       
  2964      as argument. WriteErrors are cought and will lead to a warning.
       
  2965      The changefile is not kept open, to force the change to go to disk
       
  2966      as soon as possible - thus, in case of a crash, no changes should
       
  2967      be lost due to buffering."
       
  2968 
       
  2969     self writingChangeWithTimeStamp:true do:aBlock
       
  2970 
       
  2971     "Modified: 18.11.1995 / 15:43:36 / cg"
       
  2972 !
       
  2973 
       
  2974 writingChangePerform:aSelector with:anArgument
       
  2975     self writingChangeWithTimeStamp:true perform:aSelector with:anArgument
       
  2976 
       
  2977     "Created: 28.10.1995 / 16:50:48 / cg"
       
  2978     "Modified: 18.11.1995 / 15:44:53 / cg"
       
  2979 !
       
  2980 
       
  2981 writingChangeWithTimeStamp:doStampIt do:aBlock
       
  2982     "common helper to write a change record.
       
  2983      Opens the changefile and executes aBlock passing the stream
       
  2984      as argument. WriteErrors are cought and will lead to a warning.
       
  2985      The changefile is not kept open, to force the change to go to disk
       
  2986      as soon as possible - thus, in case of a crash, no changes should
       
  2987      be lost due to buffering."
       
  2988 
       
  2989     ChangeFileAccessLock critical:[
       
  2990         |aStream|
       
  2991 
       
  2992         aStream := self changesStream.
       
  2993         aStream notNil ifTrue:[
       
  2994             FileStream writeErrorSignal handle:[:ex |
       
  2995                 self warn:('could not update the changes-file\\' , ex errorString) withCRs.
       
  2996                 ex return
       
  2997             ] do:[
       
  2998                 doStampIt ifTrue:[self addChangeTimeStampTo:aStream].
       
  2999                 aBlock value:aStream.
       
  3000                 aStream cr.
       
  3001             ].
       
  3002             aStream close
       
  3003         ]
       
  3004     ]
       
  3005 
       
  3006     "Created: 18.11.1995 / 15:36:02 / cg"
       
  3007     "Modified: 21.3.1996 / 16:32:30 / cg"
       
  3008 !
       
  3009 
       
  3010 writingChangeWithTimeStamp:stampIt perform:aSelector with:anArgument
       
  3011     self writingChangeWithTimeStamp:stampIt do:[:stream |
       
  3012 	self perform:aSelector with:anArgument with:stream.
       
  3013     ]
       
  3014 
       
  3015     "Created: 18.11.1995 / 15:44:28 / cg"
       
  3016 ! !
       
  3017 
       
  3018 !Class methodsFor:'private helpers'!
  3009 
  3019 
  3010 addAllCategoriesTo:aCollection
  3020 addAllCategoriesTo:aCollection
  3011     "helper - add categories and all superclasses categories
  3021     "helper - add categories and all superclasses categories
  3012      to the argument, aCollection"
  3022      to the argument, aCollection"
  3013 
  3023 
  3085 ! !
  3095 ! !
  3086 
  3096 
  3087 !Class methodsFor:'queries'!
  3097 !Class methodsFor:'queries'!
  3088 
  3098 
  3089 allCategories
  3099 allCategories
  3090     "Return a Collection of all method-category strings known in class
  3100     "Return a collection of all method-categories known in class
  3091      and all superclasses. The returned collection is not sorted by any order."
  3101      and all superclasses. This does NOT include the metaclass categories.
       
  3102      The returned collection is not sorted by any order."
  3092 
  3103 
  3093     |coll|
  3104     |coll|
  3094 
  3105 
  3095     coll := OrderedCollection new.
  3106     coll := OrderedCollection new.
  3096     self addAllCategoriesTo:coll.
  3107     self addAllCategoriesTo:coll.
  3097     ^ coll
  3108     ^ coll
  3098 
  3109 
  3099     "
  3110     "
  3100      Point categories  
  3111      Point categories  
  3101      Point allCategories 
  3112      Point allCategories 
  3102     "
  3113 
       
  3114      Point class categories   
       
  3115      Point class allCategories  
       
  3116     "
       
  3117 
       
  3118     "Modified: 21.3.1996 / 16:28:57 / cg"
  3103 !
  3119 !
  3104 
  3120 
  3105 categories
  3121 categories
  3106     "Return a Collection of all method-category strings known in class.
  3122     "Return a collection of all method-categories known in the receiver class.
       
  3123      This does NOT include the metaclasses categories.
  3107      The returned collection is not sorted by any order."
  3124      The returned collection is not sorted by any order."
  3108 
  3125 
  3109     |newList cat|
  3126     |newList cat|
  3110 
  3127 
  3111     newList := OrderedCollection new.
  3128     newList := OrderedCollection new.
  3112     methodArray do:[:aMethod |
  3129     methodArray do:[:aMethod |
  3113 	cat := aMethod category.
  3130         cat := aMethod category.
  3114 	newList indexOf:cat ifAbsent:[newList add:cat]
  3131         newList indexOf:cat ifAbsent:[newList add:cat]
  3115     ].
  3132     ].
  3116     ^ newList
  3133     ^ newList
  3117 
  3134 
  3118     "
  3135     "
  3119      Point categories  
  3136      Point categories    
  3120     "
  3137      Point class categories  
       
  3138     "
       
  3139 
       
  3140     "Modified: 21.3.1996 / 16:28:06 / cg"
  3121 !
  3141 !
  3122 
  3142 
  3123 isClass
  3143 isClass
  3124     "return true, if the receiver is some kind of class 
  3144     "return true, if the receiver is some kind of class 
  3125      (a real class, not just behavior);
  3145      (a real class, not just behavior);
  3140 
  3160 
  3141 wasAutoloaded
  3161 wasAutoloaded
  3142     "return true, if this class came into the system via an
  3162     "return true, if this class came into the system via an
  3143      autoload; false otherwise.
  3163      autoload; false otherwise.
  3144      This is not an attribute of the class, but instead remembered in
  3164      This is not an attribute of the class, but instead remembered in
  3145      Autoload. The interface here is for covenience."
  3165      Autoload. The interface here is for your convenience."
  3146 
  3166 
  3147     ^ Autoload wasAutoloaded:self
  3167     ^ Autoload wasAutoloaded:self
       
  3168 
       
  3169     "Modified: 21.3.1996 / 16:27:09 / cg"
  3148 !
  3170 !
  3149 
  3171 
  3150 whichClassDefinesClassVar:aVariableName
  3172 whichClassDefinesClassVar:aVariableName
  3151     "return the class which defines the class variable
  3173     "return the class which defines the class variable
  3152      named aVariableName. This method should not be used for
  3174      named aVariableName. This method should not be used for
  3917 ! !
  3939 ! !
  3918 
  3940 
  3919 !Class class methodsFor:'documentation'!
  3941 !Class class methodsFor:'documentation'!
  3920 
  3942 
  3921 version
  3943 version
  3922     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.146 1996-03-19 18:46:42 cg Exp $'
  3944     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.147 1996-03-21 15:33:40 cg Exp $'
  3923 ! !
  3945 ! !
  3924 Class initialize!
  3946 Class initialize!