cvs: ZendEngine2 / zend_API.c zend_API.h zend_compile.c zend_compile.h zend_reflection_api.c
| From: | Marcus Boerger | Date: | Tue, 19 Apr 2005 22:05:00 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c zend_API.h zend_compile.c zend_compile.h zend_reflection_api.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-3575@lists.php.net to get a copy of this message | ||
helly Tue Apr 19 18:05:00 2005 EDT
Modified files:
/ZendEngine2 zend_API.c zend_API.h zend_compile.c zend_compile.h
zend_reflection_api.c
Log:
- Add ReflectionProperty::getDocComment()
http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.281&r2=1.282&ty=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.281 ZendEngine2/zend_API.c:1.282
--- ZendEngine2/zend_API.c:1.281 Mon Mar 21 01:20:17 2005
+++ ZendEngine2/zend_API.c Tue Apr 19 18:04:57 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.281 2005/03/21 06:20:17 andrei Exp $ */
+/* $Id: zend_API.c,v 1.282 2005/04/19 22:04:57 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -1891,6 +1891,11 @@
ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_length, zval
*property, int access_type TSRMLS_DC)
{
+ return zend_declare_property_ex(ce, name, name_length, property, access_type, NULL, 0 TSRMLS_CC);
+}
+
+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_property_info property_info;
HashTable *target_symbol_table;
@@ -1952,6 +1957,9 @@
property_info.flags = access_type;
property_info.h = zend_get_hash_value(property_info.name, property_info.name_length+1);
+ property_info.doc_comment = doc_comment;
+ property_info.doc_comment_len = doc_comment_len;
+
zend_hash_update(&ce->properties_info, name, name_length + 1, &property_info,
sizeof(zend_property_info), NULL);
return SUCCESS;
http://cvs.php.net/diff.php/ZendEngine2/zend_API.h?r1=1.195&r2=1.196&ty=u
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.195 ZendEngine2/zend_API.h:1.196
--- ZendEngine2/zend_API.h:1.195 Sun Feb 27 17:18:55 2005
+++ ZendEngine2/zend_API.h Tue Apr 19 18:04:57 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.h,v 1.195 2005/02/27 22:18:55 helly Exp $ */
+/* $Id: zend_API.h,v 1.196 2005/04/19 22:04:57 helly Exp $ */
#ifndef ZEND_API_H
#define ZEND_API_H
@@ -189,6 +189,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_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);
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.617&r2=1.618&ty=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.617 ZendEngine2/zend_compile.c:1.618
--- ZendEngine2/zend_compile.c:1.617 Tue Apr 19 07:41:02 2005
+++ ZendEngine2/zend_compile.c Tue Apr 19 18:04:57 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.617 2005/04/19 11:41:02 sniper Exp $ */
+/* $Id: zend_compile.c,v 1.618 2005/04/19 22:04:57 helly Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -54,6 +54,9 @@
static void zend_destroy_property_info(zend_property_info *property_info)
{
efree(property_info->name);
+ if (property_info->doc_comment) {
+ efree(property_info->doc_comment);
+ }
}
@@ -1818,8 +1821,11 @@
}
if (proto->common.return_reference != ZEND_RETURN_REFERENCE_AGNOSTIC
- && fe->common.return_reference != proto->common.return_reference) {
- return 0;
+ && fe->common.return_reference != proto->common.return_reference) {
+ /* atm we cannot let internal function return by ref */
+ if (fe->type != ZEND_INTERNAL_FUNCTION && proto->type == ZEND_INTERNAL_FUNCTION) {
+ return 0;
+ }
}
for (i=0; i < proto->common.num_args; i++) {
@@ -2687,6 +2693,8 @@
{
zval *property;
zend_property_info *existing_property_info;
+ char *comment = NULL;
+ int comment_len = 0;
if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) {
zend_error(E_COMPILE_ERROR, "Interfaces may not include member variables");
@@ -2715,7 +2723,13 @@
property->type = IS_NULL;
}
- zend_declare_property(CG(active_class_entry), var_name->u.constant.value.str.val,
var_name->u.constant.value.str.len, property, access_type TSRMLS_CC);
+ if (CG(doc_comment)) {
+ comment = estrndup(CG(doc_comment), CG(doc_comment_len));
+ comment_len = CG(doc_comment_len);
+ RESET_DOC_COMMENT();
+ }
+
+ zend_declare_property_ex(CG(active_class_entry), var_name->u.constant.value.str.val,
var_name->u.constant.value.str.len, property, access_type, comment, comment_len TSRMLS_CC);
efree(var_name->u.constant.value.str.val);
}
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.302&r2=1.303&ty=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.302 ZendEngine2/zend_compile.h:1.303
--- ZendEngine2/zend_compile.h:1.302 Fri Feb 11 17:26:45 2005
+++ ZendEngine2/zend_compile.h Tue Apr 19 18:04:58 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.h,v 1.302 2005/02/11 22:26:45 helly Exp $ */
+/* $Id: zend_compile.h,v 1.303 2005/04/19 22:04:58 helly Exp $ */
#ifndef ZEND_COMPILE_H
#define ZEND_COMPILE_H
@@ -138,6 +138,8 @@
char *name;
int name_length;
ulong h;
+ char *doc_comment;
+ int doc_comment_len;
} zend_property_info;
http://cvs.php.net/diff.php/ZendEngine2/zend_reflection_api.c?r1=1.150&r2=1.151&ty=u
Index: ZendEngine2/zend_reflection_api.c
diff -u ZendEngine2/zend_reflection_api.c:1.150 ZendEngine2/zend_reflection_api.c:1.151
--- ZendEngine2/zend_reflection_api.c:1.150 Sun Mar 6 17:15:35 2005
+++ ZendEngine2/zend_reflection_api.c Tue Apr 19 18:04:59 2005
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_reflection_api.c,v 1.150 2005/03/06 22:15:35 helly Exp $ */
+/* $Id: zend_reflection_api.c,v 1.151 2005/04/19 22:04:59 helly Exp $ */
#include "zend.h"
#include "zend_API.h"
#include "zend_exceptions.h"
@@ -3455,6 +3455,21 @@
zend_reflection_class_factory(ref->ce, return_value TSRMLS_CC);
}
+/* {{{ proto public string ReflectionProperty::getDocComment()
+ Returns the doc comment for this property */
+ZEND_METHOD(reflection_property, getDocComment)
+{
+ reflection_object *intern;
+ property_reference *ref;
+
+ METHOD_NOTSTATIC_NUMPARAMS(0);
+ GET_REFLECTION_OBJECT_PTR(ref);
+ if (ref->prop->doc_comment) {
+ RETURN_STRINGL(ref->prop->doc_comment, ref->prop->doc_comment_len, 1);
+ }
+ RETURN_FALSE;
+}
+/* }}} */
/* {{{ proto public static mixed ReflectionExtension::export(string name [, bool return]) throws
ReflectionException
Exports a reflection object. Returns the output if TRUE is specified for return, printing it
otherwise. */
ZEND_METHOD(reflection_extension, export)
@@ -3814,6 +3829,7 @@
ZEND_ME(reflection_property, isDefault, NULL, 0)
ZEND_ME(reflection_property, getModifiers, NULL, 0)
ZEND_ME(reflection_property, getDeclaringClass, NULL, 0)
+ ZEND_ME(reflection_property, getDocComment, NULL, 0)
{NULL, NULL, NULL}
};