[23856] users/rhwood/Pallet
source_changes at macosforge.org
source_changes at macosforge.org
Wed Apr 11 02:56:52 PDT 2007
Revision: 23856
http://trac.macosforge.org/projects/macports/changeset/23856
Author: rhwood at macports.org
Date: 2007-04-11 02:56:51 -0700 (Wed, 11 Apr 2007)
Log Message:
-----------
Use generic code to take strings from PortIndex and turn them into Arrays.
All arrays items in the Pallet PortIndex memory model also get a item_as_string string representation to keep the search code in the controller simple.
The indexing code could be cleaned up some.
Modified Paths:
--------------
users/rhwood/Pallet/MPPortsController.m
users/rhwood/Pallet/PortAuthority.m
Modified: users/rhwood/Pallet/MPPortsController.m
===================================================================
--- users/rhwood/Pallet/MPPortsController.m 2007-04-11 09:05:23 UTC (rev 23855)
+++ users/rhwood/Pallet/MPPortsController.m 2007-04-11 09:56:51 UTC (rev 23856)
@@ -12,13 +12,14 @@
NSEnumerator *objectsEnumerator = [objects objectEnumerator];
id item;
+ // the *_as_string objects are retained to make searching easy
while (item = [objectsEnumerator nextObject]) {
if ([[item valueForKeyPath:@"name"] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound ||
- [[item valueForKeyPath:@"categories"] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound ||
+ [[item valueForKeyPath:@"categories_as_string"] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound ||
[[item valueForKeyPath:@"description"] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound ||
[[item valueForKeyPath:@"long_description"] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound ||
[[item valueForKeyPath:@"homepage"] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound ||
- [[item valueForKeyPath:@"maintainers"] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound
+ [[item valueForKeyPath:@"maintainers_as_string"] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound
) {
[filteredObjects addObject:item];
}
Modified: users/rhwood/Pallet/PortAuthority.m
===================================================================
--- users/rhwood/Pallet/PortAuthority.m 2007-04-11 09:05:23 UTC (rev 23855)
+++ users/rhwood/Pallet/PortAuthority.m 2007-04-11 09:56:51 UTC (rev 23856)
@@ -172,6 +172,7 @@
NSEnumerator *valuesEnumerator;
int valuesCount;
int valuesCounter;
+ const char **valuesElements;
id line;
arrays = [[NSMutableArray alloc] init];
file = [[NSString alloc] initWithContentsOfFile:index];
@@ -185,20 +186,37 @@
}
}
indexEnumerator = [arrays objectEnumerator];
+ encoding = [NSString defaultCStringEncoding];
while (line = [indexEnumerator nextObject]) {
port = [[NSMutableDictionary alloc] init];
tclResult = Tcl_SplitList(NULL, [line cString], &tclCount, &tclElements);
if (tclResult == TCL_OK && !(tclCount % 2)) {
- encoding = [NSString defaultCStringEncoding];
for (counter = 0; counter < tclCount; counter+=2) {
key = [[NSString alloc] initWithCString:tclElements[counter] encoding:encoding];
- value = [[NSString alloc] initWithCString:tclElements[counter + 1] encoding:encoding];
+ if ([key isEqualToString:@"maintainers"] ||
+ [key isEqualToString:@"depends_lib"] ||
+ [key isEqualToString:@"categories"] ||
+ [key isEqualToString:@"depends_build"]) {
+ tclResult = Tcl_SplitList(NULL, tclElements[counter + 1], &valuesCount, &valuesElements);
+ if (tclResult == TCL_OK) {
+ values = [[NSMutableArray alloc] initWithCapacity:valuesCount];
+ for (valuesCounter = 0; valuesCounter < valuesCount; valuesCounter++) {
+ [values addObject:[[NSString alloc] initWithCString:valuesElements[valuesCounter] encoding:encoding]];
+ }
+ } else {
+ values = [[NSArray alloc] init];
+ }
+ value = [[NSArray alloc] initWithArray:values];
+ // create a string containing all the tokens so that it can be rapidly and easily searched
+ [port setValue:[[NSString alloc] initWithCString:tclElements[counter + 1] encoding:encoding] forKey:[key stringByAppendingString:@"_as_string"]];
+ } else {
+ value = [[NSString alloc] initWithCString:tclElements[counter + 1] encoding:encoding];
+ }
[port setValue:value forKey:key];
- NSLog(@"%@: %@\n", key, value);
+ //NSLog(@"%@: %@\n", key, value);
}
- [port setValue:[[port valueForKey:@"maintainer"] componentsSeparatedByString:@" "] forKey:@"maintainer"];
if ([port valueForKey:@"depends_lib"]) {
- values = [[NSMutableArray alloc] initWithArray:[[port valueForKey:@"depends_lib"] componentsSeparatedByString:@" "]];
+ values = [[NSMutableArray alloc] initWithArray:[port valueForKey:@"depends_lib"]];
valuesCount = [values count];
for (valuesCounter = 0; valuesCounter < valuesCount; valuesCounter++) {
value = [[[values objectAtIndex:valuesCounter] componentsSeparatedByString:@":"] lastObject];
@@ -207,7 +225,7 @@
[port setValue:[[NSArray alloc] initWithArray:values] forKey:@"depends_lib"];
}
if ([port valueForKey:@"depends_build"]) {
- values = [[NSMutableArray alloc] initWithArray:[[port valueForKey:@"depends_build"] componentsSeparatedByString:@" "]];
+ values = [[NSMutableArray alloc] initWithArray:[port valueForKey:@"depends_build"]];
valuesCount = [values count];
for (valuesCounter = 0; valuesCounter < valuesCount; valuesCounter++) {
value = [[[values objectAtIndex:valuesCounter] componentsSeparatedByString:@":"] lastObject];
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070411/e4ce5167/attachment.html
More information about the macports-changes
mailing list