Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/guisupport/action.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 1997-2002 Parsifal Software. All Rights Reserved. | |
4 * See the file COPYING for license and usage terms. | |
5 * | |
6 * action.cpp | |
7 */ | |
8 | |
9 #include "action.h" | |
10 | |
11 //#define INCLUDE_LOGGING | |
12 #include "log.h" | |
13 | |
14 | |
15 int AgAction::running = 0; | |
16 | |
17 AgStack<AgAction> AgAction::startupStack; | |
18 | |
19 AgAction actionObject(void (*function)()) { | |
20 return AgSimpleAction(function); | |
21 } | |
22 | |
23 void AgAction::startup() { | |
24 LOGSECTION("AgAction::startup"); | |
25 running = 1; | |
26 int n = startupStack.size(); | |
27 LOGV(n); | |
28 int i; | |
29 for (i = 0; i < n; i++) { | |
30 startupStack[i].perform(); | |
31 } | |
32 startupStack.discardData(); | |
33 } | |
34 | |
35 void AgAction::performDeferred() const { | |
36 if (!running) { | |
37 startupStack.push(*this); | |
38 return; | |
39 } | |
40 LOGSECTION_OFF("AgAction::performDeferred"); | |
41 LOGV((int) kernel); | |
42 if (kernel == 0) { | |
43 return; | |
44 } | |
45 kernel->lock(); | |
46 AgActionEnqueueInGui(kernel); | |
47 } | |
48 | |
49 void AgActionDispatchFromGui(AgAction::Kernel *kernel) { | |
50 kernel->perform(); | |
51 if (kernel->unlock()) { | |
52 delete kernel; | |
53 } | |
54 } | |
55 | |
56 void defer(void (*function)()) { | |
57 actionObject(function).performDeferred(); | |
58 } |