Changeset 5296


Ignore:
Timestamp:
01/01/04 01:32:18 (18 years ago)
Author:
piso
Message:

Work in progress.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Pathname.java

    r5295 r5296  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: Pathname.java,v 1.23 2004-01-01 00:40:35 piso Exp $
     5 * $Id: Pathname.java,v 1.24 2004-01-01 01:32:18 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    181181    }
    182182
    183     // ### pathname-host
    184     private static final Primitive PATHNAME_HOST =
    185         new Primitive("pathname-host", "pathname &key case")
    186     {
    187         public LispObject execute(LispObject arg) throws ConditionThrowable
    188         {
    189             return coerceToPathname(arg).host;
    190         }
    191     };
    192 
    193     // ### pathname-device
    194     private static final Primitive PATHNAME_DEVICE =
    195         new Primitive("pathname-device", "pathname &key case")
    196     {
    197         public LispObject execute(LispObject arg) throws ConditionThrowable
    198         {
    199             return coerceToPathname(arg).device;
    200         }
    201     };
    202 
    203     // ### pathname-directory
    204     private static final Primitive PATHNAME_DIRECTORY =
    205         new Primitive("pathname-directory", "pathname &key case")
    206     {
    207         public LispObject execute(LispObject arg) throws ConditionThrowable
    208         {
    209             return coerceToPathname(arg).directory;
    210         }
    211     };
    212 
    213     // ### pathname-name
    214     private static final Primitive PATHNAME_NAME =
    215         new Primitive("pathname-name", "pathname &key case")
    216     {
    217         public LispObject execute(LispObject arg) throws ConditionThrowable
    218         {
    219             return coerceToPathname(arg).name;
    220         }
    221     };
    222 
    223     // ### pathname-type
    224     private static final Primitive PATHNAME_TYPE =
    225         new Primitive("pathname-type", "pathname &key case")
    226     {
    227         public LispObject execute(LispObject arg) throws ConditionThrowable
    228         {
    229             return coerceToPathname(arg).type;
    230         }
    231     };
    232 
    233     // ### pathname-version
    234     private static final Primitive PATHNAME_VERSION =
    235         new Primitive("pathname-version", "pathname &key case")
     183    private static final void checkCaseArgument(LispObject arg)
     184        throws ConditionThrowable
     185    {
     186        if (arg != Keyword.COMMON && arg != Keyword.LOCAL)
     187            signal(new TypeError(arg, list3(Symbol.MEMBER, Keyword.COMMON,
     188                                            Keyword.LOCAL)));
     189    }
     190
     191    private static final Primitive2 _PATHNAME_HOST =
     192        new Primitive2("%pathname-host", PACKAGE_SYS, false)
     193    {
     194        public LispObject execute(LispObject first, LispObject second)
     195            throws ConditionThrowable
     196        {
     197            checkCaseArgument(second);
     198            return coerceToPathname(first).host;
     199        }
     200    };
     201
     202    private static final Primitive2 _PATHNAME_DEVICE =
     203        new Primitive2("%pathname-device", PACKAGE_SYS, false)
     204    {
     205        public LispObject execute(LispObject first, LispObject second)
     206            throws ConditionThrowable
     207        {
     208            checkCaseArgument(second);
     209            return coerceToPathname(first).device;
     210        }
     211    };
     212
     213    private static final Primitive2 _PATHNAME_DIRECTORY =
     214        new Primitive2("%pathname-directory", PACKAGE_SYS, false)
     215    {
     216        public LispObject execute(LispObject first, LispObject second)
     217            throws ConditionThrowable
     218        {
     219            checkCaseArgument(second);
     220            return coerceToPathname(first).directory;
     221        }
     222    };
     223
     224    private static final Primitive2 _PATHNAME_NAME =
     225        new Primitive2("%pathname-name", PACKAGE_SYS, false)
     226    {
     227        public LispObject execute(LispObject first, LispObject second)
     228            throws ConditionThrowable
     229        {
     230            checkCaseArgument(second);
     231            return coerceToPathname(first).name;
     232        }
     233    };
     234
     235    private static final Primitive2 _PATHNAME_TYPE =
     236        new Primitive2("%pathname-type", PACKAGE_SYS, false)
     237    {
     238        public LispObject execute(LispObject first, LispObject second)
     239            throws ConditionThrowable
     240        {
     241            checkCaseArgument(second);
     242            return coerceToPathname(first).host;
     243        }
     244    };
     245
     246    private static final Primitive1 PATHNAME_VERSION =
     247        new Primitive1("pathname-version", "pathname")
    236248    {
    237249        public LispObject execute(LispObject arg) throws ConditionThrowable
     
    327339        }
    328340    };
    329 
    330 //     // ### pathname-type
    331 //     private static final Primitive1 PATHNAME_TYPE =
    332 //         new Primitive1("pathname-type", "pathname &key case")
    333 //     {
    334 //         public LispObject execute(LispObject arg) throws ConditionThrowable
    335 //         {
    336 //             String namestring;
    337 //             if (arg instanceof LispString)
    338 //                 namestring = ((LispString)arg).getValue();
    339 //             else if (arg instanceof Pathname)
    340 //                 namestring = ((Pathname)arg).getNamestring();
    341 //             else
    342 //                 return signal(new TypeError(arg, "pathname designator"));
    343 //             if (namestring != null) {
    344 //                 for (int i = namestring.length(); i-- > 0;) {
    345 //                     char c = namestring.charAt(i);
    346 //                     if (c == '.')
    347 //                         return new LispString(namestring.substring(i + 1));
    348 //                 }
    349 //             }
    350 //             return NIL;
    351 //         }
    352 //     };
    353341
    354342    // ### user-homedir-pathname
Note: See TracChangeset for help on using the changeset viewer.