Skip to content

Reduce cfg. #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions phper-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ pub fn register_configures() {
"cargo:rustc-cfg=phper_release_version=\"{}\"",
PHP_RELEASE_VERSION
);
println!(
"cargo:rustc-cfg=phper_php_version=\"{}.{}\"",
PHP_MAJOR_VERSION, PHP_MINOR_VERSION,
);

if PHP_DEBUG != 0 {
println!("cargo:rustc-cfg=phper_debug");
Expand Down
8 changes: 0 additions & 8 deletions phper/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,4 @@ fn main() {
"PHPER not support ZTS mode now (php built with `--enable-maintainer-zts` or \
`--enable-zts`)."
);

register_version_flags();
}

fn register_version_flags() {
if PHP_VERSION_ID >= 70100 {
println!("cargo:rustc-cfg=phper_version_id_gte_70100",);
}
}
8 changes: 4 additions & 4 deletions phper/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn type_error_class<'a>() -> &'a ClassEntry {
}

/// Predefined class `ArgumentCountError` (>= PHP 7.1.0).
#[cfg(phper_version_id_gte_70100)]
#[cfg(not(all(phper_major_version = "7", phper_minor_version = "0")))]
#[inline]
pub fn argument_count_error_class<'a>() -> &'a ClassEntry {
unsafe { ClassEntry::from_ptr(zend_ce_argument_count_error) }
Expand Down Expand Up @@ -434,12 +434,12 @@ pub struct ArgumentCountError {

impl Throwable for ArgumentCountError {
fn get_class(&self) -> &ClassEntry {
#[cfg(phper_version_id_gte_70100)]
#[cfg(not(all(phper_major_version = "7", phper_minor_version = "0")))]
{
argument_count_error_class()
}

#[cfg(not(phper_version_id_gte_70100))]
#[cfg(all(phper_major_version = "7", phper_minor_version = "0"))]
{
type_error_class()
}
Expand Down Expand Up @@ -503,7 +503,7 @@ impl Throwable for NotImplementThrowableError {
}
}

pub struct ExceptionGuard(PhantomData<()>);
pub struct ExceptionGuard(PhantomData<*mut ()>);

impl Default for ExceptionGuard {
fn default() -> Self {
Expand Down
22 changes: 14 additions & 8 deletions phper/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ impl ZendFunction {
#[cfg(all(
phper_major_version = "7",
any(
phper_minor_version = "0",
phper_minor_version = "1",
phper_minor_version = "2",
phper_minor_version = "1",
phper_minor_version = "0",
)
))]
initialized: 1,
Expand Down Expand Up @@ -449,7 +449,7 @@ unsafe extern "C" fn invoke(execute_data: *mut zend_execute_data, return_value:
pub(crate) const fn create_zend_arg_info(
name: *const c_char, _pass_by_ref: bool,
) -> zend_internal_arg_info {
#[cfg(any(phper_php_version = "8.1", phper_php_version = "8.0"))]
#[cfg(phper_major_version = "8")]
{
zend_internal_arg_info {
name,
Expand All @@ -461,10 +461,13 @@ pub(crate) const fn create_zend_arg_info(
}
}

#[cfg(any(
phper_php_version = "7.4",
phper_php_version = "7.3",
phper_php_version = "7.2"
#[cfg(all(
phper_major_version = "7",
any(
phper_minor_version = "4",
phper_minor_version = "3",
phper_minor_version = "2",
)
))]
{
#[allow(clippy::unnecessary_cast)]
Expand All @@ -476,7 +479,10 @@ pub(crate) const fn create_zend_arg_info(
}
}

#[cfg(any(phper_php_version = "7.1", phper_php_version = "7.0"))]
#[cfg(all(
phper_major_version = "7",
any(phper_minor_version = "1", phper_minor_version = "0")
))]
{
zend_internal_arg_info {
name,
Expand Down
21 changes: 13 additions & 8 deletions phper/src/ini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,21 @@ impl IniEntity {

fn create_ini_entry_ex(name: &str, default_value: &str, modifiable: u32) -> zend_ini_entry_def {
#[cfg(any(
phper_php_version = "8.1",
phper_php_version = "8.0",
phper_php_version = "7.4",
phper_php_version = "7.3",
phper_major_version = "8",
all(
phper_major_version = "7",
any(phper_minor_version = "4", phper_minor_version = "3")
)
))]
let (modifiable, name_length) = (modifiable as std::os::raw::c_uchar, name.len() as u16);
#[cfg(any(
phper_php_version = "7.2",
phper_php_version = "7.1",
phper_php_version = "7.0",

#[cfg(all(
phper_major_version = "7",
any(
phper_minor_version = "2",
phper_minor_version = "1",
phper_minor_version = "0",
)
))]
let (modifiable, name_length) = (modifiable as std::os::raw::c_int, name.len() as u32);

Expand Down