Skip to content

Commit eb34538

Browse files
committed
Add enum
1 parent 1598925 commit eb34538

File tree

8 files changed

+441
-11
lines changed

8 files changed

+441
-11
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phper-build/src/lib.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,36 @@ pub fn register_all() {
2424
pub fn register_configures() {
2525
// versions
2626
println!(
27-
"cargo:rustc-cfg=phper_major_version=\"{}\"",
27+
"cargo::rustc-cfg=phper_major_version=\"{}\"",
2828
PHP_MAJOR_VERSION
2929
);
3030
println!(
31-
"cargo:rustc-cfg=phper_minor_version=\"{}\"",
31+
"cargo::rustc-cfg=phper_minor_version=\"{}\"",
3232
PHP_MINOR_VERSION
3333
);
3434
println!(
35-
"cargo:rustc-cfg=phper_release_version=\"{}\"",
35+
"cargo::rustc-cfg=phper_release_version=\"{}\"",
3636
PHP_RELEASE_VERSION
3737
);
3838

3939
if PHP_DEBUG != 0 {
40-
println!("cargo:rustc-cfg=phper_debug");
40+
println!("cargo::rustc-cfg=phper_debug");
4141
}
4242

4343
if USING_ZTS != 0 {
44-
println!("cargo:rustc-cfg=phper_zts");
44+
println!("cargo::rustc-cfg=phper_zts");
45+
}
46+
47+
if PHP_VERSION_ID >= 80100 {
48+
println!("cargo::rustc-cfg=phper_enum_supported");
4549
}
4650
}
4751

4852
/// Register link arguments for os-specified situation.
4953
pub fn register_link_args() {
5054
#[cfg(target_os = "macos")]
5155
{
52-
println!("cargo:rustc-link-arg=-undefined");
53-
println!("cargo:rustc-link-arg=dynamic_lookup");
56+
println!("cargo::rustc-link-arg=-undefined");
57+
println!("cargo::rustc-link-arg=dynamic_lookup");
5458
}
5559
}

phper-sys/php_wrapper.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include <zend_observer.h>
2323
#endif
2424

25+
#if PHP_VERSION_ID >= 80100
26+
#include <zend_enum.h>
27+
#endif
28+
2529
typedef ZEND_INI_MH(phper_zend_ini_mh);
2630

2731
typedef zend_class_entry *

phper/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ indexmap = "2.7.1"
2828
phper-alloc = { workspace = true }
2929
phper-macros = { workspace = true }
3030
phper-sys = { workspace = true }
31+
sealed = "0.6.0"
3132
thiserror = "2.0.11"
3233

3334
[build-dependencies]
@@ -44,4 +45,9 @@ unexpected_cfgs = { level = "warn", check-cfg = [
4445
'cfg(phper_minor_version, values("3"))',
4546
'cfg(phper_minor_version, values("4"))',
4647
'cfg(phper_zts)',
48+
'cfg(phper_enum_supported)',
4749
] }
50+
51+
[package.metadata.docs.rs]
52+
rustdoc-args = ["--cfg", "docsrs"]
53+
all-features = true

phper/src/classes.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ fn find_global_class_entry_ptr(name: impl AsRef<str>) -> *mut zend_class_entry {
233233
}
234234

235235
#[derive(Clone)]
236-
enum InnerClassEntry {
236+
pub(crate) enum InnerClassEntry {
237237
Ptr(*const zend_class_entry),
238238
Name(String),
239239
}
@@ -931,7 +931,7 @@ pub struct ConstantEntity {
931931
}
932932

933933
impl ConstantEntity {
934-
fn new(name: impl Into<String>, value: impl Into<Scalar>) -> Self {
934+
pub(crate) fn new(name: impl Into<String>, value: impl Into<Scalar>) -> Self {
935935
Self {
936936
name: name.into(),
937937
value: value.into(),
@@ -1027,7 +1027,7 @@ pub enum Visibility {
10271027
pub(crate) type RawVisibility = u32;
10281028

10291029
#[allow(clippy::useless_conversion)]
1030-
unsafe extern "C" fn create_object(ce: *mut zend_class_entry) -> *mut zend_object {
1030+
pub(crate) unsafe extern "C" fn create_object(ce: *mut zend_class_entry) -> *mut zend_object {
10311031
unsafe {
10321032
// Get real ce which hold state_constructor.
10331033
let real_ce = find_real_ce(ce).unwrap();
@@ -1146,7 +1146,9 @@ unsafe fn clone_object_common(object: *mut zend_object) -> *mut zend_object {
11461146
}
11471147
}
11481148

1149-
unsafe fn add_class_constant(class_ce: *mut _zend_class_entry, constant: &ConstantEntity) {
1149+
pub(crate) unsafe fn add_class_constant(
1150+
class_ce: *mut _zend_class_entry, constant: &ConstantEntity,
1151+
) {
11501152
let name_ptr = constant.name.as_ptr() as *const c_char;
11511153
let name_len = constant.name.len();
11521154
unsafe {

0 commit comments

Comments
 (0)