Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/reflection php_reflection.c /ext/reflection/tests ReflectionFunction_getNamespaceName.phpt reflectionClass_getNamespaceName.phpt
Thank you very much! Am Mittwoch, den 25.06.2008, 12:33 + schrieb Dmitry Stogov: > dmitryWed Jun 25 12:33:46 2008 UTC > > Added files: (Branch: PHP_5_3) > /php-src/ext/reflection/tests > > ReflectionFunction_getNamespaceName.phpt > reflectionClass_getNamespaceName.phpt > > Modified files: > /php-src/ext/reflection php_reflection.c > Log: > Added support for namespaces > > > http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.45.2.16&r2=1.164.2.33.2.45.2.17&diff_format=u > Index: php-src/ext/reflection/php_reflection.c > diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.16 > php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.17 > --- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.16 Sat Jun > 21 02:41:27 2008 > +++ php-src/ext/reflection/php_reflection.c Wed Jun 25 12:33:46 2008 > @@ -20,7 +20,7 @@ > +--+ > */ > > -/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.16 2008/06/21 02:41:27 felipe > Exp $ */ > +/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.17 2008/06/25 12:33:46 dmitry > Exp $ */ > > #ifdef HAVE_CONFIG_H > #include "config.h" > @@ -2550,6 +2550,66 @@ > } > /* }}} */ > > +/* {{{ proto public bool ReflectionFunction::inNamespace() > + Returns whether this function is defined in namespace */ > +ZEND_METHOD(reflection_function, inNamespace) > +{ > + zval **name; > + char *colon; > + > + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); > + if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), > (void **) &name) == FAILURE) { > + RETURN_FALSE; > + } > + if (Z_TYPE_PP(name) == IS_STRING && > + (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && > + colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { > + RETURN_TRUE; > +} > + RETURN_FALSE; > +} > +/* }}} */ > + > +/* {{{ proto public string ReflectionFunction::getNamespaceName() > + Returns the name of namespace where this function is defined */ > +ZEND_METHOD(reflection_function, getNamespaceName) > +{ > + zval **name; > + char *colon; > + > + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); > + if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), > (void **) &name) == FAILURE) { > + RETURN_FALSE; > + } > + if (Z_TYPE_PP(name) == IS_STRING && > + (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && > + colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { > + RETURN_STRINGL(Z_STRVAL_PP(name), colon - Z_STRVAL_PP(name) - > 1, 1); > +} > + RETURN_EMPTY_STRING(); > +} > +/* }}} */ > + > +/* {{{ proto public string ReflectionFunction::getShortName() > + Returns the short name of the function (without namespace part) */ > +ZEND_METHOD(reflection_function, getShortName) > +{ > + zval **name; > + char *colon; > + > + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); > + if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), > (void **) &name) == FAILURE) { > + RETURN_FALSE; > + } > + if (Z_TYPE_PP(name) == IS_STRING && > + (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && > + colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { > + RETURN_STRINGL(colon + 1, Z_STRLEN_PP(name) - (colon - > Z_STRVAL_PP(name) + 1), 1); > +} > +RETURN_ZVAL(*name, 1, 0); > +} > +/* }}} */ > + > /* {{{ proto public bool ReflectionMethod::isConstructor() > Returns whether this method is the constructor */ > ZEND_METHOD(reflection_method, isConstructor) > @@ -3760,6 +3820,66 @@ > } > /* }}} */ > > +/* {{{ proto public bool ReflectionClass::inNamespace() > + Returns whether this class is defined in namespace */ > +ZEND_METHOD(reflection_class, inNamespace) > +{ > + zval **name; > + char *colon; > + > + METHOD_NOTSTATIC_NUMPARAMS(reflection_class_ptr, 0); > + if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), > (void **) &name) == FAILURE) { > + RETURN_FALSE; > + } > + if (Z_TYPE_PP(name) == IS_STRING && > + (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && > + colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { > + RETURN_TRUE; > +} > + RETURN_FALSE; > +} > +/* }}} */ > + > +/* {{{ proto public string ReflectionClass::getNamespaceName() > + Returns the name of namespace where this class is defined */ > +ZEND_METHOD(reflection_class, getNamespaceName) > +{ > + zval **name; > + char *colon; > + > + METHOD_NOTSTATIC_NUMPARAMS(reflection_class_ptr, 0); > + if (zend_hash_find(Z_OBJPROP_P(getThis
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/reflection php_reflection.c /ext/reflection/tests ReflectionFunction_getNamespaceName.phpt reflectionClass_getNamespaceName.phpt
dmitry Wed Jun 25 12:33:46 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/reflection/tests ReflectionFunction_getNamespaceName.phpt reflectionClass_getNamespaceName.phpt Modified files: /php-src/ext/reflection php_reflection.c Log: Added support for namespaces http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.45.2.16&r2=1.164.2.33.2.45.2.17&diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.16 php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.17 --- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.16Sat Jun 21 02:41:27 2008 +++ php-src/ext/reflection/php_reflection.c Wed Jun 25 12:33:46 2008 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.16 2008/06/21 02:41:27 felipe Exp $ */ +/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.17 2008/06/25 12:33:46 dmitry Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -2550,6 +2550,66 @@ } /* }}} */ +/* {{{ proto public bool ReflectionFunction::inNamespace() + Returns whether this function is defined in namespace */ +ZEND_METHOD(reflection_function, inNamespace) +{ + zval **name; + char *colon; + + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); + if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) { + RETURN_FALSE; + } + if (Z_TYPE_PP(name) == IS_STRING && + (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && + colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { + RETURN_TRUE; +} + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto public string ReflectionFunction::getNamespaceName() + Returns the name of namespace where this function is defined */ +ZEND_METHOD(reflection_function, getNamespaceName) +{ + zval **name; + char *colon; + + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); + if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) { + RETURN_FALSE; + } + if (Z_TYPE_PP(name) == IS_STRING && + (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && + colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { + RETURN_STRINGL(Z_STRVAL_PP(name), colon - Z_STRVAL_PP(name) - 1, 1); +} + RETURN_EMPTY_STRING(); +} +/* }}} */ + +/* {{{ proto public string ReflectionFunction::getShortName() + Returns the short name of the function (without namespace part) */ +ZEND_METHOD(reflection_function, getShortName) +{ + zval **name; + char *colon; + + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); + if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) { + RETURN_FALSE; + } + if (Z_TYPE_PP(name) == IS_STRING && + (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && + colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { + RETURN_STRINGL(colon + 1, Z_STRLEN_PP(name) - (colon - Z_STRVAL_PP(name) + 1), 1); +} +RETURN_ZVAL(*name, 1, 0); +} +/* }}} */ + /* {{{ proto public bool ReflectionMethod::isConstructor() Returns whether this method is the constructor */ ZEND_METHOD(reflection_method, isConstructor) @@ -3760,6 +3820,66 @@ } /* }}} */ +/* {{{ proto public bool ReflectionClass::inNamespace() + Returns whether this class is defined in namespace */ +ZEND_METHOD(reflection_class, inNamespace) +{ + zval **name; + char *colon; + + METHOD_NOTSTATIC_NUMPARAMS(reflection_class_ptr, 0); + if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) { + RETURN_FALSE; + } + if (Z_TYPE_PP(name) == IS_STRING && + (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && + colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { + RETURN_TRUE; +} + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto public string ReflectionClass::getNamespaceName() + Returns the name of namespace where this class is defined */ +ZEND_METHOD(reflection_class, getNamespaceName) +{ + zval **name; + char *colon; + + METHOD_NOTSTATIC_NUMPARAMS(reflection_class_ptr, 0); + if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) { + RETURN_FALSE; + } + if (Z_TYPE_PP(name) == IS_STRING && + (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && + colon > Z_STRVAL_PP(name