1 /*
2     This file is part of GNU APL, a free implementation of the
3     ISO/IEC Standard 13751, "Programming Language APL, Extended"
4 
5     Copyright (C) 2008-2013  Dr. Jürgen Sauermann
6 
7     This program is free software: you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation, either version 3 of the License, or
10     (at your option) any later version.
11 
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #include <vector>
22 
23 #include "../../config.h"
24 #include "../Svar_DB.hh"
25 
26 extern ostream & get_CERR();
27 
28 using namespace std;
29 
30 class Signal_base;
31 class CDR_string;
32 
33 extern bool verbose;
34 extern int event_port;
35 extern char pref[];   ///< a prefix for debug printouts
36 
37 struct SVAR_context;
38 
39 /// a coupled shared variable
40 struct Coupled_var
41 {
42    SV_key key;                ///< the key for this shared variable in Svar_DB
43    const CDR_string * data;   ///< the data held by this shared variable
44    SVAR_context * context;    ///< a context for this shared variable
45 };
46 
47 extern void print_vars(ostream & out);
48 
49 extern vector<Coupled_var> coupled_vars;
50 
51 //-----------------------------------------------------------------------------
52 #ifndef __ERRORCODE_HH_DEFINED__
53 enum APL_error_code
54 {
55 #define err_def(c, t, maj, min) E_ ## c = (maj) << 16 | (min),
56 #include "../Error.def"
57 };
58 #else
59 #define APL_error_code ErrorCode
60 #endif
61 
62 /// send GOT_EVENT to the event_port (if non-zero)
63 extern void got_event(uint32_t event, SV_key key);
64 
65 // API to AP specific functions...
66 
67 /// initialize new variable \b var in this AP (due to ⎕SVO);
68 /// return true on error
69 extern bool initialize(Coupled_var & var);
70 
71 /// return true if this AP automatically makes counter offers to incoming offers
72 extern bool make_counter_offer(SV_key key);
73 
74 /// retract variable \b var in this AP (due to ⎕SVR)
75 extern void retract(Coupled_var & var);
76 
77 /// return true if \b varname is supported by this AP
78 extern bool is_valid_varname(const uint32_t * varname);
79 
80 /// assign a new value
81 extern APL_error_code assign_value(Coupled_var & var, const string & data);
82 
83 /// get the current value
84 extern APL_error_code get_value(Coupled_var & var, string & data);
85 
86 /// the place where an error was detected
87 extern string error_loc;
88 
89 /// Stringify x.
90 #define STR(x) #x
91 
92 /// The current location in the source file.
93 #define LOC Loc(__FILE__, __LINE__)
94 
95 /// The location line l in file f.
96 #define Loc(f, l) f ":" STR(l)
97 
98 //-----------------------------------------------------------------------------
99 
100