Skip to content

Commit 9066abf

Browse files
authored
Merge pull request #29 from tectonic-typesetting/api-struct
Switch to a callback-API approach
2 parents c7b8c93 + 8b89da3 commit 9066abf

31 files changed

+801
-571
lines changed

build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ fn main() {
154154
let mut cppcfg = gcc::Config::new();
155155

156156
ccfg.file("tectonic/bibtex.c")
157+
.file("tectonic/core-bridge.c")
157158
.file("tectonic/dpx-agl.c")
158159
.file("tectonic/dpx-bmpimage.c")
159160
.file("tectonic/dpx-cff.c")

src/engines/bibtex.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::ffi::{CStr, CString};
77
use errors::{ErrorKind, Result};
88
use io::IoStack;
99
use status::StatusBackend;
10-
use super::{assign_global_state, c_api, IoEventBackend, ExecutionState};
10+
use super::{IoEventBackend, ExecutionState, TectonicBridgeApi};
1111
use super::tex::TexResult;
1212

1313

@@ -25,25 +25,24 @@ impl BibtexEngine {
2525
status: &mut StatusBackend, aux: &str) -> Result<TexResult> {
2626
let caux = CString::new(aux)?;
2727

28-
let mut state = ExecutionState::new(io, events, status);
28+
let /*mut*/ state = ExecutionState::new(io, events, status);
29+
let bridge = TectonicBridgeApi::new(&state);
2930

3031
unsafe {
31-
assign_global_state (&mut state, || {
32-
match c_api::bibtex_simple_main(caux.as_ptr()) {
33-
0 => Ok(TexResult::Spotless),
34-
1 => Ok(TexResult::Warnings),
35-
2 => Ok(TexResult::Errors),
36-
3 => {
37-
Err(ErrorKind::Msg("unspecified fatal bibtex error".into()).into())
38-
},
39-
99 => {
40-
let ptr = c_api::tt_get_error_message();
41-
let msg = CStr::from_ptr(ptr).to_string_lossy().into_owned();
42-
Err(ErrorKind::Msg(msg).into())
43-
},
44-
x => Err(ErrorKind::Msg(format!("internal error: unexpected 'history' value {}", x)).into())
45-
}
46-
})
32+
match super::bibtex_simple_main(&bridge, caux.as_ptr()) {
33+
0 => Ok(TexResult::Spotless),
34+
1 => Ok(TexResult::Warnings),
35+
2 => Ok(TexResult::Errors),
36+
3 => {
37+
Err(ErrorKind::Msg("unspecified fatal bibtex error".into()).into())
38+
},
39+
99 => {
40+
let ptr = super::tt_get_error_message();
41+
let msg = CStr::from_ptr(ptr).to_string_lossy().into_owned();
42+
Err(ErrorKind::Msg(msg).into())
43+
},
44+
x => Err(ErrorKind::Msg(format!("internal error: unexpected 'history' value {}", x)).into())
45+
}
4746
}
4847
}
4948
}

src/engines/c_api.rs

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/engines/file_format.rs

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/engines/io_api.rs

Lines changed: 0 additions & 212 deletions
This file was deleted.

0 commit comments

Comments
 (0)