diff --git a/Cargo.toml b/Cargo.toml index 62b360359..d627a927c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ autotests = false bitflags = "2" parking_lot = { version = "0.12", features = ["arc_lock"] } cfg-if = "1.0" -once_cell = "1.17" +once_cell = "1.21" anyhow = { version = "1", optional = true } ext-php-rs-derive = { version = "=0.11.2", path = "./crates/macros" } @@ -28,8 +28,8 @@ skeptic = "0.13" [build-dependencies] anyhow = "1" -bindgen = "0.70" -cc = "1.0" +bindgen = "0.72" +cc = "1.2" skeptic = "0.13" [target.'cfg(windows)'.build-dependencies] diff --git a/build.rs b/build.rs index e0c6dc1e0..773c4c363 100644 --- a/build.rs +++ b/build.rs @@ -234,7 +234,7 @@ fn generate_bindings(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result &'static ClassEntry`. -/// - `#[php(implements(ce = ce_fn, stub = "InterfaceName"))]` - Implements the -/// given interface on the class. Can be used multiple times. `ce_fn` must be -/// a valid function with the signature `fn() -> &'static ClassEntry`. -/// -/// You may also use the `#[php(prop)]` attribute on a struct field to use the -/// field as a PHP property. By default, the field will be accessible from PHP -/// publicly with the same name as the field. Property types must implement -/// `IntoZval` and `FromZval`. +/// - `#[php(extends(ce = ce_fn, stub = "ParentClass"))]` - Sets the parent class of the class. Can only be used once. +/// `ce_fn` must be a function with the signature `fn() -> &'static ClassEntry`. +/// - `#[php(implements(ce = ce_fn, stub = "InterfaceName"))]` - Implements the given interface on the class. Can be used +/// multiple times. `ce_fn` must be a valid function with the signature +/// `fn() -> &'static ClassEntry`. +/// +/// You may also use the `#[php(prop)]` attribute on a struct field to use the field as a +/// PHP property. By default, the field will be accessible from PHP publicly with +/// the same name as the field. Property types must implement `IntoZval` and +/// `FromZval`. /// /// You can rename the property with options: /// -/// - `name` - Allows you to rename the property, e.g. `#[php(name = -/// "new_name")]` +/// - `name` - Allows you to rename the property, e.g. +/// `#[php(name = "new_name")]` /// - `change_case` - Allows you to rename the property using rename rules, e.g. /// `#[php(change_case = PascalCase)]` /// @@ -58,19 +56,17 @@ extern crate proc_macro; /// /// ### No lifetime parameters /// -/// Rust lifetimes are used by the Rust compiler to reason about a program's -/// memory safety. They are a compile-time only concept; -/// there is no way to access Rust lifetimes at runtime from a dynamic language -/// like PHP. +/// Rust lifetimes are used by the Rust compiler to reason about a program's memory safety. +/// They are a compile-time only concept; +/// there is no way to access Rust lifetimes at runtime from a dynamic language like PHP. /// /// As soon as Rust data is exposed to PHP, -/// there is no guarantee which the Rust compiler can make on how long the data -/// will live. PHP is a reference-counted language and those references can be -/// held for an arbitrarily long time, which is untraceable by the Rust -/// compiler. The only possible way to express this correctly is to require that -/// any `#[php_class]` does not borrow data for any lifetime shorter than the -/// `'static` lifetime, i.e. the `#[php_class]` cannot have any lifetime -/// parameters. +/// there is no guarantee which the Rust compiler can make on how long the data will live. +/// PHP is a reference-counted language and those references can be held +/// for an arbitrarily long time, which is untraceable by the Rust compiler. +/// The only possible way to express this correctly is to require that any `#[php_class]` +/// does not borrow data for any lifetime shorter than the `'static` lifetime, +/// i.e. the `#[php_class]` cannot have any lifetime parameters. /// /// When you need to share ownership of data between PHP and Rust, /// instead of using borrowed references with lifetimes, consider using @@ -78,12 +74,11 @@ extern crate proc_macro; /// /// ### No generic parameters /// -/// A Rust struct `Foo` with a generic parameter `T` generates new compiled -/// implementations each time it is used with a different concrete type for `T`. +/// A Rust struct `Foo` with a generic parameter `T` generates new compiled implementations +/// each time it is used with a different concrete type for `T`. /// These new implementations are generated by the compiler at each usage site. /// This is incompatible with wrapping `Foo` in PHP, -/// where there needs to be a single compiled implementation of `Foo` which is -/// integrated with the PHP interpreter. +/// where there needs to be a single compiled implementation of `Foo` which is integrated with the PHP interpreter. /// /// ## Example /// @@ -109,8 +104,8 @@ extern crate proc_macro; /// # fn main() {} /// ``` /// -/// Create a custom exception `RedisException`, which extends `Exception`, and -/// put it in the `Redis\Exception` namespace: +/// Create a custom exception `RedisException`, which extends `Exception`, and put +/// it in the `Redis\Exception` namespace: /// /// ```rust,no_run,ignore /// # #![cfg_attr(windows, feature(abi_vectorcall))] @@ -144,8 +139,8 @@ extern crate proc_macro; /// /// ## Implementing an Interface /// -/// To implement an interface, use `#[php(implements(ce = ce_fn, stub = -/// "InterfaceName")]` where `ce_fn` is an function returning a `ClassEntry`. The following example implements [`ArrayAccess`](https://www.php.net/manual/en/class.arrayaccess.php): +/// To implement an interface, use `#[php(implements(ce = ce_fn, stub = "InterfaceName")]` where `ce_fn` is an function returning a `ClassEntry`. +/// The following example implements [`ArrayAccess`](https://www.php.net/manual/en/class.arrayaccess.php): /// /// ````rust,no_run,ignore /// # #![cfg_attr(windows, feature(abi_vectorcall))] @@ -219,27 +214,23 @@ fn php_class_internal(args: TokenStream2, input: TokenStream2) -> TokenStream2 { // BEGIN DOCS FROM enum.md /// # `#[php_enum]` Attribute /// -/// Enums can be exported to PHP as enums with the `#[php_enum]` attribute -/// macro. This attribute derives the `RegisteredClass` and `PhpEnum` traits on -/// your enum. To register the enum use the `enumeration::()` method -/// on the `ModuleBuilder` in the `#[php_module]` macro. +/// Enums can be exported to PHP as enums with the `#[php_enum]` attribute macro. +/// This attribute derives the `RegisteredClass` and `PhpEnum` traits on your enum. +/// To register the enum use the `enumeration::()` method on the `ModuleBuilder` +/// in the `#[php_module]` macro. /// /// ## Options /// /// The `#[php_enum]` attribute can be configured with the following options: -/// - `#[php(name = "EnumName")]` or `#[php(change_case = snake_case)]`: Sets -/// the name of the enum in PHP. The default is the `PascalCase` name of the -/// enum. -/// - `#[php(allow_native_discriminants)]`: Allows the use of native Rust -/// discriminants (e.g., `Hearts = 1`). +/// - `#[php(name = "EnumName")]` or `#[php(change_case = snake_case)]`: Sets the name of the enum in PHP. +/// The default is the `PascalCase` name of the enum. +/// - `#[php(allow_native_discriminants)]`: Allows the use of native Rust discriminants (e.g., `Hearts = 1`). /// /// The cases of the enum can be configured with the following options: -/// - `#[php(name = "CaseName")]` or `#[php(change_case = snake_case)]`: Sets -/// the name of the enum case in PHP. The default is the `PascalCase` name of -/// the case. -/// - `#[php(value = "value")]` or `#[php(value = 123)]`: Sets the discriminant -/// value for the enum case. This can be a string or an integer. If not set, -/// the case will be exported as a simple enum case without a discriminant. +/// - `#[php(name = "CaseName")]` or `#[php(change_case = snake_case)]`: Sets the name of the enum case in PHP. +/// The default is the `PascalCase` name of the case. +/// - `#[php(value = "value")]` or `#[php(value = 123)]`: Sets the discriminant value for the enum case. +/// This can be a string or an integer. If not set, the case will be exported as a simple enum case without a discriminant. /// /// ### Example /// @@ -266,12 +257,10 @@ fn php_class_internal(args: TokenStream2, input: TokenStream2) -> TokenStream2 { /// ``` /// /// ## Backed Enums -/// Enums can also be backed by either `i64` or `&'static str`. Those values can -/// be set using the `#[php(value = "value")]` or `#[php(value = 123)]` -/// attributes on the enum variants. +/// Enums can also be backed by either `i64` or `&'static str`. Those values can be set using the +/// `#[php(value = "value")]` or `#[php(value = 123)]` attributes on the enum variants. /// -/// All variants must have a value of the same type, either all `i64` or all -/// `&'static str`. +/// All variants must have a value of the same type, either all `i64` or all `&'static str`. /// /// ```rust,no_run,ignore /// # #![cfg_attr(windows, feature(abi_vectorcall))] @@ -297,12 +286,10 @@ fn php_class_internal(args: TokenStream2, input: TokenStream2) -> TokenStream2 { /// ``` /// /// ### 'Native' Discriminators -/// Native rust discriminants are currently not supported and will not be -/// exported to PHP. +/// Native rust discriminants are currently not supported and will not be exported to PHP. /// -/// To avoid confusion a compiler error will be raised if you try to use a -/// native discriminant. You can ignore this error by adding the -/// `#[php(allow_native_discriminants)]` attribute to your enum. +/// To avoid confusion a compiler error will be raised if you try to use a native discriminant. +/// You can ignore this error by adding the `#[php(allow_native_discriminants)]` attribute to your enum. /// /// ```rust,no_run,ignore /// # #![cfg_attr(windows, feature(abi_vectorcall))] @@ -350,10 +337,10 @@ fn php_enum_internal(_args: TokenStream2, input: TokenStream2) -> TokenStream2 { /// /// ## Optional parameters /// -/// Optional parameters can be used by setting the Rust parameter type to a -/// variant of `Option`. The macro will then figure out which parameters are -/// optional by using the last consecutive arguments that are a variant of -/// `Option` or have a default value. +/// Optional parameters can be used by setting the Rust parameter type to a variant +/// of `Option`. The macro will then figure out which parameters are optional by +/// using the last consecutive arguments that are a variant of `Option` or have a +/// default value. /// /// ```rust,no_run,ignore /// # #![cfg_attr(windows, feature(abi_vectorcall))] @@ -378,9 +365,9 @@ fn php_enum_internal(_args: TokenStream2, input: TokenStream2) -> TokenStream2 { /// # fn main() {} /// ``` /// -/// Default parameter values can also be set for optional parameters. This is -/// done through the `#[php(defaults)]` attribute option. When an optional -/// parameter has a default, it does not need to be a variant of `Option`: +/// Default parameter values can also be set for optional parameters. This is done +/// through the `#[php(defaults)]` attribute option. When an optional parameter has a +/// default, it does not need to be a variant of `Option`: /// /// ```rust,no_run,ignore /// # #![cfg_attr(windows, feature(abi_vectorcall))] @@ -466,9 +453,9 @@ fn php_enum_internal(_args: TokenStream2, input: TokenStream2) -> TokenStream2 { /// /// ## Variadic Functions /// -/// Variadic functions can be implemented by specifying the last argument in the -/// Rust function to the type `&[&Zval]`. This is the equivalent of a PHP -/// function using the `...$args` syntax. +/// Variadic functions can be implemented by specifying the last argument in the Rust +/// function to the type `&[&Zval]`. This is the equivalent of a PHP function using +/// the `...$args` syntax. /// /// ```rust,no_run,ignore /// # #![cfg_attr(windows, feature(abi_vectorcall))] @@ -513,16 +500,16 @@ fn php_function_internal(args: TokenStream2, input: TokenStream2) -> TokenStream // BEGIN DOCS FROM constant.md /// # `#[php_const]` Attribute /// -/// Exports a Rust constant as a global PHP constant. The constant can be any -/// type that implements `IntoConst`. +/// Exports a Rust constant as a global PHP constant. The constant can be any type +/// that implements `IntoConst`. /// -/// The `wrap_constant!()` macro can be used to simplify the registration of -/// constants. It sets the name and doc comments for the constant. +/// The `wrap_constant!()` macro can be used to simplify the registration of constants. +/// It sets the name and doc comments for the constant. /// /// You can rename the const with options: /// -/// - `name` - Allows you to rename the property, e.g. `#[php(name = -/// "new_name")]` +/// - `name` - Allows you to rename the property, e.g. +/// `#[php(name = "new_name")]` /// - `change_case` - Allows you to rename the property using rename rules, e.g. /// `#[php(change_case = PascalCase)]` /// @@ -581,25 +568,25 @@ fn php_const_internal(args: TokenStream2, input: TokenStream2) -> TokenStream2 { // BEGIN DOCS FROM module.md /// # `#[php_module]` Attribute /// -/// The module macro is used to annotate the `get_module` function, which is -/// used by the PHP interpreter to retrieve information about your extension, -/// including the name, version, functions and extra initialization functions. -/// Regardless if you use this macro, your extension requires a `extern "C" fn -/// get_module()` so that PHP can get this information. +/// The module macro is used to annotate the `get_module` function, which is used by +/// the PHP interpreter to retrieve information about your extension, including the +/// name, version, functions and extra initialization functions. Regardless if you +/// use this macro, your extension requires a `extern "C" fn get_module()` so that +/// PHP can get this information. /// /// The function is renamed to `get_module` if you have used another name. The -/// function is passed an instance of `ModuleBuilder` which allows you to -/// register the following (if required): +/// function is passed an instance of `ModuleBuilder` which allows you to register +/// the following (if required): /// /// - Functions, classes, and constants /// - Extension and request startup and shutdown functions. -/// - Read more about the PHP extension lifecycle [here](https://www.phpinternalsbook.com/php7/extensions_design/php_lifecycle.html). +/// - Read more about the PHP extension lifecycle +/// [here](https://www.phpinternalsbook.com/php7/extensions_design/php_lifecycle.html). /// - PHP extension information function -/// - Used by the `phpinfo()` function to get information about your -/// extension. +/// - Used by the `phpinfo()` function to get information about your extension. /// -/// Classes and constants are not registered with PHP in the `get_module` -/// function. These are registered inside the extension startup function. +/// Classes and constants are not registered with PHP in the `get_module` function. These are +/// registered inside the extension startup function. /// /// ## Usage /// @@ -664,32 +651,28 @@ fn php_module_internal(args: TokenStream2, input: TokenStream2) -> TokenStream2 // BEGIN DOCS FROM impl.md /// # `#[php_impl]` Attribute /// -/// You can export an entire `impl` block to PHP. This exports all methods as -/// well as constants to PHP on the class that it is implemented on. This -/// requires the `#[php_class]` macro to already be used on the underlying -/// struct. Trait implementations cannot be exported to PHP. Only one `impl` -/// block can be exported per class. +/// You can export an entire `impl` block to PHP. This exports all methods as well +/// as constants to PHP on the class that it is implemented on. This requires the +/// `#[php_class]` macro to already be used on the underlying struct. Trait +/// implementations cannot be exported to PHP. Only one `impl` block can be exported +/// per class. /// -/// If you do not want a function exported to PHP, you should place it in a -/// separate `impl` block. +/// If you do not want a function exported to PHP, you should place it in a separate +/// `impl` block. /// -/// If you want to use async Rust, use `#[php_async_impl]`, instead: see [here -/// »](./async_impl.md) for more info. +/// If you want to use async Rust, use `#[php_async_impl]`, instead: see [here »](./async_impl.md) for more info. /// /// ## Options /// -/// By default all constants are renamed to `UPPER_CASE` and all methods are -/// renamed to camelCase. This can be changed by passing the -/// `change_method_case` and `change_constant_case` as `#[php]` attributes on -/// the `impl` block. The options are: +/// By default all constants are renamed to `UPPER_CASE` and all methods are renamed to +/// camelCase. This can be changed by passing the `change_method_case` and +/// `change_constant_case` as `#[php]` attributes on the `impl` block. The options are: /// -/// - `#[php(change_method_case = "snake_case")]` - Renames the method to snake -/// case. -/// - `#[php(change_constant_case = "snake_case")]` - Renames the constant to -/// snake case. +/// - `#[php(change_method_case = "snake_case")]` - Renames the method to snake case. +/// - `#[php(change_constant_case = "snake_case")]` - Renames the constant to snake case. /// -/// See the [`name` and `change_case`](./php.md#name-and-change_case) section -/// for a list of all available cases. +/// See the [`name` and `change_case`](./php.md#name-and-change_case) section for a list of all +/// available cases. /// /// ## Methods /// @@ -697,79 +680,74 @@ fn php_module_internal(args: TokenStream2, input: TokenStream2) -> TokenStream2 /// [`php_function`] macro first. The primary difference between functions and /// methods is they are bounded by their class object. /// -/// Class methods can take a `&self` or `&mut self` parameter. They cannot take -/// a consuming `self` parameter. Static methods can omit this `self` parameter. +/// Class methods can take a `&self` or `&mut self` parameter. They cannot take a +/// consuming `self` parameter. Static methods can omit this `self` parameter. /// /// To access the underlying Zend object, you can take a reference to a -/// `ZendClassObject` in place of the self parameter, where the parameter -/// must be named `self_`. This can also be used to return a reference to -/// `$this`. +/// `ZendClassObject` in place of the self parameter, where the parameter must +/// be named `self_`. This can also be used to return a reference to `$this`. /// /// The rest of the options are passed as separate attributes: /// -/// - `#[php(defaults(i = 5, b = "hello"))]` - Sets the default value for -/// parameter(s). -/// - `#[php(optional = i)]` - Sets the first optional parameter. Note that this -/// also sets the remaining parameters as optional, so all optional parameters -/// must be a variant of `Option`. -/// - `#[php(vis = "public")]`, `#[php(vis = "protected")]` and `#[php(vis = -/// "private")]` - Sets the visibility of the method. -/// - `#[php(name = "method_name")]` - Renames the PHP method to a different -/// identifier, without renaming the Rust method name. +/// - `#[php(defaults(i = 5, b = "hello"))]` - Sets the default value for parameter(s). +/// - `#[php(optional = i)]` - Sets the first optional parameter. Note that this also sets +/// the remaining parameters as optional, so all optional parameters must be a +/// variant of `Option`. +/// - `#[php(vis = "public")]`, `#[php(vis = "protected")]` and `#[php(vis = "private")]` - Sets the visibility of the +/// method. +/// - `#[php(name = "method_name")]` - Renames the PHP method to a different identifier, +/// without renaming the Rust method name. /// -/// The `#[php(defaults)]` and `#[php(optional)]` attributes operate the same as -/// the equivalent function attribute parameters. +/// The `#[php(defaults)]` and `#[php(optional)]` attributes operate the same as the +/// equivalent function attribute parameters. /// /// ### Constructors /// -/// By default, if a class does not have a constructor, it is not constructable -/// from PHP. It can only be returned from a Rust function to PHP. +/// By default, if a class does not have a constructor, it is not constructable from +/// PHP. It can only be returned from a Rust function to PHP. /// /// Constructors are Rust methods which can take any amount of parameters and -/// returns either `Self` or `Result`, where `E: Into`. -/// When the error variant of `Result` is encountered, it is thrown as an -/// exception and the class is not constructed. +/// returns either `Self` or `Result`, where `E: Into`. When +/// the error variant of `Result` is encountered, it is thrown as an exception and +/// the class is not constructed. /// /// Constructors are designated by either naming the method `__construct` or by -/// annotating a method with the `#[php(constructor)]` attribute. Note that when -/// using the attribute, the function is not exported to PHP like a regular -/// method. +/// annotating a method with the `#[php(constructor)]` attribute. Note that when using +/// the attribute, the function is not exported to PHP like a regular method. /// /// Constructors cannot use the visibility or rename attributes listed above. /// /// ## Constants /// -/// Constants are defined as regular Rust `impl` constants. Any type that -/// implements `IntoZval` can be used as a constant. Constant visibility is not -/// supported at the moment, and therefore no attributes are valid on constants. +/// Constants are defined as regular Rust `impl` constants. Any type that implements +/// `IntoZval` can be used as a constant. Constant visibility is not supported at +/// the moment, and therefore no attributes are valid on constants. /// /// ## Property getters and setters /// /// You can add properties to classes which use Rust functions as getters and/or -/// setters. This is done with the `#[php(getter)]` and `#[php(setter)]` -/// attributes. By default, the `get_` or `set_` prefix is trimmed from the -/// start of the function name, and the remainder is used as the property name. +/// setters. This is done with the `#[php(getter)]` and `#[php(setter)]` attributes. By +/// default, the `get_` or `set_` prefix is trimmed from the start of the function +/// name, and the remainder is used as the property name. /// -/// If you want to use a different name for the property, you can pass a `name` -/// or `change_case` option to the `#[php]` attribute which will change the -/// property name. +/// If you want to use a different name for the property, you can pass a `name` or +/// `change_case` option to the `#[php]` attribute which will change the property name. /// -/// Properties do not necessarily have to have both a getter and a setter, if -/// the property is immutable the setter can be omitted, and vice versa for -/// getters. +/// Properties do not necessarily have to have both a getter and a setter, if the +/// property is immutable the setter can be omitted, and vice versa for getters. /// -/// The `#[php(getter)]` and `#[php(setter)]` attributes are mutually exclusive -/// on methods. Properties cannot have multiple getters or setters, and the -/// property name cannot conflict with field properties defined on the struct. +/// The `#[php(getter)]` and `#[php(setter)]` attributes are mutually exclusive on methods. +/// Properties cannot have multiple getters or setters, and the property name cannot +/// conflict with field properties defined on the struct. /// /// As the same as field properties, method property types must implement both /// `IntoZval` and `FromZval`. /// /// ## Example /// -/// Continuing on from our `Human` example in the structs section, we will -/// define a constructor, as well as getters for the properties. We will also -/// define a constant for the maximum age of a `Human`. +/// Continuing on from our `Human` example in the structs section, we will define a +/// constructor, as well as getters for the properties. We will also define a +/// constant for the maximum age of a `Human`. /// /// ```rust,no_run,ignore /// # #![cfg_attr(windows, feature(abi_vectorcall))] @@ -941,16 +919,16 @@ fn php_extern_internal(_: TokenStream2, input: TokenStream2) -> TokenStream2 { // BEGIN DOCS FROM zval_convert.md /// # `ZvalConvert` Derive Macro /// -/// The `#[derive(ZvalConvert)]` macro derives the `FromZval` and `IntoZval` -/// traits on a struct or enum. +/// The `#[derive(ZvalConvert)]` macro derives the `FromZval` and `IntoZval` traits +/// on a struct or enum. /// /// ## Structs /// -/// When used on a struct, the `FromZendObject` and `IntoZendObject` traits are -/// also implemented, mapping fields to properties in both directions. All -/// fields on the struct must implement `FromZval` as well. Generics are allowed -/// on structs that use the derive macro, however, the implementation will add a -/// `FromZval` bound to all generics types. +/// When used on a struct, the `FromZendObject` and `IntoZendObject` traits are also +/// implemented, mapping fields to properties in both directions. All fields on the +/// struct must implement `FromZval` as well. Generics are allowed on structs that +/// use the derive macro, however, the implementation will add a `FromZval` bound to +/// all generics types. /// /// ### Examples /// @@ -1033,18 +1011,18 @@ fn php_extern_internal(_: TokenStream2, input: TokenStream2) -> TokenStream2 { /// ## Enums /// /// When used on an enum, the `FromZval` implementation will treat the enum as a -/// tagged union with a mixed datatype. This allows you to accept multiple types -/// in a parameter, for example, a string and an integer. +/// tagged union with a mixed datatype. This allows you to accept multiple types in +/// a parameter, for example, a string and an integer. /// -/// The enum variants must not have named fields, and each variant must have -/// exactly one field (the type to extract from the zval). Optionally, the enum -/// may have one default variant with no data contained, which will be used when -/// the rest of the variants could not be extracted from the zval. +/// The enum variants must not have named fields, and each variant must have exactly +/// one field (the type to extract from the zval). Optionally, the enum may have one +/// default variant with no data contained, which will be used when the rest of the +/// variants could not be extracted from the zval. /// /// The ordering of the variants in the enum is important, as the `FromZval` -/// implementation will attempt to parse the zval data in order. For example, if -/// you put a `String` variant before an integer variant, the integer would be -/// converted to a string and passed as the string variant. +/// implementation will attempt to parse the zval data in order. For example, if you +/// put a `String` variant before an integer variant, the integer would be converted +/// to a string and passed as the string variant. /// /// ### Examples /// diff --git a/docsrs_bindings.rs b/docsrs_bindings.rs index 88ef1b41d..36f49ef17 100644 --- a/docsrs_bindings.rs +++ b/docsrs_bindings.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.70.1 */ +/* automatically generated by rust-bindgen 0.72.1 */ #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -16,10 +16,7 @@ where Storage: AsRef<[u8]> + AsMut<[u8]>, { #[inline] - pub fn get_bit(&self, index: usize) -> bool { - debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; - let byte = self.storage.as_ref()[byte_index]; + fn extract_bit(byte: u8, index: usize) -> bool { let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { @@ -29,10 +26,23 @@ where byte & mask == mask } #[inline] - pub fn set_bit(&mut self, index: usize, val: bool) { + pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); let byte_index = index / 8; - let byte = &mut self.storage.as_mut()[byte_index]; + let byte = self.storage.as_ref()[byte_index]; + Self::extract_bit(byte, index) + } + #[inline] + pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool { + debug_assert!(index / 8 < core::mem::size_of::()); + let byte_index = index / 8; + let byte = unsafe { + *(core::ptr::addr_of!((*this).storage) as *const u8).offset(byte_index as isize) + }; + Self::extract_bit(byte, index) + } + #[inline] + fn change_bit(byte: u8, index: usize, val: bool) -> u8 { let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { @@ -40,12 +50,28 @@ where }; let mask = 1 << bit_index; if val { - *byte |= mask; + byte | mask } else { - *byte &= !mask; + byte & !mask } } #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + *byte = Self::change_bit(*byte, index, val); + } + #[inline] + pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) { + debug_assert!(index / 8 < core::mem::size_of::()); + let byte_index = index / 8; + let byte = unsafe { + (core::ptr::addr_of_mut!((*this).storage) as *mut u8).offset(byte_index as isize) + }; + unsafe { *byte = Self::change_bit(*byte, index, val) }; + } + #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); @@ -64,6 +90,24 @@ where val } #[inline] + pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < core::mem::size_of::()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if unsafe { Self::raw_get_bit(this, i + bit_offset) } { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); @@ -79,6 +123,22 @@ where self.set_bit(index + bit_offset, val_bit_is_set); } } + #[inline] + pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < core::mem::size_of::()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) }; + } + } } pub const ZEND_DEBUG: u32 = 1; pub const _ZEND_TYPE_NAME_BIT: u32 = 16777216; @@ -290,6 +350,28 @@ impl _IO_FILE { } } #[inline] + pub unsafe fn _flags2_raw(this: *const Self) -> ::std::os::raw::c_int { + unsafe { + ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 3usize]>>::raw_get( + ::std::ptr::addr_of!((*this)._bitfield_1), + 0usize, + 24u8, + ) as u32) + } + } + #[inline] + pub unsafe fn set__flags2_raw(this: *mut Self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 3usize]>>::raw_set( + ::std::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 24u8, + val as u64, + ) + } + } + #[inline] pub fn new_bitfield_1(_flags2: ::std::os::raw::c_int) -> __BindgenBitfieldUnit<[u8; 3usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 3usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 24u8, { @@ -499,7 +581,7 @@ pub struct _zend_reference { pub struct _zend_ast_ref { pub gc: zend_refcounted_h, } -extern "C" { +unsafe extern "C" { pub fn _emalloc( size: usize, __zend_filename: *const ::std::os::raw::c_char, @@ -508,7 +590,7 @@ extern "C" { __zend_orig_lineno: u32, ) -> *mut ::std::os::raw::c_void; } -extern "C" { +unsafe extern "C" { pub fn _efree( ptr: *mut ::std::os::raw::c_void, __zend_filename: *const ::std::os::raw::c_char, @@ -517,7 +599,7 @@ extern "C" { __zend_orig_lineno: u32, ); } -extern "C" { +unsafe extern "C" { pub fn _estrdup( s: *const ::std::os::raw::c_char, __zend_filename: *const ::std::os::raw::c_char, @@ -526,7 +608,7 @@ extern "C" { __zend_orig_lineno: u32, ) -> *mut ::std::os::raw::c_char; } -extern "C" { +unsafe extern "C" { pub fn __zend_malloc( len: usize, __zend_filename: *const ::std::os::raw::c_char, @@ -558,19 +640,19 @@ pub struct _zend_llist { } pub type zend_llist = _zend_llist; pub type zend_llist_position = *mut zend_llist_element; -extern "C" { +unsafe extern "C" { pub fn zend_llist_get_next_ex( l: *mut zend_llist, pos: *mut zend_llist_position, ) -> *mut ::std::os::raw::c_void; } -extern "C" { +unsafe extern "C" { pub fn zend_llist_get_prev_ex( l: *mut zend_llist, pos: *mut zend_llist_position, ) -> *mut ::std::os::raw::c_void; } -extern "C" { +unsafe extern "C" { pub fn gc_possible_root(ref_: *mut zend_refcounted); } #[repr(C)] @@ -587,10 +669,10 @@ pub type zend_string_init_interned_func_t = ::std::option::Option< permanent: bool, ) -> *mut zend_string, >; -extern "C" { +unsafe extern "C" { pub static mut zend_string_init_interned: zend_string_init_interned_func_t; } -extern "C" { +unsafe extern "C" { pub static mut zend_known_strings: *mut *mut zend_string; } pub const _zend_known_string_id_ZEND_STR_FILE: _zend_known_string_id = 0; @@ -672,10 +754,10 @@ pub const _zend_known_string_id_ZEND_STR_GET: _zend_known_string_id = 75; pub const _zend_known_string_id_ZEND_STR_SET: _zend_known_string_id = 76; pub const _zend_known_string_id_ZEND_STR_LAST_KNOWN: _zend_known_string_id = 77; pub type _zend_known_string_id = ::std::os::raw::c_uint; -extern "C" { +unsafe extern "C" { pub fn zend_hash_clean(ht: *mut HashTable); } -extern "C" { +unsafe extern "C" { pub fn zend_hash_str_update( ht: *mut HashTable, key: *const ::std::os::raw::c_char, @@ -683,71 +765,71 @@ extern "C" { pData: *mut zval, ) -> *mut zval; } -extern "C" { +unsafe extern "C" { pub fn zend_hash_index_update(ht: *mut HashTable, h: zend_ulong, pData: *mut zval) -> *mut zval; } -extern "C" { +unsafe extern "C" { pub fn zend_hash_next_index_insert(ht: *mut HashTable, pData: *mut zval) -> *mut zval; } -extern "C" { +unsafe extern "C" { pub fn zend_hash_str_del( ht: *mut HashTable, key: *const ::std::os::raw::c_char, len: usize, ) -> zend_result; } -extern "C" { +unsafe extern "C" { pub fn zend_hash_index_del(ht: *mut HashTable, h: zend_ulong) -> zend_result; } -extern "C" { +unsafe extern "C" { pub fn zend_hash_str_find( ht: *const HashTable, key: *const ::std::os::raw::c_char, len: usize, ) -> *mut zval; } -extern "C" { +unsafe extern "C" { pub fn zend_hash_index_find(ht: *const HashTable, h: zend_ulong) -> *mut zval; } -extern "C" { +unsafe extern "C" { pub fn zend_hash_find_known_hash(ht: *const HashTable, key: *const zend_string) -> *mut zval; } -extern "C" { +unsafe extern "C" { pub fn zend_hash_move_forward_ex(ht: *mut HashTable, pos: *mut HashPosition) -> zend_result; } -extern "C" { +unsafe extern "C" { pub fn zend_hash_move_backwards_ex(ht: *mut HashTable, pos: *mut HashPosition) -> zend_result; } -extern "C" { +unsafe extern "C" { pub fn zend_hash_get_current_key_zval_ex( ht: *const HashTable, key: *mut zval, pos: *const HashPosition, ); } -extern "C" { +unsafe extern "C" { pub fn zend_hash_get_current_key_type_ex( ht: *mut HashTable, pos: *mut HashPosition, ) -> ::std::os::raw::c_int; } -extern "C" { +unsafe extern "C" { pub fn zend_hash_get_current_data_ex(ht: *mut HashTable, pos: *mut HashPosition) -> *mut zval; } -extern "C" { +unsafe extern "C" { pub fn _zend_new_array(size: u32) -> *mut HashTable; } -extern "C" { +unsafe extern "C" { pub fn zend_array_count(ht: *mut HashTable) -> u32; } -extern "C" { +unsafe extern "C" { pub fn zend_array_dup(source: *mut HashTable) -> *mut HashTable; } -extern "C" { +unsafe extern "C" { pub fn zend_array_destroy(ht: *mut HashTable); } -extern "C" { +unsafe extern "C" { pub fn zend_hash_str_find_ptr_lc( ht: *const HashTable, str_: *const ::std::os::raw::c_char, @@ -764,7 +846,7 @@ pub struct _zend_ast { pub lineno: u32, pub child: [*mut zend_ast; 1usize], } -extern "C" { +unsafe extern "C" { pub fn zval_ptr_dtor(zval_ptr: *mut zval); } pub type zend_object_iterator = _zend_object_iterator; @@ -878,13 +960,13 @@ pub union _zend_file_handle__bindgen_ty_1 { pub stream: zend_stream, } pub type zend_file_handle = _zend_file_handle; -extern "C" { +unsafe extern "C" { pub fn zend_stream_init_filename( handle: *mut zend_file_handle, filename: *const ::std::os::raw::c_char, ); } -extern "C" { +unsafe extern "C" { pub fn zend_destroy_file_handle(file_handle: *mut zend_file_handle); } pub type zend_stat_t = stat; @@ -1093,14 +1175,14 @@ pub struct _zend_class_entry__bindgen_ty_4__bindgen_ty_2 { pub builtin_functions: *const _zend_function_entry, pub module: *mut _zend_module_entry, } -extern "C" { +unsafe extern "C" { pub fn _zend_bailout(filename: *const ::std::os::raw::c_char, lineno: u32) -> !; } -extern "C" { +unsafe extern "C" { pub static mut zend_interrupt_function: ::std::option::Option; } -extern "C" { +unsafe extern "C" { pub static mut zend_standard_class_def: *mut zend_class_entry; } pub const zend_error_handling_t_EH_NORMAL: zend_error_handling_t = 0; @@ -1279,13 +1361,13 @@ pub struct _zend_object_handlers { pub compare: zend_object_compare_t, pub get_properties_for: zend_object_get_properties_for_t, } -extern "C" { +unsafe extern "C" { pub static std_object_handlers: zend_object_handlers; } -extern "C" { +unsafe extern "C" { pub fn zend_std_get_properties(object: *mut zend_object) -> *mut HashTable; } -extern "C" { +unsafe extern "C" { pub fn zend_std_read_property( object: *mut zend_object, member: *mut zend_string, @@ -1294,7 +1376,7 @@ extern "C" { rv: *mut zval, ) -> *mut zval; } -extern "C" { +unsafe extern "C" { pub fn zend_std_write_property( object: *mut zend_object, member: *mut zend_string, @@ -1302,7 +1384,7 @@ extern "C" { cache_slot: *mut *mut ::std::os::raw::c_void, ) -> *mut zval; } -extern "C" { +unsafe extern "C" { pub fn zend_std_has_property( object: *mut zend_object, member: *mut zend_string, @@ -1324,16 +1406,16 @@ pub struct _zend_strtod_state { pub result: *mut ::std::os::raw::c_char, } pub type zend_strtod_state = _zend_strtod_state; -extern "C" { +unsafe extern "C" { pub fn zend_is_identical(op1: *const zval, op2: *const zval) -> bool; } -extern "C" { +unsafe extern "C" { pub fn instanceof_function_slow( instance_ce: *const zend_class_entry, ce: *const zend_class_entry, ) -> bool; } -extern "C" { +unsafe extern "C" { pub fn zend_is_true(op: *const zval) -> bool; } pub type zend_op = _zend_op; @@ -1626,19 +1708,19 @@ pub struct _zend_compiler_globals { pub internal_run_time_cache_size: u32, pub short_circuiting_opnums: zend_stack, } -extern "C" { +unsafe extern "C" { pub static mut compiler_globals: _zend_compiler_globals; } -extern "C" { +unsafe extern "C" { pub static mut executor_globals: zend_executor_globals; } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct zend_atomic_bool_s { - pub value: u8, + pub value: bool, } pub type zend_atomic_bool = zend_atomic_bool_s; -extern "C" { +unsafe extern "C" { pub fn zend_atomic_bool_store(obj: *mut zend_atomic_bool, desired: bool); } #[repr(C)] @@ -1650,16 +1732,16 @@ pub struct _zend_stack { pub elements: *mut ::std::os::raw::c_void, } pub type zend_stack = _zend_stack; -extern "C" { +unsafe extern "C" { pub fn zend_object_std_init(object: *mut zend_object, ce: *mut zend_class_entry); } -extern "C" { +unsafe extern "C" { pub fn zend_objects_new(ce: *mut zend_class_entry) -> *mut zend_object; } -extern "C" { +unsafe extern "C" { pub fn zend_objects_clone_members(new_object: *mut zend_object, old_object: *mut zend_object); } -extern "C" { +unsafe extern "C" { pub fn zend_object_std_dtor(object: *mut zend_object); } #[repr(C)] @@ -1671,7 +1753,7 @@ pub struct _zend_objects_store { pub free_list_head: ::std::os::raw::c_int, } pub type zend_objects_store = _zend_objects_store; -extern "C" { +unsafe extern "C" { pub fn zend_objects_store_del(object: *mut zend_object); } #[repr(C)] @@ -1800,7 +1882,7 @@ pub struct _zend_executor_globals { pub strtod_state: zend_strtod_state, pub reserved: [*mut ::std::os::raw::c_void; 6usize], } -extern "C" { +unsafe extern "C" { pub fn zend_is_auto_global(name: *mut zend_string) -> bool; } pub type zend_module_entry = _zend_module_entry; @@ -1862,14 +1944,14 @@ pub struct _zend_module_dep { pub version: *const ::std::os::raw::c_char, pub type_: ::std::os::raw::c_uchar, } -extern "C" { +unsafe extern "C" { pub fn zend_lookup_class_ex( name: *mut zend_string, lcname: *mut zend_string, flags: u32, ) -> *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub fn zend_eval_string( str_: *const ::std::os::raw::c_char, retval_ptr: *mut zval, @@ -1883,7 +1965,7 @@ pub struct _zend_vm_stack { pub end: *mut zval, pub prev: zend_vm_stack, } -extern "C" { +unsafe extern "C" { pub fn zend_fetch_function_str( name: *const ::std::os::raw::c_char, len: usize, @@ -1910,26 +1992,26 @@ pub struct _zend_fcall_info_cache { pub object: *mut zend_object, pub closure: *mut zend_object, } -extern "C" { +unsafe extern "C" { pub fn zend_register_module_ex( module: *mut zend_module_entry, module_type: ::std::os::raw::c_int, ) -> *mut zend_module_entry; } -extern "C" { +unsafe extern "C" { pub fn zend_register_internal_class_ex( class_entry: *mut zend_class_entry, parent_ce: *mut zend_class_entry, ) -> *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub fn zend_is_callable( callable: *mut zval, check_flags: u32, callable_name: *mut *mut zend_string, ) -> bool; } -extern "C" { +unsafe extern "C" { pub fn zend_declare_property( ce: *mut zend_class_entry, name: *const ::std::os::raw::c_char, @@ -1938,7 +2020,7 @@ extern "C" { access_type: ::std::os::raw::c_int, ); } -extern "C" { +unsafe extern "C" { pub fn zend_declare_class_constant( ce: *mut zend_class_entry, name: *const ::std::os::raw::c_char, @@ -1946,10 +2028,10 @@ extern "C" { value: *mut zval, ); } -extern "C" { +unsafe extern "C" { pub fn object_properties_init(object: *mut zend_object, class_type: *mut zend_class_entry); } -extern "C" { +unsafe extern "C" { pub fn _call_user_function_impl( object: *mut zval, function_name: *mut zval, @@ -1959,7 +2041,7 @@ extern "C" { named_params: *mut HashTable, ) -> zend_result; } -extern "C" { +unsafe extern "C" { pub fn zend_call_known_function( fn_: *mut zend_function, object: *mut zend_object, @@ -1970,7 +2052,7 @@ extern "C" { named_params: *mut HashTable, ); } -extern "C" { +unsafe extern "C" { pub fn zend_is_iterable(iterable: *const zval) -> bool; } pub const _zend_expected_type_Z_EXPECTED_LONG: _zend_expected_type = 0; @@ -2009,13 +2091,13 @@ pub const _zend_expected_type_Z_EXPECTED_OBJECT_OR_STRING: _zend_expected_type = pub const _zend_expected_type_Z_EXPECTED_OBJECT_OR_STRING_OR_NULL: _zend_expected_type = 33; pub const _zend_expected_type_Z_EXPECTED_LAST: _zend_expected_type = 34; pub type _zend_expected_type = ::std::os::raw::c_uint; -extern "C" { +unsafe extern "C" { pub fn zend_wrong_parameters_count_error(min_num_args: u32, max_num_args: u32); } -extern "C" { +unsafe extern "C" { pub fn php_printf(format: *const ::std::os::raw::c_char, ...) -> usize; } -extern "C" { +unsafe extern "C" { pub fn php_error_docref( docref: *const ::std::os::raw::c_char, type_: ::std::os::raw::c_int, @@ -2327,6 +2409,28 @@ impl _php_stream { } } #[inline] + pub unsafe fn is_persistent_raw(this: *const Self) -> u16 { + unsafe { + ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::std::ptr::addr_of!((*this)._bitfield_1), + 0usize, + 1u8, + ) as u16) + } + } + #[inline] + pub unsafe fn set_is_persistent_raw(this: *mut Self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::std::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 1u8, + val as u64, + ) + } + } + #[inline] pub fn in_free(&self) -> u16 { unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } } @@ -2338,6 +2442,28 @@ impl _php_stream { } } #[inline] + pub unsafe fn in_free_raw(this: *const Self) -> u16 { + unsafe { + ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::std::ptr::addr_of!((*this)._bitfield_1), + 1usize, + 2u8, + ) as u16) + } + } + #[inline] + pub unsafe fn set_in_free_raw(this: *mut Self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::std::ptr::addr_of_mut!((*this)._bitfield_1), + 1usize, + 2u8, + val as u64, + ) + } + } + #[inline] pub fn eof(&self) -> u16 { unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u16) } } @@ -2349,6 +2475,28 @@ impl _php_stream { } } #[inline] + pub unsafe fn eof_raw(this: *const Self) -> u16 { + unsafe { + ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::std::ptr::addr_of!((*this)._bitfield_1), + 3usize, + 1u8, + ) as u16) + } + } + #[inline] + pub unsafe fn set_eof_raw(this: *mut Self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::std::ptr::addr_of_mut!((*this)._bitfield_1), + 3usize, + 1u8, + val as u64, + ) + } + } + #[inline] pub fn __exposed(&self) -> u16 { unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u16) } } @@ -2360,6 +2508,28 @@ impl _php_stream { } } #[inline] + pub unsafe fn __exposed_raw(this: *const Self) -> u16 { + unsafe { + ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::std::ptr::addr_of!((*this)._bitfield_1), + 4usize, + 1u8, + ) as u16) + } + } + #[inline] + pub unsafe fn set___exposed_raw(this: *mut Self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::std::ptr::addr_of_mut!((*this)._bitfield_1), + 4usize, + 1u8, + val as u64, + ) + } + } + #[inline] pub fn fclose_stdiocast(&self) -> u16 { unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 2u8) as u16) } } @@ -2371,6 +2541,28 @@ impl _php_stream { } } #[inline] + pub unsafe fn fclose_stdiocast_raw(this: *const Self) -> u16 { + unsafe { + ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::std::ptr::addr_of!((*this)._bitfield_1), + 5usize, + 2u8, + ) as u16) + } + } + #[inline] + pub unsafe fn set_fclose_stdiocast_raw(this: *mut Self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::std::ptr::addr_of_mut!((*this)._bitfield_1), + 5usize, + 2u8, + val as u64, + ) + } + } + #[inline] pub fn has_buffered_data(&self) -> u16 { unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u16) } } @@ -2382,6 +2574,28 @@ impl _php_stream { } } #[inline] + pub unsafe fn has_buffered_data_raw(this: *const Self) -> u16 { + unsafe { + ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::std::ptr::addr_of!((*this)._bitfield_1), + 7usize, + 1u8, + ) as u16) + } + } + #[inline] + pub unsafe fn set_has_buffered_data_raw(this: *mut Self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::std::ptr::addr_of_mut!((*this)._bitfield_1), + 7usize, + 1u8, + val as u64, + ) + } + } + #[inline] pub fn fclose_stdiocast_flush_in_progress(&self) -> u16 { unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u16) } } @@ -2393,6 +2607,28 @@ impl _php_stream { } } #[inline] + pub unsafe fn fclose_stdiocast_flush_in_progress_raw(this: *const Self) -> u16 { + unsafe { + ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::std::ptr::addr_of!((*this)._bitfield_1), + 8usize, + 1u8, + ) as u16) + } + } + #[inline] + pub unsafe fn set_fclose_stdiocast_flush_in_progress_raw(this: *mut Self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::std::ptr::addr_of_mut!((*this)._bitfield_1), + 8usize, + 1u8, + val as u64, + ) + } + } + #[inline] pub fn fatal_error(&self) -> u16 { unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u16) } } @@ -2404,6 +2640,28 @@ impl _php_stream { } } #[inline] + pub unsafe fn fatal_error_raw(this: *const Self) -> u16 { + unsafe { + ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::std::ptr::addr_of!((*this)._bitfield_1), + 9usize, + 1u8, + ) as u16) + } + } + #[inline] + pub unsafe fn set_fatal_error_raw(this: *mut Self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::std::ptr::addr_of_mut!((*this)._bitfield_1), + 9usize, + 1u8, + val as u64, + ) + } + } + #[inline] pub fn new_bitfield_1( is_persistent: u16, in_free: u16, @@ -2451,30 +2709,30 @@ impl _php_stream { __bindgen_bitfield_unit } } -extern "C" { +unsafe extern "C" { pub static mut php_stream_stdio_ops: php_stream_ops; } -extern "C" { +unsafe extern "C" { pub fn php_register_url_stream_wrapper( protocol: *const ::std::os::raw::c_char, wrapper: *const php_stream_wrapper, ) -> zend_result; } -extern "C" { +unsafe extern "C" { pub fn php_unregister_url_stream_wrapper( protocol: *const ::std::os::raw::c_char, ) -> zend_result; } -extern "C" { +unsafe extern "C" { pub fn php_register_url_stream_wrapper_volatile( protocol: *mut zend_string, wrapper: *mut php_stream_wrapper, ) -> zend_result; } -extern "C" { +unsafe extern "C" { pub fn php_unregister_url_stream_wrapper_volatile(protocol: *mut zend_string) -> zend_result; } -extern "C" { +unsafe extern "C" { pub fn php_stream_locate_url_wrapper( path: *const ::std::os::raw::c_char, path_for_open: *mut *const ::std::os::raw::c_char, @@ -2562,7 +2820,7 @@ pub struct _php_core_globals { pub syslog_filter: zend_long, pub error_log_mode: zend_long, } -extern "C" { +unsafe extern "C" { pub static mut core_globals: _php_core_globals; } #[repr(C)] @@ -2625,7 +2883,7 @@ pub struct _zend_ini_entry { pub orig_modifiable: u8, pub modified: u8, } -extern "C" { +unsafe extern "C" { pub fn zend_register_ini_entries( ini_entry: *const zend_ini_entry_def, module_number: ::std::os::raw::c_int, @@ -2646,7 +2904,7 @@ pub struct _zend_ini_parser_param { pub ini_parser_cb: zend_ini_parser_cb_t, pub arg: *mut ::std::os::raw::c_void, } -extern "C" { +unsafe extern "C" { pub fn zend_register_bool_constant( name: *const ::std::os::raw::c_char, name_len: usize, @@ -2655,7 +2913,7 @@ extern "C" { module_number: ::std::os::raw::c_int, ); } -extern "C" { +unsafe extern "C" { pub fn zend_register_long_constant( name: *const ::std::os::raw::c_char, name_len: usize, @@ -2664,7 +2922,7 @@ extern "C" { module_number: ::std::os::raw::c_int, ); } -extern "C" { +unsafe extern "C" { pub fn zend_register_double_constant( name: *const ::std::os::raw::c_char, name_len: usize, @@ -2673,7 +2931,7 @@ extern "C" { module_number: ::std::os::raw::c_int, ); } -extern "C" { +unsafe extern "C" { pub fn zend_register_string_constant( name: *const ::std::os::raw::c_char, name_len: usize, @@ -2682,16 +2940,16 @@ extern "C" { module_number: ::std::os::raw::c_int, ); } -extern "C" { +unsafe extern "C" { pub fn php_info_print_table_header(num_cols: ::std::os::raw::c_int, ...); } -extern "C" { +unsafe extern "C" { pub fn php_info_print_table_row(num_cols: ::std::os::raw::c_int, ...); } -extern "C" { +unsafe extern "C" { pub fn php_info_print_table_start(); } -extern "C" { +unsafe extern "C" { pub fn php_info_print_table_end(); } #[repr(C)] @@ -2722,10 +2980,10 @@ pub struct php_file_globals { pub tmp_host_buf: *mut ::std::os::raw::c_char, pub tmp_host_buf_len: usize, } -extern "C" { +unsafe extern "C" { pub static mut file_globals: php_file_globals; } -extern "C" { +unsafe extern "C" { pub fn zend_enum_new( result: *mut zval, ce: *mut zend_class_entry, @@ -2733,60 +2991,60 @@ extern "C" { backing_value_zv: *mut zval, ) -> *mut zend_object; } -extern "C" { +unsafe extern "C" { pub fn zend_register_internal_enum( name: *const ::std::os::raw::c_char, type_: u8, functions: *const zend_function_entry, ) -> *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub fn zend_enum_add_case( ce: *mut zend_class_entry, case_name: *mut zend_string, value: *mut zval, ); } -extern "C" { +unsafe extern "C" { pub fn zend_enum_get_case( ce: *mut zend_class_entry, name: *mut zend_string, ) -> *mut zend_object; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_throwable: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_exception: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_error_exception: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_compile_error: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_parse_error: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_type_error: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_argument_count_error: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_value_error: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_arithmetic_error: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_division_by_zero_error: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_unhandled_match_error: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub fn zend_throw_exception_ex( exception_ce: *mut zend_class_entry, code: zend_long, @@ -2794,31 +3052,31 @@ extern "C" { ... ) -> *mut zend_object; } -extern "C" { +unsafe extern "C" { pub fn zend_throw_exception_object(exception: *mut zval); } -extern "C" { +unsafe extern "C" { pub fn zend_do_implement_interface(ce: *mut zend_class_entry, iface: *mut zend_class_entry); } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_traversable: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_aggregate: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_iterator: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_arrayaccess: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_serializable: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_countable: *mut zend_class_entry; } -extern "C" { +unsafe extern "C" { pub static mut zend_ce_stringable: *mut zend_class_entry; } #[repr(C)] @@ -2838,7 +3096,7 @@ pub struct sapi_headers_struct { } pub type sapi_post_entry = _sapi_post_entry; pub type sapi_module_struct = _sapi_module_struct; -extern "C" { +unsafe extern "C" { pub static mut sapi_module: sapi_module_struct; } #[repr(C)] @@ -2901,13 +3159,13 @@ pub struct _sapi_globals_struct { pub request_parse_body_context: sapi_request_parse_body_context, } pub type sapi_globals_struct = _sapi_globals_struct; -extern "C" { +unsafe extern "C" { pub static mut sapi_globals: sapi_globals_struct; } -extern "C" { +unsafe extern "C" { pub fn sapi_startup(sf: *mut sapi_module_struct); } -extern "C" { +unsafe extern "C" { pub fn sapi_shutdown(); } pub const sapi_header_op_enum_SAPI_HEADER_REPLACE: sapi_header_op_enum = 0; @@ -3028,17 +3286,17 @@ pub struct _sapi_post_entry { ), >, } -extern "C" { +unsafe extern "C" { pub fn php_default_post_reader(); } -extern "C" { +unsafe extern "C" { pub fn php_default_treat_data( arg: ::std::os::raw::c_int, str_: *mut ::std::os::raw::c_char, destArray: *mut zval, ); } -extern "C" { +unsafe extern "C" { pub fn php_default_input_filter( arg: ::std::os::raw::c_int, var: *const ::std::os::raw::c_char, diff --git a/windows_build.rs b/windows_build.rs index 03b8314c8..72a64cd61 100644 --- a/windows_build.rs +++ b/windows_build.rs @@ -67,10 +67,16 @@ impl<'a> PHPProvider<'a> for Provider<'a> { // For some reason some symbols don't link without a `#[link(name = "php8")]` // attribute on each extern block. Bindgen doesn't give us the option to add // this so we need to add it manually. + // + // Note: bindgen 0.72+ generates `unsafe extern` blocks when using nightly Rust, + // so we need to handle both `extern` and `unsafe extern` variants. let php_lib_name = self.get_php_lib_name()?; for line in bindings.lines() { match line { - "extern \"C\" {" | "extern \"fastcall\" {" => { + "extern \"C\" {" + | "extern \"fastcall\" {" + | "unsafe extern \"C\" {" + | "unsafe extern \"fastcall\" {" => { writeln!(writer, "#[link(name = \"{}\")]", php_lib_name)?; } _ => {}