| 1 | //
|
|---|
| 2 | // LispController.m
|
|---|
| 3 | // LispControllerPlugin
|
|---|
| 4 | //
|
|---|
| 5 | // Created by Paul Krueger on 2/4/10.
|
|---|
| 6 | // Copyright 2010. All rights reserved.
|
|---|
| 7 | //
|
|---|
| 8 |
|
|---|
| 9 | #import <LispController.h>
|
|---|
| 10 |
|
|---|
| 11 | @implementation LispController
|
|---|
| 12 |
|
|---|
| 13 | - (void)encodeWithCoder:(NSCoder *)encoder {
|
|---|
| 14 | [encoder encodeObject:typeInfo forKey:@"typeInfo"];
|
|---|
| 15 | [encoder encodeObject:initforms forKey:@"initforms"];
|
|---|
| 16 | [encoder encodeObject:sortInfo forKey:@"sortInfo"];
|
|---|
| 17 | [encoder encodeObject:rootType forKey:@"rootType"];
|
|---|
| 18 | [encoder encodeObject:readerFunc forKey:@"readerFunc"];
|
|---|
| 19 | [encoder encodeObject:writerFunc forKey:@"writerFunc"];
|
|---|
| 20 | [encoder encodeObject:countFunc forKey:@"countFunc"];
|
|---|
| 21 | [encoder encodeObject:selectFunc forKey:@"selectFunc"];
|
|---|
| 22 | [encoder encodeObject:editedFunc forKey:@"editedFunc"];
|
|---|
| 23 | [encoder encodeObject:addedFunc forKey:@"addedFunc"];
|
|---|
| 24 | [encoder encodeObject:removedFunc forKey:@"removedFunc"];
|
|---|
| 25 | [encoder encodeObject:deleteFunc forKey:@"deleteFunc"];
|
|---|
| 26 | [encoder encodeObject:addChildFunc forKey:@"addChildFunc"];
|
|---|
| 27 | [encoder encodeObject:childrenFunc forKey:@"childrenFunc"];
|
|---|
| 28 | [encoder encodeBool:genRoot forKey:@"genRoot"];
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | - (id)init {
|
|---|
| 32 | typeInfo = [[NSMutableArray alloc] initWithCapacity:5];
|
|---|
| 33 | initforms = [[NSMutableArray alloc] initWithCapacity:5];
|
|---|
| 34 | sortInfo = [[NSMutableArray alloc] initWithCapacity:5];
|
|---|
| 35 | rootType = @"";
|
|---|
| 36 | readerFunc = @"";
|
|---|
| 37 | writerFunc = @"";
|
|---|
| 38 | countFunc = @"";
|
|---|
| 39 | selectFunc = @"";
|
|---|
| 40 | editedFunc = @"";
|
|---|
| 41 | deleteFunc = @"";
|
|---|
| 42 | addChildFunc = @"";
|
|---|
| 43 | childrenFunc = @"";
|
|---|
| 44 | genRoot = YES;
|
|---|
| 45 |
|
|---|
| 46 | [self addTypeRow];
|
|---|
| 47 | [self addInitformRow];
|
|---|
| 48 | [self addSortRow];
|
|---|
| 49 | return self;
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | - (id)initWithCoder:(NSCoder *)decoder {
|
|---|
| 53 | typeInfo = [[decoder decodeObjectForKey:@"typeInfo"] retain];
|
|---|
| 54 | initforms = [[decoder decodeObjectForKey:@"initforms"] retain];
|
|---|
| 55 | sortInfo = [[decoder decodeObjectForKey:@"sortInfo"] retain];
|
|---|
| 56 | rootType = [[decoder decodeObjectForKey:@"rootType"] retain];
|
|---|
| 57 | readerFunc = [[decoder decodeObjectForKey:@"readerFunc"] retain];
|
|---|
| 58 | writerFunc = [[decoder decodeObjectForKey:@"writerFunc"] retain];
|
|---|
| 59 | countFunc = [[decoder decodeObjectForKey:@"countFunc"] retain];
|
|---|
| 60 | selectFunc = [[decoder decodeObjectForKey:@"selectFunc"] retain];
|
|---|
| 61 | editedFunc = [[decoder decodeObjectForKey:@"editedFunc"] retain];
|
|---|
| 62 | addedFunc = [[decoder decodeObjectForKey:@"addedFunc"] retain];
|
|---|
| 63 | removedFunc = [[decoder decodeObjectForKey:@"removedFunc"] retain];
|
|---|
| 64 | deleteFunc = [[decoder decodeObjectForKey:@"deleteFunc"] retain];
|
|---|
| 65 | addChildFunc = [[decoder decodeObjectForKey:@"addChildFunc"] retain];
|
|---|
| 66 | childrenFunc = [[decoder decodeObjectForKey:@"childrenFunc"] retain];
|
|---|
| 67 | genRoot = [decoder decodeBoolForKey:@"genRoot"];
|
|---|
| 68 | return self;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | - (int)typeInfoCount {
|
|---|
| 72 | return [typeInfo count];
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | - (int)initformCount {
|
|---|
| 76 | return [initforms count];
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | - (int)sortInfoCount {
|
|---|
| 80 | return [sortInfo count];
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 | - (void)addTypeRow {
|
|---|
| 85 | int index = [typeInfo count];
|
|---|
| 86 | NSMutableArray *firstTypeEntry = [self emptyArrayOfSize:3];
|
|---|
| 87 | [typeInfo insertObject:firstTypeEntry atIndex: index];
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | - (void)addInitformRow {
|
|---|
| 91 | int index = [initforms count];
|
|---|
| 92 | NSMutableArray *firstInitformEntry = [self emptyArrayOfSize:2];
|
|---|
| 93 | [initforms insertObject:firstInitformEntry atIndex: index];
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | - (void)addSortRow {
|
|---|
| 97 | int index = [sortInfo count];
|
|---|
| 98 | NSMutableArray *firstSortEntry = [self emptyArrayOfSize:3];
|
|---|
| 99 | [sortInfo insertObject:firstSortEntry atIndex: index];
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | - (void)typeTableRemoveRow: (int)row {
|
|---|
| 103 | [typeInfo removeObjectAtIndex: row];
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | - (void)initformTableRemoveRow: (int)row {
|
|---|
| 107 | [initforms removeObjectAtIndex: row];
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | - (void)sortTableRemoveRow: (int)row {
|
|---|
| 111 | [sortInfo removeObjectAtIndex: row];
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | - (id) emptyArrayOfSize: (int) sz {
|
|---|
| 115 | NSMutableArray *newArray = [[NSMutableArray alloc] initWithCapacity: sz];
|
|---|
| 116 | int i;
|
|---|
| 117 | [newArray insertObject:@"<new type>" atIndex: 0];
|
|---|
| 118 | for (i = 1; i < sz; i++) {
|
|---|
| 119 | [newArray insertObject:@"" atIndex: i];
|
|---|
| 120 | }
|
|---|
| 121 | return newArray;
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | - (id) typeTableCellAtRow: (int)row
|
|---|
| 125 | col: (int)col {
|
|---|
| 126 | NSMutableArray *rowArray = [typeInfo objectAtIndex:row];
|
|---|
| 127 | return [rowArray objectAtIndex:col];
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | - (id) initformTableCellAtRow: (int)row
|
|---|
| 131 | col: (int)col {
|
|---|
| 132 | NSMutableArray *rowArray = [initforms objectAtIndex:row];
|
|---|
| 133 | return [rowArray objectAtIndex:col];
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | - (id) sortTableCellAtRow: (int)row
|
|---|
| 137 | col: (int)col {
|
|---|
| 138 | NSMutableArray *rowArray = [sortInfo objectAtIndex:row];
|
|---|
| 139 | return [rowArray objectAtIndex:col];
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | - (void) setValue: (id)newVal
|
|---|
| 143 | forTypeTableCellAtRow: (int)rowIndex
|
|---|
| 144 | col: (int)colIndex {
|
|---|
| 145 | NSMutableArray *rowArray = [typeInfo objectAtIndex:rowIndex];
|
|---|
| 146 | [rowArray replaceObjectAtIndex: colIndex withObject: newVal];
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | - (void) setValue: (id)newVal
|
|---|
| 150 | forInitformTableCellAtRow: (int)rowIndex
|
|---|
| 151 | col: (int)colIndex {
|
|---|
| 152 | NSMutableArray *rowArray = [initforms objectAtIndex:rowIndex];
|
|---|
| 153 | [rowArray replaceObjectAtIndex: colIndex withObject: newVal];
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | - (void) setValue: (id)newVal
|
|---|
| 157 | forSortTableCellAtRow: (int)rowIndex
|
|---|
| 158 | col: (int)colIndex {
|
|---|
| 159 | NSMutableArray *rowArray = [sortInfo objectAtIndex:rowIndex];
|
|---|
| 160 | [rowArray replaceObjectAtIndex: colIndex withObject: newVal];
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | - (IBAction)insert: (id)sender {
|
|---|
| 164 | // don't need to do anything here; implemented in Lisp
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | - (IBAction)addChild: (id)sender {
|
|---|
| 168 | // don't need to do anything here; implemented in Lisp
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | - (IBAction)remove: (id)sender {
|
|---|
| 172 | // don't need to do anything here; implemented in Lisp
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | @end
|
|---|