phpng-upgrading

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
phpng-upgrading [2015/08/24 22:14]
bjori typo
phpng-upgrading [2019/05/18 20:02] (current)
santiagolizardo Add missing parenthesis to zend_register_resource example
Line 204: Line 204:
 Zend has a new **zend_string** API, except that **zend_string** is underlining structure for string representation in **zval**, these structures are also used throughout much of the codebase where **char%%*%%** and **int** were used before. Zend has a new **zend_string** API, except that **zend_string** is underlining structure for string representation in **zval**, these structures are also used throughout much of the codebase where **char%%*%%** and **int** were used before.
  
-**zend_strings** (not **IS_STRING** zvals) may be created using **zend_string_init(char *val, int len, int persistent)** function.+**zend_strings** (not **IS_STRING** zvals) may be created using **zend_string_init(char *val, size_t ​len, int persistent)** function.
 The actual characters may be accessed as **str->​val** and string length as **str->​len**. The hash value of the string should be accessed through **zend_string_hash_val** function. It'll re-calculate hash value if necessary. The actual characters may be accessed as **str->​val** and string length as **str->​len**. The hash value of the string should be accessed through **zend_string_hash_val** function. It'll re-calculate hash value if necessary.
  
Line 270: Line 270:
 - RETURN_STRINGL(implstr.c,​ implstr.len,​ 0); - RETURN_STRINGL(implstr.c,​ implstr.len,​ 0);
 + smart_str str = {0}; + smart_str str = {0};
-+ smart_str_appendl(str,​ " ", sizeof("​ ") - 1); ++ smart_str_appendl(&str, " ", sizeof("​ ") - 1); 
-+ smart_str_0(str);​++ smart_str_0(&str);
 + if (str.s) { + if (str.s) {
 +   ​RETURN_STR(str.s);​ +   ​RETURN_STR(str.s);​
Line 499: Line 499:
      ​zend_object_std_init(&​intern->​std,​ ce TSRMLS_CC);      ​zend_object_std_init(&​intern->​std,​ ce TSRMLS_CC);
      ...      ...
-     ​custom_object_handlers.offset = XtOffsetof(struct custom_obj, std);+     ​custom_object_handlers.offset = XtOffsetOf(struct custom_obj, std);
      ​custom_object_handlers.free_obj = custom_free_storage;​      ​custom_object_handlers.free_obj = custom_free_storage;​
  
 +     ​intern->​std.handlers = custom_object_handlers;​
 +    ​
      ​return &​intern->​std;​      ​return &​intern->​std;​
 } }
Line 569: Line 571:
  
 - REGISTER_RESOURCE(return_value,​ result, le_result); - REGISTER_RESOURCE(return_value,​ result, le_result);
-+ RETURN_RES(zend_register_resource(result,​ le_result);++ RETURN_RES(zend_register_resource(result,​ le_result));
 </​code>​ </​code>​
  
Line 603: Line 605:
 ===== Parameters Parsing API changes ===== ===== Parameters Parsing API changes =====
  
-  * PHPNG doesn'​t work with **zval%%**%%** anymoreso it doesn't need **'Z'** specifier anymore. It must be replaced by **'z'**.+  * The **'​l'​** specifier now expects a ''​zend_long''​ argumentinstead of a ''​long'' ​argument.
 <​code>​ <​code>​
-zval **pzv; +long lval
-- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "​Z",​ &pzv) == FAILURE) { +zend_long lval
-zval *zv+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &lval) == FAILURE) {
-if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zv) == FAILURE) {+
 </​code>​ </​code>​
  
-  * in addition to **'​s'​** specifier that expects string, PHPNG introduced **'​S'​** specifier that also expects string, but places argument into **zend_string** variable. In some cases direct usage of **zend_string** is preferred. (For example when received string used as a key in HashTable API.+  * The length argument of the **'​s'​** specifier now expects a ''​size_t''​ variable instead of an ''​int''​ variable. 
 +<​code>​ 
 +  char *str; 
 +- int len; 
 ++ size_t len; 
 +  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "​s",​ &str, &len) == FAILURE) { 
 +</​code>​ 
 + 
 +  * In addition to **'​s'​** specifier that expects string, PHPNG introduced **'​S'​** specifier that also expects string, but places argument into **zend_string** variable. In some cases direct usage of **zend_string** is preferred. (For example when received string used as a key in HashTable API.
 <​code>​ <​code>​
 - char *str; - char *str;
Line 618: Line 627:
 + zend_string *str; + zend_string *str;
 + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "​S",​ &str) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "​S",​ &str) == FAILURE) {
 +</​code>​
 +
 +  * PHPNG doesn'​t work with **zval%%**%%** anymore, so it doesn'​t need **'​Z'​** specifier anymore. It must be replaced by **'​z'​**.
 +<​code>​
 +- zval **pzv;
 +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "​Z",​ &pzv) == FAILURE) {
 ++ zval *zv;
 ++ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "​z",​ &zv) == FAILURE) {
 </​code>​ </​code>​
  
phpng-upgrading.1440454455.txt.gz · Last modified: 2017/09/22 13:28 (external edit)