Skip to content

Commit

Permalink
upgraded to swig 4.3.0 (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonvw authored Nov 2, 2024
1 parent f1cfb59 commit 7512bb7
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 26 deletions.
28 changes: 13 additions & 15 deletions bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()

Expand All @@ -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()
10 changes: 10 additions & 0 deletions bindings/wex.i
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Copyright: (c) 2023-2024 Anton van Wezenbeek
////////////////////////////////////////////////////////////////////////////////

%include <std_filesystem.i>
%include <std_pair.i>
%include <std_sstream.i>
%include <std_string.i>
Expand All @@ -15,9 +16,12 @@

%module wex
%{
#include <wex/common/wex.h>
#include <wex/core/wex.h>
#include <wex/factory/wex.h>
%}

%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"
Expand All @@ -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"
4 changes: 2 additions & 2 deletions include/wex/common/statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -93,7 +93,7 @@ template <class T> class statistics
};

/// Returns the items.
const auto& get_items() const { return m_items; }
const std::map<std::string, T>& get_items() const { return m_items; }

/// Increments key with value.
const T inc(const std::string& key, T inc_value = 1)
Expand Down
4 changes: 2 additions & 2 deletions include/wex/factory/sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 5 additions & 7 deletions src/factory/sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <boost/algorithm/string.hpp>
Expand Down Expand Up @@ -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<std::string, std::string> m;
std::multimap<std::string, std::string> mm;
Expand All @@ -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
{
Expand Down

0 comments on commit 7512bb7

Please sign in to comment.