diff --git a/include/chimera/mstch.h b/include/chimera/mstch.h index 7d85519..22ffd5c 100644 --- a/include/chimera/mstch.h +++ b/include/chimera/mstch.h @@ -85,7 +85,8 @@ class ClangWrapper : public ::mstch::object virtual ::std::string nameAsString() { - if (const YAML::Node node = decl_config_["name"]) + if (const YAML::Node node + = chimera::util::lookupYAMLNode(decl_config_, "name")) { // Convert a `null` to an empty string. // This helps users semantically mark names that should be @@ -108,7 +109,8 @@ class ClangWrapper : public ::mstch::object virtual ::mstch::node mangledName() { - if (const YAML::Node node = decl_config_["mangled_name"]) + if (const YAML::Node node + = chimera::util::lookupYAMLNode(decl_config_, "mangled_name")) return node.as(); return chimera::util::constructMangledName(decl_); @@ -137,7 +139,8 @@ class ClangWrapper : public ::mstch::object virtual ::mstch::node qualifiedName() { - if (const YAML::Node node = decl_config_["qualified_name"]) + if (const YAML::Node node + = chimera::util::lookupYAMLNode(decl_config_, "qualified_name")) return node.as(); return decl_->getQualifiedNameAsString(); diff --git a/include/chimera/util.h b/include/chimera/util.h index 135db7b..ce8a326 100644 --- a/include/chimera/util.h +++ b/include/chimera/util.h @@ -61,14 +61,14 @@ template YAML::Node lookupYAMLNode(const YAML::Node &node, const std::string &key, Args &&... args) { - // Return if 'node' is invalid - if (not node) + // Return if 'node' is invalid. + if (!node) return node; auto next = node[key]; - // Return if failed to find a tag of 'key' - if (not next) + // Return if failed to find a tag of 'key'. + if (!next) return next; // Lookup for the next nested tags diff --git a/src/configuration.cpp b/src/configuration.cpp index 1cc8058..0f9c870 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -169,8 +169,8 @@ const std::string &chimera::Configuration::GetOutputModuleName() const chimera::CompiledConfiguration::CompiledConfiguration( const chimera::Configuration &parent, CompilerInstance *ci) : parent_(parent) - , configNode_(parent.GetRoot()) // TODO: do we need this reference? - , bindingNode_(configNode_["template"]) // TODO: is this always ok? + , configNode_(parent.GetRoot()) // TODO: do we need this reference? + , bindingNode_(chimera::util::lookupYAMLNode(configNode_, "template")) , ci_(ci) { // This placeholder will be filled in by the options.strict specified diff --git a/test/examples/01_function/function_boost_python.yaml b/test/examples/01_function/function_boost_python.yaml index 40ed52c..c1c0d1b 100644 --- a/test/examples/01_function/function_boost_python.yaml +++ b/test/examples/01_function/function_boost_python.yaml @@ -3,8 +3,7 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null classes: - 'template chimera_test::SuppressedTemplateClass': null - 'chimera_test::SuppressedClass': null + "template chimera_test::SuppressedTemplateClass": null + "chimera_test::SuppressedClass": null diff --git a/test/examples/01_function/function_pybind11.yaml b/test/examples/01_function/function_pybind11.yaml index 40ed52c..c1c0d1b 100644 --- a/test/examples/01_function/function_pybind11.yaml +++ b/test/examples/01_function/function_pybind11.yaml @@ -3,8 +3,7 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null classes: - 'template chimera_test::SuppressedTemplateClass': null - 'chimera_test::SuppressedClass': null + "template chimera_test::SuppressedTemplateClass": null + "chimera_test::SuppressedClass": null diff --git a/test/examples/02_class/class.yaml b/test/examples/02_class/class.yaml index 477d231..c0ea4e3 100644 --- a/test/examples/02_class/class.yaml +++ b/test/examples/02_class/class.yaml @@ -3,6 +3,5 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error - 'chimera_test::detail': null + "chimera_test": null + "chimera_test::detail": null diff --git a/test/examples/03_smart_pointers/smart_pointers_boost_python.yaml b/test/examples/03_smart_pointers/smart_pointers_boost_python.yaml index 607b9a0..a663ee0 100644 --- a/test/examples/03_smart_pointers/smart_pointers_boost_python.yaml +++ b/test/examples/03_smart_pointers/smart_pointers_boost_python.yaml @@ -3,8 +3,7 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null classes: - 'chimera_test::ExampleShared': - held_type: 'std::shared_ptr' + "chimera_test::ExampleShared": + held_type: "std::shared_ptr" diff --git a/test/examples/03_smart_pointers/smart_pointers_pybind11.yaml b/test/examples/03_smart_pointers/smart_pointers_pybind11.yaml index 607b9a0..a663ee0 100644 --- a/test/examples/03_smart_pointers/smart_pointers_pybind11.yaml +++ b/test/examples/03_smart_pointers/smart_pointers_pybind11.yaml @@ -3,8 +3,7 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null classes: - 'chimera_test::ExampleShared': - held_type: 'std::shared_ptr' + "chimera_test::ExampleShared": + held_type: "std::shared_ptr" diff --git a/test/examples/04_enumeration/enumeration.yaml b/test/examples/04_enumeration/enumeration.yaml index 0112083..ce2b754 100644 --- a/test/examples/04_enumeration/enumeration.yaml +++ b/test/examples/04_enumeration/enumeration.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/05_variable/variable.yaml b/test/examples/05_variable/variable.yaml index 0112083..ce2b754 100644 --- a/test/examples/05_variable/variable.yaml +++ b/test/examples/05_variable/variable.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/20_eigen/eigen_boost_python.yaml b/test/examples/20_eigen/eigen_boost_python.yaml index 83f8de0..eafe101 100644 --- a/test/examples/20_eigen/eigen_boost_python.yaml +++ b/test/examples/20_eigen/eigen_boost_python.yaml @@ -3,9 +3,8 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null # Boost.Python < 1.65.1 doesn't work for Eigen::Map parameter # Once Boost.Python >= 1.65.1 becomes the minimum required version, remove followings classes: - 'template class Eigen::Map': null + "template class Eigen::Map": null diff --git a/test/examples/20_eigen/eigen_pybind11.yaml b/test/examples/20_eigen/eigen_pybind11.yaml index f7f3235..43fe12f 100644 --- a/test/examples/20_eigen/eigen_pybind11.yaml +++ b/test/examples/20_eigen/eigen_pybind11.yaml @@ -3,11 +3,10 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null template: file: header: | #include classes: - 'template class Eigen::Map': null + "template class Eigen::Map": null diff --git a/test/examples/30_pybind11_examples/01_basics/01_first_steps/chimera_boost_python.yaml b/test/examples/30_pybind11_examples/01_basics/01_first_steps/chimera_boost_python.yaml index 0112083..ce2b754 100644 --- a/test/examples/30_pybind11_examples/01_basics/01_first_steps/chimera_boost_python.yaml +++ b/test/examples/30_pybind11_examples/01_basics/01_first_steps/chimera_boost_python.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/30_pybind11_examples/01_basics/01_first_steps/chimera_pybind11.yaml b/test/examples/30_pybind11_examples/01_basics/01_first_steps/chimera_pybind11.yaml index 0112083..ce2b754 100644 --- a/test/examples/30_pybind11_examples/01_basics/01_first_steps/chimera_pybind11.yaml +++ b/test/examples/30_pybind11_examples/01_basics/01_first_steps/chimera_pybind11.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/30_pybind11_examples/01_basics/02_object_oriented_code/chimera_boost_python.yaml b/test/examples/30_pybind11_examples/01_basics/02_object_oriented_code/chimera_boost_python.yaml index 050d077..87c0fb9 100644 --- a/test/examples/30_pybind11_examples/01_basics/02_object_oriented_code/chimera_boost_python.yaml +++ b/test/examples/30_pybind11_examples/01_basics/02_object_oriented_code/chimera_boost_python.yaml @@ -3,8 +3,7 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - "chimera_test": - name: null # TODO: otherwise, import error + "chimera_test": null types: "const std::string &": return_value_policy: copy_const_reference diff --git a/test/examples/30_pybind11_examples/01_basics/02_object_oriented_code/chimera_pybind11.yaml b/test/examples/30_pybind11_examples/01_basics/02_object_oriented_code/chimera_pybind11.yaml index 56d0dc6..a9d831f 100644 --- a/test/examples/30_pybind11_examples/01_basics/02_object_oriented_code/chimera_pybind11.yaml +++ b/test/examples/30_pybind11_examples/01_basics/02_object_oriented_code/chimera_pybind11.yaml @@ -3,8 +3,7 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - "chimera_test": - name: null # TODO: otherwise, import error + "chimera_test": null types: "const std::string &": return_value_policy: copy diff --git a/test/examples/30_pybind11_examples/02_advanced/01_functions/chimera_boost_python.yaml b/test/examples/30_pybind11_examples/02_advanced/01_functions/chimera_boost_python.yaml index 0112083..ce2b754 100644 --- a/test/examples/30_pybind11_examples/02_advanced/01_functions/chimera_boost_python.yaml +++ b/test/examples/30_pybind11_examples/02_advanced/01_functions/chimera_boost_python.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/30_pybind11_examples/02_advanced/01_functions/chimera_pybind11.yaml b/test/examples/30_pybind11_examples/02_advanced/01_functions/chimera_pybind11.yaml index 0112083..ce2b754 100644 --- a/test/examples/30_pybind11_examples/02_advanced/01_functions/chimera_pybind11.yaml +++ b/test/examples/30_pybind11_examples/02_advanced/01_functions/chimera_pybind11.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/30_pybind11_examples/02_advanced/02_classes/chimera_boost_python.yaml b/test/examples/30_pybind11_examples/02_advanced/02_classes/chimera_boost_python.yaml index 0112083..ce2b754 100644 --- a/test/examples/30_pybind11_examples/02_advanced/02_classes/chimera_boost_python.yaml +++ b/test/examples/30_pybind11_examples/02_advanced/02_classes/chimera_boost_python.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/30_pybind11_examples/02_advanced/02_classes/chimera_pybind11.yaml b/test/examples/30_pybind11_examples/02_advanced/02_classes/chimera_pybind11.yaml index fe4ed47..a5d4201 100644 --- a/test/examples/30_pybind11_examples/02_advanced/02_classes/chimera_pybind11.yaml +++ b/test/examples/30_pybind11_examples/02_advanced/02_classes/chimera_pybind11.yaml @@ -3,8 +3,7 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - "chimera_test": - name: null # TODO: otherwise, import error + "chimera_test": null classes: "chimera_test::Animal": allow_inheritance: True diff --git a/test/examples/99_dart_example/dart_example.yaml b/test/examples/99_dart_example/dart_example.yaml index 736433a..25a7851 100644 --- a/test/examples/99_dart_example/dart_example.yaml +++ b/test/examples/99_dart_example/dart_example.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'dart': - name: null # TODO: otherwise, import error + "dart": diff --git a/test/examples/regression/issue148_lambda_function/boost_python.yaml b/test/examples/regression/issue148_lambda_function/boost_python.yaml index 0112083..ce2b754 100644 --- a/test/examples/regression/issue148_lambda_function/boost_python.yaml +++ b/test/examples/regression/issue148_lambda_function/boost_python.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/regression/issue148_lambda_function/pybind11.yaml b/test/examples/regression/issue148_lambda_function/pybind11.yaml index 0112083..ce2b754 100644 --- a/test/examples/regression/issue148_lambda_function/pybind11.yaml +++ b/test/examples/regression/issue148_lambda_function/pybind11.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/regression/issue216_template_param/issue216_template_param_boost_python.yaml b/test/examples/regression/issue216_template_param/issue216_template_param_boost_python.yaml index 0112083..ce2b754 100644 --- a/test/examples/regression/issue216_template_param/issue216_template_param_boost_python.yaml +++ b/test/examples/regression/issue216_template_param/issue216_template_param_boost_python.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/regression/issue216_template_param/issue216_template_param_pybind11.yaml b/test/examples/regression/issue216_template_param/issue216_template_param_pybind11.yaml index 0112083..ce2b754 100644 --- a/test/examples/regression/issue216_template_param/issue216_template_param_pybind11.yaml +++ b/test/examples/regression/issue216_template_param/issue216_template_param_pybind11.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/regression/issue228_template_type_alias/issue228_template_type_alias_boost_python.yaml b/test/examples/regression/issue228_template_type_alias/issue228_template_type_alias_boost_python.yaml index 0112083..ce2b754 100644 --- a/test/examples/regression/issue228_template_type_alias/issue228_template_type_alias_boost_python.yaml +++ b/test/examples/regression/issue228_template_type_alias/issue228_template_type_alias_boost_python.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null diff --git a/test/examples/regression/issue228_template_type_alias/issue228_template_type_alias_pybind11.yaml b/test/examples/regression/issue228_template_type_alias/issue228_template_type_alias_pybind11.yaml index 0112083..ce2b754 100644 --- a/test/examples/regression/issue228_template_type_alias/issue228_template_type_alias_pybind11.yaml +++ b/test/examples/regression/issue228_template_type_alias/issue228_template_type_alias_pybind11.yaml @@ -3,5 +3,4 @@ arguments: - "-extra-arg" - "-I/usr/lib/clang/3.6/include" namespaces: - 'chimera_test': - name: null # TODO: otherwise, import error + "chimera_test": null