Skip to content

Commit b672f23

Browse files
committed
Port xeq_level_array variable
1 parent 4e7931a commit b672f23

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

crates/engine_xetex/src/c_api/engine.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ pub struct EngineCtx {
248248
/// An arena of TeX nodes
249249
pub(crate) mem: Vec<MemoryWord>,
250250
pub(crate) buffer: Vec<char>,
251+
pub(crate) xeq_level_array: Vec<u16>,
251252
}
252253

253254
#[derive(Copy, Clone, PartialEq, Eq)]
@@ -364,6 +365,7 @@ impl EngineCtx {
364365
prim: Box::new([B32x2 { s0: 0, s1: 0 }; PRIM_SIZE + 1]),
365366
mem: Vec::new(),
366367
buffer: Vec::new(),
368+
xeq_level_array: vec![0; EQTB_SIZE - INT_BASE + 1],
367369
}
368370
}
369371

@@ -427,6 +429,10 @@ impl EngineCtx {
427429
let val = unsafe { self.eqtb[CAT_CODE_BASE + p].b32.s1 };
428430
CatCode::try_from(val)
429431
}
432+
433+
pub fn set_xeq_level(&mut self, idx: usize, val: u16) {
434+
self.xeq_level_array[idx - INT_BASE] = val;
435+
}
430436
}
431437

432438
#[derive(Copy, Clone, PartialEq)]
@@ -1017,6 +1023,11 @@ pub extern "C" fn clear_buffer() {
10171023
ENGINE_CTX.with_borrow_mut(|engine| engine.buffer.clear())
10181024
}
10191025

1026+
#[no_mangle]
1027+
pub extern "C" fn xeq_level_array_ptr(idx: usize) -> *mut u16 {
1028+
ENGINE_CTX.with_borrow_mut(|engine| ptr::from_mut(&mut engine.xeq_level_array[idx]))
1029+
}
1030+
10201031
fn checkpool_pointer(pool: &mut StringPool, pool_ptr: usize, len: usize) {
10211032
if pool_ptr + len >= pool.pool_size {
10221033
panic!("string pool overflow [{} bytes]", pool.pool_size);

crates/engine_xetex/xetex/xetex-ini.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,6 @@ int32_t last_node_type;
291291
int32_t insert_penalties;
292292
bool output_active;
293293

294-
uint16_t _xeq_level_array[EQTB_SIZE - INT_BASE + 1];
295-
296294
#define NEG_TRIE_OP_SIZE -35111L
297295
#define MAX_TRIE_OP 65535L
298296

crates/engine_xetex/xetex/xetex-xetexd.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,7 @@ extern bool gave_char_warning_help;
655655
* with negative indices. The underlying arrays used to be named "zzzaa" and
656656
* "zzzbb". */
657657

658-
extern uint16_t _xeq_level_array[EQTB_SIZE - INT_BASE + 1];
659-
#define XEQ_LEVEL(i) _xeq_level_array[(i) - INT_BASE]
658+
#define XEQ_LEVEL(i) (*xeq_level_array_ptr((i) - INT_BASE))
660659

661660
/* the former xetexcoerce.h: */
662661

crates/engine_xetex/xetex/xetex_bindings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ void set_buffer(uintptr_t idx, uint32_t val);
740740

741741
void clear_buffer(void);
742742

743+
uint16_t *xeq_level_array_ptr(uintptr_t idx);
744+
743745
StrNumber maketexstring(const char *str);
744746

745747
char *gettexstring(StrNumber s);
@@ -766,6 +768,8 @@ void show_context(void);
766768

767769
void token_show(int32_t p);
768770

771+
void geq_word_define(int32_t p, int32_t w);
772+
769773
void pre_error_message(void);
770774

771775
void error(void);

0 commit comments

Comments
 (0)