Merge jv
authorMerge Script
Tue, 16 Aug 2016 06:51:56 +0200
branchjv
changeset 4037 dea4e4c75fa3
parent 4029 a1cc22fe4b81 (current diff)
parent 4036 677462d5333b (diff)
child 4040 645d303ede4d
Merge
Socket.st
--- a/BitArray.st	Sat Aug 13 06:52:20 2016 +0200
+++ b/BitArray.st	Tue Aug 16 06:51:56 2016 +0200
@@ -424,7 +424,7 @@
 !
 
 indexOfNth:n occurrenceOf:what
-    "return the index of the nTh occurence of a value, or 0 if there are not that many"
+    "return the index of the nTh occurrence of a value, or 0 if there are not that many"
 
     |sz byteIndex count countInByte|
 
@@ -458,15 +458,15 @@
 
     "
      (BooleanArray new:100)
-        at:1 put:true; 
-        at:2 put:true; 
-        at:4 put:true; 
-        at:5 put:true; 
-        at:6 put:true; 
-        at:7 put:true; 
-        at:8 put:true; 
-        at:10 put:true; 
-        indexOfNth:8 occurrenceOf:false         
+        at:1 put:true;
+        at:2 put:true;
+        at:4 put:true;
+        at:5 put:true;
+        at:6 put:true;
+        at:7 put:true;
+        at:8 put:true;
+        at:10 put:true;
+        indexOfNth:8 occurrenceOf:false
     "
 !
 
@@ -489,6 +489,7 @@
     ^ tally
 ! !
 
+
 !BitArray methodsFor:'visiting'!
 
 acceptVisitor:aVisitor with:aParameter
--- a/Promise.st	Sat Aug 13 06:52:20 2016 +0200
+++ b/Promise.st	Tue Aug 16 06:51:56 2016 +0200
@@ -9,8 +9,9 @@
  other person.  No title to or ownership of the software is
  hereby transferred.
 "
+"{ Package: 'stx:libbasic2' }"
 
-"{ Package: 'stx:libbasic2' }"
+"{ NameSpace: Smalltalk }"
 
 Object subclass:#Promise
 	instanceVariableNames:'value valueAvailable exception'
@@ -81,17 +82,17 @@
     "return the value of the promise. 
      If the evaluation process has not yet finished, wait for it.
      Otherwise return the value immediately.
-     Any exception which occured during the evaluation is forwarded to the
+     Any exception which occurred during the evaluation is forwarded to the
      requestor of the value here."
 
     valueAvailable waitUncounted.
     exception notNil ifTrue:[
-	"/
-	"/ an exception occured while evaluating the promise.
-	"/ This exception is remembered and raised here, when the
-	"/ value is asked for.
-	"/
-	exception raise
+        "/
+        "/ an exception occurred while evaluating the promise.
+        "/ This exception is remembered and raised here, when the
+        "/ value is asked for.
+        "/
+        exception raise
     ].
     ^ value
 !
@@ -148,5 +149,6 @@
 !Promise class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Promise.st,v 1.9 2004-11-10 10:43:23 penk Exp $'
+    ^ '$Header$'
 ! !
+
--- a/Queue.st	Sat Aug 13 06:52:20 2016 +0200
+++ b/Queue.st	Tue Aug 16 06:51:56 2016 +0200
@@ -11,6 +11,8 @@
 "
 "{ Package: 'stx:libbasic2' }"
 
+"{ NameSpace: Smalltalk }"
+
 Collection subclass:#Queue
 	instanceVariableNames:'contentsArray readPosition writePosition tally'
 	classVariableNames:''
@@ -36,7 +38,7 @@
 
 documentation
 "
-    Queues provide a simple implementation of a queue, 
+    Queues provide a simple implementation of a queue,
     where elements are added at one end and removed at the other.
 
     Access protocol is somewhat like a streams protocol, i.e. access
@@ -44,9 +46,9 @@
     The queue is created with a size argument, defining how many elements
     are to be stored. It will report an error if the queue ever becomes full
     and another element is to be added. Likewise, it will report an error
-    if its empty and an element is to be removed.
+    if it is empty and an element is to be removed.
 
-    It is NOT safe when two processes access Queues simultanously,
+    It is NOT safe when two processes access Queues simultaneously,
     since accesses to the internals are not protected against process-switches.
     See SharedQueue for a class which IS safe with processes and blocks
     on write when full or on read when empty.
@@ -54,15 +56,15 @@
     [Implementation note:]
         All of queue's functionality is also provided by the OrderedCollection (OC)
         class; OC could easily simulate a queue (using #addLast: / #removeFirst).
-        The reason for providing Queue is not any speed advantage 
-        (actually, OC seems to be even a tiny bit faster). 
+        The reason for providing Queue is not any speed advantage
+        (actually, OC seems to be even a tiny bit faster).
         The point is that an implementation of SharedQueue as a subclass of OC
         would require that many OC methods had to be blocked and/or redefined in
         such a subclass, to care for simultaneous access.
-        Since queue implements a much more lightweight protocol, 
+        Since queue implements a much more lightweight protocol,
         the sharedQueue implementation is much cleaner when based on a more
         lightweight Queue class.
-        
+
     [author:]
         Claus Gittinger
 "
@@ -75,7 +77,7 @@
     |q element  |
 
     q := Queue new:10.
-    1 to:5 do:[:i | 
+    1 to:5 do:[:i |
         Transcript showCR:('adding ' , i printString).
         q nextPut:i
     ].
@@ -95,7 +97,7 @@
     q := Queue new:100.
     tQueue := Time millisecondsToRun:[
         1000 timesRepeat:[
-            1 to:100 do:[:i | 
+            1 to:100 do:[:i |
                 q nextPut:i
             ].
             [q isEmpty] whileFalse:[
@@ -107,7 +109,7 @@
     oc := OrderedCollection new:100.
     tOC := Time millisecondsToRun:[
         1000 timesRepeat:[
-            1 to:100 do:[:i | 
+            1 to:100 do:[:i |
                 oc addLast:i
             ].
             [oc isEmpty] whileFalse:[
@@ -190,14 +192,14 @@
 !
 
 next
-    "return the next value in the queue; 
+    "return the next value in the queue;
      Return nil, if the queue is empty"
 
     ^ self nextOrNil
 !
 
 nextOrNil
-    "return the next value in the queue; 
+    "return the next value in the queue;
      Return nil, if the queue is empty"
 
     |value pos "{ Class: SmallInteger }"|
@@ -292,7 +294,7 @@
      countRemoved
      el sz|
 
-    
+
     (tally == 0) ifTrue:[
         ^ exceptionalValue value
     ].
@@ -316,7 +318,7 @@
             ] ifFalse:[
                 wPos := wPos + 1.
             ].
-        ].    
+        ].
         rPos == sz ifTrue:[
             rPos := 1.
         ] ifFalse:[
@@ -344,7 +346,7 @@
      q next.
      q nextPut:12.
      q next.
-     q removeIdentical:5.     
+     q removeIdentical:5.
      q
 
      |q|
@@ -360,7 +362,7 @@
      self assert:(q next == 7).
      self assert:(q next == 8).
      self assert:(q isEmpty).
-     q       
+     q
 
      |q|
 
@@ -393,7 +395,7 @@
 !
 
 removeLast
-    "return the last value in the queue; 
+    "return the last value in the queue;
      Return nil, if the queue is empty"
 
     |value pos "{ Class: SmallInteger }"|
@@ -466,7 +468,7 @@
 
 !Queue methodsFor:'queries'!
 
-capacity 
+capacity
     "return the number of elements the queue can hold"
 
     ^ contentsArray size
@@ -508,10 +510,10 @@
 !Queue class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Queue.st,v 1.38 2014-11-26 08:50:35 cg Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/Queue.st,v 1.38 2014-11-26 08:50:35 cg Exp $'
+    ^ '$Header$'
 ! !
 
--- a/SharedQueue.st	Sat Aug 13 06:52:20 2016 +0200
+++ b/SharedQueue.st	Tue Aug 16 06:51:56 2016 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1993 by Claus Gittinger
 	      All Rights Reserved
@@ -289,7 +287,7 @@
 !
 
 readWaitWithTimeoutMs:ms
-    "Return true if a timeout occured (i.e. false, if data is available)."
+    "Return true if a timeout occurred (i.e. false, if data is available)."
 
     ^ (dataAvailable waitUncountedWithTimeoutMs:ms) isNil.
 !
--- a/Socket.st	Sat Aug 13 06:52:20 2016 +0200
+++ b/Socket.st	Tue Aug 16 06:51:56 2016 +0200
@@ -2119,7 +2119,7 @@
     |isAsync err|
 
     handle isNil ifTrue:[
-	^ self errorNotOpen
+        ^ self errorNotOpen
     ].
 
 %{  /* STACK: 100000 */
@@ -2139,25 +2139,25 @@
     int sockaddr_size;
 
     if (!__isNonNilObject(aSocketAddress) || !__isBytes(aSocketAddress)) {
-	DBGPRINTF(("SOCKET: invalid socketAddress\n"));
-	err = @symbol(argumentError);
-	goto out;
+        DBGPRINTF(("SOCKET: invalid socketAddress\n"));
+        err = @symbol(argumentError);
+        goto out;
     }
 
     {
-	int sockAddrOffs = 0;
-	int nIndex =__byteArraySize(aSocketAddress);
-	OBJ cls = __qClass(aSocketAddress);
-
-	//if (cls != @global(ByteArray))
-	//    sockAddrOffs = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-	sockaddr_size = nIndex - sockAddrOffs;
-	if (sockaddr_size > sizeof(sa)) {
-	    DBGPRINTF(("SOCKET: invalid (short) socketAddress\n"));
-	    err = @symbol(argumentError);
-	    goto out;
-	}
-	memcpy(&sa, __byteArrayVal(aSocketAddress) + sockAddrOffs, sockaddr_size);
+        int sockAddrOffs = 0;
+        int nIndex =__byteArraySize(aSocketAddress);
+        OBJ cls = __qClass(aSocketAddress);
+
+        //if (cls != @global(ByteArray))
+        //    sockAddrOffs = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+        sockaddr_size = nIndex - sockAddrOffs;
+        if (sockaddr_size > sizeof(sa)) {
+            DBGPRINTF(("SOCKET: invalid (short) socketAddress\n"));
+            err = @symbol(argumentError);
+            goto out;
+        }
+        memcpy(&sa, __byteArrayVal(aSocketAddress) + sockAddrOffs, sockaddr_size);
     }
 
     sock = SOCKET_FROM_FILE_OBJECT(fp);
@@ -2184,18 +2184,18 @@
 
 
     do {
-	DBGFPRINTF((stderr, "SOCKET: (sock=%d) connect...\n", sock));
-	ret = STX_WSA_NOINT_CALL3("connect", connect, sock, &sa, (INT)sockaddr_size);
-	DBGFPRINTF((stderr, "SOCKET: connect(%d) -> %"_ld_" (%d)\n", sock, (INT)ret, __threadErrno));
+        DBGFPRINTF((stderr, "SOCKET: (sock=%d) connect...\n", sock));
+        ret = STX_WSA_NOINT_CALL3("connect", connect, sock, &sa, (INT)sockaddr_size);
+        DBGFPRINTF((stderr, "SOCKET: connect(%d) -> %"_ld_" (%d)\n", sock, (INT)ret, __threadErrno));
     } while ((ret < 0) && (__threadErrno == EINTR));
 
     if (ret < 0) {
-	int optLen = sizeof(errno);
-	errno = __threadErrno;
+        int optLen = sizeof(errno);
+        errno = __threadErrno;
 #if 0
-	if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &errno, &optLen) == SOCKET_ERROR) {
-	    DBGFPRINTF((stderr, "SOCKET: getsockopt(SO_ERROR) failed: %d\n", WSAGetLastError()));
-	}
+        if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &errno, &optLen) == SOCKET_ERROR) {
+            DBGFPRINTF((stderr, "SOCKET: getsockopt(SO_ERROR) failed: %d\n", WSAGetLastError()));
+        }
 #endif // 0
     }
 
@@ -2206,16 +2206,16 @@
     __BEGIN_INTERRUPTABLE__
 #  endif
     do {
-	ret = connect(sock, (struct sockaddr *)&sa, sockaddr_size);
+        ret = connect(sock, (struct sockaddr *)&sa, sockaddr_size);
     } while ((ret < 0)
 #  ifdef __win32__
-	     && (errno = WSAGetLastError())
+             && (errno = WSAGetLastError())
 #  endif
-	     && ((errno == EINTR)
+             && ((errno == EINTR)
 #  ifdef EAGAIN
-		 || (errno == EAGAIN)
+                 || (errno == EAGAIN)
 #  endif
-		));
+                ));
 #  if !defined(__win32__) && !defined(O_NONBLOCK)
     __END_INTERRUPTABLE__
 #  endif
@@ -2228,47 +2228,47 @@
 
     if (ret < 0) {
 # if defined(EINPROGRESS) || defined(EALREADY)
-	if (0
+        if (0
 #  ifdef __win32__
-	    || (errno == WSAEWOULDBLOCK)
+            || (errno == WSAEWOULDBLOCK)
 #  endif
 #  ifdef EINPROGRESS
-	    || (errno == EINPROGRESS)
+            || (errno == EINPROGRESS)
 #  endif
 #  ifdef EALREADY
-	    || (errno == EALREADY)
+            || (errno == EALREADY)
 #  endif
-	) {
-	    /*
-	     * This was a nonblocking operation that will take some time.
-	     * Do a select on read to get informed when the operation is ready.
-	     */
-	    DBGFPRINTF((stderr, "SOCKET: isAsync is true\n"));
-	    isAsync = true;
-	} else
+        ) {
+            /*
+             * This was a nonblocking operation that will take some time.
+             * Do a select on read to get informed when the operation is ready.
+             */
+            DBGFPRINTF((stderr, "SOCKET: isAsync is true\n"));
+            isAsync = true;
+        } else
 # endif /* EINPROGRESS or EALREADY */
-	{
-	    DBGFPRINTF((stderr, "SOCKET: connect failed ret=%"_ld_" errno=%d __threadErrno=%d\n",
-			(INT)ret, errno, __threadErrno ));
+        {
+            DBGFPRINTF((stderr, "SOCKET: connect failed ret=%"_ld_" errno=%d __threadErrno=%d\n",
+                        (INT)ret, errno, __threadErrno ));
 # ifdef DUMP_ADDRESS
-	    {
-		unsigned char *cp = (unsigned char *)(&sa);
-		int i;
-
-		console_printf("address data:\n");
-		for (i=0; i<sockaddr_size; i++) {
-		    console_printf(" %02x\n", *cp++);
-		}
-	    }
+            {
+                unsigned char *cp = (unsigned char *)(&sa);
+                int i;
+
+                console_printf("address data:\n");
+                for (i=0; i<sockaddr_size; i++) {
+                    console_printf(" %02x\n", *cp++);
+                }
+            }
 # endif
-	    err = __MKSMALLINT(errno);
-	}
+            err = __MKSMALLINT(errno);
+        }
     }
 
 # ifdef __win32__
     {
-	int off = 0;
-	ioctlsocket(sock, FIONBIO, &off);
+        int off = 0;
+        ioctlsocket(sock, FIONBIO, &off);
     }
 # elif defined(O_NONBLOCK) // Linux / Unix
     fcntl(sock, F_SETFL, oldFlags);
@@ -2281,34 +2281,34 @@
 %}.
 
     err notNil ifTrue:[
-	err isSymbol ifTrue:[
-	    self primitiveFailed:err.
-	].
-	lastErrorNumber := err.
-	^ false.
-	"/ Once we will raise an exception instead of returning false (and have to change some code above):
+        err isSymbol ifTrue:[
+            self primitiveFailed:err.
+        ].
+        lastErrorNumber := err.
+        ^ false.
+        "/ Once we will raise an exception instead of returning false (and have to change some code above):
 "/        (OperatingSystem errorHolderForNumber:err) reportError.
     ].
     isAsync == true ifTrue:[
-	(self writeExceptionWaitWithTimeoutMs:timeout) ifTrue:[
-	    "/ a timeout occured
-	    "/ should I cancel the connect?
-	    lastErrorNumber := OperatingSystem errorNumberFor:#ETIMEDOUT.
-	    ^ false.
-	].
-	err := self getSocketError.
-	err ~~ 0 ifTrue:[
-	    lastErrorNumber := err.
-	    ^ false.
-	].
+        (self writeExceptionWaitWithTimeoutMs:timeout) ifTrue:[
+            "/ a timeout occurred
+            "/ should I cancel the connect?
+            lastErrorNumber := OperatingSystem errorNumberFor:#ETIMEDOUT.
+            ^ false.
+        ].
+        err := self getSocketError.
+        err ~~ 0 ifTrue:[
+            lastErrorNumber := err.
+            ^ false.
+        ].
     ].
 
 
     peer := aSocketAddress.
     port isNil ifTrue:[
-	"socket has not been explicitly bound,
-	 after connect it has been bound implicitly - fetch the port"
-	port := self getFullSocketAddress port.
+        "socket has not been explicitly bound,
+         after connect it has been bound implicitly - fetch the port"
+        port := self getFullSocketAddress port.
     ].
     ^ true
 
@@ -4113,7 +4113,7 @@
      For a new connection, an accept is performed and the new socket is returned.
      For an old connection, that socket is returned.
      In any case, the caller gets a socket to operate on as return value,
-     or nil, if a timeout occured.
+     or nil, if a timeout occurred.
      This method implements the inner wait-primitive of a multi-connection
      server application."
 
@@ -4122,41 +4122,41 @@
 
     "first, a quick check if data is already available"
     self canReadWithoutBlocking ifTrue:[
-	^ self accept.
+        ^ self accept.
     ].
     otherConnections do:[:aConnection |
-	aConnection canReadWithoutBlocking ifTrue:[
-	    ^ aConnection
-	]
+        aConnection canReadWithoutBlocking ifTrue:[
+            ^ aConnection
+        ]
     ].
 
     "check again - prevent incoming interrupts from disturbing our setup"
     wasBlocked := OperatingSystem blockInterrupts.
     [
-	sema := Semaphore new name:'multiReadWait'.
-	otherConnections do:[:aConnection |
-	    Processor signal:sema onInput:(aConnection fileDescriptor).
-	].
-	Processor signal:sema onInput:(self fileDescriptor).
-	timeoutSeconds notNil ifTrue:[
-	    Processor signal:sema afterSeconds:timeoutSeconds
-	].
-	Processor activeProcess state:#ioWait.
-	sema wait.
+        sema := Semaphore new name:'multiReadWait'.
+        otherConnections do:[:aConnection |
+            Processor signal:sema onInput:(aConnection fileDescriptor).
+        ].
+        Processor signal:sema onInput:(self fileDescriptor).
+        timeoutSeconds notNil ifTrue:[
+            Processor signal:sema afterSeconds:timeoutSeconds
+        ].
+        Processor activeProcess state:#ioWait.
+        sema wait.
     ] ifCurtailed:[
-	sema notNil ifTrue:[Processor disableSemaphore:sema].
-	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+        sema notNil ifTrue:[Processor disableSemaphore:sema].
+        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
     ].
     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 
     "see who it was ..."
     self canReadWithoutBlocking ifTrue:[
-	^ self accept.
+        ^ self accept.
     ].
     otherConnections do:[:aConnection |
-	aConnection canReadWithoutBlocking ifTrue:[
-	    ^ aConnection
-	]
+        aConnection canReadWithoutBlocking ifTrue:[
+            ^ aConnection
+        ]
     ].
 
     "none - a timeout"
@@ -4167,20 +4167,20 @@
     "suspend the current process, until a new connection comes
      in at the receiver or a timeout occurs.
      For a new connection, an accept is performed and the new socket is returned.
-     Returns nil, if a timeout occured.
+     Returns nil, if a timeout occurred.
      This method implements the inner wait-primitive of a single-connection
      server application."
 
     |newSock|
 
     (self readWaitWithTimeout:timeoutSecondsOrNil) ifTrue:[
-	"a timeout occurred - no connection within timeout"
-	^ nil
+        "a timeout occurred - no connection within timeout"
+        ^ nil
     ].
     newSock := self class new.
     (newSock primAcceptOn:self blocking:false) ifFalse:[
-	"should raise an error here"
-	^ nil
+        "should raise an error here"
+        ^ nil
     ].
     ^ newSock
 ! !
--- a/extensions.st	Sat Aug 13 06:52:20 2016 +0200
+++ b/extensions.st	Tue Aug 16 06:51:56 2016 +0200
@@ -908,22 +908,23 @@
 
 onChangeSend:aSelector to:anObject
     "arrange for aSelector to be sent to anObject whenever the receiver
-     changes."
+     changes.
+     Use retractInterestsFor: in case you are no longer interested"
 
     "/ for now, use an interestConverter, which is somewhat less efficient.
     "/ In the future, a more intelligent DependencyCollection class is planned for
 
     ((self interests ? #())
-	contains:[:anInterest |
-	    (anInterest isInterestConverter)
-	    and:[ anInterest destination == anObject
-	    and:[ anInterest selector == aSelector]]
-	])
-	    ifTrue:[^ self].
+        contains:[:anInterest |
+            (anInterest isInterestConverter)
+            and:[ anInterest destination == anObject
+            and:[ anInterest selector == aSelector]]
+        ])
+            ifTrue:[^ self].
 
     self addInterest:(InterestConverter
-			  destination:anObject
-			  selector:aSelector)
+                          destination:anObject
+                          selector:aSelector)
 
     "
      |p b|