extensions.st
author Claus Gittinger <cg@exept.de>
Mon, 19 Jun 2017 16:54:35 +0200
changeset 4418 05f82ac9d198
parent 4400 23f57acf91ff
child 4429 7d3e464fb430
permissions -rw-r--r--
class: CharacterArray code duplication removed changed: #printf:on: #printf_printArgFrom:to:withData:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2337
755696d72648 comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
     1
"{ Package: 'stx:libbasic2' }"!
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
     2
4381
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     3
!ArithmeticValue methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     4
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     5
asQDouble
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     6
    "return a QDouble with same value"
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     7
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     8
    ^ self asFloat asQDouble
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     9
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    10
    "
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    11
     123 asQDouble
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    12
    "
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    13
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    14
    "Created: / 13-06-2017 / 16:48:24 / cg"
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    15
! !
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    16
4379
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    17
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    18
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    19
differenceFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    20
    "aQDouble does not know how to subtract the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    21
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    22
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    23
    ^ aQDouble retry:#- coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    24
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    25
    "Created: / 13-06-2017 / 08:55:38 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    26
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    27
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    28
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    29
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    30
equalFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    31
    "aQDouble does not know how to compare to the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    32
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    33
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    34
    ^ aQDouble retry:#= coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    35
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    36
    "Created: / 13-06-2017 / 08:55:30 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    37
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    38
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    39
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    40
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    41
lessFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    42
    "aQDouble does not know how to compare to the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    43
     Return true if aQDouble < self.
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    44
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    45
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    46
    ^ aQDouble retry:#< coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    47
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    48
    "Created: / 13-06-2017 / 08:55:20 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    49
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    50
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    51
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    52
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    53
productFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    54
    "aQDouble does not know how to multiply the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    55
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    56
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    57
    ^ aQDouble retry:#* coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    58
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    59
    "Created: / 13-06-2017 / 08:55:07 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    60
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    61
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    62
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    63
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    64
quotientFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    65
    "aQDouble does not know how to divide by the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    66
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    67
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    68
    ^ aQDouble retry:#/ coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    69
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    70
    "Created: / 13-06-2017 / 08:54:55 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    71
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    72
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    73
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    74
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    75
remainderFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    76
    "aQDouble does not know how to compute the remainder with the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    77
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    78
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    79
    ^ aQDouble retry:#rem: coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    80
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    81
    "Created: / 13-06-2017 / 08:54:47 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    82
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    83
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    84
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    85
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    86
sumFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    87
    "aQDouble does not know how to add the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    88
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    89
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    90
    ^ aQDouble retry:#+ coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    91
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    92
    "Created: / 13-06-2017 / 08:54:27 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    93
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    94
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    95
!CharacterArray methodsFor:'matching - phonetic'!
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    96
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    97
asKoelnerPhoneticCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    98
    "return a koelner phonetic code.
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    99
     The koelnerPhonetic code is for the german language what the soundex code is for english;
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   100
     it returns simular strings for similar sounding words.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   101
     There are some differences to soundex, though:
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   102
	its length is not limited to 4, but depends on the length of the original string;
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   103
	it does not start with the first character of the input.
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   104
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   105
     Caveat: this phonetic code is especially suited for german words.
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   106
	     Please have a look at the other phonetic comparison operators found
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   107
	     in PhoneticStringUtilities."
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   108
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   109
    ^ PhoneticStringUtilities koelnerPhoneticCodeOf:self
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   110
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   111
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   112
     #(
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   113
	'Müller'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   114
	'Miller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   115
	'Mueller'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   116
	'Mühler'
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   117
	'Mühlherr'
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   118
	'Mülherr'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   119
	'Myler'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   120
	'Millar'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   121
	'Myller'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   122
	'Müllar'
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   123
	'Müler'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   124
	'Muehler'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   125
	'Mülller'
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   126
	'Müllerr'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   127
	'Muehlherr'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   128
	'Muellar'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   129
	'Mueler'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   130
	'Mülleer'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   131
	'Mueller'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   132
	'Nüller'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   133
	'Nyller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   134
	'Niler'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   135
	'Czerny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   136
	'Tscherny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   137
	'Czernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   138
	'Tschernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   139
	'Schernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   140
	'Scherny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   141
	'Scherno'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   142
	'Czerne'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   143
	'Zerny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   144
	'Tzernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   145
	'Breschnew'
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   146
     ) do:[:w |
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   147
	 Transcript show:w; show:'->'; showCR:(w asKoelnerPhoneticCode)
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   148
     ].
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   149
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   150
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   151
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   152
     'Breschnew' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   153
     'Breschnew' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   154
     'Breschneff' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   155
     'Braeschneff' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   156
     'Braessneff' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   157
     'Pressneff' asKoelnerPhoneticCode -> '17863'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   158
     'Presznäph' asKoelnerPhoneticCode -> '17863'
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   159
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   160
! !
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   161
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   162
!CharacterArray methodsFor:'matching - phonetic'!
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   163
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   164
asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   165
    "return a soundex phonetic code or nil.
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   166
     Soundex returns similar codes for similar sounding words, making it a useful
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   167
     tool when searching for words where the correct spelling is unknown.
4190
031045a0f356 class: stx_libbasic2
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
   168
     (read Knuth or search the web if you don't know what a soundex code is).
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   169
2337
755696d72648 comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
   170
     Caveat: 'similar sounding words' means: 'similar sounding in ENGLISH'
4190
031045a0f356 class: stx_libbasic2
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
   171
             Please have a look at the other phonetic comparison operators found
031045a0f356 class: stx_libbasic2
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
   172
             in PhoneticStringUtilities."
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   173
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   174
    ^ PhoneticStringUtilities soundexCodeOf:self
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   175
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   176
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   177
     'claus' asSoundexCode
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   178
     'clause' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   179
     'close' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   180
     'smalltalk' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   181
     'smaltalk' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   182
     'smaltak' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   183
     'smaltok' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   184
     'smoltok' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   185
     'aa' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   186
     'by' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   187
     'bab' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   188
     'bob' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   189
     'bop' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   190
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   191
! !
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   192
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   193
!CharacterArray methodsFor:'printing & storing'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   194
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   195
printf:args
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   196
    "Format and print the receiver with <args> formatted in C style,
2295
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   197
     as specified in the Unix C-language manual page for printf(3).
3114
1d5224486d3c class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3094
diff changeset
   198
     Return the resulting string (i.e actually, this is more like an sprintf).
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   199
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   200
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   201
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   202
    |aStream|
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   203
3538
d79ee26ed971 class: Date
Stefan Vogel <sv@exept.de>
parents: 3274
diff changeset
   204
    aStream := CharacterWriteStream on:(self species uninitializedNew:self size).
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   205
    self printf:args on:aStream.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   206
    ^ aStream contents
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   207
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   208
    "
3796
70a4a03f4028 comment
Claus Gittinger <cg@exept.de>
parents: 3720
diff changeset
   209
     ('%05x %d %f %o' printf:{ 123. 234*5. 1.234. 8r377 } )    
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   210
     Transcript showCR:('%05x %d %f %o' printf:{ 123. 234*5. 1.234. 8r377 } )
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   211
    "
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   212
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   213
    "
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   214
     Transcript showCR: 'Some examples:'!!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   215
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   216
     Transcript show:'''%#x %#X %03o%*.*s'' printf: #(16rABCD 16rEF 5 9 5 ''ghijklmn'') = .'.
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   217
     Transcript show: ('%#x %#X %03o%*.*s' printf: #(16rABCD 16rEF 5 9 5 'ghijklmn')).
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   218
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   219
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   220
     Transcript show: '''%- 10.4s%.2e'' printf: (Array with: ''abcdefghijkl'' with: Float pi) = .'.
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   221
     Transcript show: ('%- 10.4s%.2e' printf: (Array with: 'abcdefghijkl' with: Float pi)).
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   222
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   223
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   224
     Transcript show: '''%8.3f'' printf: (Array with: 200 sqrt negated) = .'.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   225
     Transcript show: ('%8.3f' printf: (Array with: 200 sqrt negated)).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   226
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   227
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   228
     Transcript show: '''%c'' printf: #(16r41) = .'.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   229
     Transcript show: ('%c' printf: #(16r41)).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   230
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   231
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   232
     Transcript show: '''%f%2s%s%s%s'' sscanf: ''237.0 this is a test'' = '.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   233
     Transcript showCR: ('%f%2s%s%s%s'  sscanf: '237.0 this is a test') printString.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   234
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   235
     Transcript show: '''%d%f%s'' sscanf: ''25 54.32e-01 monday'' = '.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   236
     Transcript showCR: ('%d%f%s' sscanf: '25 54.32e-01 monday') printString.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   237
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   238
     Transcript show: '''%f%*f %8[A-F0-9]%c%d 0x%x%f'' sscanf: ''12.45 1048.73 AE40Z527 0x75BCD15 34'' = '.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   239
     Transcript showCR: ('%f%*f %8[A-F0-9]%c%d 0x%x%f' sscanf: '12.45 1048.73 AE40Z527 0x75BCD15 34') printString.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   240
    "
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   241
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   242
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   243
!CharacterArray methodsFor:'printing & storing'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   244
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   245
printf:args on:outStream
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   246
    "Format and print the receiver on <outStream> with <args>
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   247
     formatted in C style, as specified in the Unix C-language manual page for printf(3).
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   248
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   249
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   250
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   251
    PrintfScanf printf:self on:outStream arguments: args
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   252
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   253
    "
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   254
     '%e' printf:{ 1234.567 ] on:Transcript
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   255
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   256
     '%10s%3d\n' printf:{ 'hello' . 12 } on:Transcript
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   257
     '%10s%3d\n' printf:{ '1234567890' . 12 } on:Transcript
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   258
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   259
     like C's printf, a longer datum may be formatted wider than the formatspec says:
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   260
     
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   261
     '%10s%3d\n' printf:{ '12345678901234' . 12 } on:Transcript
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   262
     
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   263
     '%10s%3d\n' printf:{ 'hello' . 12 } on:Transcript
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   264
     '%10s%03d\n' printf:{ 'hello' . 12 } on:Transcript
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   265
    "
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   266
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   267
    "Modified (comment): / 19-06-2017 / 15:51:57 / cg"
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   268
! !
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   269
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   270
!CharacterArray methodsFor:'printing & storing'!
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   271
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   272
printfWith:arg1
2295
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   273
    "Format and print the receiver with <arg1> formatted in C style,
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   274
     as specified in the Unix C-language manual page for printf(3).
3114
1d5224486d3c class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3094
diff changeset
   275
     Return the resulting string (i.e actually, this is more like an sprintf)."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   276
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   277
    ^ self printf:(Array with:arg1)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   278
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   279
    "
3796
70a4a03f4028 comment
Claus Gittinger <cg@exept.de>
parents: 3720
diff changeset
   280
     ('%05x' printfWith:123)
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   281
     Transcript showCR:('%05x' printfWith:123)
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   282
    "
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   283
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   284
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   285
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   286
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   287
printfWith:arg1 with:arg2
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   288
    "Format and print the receiver with <argI> formatted in C style,
2295
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   289
     as specified in the Unix C-language manual page for printf(3).
3114
1d5224486d3c class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3094
diff changeset
   290
     Return the resulting string (i.e actually, this is more like an sprintf)."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   291
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   292
    ^ self printf:(Array with:arg1 with:arg2)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   293
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   294
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   295
     Transcript showCR:('%d %05x' printfWith:123 with:234)
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   296
    "
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   297
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   298
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   299
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   300
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   301
printfWith:arg1 with:arg2 with:arg3
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   302
    "Format and print the receiver with <argI> formatted in C style,
2295
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   303
     as specified in the Unix C-language manual page for printf(3).
3114
1d5224486d3c class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3094
diff changeset
   304
     Return the resulting string (i.e actually, this is more like an sprintf)."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   305
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   306
    ^ self printf:(Array with:arg1 with:arg2 with:arg3)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   307
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   308
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   309
     Transcript showCR:('%d %05x %08o' printfWith:123 with:234 with:345)
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   310
    "
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   311
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   312
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   313
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   314
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   315
printfWith:arg1 with:arg2 with:arg3 with:arg4
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   316
    "Format and print the receiver with <argI> formatted in C style,
2295
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   317
     as specified in the Unix C-language manual page for printf(3).
3114
1d5224486d3c class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3094
diff changeset
   318
     Return the resulting string (i.e actually, this is more like an sprintf)."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   319
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   320
    ^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   321
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   322
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   323
     Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123)
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   324
    "
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   325
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   326
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   327
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   328
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   329
printf_formatArgCount
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   330
    "Return the number of arguments required/produced if the receiver is interpreted
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   331
     as a printf/scanf format control string.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   332
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   333
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   334
    ^ PrintfScanf formatArgCountFor:self.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   335
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   336
    "Modified: / 19-06-2017 / 16:54:10 / cg"
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   337
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   338
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   339
!CharacterArray methodsFor:'private'!
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   340
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   341
printf_printArgFrom:formatStream to:outStream withData:argStream
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   342
    <resource: #obsolete>
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   343
    "Interpret the required number of arguments from <argStream>
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   344
     according to the formatting information in <formatStream>.
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   345
     Place the interpretation on <outStream>.
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   346
     The interpretation is C printf(3) style, as
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   347
     specified in the Unix C-language manual page for printf(3).
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   348
     <formatStream> is assumed to be positioned just past
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   349
     $%, and a complete control string is assumed available.
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   350
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   351
     Return when the conversion control string is consumed.
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   352
     Leave <formatStream> pointing past the last character in the conversion control string.
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   353
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   354
     This code assumes that <formatStream> is formatted according to
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   355
     specification, and error checking is minimal.  Unexpected
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   356
     results will be obtained by illegal control strings, or when
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   357
     argument types do not match conversion codes, but it probably
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   358
     won't dump core, like C does in such cases!!
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   359
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   360
     For copyright information, see goodies/String-printf_scanf.chg"
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   361
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   362
    PrintfScanf printArgFrom:formatStream to:outStream arguments:argStream
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   363
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   364
    "Modified: / 19-06-2017 / 15:44:28 / cg"
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   365
! !
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   366
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   367
!CharacterArray methodsFor:'printing & storing'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   368
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   369
printf_printOn:outStream withData:args
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   370
    <resource: #obsolete>
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   371
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   372
    "Format and print the receiver on <outStream> with <args>
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   373
     formatted in C style, as specified in the Unix C-language manual page for printf(3).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   374
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   375
     For copyright information, see goodies/String-printf_scanf.chg"
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   376
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   377
    self obsoleteMethodWarning:'use printf:on:'.
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   378
    self printf:args on:outStream
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   379
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   380
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   381
!CharacterArray methodsFor:'converting'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   382
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   383
scanf:dataStream
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   384
    "Return a Collection of objects found in the Character Stream
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   385
     <dataStream> as interpreted according to the receiver.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   386
     The receiver is assumed to be a conversion control string as
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   387
     specified in the Unix C-language manual page for scanf(3).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   388
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   389
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   390
    |results format char|
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   391
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   392
    results := OrderedCollection new.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   393
    format := ReadStream on:self.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   394
    [ format atEnd ] whileFalse:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   395
	char := format next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   396
	(char == Character space or:[ char == Character tab ]) ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   397
	    dataStream skipSeparators.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   398
	    format skipSeparators
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   399
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   400
	char == $% ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   401
	    self
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   402
		scanf_scanArgFrom:dataStream
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   403
		to:results
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   404
		format:format
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   405
	] ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   406
	    dataStream peekFor:char
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   407
	]
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   408
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   409
    ^ results
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   410
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   411
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   412
     '%d %x' scanf:(ReadStream on:'1234 ff00')
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   413
    "
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   414
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   415
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   416
!CharacterArray methodsFor:'private'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   417
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   418
scanf_scanArgFrom:dataStream to:collection format:format
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   419
    <resource: #obsolete>
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   420
    "Add to <collection> an object who's representation is found
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   421
     in <dataStream> interpreted according to the conversion
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   422
     control string in the Stream <format>.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   423
     <format> is assumed to be positioned just past a $%, and a complete control
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   424
     string is assumed available.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   425
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   426
     Return when the conversion control string is consumed.  Leave
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   427
     <format> pointing past the last character in the conversion
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   428
     control string, leave <dataStream> pointing past any width
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   429
     specified in <format>, or at the first character that doesn't
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   430
     make sense for the <format>.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   431
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   432
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   433
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   434
    |final width char pos data scanset exclusive return last|
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   435
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   436
    final := [:retval |
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   437
            collection add:retval.
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   438
            data == dataStream ifFalse:[
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   439
                dataStream position:dataStream position + data position
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   440
            ].
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   441
            ^ self
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   442
        ].
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   443
    width := 0.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   444
    char := format peek.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   445
    char == $% ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   446
        ^ dataStream peekFor:char
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   447
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   448
    char == $* ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   449
        format next.
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   450
        char := format peek.
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   451
        final := [:retval |
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   452
                data == dataStream ifFalse:[
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   453
                    dataStream position:dataStream position + data position
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   454
                ].
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   455
                ^ self
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   456
            ]
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   457
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   458
    char isDigit ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   459
        width := Integer readFrom:format.
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   460
        char := format peek
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   461
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   462
    ('slhduoxfeg' includes:char) ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   463
        dataStream skipSeparators
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   464
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   465
    width = 0 ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   466
        data := dataStream
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   467
    ] ifFalse:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   468
        pos := dataStream position.
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   469
        data := ReadStream on:(dataStream next:width).
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   470
        dataStream position:pos
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   471
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   472
    char == $s ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   473
        final value:(data upToSeparator)
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   474
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   475
    char == $c ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   476
        width = 0 ifTrue:[
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   477
            final value:(String with:data next)
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   478
        ] ifFalse:[
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   479
            final value:data contents
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   480
        ]
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   481
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   482
    char == $[ "What a mess!!" ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   483
        return := WriteStream on:(String new:8).
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   484
        scanset := IdentitySet new.
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   485
        format next.
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   486
        width = 0 ifTrue:[
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   487
            width := SmallInteger maxVal
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   488
        ].
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   489
        exclusive := format peekFor:$^.
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   490
        [
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   491
            last := char.
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   492
            char := format next.
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   493
            char == $]
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   494
        ] whileFalse:[
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   495
            char == $- ifFalse:[
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   496
                scanset add:char
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   497
            ] ifTrue:[
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   498
                last to:format next do:[:c |
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   499
                    scanset add:c
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   500
                ]
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   501
            ]
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   502
        ].
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   503
        [
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   504
            data atEnd not and:[ (scanset includes:data peek) xor:exclusive ]
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   505
        ] whileTrue:[ return nextPut:data next ].
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   506
        final value:return contents
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   507
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   508
    ('lh' includes:char) ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   509
        format next.
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   510
        char := format peek
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   511
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   512
    ('DUdu' includes:char) ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   513
        final value:(Integer readFrom:data)
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   514
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   515
    ('FEGfeg' includes:char) ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   516
        final value:(Float readFrom:data)
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   517
    ].
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   518
    ('b' includes:char) ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   519
        final value:(Integer readFrom:data radix:2)
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   520
    ].
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   521
    ('Oo' includes:char) ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   522
        final value:(Integer readFrom:data radix:8)
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   523
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   524
    ('Xx' includes:char) ifTrue:[
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   525
        final value:(Integer readFrom:data radix:16)
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   526
    ]
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   527
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   528
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   529
     '%d %x' sscanf:'1234 ff00'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   530
     '%d %x %b' sscanf:'1234 ff00 1001'
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   531
    "
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   532
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   533
    "Modified: / 29-11-2011 / 11:55:39 / cg"
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   534
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   535
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   536
!CharacterArray methodsFor:'converting'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   537
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   538
sscanf:string
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   539
    "Return a Collection of objects found in <string> as
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   540
     interpreted according to the receiver.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   541
     The receiver is assumed to be a conversion control string as
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   542
     specified in the Unix C-language manual page for scanf(3).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   543
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   544
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   545
    ^ self scanf:(ReadStream on:string)
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   546
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   547
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   548
     '%d %x' sscanf:'1234 ff00'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   549
     '%d %x %b' sscanf:'1234 ff00 1001'
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   550
    "
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   551
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   552
4365
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   553
!Collection methodsFor:'converting'!
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   554
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   555
asHalfFloatArray
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   556
    "return a new HalfFloatArray with the collection's elements
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   557
     (which must convert to 16bit half-floats)."
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   558
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   559
    ^ self asArrayOfType:HalfFloatArray
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   560
! !
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   561
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   562
!Collection methodsFor:'converting'!
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   563
4400
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   564
asIdentitySkipList
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   565
	"Answer a IdentitySkipList whose elements are the elements of the 
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   566
	receiver. The sort order is the default less than or equal."
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   567
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   568
	^ self as: IdentitySkipList
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   569
! !
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   570
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   571
!Collection methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   572
4365
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   573
asList
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   574
    "return a new List with the receiver collection's elements"
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   575
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   576
    ^ self addAllTo:(List new:self size)
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   577
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   578
    "Created: 14.2.1997 / 16:25:23 / cg"
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   579
! !
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   580
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   581
!Collection methodsFor:'converting'!
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   582
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   583
asRunArray
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   584
    "return a new RunArray with the collection's elements"
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   585
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   586
    ^ RunArray from:self.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   587
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   588
"/    |runs lastElement occurrences|
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   589
"/
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   590
"/    runs := RunArray new.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   591
"/    occurrences := 0.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   592
"/    self do:[:each |
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   593
"/        each == lastElement ifTrue:[
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   594
"/            occurrences := occurrences + 1
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   595
"/        ] ifFalse:[
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   596
"/            runs add:lastElement withOccurrences:occurrences.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   597
"/            occurrences := 1.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   598
"/            lastElement := each
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   599
"/        ].
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   600
"/    ].
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   601
"/    occurrences ~~ 0 ifTrue:[
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   602
"/        runs add:lastElement withOccurrences:occurrences
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   603
"/    ].
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   604
"/    ^ runs
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   605
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   606
    "
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   607
     #(1 2 3 3 3 4 4 4 4 5 6 7) asRunArray 
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   608
    "
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   609
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   610
    "Modified: / 7.4.1998 / 09:50:54 / cg"
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   611
! !
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   612
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   613
!Collection methodsFor:'converting'!
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   614
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   615
asSharedCollection
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   616
    "return a shared collection on the receiver.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   617
     This implements synchronized (i.e. mutually excluded) access to me.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   618
     Use this for safe access when multiple processes access me concurrently.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   619
     Notice that this is a general (possibly suboptimal) mechanism, which should
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   620
     work with all collections. Look for specialized collections (SharedQueue), which are
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   621
     tuned for this kind of operation."
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   622
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   623
    ^ SharedCollection for:self.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   624
! !
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   625
4400
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   626
!Collection methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   627
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   628
asSkipList
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   629
	"Answer a SkipList whose elements are the elements of the 
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   630
	receiver. The sort order is the default less than or equal."
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   631
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   632
	^ self as: SkipList
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   633
! !
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   634
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   635
!Collection methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   636
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   637
asSkipList: aSortBlock 
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   638
        "Answer a SkipList whose elements are the elements of the 
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   639
        receiver. The sort order is defined by the argument, aSortBlock."
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   640
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   641
        | skipList |
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   642
        skipList := SkipList new: self size sortBlock: aSortBlock.
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   643
        skipList addAll: self.
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   644
        ^ skipList
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   645
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   646
    "Modified (comment): / 18-06-2017 / 22:40:10 / cg"
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   647
! !
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   648
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   649
!Float methodsFor:'private'!
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   650
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   651
absDecimalPrintOn:aStream digits:digits
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   652
    "Place a string representation of the receiver's abs value
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   653
     on <aStream> using <digits> significant digits, using decimal notation.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   654
     This is a helper for printf."
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   655
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   656
    |exp x fuzz i|
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   657
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   658
    "x is myself normalized to (1.0, 10.0), exp is my exponent"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   659
    exp := self abs < 1.0
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   660
                ifTrue:[ (10.0 / self abs) log10 floor negated ]
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   661
                ifFalse:[ self abs log10 floor ].
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   662
    x := self abs / (10.0 raisedTo:exp).
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   663
    fuzz := 10.0 raisedTo:1 - digits.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   664
     "round the last digit to be printed"
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   665
    x := 0.5 * fuzz + x.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   666
    x >= 10.0 "check if rounding has unnormalized x" ifTrue:[
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   667
        x := x / 10.0.
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   668
        exp := exp + 1
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   669
    ].
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   670
    exp < 0 ifTrue:[
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   671
        1 to:1 - exp do:[:j |
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   672
            aStream nextPut:('0.000000000000' at:j)
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   673
        ]
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   674
    ].
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   675
    [ x >= fuzz ] "use fuzz to track significance" whileTrue:[
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   676
        i := x truncated.
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   677
        aStream nextPut:(48 + i) asCharacter.
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   678
        x := (x - i) * 10.0.
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   679
        fuzz := fuzz * 10.0.
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   680
        exp := exp - 1.
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   681
        exp = -1 ifTrue:[
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   682
            aStream nextPut:$.
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   683
        ]
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   684
    ].
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   685
    [ exp >= -1 ] whileTrue:[
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   686
        aStream nextPut:$0.
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   687
        exp := exp - 1.
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   688
        exp = -1 ifTrue:[
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   689
            aStream nextPut:$.
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   690
        ]
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   691
    ]
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   692
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   693
    "Modified: / 19-06-2017 / 14:53:47 / cg"
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   694
! !
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   695
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   696
!Float methodsFor:'private'!
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   697
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   698
absPrintOn:aStream digits:digits
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   699
    "Place a string representation of the receiver's abs value on <aStream> using
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   700
     <digits> significant digits.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   701
     This is a helper for printf."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   702
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   703
    PrintfScanf absPrintFloat:self on:aStream digits:digits
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   704
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   705
    "Modified: / 19-06-2017 / 15:04:24 / cg"
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   706
! !
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   707
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   708
!Float methodsFor:'private'!
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   709
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   710
absScientificPrintOn:aStream digits:digits
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   711
    "Place a string representation of the receiver's abs value on <aStream> using <digits> significant
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   712
     digits, using scientific notation.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   713
     This is a helper for printf."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   714
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   715
    PrintfScanf absScientificPrintFloat:self on:aStream digits:digits.
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   716
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   717
    "Modified: / 19-06-2017 / 14:59:56 / cg"
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   718
! !
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   719
4381
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   720
!Float methodsFor:'coercing & converting'!
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   721
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   722
asQDouble
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   723
    "return a QDouble with my value"
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   724
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   725
    ^ QDouble fromFloat:self
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   726
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   727
    "
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   728
     1.0 asQDouble
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   729
    "
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   730
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   731
    "Created: / 13-06-2017 / 16:48:57 / cg"
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   732
! !
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   733
4383
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   734
!Integer methodsFor:'coercing & converting'!
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   735
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   736
asQDouble
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   737
    "return a QDouble with same value as myself."
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   738
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   739
    ^ QDouble fromInteger:self
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   740
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   741
    "
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   742
     1234567890 asQDouble
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   743
     1234567890 asQDouble asInteger
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   744
     12345678901234567890 asQDouble
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   745
     12345678901234567890 asQDouble asInteger
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   746
    "
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   747
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   748
    "Created: / 12-06-2017 / 18:41:07 / cg"
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   749
    "Modified (comment): / 12-06-2017 / 20:55:24 / cg"
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   750
! !
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   751
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   752
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   753
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   754
addInterest:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   755
    "install an interest forwarder.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   756
     Here, we use the nonWeakDependencies."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   757
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   758
    self addNonWeakDependent:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   760
    "Created: 14.10.1996 / 22:27:34 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   761
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   762
3896
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   763
!Object methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   764
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   765
asDoubleLink
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   766
    "return a valueDoubleLink for the receiver.
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   767
     Used to make sure the receiver can be added to a double linked list"
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   768
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   769
    ^ ValueDoubleLink value:self
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   770
! !
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   771
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   772
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   773
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   774
expressInterestIn:aspect for:anObject sendBack:aSelector
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   775
    "arrange for aSelector to be sent to anObject whenever the receiver
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   776
     changes aspect."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   777
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   778
    "/ for now, use an interestConverter, which is somewhat less efficient.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   779
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   780
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   781
    self addInterest:(InterestConverter
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   782
			    destination:anObject
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   783
			    selector:aSelector
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   784
			    aspect:aspect)
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   785
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   786
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   787
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   788
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   789
     b := [Transcript showCR:' -> the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   790
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   791
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   792
     Transcript showCR:'interest in #foo:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   793
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   794
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   795
     Transcript showCR:'now changing #bar ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   796
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   797
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   798
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   799
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   800
     Transcript showCR:'now changing #foo ... (expect notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   801
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   802
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   803
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   804
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   805
     Transcript showCR:'no more interest in #foo:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   806
     p retractInterestIn:#foo for:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   807
     Transcript showCR:'now changing #foo ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   808
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   809
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   810
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   811
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   812
     Transcript showCR:'interest in #bar now:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   813
     p expressInterestIn:#bar for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   814
     Transcript showCR:'now changing #foo ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   815
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   816
     Transcript showCR:'now changing #bar ... (expect notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   817
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   818
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   819
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   820
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   821
     Transcript showCR:'interest in #foo now:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   822
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   823
     Transcript showCR:'now changing #foo ... (expect notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   824
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   825
     Transcript showCR:'now changing #bar ... (expect notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   826
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   827
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   828
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   829
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   830
     Transcript showCR:'no more interests:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   831
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   832
     Transcript showCR:'now changing #foo ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   833
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   834
     Transcript showCR:'now changing #bar...  (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   835
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   836
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   837
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   838
     p release.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   839
    "
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
   840
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   841
    "Created: 19.4.1996 / 10:26:22 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   842
    "Modified: 19.4.1996 / 12:34:08 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   843
    "Modified: 14.10.1996 / 22:28:20 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   844
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   845
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   846
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   847
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   848
interests
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   849
    "return a Collection of interests - empty if there is none.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   850
     Here, we use the nonWeakDependents for interests."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   851
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   852
    ^ self nonWeakDependents
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   853
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   854
    "Created: / 14.10.1996 / 22:20:51 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   855
    "Modified: / 30.1.1998 / 14:07:35 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   856
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   857
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   858
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   859
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   860
interestsFor:someOne
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   861
    "return a collection of interests of someOne - empty if there is none."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   862
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   863
    |coll deps|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   864
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   865
    deps := self interests.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   866
    deps size == 0 ifTrue:[^ #()].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   867
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   868
    coll := IdentitySet new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   869
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   870
    deps do:[:dep |
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   871
	(dep isInterestConverter) ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   872
	    dep destination == someOne ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   873
		coll add:dep.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   874
	    ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   875
	]
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   876
    ].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   877
    ^ coll
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   878
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   879
    "Created: / 30.1.1998 / 14:02:26 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   880
    "Modified: / 30.1.1998 / 14:08:24 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   881
! !
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
   882
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   883
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   884
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   885
onChangeEvaluate:aBlock
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   886
    "arrange for aBlock to be evaluated whenever the receiver changes."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   887
2149
329461c02e84 allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   888
    |na selector|
329461c02e84 allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   889
3559
fa3443d808a1 Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents: 3538
diff changeset
   890
    na := aBlock argumentCount.
2149
329461c02e84 allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   891
    na == 0 ifTrue:[
3559
fa3443d808a1 Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents: 3538
diff changeset
   892
        selector := #value
2149
329461c02e84 allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   893
    ] ifFalse:[
3559
fa3443d808a1 Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents: 3538
diff changeset
   894
        selector := #( #'value:' #'value:value:' #'value:value:value:') at:na
2149
329461c02e84 allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   895
    ].
329461c02e84 allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   896
    ^ self onChangeSend:selector to:aBlock
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   897
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   898
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   899
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   900
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   901
     b := [Transcript showCR:' -> the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   902
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   903
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   904
     Transcript showCR:'interest in #foo:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   905
     p onChangeEvaluate:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   906
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   907
     Transcript showCR:'now changing #bar ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   908
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   909
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   910
     p retractInterests.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   911
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   912
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   913
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   914
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   915
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   916
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   917
onChangeSend:aSelector to:anObject
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   918
    "arrange for aSelector to be sent to anObject whenever the receiver
4030
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
   919
     changes.
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
   920
     Use retractInterestsFor: in case you are no longer interested"
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   921
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   922
    "/ for now, use an interestConverter, which is somewhat less efficient.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   923
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   924
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   925
    ((self interests ? #())
4030
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
   926
        contains:[:anInterest |
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
   927
            (anInterest isInterestConverter)
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
   928
            and:[ anInterest destination == anObject
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
   929
            and:[ anInterest selector == aSelector]]
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
   930
        ])
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
   931
            ifTrue:[^ self].
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   932
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   933
    self addInterest:(InterestConverter
4030
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
   934
                          destination:anObject
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
   935
                          selector:aSelector)
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
   936
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
   937
    "
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   938
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   939
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   940
     b := [Transcript showCR:'the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   941
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   942
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   943
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   944
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   945
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   946
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   947
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   948
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   949
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   950
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   951
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   952
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   953
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   954
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   955
     Transcript showCR:'no more interest'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   956
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   957
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   958
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   959
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   960
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   961
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   962
     Transcript showCR:'interest again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   963
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   964
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   965
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   966
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   967
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   968
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   969
    "Created: 19.4.1996 / 10:26:38 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   970
    "Modified: 19.4.1996 / 12:34:26 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   971
    "Modified: 14.10.1996 / 22:28:27 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   972
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   973
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   974
!Object methodsFor:'dependents-st/v event simulation'!
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   975
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   976
removeActionsForEvent:eventSymbol
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   977
    "remove ST/V-style event triggers."
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   978
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   979
    self retractInterestsIn:eventSymbol
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   980
! !
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   981
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   982
!Object methodsFor:'dependents-st/v event simulation'!
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   983
2903
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
   984
removeActionsWithReceiver:aReceiver
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
   985
    "remove ST/V-style event triggers."
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
   986
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
   987
    self retractInterestsFor:aReceiver
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
   988
! !
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
   989
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
   990
!Object methodsFor:'dependents-st/v event simulation'!
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
   991
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   992
removeAllActionsWithReceiver:anObject
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   993
    "remove ST/V-style event triggers."
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   994
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   995
    self retractInterestsFor:anObject
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   996
! !
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   997
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   998
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   999
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1000
removeInterest:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1001
    "remove an interest forwarder.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1002
     Here, we use the nonWeakDependencies."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1003
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1004
    self removeNonWeakDependent:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1005
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1006
    "Created: 14.10.1996 / 22:21:59 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1007
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1008
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1009
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1010
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1011
retractInterestIn:aspect for:someOne
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1012
    "remove the interest of someOne in the receiver changing aspect
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1013
     (as installed with #expressInterestIn:for:sendBack:).
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1014
     Answer the retracted interests."
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1015
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1016
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1017
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1018
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1019
    ^ self retractInterestsForWhich:[:i | 
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1020
            (i aspect == aspect) and:[i destination == someOne]
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1021
        ]
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1022
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1023
    "
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1024
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1025
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1026
     b := [Transcript showCR:'the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1027
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1028
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1029
     Transcript showCR:'interest in #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1030
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1031
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1032
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1033
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1034
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1035
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1036
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1037
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1038
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1039
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1040
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1041
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1042
     Transcript showCR:'no more interest in #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1043
     p retractInterestIn:#foo for:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1044
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1045
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1046
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1047
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1048
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1049
     Transcript showCR:'interest in #bar now'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1050
     p expressInterestIn:#bar for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1051
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1052
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1053
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1054
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1055
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1056
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1057
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1058
     Transcript showCR:'interest in #foo now'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1059
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1060
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1061
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1062
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1063
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1064
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1065
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1066
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1067
     Transcript showCR:'no more interests'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1068
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1069
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1070
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1071
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1072
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1073
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1074
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1075
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1076
    "Created: / 19.4.1996 / 10:27:11 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1077
    "Modified: / 14.10.1996 / 22:21:19 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1078
    "Modified: / 30.1.1998 / 14:05:34 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1079
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1080
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1081
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1082
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1083
retractInterests
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1084
    "remove all interests in the receiver changing aspect
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1085
     (as installed with #expressInterestIn:for:sendBack:).
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1086
     Answer the retraced interests."
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1087
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1088
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1089
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1090
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1091
    ^ self retractInterestsForWhich:[:i | true ]
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1092
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1093
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1094
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1095
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1096
retractInterestsFor:someOne
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1097
    "remove the interest of someOne in the receiver
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1098
     (as installed with #onChangeSend:to:).
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1099
     Answer the retracted interests."
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1100
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1101
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1102
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1103
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1104
    ^ self retractInterestsForWhich:[:i | i destination == someOne ]
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1105
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1106
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1107
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1108
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1109
     b := [Transcript showCR:'the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1110
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1111
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1112
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1113
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1114
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1115
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1116
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1117
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1118
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1119
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1120
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1121
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1122
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1123
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1124
     Transcript showCR:'no more interest'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1125
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1126
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1127
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1128
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1129
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1130
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1131
     Transcript showCR:'interest again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1132
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1133
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1134
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1135
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1136
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1137
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1138
    "Created: / 19.4.1996 / 10:23:46 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1139
    "Modified: / 14.10.1996 / 22:21:25 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1140
    "Modified: / 30.1.1998 / 14:04:52 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1141
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1142
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1143
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1144
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1145
retractInterestsForWhich:aBlock
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1146
    "remove all interests in the receiver changing aspect
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1147
     (as installed with #expressInterestIn:for:sendBack:).
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1148
     Answer the retracted interests."
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1149
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1150
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1151
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1152
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1153
    |deps coll|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1154
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1155
    deps := self interests.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1156
    deps size ~~ 0 ifTrue:[
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1157
        "/ cannot removeDependent within the loop - the interests collection rehashes
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1158
        coll := IdentitySet new.
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1159
        deps do:[:dep |
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1160
            dep isInterestConverter ifTrue:[
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1161
                (aBlock value:dep) ifTrue:[coll add:dep].
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1162
            ]
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1163
        ].
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1164
        coll do:[:dep |
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1165
            self removeInterest:dep.
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1166
        ].
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1167
        ^ coll.
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1168
    ].
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1169
    ^ #()
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1170
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1171
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1172
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1173
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1174
retractInterestsIn:aspect
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1175
    "remove all interests in the receiver changing aspect
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1176
     (as installed with #expressInterestIn:for:sendBack:).
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1177
     Answer the retracted interests."
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1178
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1179
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1180
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1181
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1182
    ^ self retractInterestsForWhich:[:i | i aspect == aspect ]
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1183
! !
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1184
2901
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1185
!Object methodsFor:'Compatibility-Dolphin'!
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1186
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1187
trigger:anAspect
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1188
    self changed:anAspect
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1189
! !
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1190
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1191
!Object methodsFor:'Compatibility-Dolphin'!
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1192
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1193
trigger:anAspect with:anArgument
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1194
    self changed:anAspect with:anArgument
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1195
! !
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1196
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1197
!Object methodsFor:'dependents-st/v event simulation'!
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1198
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1199
triggerEvent:aSymbol
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1200
    self changed:aSymbol
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1201
! !
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1202
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1203
!Object methodsFor:'dependents-st/v event simulation'!
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1204
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1205
triggerEvent:eventSymbol with:aParameter
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1206
    "perform ST/V-style event triggering."
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1207
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1208
    self changed:eventSymbol with:(Array with:aParameter).
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1209
! !
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1210
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1211
!Object methodsFor:'dependents-st/v event simulation'!
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1212
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1213
triggerEvent:eventSymbol withArguments:parameters
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1214
    "perform ST/V-style event triggering."
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1215
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1216
    self changed:eventSymbol with:parameters.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1217
! !
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1218
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1219
!Object methodsFor:'dependents-st/v event simulation'!
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1220
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1221
when:eventSymbol send:selector to:anObject
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1222
    "install an ST/V-style interest forwarder.
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1223
     Here, we use the nonWeakDependencies."
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1224
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1225
    self addInterest:(InterestConverterWithParameters
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1226
                            destination:anObject
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1227
                            selector:selector
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1228
                            aspect:eventSymbol).
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1229
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1230
    "
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1231
     |p b|
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1232
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1233
     b := [Transcript showCR:'the point changed'].
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1234
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1235
     p := Point new.
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1236
     p when:#foo:bar: send:#value:value: to:[:a :b | Transcript show:'foo: '; show:a; show:' bar: '; showCR:b].
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1237
     Transcript showCR:'now changing'.
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1238
     p triggerEvent:#foo:bar: withArguments:#('fooArg' 'barArg').
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1239
     p removeActionsForEvent:#foo:bar:.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1240
    "
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1241
! !
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1242
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1243
!Object methodsFor:'dependents-st/v event simulation'!
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1244
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1245
when:eventSymbol send:selector to:anObject with:aParameter
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1246
    "install an ST/V-style interest forwarder.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1247
     Here, we use the nonWeakDependencies."
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1248
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1249
    self addInterest:((InterestConverterWithParameters
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1250
                            destination:anObject
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1251
                            selector:selector
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1252
                            aspect:eventSymbol) 
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1253
                        defaultParameters:(Array with:aParameter)).
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1254
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1255
    "
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1256
     |p b|
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1257
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1258
     b := [Transcript showCR:'the point changed'].
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1259
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1260
     p := Point new.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1261
     p 
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1262
        when:#foo: 
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1263
        send:#value: 
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1264
        to:[:a | Transcript show:'foo: '; showCR:a]
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1265
        with:123.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1266
     Transcript showCR:'now changing'.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1267
     p triggerEvent:#foo:.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1268
     p triggerEvent:#foo: with:987.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1269
     p removeActionsForEvent:#foo:.
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1270
    "
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1271
! !
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1272
2901
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1273
!Object methodsFor:'Compatibility-Dolphin'!
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1274
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1275
when:anAspect sendTo:anObject
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1276
    self expressInterestIn:anAspect for:anObject sendBack:anAspect
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1277
! !
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1278
2364
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1279
!Stream methodsFor:'stacked computing streams'!
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1280
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1281
collecting:aBlock
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1282
    "return a stacked computing stream, which reads elements from the receiver,
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1283
     applies aBlock to each read element, and provides the results as elements to its reader."
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1284
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1285
    ^ CollectingReadStream on:self collecting:aBlock
3094
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1286
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1287
    "
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1288
     |s s2|
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1289
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1290
     s := 'hello world' readStream.
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1291
     s2 := s collecting:[:ch | ch asUppercase].
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1292
     s2 upToEnd.   
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1293
    "
2364
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1294
! !
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1295
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1296
!Stream methodsFor:'stacked computing streams'!
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1297
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1298
selecting:aBlock
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1299
    "return a stacked computing stream, which reads elements from the receiver,
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1300
     but only provides elements for which aBlock returns true to its reader."
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1301
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1302
    ^ SelectingReadStream on:self selecting:aBlock
3094
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1303
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1304
    "
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1305
     |s s2|
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1306
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1307
     s := 'hello world' readStream.
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1308
     s2 := s selecting:[:ch | ch isVowel].
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1309
     s2 upToEnd.
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1310
    "
2364
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1311
! !
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1312
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1313
!stx_libbasic2 class methodsFor:'documentation'!
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1314
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1315
extensionsVersion_CVS
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
  1316
    ^ '$Header$'
3005
36ada1348967 asciiValue->codePoint
Claus Gittinger <cg@exept.de>
parents: 2903
diff changeset
  1317
! !
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
  1318