forked from phper-framework/phper
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dusan Malusev <dusan@dusanmalusev.dev>
- Loading branch information
1 parent
e15940e
commit bf89d9d
Showing
35 changed files
with
1,247 additions
and
1,199 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,44 @@ | ||
use proc_macro::TokenStream; | ||
use proc_macro2::Span; | ||
use quote::quote; | ||
use syn::parse::{Parse, ParseBuffer}; | ||
use syn::Ident; | ||
use syn::{parse_macro_input, Token}; | ||
|
||
struct ZendFn { | ||
original_zend_fn: Ident, | ||
const_name: Ident, | ||
} | ||
|
||
impl Parse for ZendFn { | ||
fn parse(input: &'_ ParseBuffer<'_>) -> syn::Result<Self> { | ||
let original_zend_fn: Ident = input.parse()?; | ||
input.parse::<Token![,]>()?; | ||
let const_name: Ident = input.parse()?; | ||
Ok(ZendFn { | ||
original_zend_fn, | ||
const_name, | ||
}) | ||
} | ||
} | ||
|
||
pub(crate) fn zend_create_fn(input: TokenStream) -> TokenStream { | ||
let ZendFn { | ||
original_zend_fn, | ||
const_name, | ||
} = parse_macro_input!(input as ZendFn); | ||
|
||
let fn_name = format!("zend_create_fn_{}", original_zend_fn.to_string()); | ||
let new_fn_name = Ident::new(&fn_name, Span::call_site()); | ||
|
||
let result = quote! { | ||
unsafe extern "C" fn #new_fn_name() -> *mut phper::sys::zend_class_entry | ||
{ | ||
unsafe { #original_zend_fn() as *mut phper::sys::zend_class_entry } | ||
} | ||
|
||
pub(crate) const #const_name: unsafe extern "C" fn() -> *mut phper::sys::zend_class_entry = #new_fn_name; | ||
}; | ||
|
||
result.into() | ||
} |
Oops, something went wrong.