From 819b1248d289b116a9b2ac6a9d1f19cd3ae1ff50 Mon Sep 17 00:00:00 2001 From: LinZhihao-723 Date: Tue, 7 Jan 2025 16:26:53 -0500 Subject: [PATCH] Refactoring done --- lint-tasks.yml | 2 ++ src/clp_ffi_py/ir/native/PyDeserializer.cpp | 14 +++++++++----- src/clp_ffi_py/ir/native/PyDeserializer.hpp | 1 - 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lint-tasks.yml b/lint-tasks.yml index c1d25fac..147c0e8b 100644 --- a/lint-tasks.yml +++ b/lint-tasks.yml @@ -115,6 +115,8 @@ tasks: - "{{.CLP_FFI_PY_CPP_SRC_DIR}}/api_decoration.hpp" - "{{.CLP_FFI_PY_CPP_SRC_DIR}}/error_messages.hpp" - "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ExceptionFFI.hpp" + - "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ir/native/PyDeserializer.cpp" + - "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ir/native/PyDeserializer.hpp" - "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ir/native/PyKeyValuePairLogEvent.cpp" - "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ir/native/PyKeyValuePairLogEvent.hpp" - "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ir/native/PySerializer.cpp" diff --git a/src/clp_ffi_py/ir/native/PyDeserializer.cpp b/src/clp_ffi_py/ir/native/PyDeserializer.cpp index c042dd7b..30a74e7c 100644 --- a/src/clp_ffi_py/ir/native/PyDeserializer.cpp +++ b/src/clp_ffi_py/ir/native/PyDeserializer.cpp @@ -72,7 +72,7 @@ CLP_FFI_PY_METHOD auto PyDeserializer_deserialize_log_event(PyDeserializer* self */ CLP_FFI_PY_METHOD auto PyDeserializer_dealloc(PyDeserializer* self) -> void; -// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays) +// NOLINTNEXTLINE(*-avoid-c-arrays, cppcoreguidelines-avoid-non-const-global-variables) PyMethodDef PyDeserializer_method_table[]{ {"deserialize_log_event", py_c_function_cast(PyDeserializer_deserialize_log_event), @@ -82,7 +82,8 @@ PyMethodDef PyDeserializer_method_table[]{ {nullptr} }; -// NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays, cppcoreguidelines-pro-type-*-cast) +// NOLINTBEGIN(cppcoreguidelines-pro-type-*-cast) +// NOLINTNEXTLINE(*-avoid-c-arrays, cppcoreguidelines-avoid-non-const-global-variables) PyType_Slot PyDeserializer_slots[]{ {Py_tp_alloc, reinterpret_cast(PyType_GenericAlloc)}, {Py_tp_dealloc, reinterpret_cast(PyDeserializer_dealloc)}, @@ -92,11 +93,12 @@ PyType_Slot PyDeserializer_slots[]{ {Py_tp_doc, const_cast(static_cast(cPyDeserializerDoc))}, {0, nullptr} }; -// NOLINTEND(cppcoreguidelines-avoid-c-arrays, cppcoreguidelines-pro-type-*-cast) +// NOLINTEND(cppcoreguidelines-pro-type-*-cast) /** * `PyDeserializer`'s Python type specifications. */ +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) PyType_Spec PyDeserializer_type_spec{ "clp_ffi_py.ir.native.Deserializer", sizeof(PyDeserializer), @@ -197,7 +199,7 @@ auto PyDeserializer::init( if (deserializer_result.has_error()) { PyErr_Format( PyExc_RuntimeError, - cDeserializerCreateErrorFormatStr.data(), + get_c_str_from_constexpr_string_view(cDeserializerCreateErrorFormatStr), deserializer_result.error().message().c_str() ); return false; @@ -232,7 +234,9 @@ auto PyDeserializer::deserialize_log_event() -> PyObject* { if (std::errc::result_out_of_range != err) { PyErr_Format( PyExc_RuntimeError, - cDeserializerDeserializeNextIrUnitErrorFormatStr.data(), + get_c_str_from_constexpr_string_view( + cDeserializerDeserializeNextIrUnitErrorFormatStr + ), err.message().c_str() ); return nullptr; diff --git a/src/clp_ffi_py/ir/native/PyDeserializer.hpp b/src/clp_ffi_py/ir/native/PyDeserializer.hpp index c986e0d6..a6d5982b 100644 --- a/src/clp_ffi_py/ir/native/PyDeserializer.hpp +++ b/src/clp_ffi_py/ir/native/PyDeserializer.hpp @@ -4,7 +4,6 @@ #include // Must be included before any other header files #include -#include #include #include