@@ -26,6 +26,7 @@ use crate::{
2626use phper_alloc:: ToRefOwned ;
2727use std:: {
2828 convert:: TryInto ,
29+ ffi:: { CStr , CString } ,
2930 marker:: PhantomData ,
3031 mem:: { size_of, transmute, zeroed} ,
3132 os:: raw:: c_char,
@@ -131,7 +132,7 @@ impl FunctionEntry {
131132
132133 /// Will leak memory
133134 unsafe fn entry (
134- name : & str , arguments : & [ Argument ] , handler : Rc < dyn Callable > ,
135+ name : & CStr , arguments : & [ Argument ] , handler : Rc < dyn Callable > ,
135136 visibility : Option < Visibility > , r#static : Option < bool > ,
136137 ) -> zend_function_entry {
137138 let mut infos = Vec :: new ( ) ;
@@ -173,74 +174,79 @@ impl FunctionEntry {
173174}
174175
175176pub struct FunctionEntity {
176- name : String ,
177+ name : CString ,
177178 handler : Rc < dyn Callable > ,
178179 arguments : Vec < Argument > ,
179180}
180181
181182impl FunctionEntity {
183+ #[ inline]
182184 pub ( crate ) fn new ( name : impl Into < String > , handler : Rc < dyn Callable > ) -> Self {
183- let name = ensure_end_with_zero ( name) ;
184185 FunctionEntity {
185- name,
186+ name : ensure_end_with_zero ( name ) ,
186187 handler,
187188 arguments : Default :: default ( ) ,
188189 }
189190 }
190191
192+ #[ inline]
191193 pub fn argument ( & mut self , argument : Argument ) -> & mut Self {
192194 self . arguments . push ( argument) ;
193195 self
194196 }
195197
198+ #[ inline]
196199 pub fn arguments ( & mut self , arguments : impl IntoIterator < Item = Argument > ) -> & mut Self {
197200 self . arguments . extend ( arguments) ;
198201 self
199202 }
200203}
201204
202205pub struct MethodEntity {
203- name : String ,
206+ name : CString ,
204207 handler : Rc < dyn Callable > ,
205208 arguments : Vec < Argument > ,
206209 visibility : Visibility ,
207210 r#static : bool ,
208211}
209212
210213impl MethodEntity {
214+ #[ inline]
211215 pub ( crate ) fn new (
212216 name : impl Into < String > , handler : Rc < dyn Callable > , visibility : Visibility ,
213217 ) -> Self {
214- let name = ensure_end_with_zero ( name) ;
215218 Self {
216- name,
219+ name : ensure_end_with_zero ( name ) ,
217220 handler,
218221 visibility,
219222 arguments : Default :: default ( ) ,
220223 r#static : false ,
221224 }
222225 }
223226
227+ #[ inline]
224228 pub ( crate ) fn r#static ( & mut self , s : bool ) -> & mut Self {
225229 self . r#static = s;
226230 self
227231 }
228232
233+ #[ inline]
229234 pub fn argument ( & mut self , argument : Argument ) -> & mut Self {
230235 self . arguments . push ( argument) ;
231236 self
232237 }
233238
239+ #[ inline]
234240 pub fn arguments ( & mut self , arguments : impl IntoIterator < Item = Argument > ) -> & mut Self {
235241 self . arguments . extend ( arguments) ;
236242 self
237243 }
238244}
239245
240246pub struct Argument {
241- pub ( crate ) name : String ,
242- pub ( crate ) pass_by_ref : bool ,
243- pub ( crate ) required : bool ,
247+ name : CString ,
248+ pass_by_ref : bool ,
249+ required : bool ,
244250}
245251
246252impl Argument {
0 commit comments