Skip to content

Commit

Permalink
today()
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Jul 19, 2024
1 parent 5e26d24 commit 016778b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
cmake_minimum_required(VERSION 3.7...3.29)
project(pya2l_extensions LANGUAGES C CXX)

cmake_policy(SET CMP0135 NEW)

find_package(Python COMPONENTS Interpreter Development)
find_package(pybind11 REQUIRED)

Expand Down
3 changes: 2 additions & 1 deletion build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import re
import subprocess # nosec
import sys
from typing import Optional
from pathlib import Path

# from pprint import pprint
Expand Down Expand Up @@ -36,7 +37,7 @@ def fetch_tags(repo: str) -> list[str]:
return sorted(tag_set, key=sort_by_version)


def most_recent_tag(repo: str) -> str | None:
def most_recent_tag(repo: str) -> Optional[str]:
tags = fetch_tags(repo)
return tags[-1] if tags else None

Expand Down
4 changes: 2 additions & 2 deletions pya2l/aml/klasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ template<>
inline std::string to_binary<std::string>(const std::string& value) {
std::string result;

auto ptr = reinterpret_cast<const std::string::value_type*>(value.c_str());
const std::uint32_t length = std::size(value);
auto ptr = reinterpret_cast<const std::string::value_type*>(value.c_str());
const std::size length = std::size(value);

// We are using Pascal strings as serialization format.
auto len_bin = to_binary(length);
Expand Down
40 changes: 20 additions & 20 deletions pya2l/aml/marshal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ void dumps(std::stringstream& ss, const AMLPredefinedType& pdt) {

// Member.
void dumps(std::stringstream& ss, const Member& mem) {
const auto& arr_spec = mem.get_array_spec();
const std::uint32_t array_size = std::size(arr_spec);
const auto& arr_spec = mem.get_array_spec();
const std::size array_size = std::size(arr_spec);
ss << to_binary(array_size);
for (const auto arr : arr_spec) {
ss << to_binary<std::uint32_t>(arr);
Expand Down Expand Up @@ -84,11 +84,11 @@ void dumps(std::stringstream& ss, const TaggedStructOrReferrer& sr) {
ss << to_binary<std::string>("TS");
if (std::holds_alternative<TaggedStruct>(sr)) {
ss << to_binary<std::string>("S");
const auto& ts = std::get<TaggedStruct>(sr);
const auto& members = ts.get_members();
const auto& name = ts.get_name();
const auto& tags = ts.get_tags();
const std::uint32_t tags_count = std::size(tags);
const auto& ts = std::get<TaggedStruct>(sr);
const auto& members = ts.get_members();
const auto& name = ts.get_name();
const auto& tags = ts.get_tags();
const std::size tags_count = std::size(tags);
ss << to_binary(name);
ss << to_binary(tags_count);
for (const auto& [tag, value] : tags) {
Expand Down Expand Up @@ -119,11 +119,11 @@ void dumps(std::stringstream& ss, const TaggedUnionOrReferrer& tr) {
ss << to_binary<std::string>("TU");
if (std::holds_alternative<TaggedUnion>(tr)) {
ss << to_binary<std::string>("U");
const auto& tu = std::get<TaggedUnion>(tr);
const auto& members = tu.get_members();
const auto& name = tu.get_name();
const auto& tags = tu.get_tags();
const std::uint32_t tags_count = std::size(tags);
const auto& tu = std::get<TaggedUnion>(tr);
const auto& members = tu.get_members();
const auto& name = tu.get_name();
const auto& tags = tu.get_tags();
const std::size tags_count = std::size(tags);
ss << to_binary(name);
ss << to_binary(tags_count);
for (const auto& [tag, value] : tags) {
Expand All @@ -141,10 +141,10 @@ void dumps(std::stringstream& ss, const StructOrReferrer& sr) {
ss << to_binary<std::string>("ST");
if (std::holds_alternative<Struct>(sr)) {
ss << to_binary<std::string>("S");
const auto& st = std::get<Struct>(sr);
const auto& name = st.get_name();
const auto& members = st.get_members();
const std::uint32_t member_count = std::size(members);
const auto& st = std::get<Struct>(sr);
const auto& name = st.get_name();
const auto& members = st.get_members();
const std::size member_count = std::size(members);
ss << to_binary(name);
ss << to_binary(member_count);
for (const auto& sm : members) {
Expand All @@ -164,10 +164,10 @@ void dumps(std::stringstream& ss, const EnumerationOrReferrer& er) {
ss << to_binary<std::string>("EN");
if (std::holds_alternative<Enumeration>(er)) {
ss << to_binary<std::string>("E");
const auto& enumeration = std::get<Enumeration>(er);
const auto& name = enumeration.get_name();
const auto& enumerators = enumeration.get_enumerators();
const std::uint32_t enumerator_count = std::size(enumerators);
const auto& enumeration = std::get<Enumeration>(er);
const auto& name = enumeration.get_name();
const auto& enumerators = enumeration.get_enumerators();
const std::size enumerator_count = std::size(enumerators);
ss << to_binary(name);
ss << to_binary(enumerator_count);
for (const auto& [tag, value] : enumerators) {
Expand Down
12 changes: 6 additions & 6 deletions pya2l/aml/unmarshal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Unmarshaller {

enumerators_t enumerators;

for (auto idx = 0; idx < enumerator_count; ++idx) {
for (std::uint32_t idx = 0UL; idx < enumerator_count; ++idx) {
auto tag = m_reader.from_binary_str();
auto value = m_reader.from_binary< std::uint32_t>();

Expand Down Expand Up @@ -144,7 +144,7 @@ class Unmarshaller {
auto name = m_reader.from_binary_str();
auto tags_count = m_reader.from_binary<std::uint32_t>();
std::vector<std::tuple<std::string, tagged_struct_member_t>> members;
for (auto idx = 0; idx < tags_count; ++idx) {
for (std::uint32_t idx = 0UL; idx < tags_count; ++idx) {
const auto& tag = m_reader.from_binary_str();
members.emplace_back(tag, load_tagged_struct_member());
}
Expand All @@ -161,7 +161,7 @@ class Unmarshaller {
auto tags_count = m_reader.from_binary<std::uint32_t>();
std::vector<tagged_union_member_t> members;

for (auto idx = 0; idx < tags_count; ++idx) {
for (std::uint32_t idx = 0UL; idx < tags_count; ++idx) {
auto tag = m_reader.from_binary_str();
const auto& dt = m_reader.from_binary_str();

Expand Down Expand Up @@ -207,7 +207,7 @@ class Unmarshaller {
member_t load_member() {
auto arr_count = m_reader.from_binary<std::uint32_t>();
std::vector<std::uint32_t> array_spec;
for (auto idx = 0; idx < arr_count; ++idx) {
for (std::uint32_t idx = 0UL; idx < arr_count; ++idx) {
array_spec.push_back(m_reader.from_binary<std::uint32_t>());
}
return member_t{ array_spec, std::make_unique<type_t>(load_type()) };
Expand All @@ -220,7 +220,7 @@ class Unmarshaller {
auto member_count = m_reader.from_binary<std::uint32_t>();
std::vector<struct_member_t> members;

for (auto idx = 0; idx < member_count; ++idx) {
for (std::uint32_t idx = 0UL; idx < member_count; ++idx) {
auto member = load_member();
auto mult = m_reader.from_binary<bool>();
members.emplace_back(mult, std::move(member));
Expand Down Expand Up @@ -249,7 +249,7 @@ class Unmarshaller {
std::vector<std::variant<type_t, block_t>> run() {
auto decl_count = m_reader.from_binary<std::uint32_t>();
std::vector<std::variant<type_t, block_t>> result;
for (auto idx = 0; idx < decl_count; ++idx) {
for (std::uint32_t idx = 0UL; idx < decl_count; ++idx) {
const auto& disc1 = m_reader.from_binary_str();

if (disc1 == "TY") {
Expand Down

0 comments on commit 016778b

Please sign in to comment.