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 3205c1a commit ce58d8b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
13 changes: 8 additions & 5 deletions build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def banner(msg: str) -> None:
# tool["cs_build"]={"antlr4_version": "4.13.0"}


def build_extension(debug: bool = False) -> None:
def build_extension(debug: bool = False, use_temp_dir=True) -> None:
print("CMakeBuild::build_extension()")

debug = int(os.environ.get("DEBUG", 0)) or debug
Expand All @@ -77,10 +77,13 @@ def build_extension(debug: bool = False) -> None:
if archs:
cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))]

build_temp = Path(TemporaryDirectory(suffix=".build-temp").name) / "extension_it_in"
# build_temp = Path(".") / "build"
if use_temp_dir:
build_temp = Path(TemporaryDirectory(suffix=".build-temp").name) / "extension_it_in"
else:
build_temp = Path(os.getcwd()) / "build"

print("cwd:", os.getcwd(), "build-dir:", build_temp, "top:", str(TOP_DIR))
# print("PHILEZ:", os.listdir(TOP_DIR))

if not build_temp.exists():
build_temp.mkdir(parents=True)

Expand All @@ -104,4 +107,4 @@ def build_extension(debug: bool = False) -> None:
if __name__ == "__main__":
includes = subprocess.getoutput("pybind11-config --cmakedir") # nosec
os.environ["pybind11_DIR"] = includes
build_extension()
build_extension(use_temp_dir=True)
5 changes: 0 additions & 5 deletions pya2l/aml/aml_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ std::any AmlVisitor::visitTaggedstruct_member(amlParser::Taggedstruct_memberCont
const auto ctx_ts1 = ctx->ts1;
const auto ctx_bl0 = ctx->bl0;
const auto ctx_bl1 = ctx->bl1;
const auto length = std::size(ctx->children); // !!CHECK!!

TaggedStructDefinition tsd;
BlockDefinition block;
Expand Down Expand Up @@ -432,10 +431,6 @@ std::any AmlVisitor::visitTaggedstruct_definition(amlParser::Taggedstruct_defini
std::string tag{};
Member member;

if (multiple) {
auto x = 9;
}

if (ctx_tag) {
const auto str_opt = std::any_cast<string_opt_t>(visit(ctx_tag));
if (str_opt) {
Expand Down
2 changes: 1 addition & 1 deletion pya2l/aml/klasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class TaggedStructDefinition {
return m_member;
}

const bool get_multiple() const noexcept {
bool get_multiple() const noexcept {
return m_multiple;
}

Expand Down
26 changes: 11 additions & 15 deletions pya2l/aml/marshal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ void dumps(std::stringstream& ss, const TaggedStructMember& tsm) {
dumps(ss, block);
} else {
ss << to_binary<std::string>("T");
const auto& tp = tsm.get_tagged_struct_def().get_member().get_type();
const auto& tsd = tsm.get_tagged_struct_def();
dumps(ss, tsd);
}
Expand All @@ -85,12 +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 member_count = std::size(members);
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::uint32_t tags_count = std::size(tags);
ss << to_binary(name);
ss << to_binary(tags_count);
for (const auto& [tag, value] : tags) {
Expand All @@ -105,11 +103,10 @@ void dumps(std::stringstream& ss, const TaggedStructOrReferrer& sr) {

// TaggedUnionMember.
void dumps(std::stringstream& ss, const TaggedUnionMember& tum) {
const auto& tag = tum.get_tag();
// const auto& tag = tum.get_tag();
const auto& block = tum.get_block();
const auto& member = tum.get_member();
if (block.get_type()) {
// ss << to_binary<std::string>("B");
dumps(ss, block);
} else {
ss << to_binary<std::string>("M");
Expand All @@ -122,12 +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 member_count = std::size(members);
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::uint32_t tags_count = std::size(tags);
ss << to_binary(name);
ss << to_binary(tags_count);
for (const auto& [tag, value] : tags) {
Expand Down
1 change: 1 addition & 0 deletions pya2l/aml/unmarshal.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <cassert>
#include <iostream>
#include <memory>
#include <optional>
#include <sstream>
#include <vector>
Expand Down
4 changes: 4 additions & 0 deletions pya2l/aml_parser.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <time.h>

#include <iostream>

#include "amlLexer.h"
Expand All @@ -14,6 +16,8 @@ void unmarshal(const std::stringstream& inbuf);
int main(int argc, const char* argv[]) {
std::ifstream stream;

// tt_tester();

if (argc == 2) {
stream.open(argv[1]);
} else {
Expand Down

0 comments on commit ce58d8b

Please sign in to comment.