Plugins/Context: removed C-style array ctor and use
This likely existed because this code was added in 2014 before we switched to C++11 and initializer lists.
This commit is contained in:
parent
ab0197343e
commit
3c01a4350b
2 changed files with 7 additions and 20 deletions
|
@ -36,24 +36,11 @@ public:
|
|||
typedef std::function<config(config)> accessor_function;
|
||||
struct aReg { char const * name; accessor_function func; };
|
||||
|
||||
using reg_vec = std::vector<Reg>;
|
||||
using areg_vec = std::vector<aReg>;
|
||||
|
||||
plugins_context( const std::string & name );
|
||||
plugins_context( const std::string & name, const std::vector<Reg>& callbacks, const std::vector<aReg>& accessors);
|
||||
template<int N, int M>
|
||||
plugins_context( const std::string & name, const Reg (& callbacks)[N], const aReg (& accessors)[M])
|
||||
: name_(name)
|
||||
{
|
||||
std::vector<Reg> l;
|
||||
std::vector<aReg> r;
|
||||
l.reserve(N);
|
||||
r.reserve(M);
|
||||
for(int i = 0; i < N; i++) {
|
||||
l.push_back(callbacks[i]);
|
||||
}
|
||||
for(int i = 0; i < M; i++) {
|
||||
r.push_back(accessors[i]);
|
||||
}
|
||||
initialize(l, r);
|
||||
}
|
||||
plugins_context( const std::string & name, const reg_vec& callbacks, const areg_vec& accessors);
|
||||
|
||||
void play_slice();
|
||||
|
||||
|
@ -74,7 +61,7 @@ private:
|
|||
typedef std::map<std::string, callback_function > callback_list;
|
||||
typedef std::map<std::string, accessor_function > accessor_list;
|
||||
|
||||
void initialize(const std::vector<Reg>& callbacks, const std::vector<aReg>& accessors);
|
||||
void initialize(const reg_vec& callbacks, const areg_vec& accessors);
|
||||
|
||||
callback_list callbacks_;
|
||||
accessor_list accessors_;
|
||||
|
|
|
@ -790,11 +790,11 @@ static int do_gameloop(const std::vector<std::string>& args)
|
|||
|
||||
plugins_manager plugins_man(new application_lua_kernel);
|
||||
|
||||
plugins_context::Reg const callbacks[] {
|
||||
const plugins_context::reg_vec callbacks {
|
||||
{"play_multiplayer", std::bind(&game_launcher::play_multiplayer, game.get(), game_launcher::MP_CONNECT)},
|
||||
};
|
||||
|
||||
plugins_context::aReg const accessors[] {
|
||||
const plugins_context::areg_vec accessors {
|
||||
{"command_line", std::bind(&commandline_options::to_config, &cmdline_opts)},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue