Rectangle.st
changeset 17238 94b805b727cf
parent 15900 ef5a31a78db8
child 17239 6f71da3ffaea
--- a/Rectangle.st	Sun Dec 21 14:03:18 2014 +0100
+++ b/Rectangle.st	Sun Dec 21 21:15:53 2014 +0100
@@ -286,6 +286,8 @@
     "
 ! !
 
+
+
 !Rectangle methodsFor:'Compatibility-Squeak'!
 
 amountToTranslateWithin: aRectangle
@@ -389,6 +391,32 @@
 corner
     "return the corner"
 
+%{  /* NOCONTEXT */
+    OBJ _left = __INST(left);
+    OBJ _top = __INST(top);
+    OBJ _width = __INST(width);
+    OBJ _height = __INST(height);
+
+    if (__bothSmallInteger(_left, _top)
+     && __bothSmallInteger(_width, _height)) {
+        if (self == @global(Rectangle)) {
+            if (__CanDoQuickNew(sizeof(struct __Point))) {      /* OBJECT ALLOCATION */
+                OBJ newPoint;
+                int spc;
+                int cX = __intVal(_left) + __intVal(_width);
+                int cY = __intVal(_top) + __intVal(_height);
+
+                if (__ISVALIDINTEGER(cX) && __ISVALIDINTEGER(cY)) {
+                    __qCheckedAlignedNew(newPoint, sizeof(struct __Point));
+                    __InstPtr(newPoint)->o_class = self; __qSTORE(newPoint, self);
+                    __PointInstPtr(newPoint)->p_x = __MKSMALLINT(cX);
+                    __PointInstPtr(newPoint)->p_y = __MKSMALLINT(cY);
+                    RETURN ( newPoint );
+                }
+            }
+        }
+    }
+%}.
     ^ (left + width) @ (top + height)
 !
 
@@ -400,8 +428,30 @@
 !
 
 extent
-    "return the extent as a point"
+    "return the extent"
+
+%{  /* NOCONTEXT */
+
+    if (__CanDoQuickNew(sizeof(struct __Point))) {      /* OBJECT ALLOCATION */
+        if (self == @global(Rectangle)) {
+            OBJ newPoint;
+            int spc;
+            OBJ newX = __INST(width);
+            OBJ newY = __INST(height);
 
+            __qCheckedAlignedNew(newPoint, sizeof(struct __Point));
+            __InstPtr(newPoint)->o_class = self; __qSTORE(newPoint, self);
+            __PointInstPtr(newPoint)->p_x = newX;
+            __PointInstPtr(newPoint)->p_y = newY;
+            if (! __bothSmallInteger(newX, newY)) {
+                spc = __qSpace(newPoint);
+                __STORE_SPC(newPoint, newX, spc);
+                __STORE_SPC(newPoint, newY, spc);
+            }
+            RETURN ( newPoint );
+        }
+    }
+%}.
     ^ Point x:width y:height
 !
 
@@ -499,6 +549,31 @@
 origin
     "return the origin"
 
+%{  /* NOCONTEXT */
+
+    /*
+     * claus: I am no longer certain, if this primitive is worth the effort
+     */
+    if (__CanDoQuickNew(sizeof(struct __Point))) {      /* OBJECT ALLOCATION */
+        if (self == @global(Rectangle)) {
+            OBJ newPoint;
+            int spc;
+            OBJ newX = __INST(left);
+            OBJ newY = __INST(top);
+
+            __qCheckedAlignedNew(newPoint, sizeof(struct __Point));
+            __InstPtr(newPoint)->o_class = self; __qSTORE(newPoint, self);
+            __PointInstPtr(newPoint)->p_x = newX;
+            __PointInstPtr(newPoint)->p_y = newY;
+            if (! __bothSmallInteger(newX, newY)) {
+                spc = __qSpace(newPoint);
+                __STORE_SPC(newPoint, newX, spc);
+                __STORE_SPC(newPoint, newY, spc);
+            }
+            RETURN ( newPoint );
+        }
+    }
+%}.
     ^ Point x:left y:top
 !
 
@@ -1821,10 +1896,10 @@
 !Rectangle class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.87 2014-01-23 16:11:19 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.88 2014-12-21 20:15:53 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.87 2014-01-23 16:11:19 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.88 2014-12-21 20:15:53 cg Exp $'
 ! !