mirror of
https://github.com/topjohnwu/cxx.git
synced 2024-10-07 00:53:28 +00:00
Reduce visibility of all pub items which are not publicly exported
This commit is contained in:
parent
c06cb140e6
commit
927d8ead12
@ -4,19 +4,19 @@ use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Crate {
|
||||
pub(crate) struct Crate {
|
||||
pub include_prefix: Option<PathBuf>,
|
||||
pub links: Option<OsString>,
|
||||
pub header_dirs: Vec<HeaderDir>,
|
||||
}
|
||||
|
||||
pub struct HeaderDir {
|
||||
pub(crate) struct HeaderDir {
|
||||
pub exported: bool,
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
impl Crate {
|
||||
pub fn print_to_cargo(&self) {
|
||||
pub(crate) fn print_to_cargo(&self) {
|
||||
if let Some(include_prefix) = &self.include_prefix {
|
||||
println!(
|
||||
"cargo:CXXBRIDGE_PREFIX={}",
|
||||
@ -38,7 +38,7 @@ impl Crate {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn direct_dependencies() -> Vec<Crate> {
|
||||
pub(crate) fn direct_dependencies() -> Vec<Crate> {
|
||||
let mut crates: BTreeMap<String, Crate> = BTreeMap::new();
|
||||
let mut exported_header_dirs: BTreeMap<String, Vec<(usize, PathBuf)>> = BTreeMap::new();
|
||||
|
||||
|
@ -3,15 +3,15 @@ use once_cell::sync::OnceCell;
|
||||
use std::sync::{Mutex, PoisonError};
|
||||
|
||||
#[derive(Copy, Clone, Default)]
|
||||
pub struct InternedString(&'static str);
|
||||
pub(crate) struct InternedString(&'static str);
|
||||
|
||||
impl InternedString {
|
||||
pub fn str(self) -> &'static str {
|
||||
pub(crate) fn str(self) -> &'static str {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
pub fn intern(s: &str) -> InternedString {
|
||||
pub(crate) fn intern(s: &str) -> InternedString {
|
||||
static INTERN: OnceCell<Mutex<Set<&'static str>>> = OnceCell::new();
|
||||
|
||||
let mut set = INTERN
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::intern::{self, InternedString};
|
||||
use std::path::Path;
|
||||
|
||||
pub trait InternedVec<T>
|
||||
pub(crate) trait InternedVec<T>
|
||||
where
|
||||
T: ?Sized,
|
||||
{
|
||||
@ -17,14 +17,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn intern<T>(elements: &[&T]) -> Vec<InternedString>
|
||||
pub(crate) fn intern<T>(elements: &[&T]) -> Vec<InternedString>
|
||||
where
|
||||
T: ?Sized + Element,
|
||||
{
|
||||
elements.iter().copied().map(Element::intern).collect()
|
||||
}
|
||||
|
||||
pub trait Element {
|
||||
pub(crate) trait Element {
|
||||
fn intern(&self) -> InternedString;
|
||||
fn unintern(_: InternedString) -> &'static Self;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use syn::parse::ParseStream;
|
||||
use syn::{Ident, LitBool, LitStr, Token};
|
||||
|
||||
#[derive(Ord, PartialOrd, Eq, PartialEq)]
|
||||
pub enum CfgValue {
|
||||
pub(crate) enum CfgValue {
|
||||
Bool(bool),
|
||||
Str(String),
|
||||
}
|
||||
@ -15,12 +15,12 @@ impl CfgValue {
|
||||
const TRUE: Self = CfgValue::Bool(true);
|
||||
}
|
||||
|
||||
pub struct FlagsCfgEvaluator {
|
||||
pub(crate) struct FlagsCfgEvaluator {
|
||||
map: Map<String, Set<CfgValue>>,
|
||||
}
|
||||
|
||||
impl FlagsCfgEvaluator {
|
||||
pub fn new(map: Map<String, Set<CfgValue>>) -> Self {
|
||||
pub(crate) fn new(map: Map<String, Set<CfgValue>>) -> Self {
|
||||
FlagsCfgEvaluator { map }
|
||||
}
|
||||
}
|
||||
@ -73,7 +73,7 @@ impl Debug for CfgValue {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(input: ParseStream) -> syn::Result<(String, CfgValue)> {
|
||||
pub(crate) fn parse(input: ParseStream) -> syn::Result<(String, CfgValue)> {
|
||||
let ident: Ident = input.parse()?;
|
||||
let name = ident.to_string();
|
||||
if input.is_empty() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use proc_macro2::Ident;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub enum Block<'a> {
|
||||
pub(crate) enum Block<'a> {
|
||||
AnonymousNamespace,
|
||||
Namespace(&'static str),
|
||||
UserDefinedNamespace(&'a Ident),
|
||||
@ -10,7 +10,7 @@ pub enum Block<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Block<'a> {
|
||||
pub fn write_begin(self, out: &mut String) {
|
||||
pub(crate) fn write_begin(self, out: &mut String) {
|
||||
if let Block::InlineNamespace(_) = self {
|
||||
out.push_str("inline ");
|
||||
}
|
||||
@ -18,7 +18,7 @@ impl<'a> Block<'a> {
|
||||
out.push_str(" {\n");
|
||||
}
|
||||
|
||||
pub fn write_end(self, out: &mut String) {
|
||||
pub(crate) fn write_end(self, out: &mut String) {
|
||||
out.push_str("} // ");
|
||||
self.write_common(out);
|
||||
out.push('\n');
|
||||
|
@ -3,7 +3,7 @@ use crate::gen::ifndef;
|
||||
use crate::gen::out::{Content, OutFile};
|
||||
|
||||
#[derive(Default, PartialEq)]
|
||||
pub struct Builtins<'a> {
|
||||
pub(crate) struct Builtins<'a> {
|
||||
pub panic: bool,
|
||||
pub rust_string: bool,
|
||||
pub rust_str: bool,
|
||||
@ -36,7 +36,7 @@ pub struct Builtins<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Builtins<'a> {
|
||||
pub fn new() -> Self {
|
||||
pub(crate) fn new() -> Self {
|
||||
Builtins::default()
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use syn::parse::discouraged::Speculative;
|
||||
use syn::parse::{Error, Parse, ParseStream, Result};
|
||||
use syn::{braced, Attribute, Ident, Item, Meta, Token, Visibility};
|
||||
|
||||
pub struct File {
|
||||
pub(crate) struct File {
|
||||
pub modules: Vec<Module>,
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ pub(crate) struct Error {
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn kind(&self) -> io::ErrorKind {
|
||||
pub(crate) fn kind(&self) -> io::ErrorKind {
|
||||
match &self.source {
|
||||
Some(io_error) => io_error.kind(),
|
||||
None => io::ErrorKind::Other,
|
||||
|
@ -19,7 +19,7 @@ pub struct Include {
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq)]
|
||||
pub struct Includes<'a> {
|
||||
pub(crate) struct Includes<'a> {
|
||||
pub custom: Vec<Include>,
|
||||
pub algorithm: bool,
|
||||
pub array: bool,
|
||||
@ -44,15 +44,15 @@ pub struct Includes<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Includes<'a> {
|
||||
pub fn new() -> Self {
|
||||
pub(crate) fn new() -> Self {
|
||||
Includes::default()
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, include: impl Into<Include>) {
|
||||
pub(crate) fn insert(&mut self, include: impl Into<Include>) {
|
||||
self.custom.push(include.into());
|
||||
}
|
||||
|
||||
pub fn has_cxx_header(&self) -> bool {
|
||||
pub(crate) fn has_cxx_header(&self) -> bool {
|
||||
self.custom
|
||||
.iter()
|
||||
.any(|header| header.path == "rust/cxx.h" || header.path == "rust\\cxx.h")
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::syntax::Pair;
|
||||
|
||||
impl Pair {
|
||||
pub fn to_fully_qualified(&self) -> String {
|
||||
pub(crate) fn to_fully_qualified(&self) -> String {
|
||||
let mut fully_qualified = String::new();
|
||||
for segment in &self.namespace {
|
||||
fully_qualified += "::";
|
||||
|
@ -2,7 +2,7 @@ use crate::syntax::namespace::Namespace;
|
||||
use crate::syntax::Api;
|
||||
|
||||
impl Api {
|
||||
pub fn namespace(&self) -> &Namespace {
|
||||
pub(crate) fn namespace(&self) -> &Namespace {
|
||||
match self {
|
||||
Api::CxxFunction(efn) | Api::RustFunction(efn) => &efn.name.namespace,
|
||||
Api::CxxType(ety) | Api::RustType(ety) => &ety.name.namespace,
|
||||
|
@ -2,21 +2,23 @@ use crate::syntax::map::UnorderedMap as Map;
|
||||
use crate::syntax::Api;
|
||||
use proc_macro2::Ident;
|
||||
|
||||
pub struct NamespaceEntries<'a> {
|
||||
pub(crate) struct NamespaceEntries<'a> {
|
||||
direct: Vec<&'a Api>,
|
||||
nested: Vec<(&'a Ident, NamespaceEntries<'a>)>,
|
||||
}
|
||||
|
||||
impl<'a> NamespaceEntries<'a> {
|
||||
pub fn new(apis: Vec<&'a Api>) -> Self {
|
||||
pub(crate) fn new(apis: Vec<&'a Api>) -> Self {
|
||||
sort_by_inner_namespace(apis, 0)
|
||||
}
|
||||
|
||||
pub fn direct_content(&self) -> &[&'a Api] {
|
||||
pub(crate) fn direct_content(&self) -> &[&'a Api] {
|
||||
&self.direct
|
||||
}
|
||||
|
||||
pub fn nested_content(&self) -> impl Iterator<Item = (&'a Ident, &NamespaceEntries<'a>)> {
|
||||
pub(crate) fn nested_content(
|
||||
&self,
|
||||
) -> impl Iterator<Item = (&'a Ident, &NamespaceEntries<'a>)> {
|
||||
self.nested.iter().map(|(k, entries)| (*k, entries))
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ pub(crate) struct OutFile<'a> {
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Content<'a> {
|
||||
pub(crate) struct Content<'a> {
|
||||
bytes: String,
|
||||
namespace: &'a Namespace,
|
||||
blocks: Vec<BlockBoundary<'a>>,
|
||||
@ -32,7 +32,7 @@ enum BlockBoundary<'a> {
|
||||
}
|
||||
|
||||
impl<'a> OutFile<'a> {
|
||||
pub fn new(header: bool, opt: &'a Opt, types: &'a Types) -> Self {
|
||||
pub(crate) fn new(header: bool, opt: &'a Opt, types: &'a Types) -> Self {
|
||||
OutFile {
|
||||
header,
|
||||
opt,
|
||||
@ -44,28 +44,28 @@ impl<'a> OutFile<'a> {
|
||||
}
|
||||
|
||||
// Write a blank line if the preceding section had any contents.
|
||||
pub fn next_section(&mut self) {
|
||||
pub(crate) fn next_section(&mut self) {
|
||||
self.content.get_mut().next_section();
|
||||
}
|
||||
|
||||
pub fn begin_block(&mut self, block: Block<'a>) {
|
||||
pub(crate) fn begin_block(&mut self, block: Block<'a>) {
|
||||
self.content.get_mut().begin_block(block);
|
||||
}
|
||||
|
||||
pub fn end_block(&mut self, block: Block<'a>) {
|
||||
pub(crate) fn end_block(&mut self, block: Block<'a>) {
|
||||
self.content.get_mut().end_block(block);
|
||||
}
|
||||
|
||||
pub fn set_namespace(&mut self, namespace: &'a Namespace) {
|
||||
pub(crate) fn set_namespace(&mut self, namespace: &'a Namespace) {
|
||||
self.content.get_mut().set_namespace(namespace);
|
||||
}
|
||||
|
||||
pub fn write_fmt(&self, args: Arguments) {
|
||||
pub(crate) fn write_fmt(&self, args: Arguments) {
|
||||
let content = &mut *self.content.borrow_mut();
|
||||
Write::write_fmt(content, args).unwrap();
|
||||
}
|
||||
|
||||
pub fn content(&mut self) -> Vec<u8> {
|
||||
pub(crate) fn content(&mut self) -> Vec<u8> {
|
||||
self.flush();
|
||||
let include = &self.include.content.bytes;
|
||||
let builtin = &self.builtin.content.bytes;
|
||||
@ -112,19 +112,19 @@ impl<'a> Content<'a> {
|
||||
Content::default()
|
||||
}
|
||||
|
||||
pub fn next_section(&mut self) {
|
||||
pub(crate) fn next_section(&mut self) {
|
||||
self.section_pending = true;
|
||||
}
|
||||
|
||||
pub fn begin_block(&mut self, block: Block<'a>) {
|
||||
pub(crate) fn begin_block(&mut self, block: Block<'a>) {
|
||||
self.push_block_boundary(BlockBoundary::Begin(block));
|
||||
}
|
||||
|
||||
pub fn end_block(&mut self, block: Block<'a>) {
|
||||
pub(crate) fn end_block(&mut self, block: Block<'a>) {
|
||||
self.push_block_boundary(BlockBoundary::End(block));
|
||||
}
|
||||
|
||||
pub fn set_namespace(&mut self, namespace: &'a Namespace) {
|
||||
pub(crate) fn set_namespace(&mut self, namespace: &'a Namespace) {
|
||||
for name in self.namespace.iter().rev() {
|
||||
self.end_block(Block::UserDefinedNamespace(name));
|
||||
}
|
||||
@ -134,7 +134,7 @@ impl<'a> Content<'a> {
|
||||
self.namespace = namespace;
|
||||
}
|
||||
|
||||
pub fn write_fmt(&mut self, args: Arguments) {
|
||||
pub(crate) fn write_fmt(&mut self, args: Arguments) {
|
||||
Write::write_fmt(self, args).unwrap();
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
pub type Node = clang_ast::Node<Clang>;
|
||||
pub(crate) type Node = clang_ast::Node<Clang>;
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum Clang {
|
||||
pub(crate) enum Clang {
|
||||
NamespaceDecl(NamespaceDecl),
|
||||
EnumDecl(EnumDecl),
|
||||
EnumConstantDecl(EnumConstantDecl),
|
||||
@ -13,13 +13,13 @@ pub enum Clang {
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct NamespaceDecl {
|
||||
pub(crate) struct NamespaceDecl {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub name: Option<Box<str>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct EnumDecl {
|
||||
pub(crate) struct EnumDecl {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub name: Option<Box<str>>,
|
||||
#[serde(
|
||||
@ -30,17 +30,17 @@ pub struct EnumDecl {
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct EnumConstantDecl {
|
||||
pub(crate) struct EnumConstantDecl {
|
||||
pub name: Box<str>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct ConstantExpr {
|
||||
pub(crate) struct ConstantExpr {
|
||||
pub value: Box<str>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Type {
|
||||
pub(crate) struct Type {
|
||||
#[serde(rename = "qualType")]
|
||||
pub qual_type: Box<str>,
|
||||
#[serde(rename = "desugaredQualType", skip_serializing_if = "Option::is_none")]
|
||||
|
@ -2,9 +2,12 @@ use crate::syntax::{derive, Enum, Struct, Trait};
|
||||
use proc_macro2::{Ident, Span, TokenStream};
|
||||
use quote::{quote, quote_spanned, ToTokens};
|
||||
|
||||
pub use crate::syntax::derive::*;
|
||||
pub(crate) use crate::syntax::derive::*;
|
||||
|
||||
pub fn expand_struct(strct: &Struct, actual_derives: &mut Option<TokenStream>) -> TokenStream {
|
||||
pub(crate) fn expand_struct(
|
||||
strct: &Struct,
|
||||
actual_derives: &mut Option<TokenStream>,
|
||||
) -> TokenStream {
|
||||
let mut expanded = TokenStream::new();
|
||||
let mut traits = Vec::new();
|
||||
|
||||
@ -35,7 +38,7 @@ pub fn expand_struct(strct: &Struct, actual_derives: &mut Option<TokenStream>) -
|
||||
expanded
|
||||
}
|
||||
|
||||
pub fn expand_enum(enm: &Enum, actual_derives: &mut Option<TokenStream>) -> TokenStream {
|
||||
pub(crate) fn expand_enum(enm: &Enum, actual_derives: &mut Option<TokenStream>) -> TokenStream {
|
||||
let mut expanded = TokenStream::new();
|
||||
let mut traits = Vec::new();
|
||||
let mut has_copy = false;
|
||||
|
@ -17,7 +17,7 @@ use quote::{format_ident, quote, quote_spanned, ToTokens};
|
||||
use std::mem;
|
||||
use syn::{parse_quote, punctuated, Generics, Lifetime, Result, Token};
|
||||
|
||||
pub fn bridge(mut ffi: Module) -> Result<TokenStream> {
|
||||
pub(crate) fn bridge(mut ffi: Module) -> Result<TokenStream> {
|
||||
let ref mut errors = Errors::new();
|
||||
|
||||
let mut cfg = CfgExpr::Unconditional;
|
||||
|
@ -5,18 +5,18 @@ use proc_macro2::TokenStream;
|
||||
use quote::ToTokens;
|
||||
use syn::{Lifetime, Token};
|
||||
|
||||
pub struct ImplGenerics<'a> {
|
||||
pub(crate) struct ImplGenerics<'a> {
|
||||
explicit_impl: Option<&'a Impl>,
|
||||
resolve: Resolution<'a>,
|
||||
}
|
||||
|
||||
pub struct TyGenerics<'a> {
|
||||
pub(crate) struct TyGenerics<'a> {
|
||||
key: NamedImplKey<'a>,
|
||||
explicit_impl: Option<&'a Impl>,
|
||||
resolve: Resolution<'a>,
|
||||
}
|
||||
|
||||
pub fn split_for_impl<'a>(
|
||||
pub(crate) fn split_for_impl<'a>(
|
||||
key: NamedImplKey<'a>,
|
||||
explicit_impl: Option<&'a Impl>,
|
||||
resolve: Resolution<'a>,
|
||||
@ -62,12 +62,12 @@ impl<'a> ToTokens for TyGenerics<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UnderscoreLifetimes<'a> {
|
||||
pub(crate) struct UnderscoreLifetimes<'a> {
|
||||
generics: &'a Lifetimes,
|
||||
}
|
||||
|
||||
impl Lifetimes {
|
||||
pub fn to_underscore_lifetimes(&self) -> UnderscoreLifetimes {
|
||||
pub(crate) fn to_underscore_lifetimes(&self) -> UnderscoreLifetimes {
|
||||
UnderscoreLifetimes { generics: self }
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ use syn::{parse_quote, Path};
|
||||
|
||||
const CXX_CLANG_AST: &str = "CXX_CLANG_AST";
|
||||
|
||||
pub fn load(cx: &mut Errors, apis: &mut [Api]) {
|
||||
pub(crate) fn load(cx: &mut Errors, apis: &mut [Api]) {
|
||||
let ref mut variants_from_header = Vec::new();
|
||||
for api in apis {
|
||||
if let Api::Enum(enm) = api {
|
||||
|
@ -3,17 +3,17 @@ use proc_macro2::TokenStream;
|
||||
use quote::{quote_spanned, ToTokens};
|
||||
use syn::Token;
|
||||
|
||||
pub struct ReceiverType<'a>(&'a Receiver);
|
||||
pub struct ReceiverTypeSelf<'a>(&'a Receiver);
|
||||
pub(crate) struct ReceiverType<'a>(&'a Receiver);
|
||||
pub(crate) struct ReceiverTypeSelf<'a>(&'a Receiver);
|
||||
|
||||
impl Receiver {
|
||||
// &TheType
|
||||
pub fn ty(&self) -> ReceiverType {
|
||||
pub(crate) fn ty(&self) -> ReceiverType {
|
||||
ReceiverType(self)
|
||||
}
|
||||
|
||||
// &Self
|
||||
pub fn ty_self(&self) -> ReceiverTypeSelf {
|
||||
pub(crate) fn ty_self(&self) -> ReceiverTypeSelf {
|
||||
ReceiverTypeSelf(self)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use proc_macro2::{TokenStream, TokenTree};
|
||||
use quote::{format_ident, quote, ToTokens};
|
||||
use syn::ext::IdentExt;
|
||||
|
||||
pub enum Crate {
|
||||
pub(crate) enum Crate {
|
||||
Cxx,
|
||||
DollarCrate(TokenTree),
|
||||
}
|
||||
@ -18,7 +18,7 @@ impl ToTokens for Crate {
|
||||
}
|
||||
|
||||
// "folly::File" => `(f, o, l, l, y, (), F, i, l, e)`
|
||||
pub fn expand(krate: Crate, arg: QualifiedName) -> TokenStream {
|
||||
pub(crate) fn expand(krate: Crate, arg: QualifiedName) -> TokenStream {
|
||||
let mut ids = Vec::new();
|
||||
|
||||
for word in arg.segments {
|
||||
|
@ -2,7 +2,7 @@ use core::char;
|
||||
use core::fmt::{self, Write as _};
|
||||
use core::str;
|
||||
|
||||
pub fn display(mut bytes: &[u8], f: &mut fmt::Formatter) -> fmt::Result {
|
||||
pub(crate) fn display(mut bytes: &[u8], f: &mut fmt::Formatter) -> fmt::Result {
|
||||
loop {
|
||||
match str::from_utf8(bytes) {
|
||||
Ok(valid) => return f.write_str(valid),
|
||||
@ -21,7 +21,7 @@ pub fn display(mut bytes: &[u8], f: &mut fmt::Formatter) -> fmt::Result {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn debug(mut bytes: &[u8], f: &mut fmt::Formatter) -> fmt::Result {
|
||||
pub(crate) fn debug(mut bytes: &[u8], f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_char('"')?;
|
||||
|
||||
while !bytes.is_empty() {
|
||||
|
@ -12,7 +12,7 @@ use core::str;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct PtrLen {
|
||||
pub(crate) struct PtrLen {
|
||||
pub ptr: NonNull<u8>,
|
||||
pub len: usize,
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ use core::ptr;
|
||||
/// (e.g., `collections::HashMap` uses it by default).
|
||||
///
|
||||
/// See: <https://131002.net/siphash>
|
||||
pub struct SipHasher13 {
|
||||
pub(crate) struct SipHasher13 {
|
||||
k0: u64,
|
||||
k1: u64,
|
||||
length: usize, // how many bytes we've processed
|
||||
@ -110,7 +110,7 @@ unsafe fn u8to64_le(buf: &[u8], start: usize, len: usize) -> u64 {
|
||||
|
||||
impl SipHasher13 {
|
||||
/// Creates a new `SipHasher13` with the two initial keys set to 0.
|
||||
pub fn new() -> Self {
|
||||
pub(crate) fn new() -> Self {
|
||||
Self::new_with_keys(0, 0)
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ use syn::{Attribute, Error, Expr, Lit, LitStr, Meta, Path, Result, Token};
|
||||
// );
|
||||
//
|
||||
#[derive(Default)]
|
||||
pub struct Parser<'a> {
|
||||
pub(crate) struct Parser<'a> {
|
||||
pub cfg: Option<&'a mut CfgExpr>,
|
||||
pub doc: Option<&'a mut Doc>,
|
||||
pub derives: Option<&'a mut Vec<Derive>>,
|
||||
@ -44,7 +44,7 @@ pub struct Parser<'a> {
|
||||
pub(crate) _more: (),
|
||||
}
|
||||
|
||||
pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> OtherAttrs {
|
||||
pub(crate) fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> OtherAttrs {
|
||||
let mut passthrough_attrs = Vec::new();
|
||||
for attr in attrs {
|
||||
let attr_path = attr.path();
|
||||
|
@ -25,7 +25,7 @@ impl CfgExpr {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_attribute(attr: &Attribute) -> Result<CfgExpr> {
|
||||
pub(crate) fn parse_attribute(attr: &Attribute) -> Result<CfgExpr> {
|
||||
attr.parse_args_with(|input: ParseStream| {
|
||||
let cfg_expr = input.call(parse_single)?;
|
||||
input.parse::<Option<Token![,]>>()?;
|
||||
|
@ -76,6 +76,6 @@ impl Display for Derive {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn contains(derives: &[Derive], query: Trait) -> bool {
|
||||
pub(crate) fn contains(derives: &[Derive], query: Trait) -> bool {
|
||||
derives.iter().any(|derive| derive.what == query)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use std::fmt::{self, Display};
|
||||
use std::str::FromStr;
|
||||
use syn::{Error, Expr, Lit, Result, Token, UnOp};
|
||||
|
||||
pub struct DiscriminantSet {
|
||||
pub(crate) struct DiscriminantSet {
|
||||
repr: Option<Atom>,
|
||||
values: BTreeSet<Discriminant>,
|
||||
previous: Option<Discriminant>,
|
||||
@ -149,7 +149,7 @@ fn insert(set: &mut DiscriminantSet, discriminant: Discriminant) -> Result<Discr
|
||||
}
|
||||
|
||||
impl Discriminant {
|
||||
pub const fn zero() -> Self {
|
||||
pub(crate) const fn zero() -> Self {
|
||||
Discriminant {
|
||||
sign: Sign::Positive,
|
||||
magnitude: 0,
|
||||
@ -180,7 +180,7 @@ impl Discriminant {
|
||||
}
|
||||
|
||||
#[cfg(feature = "experimental-enum-variants-from-header")]
|
||||
pub const fn checked_succ(self) -> Option<Self> {
|
||||
pub(crate) const fn checked_succ(self) -> Option<Self> {
|
||||
match self.sign {
|
||||
Sign::Negative => {
|
||||
if self.magnitude == 1 {
|
||||
|
@ -8,24 +8,24 @@ pub struct Doc {
|
||||
}
|
||||
|
||||
impl Doc {
|
||||
pub fn new() -> Self {
|
||||
pub(crate) fn new() -> Self {
|
||||
Doc {
|
||||
hidden: false,
|
||||
fragments: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push(&mut self, lit: LitStr) {
|
||||
pub(crate) fn push(&mut self, lit: LitStr) {
|
||||
self.fragments.push(lit);
|
||||
}
|
||||
|
||||
#[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
|
||||
pub fn is_empty(&self) -> bool {
|
||||
pub(crate) fn is_empty(&self) -> bool {
|
||||
self.fragments.is_empty()
|
||||
}
|
||||
|
||||
#[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
|
||||
pub fn to_string(&self) -> String {
|
||||
pub(crate) fn to_string(&self) -> String {
|
||||
let mut doc = String::new();
|
||||
for lit in &self.fragments {
|
||||
doc += &lit.value();
|
||||
|
@ -13,7 +13,7 @@ impl Display for Error {
|
||||
}
|
||||
}
|
||||
|
||||
pub static ERRORS: &[Error] = &[
|
||||
pub(crate) static ERRORS: &[Error] = &[
|
||||
BOX_CXX_TYPE,
|
||||
CXXBRIDGE_RESERVED,
|
||||
CXX_STRING_BY_VALUE,
|
||||
@ -27,67 +27,67 @@ pub static ERRORS: &[Error] = &[
|
||||
USE_NOT_ALLOWED,
|
||||
];
|
||||
|
||||
pub static BOX_CXX_TYPE: Error = Error {
|
||||
pub(crate) static BOX_CXX_TYPE: Error = Error {
|
||||
msg: "Box of a C++ type is not supported yet",
|
||||
label: None,
|
||||
note: Some("hint: use UniquePtr<> or SharedPtr<>"),
|
||||
};
|
||||
|
||||
pub static CXXBRIDGE_RESERVED: Error = Error {
|
||||
pub(crate) static CXXBRIDGE_RESERVED: Error = Error {
|
||||
msg: "identifiers starting with cxxbridge are reserved",
|
||||
label: Some("reserved identifier"),
|
||||
note: Some("identifiers starting with cxxbridge are reserved"),
|
||||
};
|
||||
|
||||
pub static CXX_STRING_BY_VALUE: Error = Error {
|
||||
pub(crate) static CXX_STRING_BY_VALUE: Error = Error {
|
||||
msg: "C++ string by value is not supported",
|
||||
label: None,
|
||||
note: Some("hint: wrap it in a UniquePtr<>"),
|
||||
};
|
||||
|
||||
pub static CXX_TYPE_BY_VALUE: Error = Error {
|
||||
pub(crate) static CXX_TYPE_BY_VALUE: Error = Error {
|
||||
msg: "C++ type by value is not supported",
|
||||
label: None,
|
||||
note: Some("hint: wrap it in a UniquePtr<> or SharedPtr<>"),
|
||||
};
|
||||
|
||||
pub static DISCRIMINANT_OVERFLOW: Error = Error {
|
||||
pub(crate) static DISCRIMINANT_OVERFLOW: Error = Error {
|
||||
msg: "discriminant overflow on value after ",
|
||||
label: Some("discriminant overflow"),
|
||||
note: Some("note: explicitly set `= 0` if that is desired outcome"),
|
||||
};
|
||||
|
||||
pub static DOT_INCLUDE: Error = Error {
|
||||
pub(crate) static DOT_INCLUDE: Error = Error {
|
||||
msg: "#include relative to `.` or `..` is not supported in Cargo builds",
|
||||
label: Some("#include relative to `.` or `..` is not supported in Cargo builds"),
|
||||
note: Some("note: use a path starting with the crate name"),
|
||||
};
|
||||
|
||||
pub static DOUBLE_UNDERSCORE: Error = Error {
|
||||
pub(crate) static DOUBLE_UNDERSCORE: Error = Error {
|
||||
msg: "identifiers containing double underscore are reserved in C++",
|
||||
label: Some("reserved identifier"),
|
||||
note: Some("identifiers containing double underscore are reserved in C++"),
|
||||
};
|
||||
|
||||
pub static RESERVED_LIFETIME: Error = Error {
|
||||
pub(crate) static RESERVED_LIFETIME: Error = Error {
|
||||
msg: "invalid lifetime parameter name: `'static`",
|
||||
label: Some("'static is a reserved lifetime name"),
|
||||
note: None,
|
||||
};
|
||||
|
||||
pub static RUST_TYPE_BY_VALUE: Error = Error {
|
||||
pub(crate) static RUST_TYPE_BY_VALUE: Error = Error {
|
||||
msg: "opaque Rust type by value is not supported",
|
||||
label: None,
|
||||
note: Some("hint: wrap it in a Box<>"),
|
||||
};
|
||||
|
||||
pub static UNSUPPORTED_TYPE: Error = Error {
|
||||
pub(crate) static UNSUPPORTED_TYPE: Error = Error {
|
||||
msg: "unsupported type: ",
|
||||
label: Some("unsupported type"),
|
||||
note: None,
|
||||
};
|
||||
|
||||
pub static USE_NOT_ALLOWED: Error = Error {
|
||||
pub(crate) static USE_NOT_ALLOWED: Error = Error {
|
||||
msg: "`use` items are not allowed within cxx bridge",
|
||||
label: Some("not allowed"),
|
||||
note: Some(
|
||||
|
@ -3,14 +3,14 @@ use crate::syntax::atom::Atom::{self, *};
|
||||
use crate::syntax::{Type, Types};
|
||||
use proc_macro2::Ident;
|
||||
|
||||
pub enum ImproperCtype<'a> {
|
||||
pub(crate) enum ImproperCtype<'a> {
|
||||
Definite(bool),
|
||||
Depends(&'a Ident),
|
||||
}
|
||||
|
||||
impl<'a> Types<'a> {
|
||||
// yes, no, maybe
|
||||
pub fn determine_improper_ctype(&self, ty: &Type) -> ImproperCtype<'a> {
|
||||
pub(crate) fn determine_improper_ctype(&self, ty: &Type) -> ImproperCtype<'a> {
|
||||
match ty {
|
||||
Type::Ident(ident) => {
|
||||
let ident = &ident.rust;
|
||||
|
@ -84,7 +84,7 @@ macro_rules! join {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn extern_fn(efn: &ExternFn, types: &Types) -> Symbol {
|
||||
pub(crate) fn extern_fn(efn: &ExternFn, types: &Types) -> Symbol {
|
||||
match &efn.receiver {
|
||||
Some(receiver) => {
|
||||
let receiver_ident = types.resolve(&receiver.ty);
|
||||
@ -99,7 +99,7 @@ pub fn extern_fn(efn: &ExternFn, types: &Types) -> Symbol {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn operator(receiver: &Pair, operator: &'static str) -> Symbol {
|
||||
pub(crate) fn operator(receiver: &Pair, operator: &'static str) -> Symbol {
|
||||
join!(
|
||||
receiver.namespace,
|
||||
CXXBRIDGE,
|
||||
@ -110,11 +110,11 @@ pub fn operator(receiver: &Pair, operator: &'static str) -> Symbol {
|
||||
}
|
||||
|
||||
// The C half of a function pointer trampoline.
|
||||
pub fn c_trampoline(efn: &ExternFn, var: &Pair, types: &Types) -> Symbol {
|
||||
pub(crate) fn c_trampoline(efn: &ExternFn, var: &Pair, types: &Types) -> Symbol {
|
||||
join!(extern_fn(efn, types), var.rust, 0)
|
||||
}
|
||||
|
||||
// The Rust half of a function pointer trampoline.
|
||||
pub fn r_trampoline(efn: &ExternFn, var: &Pair, types: &Types) -> Symbol {
|
||||
pub(crate) fn r_trampoline(efn: &ExternFn, var: &Pair, types: &Types) -> Symbol {
|
||||
join!(extern_fn(efn, types), var.rust, 1)
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ use std::hash::Hash;
|
||||
use std::ops::Index;
|
||||
use std::slice;
|
||||
|
||||
pub use self::ordered::OrderedMap;
|
||||
pub use self::unordered::UnorderedMap;
|
||||
pub use std::collections::hash_map::Entry;
|
||||
pub(crate) use self::ordered::OrderedMap;
|
||||
pub(crate) use self::unordered::UnorderedMap;
|
||||
pub(crate) use std::collections::hash_map::Entry;
|
||||
|
||||
mod ordered {
|
||||
use super::{Entry, Iter, UnorderedMap};
|
||||
|
@ -1,33 +1,33 @@
|
||||
// Functionality that is shared between the cxxbridge macro and the cmd.
|
||||
|
||||
pub mod atom;
|
||||
pub mod attrs;
|
||||
pub mod cfg;
|
||||
pub mod check;
|
||||
pub mod derive;
|
||||
pub(crate) mod atom;
|
||||
pub(crate) mod attrs;
|
||||
pub(crate) mod cfg;
|
||||
pub(crate) mod check;
|
||||
pub(crate) mod derive;
|
||||
mod discriminant;
|
||||
mod doc;
|
||||
pub mod error;
|
||||
pub mod file;
|
||||
pub mod ident;
|
||||
pub(crate) mod error;
|
||||
pub(crate) mod file;
|
||||
pub(crate) mod ident;
|
||||
mod impls;
|
||||
mod improper;
|
||||
pub mod instantiate;
|
||||
pub mod mangle;
|
||||
pub mod map;
|
||||
pub(crate) mod instantiate;
|
||||
pub(crate) mod mangle;
|
||||
pub(crate) mod map;
|
||||
mod names;
|
||||
pub mod namespace;
|
||||
pub(crate) mod namespace;
|
||||
mod parse;
|
||||
mod pod;
|
||||
pub mod qualified;
|
||||
pub mod report;
|
||||
pub mod resolve;
|
||||
pub mod set;
|
||||
pub mod symbol;
|
||||
pub(crate) mod qualified;
|
||||
pub(crate) mod report;
|
||||
pub(crate) mod resolve;
|
||||
pub(crate) mod set;
|
||||
pub(crate) mod symbol;
|
||||
mod tokens;
|
||||
mod toposort;
|
||||
pub mod trivial;
|
||||
pub mod types;
|
||||
pub(crate) mod trivial;
|
||||
pub(crate) mod types;
|
||||
mod visit;
|
||||
|
||||
use self::attrs::OtherAttrs;
|
||||
@ -40,13 +40,13 @@ use syn::punctuated::Punctuated;
|
||||
use syn::token::{Brace, Bracket, Paren};
|
||||
use syn::{Attribute, Expr, Generics, Lifetime, LitInt, Token, Type as RustType};
|
||||
|
||||
pub use self::atom::Atom;
|
||||
pub use self::derive::{Derive, Trait};
|
||||
pub use self::discriminant::Discriminant;
|
||||
pub use self::doc::Doc;
|
||||
pub use self::names::ForeignName;
|
||||
pub use self::parse::parse_items;
|
||||
pub use self::types::Types;
|
||||
pub(crate) use self::atom::Atom;
|
||||
pub(crate) use self::derive::{Derive, Trait};
|
||||
pub(crate) use self::discriminant::Discriminant;
|
||||
pub(crate) use self::doc::Doc;
|
||||
pub(crate) use self::names::ForeignName;
|
||||
pub(crate) use self::parse::parse_items;
|
||||
pub(crate) use self::types::Types;
|
||||
|
||||
pub enum Api {
|
||||
Include(Include),
|
||||
|
@ -13,7 +13,7 @@ pub struct ForeignName {
|
||||
}
|
||||
|
||||
impl Pair {
|
||||
pub fn to_symbol(&self) -> Symbol {
|
||||
pub(crate) fn to_symbol(&self) -> Symbol {
|
||||
let segments = self
|
||||
.namespace
|
||||
.iter()
|
||||
@ -24,7 +24,7 @@ impl Pair {
|
||||
}
|
||||
|
||||
impl NamedType {
|
||||
pub fn new(rust: Ident) -> Self {
|
||||
pub(crate) fn new(rust: Ident) -> Self {
|
||||
let generics = Lifetimes {
|
||||
lt_token: None,
|
||||
lifetimes: Punctuated::new(),
|
||||
@ -39,7 +39,7 @@ impl NamedType {
|
||||
}
|
||||
|
||||
impl ForeignName {
|
||||
pub fn parse(text: &str, span: Span) -> Result<Self> {
|
||||
pub(crate) fn parse(text: &str, span: Span) -> Result<Self> {
|
||||
// TODO: support C++ names containing whitespace (`unsigned int`) or
|
||||
// non-alphanumeric characters (`operator++`).
|
||||
match Ident::parse_any.parse_str(text) {
|
||||
|
@ -15,15 +15,15 @@ pub struct Namespace {
|
||||
}
|
||||
|
||||
impl Namespace {
|
||||
pub const ROOT: Self = Namespace {
|
||||
pub(crate) const ROOT: Self = Namespace {
|
||||
segments: Vec::new(),
|
||||
};
|
||||
|
||||
pub fn iter(&self) -> Iter<Ident> {
|
||||
pub(crate) fn iter(&self) -> Iter<Ident> {
|
||||
self.segments.iter()
|
||||
}
|
||||
|
||||
pub fn parse_bridge_attr_namespace(input: ParseStream) -> Result<Self> {
|
||||
pub(crate) fn parse_bridge_attr_namespace(input: ParseStream) -> Result<Self> {
|
||||
if input.is_empty() {
|
||||
return Ok(Namespace::ROOT);
|
||||
}
|
||||
@ -35,7 +35,7 @@ impl Namespace {
|
||||
Ok(namespace)
|
||||
}
|
||||
|
||||
pub fn parse_meta(meta: &Meta) -> Result<Self> {
|
||||
pub(crate) fn parse_meta(meta: &Meta) -> Result<Self> {
|
||||
if let Meta::NameValue(meta) = meta {
|
||||
match &meta.value {
|
||||
Expr::Lit(expr) => {
|
||||
|
@ -22,12 +22,12 @@ use syn::{
|
||||
TypeReference, Variant as RustVariant, Visibility,
|
||||
};
|
||||
|
||||
pub mod kw {
|
||||
pub(crate) mod kw {
|
||||
syn::custom_keyword!(Pin);
|
||||
syn::custom_keyword!(Result);
|
||||
}
|
||||
|
||||
pub fn parse_items(
|
||||
pub(crate) fn parse_items(
|
||||
cx: &mut Errors,
|
||||
items: Vec<Item>,
|
||||
trusted: bool,
|
||||
|
@ -2,7 +2,7 @@ use crate::syntax::atom::Atom::{self, *};
|
||||
use crate::syntax::{derive, Trait, Type, Types};
|
||||
|
||||
impl<'a> Types<'a> {
|
||||
pub fn is_guaranteed_pod(&self, ty: &Type) -> bool {
|
||||
pub(crate) fn is_guaranteed_pod(&self, ty: &Type) -> bool {
|
||||
match ty {
|
||||
Type::Ident(ident) => {
|
||||
let ident = &ident.rust;
|
||||
|
@ -2,12 +2,12 @@ use syn::ext::IdentExt;
|
||||
use syn::parse::{Error, ParseStream, Result};
|
||||
use syn::{Ident, LitStr, Token};
|
||||
|
||||
pub struct QualifiedName {
|
||||
pub(crate) struct QualifiedName {
|
||||
pub segments: Vec<Ident>,
|
||||
}
|
||||
|
||||
impl QualifiedName {
|
||||
pub fn parse_quoted(lit: &LitStr) -> Result<Self> {
|
||||
pub(crate) fn parse_quoted(lit: &LitStr) -> Result<Self> {
|
||||
if lit.value().is_empty() {
|
||||
let segments = Vec::new();
|
||||
Ok(QualifiedName { segments })
|
||||
@ -19,12 +19,12 @@ impl QualifiedName {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_unquoted(input: ParseStream) -> Result<Self> {
|
||||
pub(crate) fn parse_unquoted(input: ParseStream) -> Result<Self> {
|
||||
let allow_raw = true;
|
||||
parse_unquoted(input, allow_raw)
|
||||
}
|
||||
|
||||
pub fn parse_quoted_or_unquoted(input: ParseStream) -> Result<Self> {
|
||||
pub(crate) fn parse_quoted_or_unquoted(input: ParseStream) -> Result<Self> {
|
||||
if input.peek(LitStr) {
|
||||
let lit: LitStr = input.parse()?;
|
||||
Self::parse_quoted(&lit)
|
||||
|
@ -2,24 +2,24 @@ use quote::ToTokens;
|
||||
use std::fmt::Display;
|
||||
use syn::{Error, Result};
|
||||
|
||||
pub struct Errors {
|
||||
pub(crate) struct Errors {
|
||||
errors: Vec<Error>,
|
||||
}
|
||||
|
||||
impl Errors {
|
||||
pub fn new() -> Self {
|
||||
pub(crate) fn new() -> Self {
|
||||
Errors { errors: Vec::new() }
|
||||
}
|
||||
|
||||
pub fn error(&mut self, sp: impl ToTokens, msg: impl Display) {
|
||||
pub(crate) fn error(&mut self, sp: impl ToTokens, msg: impl Display) {
|
||||
self.errors.push(Error::new_spanned(sp, msg));
|
||||
}
|
||||
|
||||
pub fn push(&mut self, error: Error) {
|
||||
pub(crate) fn push(&mut self, error: Error) {
|
||||
self.errors.push(error);
|
||||
}
|
||||
|
||||
pub fn propagate(&mut self) -> Result<()> {
|
||||
pub(crate) fn propagate(&mut self) -> Result<()> {
|
||||
let mut iter = self.errors.drain(..);
|
||||
let mut all_errors = match iter.next() {
|
||||
Some(err) => err,
|
||||
|
@ -9,7 +9,7 @@ pub struct Resolution<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Types<'a> {
|
||||
pub fn resolve(&self, ident: &impl UnresolvedName) -> Resolution<'a> {
|
||||
pub(crate) fn resolve(&self, ident: &impl UnresolvedName) -> Resolution<'a> {
|
||||
let ident = ident.ident();
|
||||
match self.try_resolve(ident) {
|
||||
Some(resolution) => resolution,
|
||||
@ -17,13 +17,13 @@ impl<'a> Types<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_resolve(&self, ident: &impl UnresolvedName) -> Option<Resolution<'a>> {
|
||||
pub(crate) fn try_resolve(&self, ident: &impl UnresolvedName) -> Option<Resolution<'a>> {
|
||||
let ident = ident.ident();
|
||||
self.resolutions.get(ident).copied()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait UnresolvedName {
|
||||
pub(crate) trait UnresolvedName {
|
||||
fn ident(&self) -> &Ident;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::fmt::{self, Debug};
|
||||
use std::slice;
|
||||
|
||||
pub use self::ordered::OrderedSet;
|
||||
pub use self::unordered::UnorderedSet;
|
||||
pub(crate) use self::ordered::OrderedSet;
|
||||
pub(crate) use self::unordered::UnorderedSet;
|
||||
|
||||
mod ordered {
|
||||
use super::{Iter, UnorderedSet};
|
||||
|
@ -6,7 +6,7 @@ use std::fmt::{self, Display, Write};
|
||||
|
||||
// A mangled symbol consisting of segments separated by '$'.
|
||||
// For example: cxxbridge1$string$new
|
||||
pub struct Symbol(String);
|
||||
pub(crate) struct Symbol(String);
|
||||
|
||||
impl Display for Symbol {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
@ -30,7 +30,7 @@ impl Symbol {
|
||||
assert!(self.0.len() > len_before);
|
||||
}
|
||||
|
||||
pub fn from_idents<'a>(it: impl Iterator<Item = &'a dyn Segment>) -> Self {
|
||||
pub(crate) fn from_idents<'a>(it: impl Iterator<Item = &'a dyn Segment>) -> Self {
|
||||
let mut symbol = Symbol(String::new());
|
||||
for segment in it {
|
||||
segment.write(&mut symbol);
|
||||
@ -40,7 +40,7 @@ impl Symbol {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Segment {
|
||||
pub(crate) trait Segment {
|
||||
fn write(&self, symbol: &mut Symbol);
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn join(segments: &[&dyn Segment]) -> Symbol {
|
||||
pub(crate) fn join(segments: &[&dyn Segment]) -> Symbol {
|
||||
let mut symbol = Symbol(String::new());
|
||||
for segment in segments {
|
||||
segment.write(&mut symbol);
|
||||
|
@ -7,7 +7,7 @@ enum Mark {
|
||||
Visited,
|
||||
}
|
||||
|
||||
pub fn sort<'a>(cx: &mut Errors, apis: &'a [Api], types: &Types<'a>) -> Vec<&'a Struct> {
|
||||
pub(crate) fn sort<'a>(cx: &mut Errors, apis: &'a [Api], types: &Types<'a>) -> Vec<&'a Struct> {
|
||||
let mut sorted = Vec::new();
|
||||
let ref mut marks = Map::new();
|
||||
for api in apis {
|
||||
|
@ -15,7 +15,7 @@ pub enum TrivialReason<'a> {
|
||||
UnpinnedMut(&'a ExternFn),
|
||||
}
|
||||
|
||||
pub fn required_trivial_reasons<'a>(
|
||||
pub(crate) fn required_trivial_reasons<'a>(
|
||||
apis: &'a [Api],
|
||||
all: &Set<&'a Type>,
|
||||
structs: &UnorderedMap<&'a Ident, &'a Struct>,
|
||||
@ -124,7 +124,7 @@ pub fn required_trivial_reasons<'a>(
|
||||
// Context:
|
||||
// "type {type} should be trivially move constructible and trivially destructible in C++ to be used as {what} in Rust"
|
||||
// "needs a cxx::ExternType impl in order to be used as {what}"
|
||||
pub fn as_what<'a>(name: &'a Pair, reasons: &'a [TrivialReason]) -> impl Display + 'a {
|
||||
pub(crate) fn as_what<'a>(name: &'a Pair, reasons: &'a [TrivialReason]) -> impl Display + 'a {
|
||||
struct Description<'a> {
|
||||
name: &'a Pair,
|
||||
reasons: &'a [TrivialReason<'a>],
|
||||
|
@ -28,7 +28,7 @@ pub struct Types<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Types<'a> {
|
||||
pub fn collect(cx: &mut Errors, apis: &'a [Api]) -> Self {
|
||||
pub(crate) fn collect(cx: &mut Errors, apis: &'a [Api]) -> Self {
|
||||
let mut all = OrderedSet::new();
|
||||
let mut structs = UnorderedMap::new();
|
||||
let mut enums = UnorderedMap::new();
|
||||
@ -241,7 +241,7 @@ impl<'a> Types<'a> {
|
||||
types
|
||||
}
|
||||
|
||||
pub fn needs_indirect_abi(&self, ty: &Type) -> bool {
|
||||
pub(crate) fn needs_indirect_abi(&self, ty: &Type) -> bool {
|
||||
match ty {
|
||||
Type::RustBox(_) | Type::UniquePtr(_) => false,
|
||||
Type::Array(_) => true,
|
||||
@ -264,7 +264,7 @@ impl<'a> Types<'a> {
|
||||
|
||||
// Types which we need to assume could possibly exist by value on the Rust
|
||||
// side.
|
||||
pub fn is_maybe_trivial(&self, ty: &Ident) -> bool {
|
||||
pub(crate) fn is_maybe_trivial(&self, ty: &Ident) -> bool {
|
||||
self.structs.contains_key(ty)
|
||||
|| self.enums.contains_key(ty)
|
||||
|| self.aliases.contains_key(ty)
|
||||
|
@ -1,12 +1,12 @@
|
||||
use crate::syntax::Type;
|
||||
|
||||
pub trait Visit<'a> {
|
||||
pub(crate) trait Visit<'a> {
|
||||
fn visit_type(&mut self, ty: &'a Type) {
|
||||
visit_type(self, ty);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_type<'a, V>(visitor: &mut V, ty: &'a Type)
|
||||
pub(crate) fn visit_type<'a, V>(visitor: &mut V, ty: &'a Type)
|
||||
where
|
||||
V: Visit<'a> + ?Sized,
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user