[armedbear-cvs] r12477 - branches/metaclass/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Sun Feb 14 19:33:39 UTC 2010


Author: ehuelsmann
Date: Sun Feb 14 14:33:37 2010
New Revision: 12477

Log:
SlotClass now accesses its fields only through the accessor functions.

Modified:
   branches/metaclass/abcl/src/org/armedbear/lisp/SlotClass.java

Modified: branches/metaclass/abcl/src/org/armedbear/lisp/SlotClass.java
==============================================================================
--- branches/metaclass/abcl/src/org/armedbear/lisp/SlotClass.java	(original)
+++ branches/metaclass/abcl/src/org/armedbear/lisp/SlotClass.java	Sun Feb 14 14:33:37 2010
@@ -64,10 +64,13 @@
     public LispObject getParts()
     {
         LispObject result = super.getParts().nreverse();
-        result = result.push(new Cons("DIRECT-SLOTS", directSlotDefinitions));
-        result = result.push(new Cons("SLOTS", slotDefinitions));
-        result = result.push(new Cons("DIRECT-DEFAULT-INITARGS", directDefaultInitargs));
-        result = result.push(new Cons("DEFAULT-INITARGS", defaultInitargs));
+        result = result.push(new Cons("DIRECT-SLOTS",
+                                      getDirectSlotDefinitions()));
+        result = result.push(new Cons("SLOTS", getSlotDefinitions()));
+        result = result.push(new Cons("DIRECT-DEFAULT-INITARGS",
+                                      getDirectDefaultInitargs()));
+        result = result.push(new Cons("DEFAULT-INITARGS",
+                                      getDefaultInitargs()));
         return result.nreverse();
     }
 
@@ -107,6 +110,11 @@
         this.directDefaultInitargs = directDefaultInitargs;
     }
 
+    public LispObject getDefaultInitargs()
+    {
+        return defaultInitargs;
+    }
+
     public void setDefaultInitargs(LispObject defaultInitargs)
     {
         this.defaultInitargs = defaultInitargs;
@@ -133,7 +141,8 @@
         if (isFinalized())
             return;
 
-        Debug.assertTrue(slotDefinitions == NIL);
+        LispObject defs = getSlotDefinitions();
+        Debug.assertTrue(defs == NIL);
         LispObject cpl = getCPL();
         Debug.assertTrue(cpl != null);
         Debug.assertTrue(cpl.listp());
@@ -142,20 +151,20 @@
             LispObject car = cpl.car();
             if (car instanceof StandardClass) {
                 StandardClass cls = (StandardClass) car;
-                LispObject defs = cls.getDirectSlotDefinitions();
-                Debug.assertTrue(defs != null);
-                Debug.assertTrue(defs.listp());
-                while (defs != NIL) {
-                    slotDefinitions = slotDefinitions.push(defs.car());
-                    defs = defs.cdr();
+                LispObject directDefs = cls.getDirectSlotDefinitions();
+                Debug.assertTrue(directDefs != null);
+                Debug.assertTrue(directDefs.listp());
+                while (directDefs != NIL) {
+                    defs = defs.push(directDefs.car());
+                    directDefs = directDefs.cdr();
                 }
             }
             cpl = cpl.cdr();
         }
-        slotDefinitions = slotDefinitions.nreverse();
-        LispObject[] instanceSlotNames = new LispObject[slotDefinitions.length()];
+        setSlotDefinitions(defs.nreverse());
+        LispObject[] instanceSlotNames = new LispObject[defs.length()];
         int i = 0;
-        LispObject tail = slotDefinitions;
+        LispObject tail = getSlotDefinitions();
         while (tail != NIL) {
             SlotDefinition slotDefinition = (SlotDefinition) tail.car();
             slotDefinition.setLocation(i);
@@ -176,7 +185,7 @@
 
         {
             if (arg instanceof SlotClass)
-                return ((SlotClass)arg).directSlotDefinitions;
+                return ((SlotClass)arg).getDirectSlotDefinitions();
             if (arg instanceof BuiltInClass)
                 return NIL;
             return type_error(arg, Symbol.STANDARD_CLASS);
@@ -192,7 +201,7 @@
 
         {
                 if (first instanceof SlotClass) {
-                ((SlotClass)first).directSlotDefinitions = second;
+                  ((SlotClass)first).setDirectSlotDefinitions(second);
                 return second;
             }
                 else {
@@ -210,7 +219,7 @@
 
         {
             if (arg instanceof SlotClass)
-                return ((SlotClass)arg).slotDefinitions;
+                return ((SlotClass)arg).getSlotDefinitions();
             if (arg instanceof BuiltInClass)
                 return NIL;
             return type_error(arg, Symbol.STANDARD_CLASS);
@@ -225,12 +234,12 @@
         public LispObject execute(LispObject first, LispObject second)
 
         {
-                if (first instanceof SlotClass) {
-                ((SlotClass)first).slotDefinitions = second;
-                return second;
+            if (first instanceof SlotClass) {
+              ((SlotClass)first).setSlotDefinitions(second);
+              return second;
             }
-                else {
-                return type_error(first, Symbol.STANDARD_CLASS);
+            else {
+              return type_error(first, Symbol.STANDARD_CLASS);
             }
         }
     };
@@ -244,7 +253,7 @@
 
         {
             if (arg instanceof SlotClass)
-                return ((SlotClass)arg).directDefaultInitargs;
+                return ((SlotClass)arg).getDirectDefaultInitargs();
             if (arg instanceof BuiltInClass)
                 return NIL;
             return type_error(arg, Symbol.STANDARD_CLASS);
@@ -259,11 +268,11 @@
         public LispObject execute(LispObject first, LispObject second)
 
         {
-                   if (first instanceof SlotClass) {                
-                           ((SlotClass)first).directDefaultInitargs = second;                
-                           return second;
-                   }
-                   return type_error(first, Symbol.STANDARD_CLASS);
+            if (first instanceof SlotClass) {
+              ((SlotClass)first).setDirectDefaultInitargs(second);
+              return second;
+            }
+            return type_error(first, Symbol.STANDARD_CLASS);
         }
     };
 
@@ -276,7 +285,7 @@
 
         {
             if (arg instanceof SlotClass)
-                return ((SlotClass)arg).defaultInitargs;
+                return ((SlotClass)arg).getDefaultInitargs();
             if (arg instanceof BuiltInClass)
                 return NIL;
             return type_error(arg, Symbol.STANDARD_CLASS);
@@ -292,7 +301,7 @@
 
         {
             if (first instanceof SlotClass) {
-                ((SlotClass)first).defaultInitargs = second;
+                ((SlotClass)first).setDefaultInitargs(second);
                 return second;
             }
             return type_error(first, Symbol.STANDARD_CLASS);




More information about the armedbear-cvs mailing list