Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .github/scripts/rename/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ run from the repository root.
4. `.github/scripts/rename/binary.sh`: This script will rename the binary from
`rippled` to `xrpld`, and reverses the symlink so that `rippled` points to
the `xrpld` binary.
5. `.github/scripts/rename/namespace.sh`: This script will rename the C++
namespaces from `ripple` to `xrpl`.

You can run all these scripts from the repository root as follows:

Expand All @@ -37,4 +39,5 @@ You can run all these scripts from the repository root as follows:
./.github/scripts/rename/copyright.sh .
./.github/scripts/rename/cmake.sh .
./.github/scripts/rename/binary.sh .
./.github/scripts/rename/namespace.sh .
```
58 changes: 58 additions & 0 deletions .github/scripts/rename/namespace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# Exit the script as soon as an error occurs.
set -e

# On MacOS, ensure that GNU sed is installed and available as `gsed`.
SED_COMMAND=sed
if [[ "${OSTYPE}" == 'darwin'* ]]; then
if ! command -v gsed &> /dev/null; then
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
exit 1
fi
SED_COMMAND=gsed
fi

# This script renames the `ripple` namespace to `xrpl` in this project.
# Specifically, it renames all occurrences of `namespace ripple` and `ripple::`
# to `namespace xrpl` and `xrpl::`, respectively, by scanning all header and
# source files in the specified directory and its subdirectories, as well as any
# occurrences in the documentation. It also renames them in the test suites.
# Usage: .github/scripts/rename/namespace.sh <repository directory>

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <repository directory>"
exit 1
fi

DIRECTORY=$1
echo "Processing directory: ${DIRECTORY}"
if [ ! -d "${DIRECTORY}" ]; then
echo "Error: Directory '${DIRECTORY}' does not exist."
exit 1
fi
pushd ${DIRECTORY}

DIRECTORIES=("include" "src" "tests")
for DIRECTORY in "${DIRECTORIES[@]}"; do
echo "Processing directory: ${DIRECTORY}"

find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.cpp" \) | while read -r FILE; do
echo "Processing file: ${FILE}"
${SED_COMMAND} -i 's/namespace ripple/namespace xrpl/g' "${FILE}"
${SED_COMMAND} -i 's/ripple::/xrpl::/g' "${FILE}"
${SED_COMMAND} -i -E 's/(BEAST_DEFINE_TESTSUITE.+)ripple(.+)/\1xrpl\2/g' "${FILE}"
done
done

# Special case for NuDBFactory that has ripple twice in the test suite name.
${SED_COMMAND} -i -E 's/(BEAST_DEFINE_TESTSUITE.+)ripple(.+)/\1xrpl\2/g' src/test/nodestore/NuDBFactory_test.cpp

DIRECTORY=$1
find "${DIRECTORY}" -type f -name "*.md" | while read -r FILE; do
echo "Processing file: ${FILE}"
${SED_COMMAND} -i 's/ripple::/xrpl::/g' "${FILE}"
done

popd
echo "Renaming complete."
2 changes: 2 additions & 0 deletions .github/workflows/reusable-check-rename.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
run: .github/scripts/rename/cmake.sh .
- name: Check binary name
run: .github/scripts/rename/binary.sh .
- name: Check namespaces
run: .github/scripts/rename/namespace.sh .
- name: Check for differences
env:
MESSAGE: |
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ For this reason:
- Example **bad** name
`"RFC1751::insert(char* s, int x, int start, int length) : length is greater than or equal zero"`
(missing namespace, unnecessary full function signature, description too verbose).
Good name: `"ripple::RFC1751::insert : minimum length"`.
Good name: `"xrpl::RFC1751::insert : minimum length"`.
- In **few** well-justified cases a non-standard name can be used, in which case a
comment should be placed to explain the rationale (example in `contract.cpp`)
- Do **not** rename a contract without a good reason (e.g. the name no longer
Expand Down
4 changes: 2 additions & 2 deletions include/xrpl/basics/Archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <boost/filesystem.hpp>

namespace ripple {
namespace xrpl {

/** Extract a tar archive compressed with lz4

Expand All @@ -17,6 +17,6 @@ extractTarLz4(
boost::filesystem::path const& src,
boost::filesystem::path const& dst);

} // namespace ripple
} // namespace xrpl

#endif
4 changes: 2 additions & 2 deletions include/xrpl/basics/BasicConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <unordered_map>
#include <vector>

namespace ripple {
namespace xrpl {

using IniFileSections =
std::unordered_map<std::string, std::vector<std::string>>;
Expand Down Expand Up @@ -380,6 +380,6 @@ get_if_exists<bool>(Section const& section, std::string const& name, bool& v)
return stat;
}

} // namespace ripple
} // namespace xrpl

#endif
4 changes: 2 additions & 2 deletions include/xrpl/basics/Blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#include <vector>

namespace ripple {
namespace xrpl {

/** Storage for linear binary data.
Blocks of binary data appear often in various idioms and structures.
*/
using Blob = std::vector<unsigned char>;

} // namespace ripple
} // namespace xrpl

#endif
6 changes: 3 additions & 3 deletions include/xrpl/basics/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <cstring>
#include <memory>

namespace ripple {
namespace xrpl {

/** Like std::vector<char> but better.
Meets the requirements of BufferFactory.
Expand Down Expand Up @@ -96,7 +96,7 @@ class Buffer
XRPL_ASSERT(
s.size() == 0 || size_ == 0 || s.data() < p_.get() ||
s.data() >= p_.get() + size_,
"ripple::Buffer::operator=(Slice) : input not a subset");
"xrpl::Buffer::operator=(Slice) : input not a subset");

if (auto p = alloc(s.size()))
std::memcpy(p, s.data(), s.size());
Expand Down Expand Up @@ -215,6 +215,6 @@ operator!=(Buffer const& lhs, Buffer const& rhs) noexcept
return !(lhs == rhs);
}

} // namespace ripple
} // namespace xrpl

#endif
4 changes: 2 additions & 2 deletions include/xrpl/basics/ByteUtilities.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef XRPL_BASICS_BYTEUTILITIES_H_INCLUDED
#define XRPL_BASICS_BYTEUTILITIES_H_INCLUDED

namespace ripple {
namespace xrpl {

template <class T>
constexpr auto
Expand All @@ -19,6 +19,6 @@ megabytes(T value) noexcept

static_assert(kilobytes(2) == 2048, "kilobytes(2) == 2048");
static_assert(megabytes(3) == 3145728, "megabytes(3) == 3145728");
} // namespace ripple
} // namespace xrpl

#endif
4 changes: 2 additions & 2 deletions include/xrpl/basics/CompressionAlgorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <stdexcept>
#include <vector>

namespace ripple {
namespace xrpl {

namespace compression_algorithms {

Expand Down Expand Up @@ -144,6 +144,6 @@ lz4Decompress(

} // namespace compression_algorithms

} // namespace ripple
} // namespace xrpl

#endif // XRPL_COMPRESSIONALGORITHMS_H_INCLUDED
4 changes: 2 additions & 2 deletions include/xrpl/basics/CountedObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <utility>
#include <vector>

namespace ripple {
namespace xrpl {

/** Manages all counted object types. */
class CountedObjects
Expand Down Expand Up @@ -133,6 +133,6 @@ class CountedObject
}
};

} // namespace ripple
} // namespace xrpl

#endif
4 changes: 2 additions & 2 deletions include/xrpl/basics/DecayingSample.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <chrono>
#include <cmath>

namespace ripple {
namespace xrpl {

/** Sampling function using exponential decay to provide a continuous value.
@tparam The number of seconds in the decay window.
Expand Down Expand Up @@ -131,6 +131,6 @@ class DecayWindow
time_point when_;
};

} // namespace ripple
} // namespace xrpl

#endif
4 changes: 2 additions & 2 deletions include/xrpl/basics/Expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <stdexcept>

namespace ripple {
namespace xrpl {

/** Expected is an approximation of std::expected (hoped for in C++23)

Expand Down Expand Up @@ -232,6 +232,6 @@ class [[nodiscard]] Expected<void, E>
}
};

} // namespace ripple
} // namespace xrpl

#endif // XRPL_BASICS_EXPECTED_H_INCLUDED
4 changes: 2 additions & 2 deletions include/xrpl/basics/FileUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <optional>

namespace ripple {
namespace xrpl {

std::string
getFileContents(
Expand All @@ -20,6 +20,6 @@ writeFileContents(
boost::filesystem::path const& destPath,
std::string const& contents);

} // namespace ripple
} // namespace xrpl

#endif
4 changes: 2 additions & 2 deletions include/xrpl/basics/IntrusivePointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <type_traits>
#include <utility>

namespace ripple {
namespace xrpl {

//------------------------------------------------------------------------------

Expand Down Expand Up @@ -492,5 +492,5 @@ dynamic_pointer_cast(TT const& v)
return SharedPtr<T>(DynamicCastTagSharedIntrusive{}, v);
}
} // namespace intr_ptr
} // namespace ripple
} // namespace xrpl
#endif
8 changes: 4 additions & 4 deletions include/xrpl/basics/IntrusivePointer.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <utility>

namespace ripple {
namespace xrpl {

template <class T>
template <CAdoptTag TAdoptTag>
Expand Down Expand Up @@ -608,7 +608,7 @@ SharedWeakUnion<T>::convertToStrong()
[[maybe_unused]] auto action = p->releaseWeakRef();
XRPL_ASSERT(
(action == ReleaseWeakRefAction::noop),
"ripple::SharedWeakUnion::convertToStrong : "
"xrpl::SharedWeakUnion::convertToStrong : "
"action is noop");
unsafeSetRawPtr(p, RefStrength::strong);
return true;
Expand Down Expand Up @@ -637,7 +637,7 @@ SharedWeakUnion<T>::convertToWeak()
// We just added a weak ref. How could we destroy?
// LCOV_EXCL_START
UNREACHABLE(
"ripple::SharedWeakUnion::convertToWeak : destroying freshly "
"xrpl::SharedWeakUnion::convertToWeak : destroying freshly "
"added ref");
delete p;
unsafeSetRawPtr(nullptr);
Expand Down Expand Up @@ -719,5 +719,5 @@ SharedWeakUnion<T>::unsafeReleaseNoStore()
}
}

} // namespace ripple
} // namespace xrpl
#endif
Loading
Loading