File tree Expand file tree Collapse file tree 4 files changed +18
-9
lines changed Expand file tree Collapse file tree 4 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -135,5 +135,15 @@ size_t phper_zend_object_properties_size(zend_class_entry *ce) {
135135}
136136
137137void * phper_zend_object_alloc (size_t obj_size , zend_class_entry * ce ) {
138+ #if PHP_VERSION_ID >= 70300
138139 return zend_object_alloc (obj_size , ce );
140+ #else
141+ void * obj = emalloc (obj_size + zend_object_properties_size (ce ));
142+ memset (obj , 0 , obj_size - sizeof (zval ));
143+ return obj ;
144+ #endif
145+ }
146+
147+ zend_object * (* * phper_get_create_object (zend_class_entry * ce ))(zend_class_entry * class_type ) {
148+ return & ce -> create_object ;
139149}
Original file line number Diff line number Diff line change @@ -48,4 +48,6 @@ size_t phper_zend_object_properties_size(zend_class_entry *ce);
4848
4949void * phper_zend_object_alloc (size_t obj_size , zend_class_entry * ce );
5050
51+ zend_object * (* * phper_get_create_object (zend_class_entry * ce ))(zend_class_entry * class_type );
52+
5153#endif //PHPER_PHP_WRAPPER_H
Original file line number Diff line number Diff line change @@ -186,14 +186,11 @@ impl<T: 'static> ClassEntry<T> {
186186 & mut self . inner
187187 }
188188
189- pub fn create_object ( & self ) -> EBox < Object < T > > {
189+ pub fn new_object ( & self ) -> EBox < Object < T > > {
190190 unsafe {
191- let f = self
192- . inner
193- . __bindgen_anon_2
194- . create_object
195- . unwrap_or ( zend_objects_new) ;
196- let object = f ( self . as_ptr ( ) as * mut _ ) ;
191+ let ptr = self . as_ptr ( ) as * mut _ ;
192+ let f = ( * phper_get_create_object ( ptr) ) . unwrap_or ( zend_objects_new) ;
193+ let object = f ( ptr) ;
197194 EBox :: from_raw ( object. cast ( ) )
198195 }
199196 }
@@ -249,7 +246,7 @@ impl ClassEntity {
249246 } ;
250247 self . entry . store ( class. cast ( ) , Ordering :: SeqCst ) ;
251248
252- ( * class) . inner . __bindgen_anon_2 . create_object = Some ( create_object) ;
249+ * phper_get_create_object ( class. cast ( ) ) = Some ( create_object) ;
253250
254251 get_registered_class_type_map ( ) . insert ( class as usize , self . classifiable . state_type_id ( ) ) ;
255252
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ pub struct Object<T: 'static> {
2626
2727impl < T : ' static > Object < T > {
2828 pub fn new ( class_entry : & ClassEntry < T > ) -> EBox < Self > {
29- class_entry. create_object ( )
29+ class_entry. new_object ( )
3030 }
3131
3232 pub fn new_by_class_name ( class_name : impl AsRef < str > ) -> crate :: Result < EBox < Self > > {
You can’t perform that action at this time.
0 commit comments