Skip to content

Commit

Permalink
today()
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Jul 2, 2024
1 parent 6134ca2 commit f57bcd2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
15 changes: 2 additions & 13 deletions pya2l/aml/marshal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void dumps(std::stringstream& ss, const BlockDefinition& block) {
const auto type = block.get_type();
const auto& member = block.get_member();
const auto& multiple = block.get_multiple();

ss << to_binary(tag);
if (type) {
ss << to_binary<std::string>("T");
Expand All @@ -56,7 +55,7 @@ void dumps(std::stringstream& ss, const TaggedStructDefinition& tsd) {
const auto multiple = tsd.get_multiple();
const auto& member = tsd.get_member();
const auto tp = member.get_type();
ss << to_binary<bool>(multiple);
ss << to_binary<bool>(multiple);
if (tp) {
ss << to_binary<bool>(true); // available.
dumps(ss, tp);
Expand All @@ -71,7 +70,6 @@ void dumps(std::stringstream& ss, const TaggedStructMember& tsm) {
const auto multiple = tsm.get_multiple();
ss << to_binary<bool>(multiple);
if (tsm.get_block().get_type()) {
// ss << to_binary<std::string>("B");
const auto& block = tsm.get_block();
dumps(ss, block);
} else {
Expand All @@ -93,7 +91,6 @@ void dumps(std::stringstream& ss, const TaggedStructOrReferrer& sr) {
const auto& tags = ts.get_tags();
const std::uint32_t member_count = std::size(members);
const std::uint32_t tags_count = std::size(tags);

ss << to_binary(name);
ss << to_binary(tags_count);
for (const auto& [tag, value] : tags) {
Expand All @@ -111,10 +108,8 @@ void dumps(std::stringstream& ss, const TaggedUnionMember& tum) {
const auto& tag = tum.get_tag();
const auto& block = tum.get_block();
const auto& member = tum.get_member();

// ss << to_binary(tag);
if (block.get_type()) {
//ss << to_binary<std::string>("B");
// ss << to_binary<std::string>("B");
dumps(ss, block);
} else {
ss << to_binary<std::string>("M");
Expand All @@ -133,7 +128,6 @@ void dumps(std::stringstream& ss, const TaggedUnionOrReferrer& tr) {
const auto& tags = tu.get_tags();
const std::uint32_t member_count = std::size(members);
const std::uint32_t tags_count = std::size(tags);

ss << to_binary(name);
ss << to_binary(tags_count);
for (const auto& [tag, value] : tags) {
Expand Down Expand Up @@ -194,9 +188,7 @@ void dumps(std::stringstream& ss, const EnumerationOrReferrer& er) {
void dumps(std::stringstream& ss, const Type* tp_) {
auto tp = tp_->get_type();
auto tag = tp_->get_tag();

ss << to_binary(tag);

std::visit(
[&ss, &tp](auto&& arg) {
using T = std::decay_t<decltype(arg)>;
Expand All @@ -222,7 +214,6 @@ void dumps(std::stringstream& ss, const Type* tp_) {
void dumps(std::stringstream& ss, const Declaration& decl) {
const auto tp = decl.get_type();
const auto& block = decl.get_block();

if (block.get_type() != nullptr) {
ss << to_binary<std::string>("BL");
dumps(ss, block);
Expand All @@ -236,9 +227,7 @@ void dumps(std::stringstream& ss, const Declaration& decl) {
void dumps(std::stringstream& ss, const AmlFile& amlf) {
const auto& decls = amlf.get_decls();
const auto decl_count = std::size(decls);

ss << to_binary<std::uint32_t>(decl_count);

for (const auto& decl : decls) {
dumps(ss, decl);
}
Expand Down
20 changes: 6 additions & 14 deletions pya2l/aml/unmarshal.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

#include <cassert>

#include <iostream>
#include <sstream>
#include <vector>
Expand Down Expand Up @@ -55,7 +54,6 @@ class Unmarshaller {

void load_enum() {
const auto& disc = m_reader.from_binary_str();

if (disc == "E") {
auto name = m_reader.from_binary_str();
auto enumerator_count = m_reader.from_binary<std::uint32_t>();
Expand All @@ -70,8 +68,8 @@ class Unmarshaller {
}

void load_tagged_struct_definition() {
const auto multiple = m_reader.from_binary<bool>();
auto available = m_reader.from_binary< bool >();
const auto multiple = m_reader.from_binary<bool>();
auto available = m_reader.from_binary< bool >();
if (available) {
load_type();
}
Expand All @@ -80,11 +78,10 @@ class Unmarshaller {

void load_tagged_struct_member() {
const auto multiple = m_reader.from_binary<bool>();
const auto& dt = m_reader.from_binary_str();
const auto& dt = m_reader.from_binary_str();
if (dt == "T") {
load_tagged_struct_definition();
}
else if (dt == "B") {
} else if (dt == "B") {
load_block();
}
}
Expand All @@ -95,7 +92,7 @@ class Unmarshaller {
auto name = m_reader.from_binary_str();
auto tags_count = m_reader.from_binary<std::uint32_t>();
for (auto idx = 0; idx < tags_count; ++idx) {
const auto& tag = m_reader.from_binary_str();
const auto& tag = m_reader.from_binary_str();
load_tagged_struct_member();
}
} else if (disc == "R") {
Expand All @@ -105,7 +102,6 @@ class Unmarshaller {

void load_tagged_union() {
const auto& disc = m_reader.from_binary_str();

if (disc == "U") {
auto name = m_reader.from_binary_str();
auto tags_count = m_reader.from_binary<std::uint32_t>();
Expand Down Expand Up @@ -150,7 +146,6 @@ class Unmarshaller {
void 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) {
array_spec.push_back(m_reader.from_binary<std::uint32_t>());
}
Expand All @@ -159,7 +154,6 @@ class Unmarshaller {

void load_struct() {
const auto& disc = m_reader.from_binary_str();

if (disc == "S") {
auto name = m_reader.from_binary_str();
auto member_count = m_reader.from_binary<std::uint32_t>();
Expand All @@ -173,8 +167,7 @@ class Unmarshaller {
}

void load_block() {
const auto& tag = m_reader.from_binary_str();

const auto& tag = m_reader.from_binary_str();
const auto& disc = m_reader.from_binary_str();
if (disc == "T") {
load_type();
Expand All @@ -186,7 +179,6 @@ class Unmarshaller {

void run() {
auto decl_count = m_reader.from_binary<std::uint32_t>();
std::cout << decl_count;
for (auto idx = 0; idx < decl_count; ++idx) {
const auto& disc1 = m_reader.from_binary_str();

Expand Down

0 comments on commit f57bcd2

Please sign in to comment.