cvs: pecl /bcompiler bcompiler.c

From: Date: Wed, 04 Oct 2006 08:45:28 +0000
Subject: cvs: pecl /bcompiler bcompiler.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-6454@lists.php.net to get a copy of this message
val Wed Oct 4 08:45:28 2006 UTC Modified files: /pecl/bcompiler bcompiler.c Log: fix PHP6 support

http://cvs.php.net/viewvc.cgi/pecl/bcompiler/bcompiler.c?r1=1.106&r2=1.107&diff_format=u Index: pecl/bcompiler/bcompiler.c diff -u pecl/bcompiler/bcompiler.c:1.106 pecl/bcompiler/bcompiler.c:1.107 --- pecl/bcompiler/bcompiler.c:1.106 Sat Sep 16 18:55:14 2006 +++ pecl/bcompiler/bcompiler.c Wed Oct 4 08:45:28 2006 @@ -20,7 +20,7 @@ | Mike Bretz <mike@metropolis-ag.de> | +----------------------------------------------------------------------+ */ -/* $Id: bcompiler.c,v 1.106 2006/09/16 18:55:14 nlopess Exp $ */ +/* $Id: bcompiler.c,v 1.107 2006/10/04 08:45:28 val Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -49,6 +49,12 @@ #define BUILD_WITH_ZEND #endif +#if PHP_MAJOR_VERSION >= 6 +# define ZS2S(zstr) ((zstr).s) +#else +# define ZS2S(zstr) (zstr) +#endif + /* Define the header & version */ #define BCOMPILER_VERSION "0.8" @@ -988,7 +994,7 @@ { SERIALIZE_SCALAR(BCOMPILER_CLASS_ENTRY, char) #if PHP_MAJOR_VERSION >= 6 - apc_serialize_zend_class_entry(zc, NULL, 0, pos->key.u.string, pos->key.type == IS_UNICODE ? -pos->nKeyLength : pos->nKeyLength TSRMLS_CC); + apc_serialize_zend_class_entry(zc, NULL, 0, pos->key.arKey.s, pos->key.type == IS_UNICODE ? -pos->nKeyLength : pos->nKeyLength TSRMLS_CC); #else apc_serialize_zend_class_entry(zc, NULL, 0, pos->arKey, pos->nKeyLength TSRMLS_CC); #endif @@ -1016,7 +1022,7 @@ if (zf->type == ZEND_USER_FUNCTION) { if (strcmp(zf->op_array.filename, real_path) == 0) { #if PHP_MAJOR_VERSION >= 6 - zend_u_hash_del(CG(function_table), pos->key.type, pos->key.u.string, pos->nKeyLength); + zend_u_hash_del(CG(function_table), pos->key.type, ZSTR(pos->key.arKey.s), pos->nKeyLength); #else zend_hash_del(CG(function_table), pos->arKey, pos->nKeyLength); #endif @@ -1044,7 +1050,7 @@ #endif { #if PHP_MAJOR_VERSION >= 6 - zend_u_hash_del(CG(class_table), pos->key.type, pos->key.u.string, pos->nKeyLength); + zend_u_hash_del(CG(class_table), pos->key.type, ZSTR(pos->key.arKey.s), pos->nKeyLength); #else zend_hash_del(CG(class_table), pos->arKey, pos->nKeyLength); #endif @@ -1420,11 +1426,14 @@ BCOMPILER_DEBUG(("STARTING CLASS\n")); apc_create_zend_class_entry(&zc, &key, &key_len TSRMLS_CC); if (BCOMPILERG(parsing_error)) break; - if (!key) { key = zc->name; key_len = zc->name_length+1; } + if (!key) { + key = ZS2S(zc->name); + key_len = zc->name_length+1; + } /* is it in the class table already? */ #if PHP_MAJOR_VERSION >= 6 - zend_u_hash_find(EG(class_table), BCOMPILERG(is_unicode) ? IS_UNICODE : IS_STRING, key, key_len, (void **)&ce); + zend_u_hash_find(EG(class_table), BCOMPILERG(is_unicode) ? IS_UNICODE : IS_STRING, ZSTR(key), key_len, (void **)&ce); #else zend_hash_find(EG(class_table), key, key_len, (void **)&ce); #endif @@ -1439,7 +1448,7 @@ #endif BCOMPILER_DEBUG(("ADDING %s [%c%s]\n", zc->name, *key, key_len>1 ? key+1 : "")); #if PHP_MAJOR_VERSION >= 6 - if (zend_u_hash_add(EG(class_table), BCOMPILERG(is_unicode) ? IS_UNICODE : IS_STRING, key, key_len, &zc, sizeof(zend_class_entry*), NULL) == FAILURE) { + if (zend_u_hash_add(EG(class_table), BCOMPILERG(is_unicode) ? IS_UNICODE : IS_STRING, ZSTR(key), key_len, &zc, sizeof(zend_class_entry*), NULL) == FAILURE) { // zc->refcount--; #elif defined(ZEND_ENGINE_2) if (zend_hash_add(EG(class_table), key, key_len, &zc, sizeof(zend_class_entry*), NULL) == FAILURE) { @@ -1456,7 +1465,7 @@ else { efree(zc); } /* we don't need it */ #endif } - if (key != zc->name) efree(key); + if (key != ZS2S(zc->name)) efree(key); break; case BCOMPILER_INCTABLE_ENTRY: BCOMPILER_DEBUG(("STARTING INC FILE ENTRY\n")); @@ -1471,15 +1480,17 @@ case BCOMPILER_FUNCTION_ENTRY: BCOMPILER_DEBUG(("STARTING FUNCTION\n")); { - char *fname; #if PHP_MAJOR_VERSION >= 6 + zstr fname; int fname_len; +#else + char *fname; #endif apc_create_zend_function(&zf TSRMLS_CC); if (BCOMPILERG(parsing_error)) break; #if PHP_MAJOR_VERSION >= 6 - fname = zend_u_str_case_fold(BCOMPILERG(is_unicode) ? IS_UNICODE : IS_STRING, zf->op_array.function_name, BCOMPILERG(is_unicode) ? u_strlen((UChar*)zf->op_array.function_name) : strlen(zf->op_array.function_name), 0, &fname_len); + fname = zend_u_str_case_fold(BCOMPILERG(is_unicode) ? IS_UNICODE : IS_STRING, zf->op_array.function_name, BCOMPILERG(is_unicode) ? u_strlen(zf->op_array.function_name.u) : strlen(zf->op_array.function_name.s), 0, &fname_len); #elif defined(ZEND_ENGINE_2) fname = zend_str_tolower_dup(zf->op_array.function_name, strlen(zf->internal_function.function_name)); #else @@ -1504,14 +1515,15 @@ } apc_free_zend_function(&zf TSRMLS_CC); -#ifdef ZEND_ENGINE_2 - efree(fname); -#endif + efree(ZS2S(fname)); } break; case BCOMPILER_CONSTANT: BCOMPILER_DEBUG(("STARTING CONSTANT\n")); apc_create_zend_constant(&zconst TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 6 + zend_register_constant(zconst TSRMLS_CC); +#else switch(zconst->value.type) { case IS_LONG: @@ -1524,6 +1536,7 @@ zend_register_double_constant(zconst->name, zconst->name_len, zconst->value.value.dval, zconst->flags, 0 TSRMLS_CC); break; } +#endif break; case BCOMPILER_OP_ARRAY: @@ -1945,11 +1958,11 @@ SERIALIZE_SCALAR(1, char); SERIALIZE_SCALAR(arg_info->name_len , int); // apc_serialize_string(arg_info->name TSRMLS_CC); - apc_serialize_zstring(arg_info->name, arg_info->name_len TSRMLS_CC); + apc_serialize_zstring(ZS2S(arg_info->name), arg_info->name_len TSRMLS_CC); SERIALIZE_SCALAR(arg_info->class_name_len , int); if (arg_info->class_name_len) { // apc_serialize_string(arg_info->class_name TSRMLS_CC); - apc_serialize_zstring(arg_info->class_name, arg_info->class_name_len TSRMLS_CC); + apc_serialize_zstring(ZS2S(arg_info->class_name), arg_info->class_name_len TSRMLS_CC); } SERIALIZE_SCALAR(arg_info->allow_null , char); SERIALIZE_SCALAR(arg_info->pass_by_reference, char); @@ -1969,12 +1982,12 @@ return; /* arg_types is null */ } DESERIALIZE_SCALAR(&arg_info->name_len, int); - apc_create_string2(&arg_info->name, -1 TSRMLS_CC); + apc_create_string2(&ZS2S(arg_info->name), -1 TSRMLS_CC); DESERIALIZE_SCALAR(&arg_info->class_name_len, int); if (arg_info->class_name_len) { - apc_create_string2(&arg_info->class_name, -1 TSRMLS_CC); + apc_create_string2(&ZS2S(arg_info->class_name), -1 TSRMLS_CC); } - else arg_info->class_name = NULL; + else ZS2S(arg_info->class_name) = NULL; DESERIALIZE_SCALAR(&arg_info->allow_null, char); DESERIALIZE_SCALAR(&arg_info->pass_by_reference, char); DESERIALIZE_SCALAR(&arg_info->return_reference, char); @@ -2276,7 +2289,7 @@ #if PHP_MAJOR_VERSION >= 6 SERIALIZE_SCALAR(p->key.type,zend_uchar); - apc_serialize_zstring(p->key.u.string, REAL_KEY_SIZE(p->key.type, p->nKeyLength) TSRMLS_CC); + apc_serialize_zstring(p->key.arKey.s, REAL_KEY_SIZE(p->key.type, p->nKeyLength) TSRMLS_CC); #else apc_serialize_zstring(p->arKey, p->nKeyLength TSRMLS_CC); #endif @@ -2371,7 +2384,7 @@ if(datasize == sizeof(void*)) { #if PHP_MAJOR_VERSION >= 6 BCOMPILER_DEBUGFULL(("adding element [ptr] type=%d len=%d ptr=%p\n", keyType, nKeyLength, &pData)); - _zend_u_hash_add_or_update(ht, keyType, arKey, nKeyLength, &pData, + _zend_u_hash_add_or_update(ht, keyType, ZSTR(arKey), nKeyLength, &pData, datasize, NULL, HASH_ADD ZEND_FILE_LINE_CC); #elif defined(ZEND_ENGINE_2) BCOMPILER_DEBUGFULL(("adding element [ptr] %s = %p\n", arKey, &pData)); @@ -2388,7 +2401,7 @@ BCOMPILER_DEBUGFULL(("adding element [cpy] %s = %p\n", arKey, pData)); #ifdef ZEND_ENGINE_2 # if PHP_MAJOR_VERSION >= 6 - _zend_u_hash_add_or_update(ht, keyType, arKey, nKeyLength, pData, + _zend_u_hash_add_or_update(ht, keyType, ZSTR(arKey), nKeyLength, pData, datasize, &pDest, HASH_ADD ZEND_FILE_LINE_CC); # else _zend_hash_add_or_update(ht, arKey, nKeyLength, pData, @@ -2466,9 +2479,6 @@ break; case IS_CONSTANT: case IS_STRING: -#if PHP_MAJOR_VERSION >= 6 - case IS_BINARY: -#endif #ifndef ZEND_ENGINE_2 case FLAG_IS_BC: #endif @@ -2532,9 +2542,6 @@ break; case IS_CONSTANT: case IS_STRING: -#if PHP_MAJOR_VERSION >= 6 - case IS_BINARY: -#endif #ifndef ZEND_ENGINE_2 case FLAG_IS_BC: #endif @@ -2662,7 +2669,7 @@ { SERIALIZE_SCALAR(zpr->flags, zend_uint); #if PHP_MAJOR_VERSION >= 6 - apc_serialize_zstring(zpr->name, UG(unicode) ? UBYTES(zpr->name_length) : zpr->name_length TSRMLS_CC); + apc_serialize_zstring(ZS2S(zpr->name), UG(unicode) ? UBYTES(zpr->name_length) : zpr->name_length TSRMLS_CC); #else apc_serialize_zstring(zpr->name, zpr->name_length TSRMLS_CC); #endif @@ -2672,7 +2679,7 @@ void apc_deserialize_zend_property_info(zend_property_info* zpr TSRMLS_DC) { DESERIALIZE_SCALAR(&zpr->flags, zend_uint); - apc_create_string2(&zpr->name, -1 TSRMLS_CC); + apc_create_string2(&ZS2S(zpr->name), -1 TSRMLS_CC); DESERIALIZE_SCALAR(&zpr->name_length, uint); DESERIALIZE_SCALAR(&zpr->h, ulong); } @@ -2753,7 +2760,7 @@ BCOMPILER_DEBUG(("adding type : %i\n",zce->type )); SERIALIZE_SCALAR(zce->type, char); #if PHP_MAJOR_VERSION >= 6 - apc_serialize_zstring(zce->name, UG(unicode) ? UBYTES(zce->name_length) : zce->name_length TSRMLS_CC); + apc_serialize_zstring(ZS2S(zce->name), UG(unicode) ? UBYTES(zce->name_length) : zce->name_length TSRMLS_CC); #else apc_serialize_zstring(zce->name, zce->name_length TSRMLS_CC); #endif @@ -2769,7 +2776,7 @@ /*Parent*/ SERIALIZE_SCALAR(1, char); #if PHP_MAJOR_VERSION >= 6 - apc_serialize_zstring(zce->parent->name, UG(unicode) ? UBYTES(zce->parent->name_length) : zce->parent->name_length TSRMLS_CC); + apc_serialize_zstring(ZS2S(zce->parent->name), UG(unicode) ? UBYTES(zce->parent->name_length) : zce->parent->name_length TSRMLS_CC); #else apc_serialize_zstring(zce->parent->name, zce->parent->name_length TSRMLS_CC); #endif @@ -2898,7 +2905,7 @@ #ifdef ZEND_ENGINE_2 static void zend_destroy_property_info(zend_property_info *property_info) { - efree(property_info->name); + efree(ZS2S(property_info->name)); } #endif void apc_deserialize_zend_class_entry(zend_class_entry* zce, char **key, int *key_len TSRMLS_DC) @@ -2911,7 +2918,7 @@ #endif DESERIALIZE_SCALAR(&zce->type, char); - apc_create_string2(&zce->name, -1 TSRMLS_CC); + apc_create_string2(&ZS2S(zce->name), -1 TSRMLS_CC); DESERIALIZE_SCALAR(&zce->name_length, uint); zce->parent = NULL; @@ -3271,10 +3278,10 @@ #endif #if PHP_MAJOR_VERSION >= 6 - if (zoa->function_name == NULL) len = -1; - else if (UG(unicode)) len = u_strlen((UChar*)zoa->function_name) * sizeof(UChar); - else len = strlen(zoa->function_name); - apc_serialize_zstring(zoa->function_name, len TSRMLS_CC); + if (zoa->function_name.s == NULL) len = -1; + else if (UG(unicode)) len = u_strlen(zoa->function_name.u) * sizeof(UChar); + else len = strlen(zoa->function_name.s); + apc_serialize_zstring(zoa->function_name.s, len TSRMLS_CC); #else apc_serialize_string(zoa->function_name TSRMLS_CC); #endif @@ -3325,10 +3332,10 @@ #if PHP_MAJOR_VERSION >= 6 int len; if (zoa->scope == NULL) len = -1; - else if (zoa->scope->name == NULL) len = -1; - else if (UG(unicode)) len = u_strlen((UChar*)zoa->scope->name) * sizeof(UChar); - else len = strlen(zoa->scope->name); - apc_serialize_zstring(zoa->scope ? zoa->scope->name : NULL, len TSRMLS_CC); + else if (zoa->scope->name.s == NULL) len = -1; + else if (UG(unicode)) len = u_strlen(zoa->scope->name.u) * sizeof(UChar); + else len = strlen(zoa->scope->name.s); + apc_serialize_zstring(zoa->scope ? zoa->scope->name.s : NULL, len TSRMLS_CC); #else apc_serialize_string(zoa->scope ? zoa->scope->name : NULL TSRMLS_CC); #endif @@ -3347,7 +3354,7 @@ SERIALIZE_SCALAR(zoa->size_var, int); for (i = 0; i < zoa->last_var; i++) { SERIALIZE_SCALAR(zoa->vars[i].name_len, int); - apc_serialize_zstring(zoa->vars[i].name, zoa->vars[i].name_len TSRMLS_CC); + apc_serialize_zstring(ZS2S(zoa->vars[i].name), zoa->vars[i].name_len TSRMLS_CC); SERIALIZE_SCALAR(zoa->vars[i].hash_value, ulong); } } @@ -3392,7 +3399,7 @@ apc_create_arg_types(&zoa->arg_types TSRMLS_CC); #endif - apc_create_string2(&zoa->function_name, -1 TSRMLS_CC); + apc_create_string2(&ZS2S(zoa->function_name), -1 TSRMLS_CC); zoa->refcount = (int*) emalloc(sizeof(zend_uint)); DESERIALIZE_SCALAR(zoa->refcount, zend_uint); if (BCOMPILERG(current_include)) { @@ -3586,17 +3593,18 @@ zoa->scope = NULL; if (*fname) { zend_class_entry **ce = NULL; - int cmp = #if PHP_MAJOR_VERSION >= 6 - BCOMPILERG(is_unicode) ? - u_strcmp((UChar*)fname, (UChar*)BCOMPILERG(cur_zc)->name) : + int cmp = BCOMPILERG(is_unicode) ? + u_strcmp((UChar*)fname, BCOMPILERG(cur_zc)->name.u) : + strcmp(fname, BCOMPILERG(cur_zc)->name.s); +#else + int cmp = strcmp(fname, BCOMPILERG(cur_zc)->name); #endif - strcmp(fname, BCOMPILERG(cur_zc)->name); if (BCOMPILERG(cur_zc) && !cmp) { ce = &(BCOMPILERG(cur_zc)); } #if PHP_MAJOR_VERSION >= 6 - else if (SUCCESS != zend_u_hash_find(CG(class_table), BCOMPILERG(is_unicode) ? IS_UNICODE : IS_STRING, fname, BCOMPILERG(is_unicode) ? u_strlen((UChar*)fname)+1 : strlen(fname)+1, (void **)&ce)) { + else if (SUCCESS != zend_u_hash_find(CG(class_table), BCOMPILERG(is_unicode) ? IS_UNICODE : IS_STRING, ZSTR(fname), BCOMPILERG(is_unicode) ? u_strlen((UChar*)fname)+1 : strlen(fname)+1, (void **)&ce)) { #else else if (SUCCESS != zend_hash_find(CG(class_table), fname, strlen(fname)+1, (void **)&ce)) { #endif @@ -3625,7 +3633,7 @@ memset(zoa->vars, 0, zoa->size_var * sizeof(zoa->vars[0])); for (i = 0; i < zoa->last_var; i++) { DESERIALIZE_SCALAR(&(zoa->vars[i].name_len), int); - apc_create_string2(&(zoa->vars[i].name), -1 TSRMLS_CC); + apc_create_string2(&ZS2S(zoa->vars[i].name), -1 TSRMLS_CC); DESERIALIZE_SCALAR(&(zoa->vars[i].hash_value), ulong); } } @@ -3712,8 +3720,15 @@ #ifdef ZEND_ENGINE_2 /* val: don't include functions of other classes that are bound to this */ if (BCOMPILERG(cur_zc) && BCOMPILERG(current_write) >= 0x0005) { - BCOMPILER_DEBUGFULL(("current class: %s; scope: %s\n", BCOMPILERG(cur_zc)->name, zf->common.scope->name)); - if (strcmp(BCOMPILERG(cur_zc)->name, zf->common.scope->name) != 0) { +#if PHP_MAJOR_VERSION >= 6 + int cmp = BCOMPILERG(is_unicode) ? + u_strcmp(BCOMPILERG(cur_zc)->name.u, zf->common.scope->name.u) : + strcmp(BCOMPILERG(cur_zc)->name.s, zf->common.scope->name.s); +#else + int cmp = strcmp(BCOMPILERG(cur_zc)->name, zf->common.scope->name); +#endif + BCOMPILER_DEBUGFULL(("current class: %s; scope: %s\n", ZS2S(BCOMPILERG(cur_zc)->name), ZS2S(zf->common.scope->name))); + if (cmp != 0) { SERIALIZE_SCALAR(0xff, zend_uchar); return; } @@ -3882,7 +3897,7 @@ { apc_serialize_zval(&zc->value, NULL TSRMLS_CC); SERIALIZE_SCALAR(zc->flags, int); - apc_serialize_string(zc->name TSRMLS_CC); + apc_serialize_string(ZS2S(zc->name) TSRMLS_CC); BCOMPILER_DEBUG(("serializing constant %s\n",zc->name)); SERIALIZE_SCALAR(zc->name_len, uint); SERIALIZE_SCALAR(zc->module_number, int); @@ -3892,7 +3907,7 @@ { apc_deserialize_zval(&zc->value, NULL TSRMLS_CC); DESERIALIZE_SCALAR(&zc->flags, int); - apc_create_string(&zc->name TSRMLS_CC); + apc_create_string(&ZS2S(zc->name) TSRMLS_CC); BCOMPILER_DEBUG(("deserializing constant %s\n",zc->name)); DESERIALIZE_SCALAR(&zc->name_len, uint); DESERIALIZE_SCALAR(&zc->module_number, int);
« previous php.pecl.cvs (#6454) next »