Skip to content

Commit

Permalink
Fix the ci
Browse files Browse the repository at this point in the history
  • Loading branch information
HKalbasi committed Sep 4, 2023
1 parent 629316c commit 333d624
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 61 deletions.
13 changes: 5 additions & 8 deletions examples/cxx_demo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ fn main() {
.with_rs_file(crate_dir.join("./src/generated.rs"))
.generate();

cc::Build::new()
.cpp(true)
.file("generated.cpp")
.compile("zngur_generated");
let my_build = &mut cc::Build::new();
let my_build = my_build.cpp(true).compiler("clang++");
let my_build = || my_build.clone();

cc::Build::new()
.cpp(true)
.file("blobstore.cpp")
.compile("blobstore");
my_build().file("generated.cpp").compile("zngur_generated");
my_build().file("blobstore.cpp").compile("blobstore");
}
98 changes: 65 additions & 33 deletions examples/osmium/generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,9 @@ namespace rust {
template<typename T>
struct Ref;

template<typename T>
uint8_t* __zngur_internal_data_ptr(::rust::Ref<T>& t) {
return (uint8_t*)&t.data;
}

template<typename T>
void __zngur_internal_assume_init(::rust::Ref<T>&) {}

template<typename T>
void zngur_pretty_print(T&) {}

template<typename T>
void __zngur_internal_assume_deinit(::rust::Ref<T>&) {}

template<typename Type>
class Impl;

Expand Down Expand Up @@ -103,8 +92,7 @@ namespace rust {
}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<Ref<int8_t>>(::rust::Ref<int8_t>& t);
};


Expand Down Expand Up @@ -147,8 +135,7 @@ namespace rust {
}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<Ref<uint8_t>>(::rust::Ref<uint8_t>& t);
};


Expand Down Expand Up @@ -191,8 +178,7 @@ namespace rust {
}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<Ref<int16_t>>(::rust::Ref<int16_t>& t);
};


Expand Down Expand Up @@ -235,8 +221,7 @@ namespace rust {
}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<Ref<uint16_t>>(::rust::Ref<uint16_t>& t);
};


Expand Down Expand Up @@ -279,8 +264,7 @@ namespace rust {
}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<Ref<int32_t>>(::rust::Ref<int32_t>& t);
};


Expand Down Expand Up @@ -323,8 +307,7 @@ namespace rust {
}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<Ref<uint32_t>>(::rust::Ref<uint32_t>& t);
};


Expand Down Expand Up @@ -367,8 +350,7 @@ namespace rust {
}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<Ref<int64_t>>(::rust::Ref<int64_t>& t);
};


Expand Down Expand Up @@ -411,8 +393,7 @@ namespace rust {
}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<Ref<uint64_t>>(::rust::Ref<uint64_t>& t);
};

}
Expand Down Expand Up @@ -500,13 +481,30 @@ struct rust::Ref<::rust::Unit> {
}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<::rust::Ref<::rust::Unit>>(::rust::Ref<::rust::Unit>& t);

public:
};

namespace rust {

template<>
inline uint8_t* __zngur_internal_data_ptr<Ref<::rust::Unit>>(Ref<::rust::Unit>& t) {
return (uint8_t*)&t.data;
}

template<>
inline void __zngur_internal_assume_init<Ref<::rust::Unit>>(Ref<::rust::Unit>&) {
}

template<>
inline void __zngur_internal_check_init<Ref<::rust::Unit>>(Ref<::rust::Unit>&) {
}

template<>
inline void __zngur_internal_assume_deinit<Ref<::rust::Unit>>(Ref<::rust::Unit>&) {
}

template<>
inline size_t __zngur_internal_size_of<Ref<::rust::Unit>>() {
return 8;
Expand Down Expand Up @@ -605,13 +603,30 @@ struct rust::Ref<::rust::crate::Reader> {
}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<::rust::Ref<::rust::crate::Reader>>(::rust::Ref<::rust::crate::Reader>& t);

public:
};

namespace rust {

template<>
inline uint8_t* __zngur_internal_data_ptr<Ref<::rust::crate::Reader>>(Ref<::rust::crate::Reader>& t) {
return (uint8_t*)&t.data;
}

template<>
inline void __zngur_internal_assume_init<Ref<::rust::crate::Reader>>(Ref<::rust::crate::Reader>&) {
}

template<>
inline void __zngur_internal_check_init<Ref<::rust::crate::Reader>>(Ref<::rust::crate::Reader>&) {
}

template<>
inline void __zngur_internal_assume_deinit<Ref<::rust::crate::Reader>>(Ref<::rust::crate::Reader>&) {
}

template<>
inline size_t __zngur_internal_size_of<Ref<::rust::crate::Reader>>() {
return 8;
Expand Down Expand Up @@ -712,14 +727,31 @@ struct rust::Ref<::rust::crate::Flags> {
}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<::rust::Ref<::rust::crate::Flags>>(::rust::Ref<::rust::crate::Flags>& t);

public:
::uint8_t bits();
};

namespace rust {

template<>
inline uint8_t* __zngur_internal_data_ptr<Ref<::rust::crate::Flags>>(Ref<::rust::crate::Flags>& t) {
return (uint8_t*)&t.data;
}

template<>
inline void __zngur_internal_assume_init<Ref<::rust::crate::Flags>>(Ref<::rust::crate::Flags>&) {
}

template<>
inline void __zngur_internal_check_init<Ref<::rust::crate::Flags>>(Ref<::rust::crate::Flags>&) {
}

template<>
inline void __zngur_internal_assume_deinit<Ref<::rust::crate::Flags>>(Ref<::rust::crate::Flags>&) {
}

template<>
inline size_t __zngur_internal_size_of<Ref<::rust::crate::Flags>>() {
return 8;
Expand Down
2 changes: 1 addition & 1 deletion examples/osmium/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ bitflags! {

fn main() {
let f = Flags::way | Flags::node;
let reader = generated::new_blob_store_client(f);
let _reader = generated::new_blob_store_client(f);
println!("Hello, world! {}", f.bits());
}
42 changes: 23 additions & 19 deletions zngur-generator/src/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ struct rust::Ref<{ty}> {{
}}
private:
::std::array<size_t, 2> data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<::rust::Ref<{ty}>>(::rust::Ref<{ty}>& t);
"#,
ty = self.ty,
)?;
Expand All @@ -390,8 +389,7 @@ struct rust::Ref<{ty}> {{
}}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<::rust::Ref<{ty}>>(::rust::Ref<{ty}>& t);
"#,
ty = self.ty,
)?;
Expand Down Expand Up @@ -422,6 +420,24 @@ private:
state,
r#"
namespace rust {{
template<>
inline uint8_t* __zngur_internal_data_ptr<Ref<{ty}>>(Ref<{ty}>& t) {{
return (uint8_t*)&t.data;
}}
template<>
inline void __zngur_internal_assume_init<Ref<{ty}>>(Ref<{ty}>&) {{
}}
template<>
inline void __zngur_internal_check_init<Ref<{ty}>>(Ref<{ty}>&) {{
}}
template<>
inline void __zngur_internal_assume_deinit<Ref<{ty}>>(Ref<{ty}>&) {{
}}
template<>
inline size_t __zngur_internal_size_of<Ref<{ty}>>() {{
return {size};
Expand Down Expand Up @@ -697,7 +713,7 @@ namespace rust {{
}}
"#,
size = self.size,
);
)?;
if self.is_copy {
writeln!(
state,
Expand Down Expand Up @@ -749,7 +765,7 @@ namespace rust {{
}}
}}
"#,
);
)?;
}
self.emit_ref_specialization(state)
}
Expand Down Expand Up @@ -941,20 +957,9 @@ namespace rust {
template<typename T>
struct Ref;
template<typename T>
uint8_t* __zngur_internal_data_ptr(::rust::Ref<T>& t) {
return (uint8_t*)&t.data;
}
template<typename T>
void __zngur_internal_assume_init(::rust::Ref<T>&) {}
template<typename T>
void zngur_pretty_print(T&) {}
template<typename T>
void __zngur_internal_assume_deinit(::rust::Ref<T>&) {}
template<typename Type>
class Impl;
"#;
Expand Down Expand Up @@ -1004,8 +1009,7 @@ namespace rust {
}}
private:
size_t data;
template<typename T2>
friend uint8_t* ::rust::__zngur_internal_data_ptr(::rust::Ref<T2>& t);
friend uint8_t* ::rust::__zngur_internal_data_ptr<Ref<{ty}>>(::rust::Ref<{ty}>& t);
}};
"#
)?;
Expand Down

0 comments on commit 333d624

Please sign in to comment.