extensions.st
author Claus Gittinger <cg@exept.de>
Sat, 07 Nov 2009 11:15:14 +0100
changeset 2337 755696d72648
parent 2303 74c77b8cf160
child 2364 2b7b611e565c
permissions -rw-r--r--
comment/format in: #asSoundexCode
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
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
     3
!CharacterArray methodsFor:'matching - phonetic'!
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
     4
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
     5
asKoelnerPhoneticCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
     6
    "return a koelner phonetic code.
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
     7
     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
     8
     it returns simular strings for similar sounding words.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
     9
     There are some differences to soundex, though:
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    10
	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
    11
	it does not start with the first character of the input.
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    12
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    13
     Caveat: this phonetic code is especially suited for german words.
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    14
	     Please have a look at the other phonetic comparison operators found
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    15
	     in PhoneticStringUtilities."
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    16
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    17
    ^ PhoneticStringUtilities koelnerPhoneticCodeOf:self
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    18
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    19
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    20
     #(
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    21
	'Müller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    22
	'Miller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    23
	'Mueller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    24
	'Mühler'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    25
	'Mühlherr'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    26
	'Mülherr'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    27
	'Myler'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    28
	'Millar'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    29
	'Myller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    30
	'Müllar'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    31
	'Müler'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    32
	'Muehler'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    33
	'Mülller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    34
	'Müllerr'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    35
	'Muehlherr'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    36
	'Muellar'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    37
	'Mueler'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    38
	'Mülleer'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    39
	'Mueller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    40
	'Nüller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    41
	'Nyller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    42
	'Niler'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    43
	'Czerny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    44
	'Tscherny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    45
	'Czernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    46
	'Tschernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    47
	'Schernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    48
	'Scherny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    49
	'Scherno'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    50
	'Czerne'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    51
	'Zerny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    52
	'Tzernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    53
	'Breschnew'
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    54
     ) do:[:w |
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    55
	 Transcript show:w; show:'->'; showCR:(w asKoelnerPhoneticCode)
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    56
     ].
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    57
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    58
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    59
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    60
     'Breschnew' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    61
     'Breschnew' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    62
     'Breschneff' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    63
     'Braeschneff' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    64
     'Braessneff' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    65
     'Pressneff' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    66
     'Presznäph' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    67
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    68
! !
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    69
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    70
!CharacterArray methodsFor:'matching - phonetic'!
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    71
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    72
asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    73
    "return a soundex phonetic code or nil.
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    74
     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
    75
     tool when searching for words where the correct spelling is unknown.
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    76
     (read Knuth or search the web if you dont know what a soundex code is).
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    77
2337
755696d72648 comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
    78
     Caveat: 'similar sounding words' means: 'similar sounding in ENGLISH'
755696d72648 comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
    79
             Please have a look at the other phonetic comparison operators found
755696d72648 comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
    80
             in PhoneticStringUtilities."
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    81
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    82
    ^ PhoneticStringUtilities soundexCodeOf:self
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    83
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    84
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
    85
     'claus' asSoundexCode
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    86
     'clause' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    87
     'close' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    88
     'smalltalk' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    89
     'smaltalk' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    90
     'smaltak' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    91
     'smaltok' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    92
     'smoltok' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    93
     'aa' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    94
     'by' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    95
     'bab' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    96
     'bob' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    97
     'bop' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    98
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
    99
! !
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   100
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   101
!CharacterArray methodsFor:'printing & storing'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   102
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   103
printf:args
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   104
    "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
   105
     as specified in the Unix C-language manual page for printf(3).
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   106
     Return the resulting string.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   107
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   108
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   109
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   110
    |aStream|
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   111
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   112
    aStream := WriteStream on:String new.
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   113
    self printf:args on:aStream.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   114
    ^ aStream contents
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   115
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   116
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   117
     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
   118
    "
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   119
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   120
    "
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   121
     Transcript showCR: 'Some examples:'!!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   122
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   123
     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
   124
     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
   125
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   126
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   127
     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
   128
     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
   129
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   130
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   131
     Transcript show: '''%8.3f'' printf: (Array with: 200 sqrt negated) = .'.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   132
     Transcript show: ('%8.3f' printf: (Array with: 200 sqrt negated)).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   133
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   134
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   135
     Transcript show: '''%c'' printf: #(16r41) = .'.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   136
     Transcript show: ('%c' printf: #(16r41)).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   137
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   138
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   139
     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
   140
     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
   141
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   142
     Transcript show: '''%d%f%s'' sscanf: ''25 54.32e-01 monday'' = '.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   143
     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
   144
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   145
     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
   146
     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
   147
    "
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   148
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   149
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   150
!CharacterArray methodsFor:'printing & storing'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   151
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   152
printf:args on:outStream
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   153
    "Format and print the receiver on <outStream> with <args>
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   154
     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
   155
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   156
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   157
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   158
    |argStream inStream char|
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   159
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   160
    argStream := ReadStream on:args.
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   161
    inStream := ReadStream on:self.
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   162
    [ inStream atEnd ] whileFalse:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   163
	(char := inStream next) == $% ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   164
	    outStream nextPut:char
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   165
	] ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   166
	    self
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   167
		printf_printArgFrom:inStream
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   168
		to:outStream
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   169
		withData:argStream
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   170
	]
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   171
    ]
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   172
! !
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   173
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   174
!CharacterArray methodsFor:'printing & storing'!
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   175
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   176
printfWith:arg1
2295
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   177
    "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
   178
     as specified in the Unix C-language manual page for printf(3).
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   179
     Return the resulting string."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   180
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   181
    ^ self printf:(Array with:arg1)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   182
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   183
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   184
     Transcript showCR:('%05x' printfWith:123)
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   185
    "
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   186
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   187
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   188
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   189
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   190
printfWith:arg1 with:arg2
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   191
    "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
   192
     as specified in the Unix C-language manual page for printf(3).
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   193
     Return the resulting string."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   194
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   195
    ^ self printf:(Array with:arg1 with:arg2)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   196
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   197
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   198
     Transcript showCR:('%d %05x' printfWith:123 with:234)
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   199
    "
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   200
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   201
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   202
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   203
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   204
printfWith:arg1 with:arg2 with:arg3
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   205
    "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
   206
     as specified in the Unix C-language manual page for printf(3).
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   207
     Return the resulting string."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   208
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   209
    ^ self printf:(Array with:arg1 with:arg2 with:arg3)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   210
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   211
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   212
     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
   213
    "
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   214
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   215
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   216
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   217
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   218
printfWith:arg1 with:arg2 with:arg3 with:arg4
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   219
    "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
   220
     as specified in the Unix C-language manual page for printf(3).
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   221
     Return the resulting string."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   222
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   223
    ^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   224
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   225
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   226
     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
   227
    "
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   228
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   229
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   230
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   231
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   232
printf_formatArgCount
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   233
    "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
   234
     as a printf/scanf format control string.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   235
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   236
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   237
    |nonConsecutive count|
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   238
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   239
    nonConsecutive := true.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   240
    count := 0.
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   241
    self do:[:c |
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   242
	c == $% ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   243
	    nonConsecutive ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   244
		count := count + 1.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   245
		nonConsecutive := false
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   246
	    ] ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   247
		count := count - 1.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   248
		nonConsecutive := true
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   249
	    ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   250
	] ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   251
	    nonConsecutive := true
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   252
	]
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   253
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   254
    ^ count
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   255
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   256
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   257
!CharacterArray methodsFor:'private'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   258
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   259
printf_printArgFrom:inStream to:outStream withData:argStream
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   260
    "Interpret the required number of arguments from <argStream>
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   261
     according to the formatting information in <inStream>.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   262
     Place the interpretation on <outStream>.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   263
     The interpretation is C printf(3) style, as
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   264
     specified in the Unix C-language manual page for printf(3).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   265
     <inStream> is assumed to be positioned just past
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   266
     $%, and a complete control string is assumed available.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   267
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   268
     Return when the conversion control string is consumed.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   269
     Leave <inStream> pointing past the last character in the conversion control string.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   270
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   271
     This code assumes that <inStream> is formatted according to
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   272
     specification, and error checking is minimal.  Unexpected
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   273
     results will be obtained by illegal control strings, or when
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   274
     argument types do not match conversion codes, but it probably
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   275
     won't dump core, like C does in such cases!!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   276
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   277
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   278
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   279
    |nextArg ljust plus pound width precision pad char arg argString|
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   280
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   281
    nextArg := [
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   282
		    argStream atEnd ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   283
			self error:'not enough arguments for format string'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   284
		    ].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   285
		    argStream next
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   286
	       ].
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   287
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   288
    ljust := plus := pound := false.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   289
    width := 0.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   290
    precision := SmallInteger maxVal.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   291
    pad := $ .
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   292
    char := inStream peek.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   293
    char == $% ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   294
	^ outStream nextPut:inStream next
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   295
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   296
    char == $- ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   297
	ljust := true.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   298
	inStream next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   299
	char := inStream peek
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   300
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   301
    char == $  ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   302
	outStream space.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   303
	inStream next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   304
	char := inStream peek
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   305
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   306
    char == $+ ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   307
	plus := true.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   308
	inStream next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   309
	char := inStream peek
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   310
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   311
    char == $# ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   312
	pound := true.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   313
	inStream next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   314
	char := inStream peek
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   315
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   316
    char == $* ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   317
	width := nextArg value.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   318
	inStream next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   319
	char := inStream peek
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   320
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   321
    char isDigit ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   322
	char == $0 ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   323
	    pad := $0
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   324
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   325
	width := Integer readFrom:inStream.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   326
	char := inStream peek
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   327
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   328
    char == $. ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   329
	inStream next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   330
	char := inStream peek.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   331
	char == $* ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   332
	    precision := nextArg value.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   333
	    inStream next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   334
	    char := inStream peek
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   335
	] ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   336
	    precision := Integer readFrom:inStream.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   337
	    char := inStream peek
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   338
	]
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   339
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   340
    char == $l "Ignore long specifier." ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   341
	inStream next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   342
	char := inStream peek
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   343
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   344
    ('feg' includes:char) ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   345
	arg := nextArg value asFloat.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   346
	precision := precision min:6.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   347
	argString := WriteStream on:VariableString "String" new.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   348
	char == $g ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   349
	    arg absPrintOn:argString digits:precision + 1
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   350
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   351
	char == $f ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   352
	    arg absDecimalPrintOn:argString digits:precision + arg abs log + 1
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   353
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   354
	char == $e ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   355
	    arg absScientificPrintOn:argString digits:precision + 1
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   356
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   357
	argString := argString contents.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   358
	arg < 0 ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   359
	    argString := '-' , argString
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   360
	] ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   361
	    plus ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   362
		argString := '+' , argString
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   363
	    ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   364
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   365
	(precision = 0 and:[ pound not ]) ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   366
	    (argString includes:$e) ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   367
		"self halt"
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   368
	    ] ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   369
		argString := arg truncated printString
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   370
	    ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   371
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   372
	pound ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   373
	    (argString includes:$e) ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   374
		"self halt"
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   375
	    ] ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   376
		precision - (argString size - (argString indexOf:$.)) timesRepeat:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   377
		    argString := argString , '0'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   378
		]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   379
	    ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   380
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   381
	ljust ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   382
	    outStream nextPutAll:argString
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   383
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   384
	width - argString size timesRepeat:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   385
	    outStream space
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   386
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   387
	ljust ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   388
	    outStream nextPutAll:argString
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   389
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   390
	^ inStream next
2241
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
    char == $c ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   393
	arg := String with:nextArg value asCharacter
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   394
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   395
    char == $s "Assume the arg is a String or Symbol." ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   396
	arg := nextArg value asString
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   397
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   398
    char == $d ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   399
	arg := nextArg value asInteger printString.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   400
	plus ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   401
	    arg := '+' , arg
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   402
	]
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   403
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   404
    char == $u ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   405
	arg := nextArg value asInteger abs printString
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   406
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   407
    char == $o ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   408
	arg := nextArg value asInteger abs printStringRadix:8.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   409
	pound ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   410
	    arg := '0' , arg
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   411
	]
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   412
    ].
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   413
    char == $b ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   414
	arg := nextArg value asInteger abs printStringRadix:2.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   415
	pound ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   416
	    arg := '0' , arg
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   417
	]
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   418
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   419
    ('xX' includes:char) ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   420
	arg := nextArg value asInteger abs printStringRadix:16.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   421
	pound ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   422
	    arg := '0x' , arg
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   423
	]
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   424
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   425
    char == $x ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   426
	1 to:arg size do:[:i |
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   427
	    ('ABCDEF' includes:(arg at:i)) ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   428
		arg at:i put:((arg at:i) asciiValue + 16r20) asCharacter
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   429
	    ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   430
	]
2241
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
    precision := precision min:arg size.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   433
    ljust ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   434
	outStream nextPutAll:(arg copyFrom:1 to:precision)
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   435
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   436
    width - precision timesRepeat:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   437
	outStream nextPut:pad
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   438
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   439
    ljust ifFalse:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   440
	outStream nextPutAll:(arg copyFrom:1 to:precision)
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   441
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   442
    ^ inStream next
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   443
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   444
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   445
!CharacterArray methodsFor:'printing & storing'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   446
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   447
printf_printOn:outStream withData:args
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   448
    <resource: #obsolete>
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   449
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   450
    "Format and print the receiver on <outStream> with <args>
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   451
     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
   452
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   453
     For copyright information, see goodies/String-printf_scanf.chg"
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   454
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   455
    self obsoleteMethodWarning:'use printf:on:'.
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   456
    self printf:args on:outStream
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
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   459
!CharacterArray methodsFor:'converting'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   460
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   461
scanf:dataStream
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   462
    "Return a Collection of objects found in the Character Stream
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   463
     <dataStream> as interpreted according to the receiver.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   464
     The receiver is assumed to be a conversion control string as
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   465
     specified in the Unix C-language manual page for scanf(3).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   466
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   467
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   468
    |results format char|
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   469
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   470
    results := OrderedCollection new.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   471
    format := ReadStream on:self.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   472
    [ format atEnd ] whileFalse:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   473
	char := format next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   474
	(char == Character space or:[ char == Character tab ]) ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   475
	    dataStream skipSeparators.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   476
	    format skipSeparators
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   477
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   478
	char == $% ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   479
	    self
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   480
		scanf_scanArgFrom:dataStream
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   481
		to:results
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   482
		format:format
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   483
	] ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   484
	    dataStream peekFor:char
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   485
	]
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   486
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   487
    ^ results
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   488
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   489
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   490
     '%d %x' scanf:(ReadStream on:'1234 ff00')
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   491
    "
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   492
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   493
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   494
!CharacterArray methodsFor:'private'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   495
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   496
scanf_scanArgFrom:dataStream to:collection format:format
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   497
    "Add to <collection> an object who's representation is found
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   498
     in <dataStream> interpreted according to the conversion
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   499
     control string in the Stream <format>.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   500
     <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
   501
     string is assumed available.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   502
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   503
     Return when the conversion control string is consumed.  Leave
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   504
     <format> pointing past the last character in the conversion
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   505
     control string, leave <dataStream> pointing past any width
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   506
     specified in <format>, or at the first character that doesn't
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   507
     make sense for the <format>.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   508
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   509
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   510
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   511
    |final width char pos data scanset exclusive return last|
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   512
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   513
    final := [:retval |
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   514
	    collection add:retval.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   515
	    data == dataStream ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   516
		dataStream position:dataStream position + data position
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   517
	    ].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   518
	    ^ self
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   519
	].
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   520
    width := 0.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   521
    char := format peek.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   522
    char == $% ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   523
	^ dataStream peekFor:char
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   524
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   525
    char == $* ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   526
	format next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   527
	char := format peek.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   528
	final := [:retval |
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   529
		data == dataStream ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   530
		    dataStream position:dataStream position + data position
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   531
		].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   532
		^ self
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   533
	    ]
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
    char isDigit ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   536
	width := Integer readFrom:format.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   537
	char := format peek
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   538
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   539
    ('slhduoxfeg' includes:char) ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   540
	dataStream skipSeparators
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   541
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   542
    width = 0 ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   543
	data := dataStream
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   544
    ] ifFalse:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   545
	pos := dataStream position.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   546
	data := ReadStream on:(dataStream next:width).
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   547
	dataStream position:pos
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   548
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   549
    char == $s ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   550
	final value:(data upToSeparator)
2241
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
    char == $c ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   553
	width = 0 ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   554
	    final value:(String with:data next)
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   555
	] ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   556
	    final value:data contents
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   557
	]
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   558
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   559
    char == $[ "What a mess!!" ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   560
	return := WriteStream on:(VariableString "String" new:8).
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   561
	scanset := IdentitySet new.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   562
	format next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   563
	width = 0 ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   564
	    width := SmallInteger maxVal
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   565
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   566
	exclusive := format peekFor:$^.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   567
	[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   568
	    last := char.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   569
	    char := format next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   570
	    char == $]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   571
	] whileFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   572
	    char == $- ifFalse:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   573
		scanset add:char
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   574
	    ] ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   575
		(last to:format next) do:[:c |
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   576
		    scanset add:c
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   577
		]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   578
	    ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   579
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   580
	[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   581
	    data atEnd not and:[ (scanset includes:data peek) xor:exclusive ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   582
	] whileTrue:[ return nextPut:data next ].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   583
	final value:return contents
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   584
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   585
    ('lh' includes:char) ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   586
	format next.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   587
	char := format peek
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   588
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   589
    ('DUdu' includes:char) ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   590
	final value:(Integer readFrom:data)
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   591
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   592
    ('FEGfeg' includes:char) ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   593
	final value:(Float readFrom:data)
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   594
    ].
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   595
    ('b' includes:char) ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   596
	final value:(Integer readFrom:data radix:2)
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   597
    ].
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   598
    ('Oo' includes:char) ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   599
	final value:(Integer readFrom:data radix:8)
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   600
    ].
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   601
    ('Xx' includes:char) ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   602
	final value:(Integer readFrom:data radix:16)
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   603
    ]
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   604
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   605
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   606
     '%d %x' sscanf:'1234 ff00'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   607
     '%d %x %b' sscanf:'1234 ff00 1001'
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   608
    "
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   609
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   610
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   611
!CharacterArray methodsFor:'converting'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   612
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   613
sscanf:string
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   614
    "Return a Collection of objects found in <string> as
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   615
     interpreted according to the receiver.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   616
     The receiver is assumed to be a conversion control string as
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   617
     specified in the Unix C-language manual page for scanf(3).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   618
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   619
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   620
    ^ self scanf:(ReadStream on:string)
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   621
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   622
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   623
     '%d %x' sscanf:'1234 ff00'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   624
     '%d %x %b' sscanf:'1234 ff00 1001'
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   625
    "
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   626
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   627
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   628
!Float methodsFor:'private'!
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   629
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   630
absDecimalPrintOn:aStream digits:digits
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   631
    "Place a string representation of the receiver's abs value
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   632
     on <aStream> using <digits> significant digits, using decimal notation.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   633
     This is a helper for printf."
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   634
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   635
    |exp x fuzz i|
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   636
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   637
    "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
   638
    exp := self abs < 1.0
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   639
		ifTrue:[ (10.0 / self abs) log floor negated ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   640
		ifFalse:[ self abs log floor ].
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   641
    x := self abs / (10.0 raisedTo:exp).
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   642
    fuzz := 10.0 raisedTo:1 - digits.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   643
     "round the last digit to be printed"
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   644
    x := 0.5 * fuzz + x.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   645
    x >= 10.0 "check if rounding has unnormalized x" ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   646
	x := x / 10.0.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   647
	exp := exp + 1
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   648
    ].
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   649
    exp < 0 ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   650
	1 to:1 - exp do:[:j |
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   651
	    aStream nextPut:('0.000000000000' at:j)
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   652
	]
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   653
    ].
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   654
    [ x >= fuzz ] "use fuzz to track significance" whileTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   655
	i := x truncated.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   656
	aStream nextPut:(48 + i) asCharacter.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   657
	x := (x - i) * 10.0.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   658
	fuzz := fuzz * 10.0.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   659
	exp := exp - 1.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   660
	exp = -1 ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   661
	    aStream nextPut:$.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   662
	]
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   663
    ].
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   664
    [ exp >= -1 ] whileTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   665
	aStream nextPut:$0.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   666
	exp := exp - 1.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   667
	exp = -1 ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   668
	    aStream nextPut:$.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   669
	]
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   670
    ]
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   671
! !
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   672
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   673
!Float methodsFor:'private'!
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   674
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   675
absPrintOn:aStream digits:digits
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   676
    "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
   677
     <digits> significant digits.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   678
     This is a helper for printf."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   679
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   680
    (self < 1.0e6 and:[ self > 1.0e-4 ]) ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   681
	self absDecimalPrintOn:aStream digits:digits
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   682
    ] ifFalse:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   683
	self absScientificPrintOn:aStream digits:digits
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
! !
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   686
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   687
!Float methodsFor:'private'!
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   688
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   689
absScientificPrintOn:aStream digits:digits
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   690
    "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
   691
     digits, using scientific notation.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   692
     This is a helper for printf."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   693
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   694
    |exp fuzz x q i|
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
    "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
   697
    exp := self abs < 1.0
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   698
	    ifTrue:[ (10.0 / self abs) log floor negated ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   699
	    ifFalse:[ self abs log floor ].
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   700
    x := self abs / (10.0 raisedTo:exp).
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   701
    fuzz := 10.0 raisedTo:1 - digits.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   702
     "round the last digit to be printed"
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   703
    x := 0.5 * fuzz + x.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   704
    x >= 10.0 "check if rounding has unnormalized x" ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   705
	x := x / 10.0.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   706
	exp := exp + 1
2237
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
    q := exp.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   709
    exp := 0.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   710
    [ x >= fuzz ] "use fuzz to track significance" whileTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   711
	i := x truncated.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   712
	aStream nextPut:(48 + i) asCharacter.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   713
	x := (x - i) * 10.0.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   714
	fuzz := fuzz * 10.0.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   715
	exp := exp - 1.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   716
	exp = -1 ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   717
	    aStream nextPut:$.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   718
	]
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   719
    ].
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   720
    [ exp >= -1 ] whileTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   721
	aStream nextPut:$0.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   722
	exp := exp - 1.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   723
	exp = -1 ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   724
	    aStream nextPut:$.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   725
	]
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   726
    ].
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   727
    aStream nextPut:$e.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   728
    q printOn:aStream
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   729
! !
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   730
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   731
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   732
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   733
addInterest:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   734
    "install an interest forwarder.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   735
     Here, we use the nonWeakDependencies."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   736
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   737
    self addNonWeakDependent:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   738
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   739
    "Created: 14.10.1996 / 22:27:34 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   740
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   741
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   742
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   743
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   744
expressInterestIn:aspect for:anObject sendBack:aSelector
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   745
    "arrange for aSelector to be sent to anObject whenever the receiver
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   746
     changes aspect."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   747
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   748
    "/ for now, use an interestConverter, which is somewhat less efficient.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   749
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   750
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   751
    self addInterest:(InterestConverter
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   752
			    destination:anObject
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   753
			    selector:aSelector
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   754
			    aspect:aspect)
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   755
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   756
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   757
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   758
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   759
     b := [Transcript showCR:' -> the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   760
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   761
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   762
     Transcript showCR:'interest in #foo:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   763
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   764
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   765
     Transcript showCR:'now changing #bar ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   766
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   767
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   768
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   769
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   770
     Transcript showCR:'now changing #foo ... (expect notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   771
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   772
     Transcript cr.
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
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   775
     Transcript showCR:'no more interest in #foo:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   776
     p retractInterestIn:#foo for:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   777
     Transcript showCR:'now changing #foo ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   778
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   779
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   780
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   781
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   782
     Transcript showCR:'interest in #bar now:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   783
     p expressInterestIn:#bar for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   784
     Transcript showCR:'now changing #foo ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   785
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   786
     Transcript showCR:'now changing #bar ... (expect notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   787
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   788
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   789
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   790
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   791
     Transcript showCR:'interest in #foo now:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   792
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   793
     Transcript showCR:'now changing #foo ... (expect notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   794
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   795
     Transcript showCR:'now changing #bar ... (expect 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:'no more interests:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   801
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   802
     Transcript showCR:'now changing #foo ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   803
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   804
     Transcript showCR:'now changing #bar...  (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   805
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   806
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   807
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   808
     p release.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   809
    "
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
   810
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   811
    "Created: 19.4.1996 / 10:26:22 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   812
    "Modified: 19.4.1996 / 12:34:08 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   813
    "Modified: 14.10.1996 / 22:28:20 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   814
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   815
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   816
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   817
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   818
interests
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   819
    "return a Collection of interests - empty if there is none.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   820
     Here, we use the nonWeakDependents for interests."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   821
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   822
    ^ self nonWeakDependents
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   823
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   824
    "Created: / 14.10.1996 / 22:20:51 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   825
    "Modified: / 30.1.1998 / 14:07:35 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   826
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   827
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   828
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   829
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   830
interestsFor:someOne
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   831
    "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
   832
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   833
    |coll deps|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   834
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   835
    deps := self interests.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   836
    deps size == 0 ifTrue:[^ #()].
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
    coll := IdentitySet new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   839
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   840
    deps do:[:dep |
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   841
	(dep isInterestConverter) ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   842
	    dep destination == someOne ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   843
		coll add:dep.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   844
	    ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   845
	]
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   846
    ].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   847
    ^ coll
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   848
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   849
    "Created: / 30.1.1998 / 14:02:26 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   850
    "Modified: / 30.1.1998 / 14:08:24 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   851
! !
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
   852
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   853
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   854
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   855
onChangeEvaluate:aBlock
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   856
    "arrange for aBlock to be evaluated whenever the receiver changes."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   857
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
   858
    |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
   859
329461c02e84 allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   860
    na := aBlock numArgs.
329461c02e84 allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   861
    na == 0 ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   862
	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
   863
    ] ifFalse:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   864
	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
   865
    ].
329461c02e84 allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   866
    ^ self onChangeSend:selector to:aBlock
1759
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
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   869
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   870
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   871
     b := [Transcript showCR:' -> the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   872
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   873
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   874
     Transcript showCR:'interest in #foo:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   875
     p onChangeEvaluate:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   876
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   877
     Transcript showCR:'now changing #bar ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   878
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   879
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   880
     p retractInterests.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   881
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   882
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   883
! !
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
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   886
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   887
onChangeSend:aSelector to:anObject
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   888
    "arrange for aSelector to be sent to anObject whenever the receiver
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   889
     changes."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   890
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   891
    "/ for now, use an interestConverter, which is somewhat less efficient.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   892
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   893
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   894
    ((self interests ? #())
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   895
	contains:[:anInterest |
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   896
	    (anInterest isInterestConverter)
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   897
	    and:[ anInterest destination == anObject
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   898
	    and:[ anInterest selector == aSelector]]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   899
	])
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   900
	    ifTrue:[^ self].
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   901
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   902
    self addInterest:(InterestConverter
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   903
			  destination:anObject
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   904
			  selector:aSelector)
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
   905
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
   906
    "
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   907
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   908
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   909
     b := [Transcript showCR:'the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   910
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   911
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   912
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   913
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   914
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   915
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   916
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   917
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   918
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   919
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   920
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   921
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   922
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   923
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   924
     Transcript showCR:'no more interest'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   925
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   926
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   927
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   928
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   929
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   930
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   931
     Transcript showCR:'interest again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   932
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   933
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   934
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   935
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   936
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   937
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   938
    "Created: 19.4.1996 / 10:26:38 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   939
    "Modified: 19.4.1996 / 12:34:26 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   940
    "Modified: 14.10.1996 / 22:28:27 / stefan"
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
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   943
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   944
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   945
removeInterest:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   946
    "remove an interest forwarder.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   947
     Here, we use the nonWeakDependencies."
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
    self removeNonWeakDependent:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   950
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   951
    "Created: 14.10.1996 / 22:21:59 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   952
! !
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
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   955
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   956
retractInterestIn:aspect for:someOne
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   957
    "remove the interest of someOne in the receiver changing aspect
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   958
     (as installed with #expressInterestIn:for:sendBack:)."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   959
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   960
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   961
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   962
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   963
    self retractInterestsForWhich:[:i | (i aspect == aspect) and:[i destination == someOne]]
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   964
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
   965
    "
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   966
     |p b|
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
     b := [Transcript showCR:'the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   969
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   970
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   971
     Transcript showCR:'interest in #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   972
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   973
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   974
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   975
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   976
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   977
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   978
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   979
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   980
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   981
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   982
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   983
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   984
     Transcript showCR:'no more interest in #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   985
     p retractInterestIn:#foo for:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   986
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   987
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   988
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   989
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   990
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   991
     Transcript showCR:'interest in #bar now'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   992
     p expressInterestIn:#bar for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   993
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   994
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   995
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   996
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   997
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   998
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   999
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1000
     Transcript showCR:'interest in #foo now'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1001
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1002
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1003
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1004
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1005
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1006
     Transcript cr.
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
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1009
     Transcript showCR:'no more interests'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1010
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1011
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1012
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1013
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1014
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1015
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1016
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1017
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1018
    "Created: / 19.4.1996 / 10:27:11 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1019
    "Modified: / 14.10.1996 / 22:21:19 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1020
    "Modified: / 30.1.1998 / 14:05:34 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1021
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1022
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1023
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1024
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1025
retractInterests
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1026
    "remove all interests in the receiver changing aspect
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1027
     (as installed with #expressInterestIn:for:sendBack:)."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1028
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1029
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1030
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1031
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1032
    self retractInterestsForWhich:[:i | true ]
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1033
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1034
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1035
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1036
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1037
retractInterestsFor:someOne
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1038
    "remove the interest of someOne in the receiver
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1039
     (as installed with #onChangeSend:to:)."
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
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1042
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1043
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1044
    self retractInterestsForWhich:[:i | i destination == someOne ]
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1045
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1046
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1047
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1048
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1049
     b := [Transcript showCR:'the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1050
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1051
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1052
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1053
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1054
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1055
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1056
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1057
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1058
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1059
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1060
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1061
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1062
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1063
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1064
     Transcript showCR:'no more interest'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1065
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1066
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1067
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1068
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1069
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1070
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1071
     Transcript showCR:'interest again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1072
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1073
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1074
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1075
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1076
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1077
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1078
    "Created: / 19.4.1996 / 10:23:46 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1079
    "Modified: / 14.10.1996 / 22:21:25 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1080
    "Modified: / 30.1.1998 / 14:04:52 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1081
! !
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
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1084
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1085
retractInterestsForWhich:aBlock
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1086
    "remove all interests in the receiver changing aspect
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1087
     (as installed with #expressInterestIn:for:sendBack:)."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1088
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1089
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1090
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1091
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1092
    |deps coll|
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
    deps := self interests.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1095
    deps size ~~ 0 ifTrue:[
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1096
	"/ cannot removeDependent within the loop - the interests collection rehashes
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1097
	coll := OrderedCollection new.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1098
	deps do:[:dep |
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1099
	    dep isInterestConverter ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1100
		(aBlock value:dep) ifTrue:[coll add:dep].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1101
	    ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1102
	].
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1103
	coll do:[:dep |
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1104
	    self removeInterest:dep.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1105
	].
1759
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
! !
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
!Object methodsFor:'dependents-interests'!
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
retractInterestsIn:aspect
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1112
    "remove all interests in the receiver changing aspect
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1113
     (as installed with #expressInterestIn:for:sendBack:)."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1114
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1115
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1116
    "/ In the future, a more intelligent DependencyCollection class is planned for
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
    self retractInterestsForWhich:[:i | i aspect == aspect ]
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1119
! !
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1120
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1121
!Object methodsFor:'dependents-st/v event simulation'!
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1122
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1123
when:eventSymbol send:selector to:anObject
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1124
    "install an ST/V-style interest forwarder.
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1125
     Here, we use the nonWeakDependencies."
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1126
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1127
    self addInterest:(InterestConverterWithParameters
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1128
			    destination:anObject
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1129
			    selector:selector
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1130
			    aspect:eventSymbol).
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1131
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1132
    "
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1133
     |p b|
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1134
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1135
     b := [Transcript showCR:'the point changed'].
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1136
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1137
     p := Point new.
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1138
     p whem:#foo:bar: send:#value:value: to:[:a :b | Transcript show:'foo: '; show:a; show:' bar: '; showCR:b].
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1139
     Transcript showCR:'now changing'.
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1140
     p triggerEvent:#foo:bar: withArguments:#('fooArg' 'barArg').
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1141
     p retracrtInterests.
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1142
    "
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1143
! !
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1144
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1145
!stx_libbasic2 class methodsFor:'documentation'!
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1146
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1147
extensionsVersion_CVS
2337
755696d72648 comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
  1148
    ^ '$Header: /cvs/stx/stx/libbasic2/extensions.st,v 1.16 2009-11-07 10:15:14 cg Exp $'
755696d72648 comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
  1149
! !