public
Description: SmartyPants ported to Nu.
Homepage:
Clone URL: git://github.com/Grayson/nusmartypants.git
nusmartypants / smartypants.m
100644 28 lines (26 sloc) 0.817 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#import <Cocoa/Cocoa.h>
#import <Nu/Nu.h>
 
static int load_nu_files(NSString *bundleIdentifier, NSString *mainFile)
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSBundle *bundle = [NSBundle bundleWithIdentifier:bundleIdentifier];
    NSString *main_path = [bundle pathForResource:mainFile ofType:@"nu"];
    if (main_path) {
        NSString *main = [NSString stringWithContentsOfFile:main_path];
        if (main) {
id parser = [Nu parser];
            id script = [parser parse: main];
            id result = [script evalWithContext:[parser context]];
        }
    }
    [pool release];
    return 0;
}
 
void SmartyPantsInit()
{
    static initialized = 0;
    if (!initialized) {
        initialized = 1;
        load_nu_files(@"nu.programming.smartypants", @"smartypants");
    }
}