@@ -6,7 +6,7 @@ use phper::zend::api::{FunctionEntries, ModuleGlobals, function_entry_end};
6
6
use phper:: zend:: compile:: { InternalArgInfos , internal_arg_info_begin} ;
7
7
use phper:: zend:: ini:: { IniEntryDefs , ini_entry_def_end} ;
8
8
use phper:: zend:: modules:: { ModuleEntry , create_zend_module_entry} ;
9
- use phper:: zend:: types:: { ExecuteData , Val , SetVal , Value } ;
9
+ use phper:: zend:: types:: { ExecuteData , Val , SetVal , Value , ClassEntry } ;
10
10
use phper:: {
11
11
php_function, php_minit, php_minit_function, php_mshutdown, php_mshutdown_function,
12
12
php_rinit_function, php_rshutdown_function,
@@ -20,7 +20,7 @@ use std::ptr::{null, null_mut};
20
20
use phper:: zend:: exceptions:: MyException ;
21
21
use phper:: sys:: { php_info_print_table_start, php_info_print_table_row, php_info_print_table_end, phper_init_class_entry} ;
22
22
23
- static mut MY_CLASS_CE : * mut zend_class_entry = null_mut ( ) ;
23
+ static MY_CLASS_CE : ClassEntry = ClassEntry :: new ( ) ;
24
24
25
25
static SIMPLE_ENABLE : ModuleGlobals < bool > = ModuleGlobals :: new ( false ) ;
26
26
static SIMPLE_TEXT : ModuleGlobals < * const c_char > = ModuleGlobals :: new ( null ( ) ) ;
@@ -35,11 +35,9 @@ static INI_ENTRIES: IniEntryDefs<3> = IniEntryDefs::new([
35
35
fn m_init_simple ( type_ : c_int , module_number : c_int ) -> bool {
36
36
unsafe {
37
37
zend_register_ini_entries ( INI_ENTRIES . as_ptr ( ) , module_number) ;
38
- }
39
- unsafe {
40
- let mut my_class_ce = phper_init_class_entry ( c_str_ptr ! ( "MyClass" ) , MY_CLASS_METHODS . as_ptr ( ) ) ;
41
- MY_CLASS_CE = zend_register_internal_class ( & mut my_class_ce) ;
42
- zend_declare_property_string ( MY_CLASS_CE , c_str_ptr ! ( "foo" ) , 3 , c_str_ptr ! ( "bar" ) , ZEND_ACC_PUBLIC as c_int ) ;
38
+
39
+ MY_CLASS_CE . init ( c_str_ptr ! ( "MyClass" ) , & MY_CLASS_METHODS ) ;
40
+ MY_CLASS_CE . declare_property ( "foo" , 3 , ZEND_ACC_PUBLIC ) ;
43
41
}
44
42
true
45
43
}
@@ -66,8 +64,8 @@ fn r_shutdown_simple(type_: c_int, module_number: c_int) -> bool {
66
64
fn m_info_simple ( zend_module : * mut :: phper:: sys:: zend_module_entry ) {
67
65
unsafe {
68
66
php_info_print_table_start ( ) ;
69
- php_info_print_table_row ( 2 , c_str_ptr ! ( "simple.enable" ) , format ! ( "{} \0 " , * SIMPLE_ENABLE . as_ptr ( ) ) . as_ptr ( ) ) ;
70
- php_info_print_table_row ( 2 , c_str_ptr ! ( "simple.text" ) , format ! ( "{} \0 " , CStr :: from_ptr ( ( * SIMPLE_TEXT . as_ptr ( ) ) ) . to_str ( ) . unwrap ( ) ) . as_ptr ( ) ) ;
67
+ php_info_print_table_row ( 2 , if SIMPLE_ENABLE . get ( ) { c_str_ptr ! ( "1" ) } else { c_str_ptr ! ( "0" ) } ) ;
68
+ php_info_print_table_row ( 2 , c_str_ptr ! ( "simple.text" ) , SIMPLE_TEXT . as_ptr ( ) ) ;
71
69
php_info_print_table_end ( ) ;
72
70
}
73
71
}
@@ -182,14 +180,13 @@ pub fn my_class_foo(execute_data: ExecuteData) -> impl SetVal {
182
180
null_mut ( )
183
181
} ;
184
182
185
- let foo = zend_read_property ( MY_CLASS_CE , this, c_str_ptr ! ( "foo" ) , 3 , 1 , null_mut ( ) ) ;
183
+ let foo = zend_read_property ( MY_CLASS_CE . get ( ) , this, c_str_ptr ! ( "foo" ) , 3 , 1 , null_mut ( ) ) ;
186
184
let foo = Val :: from_raw ( foo) ;
187
185
let foo = foo. as_c_str ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
188
186
Some ( format ! ( "{}{}" , prefix, foo) )
189
187
}
190
188
}
191
189
192
-
193
190
static MODULE_ENTRY : ModuleEntry = ModuleEntry :: new ( create_zend_module_entry (
194
191
c_str_ptr ! ( env!( "CARGO_PKG_NAME" ) ) ,
195
192
c_str_ptr ! ( env!( "CARGO_PKG_VERSION" ) ) ,
0 commit comments