Compare commits

...
Sign in to create a new pull request.

6 commits

Author SHA1 Message Date
38a1fb328b
add build dependencies to readme
All checks were successful
/ test (push) Successful in 3m54s
2026-01-06 16:13:36 -08:00
4177a58c8d
add rust code to readme
All checks were successful
/ test (push) Successful in 3m50s
2026-01-06 16:05:02 -08:00
bc550be122
clean up dead code
All checks were successful
/ test (push) Successful in 3m47s
2026-01-06 15:29:14 -08:00
b68cb274da
change to a library 2026-01-06 15:24:16 -08:00
76438b727c
rename src/main.rs -> src/lib.rs 2026-01-06 15:21:46 -08:00
2636ab2518
Merge remote-tracking branch 'origin/wip-experimental-rust-port2'
All checks were successful
/ test (push) Successful in 5m0s
2026-01-06 14:46:38 -08:00
6 changed files with 3864 additions and 3903 deletions

32
Cargo.lock generated
View file

@ -185,7 +185,6 @@ dependencies = [
"libm",
"mupdf-sys",
"quick-xml",
"serde",
]
[[package]]
@ -210,7 +209,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b66c2058c55a409d601666cffe35f04333cf1013010882cec174a7467cd4e21c"
dependencies = [
"memchr",
"serde",
]
[[package]]
@ -257,36 +255,6 @@ version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
[[package]]
name = "serde"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
"serde_derive",
]
[[package]]
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "shlex"
version = "1.3.0"

View file

@ -14,5 +14,4 @@ rust-version = "1.89.0"
indexmap = "2.12.1"
libm = "0.2.15"
mupdf-sys = { version = "0.5.0", default-features = false }
quick-xml = { version = "0.38.4", features = ["serialize"] }
serde = { version = "1.0.228", features = ["derive"] }
quick-xml = "0.38.4"

View file

@ -4,6 +4,35 @@ See Notices.txt for copyright information
-->
parser for the OPF PowerISA 3.1C pdf to attempt to extract all instructions' pseudo-code including subscripts/superscripts and other formatting
# Using the new Rust code:
Usage:
* Download the OPF PowerISA 3.1C pdf (yes you need that exact version) from <https://openpower.foundation/specifications/isa/>
* Install Rust -- you need version 1.89.0 or later.
Getting it from https://rustup.rs/ is recommended.
* Install required build dependencies:
On Debian 12:
```bash
sudo apt update
sudo apt install build-essential clang unzip
```
* Compile and run:
```bash
cargo run -- path/to/downloaded/OPF_PowerISA_v3.1C.pdf > out.log
```
* This will spit out lots of errors and then successfully create
the output file -- `powerisa-instructions.xml` in the current directory.
# Using the old Python code:
Usage:
* Download the OPF PowerISA 3.1C pdf (yes you need that exact version) from <https://openpower.foundation/specifications/isa/>
* Obtain CPython 3.11 (the default `python3` in [Debian Bookworm](https://www.debian.org/releases/bookworm/))

3828
src/lib.rs Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -765,6 +765,7 @@ pub(crate) enum WriteMode {
}
impl<'a, 'ctx> TextSpanRef<'a, 'ctx> {
#[allow(dead_code)]
pub(crate) fn get(self) -> &'a UnsafeCell<fz_text_span> {
self.ptr
}
@ -802,6 +803,7 @@ pub(crate) struct FontRef<'a, 'ctx> {
}
impl<'a, 'ctx> FontRef<'a, 'ctx> {
#[allow(dead_code)]
pub(crate) fn get(self) -> &'a UnsafeCell<fz_font> {
self.ptr
}
@ -810,9 +812,11 @@ impl<'a, 'ctx> FontRef<'a, 'ctx> {
.to_str()
.expect("font name isn't valid UTF-8")
}
#[allow(dead_code)]
pub(crate) fn is_bold(self) -> bool {
unsafe { fz_font_is_bold(self.ctx.0.get(), self.ptr.get()) != 0 }
}
#[allow(dead_code)]
pub(crate) fn is_italic(self) -> bool {
unsafe { fz_font_is_italic(self.ctx.0.get(), self.ptr.get()) != 0 }
}
@ -824,6 +828,7 @@ impl<'a, 'ctx> FontRef<'a, 'ctx> {
}
}
#[allow(dead_code)]
pub(crate) fn transform_point(point: fz_point, m: fz_matrix) -> fz_point {
unsafe { fz_transform_point(point, m) }
}