29
29
#include "ext/standard/php_incomplete_class.h"
30
30
31
31
32
- static int le_sdl = 0 ;
33
32
static int le_typemap = 0 ;
34
33
35
34
typedef struct _soapHeader {
@@ -128,15 +127,13 @@ static void soap_error_handler(int error_num, zend_string *error_filename, const
128
127
#define FETCH_THIS_SDL (ss ) \
129
128
{ \
130
129
zval *__tmp = Z_CLIENT_SDL_P(ZEND_THIS); \
131
- if (Z_TYPE_P(__tmp) == IS_RESOURCE ) { \
132
- FETCH_SDL_RES(ss, __tmp); \
130
+ if (Z_TYPE_P(__tmp) == IS_OBJECT && instanceof_function(Z_OBJCE_P(__tmp), soap_sdl_class_entry) ) { \
131
+ ss = Z_SOAP_SDL_P( __tmp)->sdl ; \
133
132
} else { \
134
133
ss = NULL; \
135
134
} \
136
135
}
137
136
138
- #define FETCH_SDL_RES (ss ,tmp ) ss = (sdlPtr) zend_fetch_resource_ex(tmp, "sdl", le_sdl)
139
-
140
137
#define FETCH_TYPEMAP_RES (ss ,tmp ) ss = (HashTable*) zend_fetch_resource_ex(tmp, "typemap", le_typemap)
141
138
142
139
#define Z_PARAM_NAME_P (zv ) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 0))
@@ -177,9 +174,11 @@ static zend_class_entry* soap_header_class_entry;
177
174
static zend_class_entry * soap_param_class_entry ;
178
175
zend_class_entry * soap_var_class_entry ;
179
176
zend_class_entry * soap_url_class_entry ;
177
+ zend_class_entry * soap_sdl_class_entry ;
180
178
181
179
static zend_object_handlers soap_server_object_handlers ;
182
180
static zend_object_handlers soap_url_object_handlers ;
181
+ static zend_object_handlers soap_sdl_object_handlers ;
183
182
184
183
typedef struct {
185
184
soapServicePtr service ;
@@ -234,6 +233,43 @@ static zend_function *soap_url_object_get_constructor(zend_object *object)
234
233
235
234
return NULL ;
236
235
}
236
+
237
+ static inline soap_sdl_object * soap_sdl_object_fetch (zend_object * obj )
238
+ {
239
+ return (soap_sdl_object * ) ((char * ) obj - XtOffsetOf (soap_sdl_object , std ));
240
+ }
241
+
242
+ #define Z_SOAP_SDL_P (zv ) soap_sdl_object_fetch(Z_OBJ_P(zv))
243
+
244
+ static zend_object * soap_sdl_object_create (zend_class_entry * ce )
245
+ {
246
+ soap_sdl_object * sdl_obj = zend_object_alloc (sizeof (soap_sdl_object ), ce );
247
+
248
+ zend_object_std_init (& sdl_obj -> std , ce );
249
+ object_properties_init (& sdl_obj -> std , ce );
250
+
251
+ return & sdl_obj -> std ;
252
+ }
253
+
254
+ static void soap_sdl_object_free (zend_object * obj )
255
+ {
256
+ soap_sdl_object * sdl_obj = soap_sdl_object_fetch (obj );
257
+
258
+ if (sdl_obj -> sdl ) {
259
+ delete_sdl (sdl_obj -> sdl );
260
+ sdl_obj -> sdl = NULL ;
261
+ }
262
+
263
+ zend_object_std_dtor (& sdl_obj -> std );
264
+ }
265
+
266
+ static zend_function * soap_sdl_object_get_constructor (zend_object * object )
267
+ {
268
+ zend_throw_error (NULL , "Cannot directly construct Soap\\Sdl" );
269
+
270
+ return NULL ;
271
+ }
272
+
237
273
ZEND_DECLARE_MODULE_GLOBALS (soap )
238
274
239
275
static void (* old_error_handler )(int , zend_string * , const uint32_t , zend_string * );
@@ -418,11 +454,6 @@ PHP_RINIT_FUNCTION(soap)
418
454
return SUCCESS ;
419
455
}
420
456
421
- static void delete_sdl_res (zend_resource * res )
422
- {
423
- delete_sdl (res -> ptr );
424
- }
425
-
426
457
static void delete_hashtable_res (zend_resource * res )
427
458
{
428
459
delete_hashtable (res -> ptr );
@@ -458,7 +489,6 @@ PHP_MINIT_FUNCTION(soap)
458
489
459
490
soap_header_class_entry = register_class_SoapHeader ();
460
491
461
- le_sdl = zend_register_list_destructors_ex (delete_sdl_res , NULL , "SOAP SDL" , module_number );
462
492
le_typemap = zend_register_list_destructors_ex (delete_hashtable_res , NULL , "SOAP table" , module_number );
463
493
464
494
soap_url_class_entry = register_class_Soap_Url ();
@@ -472,6 +502,17 @@ PHP_MINIT_FUNCTION(soap)
472
502
soap_url_object_handlers .clone_obj = NULL ;
473
503
soap_url_object_handlers .compare = zend_objects_not_comparable ;
474
504
505
+ soap_sdl_class_entry = register_class_Soap_Sdl ();
506
+ soap_sdl_class_entry -> create_object = soap_sdl_object_create ;
507
+ soap_sdl_class_entry -> default_object_handlers = & soap_sdl_object_handlers ;
508
+
509
+ memcpy (& soap_sdl_object_handlers , & std_object_handlers , sizeof (zend_object_handlers ));
510
+ soap_sdl_object_handlers .offset = XtOffsetOf (soap_sdl_object , std );
511
+ soap_sdl_object_handlers .free_obj = soap_sdl_object_free ;
512
+ soap_sdl_object_handlers .get_constructor = soap_sdl_object_get_constructor ;
513
+ soap_sdl_object_handlers .clone_obj = NULL ;
514
+ soap_sdl_object_handlers .compare = zend_objects_not_comparable ;
515
+
475
516
register_soap_symbols (module_number );
476
517
477
518
old_error_handler = zend_error_cb ;
@@ -2086,15 +2127,20 @@ PHP_METHOD(SoapClient, __construct)
2086
2127
2087
2128
if (wsdl ) {
2088
2129
int old_soap_version ;
2089
- zend_resource * res ;
2090
2130
2091
2131
old_soap_version = SOAP_GLOBAL (soap_version );
2092
2132
SOAP_GLOBAL (soap_version ) = soap_version ;
2093
2133
2094
2134
sdl = get_sdl (this_ptr , ZSTR_VAL (wsdl ), cache_wsdl );
2095
- res = zend_register_resource (sdl , le_sdl );
2096
2135
2097
- ZVAL_RES (Z_CLIENT_SDL_P (this_ptr ), res );
2136
+ zval * sdl_zval = Z_CLIENT_SDL_P (this_ptr );
2137
+ if (Z_TYPE_P (sdl_zval ) == IS_OBJECT ) {
2138
+ zval_ptr_dtor (sdl_zval );
2139
+ }
2140
+
2141
+ object_init_ex (sdl_zval , soap_sdl_class_entry );
2142
+ soap_sdl_object * sdl_object = Z_SOAP_SDL_P (sdl_zval );
2143
+ sdl_object -> sdl = sdl ;
2098
2144
2099
2145
SOAP_GLOBAL (soap_version ) = old_soap_version ;
2100
2146
}
@@ -2227,8 +2273,11 @@ static void do_soap_call(zend_execute_data *execute_data,
2227
2273
}
2228
2274
2229
2275
tmp = Z_CLIENT_SDL_P (this_ptr );
2230
- if (Z_TYPE_P (tmp ) == IS_RESOURCE ) {
2231
- FETCH_SDL_RES (sdl ,tmp );
2276
+ if (Z_TYPE_P (tmp ) == IS_OBJECT ) {
2277
+ #ifdef ZEND_DEBUG
2278
+ ZEND_ASSERT (instanceof_function (Z_OBJCE_P (tmp ), soap_sdl_class_entry ));
2279
+ #endif
2280
+ sdl = Z_SOAP_SDL_P (tmp )-> sdl ;
2232
2281
}
2233
2282
2234
2283
tmp = Z_CLIENT_TYPEMAP_P (this_ptr );
@@ -2536,14 +2585,13 @@ PHP_METHOD(SoapClient, __soapCall)
2536
2585
/* {{{ Returns list of SOAP functions */
2537
2586
PHP_METHOD (SoapClient , __getFunctions )
2538
2587
{
2539
- sdlPtr sdl ;
2540
-
2541
- FETCH_THIS_SDL (sdl );
2542
-
2543
2588
if (zend_parse_parameters_none () == FAILURE ) {
2544
2589
RETURN_THROWS ();
2545
2590
}
2546
2591
2592
+ sdl * sdl ;
2593
+ FETCH_THIS_SDL (sdl );
2594
+
2547
2595
if (sdl ) {
2548
2596
smart_str buf = {0 };
2549
2597
sdlFunctionPtr function ;
@@ -2562,14 +2610,13 @@ PHP_METHOD(SoapClient, __getFunctions)
2562
2610
/* {{{ Returns list of SOAP types */
2563
2611
PHP_METHOD (SoapClient , __getTypes )
2564
2612
{
2565
- sdlPtr sdl ;
2566
-
2567
- FETCH_THIS_SDL (sdl );
2568
-
2569
2613
if (zend_parse_parameters_none () == FAILURE ) {
2570
2614
RETURN_THROWS ();
2571
2615
}
2572
2616
2617
+ sdl * sdl ;
2618
+ FETCH_THIS_SDL (sdl );
2619
+
2573
2620
if (sdl ) {
2574
2621
sdlTypePtr type ;
2575
2622
smart_str buf = {0 };
0 commit comments