forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathppScope.h
More file actions
180 lines (151 loc) · 6.56 KB
/
ppScope.h
File metadata and controls
180 lines (151 loc) · 6.56 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// Filename: ppScope.h
// Created by: drose (25Sep00)
//
////////////////////////////////////////////////////////////////////
#ifndef PPSCOPE_H
#define PPSCOPE_H
#include "ppremake.h"
#include <map>
#include <vector>
class PPNamedScopes;
class PPDirectory;
class PPSubroutine;
///////////////////////////////////////////////////////////////////
// Class : PPScope
// Description : Defines a (possibly nested) scope for variable
// definitions. Variables may be defined in a
// system-wide variable file, in a template file, or in
// an individual source file.
////////////////////////////////////////////////////////////////////
class PPScope {
public:
typedef map<string, PPScope *> MapVariableDefinition;
PPScope(PPNamedScopes *named_scopes);
PPNamedScopes *get_named_scopes();
void set_parent(PPScope *parent);
PPScope *get_parent();
void define_variable(const string &varname, const string &definition);
bool set_variable(const string &varname, const string &definition);
void define_map_variable(const string &varname, const string &definition);
void define_map_variable(const string &varname, const string &key_varname,
const string &scope_names);
void add_to_map_variable(const string &varname, const string &key,
PPScope *scope);
void define_formals(const string &subroutine_name,
const vector<string> &formals, const string &actuals);
string get_variable(const string &varname);
string expand_variable(const string &varname);
MapVariableDefinition &find_map_variable(const string &varname);
PPDirectory *get_directory();
void set_directory(PPDirectory *directory);
string expand_string(const string &str);
string expand_self_reference(const string &str, const string &varname);
static void push_scope(PPScope *scope);
static PPScope *pop_scope();
static PPScope *get_bottom_scope();
static PPScope *get_enclosing_scope(int n);
void tokenize_params(const string &str, vector<string> &tokens,
bool expand);
bool tokenize_numeric_pair(const string &str, double &a, double &b);
bool tokenize_ints(const string &str, vector<int> &tokens);
size_t scan_to_whitespace(const string &str, size_t start = 0);
static string format_int(int num);
static MapVariableDefinition _null_map_def;
private:
class ExpandedVariable {
public:
string _varname;
ExpandedVariable *_next;
};
bool p_set_variable(const string &varname, const string &definition);
bool p_get_variable(const string &varname, string &result);
string r_expand_string(const string &str, ExpandedVariable *expanded);
string r_scan_variable(const string &str, size_t &vp);
string r_expand_variable(const string &str, size_t &vp,
PPScope::ExpandedVariable *expanded);
string expand_variable_nested(const string &varname,
const string &scope_names);
string expand_isfullpath(const string ¶ms);
string expand_osfilename(const string ¶ms);
string expand_unixfilename(const string ¶ms);
string expand_unixshortname(const string ¶ms);
string expand_cygpath_w(const string ¶ms);
string expand_cygpath_p(const string ¶ms);
string expand_wildcard(const string ¶ms);
string expand_isdir(const string ¶ms);
string expand_isfile(const string ¶ms);
string expand_libtest(const string ¶ms);
string expand_bintest(const string ¶ms);
string expand_shell(const string ¶ms);
string expand_standardize(const string ¶ms);
string expand_canonical(const string ¶ms);
string expand_length(const string ¶ms);
string expand_substr(const string ¶ms);
string expand_findstring(const string ¶ms);
string expand_dir(const string ¶ms);
string expand_notdir(const string ¶ms);
string expand_suffix(const string ¶ms);
string expand_basename(const string ¶ms);
string expand_makeguid(const string ¶ms);
string expand_word(const string ¶ms);
string expand_wordlist(const string ¶ms);
string expand_words(const string ¶ms);
string expand_firstword(const string ¶ms);
string expand_patsubst(const string ¶ms, bool separate_words);
string expand_filter(const string ¶ms);
string expand_filter_out(const string ¶ms);
string expand_wordsubst(const string ¶ms);
string expand_subst(const string ¶ms);
string expand_join(const string ¶ms);
string expand_sort(const string ¶ms);
string expand_unique(const string ¶ms);
string expand_matrix(const string ¶ms);
string expand_if(const string ¶ms);
string expand_defined(const string ¶ms);
string expand_eq(const string ¶ms);
string expand_ne(const string ¶ms);
string expand_eqn(const string ¶ms);
string expand_nen(const string ¶ms);
string expand_ltn(const string ¶ms);
string expand_len(const string ¶ms);
string expand_gtn(const string ¶ms);
string expand_gen(const string ¶ms);
string expand_plus(const string ¶ms);
string expand_minus(const string ¶ms);
string expand_times(const string ¶ms);
string expand_divide(const string ¶ms);
string expand_modulo(const string ¶ms);
string expand_not(const string ¶ms);
string expand_or(const string ¶ms);
string expand_and(const string ¶ms);
string expand_upcase(const string ¶ms);
string expand_downcase(const string ¶ms);
string expand_cdefine(const string ¶ms);
string expand_closure(const string ¶ms);
string expand_unmapped(const string ¶ms);
string expand_dependencies(const string ¶ms);
string expand_foreach(const string ¶ms);
string expand_forscopes(const string ¶ms);
string expand_function(const string &funcname, const PPSubroutine *sub,
const string ¶ms);
string expand_map_variable(const string &varname, const string ¶ms);
string expand_map_variable(const string &varname, const string &expression,
const vector<string> &keys);
void
r_expand_matrix(vector<string> &results,
const vector<vector<string> > &words,
int index, const string &prefix);
MapVariableDefinition &
p_find_map_variable(const string &varname);
void glob_string(const string &str, vector<string> &results);
PPNamedScopes *_named_scopes;
PPDirectory *_directory;
typedef map<string, string> Variables;
Variables _variables;
typedef map<string, MapVariableDefinition> MapVariables;
MapVariables _map_variables;
PPScope *_parent_scope;
typedef vector<PPScope *> ScopeStack;
static ScopeStack _scope_stack;
};
#endif