static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type, int skip_top_traces) /* {{{ */ { zval obj; zend_object *object; zval trace; zend_class_entry *base_ce; zend_string *filename; Z_OBJ(obj) = object = zend_objects_new(class_type); Z_OBJ_HT(obj) = &default_exception_handlers; object_properties_init(object, class_type); if (EG(current_execute_data)) { zend_fetch_debug_backtrace(&trace, skip_top_traces, 0, 0); } else { array_init(&trace); } Z_SET_REFCOUNT(trace, 0); base_ce = i_get_exception_base(&obj); if (EXPECTED(class_type != zend_ce_parse_error || !(filename = zend_get_compiled_filename()))) { zend_update_property_string(base_ce, &obj, "file", sizeof("file")-1, zend_get_executed_filename()); zend_update_property_long(base_ce, &obj, "line", sizeof("line")-1, zend_get_executed_lineno()); } else { zend_update_property_str(base_ce, &obj, "file", sizeof("file")-1, filename); zend_update_property_long(base_ce, &obj, "line", sizeof("line")-1, zend_get_compiled_lineno()); } zend_update_property(base_ce, &obj, "trace", sizeof("trace")-1, &trace); return object; }
static zend_object *vector_create_object(zend_class_entry *ce) /* {{{ */ { zend_object *object; object = zend_objects_new(ce); object->handlers = &vector_object_handlers; object_properties_init(object, ce); return object; }
static zend_object_value zend_default_exception_new_ex(zend_class_entry *class_type, int skip_top_traces TSRMLS_DC) /* {{{ */ { zend_object *object; zend_object_value ret = zend_objects_new(&object, class_type TSRMLS_CC); object_properties_init(object, class_type); return ret; }
/* {{{ php_create_incomplete_class */ static zend_object *php_create_incomplete_object(zend_class_entry *class_type) { zend_object *object; object = zend_objects_new( class_type); object->handlers = &php_incomplete_object_handlers; object_properties_init(object, class_type); return object; }
ObjectData* new_ZendObjectData_Instance(Class* cls) { TSRMLS_FETCH(); size_t nProps = cls->numDeclProperties(); size_t builtinObjSize = sizeof(c_ZendObjectData) - sizeof(ObjectData); size_t size = ObjectData::sizeForNProps(nProps) + builtinObjSize; auto obj = new (MM().objMallocLogged(size)) c_ZendObjectData(cls); zend_class_entry* ce = zend_hphp_class_to_class_entry(cls); auto create_func = ce->create_object; Class * current_class = cls; while (!create_func) { Class* parent = current_class->parent(); if (!parent) { break; } zend_class_entry* parent_ce = zend_hphp_class_to_class_entry(parent); create_func = parent_ce->create_object; current_class = parent; } zend_object_value ov; if (create_func) { ov = create_func(ce TSRMLS_CC); } else { zend_object *object; ov = zend_objects_new(&object, ce TSRMLS_CC); } obj->setHandle(ov.handle); if (UNLIKELY(cls->callsCustomInstanceInit())) { /* This must happen after the constructor finishes, because it can leak references to obj AND it can throw exceptions. If we have this in the ObjectData constructor, and it throws, obj will be partially destroyed (ie ~ObjectData will be called, resetting the vtable pointer) leaving dangling references to the object (eg in backtraces). */ obj->callCustomInstanceInit(); } return obj; }
static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type, int skip_top_traces) /* {{{ */ { zval obj, tmp; zend_object *object; zval trace; zend_class_entry *base_ce; zend_string *filename; Z_OBJ(obj) = object = zend_objects_new(class_type); Z_OBJ_HT(obj) = &default_exception_handlers; object_properties_init(object, class_type); if (EG(current_execute_data)) { zend_fetch_debug_backtrace(&trace, skip_top_traces, 0, 0); } else { array_init(&trace); } Z_SET_REFCOUNT(trace, 0); base_ce = i_get_exception_base(&obj); if (EXPECTED((class_type != zend_ce_parse_error && class_type != zend_ce_compile_error) || !(filename = zend_get_compiled_filename()))) { ZVAL_STRING(&tmp, zend_get_executed_filename()); zend_update_property_ex(base_ce, &obj, ZSTR_KNOWN(ZEND_STR_FILE), &tmp); zval_ptr_dtor(&tmp); ZVAL_LONG(&tmp, zend_get_executed_lineno()); zend_update_property_ex(base_ce, &obj, ZSTR_KNOWN(ZEND_STR_LINE), &tmp); } else { ZVAL_STR(&tmp, filename); zend_update_property_ex(base_ce, &obj, ZSTR_KNOWN(ZEND_STR_FILE), &tmp); ZVAL_LONG(&tmp, zend_get_compiled_lineno()); zend_update_property_ex(base_ce, &obj, ZSTR_KNOWN(ZEND_STR_LINE), &tmp); } zend_update_property_ex(base_ce, &obj, ZSTR_KNOWN(ZEND_STR_TRACE), &trace); return object; }
void ZendObject::initZendObject(Class * cls) { TSRMLS_FETCH(); zend_class_entry* ce = zend_hphp_class_to_class_entry(cls); auto create_func = ce->create_object; Class * current_class = cls; while (!create_func) { Class* parent = current_class->parent(); if (!parent) { break; } zend_class_entry* parent_ce = zend_hphp_class_to_class_entry(parent); create_func = parent_ce->create_object; current_class = parent; } zend_object_value ov; if (create_func) { ov = create_func(ce TSRMLS_CC); } else { zend_object *object; ov = zend_objects_new(&object, ce TSRMLS_CC); } setHandle(ov.handle); }
static zend_object *zend_test_class_new(zend_class_entry *class_type) /* {{{ */ { zend_object *obj = zend_objects_new(class_type); obj->handlers = &zend_test_class_handlers; return obj; }
#define CLASS_NAME "SDO_Exception" static zend_class_entry *exception_class_entry; static zend_object_handlers sdo_exception_object_handlers; /* {{{ sdo_exception_object_create */ static zend_object_value sdo_exception_create_object(zend_class_entry *ce TSRMLS_DC) { zend_object *object; zval *tmp; /* this must be passed to hash_copy, but doesn't seem to be used */ zval z_object; zval *z_trace; z_object.value.obj = zend_objects_new(&object, ce TSRMLS_CC); z_object.value.obj.handlers = &sdo_exception_object_handlers; ALLOC_HASHTABLE(object->properties); zend_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0); // zend_hash_copy(object->properties, &ce->default_properties, (copy_ctor_func_t)zval_add_ref, (void *)&tmp, sizeof(zval *)); #if PHP_VERSION_ID < 50399 zend_hash_copy(object->properties, &ce->default_properties, (copy_ctor_func_t)zval_add_ref, (void *)&tmp, sizeof(zval *)); #else object_properties_init(object, ce); #endif zend_update_property_string(exception_class_entry, &z_object, "file", sizeof("file") - 1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC); zend_update_property_long(exception_class_entry, &z_object,