Skip to content

Commit 40346bc

Browse files
committed
Demonstrate support for non-UTF8 macro contents
1 parent ba3aeb0 commit 40346bc

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

bindgen-integration/build.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ impl ParseCallbacks for MacroCallback {
105105
assert_eq!(value, &[b"b", b",", b"a"]);
106106
*self.seen_funcs.lock().unwrap() += 1;
107107
}
108+
"TESTMACRO_STRING_FUNC_NON_UTF8(x)" => {
109+
assert_eq!(
110+
value,
111+
&[b"(" as &[u8], b"x", b"\"\xff\xff\"", b")"]
112+
);
113+
*self.seen_funcs.lock().unwrap() += 1;
114+
}
108115
_ => {
109116
// The system might provide lots of functional macros.
110117
// Ensure we did not miss handling one that we meant to handle.
@@ -123,7 +130,7 @@ impl Drop for MacroCallback {
123130
);
124131
assert_eq!(
125132
*self.seen_funcs.lock().unwrap(),
126-
4,
133+
5,
127134
"func_macro handle was not called once for all relevant macros"
128135
);
129136
}

bindgen-integration/cpp/Test.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
a
1919
//#define TESTMACRO_INVALID("string") // A conforming preprocessor rejects this
2020
#define TESTMACRO_STRING_EXPR ("string")
21+
#define TESTMACRO_STRING_FUNC_NON_UTF8(x) (x "ÿÿ") /* invalid UTF-8 on purpose */
2122

2223
#include <cwchar>
2324

0 commit comments

Comments
 (0)