Skip to content

Commit

Permalink
fix clang-specific note about std::move() vs using std::move + move()
Browse files Browse the repository at this point in the history
  • Loading branch information
pachadotdev committed Nov 20, 2024
1 parent 86278b7 commit 0371290
Show file tree
Hide file tree
Showing 33 changed files with 39,912 additions and 40,332 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ redatam_0.0.1_amd64.deb
redatamguiwindows/__/gui/moc_mainwindow.cpp
redatamguiwindows/__/gui/moc_mainwindow.cpp_parameters
redatamguiwindows/gui/moc_mainwindow.cpp_parameters
dev/cpp11-0.5.0
dev/pybind11-2.13.6
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Open Redatam <img src="rpkg/man/figures/logo.svg" align="right" height="139" alt="" />

[![Version](https://img.shields.io/github/v/release/pachadotdev/open-redatam)](https://github.com/pachadotdev/open-redatam/releases)
[![Ubuntu app](https://github.com/pachadotdev/open-redatam/actions/workflows/build-ubuntu.yml/badge.svg)](https://github.com/pachadotdev/open-redatam/actions/workflows/build-ubuntu.yml)
[![Mac app](https://github.com/pachadotdev/open-redatam/actions/workflows/build-mac.yml/badge.svg)](https://github.com/pachadotdev/open-redatam/actions/workflows/build-mac.yml)
[![Build Windows executables](https://github.com/pachadotdev/open-redatam/actions/workflows/build-windows.yml/badge.svg)](https://github.com/pachadotdev/open-redatam/actions/workflows/build-windows.yml)
Expand Down
43 changes: 38 additions & 5 deletions dev/06-format-code.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,54 @@
#!/bin/bash

# Find clang-format
# Find clang-format and clang-tidy
clang_format=$(which clang-format-19)
clang_tidy=$(which clang-tidy-19)

# Check if clang-format is installed
if [ -z "$clang_format" ]; then
echo "clang-format-19 is not installed. Please install it first."
exit 1
fi

# Find all .h, .hpp, and .cpp files, excluding those in the vendor/ directory
files=$(find . -path ./vendor -path ./rpkg/src/vendor -path ./pypkg/redatam/vendor -prune -o -name '*.h' -o -name '*.hpp' -o -name '*.cpp' -print)
# Check if clang-tidy is installed
if [ -z "$clang_tidy" ]; then
echo "clang-tidy-19 is not installed. Please install it first."
exit 1
fi

# Format each file
# Find relevant files, excluding specific directories
files=$(find . \( -path './dev' -o -path './vendor' -o -path './rpkg' -o -path './pypkg' -o -path './gui' \) -prune -o \
-type f \( -name '*.hpp' -o -name '*.cpp' \) -print)

# Format each file with clang-format
for file in $files; do
echo "Formatting $file"
$clang_format -i "$file"
done

echo "Formatting complete."
# Include directories (using absolute paths)
include_dirs=(
"-I$(realpath ./include)"
"-I$(realpath ./include/database)"
"-I$(realpath ./include/entities)"
"-I$(realpath ./include/exporters)"
"-I$(realpath ./include/readers)"
"-I$(realpath ./include/utils)"
"-I$(realpath ./src)"
"-I$(realpath ./src/database)"
"-I$(realpath ./src/entities)"
"-I$(realpath ./src/exporters)"
"-I$(realpath ./src/readers)"
"-I$(realpath ./src/utils)"
"-I$(realpath ./vendor/pugixml)"
)

# Apply clang-tidy to each .cpp file
for file in $files; do
if [[ $file == *.cpp ]]; then
echo "Running clang-tidy on $file"
$clang_tidy "$file" --extra-arg=-v -- -std=c++11 ${include_dirs[@]}
fi
done

echo "Formatting and clang-tidy checks complete."
2 changes: 1 addition & 1 deletion pypkg/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "redatam"
version = "2.0.0"
version = "2.1.0"
description = "A package for Redatam data conversion"
authors = [
{ name="Mauricio Vargas Sepulveda", email="[email protected]" }
Expand Down
5 changes: 1 addition & 4 deletions pypkg/redatamlib/entity/Entity.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "Entity.hpp"

namespace RedatamLib {

using std::make_shared;
using std::move;

Entity::Entity()
: m_name(""), m_parentName(""), m_description(""), m_indexFilename(""),
Expand Down Expand Up @@ -50,7 +48,6 @@ Entity *Entity::GetChild() const { return m_child; }
void Entity::AttachChild(Entity *child) { m_child = child; }

void Entity::AttachVariables(shared_ptr<vector<Variable>> variables) {
m_variables = move(variables);
m_variables = std::move(variables);
}

} // namespace RedatamLib
5 changes: 1 addition & 4 deletions pypkg/redatamlib/entity/Variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#include "ByteArrayReader.hpp"

namespace RedatamLib {

using std::make_shared;
using std::move;
using std::out_of_range;

Variable::Variable()
Expand All @@ -18,7 +16,7 @@ Variable::Variable(const string &name, VarType type, const string &idxFileName,
vector<Tag> tags, const string &description, size_t decimals)
: m_name(name), m_type(type), m_idxFileName(idxFileName),
m_dataSize(dataSize), m_filter(filter), m_range(range),
m_tags(move(tags)), m_description(description), m_decimals(decimals) {
m_tags(std::move(tags)), m_description(description), m_decimals(decimals) {
ParseValues();
}

Expand Down Expand Up @@ -159,5 +157,4 @@ void Variable::ParseBIN(size_t size, ByteArrayReader &reader) {

m_values = vals;
}

} // namespace RedatamLib
2 changes: 0 additions & 2 deletions pypkg/redatamlib/exporters/ParentIDCalculator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "ParentIDCalculator.hpp"

namespace RedatamLib {

ParentIDCalculator::ParentIDCalculator(Entity *child)
: m_child(child), m_currID(0), m_currLimit(0) {}

Expand All @@ -13,5 +12,4 @@ size_t ParentIDCalculator::GetParentID(size_t currRow) {

return m_currID;
}

} // namespace RedatamLib
2 changes: 0 additions & 2 deletions pypkg/redatamlib/exporters/PyDictExporter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <pybind11/stl.h>

namespace RedatamLib {

using pybind11::dict;
using std::string;
using std::vector;
Expand All @@ -30,5 +29,4 @@ class PyDictExporter {
};

} // namespace RedatamLib

#endif // PYDICTEXPORTER_HPP
2 changes: 0 additions & 2 deletions pypkg/redatamlib/readers/BitArrayReader.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "BitArrayReader.hpp"

namespace RedatamLib {

BitArrayReader::BitArrayReader(size_t dataSize)
: m_varSize(dataSize), m_remainderSize(0), m_mask(CreateMask(dataSize)),
m_data(0), m_remainder(0) {}
Expand Down Expand Up @@ -42,5 +41,4 @@ void BitArrayReader::ParseBits(std::vector<uint32_t> *results, uint32_t data) {
m_remainderSize -= m_varSize;
}
}

} // namespace RedatamLib
2 changes: 0 additions & 2 deletions pypkg/redatamlib/readers/ByteArrayReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "utils/utils.hpp"

namespace RedatamLib {

using std::all_of;
using std::bad_alloc;
using std::copy;
Expand Down Expand Up @@ -210,5 +209,4 @@ uint32_t ByteArrayReader::ReadInt32BE() {
uint32_t b = static_cast<uint32_t>(ReadInt16BE());
return a | b;
}

} // namespace RedatamLib
5 changes: 1 addition & 4 deletions pypkg/redatamlib/readers/FuzzyEntityParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include "utils/utils.hpp" // GetFileExtension, ThrowIfBad

namespace RedatamLib {

using std::make_pair;
using std::move;
using std::out_of_range;
using std::pair;
using std::runtime_error;
Expand All @@ -22,7 +20,7 @@ vector<Entity> FuzzyEntityParser::ParseEntities() {
while (true) {
curr = TryGetEntity();
if (curr.first) {
ret.push_back(move(curr.second));
ret.push_back(std::move(curr.second));
} else {
m_reader.MovePos(1);
}
Expand Down Expand Up @@ -97,5 +95,4 @@ void FuzzyEntityParser::AssignChildren(
}
}
}

} // namespace RedatamLib
2 changes: 0 additions & 2 deletions pypkg/redatamlib/readers/FuzzyEntityParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <vector>

namespace RedatamLib {

using std::pair;
using std::string;
using std::unordered_map;
Expand Down Expand Up @@ -40,5 +39,4 @@ class FuzzyEntityParser {
};

} // namespace RedatamLib

#endif // REDATAMLIB_FUZZYENTITYPARSER_HPP
5 changes: 1 addition & 4 deletions pypkg/redatamlib/readers/XMLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
#include "utils/utils.hpp"

namespace RedatamLib {

using pugi::xml_node;
using pybind11::print;
using std::exception;
using std::make_shared;
using std::move;
using std::runtime_error;
using std::stoi;
using std::string;
Expand Down Expand Up @@ -76,7 +74,7 @@ xml_node XMLParser::ParseEntity(vector<Entity> *results, xml_node node,
shared_ptr<vector<Variable>> variables = ParseVariables(node);
curr.AttachVariables(variables);

results->push_back(move(curr));
results->push_back(std::move(curr));

xml_node child = node.child("entity");
return child;
Expand Down Expand Up @@ -170,5 +168,4 @@ vector<Tag> XMLParser::ParseVarTags(xml_node var) {

return ret;
}

} // namespace RedatamLib
9 changes: 4 additions & 5 deletions pypkg/vendor/pugiconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
// #define PUGIXML_NO_EXCEPTIONS

// Set this to control attributes for public classes/functions, i.e.:
// #define PUGIXML_API __declspec(dllexport) // to export all public symbols
// from DLL #define PUGIXML_CLASS __declspec(dllimport) // to import all classes
// from DLL #define PUGIXML_FUNCTION __fastcall // to set calling conventions to
// all public functions to fastcall In absence of PUGIXML_CLASS/PUGIXML_FUNCTION
// definitions PUGIXML_API is used instead
// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL
// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL
// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall
// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead

// Tune these constants to adjust memory-related behavior
// #define PUGIXML_MEMORY_PAGE_SIZE 32768
Expand Down
Loading

0 comments on commit 0371290

Please sign in to comment.