Skip to content

Commit 8739c7e

Browse files
committed
Add a dummy padding argument to work around a Rust bug.
rust-lang/rust#25594
1 parent 87fc444 commit 8739c7e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

html5ever/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def create_comment(parser, data):
139139
return parser._keep_alive(Comment(str_from_slice(data)))
140140

141141

142-
@ffi.callback('int(ParserUserData*, Utf8Slice, Utf8Slice, Utf8Slice)', error=-1)
143-
def append_doctype_to_document(parser, name, public_id, system_id):
142+
@ffi.callback('int(ParserUserData*, uintptr_t, Utf8Slice, Utf8Slice, Utf8Slice)', error=-1)
143+
def append_doctype_to_document(parser, _dummy, name, public_id, system_id):
144144
parser = ffi.from_handle(ffi.cast('void*', parser))
145145
parser.document.children.append(Doctype(
146146
str_from_slice(name),

html5ever/_build_ffi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Node* (*get_template_contents)(ParserUserData*, Node*),
2929
int (*add_attribute_if_missing)(ParserUserData*, Node*, Utf8Slice, Utf8Slice, Utf8Slice),
3030
Node* (*create_comment)(ParserUserData*, Utf8Slice),
31-
int (*append_doctype_to_document)(ParserUserData*, Utf8Slice, Utf8Slice, Utf8Slice),
31+
int (*append_doctype_to_document)(ParserUserData*, uintptr_t, Utf8Slice, Utf8Slice, Utf8Slice),
3232
3333
int (*append_node)(ParserUserData*, Node*, Node*),
3434
int (*append_text)(ParserUserData*, Node*, Utf8Slice),

rust-glue/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use tendril::StrTendril;
1616

1717
/// When given as a function parameter, only valid for the duration of the call.
1818
#[repr(C)]
19-
#[derive(Copy, Clone)]
19+
#[derive(Copy, Clone, Debug)]
2020
#[allow(raw_pointer_derive)]
2121
pub struct BytesSlice {
2222
ptr: *const u8,
@@ -38,7 +38,7 @@ impl BytesSlice {
3838

3939
/// When given as a function parameter, only valid for the duration of the call.
4040
#[repr(C)]
41-
#[derive(Copy, Clone)]
41+
#[derive(Copy, Clone, Debug)]
4242
pub struct Utf8Slice(BytesSlice);
4343

4444
impl Utf8Slice {
@@ -207,6 +207,7 @@ impl TreeSink for CallbackTreeSink {
207207
public_id: StrTendril,
208208
system_id: StrTendril) {
209209
check_int(call!(self, append_doctype_to_document(
210+
0,
210211
Utf8Slice::from_str(&name),
211212
Utf8Slice::from_str(&public_id),
212213
Utf8Slice::from_str(&system_id))));
@@ -319,6 +320,9 @@ declare_with_callbacks! {
319320

320321
/// Create a doctype node and append it to the document.
321322
callback append_doctype_to_document: extern "C" fn(*const OpaqueParserUserData,
323+
// Work around https://github.com/rust-lang/rust/pull/27017
324+
// Add some padding so that the last Utf8Slice is not split between registers and the stack.
325+
usize,
322326
Utf8Slice, Utf8Slice, Utf8Slice) -> c_int
323327

324328
callback append_node: extern "C" fn(*const OpaqueParserUserData,

0 commit comments

Comments
 (0)