[squeak-dev] The Inbox: Collections-mtf.420.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Jan 6 19:15:36 UTC 2011


Matthew Fulmer uploaded a new version of Collections to project The Inbox:
http://source.squeak.org/inbox/Collections-mtf.420.mcz

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

Name: Collections-mtf.420
Author: mtf
Time: 6 January 2011, 2:14:56.298 pm
UUID: adc5fe75-18ce-4e64-976a-54f588e2f8af
Ancestors: Collections-mtf.419

support methods with positional arguments. Needed by OpenGL in Croquet

=============== Diff against Collections-mtf.419 ===============

Item was changed:
  ----- Method: String>>numArgs (in category 'system primitives') -----
+ numArgs
- numArgs 
  	"Answer either the number of arguments that the receiver would take if considered a selector.  Answer -1 if it couldn't be a selector.  Note that currently this will answer -1 for anything begining with an uppercase letter even though the system will accept such symbols as selectors.  It is intended mostly for the assistance of spelling correction."
  
  	| firstChar numColons excess start ix |
  	self size = 0 ifTrue: [^ -1].
  	firstChar := self at: 1.
  	(firstChar isLetter or: [firstChar = $:]) ifTrue:
+ 		[(ix := self findString: '()/') > 0 ifTrue: [
+ 			"positional keyword selector"
+ 			(self copyFrom: 1 to: ix-1) numArgs = 0 ifFalse: [^ -1]. "fast check that the name portion of the selector is valid"
+ 			^ Number readFrom: (self copyFrom: ix+3 to: self size) ifFail: [-1]].
+ 		
+ 		"Fast reject if any chars are non-alphanumeric
- 		["Fast reject if any chars are non-alphanumeric
  		NOTE: fast only for Byte things - Broken for Wide"
  		self class isBytes
  			ifTrue: [(self findSubstring: '~' in: self startingAt: 1 matchTable: Tokenish) > 0 ifTrue: [^ -1]]
  			ifFalse: [2 to: self size do: [:i | (self at: i) tokenish ifFalse: [^ -1]]].
  		"Fast colon count"
  		numColons := 0.  start := 1.
  		[(ix := self indexOf: $: startingAt: start) > 0]
  			whileTrue:
  				[numColons := numColons + 1.
  				start := ix + 1].
  		numColons = 0 ifTrue: [^ 0].
  		firstChar = $:
  			ifTrue: [excess := 2 "Has an initial keyword, as #:if:then:else:"]
  			ifFalse: [excess := 0].
  		self last = $:
  			ifTrue: [^ numColons - excess]
  			ifFalse: [^ numColons - excess - 1 "Has a final keywords as #nextPut::andCR"]].
  	firstChar isSpecial ifTrue:
  		[self size = 1 ifTrue: [^ 1].
  		2 to: self size do: [:i | (self at: i) isSpecial ifFalse: [^ -1]].
  		^ 1].
+ 	^ -1.
+ !
- 	^ -1.!




More information about the Squeak-dev mailing list