Fixed `ExternalAddress >> setAddress:` to allow for parameter to be `0` or `nil` jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 17 Jul 2018 09:07:17 +0200
branchjv
changeset 23217 5811aa416119
parent 23208 3ec0d6cb2a7b
child 23291 69fd0b0c97dd
Fixed `ExternalAddress >> setAddress:` to allow for parameter to be `0` or `nil` This MUST be allowed so we can make set the address to `NULL` (for the very same reason one set pointer to `NULL` in C).
ExternalAddress.st
--- a/ExternalAddress.st	Tue May 29 13:29:04 2018 +0200
+++ b/ExternalAddress.st	Tue Jul 17 09:07:17 2018 +0200
@@ -1,5 +1,6 @@
 "
  COPYRIGHT (c) 1995 by Claus Gittinger
+ COPYRIGHT (c) 2018 Jan Vrany
 	      All Rights Reserved
 
  This software is furnished under a license and may be used
@@ -25,6 +26,7 @@
 copyright
 "
  COPYRIGHT (c) 1995 by Claus Gittinger
+ COPYRIGHT (c) 2017 Jan Vrany
 	      All Rights Reserved
 
  This software is furnished under a license and may be used
@@ -351,13 +353,12 @@
 
     unsigned INT addr;
 
-    if (__isSmallInteger(anInteger)) {
+    if (anInteger == nil) {
+    	addr = (unsigned INT)NULL;
+    } else if (__isSmallInteger(anInteger)) {
         addr = __intVal(anInteger);
     } else {
-        addr = __unsignedLongIntVal(anInteger);
-        if (addr == 0) {
-            console_printf("invalid address argument in ExternalAddress>>setAddress\n");
-        }
+        addr = __unsignedLongIntVal(anInteger);    
     }
     __INST(address_) = (OBJ)addr;
 %}