Changeset 13358
- Timestamp:
- 06/22/11 10:38:34 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r13353 r13358 68 68 private volatile String namestring; 69 69 70 /** The protocol for changing any instance field (i.e. 'host', 'type', etc.) 71 * is to call this method after changing the field to recompute the namestring. 72 * We could do this with setter/getters, but that choose not to in order to avoid the 70 /** The protocol for changing any instance field (i.e. 'host', 71 * 'type', etc.) is to call this method after changing the field 72 * to recompute the namestring. We could do this with 73 * setter/getters, but that choose not to in order to avoid the 73 74 * performance indirection penalty. 75 * 76 * TODO There is no "perfomance penalty" in contemporary 77 * compilers which inline such access, so it would be better to 78 * implement this as setter/getter ME 20110622 74 79 * 75 80 * Although, given the number of bugs that crop up when this … … 80 85 } 81 86 82 // ### %invalidate-namestring 83 private static final Primitive _INVALIDATE_NAMESTRING = new pf_invalidate_namestring(); 87 private static final Primitive _INVALIDATE_NAMESTRING 88 = new pf_invalidate_namestring(); 89 @DocString(name="%invalidate-namestring", 90 args="pathname", 91 returns="pathname") 84 92 private static class pf_invalidate_namestring extends Primitive { 85 93 pf_invalidate_namestring() { … … 790 798 } 791 799 792 /** @return The representation of this pathname suitable for referencing an entry in a Zip/JAR file */ 800 /** @return The representation of this pathname suitable for 801 * referencing an entry in a Zip/JAR file 802 */ 793 803 protected String asEntryPath() { 794 804 Pathname p = new Pathname(); … … 1079 1089 } 1080 1090 } 1081 // ### %pathname-host 1091 1082 1092 private static final Primitive _PATHNAME_HOST = new pf_pathname_host(); 1093 @DocString(name="%pathname-host") 1083 1094 private static class pf_pathname_host extends Primitive { 1084 1095 pf_pathname_host() { … … 1087 1098 @Override 1088 1099 public LispObject execute(LispObject first, LispObject second) { 1089 checkCaseArgument(second); 1100 checkCaseArgument(second); // FIXME Why is this ignored? 1090 1101 return coerceToPathname(first).host; 1091 1102 } 1092 1103 } 1093 // ### %pathname-device1094 1104 private static final Primitive _PATHNAME_DEVICE = new pf_pathname_device(); 1105 @DocString(name="%pathname-device") 1095 1106 private static class pf_pathname_device extends Primitive { 1096 1107 pf_pathname_device() { … … 1099 1110 @Override 1100 1111 public LispObject execute(LispObject first, LispObject second) { 1101 checkCaseArgument(second); 1112 checkCaseArgument(second); // FIXME Why is this ignored? 1102 1113 return coerceToPathname(first).device; 1103 1114 } 1104 1115 } 1105 // ### %pathname-directory1106 1116 private static final Primitive _PATHNAME_DIRECTORY = new pf_pathname_directory(); 1117 @DocString(name="%pathname-directory") 1107 1118 private static class pf_pathname_directory extends Primitive { 1108 1119 pf_pathname_directory() { … … 1111 1122 @Override 1112 1123 public LispObject execute(LispObject first, LispObject second) { 1113 checkCaseArgument(second); 1124 checkCaseArgument(second); // FIXME Why is this ignored? 1114 1125 return coerceToPathname(first).directory; 1115 1126 } 1116 1127 } 1117 // ### %pathname-name1118 1128 private static final Primitive _PATHNAME_NAME = new pf_pathname_name(); 1129 @DocString(name="%pathname-name") 1119 1130 private static class pf_pathname_name extends Primitive { 1120 1131 pf_pathname_name() { … … 1123 1134 @Override 1124 1135 public LispObject execute(LispObject first, LispObject second) { 1125 checkCaseArgument(second); 1136 checkCaseArgument(second); // FIXME Why is this ignored? 1126 1137 return coerceToPathname(first).name; 1127 1138 } 1128 1139 } 1129 // ### %pathname-type1130 1140 private static final Primitive _PATHNAME_TYPE = new pf_pathname_type(); 1141 @DocString(name="%pathname-type") 1131 1142 private static class pf_pathname_type extends Primitive { 1132 1143 pf_pathname_type() { … … 1135 1146 @Override 1136 1147 public LispObject execute(LispObject first, LispObject second) { 1137 checkCaseArgument(second); 1148 checkCaseArgument(second); // FIXME Why is this ignored? 1138 1149 return coerceToPathname(first).type; 1139 1150 } 1140 1151 } 1141 // ### pathname-version1152 1142 1153 private static final Primitive PATHNAME_VERSION = new pf_pathname_version(); 1154 @DocString(name="pathname-version", 1155 args="pathname", 1156 returns="version", 1157 doc="Return the version component of PATHNAME.") 1143 1158 private static class pf_pathname_version extends Primitive { 1144 1159 pf_pathname_version() { … … 1150 1165 } 1151 1166 } 1152 // ### namestring1153 // namestring pathname => namestring1154 1167 private static final Primitive NAMESTRING = new pf_namestring(); 1168 @DocString(name="namestring", 1169 args="pathname", 1170 returns="namestring", 1171 doc="Returns the NAMESTRING of PATHNAME if it has one.\n" 1172 + "\n" 1173 + "If PATHNAME is of type url-pathname or jar-pathname the NAMESTRING is encoded\n" 1174 + "according to the uri percent escape rules.\n" 1175 + "\n" 1176 + "Signals an error if PATHNAME lacks a printable NAMESTRING representation.\n") 1155 1177 private static class pf_namestring extends Primitive { 1156 1178 pf_namestring() { … … 1168 1190 } 1169 1191 } 1170 // ### directory-namestring 1171 // directory-namestring pathname => namestring 1192 1172 1193 private static final Primitive DIRECTORY_NAMESTRING = new pf_directory_namestring(); 1194 // TODO clarify uri encoding rules in implementation, then document 1195 @DocString(name="directory-namestring", 1196 args="pathname", 1197 returns="namestring", 1198 doc="Returns the NAMESTRING of directory porition of PATHNAME if it has one.") 1173 1199 private static class pf_directory_namestring extends Primitive { 1174 1200 pf_directory_namestring() { … … 1180 1206 } 1181 1207 } 1182 // ### pathname pathspec => pathname1183 1208 private static final Primitive PATHNAME = new pf_pathname(); 1209 @DocString(name="pathname", 1210 args="pathspec", 1211 returns="pathname", 1212 doc="Returns the PATHNAME denoted by PATHSPEC.") 1184 1213 private static class pf_pathname extends Primitive { 1185 1214 pf_pathname() { … … 1191 1220 } 1192 1221 } 1193 // ### %parse-namestring string host default-pathname => pathname, position1194 1222 private static final Primitive _PARSE_NAMESTRING = new pf_parse_namestring(); 1223 @DocString(name="%parse-namestring", 1224 args="namestring host default-pathname", 1225 returns="pathname, position") 1195 1226 private static class pf_parse_namestring extends Primitive { 1196 1227 pf_parse_namestring() { … … 1223 1254 } 1224 1255 } 1225 // ### make-pathname1226 1256 private static final Primitive MAKE_PATHNAME = new pf_make_pathname(); 1257 @DocString(name="make-pathname", 1258 args="&key host device directory name type version defaults case", 1259 returns="pathname", 1260 doc="Constructs and returns a pathname from the supplied keyword arguments.") 1227 1261 private static class pf_make_pathname extends Primitive { 1228 1262 pf_make_pathname() { … … 1447 1481 return true; 1448 1482 } 1449 // ### pathnamep1450 1483 private static final Primitive PATHNAMEP = new pf_pathnamep(); 1484 @DocString(name="pathnamep", 1485 args="object", 1486 returns="generalized-boolean", 1487 doc="Returns true if OBJECT is of type pathname; otherwise, returns false.") 1451 1488 private static class pf_pathnamep extends Primitive { 1452 1489 pf_pathnamep() { … … 1458 1495 } 1459 1496 } 1460 // ### logical-pathname-p1461 1497 private static final Primitive LOGICAL_PATHNAME_P = new pf_logical_pathname_p(); 1498 @DocString(name="logical-pathname-p", 1499 args="object", 1500 returns="generalized-boolean", 1501 1502 doc="Returns true if OBJECT is of type logical-pathname; otherwise, returns false.") 1462 1503 private static class pf_logical_pathname_p extends Primitive { 1463 1504 pf_logical_pathname_p() { … … 1469 1510 } 1470 1511 } 1471 // ### user-homedir-pathname &optional host => pathname 1512 1472 1513 private static final Primitive USER_HOMEDIR_PATHNAME = new pf_user_homedir_pathname(); 1514 @DocString(name="user-homedir-pathname", 1515 args="&optional host", 1516 returns="pathname", 1517 doc="Determines the pathname that corresponds to the user's home directory.\n" 1518 + "The value returned is obtained from the JVM system propoerty 'user.home'.\n" 1519 + "If HOST is specified, returns NIL.") 1473 1520 private static class pf_user_homedir_pathname extends Primitive { 1474 1521 pf_user_homedir_pathname() { … … 1493 1540 } 1494 1541 1495 // ### list-directory directory1496 1542 private static final Primitive LIST_DIRECTORY = new pf_list_directory(); 1543 @DocString(name="list-directory", 1544 args="directory &optional (resolve-symlinks t)", 1545 returns="pathnames", 1546 doc="Lists the contents of DIRECTORY, optionally resolving symbolic links.") 1497 1547 private static class pf_list_directory extends Primitive { 1498 1548 pf_list_directory() { … … 1594 1644 } 1595 1645 1596 // ### match-wild-jar-pathname wild-jar-pathname 1646 @DocString(name="match-wild-jar-pathname", 1647 args="wild-jar-pathname", 1648 returns="pathnames", 1649 doc="Returns the pathnames matching WILD-JAR-PATHNAME which is both wild and a jar-pathname.") 1597 1650 static final Primitive MATCH_WILD_JAR_PATHNAME = new pf_match_wild_jar_pathname(); 1598 1651 private static class pf_match_wild_jar_pathname extends Primitive { … … 1697 1750 } 1698 1751 1699 // ### PATHNAME-JAR-P 1752 @DocString(name="pathname-jar-p", 1753 args="pathname", 1754 returns="generalized-boolean", 1755 doc="Predicate functionfor whether PATHNAME references a jar.") 1700 1756 private static final Primitive PATHNAME_JAR_P = new pf_pathname_jar_p(); 1701 1757 private static class pf_pathname_jar_p extends Primitive { 1702 1758 pf_pathname_jar_p() { 1703 super("pathname-jar-p", PACKAGE_EXT, true, "pathname", 1704 "Predicate for whether PATHNAME references a JAR."); 1759 super("pathname-jar-p", PACKAGE_EXT, true); 1705 1760 } 1706 1761 @Override … … 1715 1770 } 1716 1771 1717 // ### PATHNAME-URL-P 1772 @DocString(name="pathname-url-p", 1773 args="pathname", 1774 returns="generalized-boolean", 1775 doc="Predicate function for whether PATHNAME references a jaurl.") 1718 1776 private static final Primitive PATHNAME_URL_P = new pf_pathname_url_p(); 1719 1777 private static class pf_pathname_url_p extends Primitive { … … 1782 1840 return false; 1783 1841 } 1784 // ### %wild-pathname-p 1842 1785 1843 private static final Primitive _WILD_PATHNAME_P = new pf_wild_pathname_p(); 1844 @DocString(name="%wild-pathname-p", 1845 args="pathname keyword", 1846 returns="generalized-boolean", 1847 doc="Predicate for determing whether PATHNAME contains wild components.\n" 1848 + "KEYWORD, if non-nil, should be one of :directory, :host, :device,\n" 1849 + ":name, :type, or :version indicating that only the specified component\n" 1850 + "should be checked for wildness.") 1786 1851 static final class pf_wild_pathname_p extends Primitive { 1787 1852 pf_wild_pathname_p() { … … 1828 1893 } 1829 1894 1830 // ### merge-pathnames pathname &optional default-pathname default-version"1831 1895 private static final Primitive MERGE_PATHNAMES = new pf_merge_pathnames(); 1896 @DocString(name="merge-pathnames", 1897 args="pathname &optional default-pathname default-version", 1898 returns="pathname", 1899 doc="Constructs a pathname from PATHNAME by filling in any unsupplied components\n" 1900 + "with the corresponding values from DEFAULT-PATHNAME and DEFAULT-VERSION.") 1832 1901 static final class pf_merge_pathnames extends Primitive { 1833 1902 pf_merge_pathnames() { … … 2309 2378 } 2310 2379 2311 // ### mkdir pathname2312 2380 private static final Primitive MKDIR = new pf_mkdir(); 2381 @DocString(name="mkdir", 2382 args="pathname", 2383 returns="generalized-boolean", 2384 doc="Attempts to create directory at PATHNAME returning the success or failure.") 2313 2385 private static class pf_mkdir extends Primitive { 2314 2386 pf_mkdir() { … … 2338 2410 } 2339 2411 2340 // ### rename-file filespec new-name => defaulted-new-name, old-truename, new-truename2341 2412 private static final Primitive RENAME_FILE = new pf_rename_file(); 2413 @DocString(name="rename-file", 2414 args="filespec new-name", 2415 returns="defaulted-new-name, old-truename, new-truename", 2416 doc="rename-file modifies the file system in such a way that the file indicated by FILESPEC is renamed to DEFAULTED-NEW-NAME.") 2342 2417 private static class pf_rename_file extends Primitive { 2343 2418 pf_rename_file() { … … 2392 2467 } 2393 2468 } 2394 2395 // ### file-namestring pathname => namestring2469 2470 // TODO clarify uri encoding cases in implementation and document 2396 2471 private static final Primitive FILE_NAMESTRING = new pf_file_namestring(); 2472 @DocString(name="file-namestring", 2473 args="pathname", 2474 returns="namestring", 2475 doc="Returns just the name, type, and version components of PATHNAME.") 2397 2476 private static class pf_file_namestring extends Primitive { 2398 2477 pf_file_namestring() { … … 2420 2499 } 2421 2500 2422 // ### host-namestring pathname => namestring2423 2501 private static final Primitive HOST_NAMESTRING = new pf_host_namestring(); 2502 @DocString(name="host-namestring", 2503 args="pathname", 2504 returns="namestring", 2505 doc="Returns the host name of PATHNAME.") 2424 2506 private static class pf_host_namestring extends Primitive { 2425 2507 pf_host_namestring() { … … 2464 2546 2465 2547 @DocString(name="uri-decode", 2466 args="string => string", 2467 doc="Decode percent escape sequences in the manner of URI encodings.") 2548 args="string", 2549 returns="string", 2550 doc="Decode STRING percent escape sequences in the manner of URI encodings.") 2468 2551 private static final Primitive URI_DECODE = new pf_uri_decode(); 2469 2552 private static final class pf_uri_decode extends Primitive { … … 2489 2572 } 2490 2573 2491 @DocString(name="uri-encode", 2492 args="string => string", 2493 doc="Encode percent escape sequences in the manner of URI encodings.") 2574 @DocString(name="uri-encode", 2575 args="string", 2576 returns="string", 2577 doc="Encode percent escape sequences in the manner of URI encodings.") 2494 2578 private static final Primitive URI_ENCODE = new pf_uri_encode(); 2495 2579 private static final class pf_uri_encode extends Primitive {
Note: See TracChangeset
for help on using the changeset viewer.