Skip to content

Commit

Permalink
Demonstrate support for non-UTF8 macro contents
Browse files Browse the repository at this point in the history
  • Loading branch information
kulp committed Jun 20, 2020
1 parent ba3aeb0 commit 40346bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bindgen-integration/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ impl ParseCallbacks for MacroCallback {
assert_eq!(value, &[b"b", b",", b"a"]);
*self.seen_funcs.lock().unwrap() += 1;
}
"TESTMACRO_STRING_FUNC_NON_UTF8(x)" => {
assert_eq!(
value,
&[b"(" as &[u8], b"x", b"\"\xff\xff\"", b")"]
);
*self.seen_funcs.lock().unwrap() += 1;
}
_ => {
// The system might provide lots of functional macros.
// Ensure we did not miss handling one that we meant to handle.
Expand All @@ -123,7 +130,7 @@ impl Drop for MacroCallback {
);
assert_eq!(
*self.seen_funcs.lock().unwrap(),
4,
5,
"func_macro handle was not called once for all relevant macros"
);
}
Expand Down
1 change: 1 addition & 0 deletions bindgen-integration/cpp/Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
a
//#define TESTMACRO_INVALID("string") // A conforming preprocessor rejects this
#define TESTMACRO_STRING_EXPR ("string")
#define TESTMACRO_STRING_FUNC_NON_UTF8(x) (x "ÿÿ") /* invalid UTF-8 on purpose */

#include <cwchar>

Expand Down

0 comments on commit 40346bc

Please sign in to comment.