extensions.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Jun 2019 14:28:51 +0200
changeset 5050 44fa8672d102
parent 4969 9acd20c528a3
child 5088 72f0347803b6
permissions -rw-r--r--
#DOCUMENTATION by cg class: SharedQueue comment/format in: #next #nextWithTimeout:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2337
755696d72648 comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
     1
"{ Package: 'stx:libbasic2' }"!
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
     2
4381
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     3
!ArithmeticValue methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     4
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     5
asQDouble
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     6
    "return a QDouble with same value"
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     7
4480
3149cd46d7d1 comment
Claus Gittinger <cg@exept.de>
parents: 4473
diff changeset
     8
    ^ QDouble fromFloat:self asFloat
4381
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
     9
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    10
    "
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    11
     123 asQDouble
4480
3149cd46d7d1 comment
Claus Gittinger <cg@exept.de>
parents: 4473
diff changeset
    12
     (Fraction basicNew setNumerator:246 denominator:2) asQDouble
3149cd46d7d1 comment
Claus Gittinger <cg@exept.de>
parents: 4473
diff changeset
    13
     123 asLongFloat asQDouble
3149cd46d7d1 comment
Claus Gittinger <cg@exept.de>
parents: 4473
diff changeset
    14
     123 asLargeFloat asQDouble
4381
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    15
    "
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    16
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    17
    "Created: / 13-06-2017 / 16:48:24 / cg"
4480
3149cd46d7d1 comment
Claus Gittinger <cg@exept.de>
parents: 4473
diff changeset
    18
    "Modified (comment): / 25-07-2017 / 16:06:19 / cg"
4381
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    19
! !
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
    20
4379
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    21
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    22
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    23
differenceFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    24
    "aQDouble does not know how to subtract the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    25
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    26
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    27
    ^ aQDouble retry:#- coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    28
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    29
    "Created: / 13-06-2017 / 08:55:38 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    30
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    31
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    32
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    33
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    34
equalFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    35
    "aQDouble does not know how to compare to the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    36
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    37
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    38
    ^ aQDouble retry:#= coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    39
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    40
    "Created: / 13-06-2017 / 08:55:30 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    41
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    42
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    43
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    44
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    45
lessFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    46
    "aQDouble does not know how to compare to the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    47
     Return true if aQDouble < self.
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    48
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    49
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    50
    ^ aQDouble retry:#< coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    51
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    52
    "Created: / 13-06-2017 / 08:55:20 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    53
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    54
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    55
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    56
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    57
productFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    58
    "aQDouble does not know how to multiply the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    59
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    60
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    61
    ^ aQDouble retry:#* coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    62
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    63
    "Created: / 13-06-2017 / 08:55:07 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    64
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    65
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    66
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    67
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    68
quotientFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    69
    "aQDouble does not know how to divide by the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    70
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    71
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    72
    ^ aQDouble retry:#/ coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    73
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    74
    "Created: / 13-06-2017 / 08:54:55 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    75
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    76
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    77
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    78
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    79
remainderFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    80
    "aQDouble does not know how to compute the remainder with the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    81
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    82
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    83
    ^ aQDouble retry:#rem: coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    84
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    85
    "Created: / 13-06-2017 / 08:54:47 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    86
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    87
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    88
!ArithmeticValue methodsFor:'double dispatching'!
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    89
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    90
sumFromQDouble:aQDouble
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    91
    "aQDouble does not know how to add the receiver -
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    92
     retry the operation by coercing to higher generality"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    93
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    94
    ^ aQDouble retry:#+ coercing:self
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    95
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    96
    "Created: / 13-06-2017 / 08:54:27 / cg"
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    97
! !
e547154fa694 double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents: 4365
diff changeset
    98
4448
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
    99
!Block methodsFor:'Compatibility-Dolphin'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   100
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   101
deferredValue
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   102
    "Dolphin compatibility method - do not use in new code.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   103
     Dolphin's alias for futureValue"
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   104
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   105
    ^ Future new block:self
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   106
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   107
    "Modified: / 04-10-2011 / 14:56:27 / cg"
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   108
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   109
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   110
!Block methodsFor:'Compatibility-Dolphin'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   111
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   112
deferredValueAt:priority
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   113
    "Dolphin compatibility method - do not use in new code.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   114
     Dolphin's alias for futureValue"
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   115
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   116
    ^ Future new
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   117
	priority:priority block:self
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   118
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   119
    "Created: / 04-10-2011 / 14:55:56 / cg"
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   120
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   121
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   122
!Block methodsFor:'parallel evaluation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   123
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   124
futureValue
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   125
    "Fork a synchronised evaluation of myself.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   126
     Starts the evaluation in parallel now, but synchronizes
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   127
     any access to wait until the result is computed."
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   128
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   129
    ^ Future new block:self
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   130
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   131
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   132
!Block methodsFor:'parallel evaluation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   133
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   134
futureValue:aValue
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   135
    "Fork a synchronised evaluation of myself.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   136
     Starts the evaluation in parallel now, but synchronizes
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   137
     any access to wait until the result is computed."
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   138
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   139
    ^ Future new block:self value:aValue
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   140
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   141
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   142
!Block methodsFor:'parallel evaluation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   143
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   144
futureValue:aValue value:anotherValue
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   145
    "Fork a synchronised evaluation of myself.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   146
     Starts the evaluation in parallel now, but synchronizes
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   147
     any access to wait until the result is computed."
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   148
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   149
    ^ Future new
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   150
	block:self
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   151
	value:aValue
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   152
	value:anotherValue
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   153
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   154
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   155
!Block methodsFor:'parallel evaluation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   156
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   157
futureValue:aValue value:anotherValue value:bValue
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   158
    "Fork a synchronised evaluation of myself.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   159
     Starts the evaluation in parallel now, but synchronizes
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   160
     any access to wait until the result is computed."
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   161
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   162
    ^ Future new
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   163
	block:self
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   164
	value:aValue
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   165
	value:anotherValue
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   166
	value:bValue
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   167
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   168
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   169
!Block methodsFor:'parallel evaluation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   170
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   171
futureValueWithArguments:anArray
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   172
    "Fork a synchronised evaluation of myself.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   173
     Starts the evaluation in parallel now, but synchronizes
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   174
     any access to wait until the result is computed."
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   175
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   176
    ^ Future new
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   177
	block:self
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   178
	valueWithArguments:anArray
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   179
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   180
    "Modified (format): / 04-10-2011 / 14:55:40 / cg"
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   181
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   182
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   183
!Block methodsFor:'parallel evaluation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   184
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   185
lazyValue
4797
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   186
    "Return a lazy value object, evaluating myself. 
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   187
     Only computes when the result is requested."
4448
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   188
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   189
    ^ Lazy new block:self
4797
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   190
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   191
    "Modified (comment): / 09-02-2019 / 15:59:29 / Claus Gittinger"
4448
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   192
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   193
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   194
!Block methodsFor:'parallel evaluation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   195
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   196
lazyValue:aValue
4797
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   197
    "Return a lazy value object, evaluating myself. 
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   198
     Only computes when the result is requested."
4448
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   199
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   200
    ^ Lazy new block:self value:aValue
4797
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   201
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   202
    "Modified (comment): / 09-02-2019 / 16:00:02 / Claus Gittinger"
4448
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   203
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   204
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   205
!Block methodsFor:'parallel evaluation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   206
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   207
lazyValue:aValue value:anotherValue
4797
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   208
    "Return a lazy value object, evaluating myself. 
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   209
     Only computes when the result is requested."
4448
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   210
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   211
    ^ Lazy new
4797
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   212
        block:self
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   213
        value:aValue
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   214
        value:anotherValue
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   215
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   216
    "Modified (comment): / 09-02-2019 / 16:00:05 / Claus Gittinger"
4448
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   217
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   218
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   219
!Block methodsFor:'parallel evaluation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   220
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   221
lazyValue:aValue value:anotherValue value:bValue
4797
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   222
    "Return a lazy value object, evaluating myself. 
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   223
     Only computes when the result is requested."
4448
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   224
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   225
    ^ Lazy new
4797
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   226
        block:self
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   227
        value:aValue
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   228
        value:anotherValue
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   229
        value:bValue
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   230
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   231
    "Modified (comment): / 09-02-2019 / 16:00:08 / Claus Gittinger"
4448
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   232
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   233
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   234
!Block methodsFor:'parallel evaluation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   235
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   236
lazyValueWithArguments:anArray
4797
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   237
    "Return a lazy value object, evaluating myself. 
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   238
     Only computes when the result is requested."
4448
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   239
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   240
    ^ Lazy new block:self valueWithArguments:anArray
4797
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   241
ea7ce61a8957 class: Block
Claus Gittinger <cg@exept.de>
parents: 4773
diff changeset
   242
    "Modified (comment): / 09-02-2019 / 16:00:12 / Claus Gittinger"
4448
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   243
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   244
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   245
!Block methodsFor:'process creation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   246
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   247
promise
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   248
    "create a promise on the receiver. The promise will evaluate the
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   249
     receiver and promise to return the value with the #value message.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   250
     The evaluation will be performed as a separate process.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   251
     Asking the promise for its value will either block the asking process
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   252
     (if the evaluation has not yet been finished) or return the value
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   253
     immediately."
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   254
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   255
    ^ Promise value:self
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   256
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   257
    "
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   258
     |p|
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   259
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   260
     p := [1000 factorial] promise.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   261
     'do something else ...'.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   262
     p value
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   263
    "
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   264
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   265
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   266
!Block methodsFor:'process creation'!
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   267
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   268
promiseAt:prio
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   269
    "create a promise on the receiver. The promise will evaluate the
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   270
     receiver and promise to return the value with the #value message.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   271
     The evaluation will be performed as a separate process running at prio.
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   272
     Asking the promise for its value will either block the asking process
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   273
     (if the evaluation has not yet been finished) or return the value
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   274
     immediately."
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   275
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   276
    ^ Promise value:self priority:prio
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   277
! !
f9bbcb40b337 class: Block
Stefan Vogel <sv@exept.de>
parents: 4429
diff changeset
   278
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   279
!CharacterArray methodsFor:'matching - phonetic'!
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   280
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   281
asKoelnerPhoneticCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   282
    "return a koelner phonetic code.
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   283
     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
   284
     it returns simular strings for similar sounding words.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   285
     There are some differences to soundex, though:
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   286
	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
   287
	it does not start with the first character of the input.
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   289
     Caveat: this phonetic code is especially suited for german words.
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   290
	     Please have a look at the other phonetic comparison operators found
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   291
	     in PhoneticStringUtilities."
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   292
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   293
    ^ PhoneticStringUtilities koelnerPhoneticCodeOf:self
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   294
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   295
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   296
     #(
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   297
	'Müller'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   298
	'Miller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   299
	'Mueller'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   300
	'Mühler'
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   301
	'Mühlherr'
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   302
	'Mülherr'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   303
	'Myler'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   304
	'Millar'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   305
	'Myller'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   306
	'Müllar'
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   307
	'Müler'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   308
	'Muehler'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   309
	'Mülller'
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   310
	'Müllerr'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   311
	'Muehlherr'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   312
	'Muellar'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   313
	'Mueler'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   314
	'Mülleer'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   315
	'Mueller'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   316
	'Nüller'
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   317
	'Nyller'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   318
	'Niler'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   319
	'Czerny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   320
	'Tscherny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   321
	'Czernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   322
	'Tschernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   323
	'Schernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   324
	'Scherny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   325
	'Scherno'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   326
	'Czerne'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   327
	'Zerny'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   328
	'Tzernie'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   329
	'Breschnew'
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   330
     ) do:[:w |
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   331
	 Transcript show:w; show:'->'; showCR:(w asKoelnerPhoneticCode)
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   332
     ].
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   333
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   334
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   335
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   336
     'Breschnew' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   337
     'Breschnew' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   338
     'Breschneff' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   339
     'Braeschneff' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   340
     'Braessneff' asKoelnerPhoneticCode -> '17863'
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   341
     'Pressneff' asKoelnerPhoneticCode -> '17863'
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
   342
     'Presznäph' asKoelnerPhoneticCode -> '17863'
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   343
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   344
! !
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   345
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   346
!CharacterArray methodsFor:'matching - phonetic'!
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   347
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   348
asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   349
    "return a soundex phonetic code or nil.
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   350
     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
   351
     tool when searching for words where the correct spelling is unknown.
4190
031045a0f356 class: stx_libbasic2
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
   352
     (read Knuth or search the web if you don't know what a soundex code is).
2288
316a202d1c8b category changes
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   353
2337
755696d72648 comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
   354
     Caveat: 'similar sounding words' means: 'similar sounding in ENGLISH'
4190
031045a0f356 class: stx_libbasic2
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
   355
             Please have a look at the other phonetic comparison operators found
031045a0f356 class: stx_libbasic2
Claus Gittinger <cg@exept.de>
parents: 4095
diff changeset
   356
             in PhoneticStringUtilities."
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   357
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   358
    ^ PhoneticStringUtilities soundexCodeOf:self
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   359
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   360
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   361
     'claus' asSoundexCode
2199
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   362
     'clause' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   363
     'close' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   364
     'smalltalk' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   365
     'smaltalk' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   366
     'smaltak' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   367
     'smaltok' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   368
     'smoltok' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   369
     'aa' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   370
     'by' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   371
     'bab' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   372
     'bob' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   373
     'bop' asSoundexCode
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   374
    "
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   375
! !
a9d3b1aa9f03 phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents: 2150
diff changeset
   376
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   377
!CharacterArray methodsFor:'printing & storing'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   378
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   379
printf:args
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   380
    "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
   381
     as specified in the Unix C-language manual page for printf(3).
3114
1d5224486d3c class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3094
diff changeset
   382
     Return the resulting string (i.e actually, this is more like an sprintf).
4619
7e627429f1c6 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   383
     For smalltalk specific formats, 
7e627429f1c6 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   384
     see documentation in PrintfScanf >> format_printf.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   385
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   386
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   387
    |aStream|
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   388
3538
d79ee26ed971 class: Date
Stefan Vogel <sv@exept.de>
parents: 3274
diff changeset
   389
    aStream := CharacterWriteStream on:(self species uninitializedNew:self size).
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   390
    self printf:args on:aStream.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   391
    ^ aStream contents
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   392
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   393
    "
3796
70a4a03f4028 comment
Claus Gittinger <cg@exept.de>
parents: 3720
diff changeset
   394
     ('%05x %d %f %o' printf:{ 123. 234*5. 1.234. 8r377 } )    
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   395
     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
   396
    "
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   397
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   398
    "
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   399
     Transcript showCR: 'Some examples:'!!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   400
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   401
     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
   402
     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
   403
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   404
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   405
     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
   406
     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
   407
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   408
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   409
     Transcript show: '''%8.3f'' printf: (Array with: 200 sqrt negated) = .'.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   410
     Transcript show: ('%8.3f' printf: (Array with: 200 sqrt negated)).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   411
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   412
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   413
     Transcript show: '''%c'' printf: #(16r41) = .'.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   414
     Transcript show: ('%c' printf: #(16r41)).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   415
     Transcript showCR: '.'
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   416
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   417
     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
   418
     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
   419
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   420
     Transcript show: '''%d%f%s'' sscanf: ''25 54.32e-01 monday'' = '.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   421
     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
   422
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   423
     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
   424
     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
   425
    "
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   426
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   427
    "Modified (comment): / 14-11-2017 / 22:58:01 / cg"
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   428
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   429
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   430
!CharacterArray methodsFor:'printing & storing'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   431
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   432
printf:args on:outStream
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   433
    "Format and print the receiver on <outStream> with <args>
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   434
     formatted in C style, as specified in the Unix C-language manual page for printf(3).
4619
7e627429f1c6 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   435
     For smalltalk specific formats, 
7e627429f1c6 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   436
     see documentation in PrintfScanf >> format_printf.
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   437
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   438
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   439
    PrintfScanf printf:self on:outStream arguments: args
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   440
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   441
    "
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   442
     '%e' printf:{ 1234.567 ] on:Transcript
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   443
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   444
     '%10s%3d\n' printf:{ 'hello' . 12 } on:Transcript
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   445
     '%10s%3d\n' printf:{ '1234567890' . 12 } on:Transcript
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   446
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   447
     like C's printf, a longer datum may be formatted wider than the formatspec says:
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   448
     
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   449
     '%10s%3d\n' printf:{ '12345678901234' . 12 } on:Transcript
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   450
     
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   451
     '%10s%3d\n' printf:{ 'hello' . 12 } on:Transcript
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   452
     '%10s%03d\n' printf:{ 'hello' . 12 } on:Transcript
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   453
    "
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   454
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   455
    "Modified (comment): / 14-11-2017 / 22:57:58 / cg"
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   456
! !
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   457
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   458
!CharacterArray methodsFor:'printing & storing'!
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   459
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   460
printfWith:arg1
2295
27e3885efddd comment/format in:6 methods
Claus Gittinger <cg@exept.de>
parents: 2288
diff changeset
   461
    "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
   462
     as specified in the Unix C-language manual page for printf(3).
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   463
     Return the resulting string (i.e actually, this is more like an sprintf).
4619
7e627429f1c6 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   464
     For smalltalk specific formats, 
7e627429f1c6 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   465
     see documentation in PrintfScanf >> format_printf"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   466
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   467
    ^ self printf:(Array with:arg1)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   468
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   469
    "
3796
70a4a03f4028 comment
Claus Gittinger <cg@exept.de>
parents: 3720
diff changeset
   470
     ('%05x' printfWith:123)
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   471
     Transcript showCR:('%05x' printfWith:123)
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   472
    "
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   473
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   474
    "Modified (comment): / 14-11-2017 / 22:58:10 / cg"
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   475
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   476
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   477
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   478
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   479
printfWith:arg1 with:arg2
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   480
    "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
   481
     as specified in the Unix C-language manual page for printf(3).
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   482
     Return the resulting string (i.e actually, this is more like an sprintf).
4619
7e627429f1c6 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   483
     For smalltalk specific formats, see documentation in PrintfScanf >> format_printf."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   484
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   485
    ^ self printf:(Array with:arg1 with:arg2)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   486
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   487
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   488
     Transcript showCR:('%d %05x' printfWith:123 with:234)
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   489
    "
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   490
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   491
    "Modified (comment): / 14-11-2017 / 22:58:16 / cg"
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   492
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   493
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   494
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   495
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   496
printfWith:arg1 with:arg2 with:arg3
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   497
    "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
   498
     as specified in the Unix C-language manual page for printf(3).
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   499
     Return the resulting string (i.e actually, this is more like an sprintf).
4619
7e627429f1c6 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   500
     For smalltalk specific formats, see documentation in PrintfScanf >> format_printf."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   501
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   502
    ^ self printf:(Array with:arg1 with:arg2 with:arg3)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   503
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   504
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   505
     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
   506
    "
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   507
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   508
    "Modified (comment): / 14-11-2017 / 22:58:20 / cg"
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   509
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   510
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   511
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   512
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   513
printfWith:arg1 with:arg2 with:arg3 with:arg4
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   514
    "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
   515
     as specified in the Unix C-language manual page for printf(3).
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   516
     Return the resulting string (i.e actually, this is more like an sprintf).
4619
7e627429f1c6 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   517
     For smalltalk specific formats, see documentation in PrintfScanf >> format_printf."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   518
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   519
    ^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4)
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   520
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   521
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   522
     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
   523
    "
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   524
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   525
    "Modified (comment): / 14-11-2017 / 22:58:23 / cg"
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   526
! !
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   527
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   528
!CharacterArray methodsFor:'printing & storing'!
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   529
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   530
printfWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   531
    "Format and print the receiver with <argI> formatted in C style,
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   532
     as specified in the Unix C-language manual page for printf(3).
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   533
     Return the resulting string (i.e actually, this is more like an sprintf).
4619
7e627429f1c6 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4528
diff changeset
   534
     For smalltalk specific formats, see documentation in PrintfScanf >> format_printf."
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   535
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   536
    ^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5)
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   537
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   538
    "
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   539
     Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123)
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   540
    "
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   541
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   542
    "Modified (comment): / 14-11-2017 / 22:58:28 / cg"
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   543
! !
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   544
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   545
!CharacterArray methodsFor:'printing & storing'!
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   546
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   547
printf_formatArgCount
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   548
    "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
   549
     as a printf/scanf format control string.
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   550
     For smalltalk specific formats, see documentation in PrintfScanf.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   551
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   552
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   553
    ^ PrintfScanf formatArgCountFor:self.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   554
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   555
    "Modified: / 19-06-2017 / 16:54:10 / cg"
4528
844e085a7ac1 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4480
diff changeset
   556
    "Modified (comment): / 14-11-2017 / 22:58:34 / cg"
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   557
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   558
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   559
!CharacterArray methodsFor:'private'!
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   560
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   561
printf_printArgFrom:formatStream to:outStream withData:argStream
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   562
    <resource: #obsolete>
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   563
    "Interpret the required number of arguments from <argStream>
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   564
     according to the formatting information in <formatStream>.
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   565
     Place the interpretation on <outStream>.
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   566
     The interpretation is C printf(3) style, as
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   567
     specified in the Unix C-language manual page for printf(3).
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   568
     <formatStream> is assumed to be positioned just past
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   569
     $%, and a complete control string is assumed available.
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   570
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   571
     Return when the conversion control string is consumed.
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   572
     Leave <formatStream> pointing past the last character in the conversion control string.
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   573
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   574
     This code assumes that <formatStream> is formatted according to
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   575
     specification, and error checking is minimal.  Unexpected
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   576
     results will be obtained by illegal control strings, or when
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   577
     argument types do not match conversion codes, but it probably
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   578
     won't dump core, like C does in such cases!!
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   579
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   580
     For copyright information, see goodies/String-printf_scanf.chg"
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   581
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   582
    PrintfScanf printArgFrom:formatStream to:outStream arguments:argStream
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   583
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   584
    "Modified: / 19-06-2017 / 15:44:28 / cg"
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   585
! !
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
   586
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   587
!CharacterArray methodsFor:'printing & storing'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   588
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   589
printf_printOn:outStream withData:args
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   590
    <resource: #obsolete>
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   591
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   592
    "Format and print the receiver on <outStream> with <args>
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   593
     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
   594
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   595
     For copyright information, see goodies/String-printf_scanf.chg"
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   596
2260
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   597
    self obsoleteMethodWarning:'use printf:on:'.
fd7e5634d0d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
   598
    self printf:args on:outStream
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   599
! !
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
!CharacterArray methodsFor:'converting'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   602
4473
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   603
scanf:dataStreamOrString
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   604
    "Return a Collection of objects found in the Character Stream
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   605
     <dataStream> as interpreted according to the receiver.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   606
     The receiver is assumed to be a conversion control string as
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   607
     specified in the Unix C-language manual page for scanf(3).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   608
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   609
4473
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   610
    |dataStream|
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   611
4473
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   612
    dataStream := dataStreamOrString readStream.
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   613
    ^ PrintfScanf scanf:self fromStream:dataStream
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   614
    
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   615
"/    |results format char|
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   616
"/
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   617
"/    results := OrderedCollection new.
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   618
"/    format := ReadStream on:self.
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   619
"/    [ format atEnd ] whileFalse:[
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   620
"/        char := format next.
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   621
"/        (char == Character space or:[ char == Character tab ]) ifTrue:[
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   622
"/            dataStream skipSeparators.
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   623
"/            format skipSeparators
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   624
"/        ].
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   625
"/        char == $% ifTrue:[
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   626
"/            PrintfScanf scanArgFrom:dataStream to:results format:format.
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   627
"/        ] ifFalse:[
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   628
"/            dataStream peekFor:char
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   629
"/        ]
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   630
"/    ].
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   631
"/    ^ results
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   632
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   633
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   634
     '%d %x' scanf:(ReadStream on:'1234 ff00')
4473
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   635
     '%d %s' scanf:(ReadStream on:'1234 ff00')
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   636
     '%d %b' scanf:(ReadStream on:'1234 1111')
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   637
     '%d %f' scanf:(ReadStream on:'1234 1111')
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   638
     '%d %f' scanf:(ReadStream on:'1234 1111.2345')
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   639
     '%d %q' scanf:(ReadStream on:'1234 1111.2345')
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   640
    "
4473
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   641
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   642
    "Modified: / 14-07-2017 / 11:11:49 / cg"
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   643
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   644
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   645
!CharacterArray methodsFor:'private'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   646
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   647
scanf_scanArgFrom:dataStream to:collection format:format
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   648
    <resource: #obsolete>
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   649
    "Add to <collection> an object who's representation is found
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   650
     in <dataStream> interpreted according to the conversion
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   651
     control string in the Stream <format>.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   652
     <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
   653
     string is assumed available.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   654
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   655
     Return when the conversion control string is consumed.  Leave
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   656
     <format> pointing past the last character in the conversion
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   657
     control string, leave <dataStream> pointing past any width
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   658
     specified in <format>, or at the first character that doesn't
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   659
     make sense for the <format>.
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   660
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   661
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   662
4473
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   663
    PrintfScanf scanArgFrom:dataStream to:collection format:format.
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   664
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   665
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   666
     '%d %x' sscanf:'1234 ff00'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   667
     '%d %x %b' sscanf:'1234 ff00 1001'
2256
10583ebc7f64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   668
    "
2679
cfab54d30fcc changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents: 2582
diff changeset
   669
4473
2fbda206b293 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4448
diff changeset
   670
    "Modified: / 14-07-2017 / 11:09:35 / cg"
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   671
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   672
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   673
!CharacterArray methodsFor:'converting'!
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   674
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   675
sscanf:string
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   676
    "Return a Collection of objects found in <string> as
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   677
     interpreted according to the receiver.
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   678
     The receiver is assumed to be a conversion control string as
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   679
     specified in the Unix C-language manual page for scanf(3).
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   680
     For copyright information, see goodies/String-printf_scanf.chg"
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   681
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   682
    ^ self scanf:(ReadStream on:string)
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   683
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   684
    "
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   685
     '%d %x' sscanf:'1234 ff00'
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   686
     '%d %x %b' sscanf:'1234 ff00 1001'
2241
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   687
    "
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   688
! !
81f10d4ad4bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   689
4714
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   690
!CharacterArray methodsFor:'Compatibility-Squeak'!
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   691
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   692
urlDecoded
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   693
    "decode %xx form.  This is the opposite of #urlEncoded"
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   694
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   695
    ^ HTMLUtilities urlDecoded:self
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   696
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   697
    "
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   698
     'abc%61def' unescapePercents
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   699
     'abc%61def' urlDecoded
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   700
     
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   701
      (HTMLUtilities urlEncoded:'_-.*Frankfurt(Main) Hbf') unescapePercents
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   702
      (HTMLUtilities urlEncoded:'_-.*Frankfurt(Main) Hbf') urlDecoded
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   703
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   704
      (HTMLUtilities urlEncoded:'-_.*%exept ex+pecco;') unescapePercents
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   705
      (HTMLUtilities urlEncoded:'-_.*%exept+ex+pecco;') urlDecoded
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   706
    "
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   707
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   708
    "Created: / 26-08-2018 / 12:41:49 / Claus Gittinger"
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   709
! !
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   710
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   711
!CharacterArray methodsFor:'Compatibility-Squeak'!
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   712
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   713
urlEncoded
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   714
    "encode into %xx form.  This is the opposite of #urlDecoded"
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   715
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   716
    ^ HTMLUtilities urlEncoded:self
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   717
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   718
    "
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   719
     'abcäöüdef' urlEncoded urlDecoded
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   720
     'abc%def' urlEncoded urlDecoded
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   721
     
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   722
      ('_-.*Frankfurt(Main) Hbf' urlEncoded) unescapePercents
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   723
      ('_-.*Frankfurt(Main) Hbf' urlEncoded) urlDecoded
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   724
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   725
      ('-_.*%exept ex+pecco;' urlEncoded) unescapePercents
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   726
      ('-_.*%exept+ex+pecco;' urlEncoded) urlDecoded
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   727
    "
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   728
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   729
    "Created: / 26-08-2018 / 13:03:03 / Claus Gittinger"
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   730
! !
5cc3b93dfc48 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4620
diff changeset
   731
4365
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   732
!Collection methodsFor:'converting'!
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   733
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   734
asHalfFloatArray
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   735
    "return a new HalfFloatArray with the collection's elements
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   736
     (which must convert to 16bit half-floats)."
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   737
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   738
    ^ self asArrayOfType:HalfFloatArray
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   739
! !
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   740
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   741
!Collection methodsFor:'converting'!
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   742
4400
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   743
asIdentitySkipList
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   744
	"Answer a IdentitySkipList whose elements are the elements of the 
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   745
	receiver. The sort order is the default less than or equal."
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   746
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   747
	^ self as: IdentitySkipList
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   748
! !
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   749
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   750
!Collection methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   751
4365
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   752
asList
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   753
    "return a new List with the receiver collection's elements"
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   754
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   755
    ^ self addAllTo:(List new:self size)
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   756
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   757
    "Created: 14.2.1997 / 16:25:23 / cg"
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   758
! !
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   759
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   760
!Collection methodsFor:'converting'!
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   761
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   762
asRunArray
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   763
    "return a new RunArray with the collection's elements"
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   764
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   765
    ^ RunArray from:self.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   766
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   767
"/    |runs lastElement occurrences|
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   768
"/
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   769
"/    runs := RunArray new.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   770
"/    occurrences := 0.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   771
"/    self do:[:each |
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   772
"/        each == lastElement ifTrue:[
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   773
"/            occurrences := occurrences + 1
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   774
"/        ] ifFalse:[
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   775
"/            runs add:lastElement withOccurrences:occurrences.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   776
"/            occurrences := 1.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   777
"/            lastElement := each
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   778
"/        ].
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   779
"/    ].
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   780
"/    occurrences ~~ 0 ifTrue:[
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   781
"/        runs add:lastElement withOccurrences:occurrences
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   782
"/    ].
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   783
"/    ^ runs
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   784
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   785
    "
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   786
     #(1 2 3 3 3 4 4 4 4 5 6 7) asRunArray 
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   787
    "
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   788
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   789
    "Modified: / 7.4.1998 / 09:50:54 / cg"
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   790
! !
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   791
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   792
!Collection methodsFor:'converting'!
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   793
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   794
asSharedCollection
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   795
    "return a shared collection on the receiver.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   796
     This implements synchronized (i.e. mutually excluded) access to me.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   797
     Use this for safe access when multiple processes access me concurrently.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   798
     Notice that this is a general (possibly suboptimal) mechanism, which should
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   799
     work with all collections. Look for specialized collections (SharedQueue), which are
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   800
     tuned for this kind of operation."
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   801
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   802
    ^ SharedCollection for:self.
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   803
! !
c166b1f7825c Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents: 4202
diff changeset
   804
4400
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   805
!Collection methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   806
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   807
asSkipList
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   808
	"Answer a SkipList whose elements are the elements of the 
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   809
	receiver. The sort order is the default less than or equal."
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   810
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   811
	^ self as: SkipList
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   812
! !
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   813
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   814
!Collection methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   815
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   816
asSkipList: aSortBlock 
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   817
        "Answer a SkipList whose elements are the elements of the 
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   818
        receiver. The sort order is defined by the argument, aSortBlock."
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   819
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   820
        | skipList |
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   821
        skipList := SkipList new: self size sortBlock: aSortBlock.
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   822
        skipList addAll: self.
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   823
        ^ skipList
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   824
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   825
    "Modified (comment): / 18-06-2017 / 22:40:10 / cg"
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   826
! !
Claus Gittinger <cg@exept.de>
parents: 4383
diff changeset
   827
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   828
!Float methodsFor:'private'!
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   829
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   830
absDecimalPrintOn:aStream digits:digits
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   831
    "Place a string representation of the receiver's abs value
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   832
     on <aStream> using <digits> significant digits, using decimal notation.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   833
     This is a helper for printf."
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   834
4429
7d3e464fb430 class: PrintfScanf class
Claus Gittinger <cg@exept.de>
parents: 4418
diff changeset
   835
    <resource: #obsolete>
7d3e464fb430 class: PrintfScanf class
Claus Gittinger <cg@exept.de>
parents: 4418
diff changeset
   836
    PrintfScanf absDecimalPrintFloat:self on:aStream digits:digits.
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   837
4429
7d3e464fb430 class: PrintfScanf class
Claus Gittinger <cg@exept.de>
parents: 4418
diff changeset
   838
    "Modified: / 20-06-2017 / 11:49:15 / cg"
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   839
! !
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   840
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   841
!Float methodsFor:'private'!
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   842
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   843
absPrintOn:aStream digits:digits
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   844
    "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
   845
     <digits> significant digits.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   846
     This is a helper for printf."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   847
4429
7d3e464fb430 class: PrintfScanf class
Claus Gittinger <cg@exept.de>
parents: 4418
diff changeset
   848
    <resource: #obsolete>
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   849
    PrintfScanf absPrintFloat:self on:aStream digits:digits
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   850
4429
7d3e464fb430 class: PrintfScanf class
Claus Gittinger <cg@exept.de>
parents: 4418
diff changeset
   851
    "Modified: / 20-06-2017 / 11:49:11 / cg"
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   852
! !
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   853
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   854
!Float methodsFor:'private'!
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   855
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   856
absScientificPrintOn:aStream digits:digits
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   857
    "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
   858
     digits, using scientific notation.
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   859
     This is a helper for printf."
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   860
4429
7d3e464fb430 class: PrintfScanf class
Claus Gittinger <cg@exept.de>
parents: 4418
diff changeset
   861
    <resource: #obsolete>
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   862
    PrintfScanf absScientificPrintFloat:self on:aStream digits:digits.
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   863
4418
05f82ac9d198 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
   864
    "Modified: / 19-06-2017 / 14:59:56 / cg"
4429
7d3e464fb430 class: PrintfScanf class
Claus Gittinger <cg@exept.de>
parents: 4418
diff changeset
   865
    "Modified (format): / 20-06-2017 / 11:49:07 / cg"
2237
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   866
! !
3b041af2bf04 printf / scanf added
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   867
4381
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   868
!Float methodsFor:'coercing & converting'!
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   869
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   870
asQDouble
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   871
    "return a QDouble with my value"
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   872
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   873
    ^ QDouble fromFloat:self
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   874
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   875
    "
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   876
     1.0 asQDouble
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   877
    "
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   878
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   879
    "Created: / 13-06-2017 / 16:48:57 / cg"
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   880
! !
Claus Gittinger <cg@exept.de>
parents: 4379
diff changeset
   881
4383
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   882
!Integer methodsFor:'coercing & converting'!
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   883
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   884
asQDouble
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   885
    "return a QDouble with same value as myself."
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   886
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   887
    ^ QDouble fromInteger:self
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   888
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   889
    "
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   890
     1234567890 asQDouble
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   891
     1234567890 asQDouble asInteger
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   892
     12345678901234567890 asQDouble
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   893
     12345678901234567890 asQDouble asInteger
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   894
    "
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   895
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   896
    "Created: / 12-06-2017 / 18:41:07 / cg"
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   897
    "Modified (comment): / 12-06-2017 / 20:55:24 / cg"
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   898
! !
Claus Gittinger <cg@exept.de>
parents: 4381
diff changeset
   899
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   900
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   901
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   902
addInterest:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   903
    "install an interest forwarder.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   904
     Here, we use the nonWeakDependencies."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   905
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   906
    self addNonWeakDependent:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   907
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   908
    "Created: 14.10.1996 / 22:27:34 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   909
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   910
3896
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   911
!Object methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   912
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   913
asDoubleLink
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   914
    "return a valueDoubleLink for the receiver.
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   915
     Used to make sure the receiver can be added to a double linked list"
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   916
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   917
    ^ ValueDoubleLink value:self
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   918
! !
Claus Gittinger <cg@exept.de>
parents: 3856
diff changeset
   919
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   920
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   921
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   922
expressInterestIn:aspect for:anObject sendBack:aSelector
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   923
    "arrange for aSelector to be sent to anObject whenever the receiver
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   924
     changes aspect."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   925
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   926
    "/ for now, use an interestConverter, which is somewhat less efficient.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   927
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   928
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   929
    self addInterest:(InterestConverter
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   930
			    destination:anObject
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   931
			    selector:aSelector
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
   932
			    aspect:aspect)
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   933
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   934
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   935
     |p b|
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
     b := [Transcript showCR:' -> the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   938
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   939
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   940
     Transcript showCR:'interest in #foo:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   941
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   942
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   943
     Transcript showCR:'now changing #bar ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   944
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   945
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   946
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   947
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   948
     Transcript showCR:'now changing #foo ... (expect notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   949
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   950
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   951
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   952
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   953
     Transcript showCR:'no more interest in #foo:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   954
     p retractInterestIn:#foo for:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   955
     Transcript showCR:'now changing #foo ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   956
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   957
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   958
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   959
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   960
     Transcript showCR:'interest in #bar now:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   961
     p expressInterestIn:#bar for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   962
     Transcript showCR:'now changing #foo ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   963
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   964
     Transcript showCR:'now changing #bar ... (expect notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   965
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   966
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   967
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   968
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   969
     Transcript showCR:'interest in #foo now:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   970
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   971
     Transcript showCR:'now changing #foo ... (expect notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   972
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   973
     Transcript showCR:'now changing #bar ... (expect notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   974
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   975
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   976
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   977
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   978
     Transcript showCR:'no more interests:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   979
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   980
     Transcript showCR:'now changing #foo ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   981
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   982
     Transcript showCR:'now changing #bar...  (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   983
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   984
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   985
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   986
     p release.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   987
    "
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
   988
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   989
    "Created: 19.4.1996 / 10:26:22 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   990
    "Modified: 19.4.1996 / 12:34:08 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   991
    "Modified: 14.10.1996 / 22:28:20 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   992
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   993
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   994
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   995
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   996
interests
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   997
    "return a Collection of interests - empty if there is none.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   998
     Here, we use the nonWeakDependents for interests."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   999
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1000
    ^ self nonWeakDependents
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1001
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1002
    "Created: / 14.10.1996 / 22:20:51 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1003
    "Modified: / 30.1.1998 / 14:07:35 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1004
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1005
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1006
!Object methodsFor:'dependents-interests'!
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
interestsFor:someOne
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1009
    "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
  1010
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1011
    |coll deps|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1012
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1013
    deps := self interests.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1014
    deps size == 0 ifTrue:[^ #()].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1015
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1016
    coll := IdentitySet new.
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
    deps do:[:dep |
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1019
	(dep isInterestConverter) ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1020
	    dep destination == someOne ifTrue:[
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1021
		coll add:dep.
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1022
	    ]
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1023
	]
1759
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
    ^ coll
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1026
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1027
    "Created: / 30.1.1998 / 14:02:26 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1028
    "Modified: / 30.1.1998 / 14:08:24 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1029
! !
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1030
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1031
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1032
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1033
onChangeEvaluate:aBlock
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1034
    "arrange for aBlock to be evaluated whenever the receiver changes."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1035
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
  1036
    |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
  1037
3559
fa3443d808a1 Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents: 3538
diff changeset
  1038
    na := aBlock argumentCount.
2149
329461c02e84 allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
  1039
    na == 0 ifTrue:[
3559
fa3443d808a1 Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents: 3538
diff changeset
  1040
        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
  1041
    ] ifFalse:[
3559
fa3443d808a1 Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents: 3538
diff changeset
  1042
        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
  1043
    ].
329461c02e84 allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
  1044
    ^ self onChangeSend:selector to:aBlock
1759
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
     Transcript showCR:'interest in #foo:'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1053
     p onChangeEvaluate:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1054
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1055
     Transcript showCR:'now changing #bar ... (expect no notification)'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1056
     p changed:#bar.
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
     p retractInterests.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1059
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1060
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1061
! !
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
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1064
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1065
onChangeSend:aSelector to:anObject
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1066
    "arrange for aSelector to be sent to anObject whenever the receiver
4030
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
  1067
     changes.
fd37ac079cf0 class: GDBApplication
Claus Gittinger <cg@exept.de>
parents: 3896
diff changeset
  1068
     Use retractInterestsFor: in case you are no longer interested"
1759
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
    "/ for now, use an interestConverter, which is somewhat less efficient.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1071
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1072
4773
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1073
    (self interests contains:[:anInterest |
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1074
            anInterest isInterestConverter
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1075
                and:[anInterest destination == anObject
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1076
                and:[anInterest selector == aSelector]]
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1077
            ]
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1078
    ) ifFalse:[
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1079
        self addInterest:(InterestConverter
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1080
                              destination:anObject
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1081
                              selector:aSelector)
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1082
    ].
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1083
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1084
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1085
    "
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1086
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1087
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1088
     b := [Transcript showCR:'the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1089
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1090
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1091
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1092
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1093
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1094
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1095
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1096
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1097
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1098
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1099
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1100
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1101
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1102
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1103
     Transcript showCR:'no more interest'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1104
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1105
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1106
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1107
     Transcript cr.
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
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1110
     Transcript showCR:'interest again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1111
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1112
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1113
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1114
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1115
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1116
4773
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1117
    "Created: / 19-04-1996 / 10:26:38 / cg"
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1118
    "Modified: / 19-04-1996 / 12:34:26 / cg"
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1119
    "Modified: / 14-10-1996 / 22:28:27 / stefan"
9a9b8a439b6d class Object
Stefan Vogel <sv@exept.de>
parents: 4714
diff changeset
  1120
    "Modified: / 30-11-2018 / 18:01:47 / Stefan Vogel"
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1121
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1122
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1123
!Object methodsFor:'dependents-st/v event simulation'!
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1124
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1125
removeActionsForEvent:eventSymbol
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1126
    "remove ST/V-style event triggers."
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1127
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1128
    self retractInterestsIn:eventSymbol
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1129
! !
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1130
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1131
!Object methodsFor:'dependents-st/v event simulation'!
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1132
2903
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  1133
removeActionsWithReceiver:aReceiver
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  1134
    "remove ST/V-style event triggers."
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  1135
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  1136
    self retractInterestsFor:aReceiver
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  1137
! !
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  1138
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  1139
!Object methodsFor:'dependents-st/v event simulation'!
80af520506e8 class: SSL::SSLTests
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  1140
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1141
removeAllActionsWithReceiver:anObject
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1142
    "remove ST/V-style event triggers."
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1143
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1144
    self retractInterestsFor:anObject
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1145
! !
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1146
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1147
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1148
4969
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1149
removeDependentAndRetractInterestsFor:someOne
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1150
    "remove any dependency and interest of someOne in the receiver.
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1151
     Answer the receiver"
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1152
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1153
    self retractInterestsFor:someOne.
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1154
    self removeDependent:someOne.
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1155
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1156
    "Created: / 30-05-2019 / 11:11:19 / Claus Gittinger"
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1157
! !
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1158
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1159
!Object methodsFor:'dependents-interests'!
9acd20c528a3 combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents: 4866
diff changeset
  1160
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1161
removeInterest:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1162
    "remove an interest forwarder.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1163
     Here, we use the nonWeakDependencies."
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1164
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1165
    self removeNonWeakDependent:anInterest
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1166
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1167
    "Created: 14.10.1996 / 22:21:59 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1168
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1169
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1170
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1171
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1172
retractInterestIn:aspect for:someOne
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1173
    "remove the interest of someOne in the receiver changing aspect
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1174
     (as installed with #expressInterestIn:for:sendBack:).
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1175
     Answer the retracted interests."
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1176
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1177
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1178
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1179
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1180
    ^ self retractInterestsForWhich:[:i | 
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1181
            (i aspect == aspect) and:[i destination == someOne]
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1182
        ]
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1183
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1184
    "
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1185
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1186
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1187
     b := [Transcript showCR:'the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1188
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1189
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1190
     Transcript showCR:'interest in #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1191
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1192
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1193
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1194
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1195
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1196
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1197
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1198
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1199
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1200
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1201
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1202
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1203
     Transcript showCR:'no more interest in #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1204
     p retractInterestIn:#foo for:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1205
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1206
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1207
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1208
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1209
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1210
     Transcript showCR:'interest in #bar now'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1211
     p expressInterestIn:#bar for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1212
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1213
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1214
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1215
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1216
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1217
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1218
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1219
     Transcript showCR:'interest in #foo now'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1220
     p expressInterestIn:#foo for:b sendBack:#value.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1221
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1222
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1223
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1224
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1225
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1226
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1227
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1228
     Transcript showCR:'no more interests'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1229
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1230
     Transcript showCR:'now changing #foo'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1231
     p changed:#foo.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1232
     Transcript showCR:'now changing #bar'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1233
     p changed:#bar.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1234
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1235
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1236
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1237
    "Created: / 19.4.1996 / 10:27:11 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1238
    "Modified: / 14.10.1996 / 22:21:19 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1239
    "Modified: / 30.1.1998 / 14:05:34 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1240
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1241
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1242
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1243
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1244
retractInterests
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1245
    "remove all interests in the receiver changing aspect
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1246
     (as installed with #expressInterestIn:for:sendBack:).
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1247
     Answer the retraced interests."
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1248
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1249
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1250
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1251
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1252
    ^ self retractInterestsForWhich:[:i | true ]
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1253
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1254
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1255
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1256
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1257
retractInterestsFor:someOne
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1258
    "remove the interest of someOne in the receiver
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1259
     (as installed with #onChangeSend:to:).
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1260
     Answer the retracted interests."
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1261
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1262
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1263
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1264
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1265
    ^ self retractInterestsForWhich:[:i | i destination == someOne ]
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1266
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1267
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1268
     |p b|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1269
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1270
     b := [Transcript showCR:'the point changed'].
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1271
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1272
     p := Point new.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1273
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1274
     p x:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1275
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1276
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1277
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1278
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1279
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1280
     Transcript showCR:'now changing'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1281
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1282
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1283
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1284
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1285
     Transcript showCR:'no more interest'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1286
     p retractInterestsFor:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1287
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1288
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1289
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1290
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1291
     Delay waitForSeconds:1.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1292
     Transcript showCR:'interest again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1293
     p onChangeSend:#value to:b.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1294
     Transcript showCR:'now changing again'.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1295
     p changed.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1296
     Transcript cr.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1297
    "
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1298
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1299
    "Created: / 19.4.1996 / 10:23:46 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1300
    "Modified: / 14.10.1996 / 22:21:25 / stefan"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1301
    "Modified: / 30.1.1998 / 14:04:52 / cg"
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1302
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1303
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1304
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1305
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1306
retractInterestsForWhich:aBlock
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1307
    "remove all interests in the receiver changing aspect
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1308
     (as installed with #expressInterestIn:for:sendBack:).
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1309
     Answer the retracted interests."
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1310
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1311
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1312
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1313
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1314
    |deps coll|
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1315
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1316
    deps := self interests.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1317
    deps size ~~ 0 ifTrue:[
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1318
        "/ cannot removeDependent within the loop - the interests collection rehashes
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1319
        coll := IdentitySet new.
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1320
        deps do:[:dep |
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1321
            dep isInterestConverter ifTrue:[
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1322
                (aBlock value:dep) ifTrue:[coll add:dep].
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1323
            ]
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1324
        ].
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1325
        coll do:[:dep |
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1326
            self removeInterest:dep.
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1327
        ].
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1328
        ^ coll.
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1329
    ].
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1330
    ^ #()
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1331
! !
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1332
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1333
!Object methodsFor:'dependents-interests'!
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1334
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1335
retractInterestsIn:aspect
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1336
    "remove all interests in the receiver changing aspect
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1337
     (as installed with #expressInterestIn:for:sendBack:).
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1338
     Answer the retracted interests."
1759
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1339
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1340
    "/ for now, remove the interestConverter.
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1341
    "/ In the future, a more intelligent DependencyCollection class is planned for
78e481899a63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
  1342
4202
88ea818849fa change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents: 4190
diff changeset
  1343
    ^ self retractInterestsForWhich:[:i | i aspect == aspect ]
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1344
! !
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1345
2901
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1346
!Object methodsFor:'Compatibility-Dolphin'!
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1347
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1348
trigger:anAspect
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1349
    self changed:anAspect
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1350
! !
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1351
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1352
!Object methodsFor:'Compatibility-Dolphin'!
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1353
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1354
trigger:anAspect with:anArgument
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1355
    self changed:anAspect with:anArgument
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1356
! !
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1357
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1358
!Object methodsFor:'dependents-st/v event simulation'!
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1359
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1360
triggerEvent:aSymbol
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1361
    self changed:aSymbol
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1362
! !
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1363
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1364
!Object methodsFor:'dependents-st/v event simulation'!
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1365
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1366
triggerEvent:eventSymbol with:aParameter
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1367
    "perform ST/V-style event triggering."
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1368
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1369
    self changed:eventSymbol with:(Array with:aParameter).
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1370
! !
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1371
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1372
!Object methodsFor:'dependents-st/v event simulation'!
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1373
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1374
triggerEvent:eventSymbol withArguments:parameters
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1375
    "perform ST/V-style event triggering."
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1376
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1377
    self changed:eventSymbol with:parameters.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1378
! !
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1379
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1380
!Object methodsFor:'dependents-st/v event simulation'!
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1381
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1382
when:eventSymbol send:selector to:anObject
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1383
    "install an ST/V-style interest forwarder.
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1384
     Here, we use the nonWeakDependencies."
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1385
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1386
    self addInterest:(InterestConverterWithParameters
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1387
                            destination:anObject
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1388
                            selector:selector
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1389
                            aspect:eventSymbol).
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1390
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1391
    "
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1392
     |p b|
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1393
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1394
     b := [Transcript showCR:'the point changed'].
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1395
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1396
     p := Point new.
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1397
     p when:#foo:bar: send:#value:value: to:[:a :b | Transcript show:'foo: '; show:a; show:' bar: '; showCR:b].
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1398
     Transcript showCR:'now changing'.
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1399
     p triggerEvent:#foo:bar: withArguments:#('fooArg' 'barArg').
2897
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1400
     p removeActionsForEvent:#foo:bar:.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1401
    "
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1402
! !
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1403
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1404
!Object methodsFor:'dependents-st/v event simulation'!
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1405
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1406
when:eventSymbol send:selector to:anObject with:aParameter
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1407
    "install an ST/V-style interest forwarder.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1408
     Here, we use the nonWeakDependencies."
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1409
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1410
    self addInterest:((InterestConverterWithParameters
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1411
                            destination:anObject
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1412
                            selector:selector
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1413
                            aspect:eventSymbol) 
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1414
                        defaultParameters:(Array with:aParameter)).
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1415
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1416
    "
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1417
     |p b|
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1418
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1419
     b := [Transcript showCR:'the point changed'].
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1420
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1421
     p := Point new.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1422
     p 
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1423
        when:#foo: 
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1424
        send:#value: 
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1425
        to:[:a | Transcript show:'foo: '; showCR:a]
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1426
        with:123.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1427
     Transcript showCR:'now changing'.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1428
     p triggerEvent:#foo:.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1429
     p triggerEvent:#foo: with:987.
3060cf059978 more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
  1430
     p removeActionsForEvent:#foo:.
1668
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1431
    "
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1432
! !
96c1701345c5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1667
diff changeset
  1433
2901
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1434
!Object methodsFor:'Compatibility-Dolphin'!
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1435
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1436
when:anAspect sendTo:anObject
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1437
    self expressInterestIn:anAspect for:anObject sendBack:anAspect
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1438
! !
31bfe7c3474d move methods to extensions
Claus Gittinger <cg@exept.de>
parents: 2897
diff changeset
  1439
2364
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1440
!Stream methodsFor:'stacked computing streams'!
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1441
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1442
collecting:aBlock
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1443
    "return a stacked computing stream, which reads elements from the receiver,
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1444
     applies aBlock to each read element, and provides the results as elements to its reader."
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1445
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1446
    ^ CollectingReadStream on:self collecting:aBlock
3094
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1447
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1448
    "
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1449
     |s s2|
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1450
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1451
     s := 'hello world' readStream.
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1452
     s2 := s collecting:[:ch | ch asUppercase].
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1453
     s2 upToEnd.   
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1454
    "
2364
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1455
! !
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1456
4620
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1457
!Stream methodsFor:'writing'!
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1458
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1459
printf:format
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1460
    "C-style printing into a stream.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1461
     For smalltalk specific formats, 
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1462
     see documentation in PrintfScanf >> format_printf"
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1463
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1464
    format printf:#() on:self.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1465
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1466
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1467
     Transcript printf:'Hello World\n'
4866
c938d3377688 class: Stream
Claus Gittinger <cg@exept.de>
parents: 4797
diff changeset
  1468
     Transcript printf:'Hello World %d\n' with:123
4620
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1469
    "
4866
c938d3377688 class: Stream
Claus Gittinger <cg@exept.de>
parents: 4797
diff changeset
  1470
c938d3377688 class: Stream
Claus Gittinger <cg@exept.de>
parents: 4797
diff changeset
  1471
    "Modified (comment): / 17-03-2019 / 15:05:29 / Claus Gittinger"
4620
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1472
! !
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1473
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1474
!Stream methodsFor:'writing'!
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1475
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1476
printf:format arguments:arguments
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1477
    "C-style printing into a stream.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1478
     Same as printf:withAll:, for protocol completeness.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1479
     For smalltalk specific formats, 
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1480
     see documentation in PrintfScanf >> format_printf"
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1481
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1482
    format printf:arguments on:self.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1483
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1484
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1485
     Transcript printf:'%05x %d %f %o\n' withAll:{ 123. 234*5. 1.234. 8r377 }
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1486
     Transcript printf:'%03d %03d %03d\n' withAll:{ 1. 2. 3 }
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1487
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1488
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1489
    "Created: / 23-02-2017 / 16:43:39 / cg"
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1490
! !
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1491
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1492
!Stream methodsFor:'writing'!
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1493
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1494
printf:format with:argument
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1495
    "C-style printing into a stream.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1496
     For smalltalk specific formats, 
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1497
     see documentation in PrintfScanf >> format_printf"
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1498
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1499
    format printf:{argument} on:self.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1500
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1501
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1502
     Transcript printf:'%05x\n' with:12345
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1503
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1504
! !
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1505
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1506
!Stream methodsFor:'writing'!
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1507
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1508
printf:format with:argument1 with:argument2
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1509
    "C-style printing into a stream.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1510
     For smalltalk specific formats, 
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1511
     see documentation in PrintfScanf >> format_printf"
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1512
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1513
    format printf:{argument1 . argument2} on:self.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1514
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1515
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1516
     Transcript printf:'%05x %3s\n' with:12345 with:'abc'
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1517
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1518
! !
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1519
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1520
!Stream methodsFor:'writing'!
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1521
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1522
printf:format with:argument1 with:argument2 with:argument3
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1523
    "C-style printing into a stream.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1524
     For smalltalk specific formats, 
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1525
     see documentation in PrintfScanf >> format_printf"
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1526
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1527
    format printf:{argument1 . argument2 . argument3} on:self.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1528
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1529
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1530
     Transcript printf:'%05x %3s %09s\n' with:12345 with:'abc' with:'abc'
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1531
     Transcript printf:'%05x %3s %9s\n' with:12345 with:'abc' with:'abc'
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1532
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1533
! !
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1534
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1535
!Stream methodsFor:'writing'!
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1536
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1537
printf:format with:argument1 with:argument2 with:argument3 with:argument4
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1538
    "C-style printing into a stream.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1539
     For smalltalk specific formats, 
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1540
     see documentation in PrintfScanf >> format_printf"
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1541
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1542
    format printf:{argument1 . argument2 . argument3 . argument4} on:self.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1543
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1544
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1545
     Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1546
     Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1547
     Transcript printf:'%-2x %-2x %-2x %-2x\n' with:1 with:2 with:3 with:4
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1548
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1549
! !
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1550
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1551
!Stream methodsFor:'writing'!
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1552
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1553
printf:format with:argument1 with:argument2 with:argument3 with:argument4 with:argument5
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1554
    "C-style printing into a stream.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1555
     For smalltalk specific formats, 
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1556
     see documentation in PrintfScanf >> format_printf"
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1557
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1558
    format printf:{argument1 . argument2 . argument3 . argument4 . argument5} on:self.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1559
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1560
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1561
     Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1562
     Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1563
     Transcript printf:'%-2x %-2x %-2x %-2x\n' with:1 with:2 with:3 with:4
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1564
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1565
! !
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1566
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1567
!Stream methodsFor:'writing'!
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1568
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1569
printf:format withAll:arguments
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1570
    "C-style printing into a stream.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1571
     For smalltalk specific formats, 
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1572
     see documentation in PrintfScanf >> format_printf"
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1573
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1574
    format printf:arguments on:self.
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1575
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1576
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1577
     Transcript printf:'%05x %d %f %o\n' withAll:{ 123. 234*5. 1.234. 8r377 }
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1578
     Transcript printf:'%03d %03d %03d\n' withAll:{ 1. 2. 3 }
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1579
    "
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1580
! !
df4699518c1b class: Stream
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
  1581
2364
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1582
!Stream methodsFor:'stacked computing streams'!
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1583
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1584
selecting:aBlock
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1585
    "return a stacked computing stream, which reads elements from the receiver,
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1586
     but only provides elements for which aBlock returns true to its reader."
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1587
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1588
    ^ SelectingReadStream on:self selecting:aBlock
3094
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1589
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1590
    "
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1591
     |s s2|
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1592
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1593
     s := 'hello world' readStream.
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1594
     s2 := s selecting:[:ch | ch isVowel].
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1595
     s2 upToEnd.
4b7e65efd84f class: Stream
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1596
    "
2364
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1597
! !
2b7b611e565c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2337
diff changeset
  1598
2303
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1599
!stx_libbasic2 class methodsFor:'documentation'!
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1600
74c77b8cf160 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2295
diff changeset
  1601
extensionsVersion_CVS
3715
59267baeb546 class: CharacterArray
Claus Gittinger <cg@exept.de>
parents: 3559
diff changeset
  1602
    ^ '$Header$'
3005
36ada1348967 asciiValue->codePoint
Claus Gittinger <cg@exept.de>
parents: 2903
diff changeset
  1603
! !
3006
1847bcaf8018 Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3005
diff changeset
  1604