Open kraktus opened 3 months ago
I added a very low effort implementation of a main.zng
generator, you can use it by generating your project's json docs by cargo +nightly rustdoc -Zunstable-options --output-format=json
and copy the result into zngur/zngur-autozng/doc.json
and then run autozng using cargo run
. I did it for your project, and here is the result:
type crate::MoveKind {
#heap_allocated;
fn new(Option, Option) -> Result;
fn is_uncapture(self) -> bool;
fn is_en_passant(self) -> bool;
fn is_unpromotion(self) -> bool;
fn to_retro_uci(self) -> String;
}
type crate::UnMove {
#heap_allocated;
fn from_retro_uci(&str) -> Result;
fn new(Square, Square, MoveKind) -> Self;
fn to_retro_uci(self) -> String;
fn is_uncapture(self) -> bool;
fn uncapture(self) -> Option;
fn is_unpromotion(self) -> bool;
fn is_en_passant(self) -> bool;
fn uncapture_square(self) -> Option;
fn mirror(self) -> Self;
}
type crate::RetroPockets {
#heap_allocated;
fn color(self, Color) -> &RetroPocket;
fn color_mut(self, Color) -> &mut RetroPocket;
fn from_str(&str, &str) -> Result;
}
type crate::RetroBoard {
#heap_allocated;
fn new_no_pockets(&str) -> Result;
fn new(&str, &str, &str) -> Result;
fn push(self, &UnMove);
fn pseudo_legal_unmoves(self, &mut UnMoveList);
fn legal_unmoves(self) -> UnMoveList;
fn board(self) -> &Board;
fn retro_turn(self) -> Color;
fn us(self) -> Bitboard;
fn our(self, Role) -> Bitboard;
fn them(self) -> Bitboard;
fn their(self, Role) -> Bitboard;
fn king_of(self, Color) -> Square;
fn flip_vertical(self);
fn flip_horizontal(self);
fn flip_diagonal(self);
fn flip_anti_diagonal(self);
fn rotate_90(self);
fn rotate_180(self);
fn rotate_270(self);
}
type crate::ParseRetroPocketError {
#heap_allocated;
}
type crate::RetroPocket {
#heap_allocated;
fn decr(self, Role);
}
type crate::ParseRetroUciError {
#heap_allocated;
}
It is broken in multiple ways, and you can use it just as a template. You need to fix these things for it to become usable:
crate::UnMove
, ::shakmaty::Role
or ::std::string::String
.unwrap
.self
types are wrong (I can fix this easily if it is annoying).shakmaty
crate as well.The autozng
is a simple 200 line script which you can easily read and improve, and ideally we want to have a full featured autozng
and it is in the scope of this project, however I currently don't have time to make it complete and polished, but I can add some more features if you desire.
Please tell me if you hit any problems in using zngur, or have some ideas. My own project that triggered me to create zngur became fully Rust, so now there is no real project using it. But I still believe in zngur idea and would really like to see a real project use zngur, so I will help you if you hit any zngur related problem.
Thanks! I actually did something similar 2 years ago: https://github.com/kraktus/cargo-extern-fn and got quite far using proc macros, but it was based on cxx which turned out to be too limited in terms of fondamental type support (not even Option
Will definitely check it out once I've more time.
Hello, thanks for this promising project.
I’ve a rust crate https://github.com/kraktus/rs-retroboard-chess that has sparked the interest of cpp users. I’d like to make it available.
The good thing is that it mostly returns simple types or wrapper around it, however the api surface is still quite high to make a main.zng file manually. Is there a way to generate it from the rust code? Even imperfectly, as a way to save time.