public
Description: The Nu programming language.
Homepage: http://programming.nu
Clone URL: git://github.com/timburks/nu.git
A few basic enhancements.

* Moved several commonly-used methods from Nu to Objective-C.
* Added instanceMethodNames and classMethodNames methods to
  make introspection easier.
* Added new method "mapSelector:" to the NuEnumerable mixin.
* Added tests for enumerable methods and (NSString +lines).
* Modified library nuke task to skip lipo for single-target
  libraries.
timburks (author)
Thu Apr 24 13:48:03 -0700 2008
commit  86aea2e982b15dd231aa9344540e00539ab2b46c
tree    97d0d48a00a595d59c2eb30ab3ddd5be8e206370
parent  19334d34bc74c85067908ea123e94d5a16fd7131
...
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
...
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
...
984
985
986
987
 
988
...
365
366
367
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
369
370
...
396
397
398
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
400
401
...
828
829
830
 
831
832
0
@@ -365,39 +365,6 @@ _nucell(_nusymbol((const char[]){115,101,108,102,0}),
0
 _nunull())))))))),
0
 _nunull()))),
0
 _nucell(_nucell(_nusymbol((const char[]){99,108,97,115,115,0}),
0
-_nucell(_nusymbol((const char[]){78,83,65,114,114,97,121,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){45,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){105,100,0}),
0
-_nunull()),
0
-_nucell(_nusymbol((const char[]){115,111,114,116,0}),
0
-_nucell(_nusymbol((const char[]){105,115,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){115,101,108,102,0}),
0
-_nucell(_nusymbol((const char[]){115,111,114,116,101,100,65,114,114,97,121,85,115,105,110,103,83,101,108,101,99,116,111,114,58,0}),
0
-_nucell(_nustring((const char[]){99,111,109,112,97,114,101,58,0}),
0
-_nunull()))),
0
-_nunull()))))),
0
-_nucell(_nucell(_nusymbol((const char[]){45,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){105,100,0}),
0
-_nunull()),
0
-_nucell(_nusymbol((const char[]){108,105,115,116,0}),
0
-_nucell(_nusymbol((const char[]){105,115,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){115,101,108,102,0}),
0
-_nucell(_nusymbol((const char[]){114,101,100,117,99,101,76,101,102,116,58,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){100,111,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){114,101,115,117,108,116,0}),
0
-_nucell(_nusymbol((const char[]){105,116,101,109,0}),
0
-_nunull())),
0
-_nucell(_nucell(_nusymbol((const char[]){99,111,110,115,0}),
0
-_nucell(_nusymbol((const char[]){105,116,101,109,0}),
0
-_nucell(_nusymbol((const char[]){114,101,115,117,108,116,0}),
0
-_nunull()))),
0
-_nunull()))),
0
-_nucell(_nusymbol((const char[]){102,114,111,109,58,0}),
0
-_nucell(_nusymbol((const char[]){110,105,108,0}),
0
-_nunull()))))),
0
-_nunull()))))),
0
-_nunull())))),
0
-_nucell(_nucell(_nusymbol((const char[]){99,108,97,115,115,0}),
0
 _nucell(_nusymbol((const char[]){78,83,77,117,116,97,98,108,101,65,114,114,97,121,0}),
0
 _nucell(_nucell(_nusymbol((const char[]){45,0}),
0
 _nucell(_nucell(_nusymbol((const char[]){118,111,105,100,0}),
0
@@ -429,129 +396,6 @@ _nucell(_nusymbol((const char[]){111,98,106,101,99,116,0}),
0
 _nunull()))),
0
 _nunull()))))))),
0
 _nunull()))),
0
-_nucell(_nucell(_nusymbol((const char[]){99,108,97,115,115,0}),
0
-_nucell(_nusymbol((const char[]){78,83,68,105,99,116,105,111,110,97,114,121,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){45,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){105,100,0}),
0
-_nunull()),
0
-_nucell(_nusymbol((const char[]){101,97,99,104,58,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){105,100,0}),
0
-_nunull()),
0
-_nucell(_nusymbol((const char[]){98,108,111,99,107,0}),
0
-_nucell(_nusymbol((const char[]){105,115,0}),
0
-_nucell(_nucell(_nucell(_nusymbol((const char[]){115,101,108,102,0}),
0
-_nucell(_nusymbol((const char[]){97,108,108,75,101,121,115,0}),
0
-_nunull())),
0
-_nucell(_nusymbol((const char[]){101,97,99,104,58,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){100,111,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){107,101,121,0}),
0
-_nunull()),
0
-_nucell(_nucell(_nusymbol((const char[]){98,108,111,99,107,0}),
0
-_nucell(_nusymbol((const char[]){107,101,121,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){115,101,108,102,0}),
0
-_nucell(_nusymbol((const char[]){111,98,106,101,99,116,70,111,114,75,101,121,58,0}),
0
-_nucell(_nusymbol((const char[]){107,101,121,0}),
0
-_nunull()))),
0
-_nunull()))),
0
-_nunull()))),
0
-_nunull()))),
0
-_nunull()))))))),
0
-_nunull()))),
0
-_nucell(_nucell(_nusymbol((const char[]){99,108,97,115,115,0}),
0
-_nucell(_nusymbol((const char[]){78,83,83,116,114,105,110,103,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){45,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){105,100,0}),
0
-_nunull()),
0
-_nucell(_nusymbol((const char[]){115,121,109,98,111,108,86,97,108,117,101,0}),
0
-_nucell(_nusymbol((const char[]){105,115,0}),
0
-_nucell(_nucell(_nucell(_nusymbol((const char[]){78,117,83,121,109,98,111,108,84,97,98,108,101,0}),
0
-_nucell(_nusymbol((const char[]){115,104,97,114,101,100,83,121,109,98,111,108,84,97,98,108,101,0}),
0
-_nunull())),
0
-_nucell(_nusymbol((const char[]){115,121,109,98,111,108,87,105,116,104,83,116,114,105,110,103,58,0}),
0
-_nucell(_nusymbol((const char[]){115,101,108,102,0}),
0
-_nunull()))),
0
-_nunull()))))),
0
-_nucell(_nucell(_nusymbol((const char[]){45,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){105,100,0}),
0
-_nunull()),
0
-_nucell(_nusymbol((const char[]){108,105,110,101,115,0}),
0
-_nucell(_nusymbol((const char[]){105,115,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){108,101,116,0}),
0
-_nucell(_nucell(_nucell(_nusymbol((const char[]){97,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){115,101,108,102,0}),
0
-_nucell(_nusymbol((const char[]){99,111,109,112,111,110,101,110,116,115,83,101,112,97,114,97,116,101,100,66,121,83,116,114,105,110,103,58,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){78,83,83,116,114,105,110,103,0}),
0
-_nucell(_nusymbol((const char[]){99,97,114,114,105,97,103,101,82,101,116,117,114,110,0}),
0
-_nunull())),
0
-_nunull()))),
0
-_nunull())),
0
-_nunull()),
0
-_nucell(_nucell(_nusymbol((const char[]){105,102,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){101,113,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){97,0}),
0
-_nucell(_nusymbol((const char[]){108,97,115,116,79,98,106,101,99,116,0}),
0
-_nunull())),
0
-_nucell(_nustring((const char[]){0}),
0
-_nunull()))),
0
-_nucell(_nucell(_nusymbol((const char[]){116,104,101,110,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){97,0}),
0
-_nucell(_nusymbol((const char[]){115,117,98,97,114,114,97,121,87,105,116,104,82,97,110,103,101,58,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){108,105,115,116,0}),
0
-_nucell(_nunumberd(0),
0
-_nucell(_nucell(_nusymbol((const char[]){45,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){97,0}),
0
-_nucell(_nusymbol((const char[]){99,111,117,110,116,0}),
0
-_nunull())),
0
-_nucell(_nunumberd(1),
0
-_nunull()))),
0
-_nunull()))),
0
-_nunull()))),
0
-_nunull())),
0
-_nucell(_nucell(_nusymbol((const char[]){101,108,115,101,0}),
0
-_nucell(_nusymbol((const char[]){97,0}),
0
-_nunull())),
0
-_nunull())))),
0
-_nunull()))),
0
-_nunull()))))),
0
-_nucell(_nucell(_nusymbol((const char[]){45,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){105,100,0}),
0
-_nunull()),
0
-_nucell(_nusymbol((const char[]){114,101,112,108,97,99,101,83,116,114,105,110,103,58,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){105,100,0}),
0
-_nunull()),
0
-_nucell(_nusymbol((const char[]){116,97,114,103,101,116,0}),
0
-_nucell(_nusymbol((const char[]){119,105,116,104,83,116,114,105,110,103,58,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){105,100,0}),
0
-_nunull()),
0
-_nucell(_nusymbol((const char[]){114,101,112,108,97,99,101,109,101,110,116,0}),
0
-_nucell(_nusymbol((const char[]){105,115,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){108,101,116,0}),
0
-_nucell(_nucell(_nucell(_nusymbol((const char[]){115,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){78,83,77,117,116,97,98,108,101,83,116,114,105,110,103,0}),
0
-_nucell(_nusymbol((const char[]){115,116,114,105,110,103,87,105,116,104,83,116,114,105,110,103,58,0}),
0
-_nucell(_nusymbol((const char[]){115,101,108,102,0}),
0
-_nunull()))),
0
-_nunull())),
0
-_nunull()),
0
-_nucell(_nucell(_nusymbol((const char[]){115,0}),
0
-_nucell(_nusymbol((const char[]){114,101,112,108,97,99,101,79,99,99,117,114,114,101,110,99,101,115,79,102,83,116,114,105,110,103,58,0}),
0
-_nucell(_nusymbol((const char[]){116,97,114,103,101,116,0}),
0
-_nucell(_nusymbol((const char[]){119,105,116,104,83,116,114,105,110,103,58,0}),
0
-_nucell(_nusymbol((const char[]){114,101,112,108,97,99,101,109,101,110,116,0}),
0
-_nucell(_nusymbol((const char[]){111,112,116,105,111,110,115,58,0}),
0
-_nucell(_nusymbol((const char[]){110,105,108,0}),
0
-_nucell(_nusymbol((const char[]){114,97,110,103,101,58,0}),
0
-_nucell(_nucell(_nusymbol((const char[]){108,105,115,116,0}),
0
-_nucell(_nunumberd(0),
0
-_nucell(_nucell(_nusymbol((const char[]){115,101,108,102,0}),
0
-_nucell(_nusymbol((const char[]){108,101,110,103,116,104,0}),
0
-_nunull())),
0
-_nunull()))),
0
-_nunull()))))))))),
0
-_nucell(_nusymbol((const char[]){115,0}),
0
-_nunull())))),
0
-_nunull())))))))))),
0
-_nunull()))))),
0
 _nucell(_nucell(_nusymbol((const char[]){105,102,0}),
0
 _nucell(_nucell(_nusymbol((const char[]){101,113,0}),
0
 _nucell(_nucell(_nusymbol((const char[]){117,110,97,109,101,0}),
0
@@ -984,5 +828,5 @@ _nunull()))),
0
 _nunull()))))))))))),
0
 _nunull()))))))))),
0
 _nunull()))),
0
-_nunull()))))))))))))))))))))));
0
+_nunull())))))))))))))))))));
0
 }
...
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
...
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
64
65
66
 
 
 
 
 
 
 
 
 
 
67
68
69
...
74
75
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
78
79
0
@@ -64,16 +64,6 @@
0
                                              (else (self setValue:value forKey:label))))))
0
         self))
0
 
0
-(class NSArray
0
-
0
- ;; This default sort method sorts an array using its elements' compare: method.
0
- (- (id) sort is
0
- (self sortedArrayUsingSelector:"compare:"))
0
-
0
- ;; Convert an array into a list.
0
- (- (id) list is
0
- (self reduceLeft:(do (result item) (cons item result)) from: nil)))
0
-
0
 (class NSMutableArray
0
      
0
      ;; Concisely add objects to arrays using this method, which is equivalent to a call to addObject:.
0
@@ -84,24 +74,6 @@
0
      ;; Concisely add objects to sets using this method, which is equivalent to a call to addObject:.
0
      (- (void) << (id) object is (self addObject:object)))
0
 
0
-(class NSString
0
-
0
- ;; Convert a string into a symbol.
0
- (- (id) symbolValue is ((NuSymbolTable sharedSymbolTable) symbolWithString:self))
0
-
0
- ;; Split a string into lines.
0
- (- (id) lines is
0
- (let ((a (self componentsSeparatedByString:(NSString carriageReturn))))
0
- (if (eq (a lastObject) "")
0
- (then (a subarrayWithRange:(list 0 (- (a count) 1))))
0
- (else a))))
0
-
0
- ;; Replace a substring with another.
0
- (- (id) replaceString:(id) target withString:(id) replacement is
0
- (let ((s (NSMutableString stringWithString:self)))
0
- (s replaceOccurrencesOfString:target withString:replacement options:nil range:(list 0 (self length)))
0
- s)))
0
-
0
 (if (eq (uname) "Darwin")
0
     (class NuCell
0
          ;; Convert a list into an NSRect. The list must have at least four elements.
...
52
53
54
 
 
 
 
55
56
57
...
52
53
54
55
56
57
58
59
60
61
0
@@ -52,6 +52,10 @@ Beware, some of these classes may be deprecated, undocumented, or otherwise unsa
0
 - (NSArray *) classMethods;
0
 /*! Get an array containing NuMethod representations of the instance methods of a class. */
0
 - (NSArray *) instanceMethods;
0
+/*! Get an array containing the names of the class methods of a class. */
0
+- (NSArray *) classMethodNames;
0
+/*! Get an array containing the names of the instance methods of a class. */
0
+- (NSArray *) instanceMethodNames;
0
 /*! Determine whether a class is derived from another class. */
0
 - (BOOL) isDerivedFromClass:(Class) parent;
0
 /*! Compare a class with another class by name. This allows arrays of classes to be easily sorted. */
...
139
140
141
 
 
 
 
 
 
 
 
 
 
 
 
142
143
144
...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
0
@@ -139,6 +139,18 @@ limitations under the License.
0
     return array;
0
 }
0
 
0
+/*! Get an array containing the names of the class methods of a class. */
0
+- (NSArray *) classMethodNames
0
+{
0
+ return [[self classMethods] mapSelector:@selector(name)];
0
+}
0
+
0
+/*! Get an array containing the names of the instance methods of a class. */
0
+- (NSArray *) instanceMethodNames
0
+{
0
+ return [[self instanceMethods] mapSelector:@selector(name)];
0
+}
0
+
0
 - (BOOL) isDerivedFromClass:(Class) parent
0
 {
0
     Class myclass = [self wrappedClass];
...
35
36
37
38
39
 
 
40
41
42
43
 
 
44
45
 
 
46
47
48
49
50
51
 
 
52
53
54
 
55
...
35
36
37
 
 
38
39
40
41
 
 
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
58
59
0
@@ -35,21 +35,25 @@ limitations under the License.
0
 /*! Iterate over each member of a collection, evaluating the provided block for each member.
0
     The block is expected to take two arguments: the member and its index. */
0
 - (id) eachWithIndex:(NuBlock *) block;
0
-/*! Iterate over each member of a collection, returning a list containing the elements for which the provided block evaluates non-nil. */
0
-- (id) select:(NuBlock *) block;
0
+/*! Iterate over each member of a collection, returning an array containing the elements for which the provided block evaluates non-nil. */
0
+- (NSArray *) select:(NuBlock *) block;
0
 /*! Iterate over each member of a collection, returning the first element for which the provided block evaluates non-nil. */
0
 - (id) find:(NuBlock *) block;
0
-/*! Iterate over each member of a collection, applying the provided block to each member, and returning a list of the results. */
0
-- (id) map:(NuBlock *) block;
0
+/*! Iterate over each member of a collection, applying the provided block to each member, and returning an array of the results. */
0
+- (NSArray *) map:(NuBlock *) block;
0
 /*! Iterate over each member of a collection, using the provided block to combine members into a single return value. */
0
 - (id) reduce:(NuBlock *) block from:(id) initial;
0
+/*! Iterate over each member of a collection, applying the provided selector to each member, and returning an array of the results. */
0
+- (NSArray *) mapSelector:(SEL) selector;
0
 @end
0
 
0
 @interface NSArray (Enumeration)
0
 /*! Repeatedly apply a function of two arguments to the elements of an array,
0
 working from right to left and beginning with the specified inital value. */
0
 - (id) reduceLeft:(NuBlock *) block from:(id) initial;
0
+/*! Iterate over each member of an array in reverse order and beginning with the lastObject, evaluating the provided block for each member. */
0
+- (id) eachInReverse:(NuBlock *) block;
0
 /*! Return a sorted array using the specified block to compare array elements.
0
 The block should return -1, 0, or 1. */
0
-- (id) sortedArrayUsingBlock:(NuBlock *) block;
0
+- (NSArray *) sortedArrayUsingBlock:(NuBlock *) block;
0
 @end
...
1
2
3
 
4
5
6
...
61
62
63
64
 
65
66
67
...
99
100
101
102
 
103
104
105
...
115
116
117
 
 
 
 
 
 
 
 
 
 
 
 
118
119
120
...
200
201
202
203
204
205
206
...
216
217
218
219
 
220
221
222
...
1
2
 
3
4
5
6
...
61
62
63
 
64
65
66
67
...
99
100
101
 
102
103
104
105
...
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
...
212
213
214
 
215
216
217
...
227
228
229
 
230
231
232
233
0
@@ -1,6 +1,6 @@
0
 /*!
0
 @file enumerable.m
0
-@description The NuEnumerable mixin.
0
+@description The NuEnumerable mixin.
0
 This class implements methods that enumerate over collections of objects.
0
 The receiving class must have an objectEnumerator method that returns an NSEnumerator.
0
 @copyright Copyright (c) 2007 Neon Design Technology, Inc.
0
@@ -61,7 +61,7 @@ limitations under the License.
0
     return self;
0
 }
0
 
0
-- (id) select:(NuBlock *) block
0
+- (NSArray *) select:(NuBlock *) block
0
 {
0
     NSMutableArray *selected = [[NSMutableArray alloc] init];
0
     id args = [[NuCell alloc] init];
0
@@ -99,7 +99,7 @@ limitations under the License.
0
     return Nu__null;
0
 }
0
 
0
-- (id) map:(NuBlock *) block
0
+- (NSArray *) map:(NuBlock *) block
0
 {
0
     NSMutableArray *results = [[NSMutableArray alloc] init];
0
     id args = [[NuCell alloc] init];
0
@@ -115,6 +115,18 @@ limitations under the License.
0
     return results;
0
 }
0
 
0
+- (NSArray *) mapSelector:(SEL) sel
0
+{
0
+ NSMutableArray *results = [[NSMutableArray alloc] init];
0
+ NSEnumerator *enumerator = [self objectEnumerator];
0
+ id object;
0
+ while ((object = [enumerator nextObject])) {
0
+ // this will fail (crash!) if the selector returns any type other than an object.
0
+ [results addObject:[object performSelector:sel]];
0
+ }
0
+ return results;
0
+}
0
+
0
 - (id) reduce:(NuBlock *) block from:(id) initial
0
 {
0
     id args = [[NuCell alloc] init];
0
@@ -200,7 +212,6 @@ limitations under the License.
0
     return self;
0
 }
0
 
0
-
0
 static NSComparisonResult sortedArrayUsingBlockHelper(id a, id b, void *context)
0
 {
0
     id args = [[NuCell alloc] init];
0
@@ -216,7 +227,7 @@ static NSComparisonResult sortedArrayUsingBlockHelper(id a, id b, void *context)
0
     return [result intValue];
0
 }
0
 
0
-- (id) sortedArrayUsingBlock:(NuBlock *) block
0
+- (NSArray *) sortedArrayUsingBlock:(NuBlock *) block
0
 {
0
     return [self sortedArrayUsingFunction:sortedArrayUsingBlockHelper context:block];
0
 }
...
17
18
19
 
20
21
22
...
41
42
43
 
 
 
 
 
 
 
44
45
46
...
127
128
129
 
 
 
 
 
 
 
 
 
130
131
132
...
17
18
19
20
21
22
23
...
42
43
44
45
46
47
48
49
50
51
52
53
54
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
0
@@ -17,6 +17,7 @@ limitations under the License.
0
 */
0
 
0
 #import <Foundation/Foundation.h>
0
+@class NuCell;
0
 
0
 #ifdef LINUX
0
 #define bool char
0
@@ -41,6 +42,13 @@ limitations under the License.
0
 @interface NSArray(Nu)
0
 /*! Creates an array that contains the contents of a specified list. */
0
 + (NSArray *) arrayWithList:(id) list;
0
+
0
+/*! Sort an array using its elements' compare: method. */
0
+- (NSArray *) sort;
0
+
0
+/*! Convert an array into a list. */
0
+- (NuCell *) list;
0
+
0
 @end
0
 
0
 /*!
0
@@ -127,6 +135,15 @@ limitations under the License.
0
 /*! Create a string from a specified character */
0
 + (NSString *) stringWithCharacter:(unichar) c;
0
 
0
+/*! Convert a string into a symbol. */
0
+- (id) symbolValue;
0
+
0
+/*! Split a string into lines. */
0
+- (NSArray *) lines;
0
+
0
+/*! Replace a substring with another. */
0
+- (NSString *) replaceString:(NSString *) target withString:(NSString *) replacement;
0
+
0
 #ifdef LINUX
0
 + (NSString *) stringWithCString:(const char *) cString encoding:(NSStringEncoding) encoding;
0
 - (const char *) cStringUsingEncoding:(NSStringEncoding) encoding;
...
93
94
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
97
98
...
185
186
187
188
189
 
 
190
191
192
...
311
312
313
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
315
316
...
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
...
208
209
210
 
 
211
212
213
214
215
...
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
0
@@ -93,6 +93,29 @@ extern id Nu__null;
0
     }
0
 }
0
 
0
+// This default sort method sorts an array using its elements' compare: method.
0
+- (NSArray *) sort
0
+{
0
+ return [self sortedArrayUsingSelector:@selector(compare:)];
0
+}
0
+
0
+// Convert an array into a list.
0
+- (NuCell *) list
0
+{
0
+ int count = [self count];
0
+ if (count == 0)
0
+ return nil;
0
+ NuCell *result = [[[NuCell alloc] init] autorelease];
0
+ NuCell *cursor = result;
0
+ [result setCar:[self objectAtIndex:0]];
0
+ for (int i = 1; i < count; i++) {
0
+ [cursor setCdr:[[[NuCell alloc] init] autorelease]];
0
+ cursor = [cursor cdr];
0
+ [cursor setCar:[self objectAtIndex:i]];
0
+ }
0
+ return result;
0
+}
0
+
0
 @end
0
 
0
 @implementation NSMutableArray(Nu)
0
@@ -185,8 +208,8 @@ extern id Nu__null;
0
         [[args cdr] setCar:[self objectForKey:key]];
0
         [block evalWithArguments:args context:Nu__null];
0
     }
0
- [args release];
0
- return self;
0
+ [args release];
0
+ return self;
0
 }
0
 
0
 @end
0
@@ -311,6 +334,32 @@ extern id Nu__null;
0
     #endif
0
 }
0
 
0
+// Convert a string into a symbol.
0
+- (id) symbolValue
0
+{
0
+ return [[NuSymbolTable sharedSymbolTable] symbolWithString:self];
0
+}
0
+
0
+// Split a string into lines.
0
+- (NSArray *) lines
0
+{
0
+ NSArray *a = [self componentsSeparatedByString:@"\n"];
0
+ if ([[a lastObject] isEqualToString:@""]) {
0
+ return [a subarrayWithRange:NSMakeRange(0, [a count]-1)];
0
+ }
0
+ else {
0
+ return a;
0
+ }
0
+}
0
+
0
+// Replace a substring with another.
0
+- (NSString *) replaceString:(NSString *) target withString:(NSString *) replacement
0
+{
0
+ NSMutableString *s = [NSMutableString stringWithString:self];
0
+ [s replaceOccurrencesOfString:target withString:replacement options:nil range:NSMakeRange(0, [self length])];
0
+ return s;
0
+}
0
+
0
 #ifdef LINUX
0
 + (NSString *) stringWithCString:(const char *) cString encoding:(NSStringEncoding) encoding
0
 {
...
44
45
46
 
 
 
 
47
48
49
...
44
45
46
47
48
49
50
51
52
53
0
@@ -44,6 +44,10 @@ limitations under the License.
0
 + (NSArray *) classMethods;
0
 /*! Get an array containing NuMethod representations of the instance methods of a class. */
0
 + (NSArray *) instanceMethods;
0
+/*! Get an array containing the names of the class methods of a class. */
0
++ (NSArray *) classMethodNames;
0
+/*! Get an array containing the names of the instance methods of a class. */
0
++ (NSArray *) instanceMethodNames;
0
 /*! Get an array containing the names of all instance variables of the class. */
0
 + (NSArray *) instanceVariableNames;
0
 
...
470
471
472
 
 
 
 
 
 
 
 
 
 
 
 
473
474
475
...
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
0
@@ -470,6 +470,18 @@ limitations under the License.
0
     return array;
0
 }
0
 
0
++ (NSArray *) classMethodNames
0
+{
0
+ Class c = [self class];
0
+ return [[c classMethods] mapSelector:@selector(name)];
0
+}
0
+
0
++ (NSArray *) instanceMethodNames
0
+{
0
+ Class c = [self class];
0
+ return [[c instanceMethods] mapSelector:@selector(name)];
0
+}
0
+
0
 + (NSArray *) instanceVariableNames
0
 {
0
     NSMutableArray *array = [[NSMutableArray alloc] init];
...
93
94
95
96
 
 
 
 
 
 
 
 
 
 
 
 
...
93
94
95
 
96
97
98
99
100
101
102
103
104
105
106
107
0
@@ -93,4 +93,15 @@ foo\nbarEND)
0
           (set x <<+END
0
 foo\nbarEND)
0
           (assert_equal 7 (x length))
0
- (assert_equal 10 (x characterAtIndex:3))))
0
+ (assert_equal 10 (x characterAtIndex:3)))
0
+
0
+ (imethod (id) testLineSplitting is
0
+ (set x <<-END
0
+Line 0
0
+Line 1
0
+Line 2
0
+END)
0
+ (set lines (x lines))
0
+ (assert_equal 3 (lines count))
0
+ (assert_equal "Line 1" (lines objectAtIndex:1))))
0
+
...
631
632
633
634
 
 
 
635
636
637
...
631
632
633
 
634
635
636
637
638
639
0
@@ -631,7 +631,9 @@
0
      ;; library fat archive
0
      (set @library_executable_name "#{@library}.a")
0
      (file @library_executable_name => @library_executables is
0
- (set command "lipo -create #{(@library_executables join)} -output '#{@library_executable_name}'")
0
+ (if (> (@library_executables count) 1)
0
+ (then (set command "lipo -create #{(@library_executables join)} -output '#{@library_executable_name}'"))
0
+ (else (set command "cp '#{(@library_executables objectAtIndex:0)}' '#{@library_executable_name}'")))
0
            (SH command))
0
      
0
      (task "library" => @library_executable_name))

Comments

    No one has commented yet.