diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index 9488bdd9b..a982ff68d 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -1,13 +1,13 @@ find_package(Python COMPONENTS Development Interpreter) -if (NOT Python_FOUND) +if(NOT Python_FOUND) return() endif() -find_package(SWIG 4.2.1 COMPONENTS python) +find_package(SWIG 4.3.0 COMPONENTS python) include(UseSWIG) -if (NOT SWIG_FOUND) +if(NOT SWIG_FOUND) return() endif() @@ -16,18 +16,16 @@ include_directories(${CMAKE_SOURCE_DIR}/bindings ${Python_INCLUDE_DIRS}) set_property(SOURCE wex.i PROPERTY CPLUSPLUS ON) set_property(SOURCE wex.i PROPERTY SWIG_FLAGS -std=c++23) -swig_add_library(${PROJECT_NAME} - TYPE SHARED - LANGUAGE python - SOURCES wex.i) - +swig_add_library(${PROJECT_NAME} TYPE SHARED LANGUAGE python SOURCES wex.i) + wex_target_link_all() - -if (APPLE) - set(SWIG_FILES + +if(APPLE) + set( + SWIG_FILES ${CMAKE_CURRENT_BINARY_DIR}/wex.py - ${CMAKE_CURRENT_BINARY_DIR}/_wex.dylib) + ${CMAKE_CURRENT_BINARY_DIR}/_wex.dylib + ) - install(FILES ${SWIG_FILES} - DESTINATION ${Python_SITELIB}) -endif () + install(FILES ${SWIG_FILES} DESTINATION ${Python_SITELIB}) +endif() diff --git a/bindings/wex.i b/bindings/wex.i index 290e8336a..c7322dba8 100644 --- a/bindings/wex.i +++ b/bindings/wex.i @@ -5,6 +5,7 @@ // Copyright: (c) 2023-2024 Anton van Wezenbeek //////////////////////////////////////////////////////////////////////////////// +%include %include %include %include @@ -15,9 +16,12 @@ %module wex %{ +#include #include +#include %} +%include "../include/wex/core/app.h" %include "../include/wex/core/chrono.h" %include "../include/wex/core/core.h" %include "../include/wex/core/file-status.h" @@ -26,4 +30,10 @@ %include "../include/wex/core/queue-thread.h" %include "../include/wex/core/regex.h" %include "../include/wex/core/regex-part.h" +%include "../include/wex/core/tokenize.h" +%include "../include/wex/core/types.h" %include "../include/wex/core/version.h" + +%include "../include/wex/factory/sort.h" + +%include "../include/wex/common/statistics.h" diff --git a/include/wex/common/statistics.h b/include/wex/common/statistics.h index 30cead80a..ad42de05b 100644 --- a/include/wex/common/statistics.h +++ b/include/wex/common/statistics.h @@ -2,7 +2,7 @@ // Name: statistics.h // Purpose: Include file for class wex::statistics // Author: Anton van Wezenbeek -// Copyright: (c) 2021 Anton van Wezenbeek +// Copyright: (c) 2021-2024 Anton van Wezenbeek //////////////////////////////////////////////////////////////////////////////// #pragma once @@ -93,7 +93,7 @@ template class statistics }; /// Returns the items. - const auto& get_items() const { return m_items; } + const std::map& get_items() const { return m_items; } /// Increments key with value. const T inc(const std::string& key, T inc_value = 1) diff --git a/include/wex/factory/sort.h b/include/wex/factory/sort.h index fe1a68346..fe4842512 100644 --- a/include/wex/factory/sort.h +++ b/include/wex/factory/sort.h @@ -2,7 +2,7 @@ // Name: sort.h // Purpose: Declaration of wex::sort class // Author: Anton van Wezenbeek -// Copyright: (c) 2021-2023 Anton van Wezenbeek +// Copyright: (c) 2021-2024 Anton van Wezenbeek //////////////////////////////////////////////////////////////////////////////// #pragma once @@ -46,7 +46,7 @@ class sort const std::string string( /// text to sort const std::string& input, - /// characters to split lines + /// characters to tokenize the input const std::string& separators); private: diff --git a/src/factory/sort.cpp b/src/factory/sort.cpp index dfcb6cb52..1486b0947 100644 --- a/src/factory/sort.cpp +++ b/src/factory/sort.cpp @@ -2,7 +2,7 @@ // Name: sort.cpp // Purpose: Implementation of wex::sort class // Author: Anton van Wezenbeek -// Copyright: (c) 2021-2023 Anton van Wezenbeek +// Copyright: (c) 2021-2024 Anton van Wezenbeek //////////////////////////////////////////////////////////////////////////////// #include @@ -153,12 +153,6 @@ bool wex::factory::sort::selection_other(factory::stc* stc) const std::string wex::factory::sort::string(const std::string& input, const std::string& sep) { - if (!std::all_of(sep.begin(), sep.end(), isspace)) - { - log("sort::string separator should contain whitespace only") << sep; - return input; - } - // Empty lines are not kept after sorting, as they are used as separator. std::map m; std::multimap mm; @@ -182,9 +176,13 @@ wex::factory::sort::string(const std::string& input, const std::string& sep) if (m_len == std::string::npos) { if (m_sort_t[SORT_UNIQUE]) + { m.insert({key, line}); + } else + { mm.insert({key, line}); + } } else {