isString -> isStringLike cvs_MAIN
authorClaus Gittinger <cg@exept.de>
Fri, 22 Mar 2019 13:29:20 +0100
branchcvs_MAIN
changeset 3894 fd7498845be2
parent 3893 4369b50445db
child 3895 eb9b49155bf8
isString -> isStringLike
extensions.st
--- a/extensions.st	Wed Mar 13 22:25:18 2019 +0100
+++ b/extensions.st	Fri Mar 22 13:29:20 2019 +0100
@@ -20,8 +20,8 @@
     ^ false
 
     "
-        (Java classForName:'java.lang.Class') isJavaPrimitiveType
-        ByteArray isJavaPrimitiveType
+	(Java classForName:'java.lang.Class') isJavaPrimitiveType
+	ByteArray isJavaPrimitiveType
     "
 
     "Created: / 20-12-2010 / 21:52:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -74,11 +74,11 @@
     | value |
 
     (object class binaryName = 'java/lang/Boolean') ifFalse:[
-        errorBlock value.
+	errorBlock value.
     ].
     value := object instVarNamed: #value.
     (value ~~ 0 and:[value ~~ 1]) ifTrue:[
-        errorBlock value.
+	errorBlock value.
     ].
     ^value
 
@@ -243,11 +243,11 @@
     | value |
 
     (object class binaryName = 'java/lang/Character') ifFalse:[
-        errorBlock value.
+	errorBlock value.
     ].
     value := object instVarNamed: #value.
     (value between: 0 and: 255) ifFalse:[
-        errorBlock value.
+	errorBlock value.
     ].
     ^value
 
@@ -309,15 +309,15 @@
     | nm |
     nm := self asJavaComponentClassName.
     (nm first == $L) ifTrue: [
-        nm := nm copyFrom: 2 to: nm size - 1.
-        (nm includes: $/) ifTrue: [
-            "/ No need to do another copt here!!
-            nm replaceAll: $/ with: $.
-        ].
+	nm := nm copyFrom: 2 to: nm size - 1.
+	(nm includes: $/) ifTrue: [
+	    "/ No need to do another copt here!!
+	    nm replaceAll: $/ with: $.
+	].
     ] ifFalse:[
-        (nm includes: $/) ifTrue: [
-            nm := nm copyReplaceAll: $/ with: $.
-        ].
+	(nm includes: $/) ifTrue: [
+	    nm := nm copyReplaceAll: $/ with: $.
+	].
     ].
     ^ nm.
 
@@ -333,7 +333,7 @@
 
     componentClassName := self "utf8Encoded".
     (componentClassName first == $[) ifTrue: [
-        componentClassName := componentClassName copyFrom: (componentClassName lastIndexOf: $[) + 1
+	componentClassName := componentClassName copyFrom: (componentClassName lastIndexOf: $[) + 1
     ].
     ^ componentClassName.
 
@@ -373,15 +373,15 @@
     | internalName |
     internalName := self asJavaComponentClassName.
     (internalName first == $L) ifTrue: [
-        internalName := internalName copyFrom: 2 to: internalName size - 1.
-        "/ No need to do another copy here
-        (internalName includes: $.) ifTrue: [
-            internalName replaceAll: $. with: $/
-        ].
+	internalName := internalName copyFrom: 2 to: internalName size - 1.
+	"/ No need to do another copy here
+	(internalName includes: $.) ifTrue: [
+	    internalName replaceAll: $. with: $/
+	].
     ] ifFalse:[
-        (internalName includes: $.) ifTrue: [
-            internalName := internalName copyReplaceAll: $. with: $/
-        ].
+	(internalName includes: $.) ifTrue: [
+	    internalName := internalName copyReplaceAll: $. with: $/
+	].
     ].
     ^ internalName.
 
@@ -402,24 +402,6 @@
     ^ (self size = 1 and: [ JavaDescriptor baseTypes includesKey: self first ]).
 ! !
 
-!CharacterArray methodsFor:'special string converting'!
-
-withoutSuffix: aString
-    "if the receiver endsWith aString, return a copy without it.
-     Otherwise return the receiver"
-
-    (self endsWith: aString) ifTrue: [
-        ^ self copyFrom: 1 to: self size - aString size
-    ].
-    ^ self
-
-    "
-     'helloworld' withoutSuffix:'world'
-     'helloworld' withoutSuffix:'foo'"
-
-    "Created: / 08-12-2012 / 20:26:27 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
-! !
-
 !CharacterArray class methodsFor:'encoding & decoding'!
 
 decodeFromJavaUTF8: string8
@@ -429,7 +411,7 @@
 
     | string16 |
 %{
-    if (__isString(string8) ) {
+    if (__isStringLike(string8) ) {
         unsigned char *ptr;
         unsigned short c;
         unsigned short* dst;
@@ -479,12 +461,13 @@
     "Modified: / 09-02-2011 / 01:12:25 / Marcel Hlopko <hlopik@gmail.com>"
     "Modified: / 13-03-2011 / 15:52:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 04-08-2014 / 14:45:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-
+    "Modified: / 22-03-2019 / 03:00:17 / Claus Gittinger"
 ! !
 
 !CharacterArray class methodsFor:'instance creation'!
 
 fromJavaUTF8Bytes:aByteCollection
+    <resource: #obsolete>
     "return a new string which represents the characters as decoded
      from the modified utf8 encoded bytes as specified in
      The class file format specification, section 4.5.7"
@@ -813,7 +796,7 @@
     | value |
 
     (object class binaryName = 'java/lang/Double') ifFalse:[
-        errorBlock value.
+	errorBlock value.
     ].
     value := object instVarNamed: #value.
     ^value
@@ -951,8 +934,8 @@
 javaUnbox: object onError: errorBlock
 
     ^self javaUnbox: object onError: errorBlock
-          min: "Integer.MIN_VALUE"-2147483648
-          max: "Integer.MAX_VALUE" 2147483647
+	  min: "Integer.MIN_VALUE"-2147483648
+	  max: "Integer.MAX_VALUE" 2147483647
 
     "Created: / 25-11-2011 / 19:10:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
@@ -964,15 +947,15 @@
     | value |
 
     (#(  'java/lang/Byte'
-        'java/lang/Short'
-        'java/lang/Integer'
-        "'java/lang/Long'" ) includes: object class binaryName) ifFalse:[
-        errorBlock value.
+	'java/lang/Short'
+	'java/lang/Integer'
+	"'java/lang/Long'" ) includes: object class binaryName) ifFalse:[
+	errorBlock value.
     ].
 
     value := object instVarNamed:#value.
     (value between: min and: max) ifFalse:[
-        errorBlock value.
+	errorBlock value.
     ].
     ^value
 
@@ -1035,12 +1018,12 @@
     | value |
 
     (object class binaryName = 'java/lang/Long') ifFalse:[
-        errorBlock value.
+	errorBlock value.
     ].
 
     value := object instVarNamed:#value.
     (value between: "Integer.MIN_VALUE"-9223372036854775808 and: "Integer.MAX_VALUE" 9223372036854775807) ifFalse:[
-        errorBlock value.
+	errorBlock value.
     ].
     ^value
 
@@ -1114,8 +1097,8 @@
 getJavaLockWord
     "Returns a Java lock word for given object. The returned
      value is
-        - either SmallInteger that encodes the thinlock
-        - or a fat lock, instance of JavaMonitor
+	- either SmallInteger that encodes the thinlock
+	- or a fat lock, instance of JavaMonitor
     "
 
     "/For nonJava objects, always return fatlock
@@ -1368,25 +1351,25 @@
 
 javaInterrupt
     self isWaiting ifTrue: [
-        self interruptWith: [
-            JavaVM throwInterruptedException: 'thread has been interrupted during wait'.
-            self terminate
-        ].
-        ^self
+	self interruptWith: [
+	    JavaVM throwInterruptedException: 'thread has been interrupted during wait'.
+	    self terminate
+	].
+	^self
     ].
 
     self isSleeping ifTrue: [
-        self interruptWith: [
-            JavaVM throwInterruptedException: 'thread has been interrupted during sleep'.
-            self terminate
-        ].
-        ^self
+	self interruptWith: [
+	    JavaVM throwInterruptedException: 'thread has been interrupted during sleep'.
+	    self terminate
+	].
+	^self
     ].
 
     self isParked ifTrue:[
-        self setInterrupted.
-        JavaVM unpark: self.
-        ^self.
+	self setInterrupted.
+	JavaVM unpark: self.
+	^self.
     ].
 
     self setInterrupted
@@ -1411,10 +1394,10 @@
     ^ self generateJavaBuildPrereqsUsingTemplate:
 
 '    <target name="prereqs.%(PREREQ_PACKAGE_DOTTED)" extensionOf="prereqs.main">
-        <ant antfile="${TOP}/../%(PREREQ_PACKAGE_SLASHED)/java/build.xml" 
-             target="${ant.project.invoked-targets}"
-             inheritAll="false"
-             useNativeBasedir="true"/> 
+	<ant antfile="${TOP}/../%(PREREQ_PACKAGE_SLASHED)/java/build.xml"
+	     target="${ant.project.invoked-targets}"
+	     inheritAll="false"
+	     useNativeBasedir="true"/>
     </target>
 '
 
@@ -1428,8 +1411,8 @@
     ^ self generateJavaBuildPrereqsUsingTemplate:
 
 '    <path id="build.classpath.prereqs.%(PREREQ_PACKAGE_DOTTED)">
-        <pathelement path="${TOP}/../%(PREREQ_PACKAGE_SLASHED)/java/bin"/>
-        <fileset dir="${TOP}/../%(PREREQ_PACKAGE_SLASHED)/java/libs" includes="*.jar"/>  
+	<pathelement path="${TOP}/../%(PREREQ_PACKAGE_SLASHED)/java/bin"/>
+	<fileset dir="${TOP}/../%(PREREQ_PACKAGE_SLASHED)/java/libs" includes="*.jar"/>
     </path>
 '
 
@@ -1458,16 +1441,16 @@
     mappings at: 'PACKAGE_DOTTED' put: ((self package copyReplaceAll: $: with: $/) replaceAll: $/ with: $.).
 
     ^ String streamContents:[ :s |
-        ((self preRequisitesFor: self package) asArray sort) do:[:each |
-            | def |
-
-            def := ProjectDefinition definitionClassForPackage: each createIfAbsent: false.
-            def javaBundle notNil ifTrue: [ 
-                mappings at: 'PREREQ_PACKAGE_SLASHED' put:  (each copyReplaceAll: $: with: $/).
-                mappings at: 'PREREQ_PACKAGE_DOTTED' put: ((each copyReplaceAll: $: with: $/) replaceAll: $/ with: $.).
-                s nextPutAll: (template expandPlaceholdersWith: mappings)   
-            ]
-        ].
+	((self preRequisitesFor: self package) asArray sort) do:[:each |
+	    | def |
+
+	    def := ProjectDefinition definitionClassForPackage: each createIfAbsent: false.
+	    def javaBundle notNil ifTrue: [
+		mappings at: 'PREREQ_PACKAGE_SLASHED' put:  (each copyReplaceAll: $: with: $/).
+		mappings at: 'PREREQ_PACKAGE_DOTTED' put: ((each copyReplaceAll: $: with: $/) replaceAll: $/ with: $.).
+		s nextPutAll: (template expandPlaceholdersWith: mappings)
+	    ]
+	].
     ]
 
     "Created: / 18-01-2015 / 07:43:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -1479,10 +1462,10 @@
 generate_java_build_auto_dot_xml
     <file: 'java/build.auto.xml' overwrite: true>
 
-    self javaBundle isNil ifTrue:[ ^ nil ].    
-    ^self 
-        replaceMappings: self java_build_auto_dot_xml_mappings
-        in:              self java_build_auto_dot_xml
+    self javaBundle isNil ifTrue:[ ^ nil ].
+    ^self
+	replaceMappings: self java_build_auto_dot_xml_mappings
+	in:              self java_build_auto_dot_xml
 
     "
     stx_libjava_tools generate_java_build_auto_dot_xml
@@ -1500,9 +1483,9 @@
     <file: 'java/build.xml' overwrite: false>
 
     self javaBundle isNil ifTrue:[ ^ nil ].
-    ^self 
-        replaceMappings: self java_build_dot_xml_mappings
-        in:              self java_build_dot_xml
+    ^self
+	replaceMappings: self java_build_dot_xml_mappings
+	in:              self java_build_dot_xml
 
     "
     stx_libjava_tools generate_java_build_auto_dot_xml
@@ -1551,7 +1534,7 @@
 
 !ProjectDefinition class methodsFor:'file templates'!
 
-java_build_auto_dot_xml  
+java_build_auto_dot_xml
     "Template for java/build.auto.xml"
 ^ '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!!-- This file has been generated by STX:LIBJAVA. Do not edit!! Edit build.xml instead -->
@@ -1578,13 +1561,13 @@
 
 java_build_auto_dot_xml_mappings
     ^ self common_mappings
-        at: 'TOP' put: (self pathToTopWithSeparator:'/');
-        at: 'PACKAGE_SLASHED' put:  (self package copyReplaceAll: $: with: $/);
-        at: 'PACKAGE_DOTTED' put: ((self package copyReplaceAll: $: with: $/) replaceAll: $/ with: $.);
-        at: 'BUILD_PREREQS_CLASSPATH_REFS'  put: (self generateJavaBuildPrereqsClasspathRefs);
-        at: 'BUILD_PREREQS_CLASSPATH_PATHS' put: (self generateJavaBuildPrereqsClasspathPaths);
-        at: 'BUILD_PREREQS'                 put: (self generateJavaBuildPrereqs);
-        yourself
+	at: 'TOP' put: (self pathToTopWithSeparator:'/');
+	at: 'PACKAGE_SLASHED' put:  (self package copyReplaceAll: $: with: $/);
+	at: 'PACKAGE_DOTTED' put: ((self package copyReplaceAll: $: with: $/) replaceAll: $/ with: $.);
+	at: 'BUILD_PREREQS_CLASSPATH_REFS'  put: (self generateJavaBuildPrereqsClasspathRefs);
+	at: 'BUILD_PREREQS_CLASSPATH_PATHS' put: (self generateJavaBuildPrereqsClasspathPaths);
+	at: 'BUILD_PREREQS'                 put: (self generateJavaBuildPrereqs);
+	yourself
 
     "Created: / 18-01-2015 / 07:32:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 19-01-2015 / 07:21:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -1592,12 +1575,12 @@
 
 !ProjectDefinition class methodsFor:'file templates'!
 
-java_build_dot_xml  
+java_build_dot_xml
     "Template for java/build.xml"
 ^ '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <project name="%(PACKAGE_DITTED)" default="compile" basedir=".">
     <import file="build.auto.xml"/>
-    <!!-- Put custom build code here, this file is never overwritten by Smalltalk/X -->    
+    <!!-- Put custom build code here, this file is never overwritten by Smalltalk/X -->
 </project>
 '
 
@@ -1608,10 +1591,10 @@
 
 java_build_dot_xml_mappings
     ^ self common_mappings
-        at: 'TOP' put: (self pathToTopWithSeparator:'/');
-        at: 'PACKAGE_SLASHED' put:  (self package copyReplaceAll: $: with: $/);
-        at: 'PACKAGE_DOTTED' put: ((self package copyReplaceAll: $: with: $/) replaceAll: $/ with: $.);
-        yourself
+	at: 'TOP' put: (self pathToTopWithSeparator:'/');
+	at: 'PACKAGE_SLASHED' put:  (self package copyReplaceAll: $: with: $/);
+	at: 'PACKAGE_DOTTED' put: ((self package copyReplaceAll: $: with: $/) replaceAll: $/ with: $.);
+	yourself
 
     "Created: / 19-01-2015 / 07:37:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
@@ -1627,7 +1610,7 @@
 !Set methodsFor:'javaProtocol'!
 
 java__contains:anObject
-         ^ self contains: [:el | anObject = el ]
+	 ^ self contains: [:el | anObject = el ]
 ! !
 
 !ShortFloat class methodsFor:'queries'!
@@ -1672,7 +1655,7 @@
 
 javaUnbox: object onError: errorBlock
     (object class binaryName = 'java/lang/Float') ifFalse:[
-        errorBlock value.
+	errorBlock value.
     ].
     ^object instVarNamed: #value.
 
@@ -1905,7 +1888,7 @@
 
 javaUnwrapFrom: javaType
     javaType = #boolean ifTrue: [
-        ^ self = 1
+	^ self = 1
     ].
     ^ self
 
@@ -1927,9 +1910,9 @@
 
     listening ifFalse:[ ^ self ].
     OpenError catch:[
-        self domain:domain type:socketType protocol:protocol.
-        self bindTo:port address:nil reuseAddress:true.
-        self listenFor: 5
+	self domain:domain type:socketType protocol:protocol.
+	self bindTo:port address:nil reuseAddress:true.
+	self listenFor: 5
     ].
 
     "Created: / 17-08-2012 / 15:43:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -2058,9 +2041,9 @@
     | orig |
     orig := self originalMethod.
     ^(orig respondsTo: #descriptor) ifTrue:[
-        orig descriptor
+	orig descriptor
     ] ifFalse:[
-        self doesNotUnderstand: (Message selector: #descriptor)
+	self doesNotUnderstand: (Message selector: #descriptor)
     ]
 
     "Created: / 16-12-2011 / 20:03:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"