| // Part of the Crubit project, under the Apache License v2.0 with LLVM |
| // Exceptions. See /LICENSE for license information. |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| use proc_macro2::TokenStream; |
| // TODO(lukasza): Consider adding more items into `code_gen_utils` (this crate). |
| // For example, the following items from `src_code_gen.rs` will be most likely |
| // reused from `cc_bindings_from_rs`: |
| // - `NamespaceQualifier` |
| /// Formats a C++ identifier. Does not escape C++ keywords. |
| pub fn format_cc_ident(ident: &str) -> TokenStream { |
| use token_stream_matchers::assert_cc_matches; |
| fn test_format_cc_ident_basic() { |
| assert_cc_matches!(format_cc_ident("foo"), quote! { foo }); |
| fn test_format_cc_ident_reserved_rust_keyword() { |
| assert_cc_matches!(format_cc_ident("impl"), quote! { impl }); |
| fn test_format_cc_ident_reserved_cc_keyword() { |
| assert_cc_matches!(format_cc_ident("int"), quote! { int }); |