Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GS64: Add Metaprogramming, Dynamic-Binding and Comparison packages #85

Merged
merged 15 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion rowan/components/Deployment.ston
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ RwSimpleProjectLoadComponentV2 {
#packageNames : [
'Buoy-Assertions',
'Buoy-Assertions-Extensions',
'Buoy-Collections-Extensions',
'Buoy-Collections-GS64-Extensions',
'Buoy-Conditions-Extensions',
'Buoy-Comparison',
'Buoy-Comparison-Extensions',
'Buoy-Conditions',
'Buoy-Conditions-Extensions',
'Buoy-Dynamic-Binding',
'Buoy-Exception-Handling-Extensions',
'Buoy-Math-GS64-Extensions',
'Buoy-Metaprogramming',
'Buoy-Metaprogramming-Extensions',
'Buoy-Metaprogramming-GS64-Extensions'
],
Expand All @@ -19,15 +25,24 @@ RwSimpleProjectLoadComponentV2 {
'Buoy-Assertions-Extensions' : {
'symbolDictName' : 'Globals'
},
'Buoy-Collections-Extensions' : {
'symbolDictName' : 'Globals'
},
'Buoy-Collections-GS64-Extensions' : {
'symbolDictName' : 'Globals'
},
'Buoy-Comparison-Extensions' : {
'symbolDictName' : 'Globals'
},
'Buoy-Conditions-Extensions' : {
'symbolDictName' : 'Globals'
},
'Buoy-Exception-Handling-Extensions' : {
'symbolDictName' : 'Globals'
},
'Buoy-Math-GS64-Extensions' : {
'symbolDictName' : 'Globals'
},
'Buoy-Metaprogramming-Extensions' : {
'symbolDictName' : 'Globals'
},
Expand Down
5 changes: 4 additions & 1 deletion rowan/components/Tests.ston
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ RwSimpleProjectLoadComponentV2 {
],
#packageNames : [
'Buoy-Assertions-Tests',
'Buoy-Comparison-Tests',
'Buoy-Conditions-Tests',
'Buoy-Exception-Handling-Extensions-Tests',
'Buoy-Dynamic-Binding-Tests',
'Buoy-Exception-Handling-Tests',
'Buoy-Metaprogramming-Tests',
'Buoy-SUnit-Tests'
],
#comment : ''
Expand Down
33 changes: 23 additions & 10 deletions source/BaselineOfBuoy/BaselineOfBuoy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,33 @@ BaselineOfBuoy >> baselineAssertions: spec [
BaselineOfBuoy >> baselineCollections: spec [

spec
package: 'Buoy-Collections'
with: [ spec requires: #( 'Buoy-Assertions' 'Buoy-Dynamic-Binding' 'Buoy-Comparison' ) ];
package: 'Buoy-Collections' with: [
spec requires:
#( 'Buoy-Assertions' 'Buoy-Dynamic-Binding'
'Buoy-Comparison' ) ];
group: 'Deployment' with: 'Buoy-Collections';
package: 'Buoy-Collections-Tests'
with: [ spec requires: #( 'Buoy-Collections' 'Dependent-SUnit-Extensions' ) ];
package: 'Buoy-Collections-Extensions'
with: [ spec requires: 'Buoy-Collections' ];
group: 'Deployment' with: 'Buoy-Collections-Extensions';
package: 'Buoy-Collections-Tests' with: [
spec requires: #( 'Buoy-Collections' 'Buoy-Collections-Extensions'
'Dependent-SUnit-Extensions' ) ];
group: 'Tests' with: 'Buoy-Collections-Tests'
]

{ #category : #baselines }
BaselineOfBuoy >> baselineComparison: spec [

spec
package: 'Buoy-Comparison' with: [ spec requires: 'Buoy-Assertions' ];
package: 'Buoy-Comparison'
with: [ spec requires: 'Buoy-Assertions' ];
group: 'Deployment' with: 'Buoy-Comparison';
package: 'Buoy-Comparison-Extensions'
with: [ spec requires: 'Buoy-Comparison' ];
group: 'Deployment' with: 'Buoy-Comparison-Extensions';
package: 'Buoy-Comparison-Tests'
with: [ spec requires: #('Buoy-Comparison' 'Dependent-SUnit-Extensions') ];
with: [
spec requires: #( 'Buoy-Comparison-Extensions' 'Dependent-SUnit-Extensions' ) ];
group: 'Tests' with: 'Buoy-Comparison-Tests'
]

Expand Down Expand Up @@ -106,8 +117,8 @@ BaselineOfBuoy >> baselineExceptionHandling: spec [
spec
package: 'Buoy-Exception-Handling-Extensions';
group: 'Deployment' with: 'Buoy-Exception-Handling-Extensions';
package: 'Buoy-Exception-Handling-Extensions-Tests' with: [ spec requires: 'Buoy-Exception-Handling-Extensions' ];
group: 'Tests' with: 'Buoy-Exception-Handling-Extensions-Tests'
package: 'Buoy-Exception-Handling-Tests' with: [ spec requires: 'Buoy-Exception-Handling-Extensions' ];
group: 'Tests' with: 'Buoy-Exception-Handling-Tests'
]

{ #category : #baselines }
Expand All @@ -129,10 +140,12 @@ BaselineOfBuoy >> baselineMetaprogramming: spec [
group: 'Deployment' with: 'Buoy-Metaprogramming';
package: 'Buoy-Metaprogramming-Extensions'
with: [ spec requires: 'Buoy-Assertions' ];
group: 'Deployment' with: 'Buoy-Metaprogramming-Extensions';
package: 'Buoy-Metaprogramming-Pharo-Extensions';
group: 'Deployment' with: 'Buoy-Metaprogramming-Pharo-Extensions';
package: 'Buoy-Metaprogramming-Tests' with: [
spec requires:
#( 'Buoy-Metaprogramming' 'Buoy-Metaprogramming-Extensions' ) ];
#( 'Buoy-Metaprogramming' 'Buoy-Metaprogramming-Extensions'
'Buoy-Metaprogramming-Pharo-Extensions' ) ];
group: 'Tests' with: 'Buoy-Metaprogramming-Tests'
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Extension { #name : #SequenceableCollection }

{ #category : #'*Buoy-Collections-Extensions' }
SequenceableCollection >> equalityChecker [

^ SequenceableCollectionEqualityChecker new
]

{ #category : #'*Buoy-Collections-Extensions' }
SequenceableCollection >> withoutFirst [

^self withoutFirst: 1
]

{ #category : #'*Buoy-Collections-Extensions' }
SequenceableCollection >> withoutFirst: n [

(self size <= n) ifTrue: [^self species new].
^self copyFrom: n + 1 to: self size
]
1 change: 1 addition & 0 deletions source/Buoy-Collections-Extensions/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Buoy-Collections-Extensions' }
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Extension { #name : #AbstractDictionary }

{ #category : #'*Buoy-Collections-GS64-Extensions' }
AbstractDictionary >> at: key ifPresent: aBlock ifAbsentPut: anAbsentBlock [

| presentValue |
presentValue := self at: key ifAbsent: [
| absentValue |
absentValue := anAbsentBlock value.
self at: key put: absentValue.
^ absentValue ].
^ aBlock cull: presentValue
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ CharacterCollection >> expandMacros [
^ self expandMacrosWithArguments: #( )
]

{ #category : #'*Buoy-Collections-GS64-Extensions' }
CharacterCollection >> expandMacrosWith: anObject [

^ self expandMacrosWithArguments: { anObject }
]

{ #category : #'*Buoy-Collections-GS64-Extensions' }
CharacterCollection >> expandMacrosWith: anObject with: anotherObject [

Expand Down
20 changes: 20 additions & 0 deletions source/Buoy-Collections-GS64-Extensions/Collection.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,23 @@ Collection >> anyOne [

^ self any
]

{ #category : #'*Buoy-Collections-GS64-Extensions' }
Collection >> ifEmpty: emptyBlock ifNotEmpty: notEmptyBlock [

^ self isEmpty
ifTrue: emptyBlock
ifFalse: [ notEmptyBlock cull: self ]
]

{ #category : #'*Buoy-Collections-GS64-Extensions' }
Collection >> isSequenceable [

^ false
]

{ #category : #'*Buoy-Collections-GS64-Extensions' }
Collection >> select: selectBlock thenCollect: collectBlock [

^ (self select: selectBlock) collect: collectBlock
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #SequenceableCollection }

{ #category : #'*Buoy-Collections-GS64-Extensions' }
SequenceableCollection >> isSequenceable [

^ true
]
19 changes: 0 additions & 19 deletions source/Buoy-Collections/SequenceableCollection.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,3 @@ SequenceableCollection >> copyNoMoreThanLast: n [

^ self copyLast: ( n min: self size )
]

{ #category : #'*Buoy-Collections' }
SequenceableCollection >> equalityChecker [

^ SequenceableCollectionEqualityChecker new
]

{ #category : #'*Buoy-Collections' }
SequenceableCollection >> withoutFirst [

^self withoutFirst: 1
]

{ #category : #'*Buoy-Collections' }
SequenceableCollection >> withoutFirst: n [

(self size <= n) ifTrue: [^self species new].
^self copyFrom: n + 1 to: self size
]
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Extension { #name : #Object }

{ #category : #'*Buoy-Comparison' }
{ #category : #'*Buoy-Comparison-Extensions' }
Object >> equalityChecker [

^ PropertyBasedEqualityChecker on: self
]

{ #category : #'*Buoy-Comparison' }
{ #category : #'*Buoy-Comparison-Extensions' }
Object >> equalityHashCombinator [

^ BitwiseExclusiveDisjunctionHashCombinator new
Expand Down
1 change: 1 addition & 0 deletions source/Buoy-Comparison-Extensions/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Buoy-Comparison-Extensions' }
24 changes: 16 additions & 8 deletions source/Buoy-Dynamic-Binding/Optional.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,37 @@ Optional class >> unusedBecauseAll: anExplanationCollection [
{ #category : #'instance creation' }
Optional class >> whenAllUsedIn: optionals injectInto: aDyadicBlock [

^ optionals ifNotEmpty: [ optionals first whenAllUsedIn: optionals allButFirst injectInto: aDyadicBlock ] ifEmpty: [ self unused ]
^ optionals ifEmpty: [ self unused ] ifNotEmpty: [
optionals first
whenAllUsedIn: optionals allButFirst
injectInto: aDyadicBlock ]
]

{ #category : #'instance creation' }
Optional class >> whenAllUsedIn: optionals return: aMonadycBlock [

^ optionals ifNotEmpty: [ optionals first whenAllUsedIn: optionals allButFirst return: aMonadycBlock ] ifEmpty: [ self unused ]
^ optionals ifEmpty: [ self unused ] ifNotEmpty: [
optionals first
whenAllUsedIn: optionals allButFirst
return: aMonadycBlock ]
]

{ #category : #'instance creation' }
Optional class >> withUsedOnlyIn: optionals injectInto: aDyadicBlock [

^ optionals
ifNotEmpty: [ optionals first withUsedOnlyIn: optionals allButFirst injectInto: aDyadicBlock ]
ifEmpty: [ self unused ]
^ optionals ifEmpty: [ self unused ] ifNotEmpty: [
optionals first
withUsedOnlyIn: optionals allButFirst
injectInto: aDyadicBlock ]
]

{ #category : #'instance creation' }
Optional class >> withUsedOnlyIn: optionals return: aMonadycBlock [

^ optionals
ifNotEmpty: [ optionals first withUsedOnlyIn: optionals allButFirst return: aMonadycBlock ]
ifEmpty: [ self unused ]
^ optionals ifEmpty: [ self unused ] ifNotEmpty: [
optionals first
withUsedOnlyIn: optionals allButFirst
return: aMonadycBlock ]
]

{ #category : #comparing }
Expand Down
1 change: 0 additions & 1 deletion source/Buoy-Exception-Handling-Extensions-Tests/package.st

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ I'm a test case for the exception handling system.
Class {
#name : #ExceptionHandlingSystemTest,
#superclass : #TestCase,
#category : #'Buoy-Exception-Handling-Extensions-Tests'
#category : #'Buoy-Exception-Handling-Tests'
}

{ #category : #private }
Expand Down
1 change: 1 addition & 0 deletions source/Buoy-Exception-Handling-Tests/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Buoy-Exception-Handling-Tests' }
10 changes: 10 additions & 0 deletions source/Buoy-GS64-Compatibility/AbstractDictionary.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"
AbstractDictionary is an abstract class in GS64, the superclass of all the Dictionary-like abstractions.
This version is just a placeholder so we can easily create extension methods to load in GS64 specific
packages.
"
Class {
#name : #AbstractDictionary,
#superclass : #Collection,
#category : #'Buoy-GS64-Compatibility'
}
10 changes: 10 additions & 0 deletions source/Buoy-GS64-Compatibility/ClassOrganizer.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"
In GS64, a `ClassOrganizer` can answer queries about classes in the image, provides
tools and reports on information on classes and methods and can perform
cross-referencing and fileout.
"
Class {
#name : #ClassOrganizer,
#superclass : #Object,
#category : #'Buoy-GS64-Compatibility'
}
7 changes: 7 additions & 0 deletions source/Buoy-Math-GS64-Extensions/Number.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #Number }

{ #category : #'*Buoy-Math-GS64-Extensions' }
Number >> isZero [

^ self = 0
]
1 change: 1 addition & 0 deletions source/Buoy-Math-GS64-Extensions/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Buoy-Math-GS64-Extensions' }
11 changes: 11 additions & 0 deletions source/Buoy-Metaprogramming-GS64-Extensions/Class.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Extension { #name : #Class }

{ #category : #'*Buoy-Metaprogramming-GS64-Extensions' }
Class >> allLeafSubclasses [

| leafs |
leafs := OrderedCollection new.
(ClassOrganizer new allSubclassesOf: self) do: [ :class |
class subclasses ifEmpty: [ leafs add: class ] ].
^ leafs
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #Behavior }

{ #category : #'*Buoy-Metaprogramming' }
{ #category : #'*Buoy-Metaprogramming-Pharo-Extensions' }
Behavior >> allLeafSubclasses [

| leafs |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #Symbol }

{ #category : #'*Buoy-Metaprogramming' }
{ #category : #'*Buoy-Metaprogramming-Pharo-Extensions' }
Symbol >> argumentCount [

^self numArgs
Expand Down
1 change: 1 addition & 0 deletions source/Buoy-Metaprogramming-Pharo-Extensions/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Buoy-Metaprogramming-Pharo-Extensions' }
2 changes: 1 addition & 1 deletion source/Buoy-Metaprogramming-Tests/NamespaceTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ NamespaceTest >> testBindTo [
namespace bind: #Zero to: 0.

self
assertCollection: namespace names equals: #(#Zero);
assertCollection: namespace names hasSameElements: #(#Zero);
assert: namespace >> #Zero equals: 0
]

Expand Down
Loading