Skip to content

Commit eb3606f

Browse files
committed
Change enum types from u32 to c_int
1 parent c5362ab commit eb3606f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

templates/rust/src/ast/nodes.rs.erb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::ffi::{CToken, HbArray};
44
use crate::nodes::*;
55
use crate::{Location, Position};
66
use std::ffi::CStr;
7-
use std::os::raw::{c_char, c_void};
7+
use std::os::raw::{c_char, c_int, c_void};
88

99
#[repr(C)]
1010
#[derive(Copy, Clone)]
@@ -67,13 +67,13 @@ unsafe fn convert_location(c_loc: CLocation) -> Location {
6767

6868
#[repr(C)]
6969
struct CErrorBase {
70-
error_type: u32,
70+
error_type: c_int,
7171
location: CLocation,
7272
message: *const c_char,
7373
}
7474

7575
<%- errors.each_with_index do |error, index| -%>
76-
const <%= error.type %>: u32 = <%= index %>;
76+
const <%= error.type %>: c_int = <%= index %>;
7777
<%- end -%>
7878

7979
<%- errors.each do |error| -%>
@@ -88,7 +88,7 @@ struct C<%= error.name %> {
8888
<%- when Herb::Template::TokenField -%>
8989
<%= field.name %>: *mut CToken,
9090
<%- when Herb::Template::TokenTypeField -%>
91-
<%= field.name %>: u32,
91+
<%= field.name %>: c_int,
9292
<%- end -%>
9393
<%- end -%>
9494
}
@@ -112,10 +112,10 @@ unsafe fn convert_<%= snake_name %>(error_ptr: *const C<%= error.name %>) -> <%=
112112
<%- when Herb::Template::TokenField -%>
113113
convert_token_field(error_ref.<%= field.name %>),
114114
<%- when Herb::Template::TokenTypeField -%>
115-
if error_ref.<%= field.name %> == u32::MAX {
115+
if error_ref.<%= field.name %> == -1 {
116116
None
117117
} else {
118-
Some(CStr::from_ptr(crate::ffi::token_type_to_string(error_ref.<%= field.name %>)).to_string_lossy().into_owned())
118+
Some(CStr::from_ptr(crate::ffi::token_type_to_string(error_ref.<%= field.name %> as u32)).to_string_lossy().into_owned())
119119
},
120120
<%- end -%>
121121
<%- end -%>

0 commit comments

Comments
 (0)