Changeset 12713


Ignore:
Timestamp:
05/20/10 17:58:13 (11 years ago)
Author:
astalla
Message:

Serialization support for some Lisp types.
For symbols and packages, only the "identity" is serialized, i.e. package name + symbol name.
For packages, it is expected that a package of the same name exists "at the other side".
For symbols, the deserialized symbol is interned in its home package.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/AbstractArray.java

    r12298 r12713  
    3636import static org.armedbear.lisp.Lisp.*;
    3737
    38 public abstract class AbstractArray extends LispObject
     38public abstract class AbstractArray extends LispObject implements java.io.Serializable
    3939{
    4040    @Override
  • trunk/abcl/src/org/armedbear/lisp/Cons.java

    r12612 r12713  
    3636import static org.armedbear.lisp.Lisp.*;
    3737
    38 public final class Cons extends LispObject
     38public final class Cons extends LispObject implements java.io.Serializable
    3939{
    4040  public LispObject car;
  • trunk/abcl/src/org/armedbear/lisp/LispInteger.java

    r12429 r12713  
    3737 * Fixnum and Bignum
    3838 */
    39 public class LispInteger extends LispObject
     39public class LispInteger extends LispObject implements java.io.Serializable
    4040{
    4141
  • trunk/abcl/src/org/armedbear/lisp/Nil.java

    r12598 r12713  
    165165        return "NIL";
    166166    }
     167
     168    public Object readResolve() throws java.io.ObjectStreamException {
     169       return NIL;
     170    }
     171
    167172}
  • trunk/abcl/src/org/armedbear/lisp/Package.java

    r12712 r12713  
    4141import java.util.List;
    4242
    43 public final class Package extends LispObject
     43public final class Package extends LispObject implements java.io.Serializable
    4444{
    4545    private String name;
    46     private SimpleString lispName;
    47 
    48     private LispObject propertyList;
    49 
    50     private final SymbolHashTable internalSymbols = new SymbolHashTable(16);
    51     private final SymbolHashTable externalSymbols = new SymbolHashTable(16);
    52 
    53     private HashMap<String,Symbol> shadowingSymbols;
    54     private ArrayList<String> nicknames;
    55     private LispObject useList = null;
    56     private ArrayList<Package> usedByList = null;
     46    private transient SimpleString lispName;
     47
     48    private transient LispObject propertyList;
     49
     50    private transient final SymbolHashTable internalSymbols = new SymbolHashTable(16);
     51    private transient final SymbolHashTable externalSymbols = new SymbolHashTable(16);
     52
     53    private transient HashMap<String,Symbol> shadowingSymbols;
     54    private transient ArrayList<String> nicknames;
     55    private transient LispObject useList = null;
     56    private transient ArrayList<Package> usedByList = null;
    5757
    5858    // Anonymous package.
     
    849849            return unreadableString("PACKAGE");
    850850    }
     851
     852    public Object readResolve() throws java.io.ObjectStreamException {
     853  Package pkg = Packages.findPackage(name);
     854  if(pkg != null) {
     855      return pkg;
     856  } else {
     857      return error(new PackageError(name + " is not the name of a package."));
     858  }
     859    }
    851860}
  • trunk/abcl/src/org/armedbear/lisp/Symbol.java

    r12620 r12713  
    3636import static org.armedbear.lisp.Lisp.*;
    3737
    38 public class Symbol extends LispObject
     38public class Symbol extends LispObject implements java.io.Serializable
    3939{
    4040  // Bit flags.
     
    5656   * used to find the index in the LispThread.specials array
    5757   */
    58   int specialIndex = LispThread.UNASSIGNED_SPECIAL_INDEX;
     58  transient int specialIndex = LispThread.UNASSIGNED_SPECIAL_INDEX;
    5959  private LispObject pkg; // Either a package object or NIL.
    60   private LispObject value;
    61   private LispObject function;
    62   private LispObject propertyList;
     60  private transient LispObject value;
     61  private transient LispObject function;
     62  private transient LispObject propertyList;
    6363  private int flags;
    6464
     
    908908      function.incrementHotCount();
    909909  }
     910
     911    public Object readResolve() throws java.io.ObjectStreamException {
     912  if(pkg instanceof Package) {
     913      Symbol s = ((Package) pkg).intern(name.getStringValue());
     914      return s;
     915  } else {
     916      return this;
     917  }
     918    }
    910919
    911920
Note: See TracChangeset for help on using the changeset viewer.