-
-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
An initial toehold on refactoring work to partially unify wrapper-fn expansions in their implementations, especially where it is correctness-relevant.
- Loading branch information
1 parent
6fae0dc
commit 3ce0391
Showing
4 changed files
with
30 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use quote::{format_ident, quote}; | ||
use syn::{self, ItemFn}; | ||
|
||
/// Generate the Postgres fn info record | ||
/// | ||
/// Equivalent to PG_FUNCTION_INFO_V1, Postgres will sprintf the fn ident, then `dlsym(so, expected_name)`, | ||
/// so it is important to pass exactly the ident that you want to have the record associated with! | ||
pub fn finfo_v1_tokens(ident: proc_macro2::Ident) -> syn::Result<ItemFn> { | ||
let finfo_name = format_ident!("pg_finfo_{ident}"); | ||
let tokens = quote! { | ||
#[no_mangle] | ||
#[doc(hidden)] | ||
pub extern "C" fn #finfo_name() -> &'static ::pgrx::pg_sys::Pg_finfo_record { | ||
const V1_API: ::pgrx::pg_sys::Pg_finfo_record = ::pgrx::pg_sys::Pg_finfo_record { api_version: 1 }; | ||
&V1_API | ||
} | ||
}; | ||
syn::parse2(tokens) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters