Object.st
changeset 2148 f0a95dd96db5
parent 2147 3579ce76c8c8
child 2150 3daace4e5fbc
--- a/Object.st	Sat Jan 11 14:56:14 1997 +0100
+++ b/Object.st	Sat Jan 11 15:06:17 1997 +0100
@@ -430,7 +430,7 @@
 basicAt:index
     "return the indexed instance variable with index, anInteger.
      Trigger an error if the receiver has no indexed instance variables.
-     This method should NOT be redefined in any subclass"
+     This method should NOT be redefined in any subclass (except with great care, for tuning)"
 
 %{  /* NOCONTEXT */
 
@@ -455,81 +455,81 @@
      * and SmallInteger
      */
     if (__isSmallInteger(index)) {
-	myClass = __qClass(self);
-	indx = __intVal(index) - 1;
-	n /* nInstVars */ = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
-	n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* nInstVars */);
-	nbytes = __qSize(self) - n /* nInstBytes */;
-	pFirst = (char *)(__InstPtr(self)) + n /* nInstBytes */;
-
-	/* 
-	 * replaced switch by open-coded if; this is slightly faster 
-	 * since it avoids the range check and also handles the most common case first
-	 */
-	n = (INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK);
-
-	if ((n == __MASKSMALLINT(POINTERARRAY))
-	 || (n == __MASKSMALLINT(WKPOINTERARRAY))) {
-	    if ((indx >= 0) && (indx < (__BYTES2OBJS__(nbytes)))) {
-		op = (OBJ *)pFirst + indx;
-		RETURN ( *op );
-	    }
-	} else if (n == __MASKSMALLINT(BYTEARRAY)) {
-	    if ((indx >= 0) && (indx < (nbytes / sizeof(char)))) {
-		cp = (unsigned char *)pFirst + indx;
-		RETURN ( __MKSMALLINT(*cp & 0xFF) );
-	    }
-	} else if (n == __MASKSMALLINT(FLOATARRAY)) {
-	    if ((indx >= 0) && (indx < (nbytes / sizeof(float)))) {
-		float *fp;
-
-		fp = (float *)pFirst + indx;
-		RETURN ( __MKFLOAT((double)(*fp)));
-	    }
-	} else if (n == __MASKSMALLINT(DOUBLEARRAY)) {
-	    if ((indx >= 0) && (indx < (nbytes / sizeof(double)))) {
-		double *dp;
+        myClass = __qClass(self);
+        indx = __intVal(index) - 1;
+        n /* nInstVars */ = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
+        n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* nInstVars */);
+        nbytes = __qSize(self) - n /* nInstBytes */;
+        pFirst = (char *)(__InstPtr(self)) + n /* nInstBytes */;
+
+        /* 
+         * replaced switch by open-coded if; this is slightly faster 
+         * since it avoids the range check and also handles the most common case first
+         */
+        n = (INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK);
+
+        if ((n == __MASKSMALLINT(POINTERARRAY))
+         || (n == __MASKSMALLINT(WKPOINTERARRAY))) {
+            if ((indx >= 0) && (indx < (__BYTES2OBJS__(nbytes)))) {
+                op = (OBJ *)pFirst + indx;
+                RETURN ( *op );
+            }
+        } else if (n == __MASKSMALLINT(BYTEARRAY)) {
+            if ((indx >= 0) && (indx < (nbytes / sizeof(char)))) {
+                cp = (unsigned char *)pFirst + indx;
+                RETURN ( __MKSMALLINT(*cp & 0xFF) );
+            }
+        } else if (n == __MASKSMALLINT(FLOATARRAY)) {
+            if ((indx >= 0) && (indx < (nbytes / sizeof(float)))) {
+                float *fp;
+
+                fp = (float *)pFirst + indx;
+                RETURN ( __MKFLOAT((double)(*fp)));
+            }
+        } else if (n == __MASKSMALLINT(DOUBLEARRAY)) {
+            if ((indx >= 0) && (indx < (nbytes / sizeof(double)))) {
+                double *dp;
 
 #ifdef NEED_DOUBLE_ALIGN
-		/*
-		 * care for filler
-		 */
-		pFirst += sizeof(FILLTYPE);
+                /*
+                 * care for filler
+                 */
+                pFirst += sizeof(FILLTYPE);
 #endif
-		dp = (double *)pFirst + indx;
-		RETURN ( __MKFLOAT(*dp));
-	    }
-	} else if (n == __MASKSMALLINT(WORDARRAY)) {
-	    if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) {
-		sp = (unsigned short *)pFirst + indx;
-		RETURN ( __MKSMALLINT(*sp & 0xFFFF) );
-	    }
-	} else if (n == __MASKSMALLINT(SWORDARRAY)) {
-	    if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) {
-		ssp = (short *)pFirst + indx;
-		RETURN ( __MKSMALLINT(*ssp) );
-	    }
-	} else if (n == __MASKSMALLINT(LONGARRAY)) {
-	    if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) {
-		lp = (unsigned long *)pFirst + indx;
-		ul = *lp;
-		if (ul <= _MAX_INT)
-		    RETURN ( __MKSMALLINT(ul) );
-		RETURN ( __MKULARGEINT(ul) );
-	    }
-	} else if (n == __MASKSMALLINT(SLONGARRAY)) {
-	    if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) {
-		slp = (long *)pFirst + indx;
-		l = *slp;
-		if ((l >= _MIN_INT) && (l <= _MAX_INT))
-		    RETURN ( __MKSMALLINT(l) );
-		RETURN ( __MKLARGEINT(l) );
-	    }
-	}
+                dp = (double *)pFirst + indx;
+                RETURN ( __MKFLOAT(*dp));
+            }
+        } else if (n == __MASKSMALLINT(WORDARRAY)) {
+            if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) {
+                sp = (unsigned short *)pFirst + indx;
+                RETURN ( __MKSMALLINT(*sp & 0xFFFF) );
+            }
+        } else if (n == __MASKSMALLINT(SWORDARRAY)) {
+            if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) {
+                ssp = (short *)pFirst + indx;
+                RETURN ( __MKSMALLINT(*ssp) );
+            }
+        } else if (n == __MASKSMALLINT(LONGARRAY)) {
+            if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) {
+                lp = (unsigned long *)pFirst + indx;
+                ul = *lp;
+                if (ul <= _MAX_INT)
+                    RETURN ( __MKSMALLINT(ul) );
+                RETURN ( __MKULARGEINT(ul) );
+            }
+        } else if (n == __MASKSMALLINT(SLONGARRAY)) {
+            if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) {
+                slp = (long *)pFirst + indx;
+                l = *slp;
+                if ((l >= _MIN_INT) && (l <= _MAX_INT))
+                    RETURN ( __MKSMALLINT(l) );
+                RETURN ( __MKLARGEINT(l) );
+            }
+        }
     }
 %}.
     index isInteger ifFalse:[
-	^ self indexNotInteger
+        ^ self indexNotInteger
     ].
     ^ self subscriptBoundsError:index
 !
@@ -538,7 +538,8 @@
     "store the 2nd arg, anObject as indexed instvar with index, anInteger.
      Returns anObject (sigh).
      Trigger an error if the receiver has no indexed instance variables.
-     This method should NOT be redefined in any subclass"
+
+     This method should NOT be redefined in any subclass (except with great care, for tuning)"
 
 %{  /* NOCONTEXT */
 
@@ -568,14 +569,14 @@
         nbytes = __qSize(self) - n /* nInstBytes */;
         pFirst = (char *)(__InstPtr(self)) + n /* nInstBytes */;
 
-	n = (INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK);
-
-	/* 
-	 * replaced switch by open-coded if; this is slightly faster 
-	 * since it avoids the range check and also handles the most common case first
-	 */
+        n = (INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK);
+
+        /* 
+         * replaced switch by open-coded if; this is slightly faster 
+         * since it avoids the range check and also handles the most common case first
+         */
         if ((n == __MASKSMALLINT(POINTERARRAY))
-	 || (n == __MASKSMALLINT(WKPOINTERARRAY))) {
+         || (n == __MASKSMALLINT(WKPOINTERARRAY))) {
             if ((indx >= 0) && (indx < (__BYTES2OBJS__(nbytes)))) {
                 op = (OBJ *)pFirst + indx;
                 *op = anObject;
@@ -655,27 +656,27 @@
                 if (__isSmallInteger(anObject)) {
                     *slp = __intVal(anObject);
                     RETURN ( anObject );
-		}
-		n = __signedLongIntVal(anObject);
-		/* zero means failure for an int larger than 4 bytes  ... (would be a smallInteger) */
-		if (n) {
-		    *slp = n;
-		    RETURN ( anObject );
+                }
+                n = __signedLongIntVal(anObject);
+                /* zero means failure for an int larger than 4 bytes  ... (would be a smallInteger) */
+                if (n) {
+                    *slp = n;
+                    RETURN ( anObject );
                 }
             }
         } else if (n == __MASKSMALLINT(LONGARRAY)) {
             if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) {
                 lp = (unsigned long *)pFirst + indx;
-		if (anObject == __MKSMALLINT(0)) {
-		    *lp = 0;
-	       	    RETURN ( anObject );
-		}
-		u = __longIntVal(anObject);
-		/* zero means failure for an int larger than 4 bytes  ... (would be a smallInteger) */
-		if (u) {
-		    *lp = u;
-		    RETURN ( anObject );
-		}
+                if (anObject == __MKSMALLINT(0)) {
+                    *lp = 0;
+                    RETURN ( anObject );
+                }
+                u = __longIntVal(anObject);
+                /* zero means failure for an int larger than 4 bytes  ... (would be a smallInteger) */
+                if (u) {
+                    *lp = u;
+                    RETURN ( anObject );
+                }
             }
         }
     }
@@ -4246,7 +4247,7 @@
     "return the number of the receivers indexed instance variables,
      0 if it has none.
 
-     This method should NOT be redefined in any subclass"
+     This method should NOT be redefined in any subclass (except with great care, for tuning)"
 
 %{  /* NOCONTEXT */
 
@@ -4261,8 +4262,8 @@
      */
     myClass = __qClass(self);
     nbytes = __qSize(self) 
-	      - OHDR_SIZE 
-	      - __OBJS2BYTES__(__intVal(__ClassInstPtr(myClass)->c_ninstvars));
+              - OHDR_SIZE 
+              - __OBJS2BYTES__(__intVal(__ClassInstPtr(myClass)->c_ninstvars));
 
     flags = __intVal(__ClassInstPtr(myClass)->c_flags) & ARRAYMASK;
     /*
@@ -4271,28 +4272,28 @@
      */
     if ((flags == POINTERARRAY)
      || (flags == WKPOINTERARRAY)) {
-	RETURN ( __MKSMALLINT(__BYTES2OBJS__(nbytes)) );
+        RETURN ( __MKSMALLINT(__BYTES2OBJS__(nbytes)) );
     }
     if (flags == BYTEARRAY) {
-	    RETURN ( __MKSMALLINT(nbytes / sizeof(char)) );
+            RETURN ( __MKSMALLINT(nbytes / sizeof(char)) );
     }
     if (flags == FLOATARRAY) {
-	RETURN ( __MKSMALLINT(nbytes / sizeof(float)) );
+        RETURN ( __MKSMALLINT(nbytes / sizeof(float)) );
     }
     if (flags == DOUBLEARRAY) {
 #ifdef NEED_DOUBLE_ALIGN
-	    /*
-	     * care for filler
-	     */
-	    nbytes -= sizeof(FILLTYPE);
+            /*
+             * care for filler
+             */
+            nbytes -= sizeof(FILLTYPE);
 #endif
-	    RETURN ( __MKSMALLINT(nbytes / sizeof(double)) );
+            RETURN ( __MKSMALLINT(nbytes / sizeof(double)) );
     }
     if ((flags == WORDARRAY) || (flags == SWORDARRAY)) {
-	RETURN ( __MKSMALLINT(nbytes / sizeof(short)) );
+        RETURN ( __MKSMALLINT(nbytes / sizeof(short)) );
     }
     if ((flags == LONGARRAY) || (flags == SLONGARRAY)) {
-	RETURN ( __MKSMALLINT(nbytes / sizeof(long)) );
+        RETURN ( __MKSMALLINT(nbytes / sizeof(long)) );
     }
 %}.
     ^ 0
@@ -4830,7 +4831,7 @@
       as in:
           foo := arg ? #defaultValue
 
-      Note: this method should never be redefined.
+      Note: this method should never be redefined in classes other than UndefinedObject.
      "
 
     ^ self
@@ -4841,7 +4842,7 @@
     "
 
     "Created: 4.11.1996 / 20:36:19 / cg"
-    "Modified: 11.1.1997 / 14:55:44 / cg"
+    "Modified: 11.1.1997 / 14:56:47 / cg"
 !
 
 isArray
@@ -5409,6 +5410,6 @@
 !Object class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.159 1997-01-11 13:56:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.160 1997-01-11 14:06:17 cg Exp $'
 ! !
 Object initialize!