summaryrefslogtreecommitdiff
path: root/hscript/script.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-02-26 04:33:29 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-02-26 04:33:29 -0600
commit75f10ffe70935187bb900501866a8d555b83a855 (patch)
tree22e60be53af48fcec8465fef2681e9cd5f8cb36e /hscript/script.cc
parentca78cc8d66498cccf54ed26d5318f09362859ba7 (diff)
downloadhorizon-75f10ffe70935187bb900501866a8d555b83a855.tar.gz
horizon-75f10ffe70935187bb900501866a8d555b83a855.tar.bz2
horizon-75f10ffe70935187bb900501866a8d555b83a855.tar.xz
horizon-75f10ffe70935187bb900501866a8d555b83a855.zip
hscript: Refactor Keys to be owned by a Script*
This means that a Key can introspect its Script.
Diffstat (limited to 'hscript/script.cc')
-rw-r--r--hscript/script.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/hscript/script.cc b/hscript/script.cc
index 0bc6b8a..9073e04 100644
--- a/hscript/script.cc
+++ b/hscript/script.cc
@@ -30,7 +30,8 @@
#define SCRIPT_LINE_MAX 512
-typedef Horizon::Keys::Key *(*key_parse_fn)(const std::string &, int, int*, int*);
+typedef Horizon::Keys::Key *(*key_parse_fn)(const std::string &, int, int*,
+ int*, const Horizon::Script *);
using namespace Horizon::Keys;
@@ -203,6 +204,7 @@ const Script *Script::load(std::istream &sstream,
using namespace Horizon::Keys;
Script *the_script = new Script;
+ the_script->opts = opts;
int lineno = 0;
char nextline[SCRIPT_LINE_MAX];
@@ -248,7 +250,7 @@ const Script *Script::load(std::istream &sstream,
}
Key *key_obj = valid_keys.at(key)(line.substr(value_begin), lineno,
- &errors, &warnings);
+ &errors, &warnings, the_script);
if(!key_obj) {
PARSER_ERROR("value for key '" + key + "' was invalid")
continue;
@@ -309,7 +311,6 @@ const Script *Script::load(std::istream &sstream,
delete the_script;
return nullptr;
} else {
- the_script->opts = opts;
return the_script;
}