Skip to content

Commit 3b685a4

Browse files
authored
Reduce cfg. (#85)
1 parent 8c60c8d commit 3b685a4

File tree

5 files changed

+31
-32
lines changed

5 files changed

+31
-32
lines changed

phper-build/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ pub fn register_configures() {
2828
"cargo:rustc-cfg=phper_release_version=\"{}\"",
2929
PHP_RELEASE_VERSION
3030
);
31-
println!(
32-
"cargo:rustc-cfg=phper_php_version=\"{}.{}\"",
33-
PHP_MAJOR_VERSION, PHP_MINOR_VERSION,
34-
);
3531

3632
if PHP_DEBUG != 0 {
3733
println!("cargo:rustc-cfg=phper_debug");

phper/build.rs

-8
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,4 @@ fn main() {
2424
"PHPER not support ZTS mode now (php built with `--enable-maintainer-zts` or \
2525
`--enable-zts`)."
2626
);
27-
28-
register_version_flags();
29-
}
30-
31-
fn register_version_flags() {
32-
if PHP_VERSION_ID >= 70100 {
33-
println!("cargo:rustc-cfg=phper_version_id_gte_70100",);
34-
}
3527
}

phper/src/errors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn type_error_class<'a>() -> &'a ClassEntry {
5555
}
5656

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

435435
impl Throwable for ArgumentCountError {
436436
fn get_class(&self) -> &ClassEntry {
437-
#[cfg(phper_version_id_gte_70100)]
437+
#[cfg(not(all(phper_major_version = "7", phper_minor_version = "0")))]
438438
{
439439
argument_count_error_class()
440440
}
441441

442-
#[cfg(not(phper_version_id_gte_70100))]
442+
#[cfg(all(phper_major_version = "7", phper_minor_version = "0"))]
443443
{
444444
type_error_class()
445445
}
@@ -503,7 +503,7 @@ impl Throwable for NotImplementThrowableError {
503503
}
504504
}
505505

506-
pub struct ExceptionGuard(PhantomData<()>);
506+
pub struct ExceptionGuard(PhantomData<*mut ()>);
507507

508508
impl Default for ExceptionGuard {
509509
fn default() -> Self {

phper/src/functions.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ impl ZendFunction {
381381
#[cfg(all(
382382
phper_major_version = "7",
383383
any(
384-
phper_minor_version = "0",
385-
phper_minor_version = "1",
386384
phper_minor_version = "2",
385+
phper_minor_version = "1",
386+
phper_minor_version = "0",
387387
)
388388
))]
389389
initialized: 1,
@@ -449,7 +449,7 @@ unsafe extern "C" fn invoke(execute_data: *mut zend_execute_data, return_value:
449449
pub(crate) const fn create_zend_arg_info(
450450
name: *const c_char, _pass_by_ref: bool,
451451
) -> zend_internal_arg_info {
452-
#[cfg(any(phper_php_version = "8.1", phper_php_version = "8.0"))]
452+
#[cfg(phper_major_version = "8")]
453453
{
454454
zend_internal_arg_info {
455455
name,
@@ -461,10 +461,13 @@ pub(crate) const fn create_zend_arg_info(
461461
}
462462
}
463463

464-
#[cfg(any(
465-
phper_php_version = "7.4",
466-
phper_php_version = "7.3",
467-
phper_php_version = "7.2"
464+
#[cfg(all(
465+
phper_major_version = "7",
466+
any(
467+
phper_minor_version = "4",
468+
phper_minor_version = "3",
469+
phper_minor_version = "2",
470+
)
468471
))]
469472
{
470473
#[allow(clippy::unnecessary_cast)]
@@ -476,7 +479,10 @@ pub(crate) const fn create_zend_arg_info(
476479
}
477480
}
478481

479-
#[cfg(any(phper_php_version = "7.1", phper_php_version = "7.0"))]
482+
#[cfg(all(
483+
phper_major_version = "7",
484+
any(phper_minor_version = "1", phper_minor_version = "0")
485+
))]
480486
{
481487
zend_internal_arg_info {
482488
name,

phper/src/ini.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,21 @@ impl IniEntity {
141141

142142
fn create_ini_entry_ex(name: &str, default_value: &str, modifiable: u32) -> zend_ini_entry_def {
143143
#[cfg(any(
144-
phper_php_version = "8.1",
145-
phper_php_version = "8.0",
146-
phper_php_version = "7.4",
147-
phper_php_version = "7.3",
144+
phper_major_version = "8",
145+
all(
146+
phper_major_version = "7",
147+
any(phper_minor_version = "4", phper_minor_version = "3")
148+
)
148149
))]
149150
let (modifiable, name_length) = (modifiable as std::os::raw::c_uchar, name.len() as u16);
150-
#[cfg(any(
151-
phper_php_version = "7.2",
152-
phper_php_version = "7.1",
153-
phper_php_version = "7.0",
151+
152+
#[cfg(all(
153+
phper_major_version = "7",
154+
any(
155+
phper_minor_version = "2",
156+
phper_minor_version = "1",
157+
phper_minor_version = "0",
158+
)
154159
))]
155160
let (modifiable, name_length) = (modifiable as std::os::raw::c_int, name.len() as u32);
156161

0 commit comments

Comments
 (0)