andrei Fri Oct 27 21:22:06 2006 UTC
Modified files:
/ZendEngine2 zend.h zend_API.c zend_API.h zend_compile.c
zend_compile.h zend_globals.h zend_language_scanner.l
/php-src/ext/reflection php_reflection.c
Log:
Turn doc comments into zstr strings with corresponding adjustments.
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.h?r1=1.329&r2=1.330&diff_format=u
Index: ZendEngine2/zend.h
diff -u ZendEngine2/zend.h:1.329 ZendEngine2/zend.h:1.330
--- ZendEngine2/zend.h:1.329 Mon Oct 16 21:13:13 2006
+++ ZendEngine2/zend.h Fri Oct 27 21:22:05 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend.h,v 1.329 2006/10/16 21:13:13 andrei Exp $ */
+/* $Id: zend.h,v 1.330 2006/10/27 21:22:05 andrei Exp $ */
#ifndef ZEND_H
#define ZEND_H
@@ -399,7 +399,7 @@
char *filename;
zend_uint line_start;
zend_uint line_end;
- char *doc_comment;
+ zstr doc_comment;
zend_uint doc_comment_len;
struct _zend_module_entry *module;
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.413&r2=1.414&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.413 ZendEngine2/zend_API.c:1.414
--- ZendEngine2/zend_API.c:1.413 Tue Oct 17 22:15:19 2006
+++ ZendEngine2/zend_API.c Fri Oct 27 21:22:05 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.413 2006/10/17 22:15:19 andrei Exp $ */
+/* $Id: zend_API.c,v 1.414 2006/10/27 21:22:05 andrei Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -2902,7 +2902,7 @@
return module->version;
}
-ZEND_API int zend_u_declare_property_ex(zend_class_entry *ce, zend_uchar type,
zstr name, int name_length, zval *property, int access_type, char *doc_comment,
int doc_comment_len TSRMLS_DC)
+ZEND_API int zend_u_declare_property_ex(zend_class_entry *ce, zend_uchar type,
zstr name, int name_length, zval *property, int access_type, zstr doc_comment,
int doc_comment_len TSRMLS_DC)
{
zend_property_info property_info;
HashTable *target_symbol_table;
@@ -2977,19 +2977,19 @@
return SUCCESS;
}
-ZEND_API int zend_declare_property_ex(zend_class_entry *ce, char *name, int
name_length, zval *property, int access_type, char *doc_comment, int
doc_comment_len TSRMLS_DC)
+ZEND_API int zend_declare_property_ex(zend_class_entry *ce, char *name, int
name_length, zval *property, int access_type, zstr doc_comment, int
doc_comment_len TSRMLS_DC)
{
- return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name),
name_length, property, access_type, NULL, 0 TSRMLS_CC);
+ return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name),
name_length, property, access_type, doc_comment, doc_comment_len TSRMLS_CC);
}
ZEND_API int zend_u_declare_property(zend_class_entry *ce, zend_uchar type,
zstr name, int name_length, zval *property, int access_type TSRMLS_DC)
{
- return zend_u_declare_property_ex(ce, type, name, name_length,
property, access_type, NULL, 0 TSRMLS_CC);
+ return zend_u_declare_property_ex(ce, type, name, name_length,
property, access_type, NULL_ZSTR, 0 TSRMLS_CC);
}
ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int
name_length, zval *property, int access_type TSRMLS_DC)
{
- return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name),
name_length, property, access_type, NULL, 0 TSRMLS_CC);
+ return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name),
name_length, property, access_type, NULL_ZSTR, 0 TSRMLS_CC);
}
ZEND_API int zend_declare_property_null(zend_class_entry *ce, char *name, int
name_length, int access_type TSRMLS_DC)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.h?r1=1.267&r2=1.268&diff_format=u
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.267 ZendEngine2/zend_API.h:1.268
--- ZendEngine2/zend_API.h:1.267 Tue Oct 24 12:46:33 2006
+++ ZendEngine2/zend_API.h Fri Oct 27 21:22:05 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.h,v 1.267 2006/10/24 12:46:33 tony2001 Exp $ */
+/* $Id: zend_API.h,v 1.268 2006/10/27 21:22:05 andrei Exp $ */
#ifndef ZEND_API_H
#define ZEND_API_H
@@ -224,7 +224,7 @@
ZEND_API char *zend_get_module_version(char *module_name);
ZEND_API int zend_get_module_started(char *module_name);
ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int
name_length, zval *property, int access_type TSRMLS_DC);
-ZEND_API int zend_declare_property_ex(zend_class_entry *ce, char *name, int
name_length, zval *property, int access_type, char *doc_comment, int
doc_comment_len TSRMLS_DC);
+ZEND_API int zend_declare_property_ex(zend_class_entry *ce, char *name, int
name_length, zval *property, int access_type, zstr doc_comment, int
doc_comment_len TSRMLS_DC);
ZEND_API int zend_declare_property_null(zend_class_entry *ce, char *name, int
name_length, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_bool(zend_class_entry *ce, char *name, int
name_length, long value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_long(zend_class_entry *ce, char *name, int
name_length, long value, int access_type TSRMLS_DC);
@@ -233,7 +233,7 @@
ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, char *name,
int name_length, char *value, int value_len, int access_type TSRMLS_DC);
ZEND_API int zend_u_declare_property(zend_class_entry *ce, zend_uchar type,
zstr name, int name_length, zval *property, int access_type TSRMLS_DC);
-ZEND_API int zend_u_declare_property_ex(zend_class_entry *ce, zend_uchar type,
zstr name, int name_length, zval *property, int access_type, char *doc_comment,
int doc_comment_len TSRMLS_DC);
+ZEND_API int zend_u_declare_property_ex(zend_class_entry *ce, zend_uchar type,
zstr name, int name_length, zval *property, int access_type, zstr doc_comment,
int doc_comment_len TSRMLS_DC);
ZEND_API int zend_declare_class_constant(zend_class_entry *ce, char *name,
size_t name_length, zval *value TSRMLS_DC);
ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, char
*name, size_t name_length TSRMLS_DC);
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.726&r2=1.727&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.726 ZendEngine2/zend_compile.c:1.727
--- ZendEngine2/zend_compile.c:1.726 Mon Oct 16 21:13:13 2006
+++ ZendEngine2/zend_compile.c Fri Oct 27 21:22:05 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.726 2006/10/16 21:13:13 andrei Exp $ */
+/* $Id: zend_compile.c,v 1.727 2006/10/27 21:22:05 andrei Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -41,11 +41,14 @@
if (UG(unicode)) {
property_info->name.u = eustrndup(property_info->name.u,
property_info->name_length);
+ if (property_info->doc_comment.u) {
+ property_info->doc_comment.u =
eustrndup(property_info->doc_comment.u, property_info->doc_comment_len);
+ }
} else {
property_info->name.s = estrndup(property_info->name.s,
property_info->name_length);
- }
- if (property_info->doc_comment) {
- property_info->doc_comment =
estrndup(property_info->doc_comment, property_info->doc_comment_len);
+ if (property_info->doc_comment.s) {
+ property_info->doc_comment.s =
estrndup(property_info->doc_comment.s, property_info->doc_comment_len);
+ }
}
}
@@ -65,8 +68,8 @@
static void zend_destroy_property_info(zend_property_info *property_info)
{
efree(property_info->name.v);
- if (property_info->doc_comment) {
- efree(property_info->doc_comment);
+ if (property_info->doc_comment.v) {
+ efree(property_info->doc_comment.v);
}
}
@@ -1250,10 +1253,10 @@
}
}
- if (CG(doc_comment)) {
+ if (CG(doc_comment).v) {
CG(active_op_array)->doc_comment = CG(doc_comment);
CG(active_op_array)->doc_comment_len = CG(doc_comment_len);
- CG(doc_comment) = NULL;
+ CG(doc_comment) = NULL_ZSTR;
CG(doc_comment_len) = 0;
}
@@ -2936,10 +2939,10 @@
opline->result.op_type = IS_CONST;
CG(implementing_class) = opline->result;
- if (CG(doc_comment)) {
+ if (CG(doc_comment).v) {
CG(active_class_entry)->doc_comment = CG(doc_comment);
CG(active_class_entry)->doc_comment_len = CG(doc_comment_len);
- CG(doc_comment) = NULL;
+ CG(doc_comment) = NULL_ZSTR;
CG(doc_comment_len) = 0;
}
}
@@ -3147,7 +3150,7 @@
{
zval *property;
zend_property_info *existing_property_info;
- char *comment = NULL;
+ zstr comment = NULL_ZSTR;
int comment_len = 0;
if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) {
@@ -3177,10 +3180,10 @@
Z_TYPE_P(property) = IS_NULL;
}
- if (CG(doc_comment)) {
+ if (CG(doc_comment).v) {
comment = CG(doc_comment);
comment_len = CG(doc_comment_len);
- CG(doc_comment) = NULL;
+ CG(doc_comment) = NULL_ZSTR;
CG(doc_comment_len) = 0;
}
@@ -4337,7 +4340,7 @@
ce->constants_updated = 0;
ce->ce_flags = 0;
- ce->doc_comment = NULL;
+ ce->doc_comment = NULL_ZSTR;
ce->doc_comment_len = 0;
zend_u_hash_init_ex(&ce->default_properties, 0, NULL,
zval_ptr_dtor_func, persistent_hashes, UG(unicode), 0);
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.h?r1=1.348&r2=1.349&diff_format=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.348 ZendEngine2/zend_compile.h:1.349
--- ZendEngine2/zend_compile.h:1.348 Thu Oct 26 09:28:44 2006
+++ ZendEngine2/zend_compile.h Fri Oct 27 21:22:05 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.h,v 1.348 2006/10/26 09:28:44 tony2001 Exp $ */
+/* $Id: zend_compile.h,v 1.349 2006/10/27 21:22:05 andrei Exp $ */
#ifndef ZEND_COMPILE_H
#define ZEND_COMPILE_H
@@ -42,11 +42,11 @@
#define RESET_DOC_COMMENT() \
{ \
- if (CG(doc_comment)) { \
- efree(CG(doc_comment)); \
- CG(doc_comment) = NULL; \
- } \
- CG(doc_comment_len) = 0; \
+ if (CG(doc_comment.v)) { \
+ efree(CG(doc_comment.v)); \
+ CG(doc_comment) = NULL_ZSTR; \
+ } \
+ CG(doc_comment_len) = 0; \
}
typedef struct _zend_op_array zend_op_array;
@@ -152,7 +152,7 @@
zstr name;
int name_length;
ulong h;
- char *doc_comment;
+ zstr doc_comment;
int doc_comment_len;
zend_class_entry *ce;
} zend_property_info;
@@ -220,7 +220,7 @@
char *script_encoding;
zend_uint line_start;
zend_uint line_end;
- char *doc_comment;
+ zstr doc_comment;
zend_uint doc_comment_len;
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_globals.h?r1=1.164&r2=1.165&diff_format=u
Index: ZendEngine2/zend_globals.h
diff -u ZendEngine2/zend_globals.h:1.164 ZendEngine2/zend_globals.h:1.165
--- ZendEngine2/zend_globals.h:1.164 Fri Sep 29 20:59:26 2006
+++ ZendEngine2/zend_globals.h Fri Oct 27 21:22:05 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_globals.h,v 1.164 2006/09/29 20:59:26 andrei Exp $ */
+/* $Id: zend_globals.h,v 1.165 2006/10/27 21:22:05 andrei Exp $ */
#ifndef ZEND_GLOBALS_H
#define ZEND_GLOBALS_H
@@ -126,7 +126,7 @@
zend_uint access_type;
- char *doc_comment;
+ zstr doc_comment;
zend_uint doc_comment_len;
zend_uchar literal_type;
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_language_scanner.l?r1=1.158&r2=1.159&diff_format=u
Index: ZendEngine2/zend_language_scanner.l
diff -u ZendEngine2/zend_language_scanner.l:1.158
ZendEngine2/zend_language_scanner.l:1.159
--- ZendEngine2/zend_language_scanner.l:1.158 Mon Sep 18 17:59:10 2006
+++ ZendEngine2/zend_language_scanner.l Fri Oct 27 21:22:05 2006
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_language_scanner.l,v 1.158 2006/09/18 17:59:10 andrei Exp $ */
+/* $Id: zend_language_scanner.l,v 1.159 2006/10/27 21:22:05 andrei Exp $ */
#define yyleng SCNG(yy_leng)
#define yytext SCNG(yy_text)
@@ -130,7 +130,7 @@
{
CG(heredoc) = NULL;
CG(heredoc_len) = 0;
- CG(doc_comment) = NULL;
+ CG(doc_comment) = NULL_ZSTR;
CG(doc_comment_len) = 0;
SCNG(yy_start_stack_ptr) = 0;
SCNG(yy_start_stack_depth) = 0;
@@ -2167,9 +2167,14 @@
}
<ST_DOC_COMMENT>"*/" {
- CG(doc_comment) = estrndup(yytext, yyleng);
- CG(doc_comment_len) = yyleng;
+ zval temp;
+
HANDLE_NEWLINES(yytext, yyleng);
+ if (!zend_copy_scanner_string(&temp, yytext, yyleng,
UG(unicode)?IS_UNICODE:IS_STRING, SCNG(output_conv) TSRMLS_CC)) {
+ return 0;
+ }
+ CG(doc_comment) = temp.value.uni.val;
+ CG(doc_comment_len) = temp.value.uni.len;
BEGIN(ST_IN_SCRIPTING);
return T_DOC_COMMENT;
}
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.265&r2=1.266&diff_format=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.265
php-src/ext/reflection/php_reflection.c:1.266
--- php-src/ext/reflection/php_reflection.c:1.265 Tue Oct 24 17:37:17 2006
+++ php-src/ext/reflection/php_reflection.c Fri Oct 27 21:22:05 2006
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_reflection.c,v 1.265 2006/10/24 17:37:17 andrei Exp $ */
+/* $Id: php_reflection.c,v 1.266 2006/10/27 21:22:05 andrei Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -292,8 +292,8 @@
string_printf(&sub_indent, "%s ", indent);
/* TBD: Repair indenting of doc comment (or is this to be done in the
parser?) */
- if (ce->type == ZEND_USER_CLASS && ce->doc_comment) {
- string_printf(str, "%s%s", indent, ce->doc_comment);
+ if (ce->type == ZEND_USER_CLASS && ce->doc_comment.v) {
+ string_printf(str, "%s%v", indent, ce->doc_comment.v);
string_write(str, "\n", 1);
}
@@ -708,8 +708,8 @@
* What's "wrong" is that any whitespace before the doc comment start
is
* swallowed, leading to an unaligned comment.
*/
- if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) {
- string_printf(str, "%s%s\n", indent,
fptr->op_array.doc_comment);
+ if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment.v) {
+ string_printf(str, "%s%v\n", indent,
fptr->op_array.doc_comment.v);
}
string_printf(str, fptr->common.scope ? "%sMethod [ " : "%sFunction [
", indent);
@@ -1537,12 +1537,8 @@
METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
GET_REFLECTION_OBJECT_PTR(fptr);
- if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) {
- /* FIXME
- * It should use the encoding in which the doc comment was
written, aka
- * the script encoding for the file that the class was defined
in.
- */
- RETURN_RT_STRINGL(fptr->op_array.doc_comment,
fptr->op_array.doc_comment_len, 1);
+ if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment.v) {
+ RETURN_ZSTRL(fptr->op_array.doc_comment,
fptr->op_array.doc_comment_len, ZEND_STR_TYPE, 1);
}
RETURN_FALSE;
}
@@ -2957,13 +2953,8 @@
METHOD_NOTSTATIC_NUMPARAMS(reflection_class_ptr, 0);
GET_REFLECTION_OBJECT_PTR(ce);
- if (ce->type == ZEND_USER_CLASS && ce->doc_comment) {
- /* FIXME
- * It should use the encoding in which the doc comment was
written, aka
- * the script encoding for the file that the class was defined
in. We
- * don't have access to that yet.
- */
- RETURN_RT_STRINGL(ce->doc_comment, ce->doc_comment_len, 1);
+ if (ce->type == ZEND_USER_CLASS && ce->doc_comment.v) {
+ RETURN_ZSTRL(ce->doc_comment, ce->doc_comment_len,
ZEND_STR_TYPE, 1);
}
RETURN_FALSE;
}
@@ -4162,13 +4153,8 @@
METHOD_NOTSTATIC_NUMPARAMS(reflection_property_ptr, 0);
GET_REFLECTION_OBJECT_PTR(ref);
- if (ref->prop->doc_comment) {
- /* FIXME
- * It should use the encoding in which the doc comment was
written, aka
- * the script encoding for the file that the class was defined
in. We
- * don't have access to that yet.
- */
- RETURN_RT_STRINGL(ref->prop->doc_comment,
ref->prop->doc_comment_len, 1);
+ if (ref->prop->doc_comment.v) {
+ RETURN_ZSTRL(ref->prop->doc_comment,
ref->prop->doc_comment_len, ZEND_STR_TYPE, 1);
}
RETURN_FALSE;
}
@@ -4962,7 +4948,7 @@
php_info_print_table_start();
php_info_print_table_header(2, "Reflection", "enabled");
- php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.265
2006/10/24 17:37:17 andrei Exp $");
+ php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.266
2006/10/27 21:22:05 andrei Exp $");
php_info_print_table_end();
} /* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php