From 2c737c926753035e538ffd9215ec70664563893f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Jul 2026 01:29:12 +0000 Subject: [PATCH 1/2] Add the canonical TapHouse pre-commit clang-format hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completes OscTap's adoption of the Tap House Rules: it already carries the canonical .clang-format and STYLE.md (layout half) and runs a format-only CI gate. This adds the local pre-commit clang-format hook so staged C/C++ is formatted before commit, matching the rest of the family. The naming half stays deliberately exempt (readability-identifier-naming is off) — OscTap is a drop-in source-compatible continuation of oscpack, and the exemption is documented in TapHouse STYLE.md. The pre-commit hook is clang-format only, so it is fully compatible with that exemption. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01MRTDgYKY38WH8Bqz17W9k1 --- .pre-commit-config.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b392057 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +# Canonical Tap House pre-commit config — the single source of truth for the +# Tap family's local formatting hook. Distributed to every Tap repo by +# scripts/sync.sh (alongside .clang-format / .clang-tidy / STYLE.md) and kept +# honest by the drift-check workflow, so every repo runs the SAME hook at the +# SAME pinned clang-format version. +# +# Why the pin matters: an ad-hoc hook using each machine's own clang-format +# would format differently than CI and be worse than none. The `rev` below is +# the Tap-wide clang-format version — bump it HERE, re-sync, and every repo +# (and its CI, which runs `pre-commit run --all-files`) moves together. +# +# Adopt in a consumer repo: +# 1. taphouse/scripts/sync.sh /path/to/your-repo # copies this file in +# 2. cd your-repo && pre-commit install # once per clone +# Thereafter `git commit` formats staged C/C++ before it can be pushed, so the +# clang-format CI gate can never fail on a local commit again. +repos: + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v18.1.3 # Tap-wide clang-format version (matches CI) + hooks: + - id: clang-format + types_or: [c, c++] + exclude: '^third_party/' # vendored sources are formatted upstream, never by us From 1c4b25fb3e7129f9e501b570f5338dae6d777c7a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Jul 2026 02:08:22 +0000 Subject: [PATCH 2/2] Adopt the tap::osc namespace, keeping osctap/oscpack as compat aliases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migrate the library's canonical C++ namespace to tap::osc, per the family convention (tap::dsp, tap::ambi, …). Non-breaking: both former names are retained as namespace aliases, so existing code on either spelling keeps compiling — namespace osctap = tap::osc; // the former modern name namespace oscpack = tap::osc; // the original oscpack name Only the library headers under osctap/ move (25 namespace blocks; 64 internal osctap:: references retargeted to tap::osc::). The tests and examples that deliberately exercise the osctap::/oscpack:: aliases are left untouched — they are the live verification that the shims still resolve, and now cover the tap::osc indirection too. Include paths and the osctap/ directory are unchanged. Verified: builds and all 9 tests pass on Linux; clang-format clean. The naming exemption is unaffected (namespace casing was never gated). Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01MRTDgYKY38WH8Bqz17W9k1 --- README.md | 6 +- osctap/ip/AbstractUdpSocket.h | 11 +-- osctap/ip/IpEndpointName.h | 13 ++-- osctap/ip/PacketListener.h | 11 +-- osctap/ip/TcpSocket.h | 10 ++- osctap/ip/TimerListener.h | 11 +-- osctap/ip/UdpSocket.h | 15 ++-- osctap/ip/posix/NetworkingUtils.h | 11 +-- osctap/ip/posix/TcpSocket.h | 4 +- osctap/ip/posix/UdpSocket.h | 15 ++-- osctap/ip/win32/NetworkingUtils.h | 11 +-- osctap/ip/win32/TcpSocket.h | 4 +- osctap/ip/win32/UdpSocket.h | 15 ++-- osctap/osc/MessageMappingOscPacketListener.h | 15 ++-- osctap/osc/OscConfig.h | 6 +- osctap/osc/OscDebug.h | 11 +-- osctap/osc/OscException.h | 11 +-- osctap/osc/OscOutboundPacketStream.h | 25 ++++--- osctap/osc/OscPacketListener.h | 17 +++-- osctap/osc/OscPrintReceivedElements.h | 11 +-- osctap/osc/OscReceivedElements.h | 35 ++++----- osctap/osc/OscStreamFraming.h | 11 +-- osctap/osc/OscTypes.h | 11 +-- osctap/osc/OscTypesTraits.h | 77 ++++++++++---------- osctap/osc/OscUtilities.h | 11 +-- 25 files changed, 200 insertions(+), 178 deletions(-) diff --git a/README.md b/README.md index c1a789f..189710e 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ packing and unpacking [Open Sound Control](https://opensoundcontrol.stanford.edu/) (OSC) packets, with UDP **and TCP** networking classes for Windows and POSIX. -It is a drop-in successor: the `oscpack` namespace and include paths are retained as a -deprecated compatibility alias, so existing code keeps building while new code uses the -`osctap` name. +It is a drop-in successor: the canonical namespace is `tap::osc`, and the former names +(`osctap`, and `oscpack` before it) plus the original include paths are retained as +compatibility aliases, so existing code keeps building while new code uses `tap::osc`. > **Status:** actively modernized. The parsing path is audited, hardened, and fuzzed; > a non-throwing validation gate, a freestanding/embedded profile, OSC-over-TCP, and an diff --git a/osctap/ip/AbstractUdpSocket.h b/osctap/ip/AbstractUdpSocket.h index a241aea..c9b1412 100644 --- a/osctap/ip/AbstractUdpSocket.h +++ b/osctap/ip/AbstractUdpSocket.h @@ -42,7 +42,7 @@ #include "IpEndpointName.h" #include "NetworkingUtils.h" -namespace osctap { +namespace tap::osc { class PacketListener; class TimerListener; @@ -192,10 +192,11 @@ namespace osctap { } // namespace detail -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_UDPSOCKET_H */ diff --git a/osctap/ip/IpEndpointName.h b/osctap/ip/IpEndpointName.h index 27097b3..9155832 100644 --- a/osctap/ip/IpEndpointName.h +++ b/osctap/ip/IpEndpointName.h @@ -41,9 +41,9 @@ #include "NetworkingUtils.h" -namespace osctap { +namespace tap::osc { class IpEndpointName { - static unsigned long GetHostByName(const char* s) { return osctap::GetHostByName(s); } + static unsigned long GetHostByName(const char* s) { return tap::osc::GetHostByName(s); } public: static const unsigned long ANY_ADDRESS = 0xFFFFFFFF; @@ -114,10 +114,11 @@ namespace osctap { inline bool operator!=(const IpEndpointName& lhs, const IpEndpointName& rhs) { return !(lhs == rhs); } -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_IPENDPOINTNAME_H */ diff --git a/osctap/ip/PacketListener.h b/osctap/ip/PacketListener.h index 2c0b988..7a07422 100644 --- a/osctap/ip/PacketListener.h +++ b/osctap/ip/PacketListener.h @@ -37,7 +37,7 @@ #ifndef INCLUDED_OSCTAP_PACKETLISTENER_H #define INCLUDED_OSCTAP_PACKETLISTENER_H -namespace osctap { +namespace tap::osc { class IpEndpointName; class PacketListener { @@ -45,10 +45,11 @@ namespace osctap { virtual ~PacketListener() {} virtual void ProcessPacket(const char* data, int size, const IpEndpointName& remoteEndpoint) = 0; }; -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_PACKETLISTENER_H */ diff --git a/osctap/ip/TcpSocket.h b/osctap/ip/TcpSocket.h index c2a931b..5e8d29c 100644 --- a/osctap/ip/TcpSocket.h +++ b/osctap/ip/TcpSocket.h @@ -19,7 +19,7 @@ #include "posix/TcpSocket.h" #endif -namespace osctap { +namespace tap::osc { #if defined(_WIN32) using TcpTransmitSocket = win32::TcpTransmitSocket; using TcpListeningReceiveSocket = win32::TcpListeningReceiveSocket; @@ -27,9 +27,11 @@ namespace osctap { using TcpTransmitSocket = posix::TcpTransmitSocket; using TcpListeningReceiveSocket = posix::TcpListeningReceiveSocket; #endif -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_TCPSOCKET_H */ diff --git a/osctap/ip/TimerListener.h b/osctap/ip/TimerListener.h index f179ff3..54a5d80 100644 --- a/osctap/ip/TimerListener.h +++ b/osctap/ip/TimerListener.h @@ -37,16 +37,17 @@ #ifndef INCLUDED_OSCTAP_TIMERLISTENER_H #define INCLUDED_OSCTAP_TIMERLISTENER_H -namespace osctap { +namespace tap::osc { class TimerListener { public: virtual ~TimerListener() {} virtual void TimerExpired() = 0; }; -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_TIMERLISTENER_H */ diff --git a/osctap/ip/UdpSocket.h b/osctap/ip/UdpSocket.h index a0eadf3..3b2a915 100644 --- a/osctap/ip/UdpSocket.h +++ b/osctap/ip/UdpSocket.h @@ -8,20 +8,21 @@ #include "posix/UdpSocket.h" #endif -namespace osctap { +namespace tap::osc { namespace detail { #if defined(_WIN32) - using Implementation = osctap::win32::Implementation; + using Implementation = tap::osc::win32::Implementation; #else - using Implementation = osctap::posix::Implementation; + using Implementation = tap::osc::posix::Implementation; #endif } // namespace detail using UdpTransmitSocket = detail::UdpTransmitSocket; using UdpReceiveSocket = detail::UdpReceiveSocket; using UdpListeningReceiveSocket = detail::UdpListeningReceiveSocket; -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; diff --git a/osctap/ip/posix/NetworkingUtils.h b/osctap/ip/posix/NetworkingUtils.h index f72b915..c12aea9 100644 --- a/osctap/ip/posix/NetworkingUtils.h +++ b/osctap/ip/posix/NetworkingUtils.h @@ -5,7 +5,7 @@ #include #include #include -namespace osctap { +namespace tap::osc { // in general NetworkInitializer is only used internally, but if you're // application creates multiple sockets from different threads at runtime you // should instantiate one of these in main just to make sure the networking @@ -42,8 +42,9 @@ namespace osctap { } return result; } -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; diff --git a/osctap/ip/posix/TcpSocket.h b/osctap/ip/posix/TcpSocket.h index b78cf40..d175585 100644 --- a/osctap/ip/posix/TcpSocket.h +++ b/osctap/ip/posix/TcpSocket.h @@ -39,7 +39,7 @@ #include "ip/posix/UdpSocket.h" #include "osc/OscStreamFraming.h" -namespace osctap { +namespace tap::osc { namespace posix { // --------------------------------------------------------------------------- @@ -296,6 +296,6 @@ namespace osctap { }; } // namespace posix -} // namespace osctap +} // namespace tap::osc #endif /* INCLUDED_OSCTAP_POSIX_TCPSOCKET_H */ diff --git a/osctap/ip/posix/UdpSocket.h b/osctap/ip/posix/UdpSocket.h index 067463d..1e25606 100644 --- a/osctap/ip/posix/UdpSocket.h +++ b/osctap/ip/posix/UdpSocket.h @@ -61,7 +61,7 @@ #include "ip/PacketListener.h" #include "ip/TimerListener.h" -namespace osctap { +namespace tap::osc { namespace posix { @@ -470,13 +470,14 @@ namespace osctap { }; struct Implementation { - using udp_socket_t = osctap::posix::UdpSocketImplementation; - using socket_multiplexer_t = osctap::posix::SocketReceiveMultiplexerImplementation; + using udp_socket_t = tap::osc::posix::UdpSocketImplementation; + using socket_multiplexer_t = tap::osc::posix::SocketReceiveMultiplexerImplementation; }; } // namespace posix -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; diff --git a/osctap/ip/win32/NetworkingUtils.h b/osctap/ip/win32/NetworkingUtils.h index 2137074..53b22c3 100644 --- a/osctap/ip/win32/NetworkingUtils.h +++ b/osctap/ip/win32/NetworkingUtils.h @@ -46,7 +46,7 @@ #include -namespace osctap { +namespace tap::osc { class NetworkInitializer { public: static const NetworkInitializer& instance() { @@ -86,8 +86,9 @@ namespace osctap { return result; } -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; diff --git a/osctap/ip/win32/TcpSocket.h b/osctap/ip/win32/TcpSocket.h index a010c7d..a46fbcb 100644 --- a/osctap/ip/win32/TcpSocket.h +++ b/osctap/ip/win32/TcpSocket.h @@ -39,7 +39,7 @@ #include "ip/win32/UdpSocket.h" #include "osc/OscStreamFraming.h" -namespace osctap { +namespace tap::osc { namespace win32 { // Mirrors ip/posix/TcpSocket.h on Winsock. The connection-aware server uses @@ -303,6 +303,6 @@ namespace osctap { }; } // namespace win32 -} // namespace osctap +} // namespace tap::osc #endif /* INCLUDED_OSCTAP_WIN32_TCPSOCKET_H */ diff --git a/osctap/ip/win32/UdpSocket.h b/osctap/ip/win32/UdpSocket.h index 4d85ca2..891cb1a 100644 --- a/osctap/ip/win32/UdpSocket.h +++ b/osctap/ip/win32/UdpSocket.h @@ -63,7 +63,7 @@ typedef int socklen_t; -namespace osctap { +namespace tap::osc { namespace win32 { static void SockaddrFromIpEndpointName(struct sockaddr_in& sockAddr, const IpEndpointName& endpoint) { std::memset((char*)&sockAddr, 0, sizeof(sockAddr)); @@ -438,12 +438,13 @@ namespace osctap { }; struct Implementation { - using udp_socket_t = osctap::win32::UdpSocketImplementation; - using socket_multiplexer_t = osctap::win32::SocketReceiveMultiplexerImplementation; + using udp_socket_t = tap::osc::win32::UdpSocketImplementation; + using socket_multiplexer_t = tap::osc::win32::SocketReceiveMultiplexerImplementation; }; } // namespace win32 -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; diff --git a/osctap/osc/MessageMappingOscPacketListener.h b/osctap/osc/MessageMappingOscPacketListener.h index 175a1cd..33ffa10 100644 --- a/osctap/osc/MessageMappingOscPacketListener.h +++ b/osctap/osc/MessageMappingOscPacketListener.h @@ -42,19 +42,19 @@ #include "OscPacketListener.h" -namespace osctap { +namespace tap::osc { template class MessageMappingOscPacketListener : public OscPacketListener { public: - typedef void (T::*function_type)(const osctap::ReceivedMessage&, const IpEndpointName&); + typedef void (T::*function_type)(const tap::osc::ReceivedMessage&, const IpEndpointName&); protected: void RegisterMessageFunction(const char* addressPattern, function_type f) { functions_.insert(std::make_pair(addressPattern, f)); } - virtual void ProcessMessage(const osctap::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) { + virtual void ProcessMessage(const tap::osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) { typename function_map_type::iterator i = functions_.find(m.AddressPattern()); if (i != functions_.end()) (dynamic_cast(this)->*(i->second))(m, remoteEndpoint); @@ -69,10 +69,11 @@ namespace osctap { function_map_type functions_; }; -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_MESSAGEMAPPINGOSCPACKETLISTENER_H */ diff --git a/osctap/osc/OscConfig.h b/osctap/osc/OscConfig.h index 0341fea..b50acce 100644 --- a/osctap/osc/OscConfig.h +++ b/osctap/osc/OscConfig.h @@ -90,7 +90,7 @@ #define OSCTAP_THROW(EXC) (OSCTAP_FATAL_HANDLER((EXC).what())) #else #include // std::abort -namespace osctap { +namespace tap::osc { namespace detail { // Default fatal handler used when exceptions are disabled and the integrator // has not supplied OSCTAP_FATAL_HANDLER. Marked [[noreturn]] so the compiler @@ -100,8 +100,8 @@ namespace osctap { std::abort(); } } // namespace detail -} // namespace osctap -#define OSCTAP_THROW(EXC) (::osctap::detail::OscFatalError((EXC).what())) +} // namespace tap::osc +#define OSCTAP_THROW(EXC) (::tap::osc::detail::OscFatalError((EXC).what())) #endif #endif diff --git a/osctap/osc/OscDebug.h b/osctap/osc/OscDebug.h index 6816860..0f18df8 100644 --- a/osctap/osc/OscDebug.h +++ b/osctap/osc/OscDebug.h @@ -3,7 +3,7 @@ #include "OscReceivedElements.h" -namespace osctap { +namespace tap::osc { template auto& debug(Stream& s, const ReceivedMessage& mess) { @@ -34,8 +34,9 @@ namespace osctap { return s; } -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; diff --git a/osctap/osc/OscException.h b/osctap/osc/OscException.h index fddd14a..9acade1 100644 --- a/osctap/osc/OscException.h +++ b/osctap/osc/OscException.h @@ -39,7 +39,7 @@ #include -namespace osctap { +namespace tap::osc { class Exception : public std::exception { const char* what_; @@ -59,10 +59,11 @@ namespace osctap { const char* what() const noexcept override { return what_; } }; -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_OSCEXCEPTION_H */ diff --git a/osctap/osc/OscOutboundPacketStream.h b/osctap/osc/OscOutboundPacketStream.h index 92955c1..2736fd0 100644 --- a/osctap/osc/OscOutboundPacketStream.h +++ b/osctap/osc/OscOutboundPacketStream.h @@ -47,7 +47,7 @@ #endif #include -namespace osctap { +namespace tap::osc { using string_view = std::string_view; } @@ -64,7 +64,7 @@ namespace osctap { #include // alloca on OSX and FreeBSD (and Linux?) #endif -namespace osctap { +namespace tap::osc { class OutOfBufferMemoryException : public Exception { public: @@ -91,10 +91,10 @@ namespace osctap { }; struct BeginMessageN { - explicit BeginMessageN(osctap::string_view str) + explicit BeginMessageN(tap::osc::string_view str) : addressPattern{str} {} - osctap::string_view addressPattern; + tap::osc::string_view addressPattern; }; class OutboundPacketStream { @@ -390,7 +390,7 @@ namespace osctap { return *this; } - OutboundPacketStream& operator<<(osctap::string_view rhs) { + OutboundPacketStream& operator<<(tap::osc::string_view rhs) { CheckForAvailableArgumentSpace(RoundUp4(static_cast(rhs.size() + 1))); *(--typeTagsCurrent_) = STRING_TYPE_TAG; @@ -417,16 +417,16 @@ namespace osctap { // overload below; this catches decayed/runtime pointers.) Freestanding-safe: // forwards to the string_view overload, no heap. OutboundPacketStream& operator<<(const char* rhs) { - operator<<(osctap::string_view(rhs)); + operator<<(tap::osc::string_view(rhs)); return *this; } #ifndef OSCTAP_FREESTANDING // Hosted convenience: std::string pulls in (and heap). The // freestanding profile omits it; pass const char*, a char array, or - // osctap::string_view instead. + // tap::osc::string_view instead. OutboundPacketStream& operator<<(const std::string& rhs) { - operator<<(osctap::string_view(rhs)); + operator<<(tap::osc::string_view(rhs)); return *this; } #endif @@ -592,10 +592,11 @@ namespace osctap { bool messageIsInProgress_; }; -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_OSCOUTBOUNDPACKETSTREAM_H */ diff --git a/osctap/osc/OscPacketListener.h b/osctap/osc/OscPacketListener.h index dd13f75..6728576 100644 --- a/osctap/osc/OscPacketListener.h +++ b/osctap/osc/OscPacketListener.h @@ -40,7 +40,7 @@ #include "../ip/PacketListener.h" #include "OscReceivedElements.h" -namespace osctap { +namespace tap::osc { class OscPacketListener : public PacketListener { public: @@ -55,7 +55,7 @@ namespace osctap { unsigned int MaxBundleNestingDepth() const { return maxBundleNestingDepth_; } protected: - virtual void ProcessBundle(const osctap::ReceivedBundle& b, const IpEndpointName& remoteEndpoint) { + virtual void ProcessBundle(const tap::osc::ReceivedBundle& b, const IpEndpointName& remoteEndpoint) { // ignore bundle time tag for now // Bound recursion depth so a deeply-nested bundle from an untrusted @@ -81,11 +81,11 @@ namespace osctap { } } - virtual void ProcessMessage(const osctap::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) = 0; + virtual void ProcessMessage(const tap::osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) = 0; public: void ProcessPacket(const char* data, int size, const IpEndpointName& remoteEndpoint) override { - osctap::ReceivedPacket p(data, size); + tap::osc::ReceivedPacket p(data, size); if (p.IsBundle()) ProcessBundle(ReceivedBundle(p), remoteEndpoint); else @@ -97,10 +97,11 @@ namespace osctap { unsigned int maxBundleNestingDepth_ = DEFAULT_MAX_BUNDLE_NESTING_DEPTH; }; -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_OSCPACKETLISTENER_H */ diff --git a/osctap/osc/OscPrintReceivedElements.h b/osctap/osc/OscPrintReceivedElements.h index bd2af3a..0255579 100644 --- a/osctap/osc/OscPrintReceivedElements.h +++ b/osctap/osc/OscPrintReceivedElements.h @@ -45,7 +45,7 @@ #include "OscReceivedElements.h" -namespace osctap { +namespace tap::osc { template Ostream_T& operator<<(Ostream_T& os, const ReceivedPacket& p); @@ -262,10 +262,11 @@ namespace osctap { return os; } -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_OSCPRINTRECEIVEDELEMENTS_H */ diff --git a/osctap/osc/OscReceivedElements.h b/osctap/osc/OscReceivedElements.h index 9199725..e556c3d 100644 --- a/osctap/osc/OscReceivedElements.h +++ b/osctap/osc/OscReceivedElements.h @@ -50,7 +50,7 @@ #include // std::vector backs OwnedMessage (hosted-only) #endif -namespace osctap { +namespace tap::osc { class MalformedPacketException : public Exception { public: @@ -155,7 +155,7 @@ namespace osctap { bool IsBundle() const { return (Size() > 0 && Contents()[0] == '#'); } osc_bundle_element_size_t Size() const { return ToInt32(sizePtr_); } - const char* Contents() const { return sizePtr_ + osctap::OSC_SIZEOF_INT32; } + const char* Contents() const { return sizePtr_ + tap::osc::OSC_SIZEOF_INT32; } private: const char* sizePtr_; @@ -363,7 +363,7 @@ namespace osctap { // re-validating is safe. That makes this throw-free and realtime-safe -- the // non-throwing blob accessor for the RT read path. size = (osc_bundle_element_size_t)ToUInt32(argumentPtr_); - data = (const void*)(argumentPtr_ + osctap::OSC_SIZEOF_INT32); + data = (const void*)(argumentPtr_ + tap::osc::OSC_SIZEOF_INT32); } bool IsArrayBegin() const { return *typeTagPtr_ == ARRAY_BEGIN_TYPE_TAG; } @@ -479,7 +479,7 @@ namespace osctap { case BLOB_TYPE_TAG: { // treat blob size as an unsigned int for the purposes of this calculation uint32_t blobSize = ToUInt32(value_.argumentPtr_); - value_.argumentPtr_ = value_.argumentPtr_ + osctap::OSC_SIZEOF_INT32 + RoundUp4(blobSize); + value_.argumentPtr_ = value_.argumentPtr_ + tap::osc::OSC_SIZEOF_INT32 + RoundUp4(blobSize); } break; case ARRAY_BEGIN_TYPE_TAG: @@ -755,7 +755,7 @@ namespace osctap { break; case BLOB_TYPE_TAG: { - if (argument + osctap::OSC_SIZEOF_INT32 > end) + if (argument + tap::osc::OSC_SIZEOF_INT32 > end) return "arguments exceed message size"; // treat blob size as an unsigned int for the purposes of this calculation @@ -767,7 +767,7 @@ namespace osctap { // blobSize must not be allowed to overflow the pointer (or RoundUp4) // and thereby slip past the bounds check. blobData <= end is // guaranteed by the check above. - const char* blobData = argument + osctap::OSC_SIZEOF_INT32; + const char* blobData = argument + tap::osc::OSC_SIZEOF_INT32; if (RoundUp4(blobSize) > (uint32_t)(end - blobData)) return "arguments exceed message size"; @@ -929,7 +929,7 @@ namespace osctap { const char* p = timeTag_ + 8; while (p < end_) { - if (p + osctap::OSC_SIZEOF_INT32 > end_) + if (p + tap::osc::OSC_SIZEOF_INT32 > end_) return "packet too short for elementSize"; // treat element size as an unsigned int for the purposes of this calculation @@ -939,7 +939,7 @@ namespace osctap { // Compare sizes rather than advancing the pointer first, so that a huge // elementSize can't overflow the pointer and slip past the bounds check. - const char* elementData = p + osctap::OSC_SIZEOF_INT32; + const char* elementData = p + tap::osc::OSC_SIZEOF_INT32; if (elementSize > (uint32_t)(end_ - elementData)) return "packet too short for bundle element"; @@ -998,11 +998,11 @@ namespace osctap { uint32_t elementCount_; }; - inline auto begin(const osctap::ReceivedMessage& mes) { + inline auto begin(const tap::osc::ReceivedMessage& mes) { return mes.ArgumentsBegin(); } - inline auto end(const osctap::ReceivedMessage& mes) { + inline auto end(const tap::osc::ReceivedMessage& mes) { return mes.ArgumentsEnd(); } @@ -1015,8 +1015,8 @@ namespace osctap { // freestanding build, where a malformed packet would otherwise hit the fatal // handler (abort) during construction or iteration: // - // if( osctap::TryValidatePacket(buf, n) == nullptr ) { - // osctap::ReceivedPacket p(buf, n); // won't abort + // if( tap::osc::TryValidatePacket(buf, n) == nullptr ) { + // tap::osc::ReceivedPacket p(buf, n); // won't abort // ... read the message / iterate the bundle ... // } else { // ... drop the datagram ... @@ -1041,7 +1041,7 @@ namespace osctap { while (p < end) { // Framing was validated above: elementSize is multiple-of-4 and in bounds. uint32_t elementSize = ToUInt32(p); - const char* elementData = p + osctap::OSC_SIZEOF_INT32; + const char* elementData = p + tap::osc::OSC_SIZEOF_INT32; if (const char* err = TryValidatePacket(elementData, (osc_bundle_element_size_t)elementSize, maxBundleNestingDepth - 1)) return err; @@ -1054,10 +1054,11 @@ namespace osctap { return ReceivedMessage::Validate(data, size); } -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_OSCRECEIVEDELEMENTS_H */ diff --git a/osctap/osc/OscStreamFraming.h b/osctap/osc/OscStreamFraming.h index 7783bf2..0b7d5f7 100644 --- a/osctap/osc/OscStreamFraming.h +++ b/osctap/osc/OscStreamFraming.h @@ -51,7 +51,7 @@ SLIP framing (the OSC 1.1 nominated alternative) is intentionally deferred. */ -namespace osctap { +namespace tap::osc { enum { OSC_STREAM_FRAME_HEADER_SIZE = 4 }; @@ -175,10 +175,11 @@ namespace osctap { bool haveHeader_; // false: reading header; true: reading payload }; -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_OSCSTREAMFRAMING_H */ diff --git a/osctap/osc/OscTypes.h b/osctap/osc/OscTypes.h index 700f74e..c19982c 100644 --- a/osctap/osc/OscTypes.h +++ b/osctap/osc/OscTypes.h @@ -57,7 +57,7 @@ #define OSCTAP_REALTIME #endif -namespace osctap { +namespace tap::osc { enum ValueTypeSizes { OSC_SIZEOF_INT32 = 4, OSC_SIZEOF_UINT32 = 4, OSC_SIZEOF_INT64 = 8, OSC_SIZEOF_UINT64 = 8 }; @@ -204,10 +204,11 @@ namespace osctap { return {}; } -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; #endif /* INCLUDED_OSCTAP_OSCTYPES_H */ diff --git a/osctap/osc/OscTypesTraits.h b/osctap/osc/OscTypesTraits.h index ddb30ac..177d9f2 100644 --- a/osctap/osc/OscTypesTraits.h +++ b/osctap/osc/OscTypesTraits.h @@ -2,9 +2,9 @@ #include #include "OscReceivedElements.h" -namespace osctap { +namespace tap::osc { // Helpers to get the values. - template + template struct OscpackFunction; // For the ones that requires access to more than the type. @@ -14,63 +14,63 @@ namespace osctap { struct object_useless_trait {}; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_required_trait; - static const constexpr auto convert = &osctap::ReceivedMessageArgument::AsInt32; - static const constexpr auto convert_unchecked = &osctap::ReceivedMessageArgument::AsInt32Unchecked; + static const constexpr auto convert = &tap::osc::ReceivedMessageArgument::AsInt32; + static const constexpr auto convert_unchecked = &tap::osc::ReceivedMessageArgument::AsInt32Unchecked; }; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_required_trait; - static const constexpr auto convert = &osctap::ReceivedMessageArgument::AsInt64; - static const constexpr auto convert_unchecked = &osctap::ReceivedMessageArgument::AsInt64Unchecked; + static const constexpr auto convert = &tap::osc::ReceivedMessageArgument::AsInt64; + static const constexpr auto convert_unchecked = &tap::osc::ReceivedMessageArgument::AsInt64Unchecked; }; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_required_trait; - static const constexpr auto convert = &osctap::ReceivedMessageArgument::AsFloat; - static const constexpr auto convert_unchecked = &osctap::ReceivedMessageArgument::AsFloatUnchecked; + static const constexpr auto convert = &tap::osc::ReceivedMessageArgument::AsFloat; + static const constexpr auto convert_unchecked = &tap::osc::ReceivedMessageArgument::AsFloatUnchecked; }; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_required_trait; - static const constexpr auto convert = &osctap::ReceivedMessageArgument::AsDouble; - static const constexpr auto convert_unchecked = &osctap::ReceivedMessageArgument::AsDoubleUnchecked; + static const constexpr auto convert = &tap::osc::ReceivedMessageArgument::AsDouble; + static const constexpr auto convert_unchecked = &tap::osc::ReceivedMessageArgument::AsDoubleUnchecked; }; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_required_trait; - static const constexpr auto convert = &osctap::ReceivedMessageArgument::AsChar; - static const constexpr auto convert_unchecked = &osctap::ReceivedMessageArgument::AsCharUnchecked; + static const constexpr auto convert = &tap::osc::ReceivedMessageArgument::AsChar; + static const constexpr auto convert_unchecked = &tap::osc::ReceivedMessageArgument::AsCharUnchecked; }; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_required_trait; - static const constexpr auto convert = &osctap::ReceivedMessageArgument::AsString; - static const constexpr auto convert_unchecked = &osctap::ReceivedMessageArgument::AsStringUnchecked; + static const constexpr auto convert = &tap::osc::ReceivedMessageArgument::AsString; + static const constexpr auto convert_unchecked = &tap::osc::ReceivedMessageArgument::AsStringUnchecked; }; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_required_trait; - static const constexpr auto convert = &osctap::ReceivedMessageArgument::AsSymbol; - static const constexpr auto convert_unchecked = &osctap::ReceivedMessageArgument::AsSymbolUnchecked; + static const constexpr auto convert = &tap::osc::ReceivedMessageArgument::AsSymbol; + static const constexpr auto convert_unchecked = &tap::osc::ReceivedMessageArgument::AsSymbolUnchecked; }; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_required_trait; - static const constexpr auto convert = &osctap::ReceivedMessageArgument::AsBlob; - static const constexpr auto convert_unchecked = &osctap::ReceivedMessageArgument::AsBlobUnchecked; + static const constexpr auto convert = &tap::osc::ReceivedMessageArgument::AsBlob; + static const constexpr auto convert_unchecked = &tap::osc::ReceivedMessageArgument::AsBlobUnchecked; }; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_useless_trait; static bool true_fun() { return true; } static const constexpr auto convert = &true_fun; @@ -78,7 +78,7 @@ namespace osctap { }; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_useless_trait; static bool false_fun() { return false; } static const constexpr auto convert = &false_fun; @@ -86,7 +86,7 @@ namespace osctap { }; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_useless_trait; static InfinitumType impulse_fun() { return {}; } static const constexpr auto convert = &impulse_fun; @@ -94,31 +94,32 @@ namespace osctap { }; template <> - struct OscpackFunction { + struct OscpackFunction { using conversion_mode = object_useless_trait; static NilType nil_fun() { return {}; } static const constexpr auto convert = &nil_fun; static const constexpr auto convert_unchecked = &nil_fun; }; - template + template auto convert( - osctap::ReceivedMessageArgument arg, + tap::osc::ReceivedMessageArgument arg, std::enable_if_t::conversion_mode, object_required_trait>::value>* = nullptr) { return (arg.*OscpackFunction::convert)(); } - template + template auto convert( - osctap::ReceivedMessageArgument, + tap::osc::ReceivedMessageArgument, std::enable_if_t::conversion_mode, object_useless_trait>::value>* = nullptr) { return (*OscpackFunction::convert)(); } -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc; diff --git a/osctap/osc/OscUtilities.h b/osctap/osc/OscUtilities.h index 4a902b2..81e7300 100644 --- a/osctap/osc/OscUtilities.h +++ b/osctap/osc/OscUtilities.h @@ -17,7 +17,7 @@ #define OSCTAP_BITCAST_CONSTEXPR inline #endif -namespace osctap { +namespace tap::osc { // Reinterpret the bits of one trivially-copyable type as another of the same // size, without the undefined behaviour of union type-punning or pointer casts. @@ -135,8 +135,9 @@ namespace osctap { constexpr uint64_t ToUInt64(const char* p) noexcept { return LoadBigEndian64(p); } -} // namespace osctap +} // namespace tap::osc -// Backwards-compatibility alias: this library was formerly named oscpack. -// Existing code that uses the oscpack:: namespace continues to compile. -namespace oscpack = osctap; +// Backwards-compatibility aliases: the canonical namespace is tap::osc. +// The former names (osctap, and oscpack before it) keep compiling. +namespace osctap = tap::osc; +namespace oscpack = tap::osc;