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;
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;
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)
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);
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);
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);
+ }
}
}
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);
}
}
}
}
- 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;
}
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;
}
}
{
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) {
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;
}
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);
#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;
zstr name;
int name_length;
ulong h;
- char *doc_comment;
+ zstr doc_comment;
int doc_comment_len;
zend_class_entry *ce;
} zend_property_info;
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];
zend_uint access_type;
- char *doc_comment;
+ zstr doc_comment;
zend_uint doc_comment_len;
zend_uchar literal_type;
{
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;
}
<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;
}
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);
}
* 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);
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;
}
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;
}
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;
}