Skip to content

Commit 672ba57

Browse files
committed
libm-macros: Start tracking which functions are public
It would be nice to reuse some of the macro structure for internal functions, like `rem_pio2`. To facilitate this, add a `public` field and make it available in the macro's API.
1 parent 667ba28 commit 672ba57

File tree

4 files changed

+226
-175
lines changed

4 files changed

+226
-175
lines changed

crates/libm-macros/src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use syn::visit_mut::VisitMut;
1212
use syn::{Ident, ItemEnum};
1313

1414
const KNOWN_TYPES: &[&str] = &[
15-
"FTy", "CFn", "CArgs", "CRet", "RustFn", "RustArgs", "RustRet",
15+
"FTy", "CFn", "CArgs", "CRet", "RustFn", "RustArgs", "RustRet", "public",
1616
];
1717

1818
/// Populate an enum with a variant representing function. Names are in upper camel case.
@@ -80,6 +80,8 @@ pub fn base_name_enum(attributes: pm::TokenStream, tokens: pm::TokenStream) -> p
8080
/// RustArgs: $RustArgs:ty,
8181
/// // The Rust version's return type (e.g. `(f32, f32)`)
8282
/// RustRet: $RustRet:ty,
83+
/// // True if this is part of `libm`'s public API
84+
/// public: $public:expr,
8385
/// // Attributes for the current function, if any
8486
/// attrs: [$($attr:meta),*],
8587
/// // Extra tokens passed directly (if any)
@@ -329,6 +331,7 @@ fn expand(input: StructuredInput, fn_list: &[&MathOpInfo]) -> syn::Result<pm2::T
329331
let c_ret = &func.c_sig.returns;
330332
let rust_args = &func.rust_sig.args;
331333
let rust_ret = &func.rust_sig.returns;
334+
let public = func.public;
332335

333336
let mut ty_fields = Vec::new();
334337
for ty in &input.emit_types {
@@ -340,6 +343,7 @@ fn expand(input: StructuredInput, fn_list: &[&MathOpInfo]) -> syn::Result<pm2::T
340343
"RustFn" => quote! { RustFn: fn( #(#rust_args),* ,) -> ( #(#rust_ret),* ), },
341344
"RustArgs" => quote! { RustArgs: ( #(#rust_args),* ,), },
342345
"RustRet" => quote! { RustRet: ( #(#rust_ret),* ), },
346+
"public" => quote! { public: #public, },
343347
_ => unreachable!("checked in validation"),
344348
};
345349
ty_fields.push(field);

0 commit comments

Comments
 (0)