The Trunk: Tools-eem.626.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Tools-eem.626.mcz

commits-2
Eliot Miranda uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-eem.626.mcz

==================== Summary ====================

Name: Tools-eem.626
Author: eem
Time: 30 June 2015, 3:05:48.319 pm
UUID: 0bfae54b-3e68-4252-98d8-ddb1e56fc869
Ancestors: Tools-mt.625

Upgrade MessageSet class>>parse:toClassAndSelector:
to allow one to construct text links in modern syntax, e.g.
BitBlt class>>#subPixelRenderColorFonts

=============== Diff against Tools-mt.625 ===============

Item was changed:
  ----- Method: MessageSet class>>parse:toClassAndSelector: (in category 'utilities') -----
  parse: methodRef toClassAndSelector: csBlock
  "Decode strings of the form <className> [class] <selectorName>."
 
  | tuple cl |
 
 
  self flag: #mref. "compatibility with pre-MethodReference lists"
 
  methodRef ifNil: [^ csBlock value: nil value: nil].
  methodRef isString ifFalse:
  [^methodRef setClassAndSelectorIn: csBlock].
  methodRef isEmpty ifTrue:
  [^csBlock value: nil value: nil].
+ tuple := (methodRef asString includesSubString: '>>')
+ ifTrue: [(methodRef findTokens: '>>') fold: [:a :b| (a findTokens: ' '), {b first = $# ifTrue: [b allButFirst] ifFalse: [b]}]]
+ ifFalse: [methodRef asString findTokens: ' .'].
- tuple := methodRef asString findTokens: ' .'.
  cl := Smalltalk at: tuple first asSymbol ifAbsent: [^ csBlock value: nil value: nil].
  ^(tuple size = 2 or: [tuple size > 2 and: [(tuple at: 2) ~= 'class']])
  ifTrue: [csBlock value: cl value: (tuple at: 2) asSymbol]
  ifFalse: [csBlock value: cl class value: (tuple at: 3) asSymbol]!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Tools-eem.626.mcz

Levente Uzonyi-2
Hi Eliot,

I think an #asString send is missing from the line

                              ifTrue: [(methodRef findTokens: '>>') fold: [:a :b| (a findTokens: ' '), {b first = $# ifTrue: [b allButFirst] ifFalse: [b]}]]

It should be

                              ifTrue: [(methodRef asString findTokens: '>>') fold: [:a :b| (a findTokens: ' '), {b first = $# ifTrue: [b allButFirst] ifFalse: [b]}]]

It would be even better to store "methodRef asString" in a temporary
variable.
But taking a closer look at the code the #asString sends are unnecessary,
because we already know that methodRef #isString is true. And there's no
point in converting Symbols to Strings for #includesSubString:
or #findTokens:.

Levente

On Tue, 30 Jun 2015, [hidden email] wrote:

> Eliot Miranda uploaded a new version of Tools to project The Trunk:
> http://source.squeak.org/trunk/Tools-eem.626.mcz
>
> ==================== Summary ====================
>
> Name: Tools-eem.626
> Author: eem
> Time: 30 June 2015, 3:05:48.319 pm
> UUID: 0bfae54b-3e68-4252-98d8-ddb1e56fc869
> Ancestors: Tools-mt.625
>
> Upgrade MessageSet class>>parse:toClassAndSelector:
> to allow one to construct text links in modern syntax, e.g.
> BitBlt class>>#subPixelRenderColorFonts
>
> =============== Diff against Tools-mt.625 ===============
>
> Item was changed:
>  ----- Method: MessageSet class>>parse:toClassAndSelector: (in category 'utilities') -----
>  parse: methodRef toClassAndSelector: csBlock
>   "Decode strings of the form <className> [class] <selectorName>."
>
>   | tuple cl |
>
>
>   self flag: #mref. "compatibility with pre-MethodReference lists"
>
>   methodRef ifNil: [^ csBlock value: nil value: nil].
>   methodRef isString ifFalse:
>   [^methodRef setClassAndSelectorIn: csBlock].
>   methodRef isEmpty ifTrue:
>   [^csBlock value: nil value: nil].
> + tuple := (methodRef asString includesSubString: '>>')
> + ifTrue: [(methodRef findTokens: '>>') fold: [:a :b| (a findTokens: ' '), {b first = $# ifTrue: [b allButFirst] ifFalse: [b]}]]
> + ifFalse: [methodRef asString findTokens: ' .'].
> - tuple := methodRef asString findTokens: ' .'.
>   cl := Smalltalk at: tuple first asSymbol ifAbsent: [^ csBlock value: nil value: nil].
>   ^(tuple size = 2 or: [tuple size > 2 and: [(tuple at: 2) ~= 'class']])
>   ifTrue: [csBlock value: cl value: (tuple at: 2) asSymbol]
>   ifFalse: [csBlock value: cl class value: (tuple at: 3) asSymbol]!
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Tools-eem.626.mcz

Eliot Miranda-2
Hi Levente,

You're right.  The asString sends here are, I think, to guard against being given a text and Text not being protocol-compatible with String.  That they're not protocol-compatible is a bug, but the system should still work.  I'll take a look.


On Wed, Jul 1, 2015 at 1:48 PM, Levente Uzonyi <[hidden email]> wrote:
Hi Eliot,

I think an #asString send is missing from the line

                             ifTrue: [(methodRef findTokens: '>>') fold: [:a :b| (a findTokens: ' '), {b first = $# ifTrue: [b allButFirst] ifFalse: [b]}]]

It should be

                             ifTrue: [(methodRef asString findTokens: '>>') fold: [:a :b| (a findTokens: ' '), {b first = $# ifTrue: [b allButFirst] ifFalse: [b]}]]

It would be even better to store "methodRef asString" in a temporary variable.
But taking a closer look at the code the #asString sends are unnecessary, because we already know that methodRef #isString is true. And there's no point in converting Symbols to Strings for #includesSubString: or #findTokens:.

Levente


On Tue, 30 Jun 2015, [hidden email] wrote:

Eliot Miranda uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-eem.626.mcz

==================== Summary ====================

Name: Tools-eem.626
Author: eem
Time: 30 June 2015, 3:05:48.319 pm
UUID: 0bfae54b-3e68-4252-98d8-ddb1e56fc869
Ancestors: Tools-mt.625

Upgrade MessageSet class>>parse:toClassAndSelector:
to allow one to construct text links in modern syntax, e.g.
BitBlt class>>#subPixelRenderColorFonts

=============== Diff against Tools-mt.625 ===============

Item was changed:
 ----- Method: MessageSet class>>parse:toClassAndSelector: (in category 'utilities') -----
 parse: methodRef toClassAndSelector: csBlock
        "Decode strings of the form <className> [class] <selectorName>."

        | tuple cl |


        self flag: #mref.       "compatibility with pre-MethodReference lists"

        methodRef ifNil: [^ csBlock value: nil value: nil].
        methodRef isString ifFalse:
                [^methodRef setClassAndSelectorIn: csBlock].
        methodRef isEmpty ifTrue:
                [^csBlock value: nil value: nil].
+       tuple := (methodRef asString includesSubString: '>>')
+                               ifTrue: [(methodRef findTokens: '>>') fold: [:a :b| (a findTokens: ' '), {b first = $# ifTrue: [b allButFirst] ifFalse: [b]}]]
+                               ifFalse: [methodRef asString findTokens: ' .'].
-       tuple := methodRef asString findTokens: ' .'.
        cl := Smalltalk at: tuple first asSymbol ifAbsent: [^ csBlock value: nil value: nil].
        ^(tuple size = 2 or: [tuple size > 2 and: [(tuple at: 2) ~= 'class']])
                ifTrue: [csBlock value: cl value: (tuple at: 2) asSymbol]
                ifFalse: [csBlock value: cl class value: (tuple at: 3) asSymbol]!







--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Tools-eem.626.mcz

Levente Uzonyi-2
Hi Eliot,

Sending #isString to a Text instance will return false, which sounds right
to me. When #asString is sent to methodRef in the code, the receiver is
already a String.

Levente

On Wed, 1 Jul 2015, Eliot Miranda wrote:

> Hi Levente,
> You're right.  The asString sends here are, I think, to guard against being given a text and Text not being protocol-compatible with String.  That they're not protocol-compatible is a bug, but the system should still work.  I'll take a look.
>
>
> On Wed, Jul 1, 2015 at 1:48 PM, Levente Uzonyi <[hidden email]> wrote:
>       Hi Eliot,
>
>       I think an #asString send is missing from the line
>
>                                    ifTrue: [(methodRef findTokens: '>>') fold: [:a :b| (a findTokens: ' '), {b first = $# ifTrue: [b allButFirst] ifFalse: [b]}]]
>
>       It should be
>
>                                    ifTrue: [(methodRef asString findTokens: '>>') fold: [:a :b| (a findTokens: ' '), {b first = $# ifTrue: [b allButFirst] ifFalse: [b]}]]
>
>       It would be even better to store "methodRef asString" in a temporary variable.
>       But taking a closer look at the code the #asString sends are unnecessary, because we already know that methodRef #isString is true. And there's no point in converting Symbols to Strings for #includesSubString: or #findTokens:.
>
>       Levente
>
>       On Tue, 30 Jun 2015, [hidden email] wrote:
>
>             Eliot Miranda uploaded a new version of Tools to project The Trunk:
>             http://source.squeak.org/trunk/Tools-eem.626.mcz
>
>             ==================== Summary ====================
>
>             Name: Tools-eem.626
>             Author: eem
>             Time: 30 June 2015, 3:05:48.319 pm
>             UUID: 0bfae54b-3e68-4252-98d8-ddb1e56fc869
>             Ancestors: Tools-mt.625
>
>             Upgrade MessageSet class>>parse:toClassAndSelector:
>             to allow one to construct text links in modern syntax, e.g.
>             BitBlt class>>#subPixelRenderColorFonts
>
>             =============== Diff against Tools-mt.625 ===============
>
>             Item was changed:
>              ----- Method: MessageSet class>>parse:toClassAndSelector: (in category 'utilities') -----
>              parse: methodRef toClassAndSelector: csBlock
>                     "Decode strings of the form <className> [class] <selectorName>."
>
>                     | tuple cl |
>
>
>                     self flag: #mref.       "compatibility with pre-MethodReference lists"
>
>                     methodRef ifNil: [^ csBlock value: nil value: nil].
>                     methodRef isString ifFalse:
>                             [^methodRef setClassAndSelectorIn: csBlock].
>                     methodRef isEmpty ifTrue:
>                             [^csBlock value: nil value: nil].
>             +       tuple := (methodRef asString includesSubString: '>>')
>             +                               ifTrue: [(methodRef findTokens: '>>') fold: [:a :b| (a findTokens: ' '), {b first = $# ifTrue: [b allButFirst] ifFalse: [b]}]]
>             +                               ifFalse: [methodRef asString findTokens: ' .'].
>             -       tuple := methodRef asString findTokens: ' .'.
>                     cl := Smalltalk at: tuple first asSymbol ifAbsent: [^ csBlock value: nil value: nil].
>                     ^(tuple size = 2 or: [tuple size > 2 and: [(tuple at: 2) ~= 'class']])
>                             ifTrue: [csBlock value: cl value: (tuple at: 2) asSymbol]
>                             ifFalse: [csBlock value: cl class value: (tuple at: 3) asSymbol]!
>
>
>
>
>
>
>
> --
> best,Eliot
>
>