Brian Silverman | 4e662aa | 2022-05-11 23:10:19 -0700 | [diff] [blame^] | 1 | // Copyright 2020 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 4 | // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 5 | // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your |
| 6 | // option. This file may not be copied, modified, or distributed |
| 7 | // except according to those terms. |
| 8 | |
| 9 | use autocxx_parser::IncludeCppConfig; |
| 10 | |
| 11 | use super::{ |
| 12 | api::{ApiName, NullPhase, UnanalyzedApi}, |
| 13 | apivec::ApiVec, |
| 14 | }; |
| 15 | use crate::types::{make_ident, Namespace}; |
| 16 | |
| 17 | /// Adds items which we always add, cos they're useful. |
| 18 | /// Any APIs or techniques which do not involve actual C++ interop |
| 19 | /// shouldn't go here, but instead should go into the main autocxx |
| 20 | /// src/lib.rs. |
| 21 | pub(crate) fn generate_utilities(apis: &mut ApiVec<NullPhase>, config: &IncludeCppConfig) { |
| 22 | // Unless we've been specifically asked not to do so, we always |
| 23 | // generate a 'make_string' function. That pretty much *always* means |
| 24 | // we run two passes through bindgen. i.e. the next 'if' is always true, |
| 25 | // and we always generate an additional C++ file for our bindings additions, |
| 26 | // unless the include_cpp macro has specified ExcludeUtilities. |
| 27 | apis.push(UnanalyzedApi::StringConstructor { |
| 28 | name: ApiName::new(&Namespace::new(), make_ident(config.get_makestring_name())), |
| 29 | }); |
| 30 | } |