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) {
135
135
}
136
136
137
137
void * phper_zend_object_alloc (size_t obj_size , zend_class_entry * ce ) {
138
+ #if PHP_VERSION_ID >= 70300
138
139
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 ;
139
149
}
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);
48
48
49
49
void * phper_zend_object_alloc (size_t obj_size , zend_class_entry * ce );
50
50
51
+ zend_object * (* * phper_get_create_object (zend_class_entry * ce ))(zend_class_entry * class_type );
52
+
51
53
#endif //PHPER_PHP_WRAPPER_H
Original file line number Diff line number Diff line change @@ -186,14 +186,11 @@ impl<T: 'static> ClassEntry<T> {
186
186
& mut self . inner
187
187
}
188
188
189
- pub fn create_object ( & self ) -> EBox < Object < T > > {
189
+ pub fn new_object ( & self ) -> EBox < Object < T > > {
190
190
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) ;
197
194
EBox :: from_raw ( object. cast ( ) )
198
195
}
199
196
}
@@ -249,7 +246,7 @@ impl ClassEntity {
249
246
} ;
250
247
self . entry . store ( class. cast ( ) , Ordering :: SeqCst ) ;
251
248
252
- ( * class) . inner . __bindgen_anon_2 . create_object = Some ( create_object) ;
249
+ * phper_get_create_object ( class. cast ( ) ) = Some ( create_object) ;
253
250
254
251
get_registered_class_type_map ( ) . insert ( class as usize , self . classifiable . state_type_id ( ) ) ;
255
252
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ pub struct Object<T: 'static> {
26
26
27
27
impl < T : ' static > Object < T > {
28
28
pub fn new ( class_entry : & ClassEntry < T > ) -> EBox < Self > {
29
- class_entry. create_object ( )
29
+ class_entry. new_object ( )
30
30
}
31
31
32
32
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