diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-06-27 15:27:14 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-06-27 15:27:14 +0200 |
commit | 34cc74df52ed129bffeb7b6fcf11f05c222550ba (patch) | |
tree | c4e3a48a03cf507ee4a4219a8b3d57c4dce17a8c /build2/module | |
parent | 5f924ea1926fe17acf699a43713b7f5881e9d30d (diff) |
Get rid of extern "C" in module boot()/init()
We will have a separate (extern "C") register() function that will return
the pointers to these two. This way we can still throw exceptions from
boot() and init().
Diffstat (limited to 'build2/module')
-rw-r--r-- | build2/module | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/build2/module b/build2/module index 314f5a6..c19f31d 100644 --- a/build2/module +++ b/build2/module @@ -25,7 +25,6 @@ namespace build2 ~module_base () = default; }; - extern "C" using module_boot_function = void (scope& root, const location&, unique_ptr<module_base>&); @@ -35,7 +34,6 @@ namespace build2 // unconfigured for as long as it is actually not used (e.g., install, // dist). The return value is used to set the <module>.configured variable. // - extern "C" using module_init_function = bool (scope& root, scope& base, @@ -45,7 +43,21 @@ namespace build2 bool optional, // Loaded with using? (optional module). const variable_map& hints); // Configuration hints (see below). + struct module_functions + { + module_boot_function* boot; + module_init_function* init; + }; + // The register() function will be written in C++ and will be called from + // C++ but we need to suppress name mangling to be able to use dlsym() and + // equivalent. + // + extern "C" + using module_register_function = module_functions (); + + // Loaded modules state. + // struct module_state { bool boot; // True if the module boot'ed but not yet init'ed. @@ -93,12 +105,6 @@ namespace build2 // Builtin modules. // - struct module_functions - { - module_boot_function* boot; - module_init_function* init; - }; - using available_module_map = std::map<string, module_functions>; extern available_module_map builtin_modules; } |