@@ -52,6 +52,7 @@ pub struct EngineCtx {
5252 pub ( crate ) input_ptr : usize ,
5353 pub ( crate ) cur_input : InputState ,
5454 pub ( crate ) interaction : InteractionMode ,
55+ pub ( crate ) history : History ,
5556
5657 pub ( crate ) eqtb : Vec < MemoryWord > ,
5758 pub ( crate ) prim : Box < [ B32x2 ; PRIM_SIZE + 1 ] > ,
@@ -105,6 +106,29 @@ struct NodeError {
105106 subty : u16 ,
106107}
107108
109+ #[ derive( Copy , Clone , PartialEq , Eq ) ]
110+ #[ repr( C ) ]
111+ pub enum History {
112+ Spotless = 0 ,
113+ WarningIssued = 1 ,
114+ ErrorIssued = 2 ,
115+ FatalError = 3 ,
116+ }
117+
118+ impl TryFrom < u8 > for History {
119+ type Error = u8 ;
120+
121+ fn try_from ( value : u8 ) -> Result < Self , Self :: Error > {
122+ Ok ( match value {
123+ 0 => History :: Spotless ,
124+ 1 => History :: WarningIssued ,
125+ 2 => History :: ErrorIssued ,
126+ 3 => History :: FatalError ,
127+ _ => return Err ( value) ,
128+ } )
129+ }
130+ }
131+
108132impl EngineCtx {
109133 fn new ( ) -> EngineCtx {
110134 EngineCtx {
@@ -132,6 +156,7 @@ impl EngineCtx {
132156 input_ptr : 0 ,
133157 cur_input : InputState :: default ( ) ,
134158 interaction : InteractionMode :: Batch ,
159+ history : History :: Spotless ,
135160
136161 eqtb : Vec :: new ( ) ,
137162 prim : Box :: new ( [ B32x2 { s0 : 0 , s1 : 0 } ; PRIM_SIZE + 1 ] ) ,
@@ -536,6 +561,16 @@ pub extern "C" fn set_interaction(val: u8) {
536561 . with_borrow_mut ( |engine| engine. interaction = InteractionMode :: try_from ( val) . unwrap ( ) )
537562}
538563
564+ #[ no_mangle]
565+ pub extern "C" fn history ( ) -> History {
566+ ENGINE_CTX . with_borrow ( |engine| engine. history )
567+ }
568+
569+ #[ no_mangle]
570+ pub extern "C" fn set_history ( val : u8 ) {
571+ ENGINE_CTX . with_borrow_mut ( |engine| engine. history = History :: try_from ( val) . unwrap ( ) )
572+ }
573+
539574#[ no_mangle]
540575pub extern "C" fn eqtb ( idx : usize ) -> MemoryWord {
541576 ENGINE_CTX . with_borrow ( |engine| engine. eqtb [ idx] )
0 commit comments