Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/guisupport/dc.cpp @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 * AnaGram, A System for Syntax Directed Programming | |
3 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
4 * See the file COPYING for license and usage terms. | |
5 * | |
6 * dc.cpp - display contexts | |
7 */ | |
8 | |
9 #include "assert.h" | |
10 #include "dc.h" | |
11 #include "myalloc.h" | |
12 #include "stacks.h" | |
13 #include "wdata.h" | |
14 #include "wm1.h" | |
15 | |
16 //#define INCLUDE_LOGGING | |
17 #include "log.h" | |
18 | |
19 | |
20 static int dcsCreated = 0; | |
21 static int dcsDestroyed = 0; | |
22 | |
23 | |
24 //////////////////////////////////////////////////////////// | |
25 // | |
26 // dc methods | |
27 | |
28 void dc::init_dc(void) { | |
29 LOGSECTION("dc::init"); | |
30 LOGV((int) this) LCV(head_title) LCV(foot_title); | |
31 id = this; | |
32 clear_data(); | |
33 des = ZALLOCATE(1, wd); | |
34 | |
35 tab_stops = NULL; | |
36 syntax_dependent = 1; | |
37 dcsCreated++; | |
38 } | |
39 | |
40 void dc::clear_data(void) { | |
41 LOGSECTION("dc::clear_data"); | |
42 usage_count = 0; | |
43 tab_stops = NULL; | |
44 syntax_dependent = 1; | |
45 } | |
46 | |
47 dc::dc(void) | |
48 : head_title() | |
49 , foot_title() | |
50 , windowConnector(0) | |
51 { | |
52 init_dc(); | |
53 } | |
54 | |
55 dc::dc(const AgString head) | |
56 : head_title(head) | |
57 , foot_title() | |
58 , windowConnector(0) | |
59 { | |
60 init_dc(); | |
61 } | |
62 | |
63 dc::dc(const AgString head, const AgString foot) | |
64 : head_title(head) | |
65 , foot_title(foot) | |
66 , windowConnector(0) | |
67 { | |
68 init_dc(); | |
69 } | |
70 | |
71 dc::dc(dc &x) | |
72 : head_title(x.head_title) | |
73 , foot_title(x.foot_title) | |
74 , windowConnector(0) | |
75 { | |
76 id = this; | |
77 des = ZALLOCATE(1,wd); | |
78 *des = *x.des; | |
79 syntax_dependent = x.syntax_dependent; | |
80 tab_stops = x.tab_stops; | |
81 columnHeadTitle = x.columnHeadTitle; | |
82 usage_count = 0; | |
83 dcsCreated++; | |
84 } | |
85 | |
86 dc::~dc(void) { | |
87 LOGSECTION("dc::~dc"); | |
88 LOGV(head_title) LCV(foot_title); | |
89 assert(this == id && usage_count == 0); | |
90 ok_ptr(this); | |
91 ok_ptr(des); | |
92 //if (windowConnector) delete windowConnector; | |
93 DEALLOCATE(des); | |
94 dcsDestroyed++; | |
95 } | |
96 | |
97 AgString dc::findHelpTopic() { return AgString(); } | |
98 | |
99 #define CURSOR windowConnector->getCursorLine() | |
100 | |
101 void dc::anomaly_trace() { pop_up_window(anomaly_trace (CURSOR)); } | |
102 void dc::aux_trace() { pop_up_window(aux_trace (CURSOR)); } | |
103 void dc::derive_rule() { pop_up_window(derive_rule (CURSOR)); } | |
104 void dc::derive_token() { pop_up_window(derive_token (CURSOR)); } | |
105 void dc::expansion_chain() { pop_up_window(expansion_chain (CURSOR)); } | |
106 void dc::expansion_rules() { pop_up_window(expansion_rules (CURSOR)); } | |
107 void dc::keywords() { pop_up_window(keywords (CURSOR)); } | |
108 void dc::partition_sets() { pop_up_window(partition_sets (CURSOR)); } | |
109 void dc::previous_states() { pop_up_window(previous_states (CURSOR)); } | |
110 void dc::problem_states() { pop_up_window(problem_states (CURSOR)); } | |
111 void dc::productions() { pop_up_window(productions (CURSOR)); } | |
112 | |
113 void dc::reduction_states() { pop_up_window(reduction_states(CURSOR)); } | |
114 void dc::reduction_trace() { pop_up_window(reduction_trace (CURSOR)); } | |
115 void dc::rule_context() { pop_up_window(rule_context (CURSOR)); } | |
116 //void dc::rule_stack() { pop_up_window(rule_stack (CURSOR)); } | |
117 void dc::select_conflict() { pop_up_window(select_conflict (CURSOR)); } | |
118 void dc::set_elements() { pop_up_window(set_elements (CURSOR)); } | |
119 void dc::state_definition() { pop_up_window(state_definition(CURSOR)); } | |
120 void dc::state_expansion() { pop_up_window(state_expansion (CURSOR)); } | |
121 void dc::usage() { pop_up_window(usage (CURSOR)); } | |
122 | |
123 int dc::derive_rule_ok() { return derive_rule_ok (CURSOR); } | |
124 int dc::expansion_chain_ok() { return expansion_chain_ok (CURSOR); } | |
125 | |
126 int dc::expansion_rules_ok() { return expansion_rules_ok (CURSOR); } | |
127 | |
128 int dc::keywords_ok() { return keywords_ok (CURSOR); } | |
129 int dc::previous_states_ok() { return previous_states_ok (CURSOR); } | |
130 int dc::productions_ok() { return productions_ok (CURSOR); } | |
131 int dc::reduction_states_ok() { return reduction_states_ok (CURSOR); } | |
132 int dc::rule_context_ok() { return rule_context_ok (CURSOR); } | |
133 int dc::set_elements_ok() { return set_elements_ok (CURSOR); } | |
134 int dc::state_expansion_ok() { return state_expansion_ok (CURSOR); } | |
135 int dc::usage_ok() { return usage_ok (CURSOR); } | |
136 | |
137 #undef CURSOR | |
138 | |
139 void dc::getLine(unsigned ln) const { | |
140 LOGSECTION("dc::getLine"); | |
141 LOGV(ln); | |
142 assert(ln < (unsigned) des->d_size.y); | |
143 ics(); | |
144 } | |
145 | |
146 //////////////////////////////////////////////////////////// | |
147 // | |
148 // dc_ref methods | |
149 | |
150 dc::ref::ref() : window(0) {} | |
151 | |
152 dc::ref::ref(dc *x) { | |
153 LOGSECTION("dc::ref::ref"); | |
154 window = x; | |
155 if (window) { | |
156 ok_ptr(window); | |
157 window->usage_count++; | |
158 LOGV((int) window) LCV(window->usage_count); | |
159 } | |
160 } | |
161 | |
162 dc::ref::ref(const ref &x) { | |
163 window = x.window; | |
164 if (window) { | |
165 ok_ptr(window); | |
166 window->usage_count++; | |
167 } | |
168 } | |
169 | |
170 dc::ref &dc::ref::operator =(const ref &x) { | |
171 if (window == x.window) { | |
172 return *this; | |
173 } | |
174 if (window) { | |
175 ok_ptr(window); | |
176 if (window->usage_count && --window->usage_count == 0) { | |
177 delete window; | |
178 } | |
179 } | |
180 window = x.window; | |
181 if (window) { | |
182 ok_ptr(window); | |
183 window->usage_count++; | |
184 } | |
185 return *this; | |
186 } | |
187 | |
188 dc::ref &dc::ref::operator =(dc *x) { | |
189 if (window == x) { | |
190 return *this; | |
191 } | |
192 if (window) { | |
193 ok_ptr(window); | |
194 LOGV((int) window) LCV(window->usage_count); | |
195 if (window->usage_count && --window->usage_count == 0) { | |
196 delete window; | |
197 } | |
198 } | |
199 window = x; | |
200 if (window) { | |
201 ok_ptr(window); | |
202 LOGV(window->usage_count); | |
203 window->usage_count++; | |
204 } | |
205 return *this; | |
206 } | |
207 | |
208 dc::ref::~ref(void) { | |
209 LOGSECTION("dc::ref::~ref"); | |
210 if (window) { | |
211 ok_ptr(window); | |
212 LOGV((int) window) LCV(window->usage_count); | |
213 if (window->usage_count && --window->usage_count == 0) { | |
214 delete window; | |
215 } | |
216 } | |
217 } | |
218 | |
219 void dc::ref::discardData(void) { | |
220 dc *alias = window; | |
221 window = 0; | |
222 if (alias) { | |
223 ok_ptr(alias); | |
224 LOGV((int) alias) LCV(alias->usage_count); | |
225 if (alias->usage_count && --alias->usage_count == 0) { | |
226 delete alias; | |
227 } | |
228 } | |
229 } | |
230 | |
231 dc::ref::operator dc *(void) const { | |
232 if (window) { | |
233 ok_ptr(window); | |
234 } | |
235 return window; | |
236 } | |
237 | |
238 dc *dc::ref::operator ->(void) const { | |
239 ok_ptr(window); | |
240 return window; | |
241 } |