mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

The Generator class now uses a zend_generator struct, so it'll be able to store additional info. This commit also ensures that Generator cannot be directly instantiated and extended. The error tests are now in a separate folder from the (yet-to-come) functional tests.
94 lines
3 KiB
C
94 lines
3 KiB
C
/*
|
|
+----------------------------------------------------------------------+
|
|
| Zend Engine |
|
|
+----------------------------------------------------------------------+
|
|
| Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
|
|
+----------------------------------------------------------------------+
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
| available through the world-wide-web at the following url: |
|
|
| http://www.zend.com/license/2_00.txt. |
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
| license@zend.com so we can mail you a copy immediately. |
|
|
+----------------------------------------------------------------------+
|
|
| Authors: Nikita Popov <nikic@php.net> |
|
|
+----------------------------------------------------------------------+
|
|
*/
|
|
|
|
/* $Id$ */
|
|
|
|
#include "zend.h"
|
|
#include "zend_API.h"
|
|
#include "zend_generators.h"
|
|
|
|
ZEND_API zend_class_entry *zend_ce_generator;
|
|
static zend_object_handlers zend_generator_handlers;
|
|
|
|
typedef struct _zend_generator {
|
|
zend_object std;
|
|
/* nothing more for now */
|
|
} zend_generator;
|
|
|
|
static void zend_generator_free_storage(zend_generator *generator TSRMLS_DC) /* {{{ */
|
|
{
|
|
zend_object_std_dtor(&generator->std TSRMLS_CC);
|
|
|
|
efree(generator);
|
|
}
|
|
/* }}} */
|
|
|
|
static zend_object_value zend_generator_create(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
|
|
{
|
|
zend_generator *generator;
|
|
zend_object_value object;
|
|
|
|
generator = emalloc(sizeof(zend_generator));
|
|
memset(generator, 0, sizeof(zend_generator));
|
|
|
|
zend_object_std_init(&generator->std, class_type TSRMLS_CC);
|
|
|
|
object.handle = zend_objects_store_put(generator, NULL,
|
|
(zend_objects_free_object_storage_t) zend_generator_free_storage,
|
|
NULL /* no clone handler for now */
|
|
TSRMLS_CC
|
|
);
|
|
object.handlers = &zend_generator_handlers;
|
|
|
|
return object;
|
|
}
|
|
/* }}} */
|
|
|
|
static zend_function *zend_generator_get_constructor(zval *object TSRMLS_DC) /* {{{ */
|
|
{
|
|
zend_error(E_RECOVERABLE_ERROR, "The \"Generator\" class is reserved for internal use and cannot be manually instantiated");
|
|
|
|
return NULL;
|
|
}
|
|
/* }}} */
|
|
|
|
static const zend_function_entry generator_functions[] = {
|
|
ZEND_FE_END
|
|
};
|
|
|
|
void zend_register_generator_ce(TSRMLS_D) /* {{{ */
|
|
{
|
|
zend_class_entry ce;
|
|
|
|
INIT_CLASS_ENTRY(ce, "Generator", generator_functions);
|
|
zend_ce_generator = zend_register_internal_class(&ce TSRMLS_CC);
|
|
zend_ce_generator->ce_flags |= ZEND_ACC_FINAL_CLASS;
|
|
zend_ce_generator->create_object = zend_generator_create;
|
|
|
|
memcpy(&zend_generator_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
|
zend_generator_handlers.get_constructor = zend_generator_get_constructor;
|
|
}
|
|
/* }}} */
|
|
|
|
/*
|
|
* Local variables:
|
|
* tab-width: 4
|
|
* c-basic-offset: 4
|
|
* indent-tabs-mode: t
|
|
* End:
|
|
*/
|