blob: b90b36597ac860d8b8abd867c20bcfcff49f0d53 [file] [log] [blame]
Brian Silverman4e662aa2022-05-11 23:10:19 -07001// 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
9use autocxx_parser::IncludeCppConfig;
10
11use super::{
12 api::{ApiName, NullPhase, UnanalyzedApi},
13 apivec::ApiVec,
14};
15use 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.
21pub(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}