Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit16932a1

Browse files
authored
Mark bind_class and bind_interface public (#177)
1 parente90afbc commit16932a1

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

‎phper/src/classes.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ fn find_global_class_entry_ptr(name: impl AsRef<str>) -> *mut zend_class_entry {
236236
}
237237

238238
/// The [StateClass] holds [zend_class_entry] and inner state, created by
239-
/// [Module::add_class](crate::modules::Module::add_class).
239+
/// [Module::add_class](crate::modules::Module::add_class) or
240+
/// [ClassEntity::bind_class].
240241
///
241242
/// When the class registered (module initialized), the [StateClass] will
242243
/// be initialized, so you can use the [StateClass] to new stateful
@@ -690,8 +691,25 @@ impl<T: 'static> ClassEntity<T> {
690691
.collect()
691692
}
692693

694+
/// Get the bound class.
695+
///
696+
/// # Examples
697+
///
698+
/// ```
699+
/// use phper::classes::{ClassEntity, Visibility};
700+
///
701+
/// pub fn make_foo_class() -> ClassEntity<()> {
702+
/// let mut class = ClassEntity::<()>::new_with_default_state_constructor("Foo");
703+
/// let foo_class = class.bind_class();
704+
/// class.add_static_method("newInstance", Visibility::Public, move |_| {
705+
/// let mut object = foo_class.init_object()?;
706+
/// Ok::<_, phper::Error>(object)
707+
/// });
708+
/// class
709+
/// }
710+
/// ```
693711
#[inline]
694-
pub(crate)fnbind_class(&self) ->StateClass<T>{
712+
pubfnbind_class(&self) ->StateClass<T>{
695713
self.bind_class.clone()
696714
}
697715
}
@@ -798,8 +816,9 @@ impl InterfaceEntity {
798816
Box::into_raw(methods.into_boxed_slice()).cast()
799817
}
800818

819+
/// Get the bound interface.
801820
#[inline]
802-
pub(crate)fnbind_interface(&self) ->Interface{
821+
pubfnbind_interface(&self) ->Interface{
803822
self.bind_interface.clone()
804823
}
805824
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp