Skip to content

Commit

Permalink
Remove most compilation warnings and fix non-MicroTeX build.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasper Peeters committed Apr 12, 2024
1 parent 20f931b commit 78be2f9
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
message(FATAL_ERROR "GCC version must be at least 4.9 for regex support! See http://askubuntu.com/questions/428198/getting-installing-gcc-g-4-9-on-ubuntu and then set the environment variables CXX to g++-4.9 and CC to gcc-4.9. You may have to erase the build directory before re-running cmake.")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -Wall -fvisibility=hidden -Wno-unused-but-set-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -Wall -Wextra -Wunused -fvisibility=hidden -Wno-unused-but-set-variable -Wno-unused-parameter")
endif()

# Clang
Expand All @@ -198,7 +198,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
message(FATAL_ERROR "Clang version must be at least 3.5 to avoid known bugs.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -fvisibility=hidden -Wall -Wextra -Wunused")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -fvisibility=hidden -Wall -Wextra -Wunused -Wno-unused-parameter")
endif()

# Visual Studio
Expand Down
2 changes: 1 addition & 1 deletion core/NEvaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ NTensor NEvaluator::evaluate()

void NEvaluator::set_variable(const Ex& var, const NTensor& val)
{
variable_values.push_back( VariableValues({var, val}) );
variable_values.push_back( VariableValues({var, val, {} }) );
}

void NEvaluator::find_variable_locations()
Expand Down
11 changes: 11 additions & 0 deletions core/Storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ namespace cadabra {
// std::cout << "Ex copy constructor" << std::endl;
}

Ex& Ex::operator=(Ex other)
{
std::swap(static_cast<tree<str_node>&>(*this),
static_cast<tree<str_node>&>(other));
std::swap((*this).state_, other.state_);
std::swap((*this).history, other.history);
std::swap((*this).terms, other.terms);

return *this;
}

Ex::Ex(const std::string& str)
: state_(result_t::l_no_action)
{
Expand Down
2 changes: 2 additions & 0 deletions core/Storage.hh
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ namespace cadabra {
Ex(const std::string&);
Ex(int);

Ex& operator=(Ex);

/// Keeping track of what algorithms have done to this expression.
/// After a reset_state (or at initialisation), the expression sits
/// in the 'checkpointed' state. When an algorithm acts, it can then
Expand Down
10 changes: 10 additions & 0 deletions core/YoungTab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ namespace yngtab {
{
}

tableau::tableau()
: tableau_base()
{
}

tableau::tableau(const tableau& other)
{
rows=other.rows;
}

void tableau_base::add_row(unsigned int row_size)
{
assert(row_size>0);
Expand Down
18 changes: 18 additions & 0 deletions core/YoungTab.hh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ namespace yngtab {

class tableau : public tableau_base {
public:
tableau();
tableau(const tableau&);

virtual ~tableau();
virtual unsigned int number_of_rows() const;
virtual unsigned int row_size(unsigned int row) const;
Expand All @@ -85,6 +88,9 @@ namespace yngtab {
public:
typedef T value_type;

filled_tableau();
filled_tableau(const filled_tableau<T>&);

virtual ~filled_tableau();
virtual unsigned int number_of_rows() const;
virtual unsigned int row_size(unsigned int row) const;
Expand Down Expand Up @@ -1716,6 +1722,18 @@ namespace yngtab {
}
}

template<class T>
filled_tableau<T>::filled_tableau()
: tableau()
{
}

template<class T>
filled_tableau<T>::filled_tableau(const filled_tableau<T>& other)
: tableau(other), rows(other.rows)
{
}

template<class T>
filled_tableau<T>& filled_tableau<T>::operator=(const filled_tableau<T>& other)
{
Expand Down
3 changes: 2 additions & 1 deletion core/algorithms/fierz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ Algorithm::result_t fierz::apply(iterator& it)
locgam2=tmpit;
if(i==0) cpyterm.erase(locgam2);
else cpyterm.erase_children(locgam2);
if(i>0)
if(i>0) {
DEBUG( std::cerr << "New gamma reads " << Ex(locgam2) << std::endl; );
}
}

++cpit;
Expand Down
43 changes: 40 additions & 3 deletions core/tree.hh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

// STL-like templated tree class.
//
// Copyright (C) 2001-2023 Kasper Peeters <[email protected]>
// Copyright (C) 2001-2024 Kasper Peeters <[email protected]>
// Distributed under the GNU General Public License version 3.
//
// Special permission to use tree.hh under the conditions of a
// different license can be requested from the author.

/** \mainpage tree.hh
\author Kasper Peeters
\version 3.19
\date 2023-11-17
\version 3.20
\date 2024-04-12
\see http://github.com/kpeeters/tree.hh/
The tree.hh library for C++ provides an STL-like container class
Expand Down Expand Up @@ -223,6 +223,9 @@ class tree {
fixed_depth_iterator(const sibling_iterator&);
fixed_depth_iterator(const fixed_depth_iterator&);

void swap(fixed_depth_iterator&, fixed_depth_iterator&);
fixed_depth_iterator& operator=(fixed_depth_iterator);

bool operator==(const fixed_depth_iterator&) const;
bool operator!=(const fixed_depth_iterator&) const;
fixed_depth_iterator& operator++();
Expand All @@ -243,6 +246,9 @@ class tree {
sibling_iterator(const sibling_iterator&);
sibling_iterator(const iterator_base&);

void swap(sibling_iterator&, sibling_iterator&);
sibling_iterator& operator=(sibling_iterator);

bool operator==(const sibling_iterator&) const;
bool operator!=(const sibling_iterator&) const;
sibling_iterator& operator++();
Expand Down Expand Up @@ -3003,6 +3009,21 @@ tree<T, tree_node_allocator>::fixed_depth_iterator::fixed_depth_iterator(const f
{
}

template <class T, class tree_node_allocator>
void tree<T, tree_node_allocator>::fixed_depth_iterator::swap(fixed_depth_iterator& first, fixed_depth_iterator& second)
{
std::swap(first.node, second.node);
std::swap(first.skip_current_children_, second.skip_current_children_);
std::swap(first.top_node, second.top_node);
}

template <class T, class tree_node_allocator>
typename tree<T, tree_node_allocator>::fixed_depth_iterator& tree<T, tree_node_allocator>::fixed_depth_iterator::operator=(fixed_depth_iterator other)
{
swap(*this, other);
return *this;
}

template <class T, class tree_node_allocator>
bool tree<T, tree_node_allocator>::fixed_depth_iterator::operator==(const fixed_depth_iterator& other) const
{
Expand Down Expand Up @@ -3185,6 +3206,22 @@ tree<T, tree_node_allocator>::sibling_iterator::sibling_iterator(const sibling_i
{
}

template <class T, class tree_node_allocator>
void tree<T, tree_node_allocator>::sibling_iterator::swap(sibling_iterator& first, sibling_iterator& second)
{
std::swap(first.node, second.node);
std::swap(first.skip_current_children_, second.skip_current_children_);
std::swap(first.parent_, second.parent_);
}


template <class T, class tree_node_allocator>
typename tree<T, tree_node_allocator>::sibling_iterator& tree<T, tree_node_allocator>::sibling_iterator::operator=(sibling_iterator other)
{
swap(*this, other);
return *this;
}

template <class T, class tree_node_allocator>
void tree<T, tree_node_allocator>::sibling_iterator::set_parent_()
{
Expand Down
5 changes: 4 additions & 1 deletion frontend/gtkmm/TeXView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ void TeXView::update_image()
float new_size = text_size();
if(image._text_size != new_size) {
image._text_size = new_size;
#ifdef USE_MICROTEX
image.layout_latex();
#endif
}
image.update_image(content, engine.get_scale());
}
Expand Down Expand Up @@ -344,8 +346,9 @@ void TeXView::TeXArea::set_latex(const std::string& latex)
TeXView::TeXArea::TeXArea()
: rendering_width(1)
#ifdef USE_MICROTEX
, _render(nullptr), _text_size(5.f), padding_x(15), padding_y(20)
, _render(nullptr), _text_size(5.f)
#endif
, padding_x(15), padding_y(20)
{
set_hexpand(true);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/gtkmm/TeXView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ namespace cadabra {

#ifdef USE_MICROTEX
mutable tex::TeXRender* _render;
int padding_x, padding_y;
std::string unfixed, fixed;
#endif
int padding_x, padding_y;
};

TeXArea image;
Expand Down

0 comments on commit 78be2f9

Please sign in to comment.