Changeset 276 for trunk/ext/php
- Timestamp:
- 10/05/2007 01:52:32 (14 months ago)
- Location:
- trunk/ext/php
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/php/CHANGELOG
r275 r276 9 9 - added support for loading explicitly typed DateTime (with timestamp-compatible value) 10 10 - fixed loading of maps with numeric keys 11 - added support for loading sequences into classes which implement ArrayAccess 11 - added support for loading sequences into classes which implement ArrayAccess (!php/array:ClassName) 12 - added support for loading maps into classes which implement ArrayAccess (!php/hash:ClassName) 12 13 13 14 - version: 0.9.1 -
trunk/ext/php/TODO
r275 r276 8 8 load: 9 9 - objects: 10 - "!php/hash:ClassName"11 10 - "!php:ClassName (?)" 12 11 - allow user to assign custom handler for loading any other type of objects (java, ruby, etc.) -
trunk/ext/php/phpext.c
r275 r276 396 396 } 397 397 } else if (strncmp(n->type_id, "php/array:", 10) == 0) { 398 /* some class which implements Array Iterator*/398 /* some class which implements ArrayAccess */ 399 399 size_t i; 400 400 size_t classname_len = strlen(n->type_id) - 10; … … 428 428 efree(key); 429 429 } 430 431 if (zend_hash_exists(&(*ce)->function_table, "__wakeup", 9)) { 432 zend_call_method_with_0_params(&o, *ce, NULL, "__wakeup", NULL); 433 } 430 434 } else { 431 zend_throw_exception_ex(syck_exception_entry, 0 TSRMLS_CC, "Class %s doesn't implement Array Iteratoron line %d, col %d: '%s'", classname, p->linect, p->cursor - p->lineptr, p->lineptr);435 zend_throw_exception_ex(syck_exception_entry, 0 TSRMLS_CC, "Class %s doesn't implement ArrayAccess on line %d, col %d: '%s'", classname, p->linect, p->cursor - p->lineptr, p->lineptr); 432 436 efree(classname); 433 437 break; … … 473 477 } else if (strncmp(n->type_id, "php/hash:", 9) == 0) { 474 478 /* some classm which implements ArrayAccess */ 479 SYMID oid; 480 size_t i; 481 zval *o2, *o3; 475 482 size_t classname_len = strlen(n->type_id) - 9; 476 483 char *classname = emalloc(classname_len + 1); … … 492 499 } 493 500 494 /* 495 * TODO: add filling of ArrayAccess object with values 496 */ 497 array_init(o); 501 object_init_ex(o, *ce); 502 503 for (i = 0; i < n->data.pairs->idx; i++) { 504 oid = syck_map_read(n, map_key, i); 505 syck_lookup_sym(p, oid, (char **) &o2); /* retrieving key-node */ 506 507 if (o2->type == IS_STRING || o2->type == IS_LONG) { 508 oid = syck_map_read(n, map_value, i); 509 syck_lookup_sym(p, oid, (char **) &o3); /* retrieving value-node */ 510 511 zend_call_method_with_2_params(&o, *ce, NULL, "offsetset", NULL, o2, o3); 512 zval_ptr_dtor(&o3); 513 } 514 515 zval_ptr_dtor(&o2); 516 } 517 518 if (zend_hash_exists(&(*ce)->function_table, "__wakeup", 9)) { 519 zend_call_method_with_0_params(&o, *ce, NULL, "__wakeup", NULL); 520 } 498 521 499 522 efree(classname); -
trunk/ext/php/phpunit-tests/TestLoad.php
r275 r276 177 177 178 178 // ArrayObject implements ArrayAccess: OK 179 $this->assertEquals(syck_load('!php/hash:ArrayObject {}'), array()); 179 $this->assertEquals(new ArrayObject(), syck_load('!php/hash:ArrayObject {}')); 180 $this->assertEquals( 181 new ArrayObject(array('a' => 1, 'b' => 2, 3 => 3, 4 => 'd', 'e' => 5)), 182 syck_load('!php/hash:ArrayObject {a: 1, b: 2, 3: 3, 4: d, e: 5}') 183 ); 180 184 181 185 // SyckTestSomeClass doesn't implement ArrayAccess: FAILURE