Skip to content

Commit

Permalink
Name games
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee committed May 14, 2024
1 parent 3e64627 commit 6bf40f1
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 78 deletions.
6 changes: 3 additions & 3 deletions pgrx-examples/custom_types/src/hexint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//LICENSE All rights reserved.
//LICENSE
//LICENSE Use of this source code is governed by the MIT license that can be found in the LICENSE file.
use pgrx::callconv::{BoxRet, Ret};
use pgrx::callconv::{Ret, ReturnShipping};
use pgrx::pg_sys::{Datum, Oid};
use pgrx::pgrx_sql_entity_graph::metadata::{
ArgumentError, Returns, ReturnsError, SqlMapping, SqlTranslatable,
Expand Down Expand Up @@ -94,9 +94,9 @@ impl IntoDatum for HexInt {
}
}

unsafe impl BoxRet for HexInt {
unsafe impl ReturnShipping for HexInt {
type CallRet = Self;
fn into_ret(self) -> Ret<Self>
fn label_ret(self) -> Ret<Self>
where
Self: Sized,
{
Expand Down
12 changes: 4 additions & 8 deletions pgrx-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,15 +705,11 @@ fn impl_postgres_enum(ast: DeriveInput) -> syn::Result<proc_macro2::TokenStream>

}

unsafe impl ::pgrx::callconv::BoxRet for #enum_ident {
unsafe impl ::pgrx::callconv::ReturnShipping for #enum_ident {
type CallRet = Self;
fn into_ret(self) -> ::pgrx::callconv::Ret<Self>
where
Self: Sized,
{
fn label_ret(self) -> ::pgrx::callconv::Ret<Self> {
::pgrx::callconv::Ret::Once(self)
}

unsafe fn box_return(fcinfo: ::pgrx::pg_sys::FunctionCallInfo, ret: ::pgrx::callconv::Ret<Self>) -> ::pgrx::pg_sys::Datum {
match ret {
::pgrx::callconv::Ret::Zero => unsafe { ::pgrx::pg_return_null(fcinfo) },
Expand Down Expand Up @@ -826,9 +822,9 @@ fn impl_postgres_type(ast: DeriveInput) -> syn::Result<proc_macro2::TokenStream>
}
}

unsafe impl #generics ::pgrx::callconv::BoxRet for #name #generics {
unsafe impl #generics ::pgrx::callconv::ReturnShipping for #name #generics {
type CallRet = Self;
fn into_ret(self) -> ::pgrx::callconv::Ret<Self> {
fn label_ret(self) -> ::pgrx::callconv::Ret<Self> {
::pgrx::callconv::Ret::Once(self)
}
unsafe fn box_return(fcinfo: ::pgrx::pg_sys::FunctionCallInfo, ret: ::pgrx::callconv::Ret<Self>) -> ::pgrx::pg_sys::Datum {
Expand Down
8 changes: 4 additions & 4 deletions pgrx-sql-entity-graph/src/pg_extern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,18 +419,18 @@ impl PgExtern {
#[allow(unused_unsafe)]
unsafe {
let fcinfo = #fcinfo_ident;
let result: ::pgrx::callconv::Ret<#ret_ty> = match <#ret_ty as ::pgrx::callconv::BoxRet>::prepare_call(fcinfo) {
let result: ::pgrx::callconv::Ret<#ret_ty> = match <#ret_ty as ::pgrx::callconv::ReturnShipping>::prepare_call(fcinfo) {
::pgrx::callconv::CallCx::WrappedFn(mcx) => {
let mut mcx = ::pgrx::PgMemoryContexts::For(mcx);
let call_result: #ret_ty = mcx.switch_to(|_| {
#(#arg_fetches)*
#func_name( #(#arg_pats),* )
});
::pgrx::callconv::BoxRet::into_ret(call_result)
::pgrx::callconv::ReturnShipping::label_ret(call_result)
}
::pgrx::callconv::CallCx::RestoreCx => ::pgrx::callconv::BoxRet::ret_from_context(fcinfo),
::pgrx::callconv::CallCx::RestoreCx => ::pgrx::callconv::ReturnShipping::ret_from_context(fcinfo),
};
unsafe { ::pgrx::callconv::BoxRet::box_return(fcinfo, result) }
unsafe { ::pgrx::callconv::ReturnShipping::box_return(fcinfo, result) }
}
};
finfo_v1_extern_c(&self.func, fcinfo_ident, wrapper_code)
Expand Down
Loading

0 comments on commit 6bf40f1

Please sign in to comment.