From a3504832b357f6bd97f51560dbbf8a933583dc70 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Thu, 31 Oct 2019 13:54:18 -0500 Subject: hscript: Add Keymap code --- hscript/meta.cc | 16 +++++++++++++++- hscript/meta.hh | 8 ++++++++ hscript/script.cc | 20 ++++++++++++++++++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/hscript/meta.cc b/hscript/meta.cc index 3b3ee3d..dfd147a 100644 --- a/hscript/meta.cc +++ b/hscript/meta.cc @@ -261,7 +261,6 @@ Key *Language::parseFromData(const std::string &data, int lineno, int *errors, return new Language(lineno, data); } - bool Language::execute(ScriptOptions opts) const { output_info("installfile:" + std::to_string(this->lineno()), "language: setting default system language to " + @@ -302,6 +301,21 @@ bool Language::execute(ScriptOptions opts) const { } +Key *Keymap::parseFromData(const std::string &data, int lineno, int *, int *) { + return new Keymap(lineno, data); +} + +bool Keymap::validate(ScriptOptions) const { + /* TODO XXX */ + /* Will require console-setup to be installed on the validating machine. */ + return true; +} + +bool Keymap::execute(ScriptOptions) const { + return true; +} + + Key *Firmware::parseFromData(const std::string &data, int lineno, int *errors, int *warnings) { bool value; diff --git a/hscript/meta.hh b/hscript/meta.hh index b2e1963..25ff931 100644 --- a/hscript/meta.hh +++ b/hscript/meta.hh @@ -55,6 +55,14 @@ public: }; class Keymap : public StringKey { +private: + Keymap(int _line, const std::string &keymap) : + StringKey(_line, keymap) {} +public: + static Key *parseFromData(const std::string &data, int lineno, int *errors, + int *warnings); + bool validate(ScriptOptions) const override; + bool execute(ScriptOptions) const override; }; class Firmware : public BooleanKey { diff --git a/hscript/script.cc b/hscript/script.cc index f1fa5d6..dae014c 100644 --- a/hscript/script.cc +++ b/hscript/script.cc @@ -91,7 +91,8 @@ struct Script::ScriptPrivate { std::unique_ptr rootpw; /*! The system language. */ std::unique_ptr lang; - /* keymap */ + /*! The system keymap. */ + std::unique_ptr keymap; /*! The system timezone. */ std::unique_ptr tzone; @@ -151,6 +152,8 @@ struct Script::ScriptPrivate { return store_rootpw(obj, lineno, errors, warnings, opts); } else if(key_name == "language") { return store_lang(obj, lineno, errors, warnings, opts); + } else if(key_name == "keymap") { + return store_keymap(obj, lineno, errors, warnings, opts); } else if(key_name == "firmware") { return store_firmware(obj, lineno, errors, warnings, opts); } else if(key_name == "timezone") { @@ -293,6 +296,18 @@ struct Script::ScriptPrivate { return true; } + bool store_keymap(Keys::Key *obj, int lineno, int *errors, int *, + ScriptOptions) { + if(this->keymap) { + DUPLICATE_ERROR(this->keymap, std::string("keymap"), + this->keymap->value()) + return false; + } + std::unique_ptr k(dynamic_cast(obj)); + this->keymap = std::move(k); + return true; + } + bool store_timezone(Keys::Key *obj, int lineno, int *errors, int *, ScriptOptions) { if(this->tzone) { @@ -722,7 +737,8 @@ bool Script::validate() const { /* REQ: Runner.Validate.language */ if(internal->lang && !internal->lang->validate(this->opts)) failures++; - /* keymap */ + /* REQ: Runner.Validate.keymap */ + if(internal->keymap && !internal->keymap->validate(this->opts)) failures++; #ifdef NON_LIBRE_FIRMWARE /* REQ: Runner.Validate.firmware */ -- cgit v1.2.3-70-g09d2