[prev in list] [next in list] [prev in thread] [next in thread]
List: pecl-cvs
Subject: [PECL-CVS] cvs: pecl /classkit classkit.c php_classkit.h
From: "Sara Golemon" <pollita () php ! net>
Date: 2004-08-26 3:54:07
Message-ID: cvspollita1093492447 () cvsserver
[Download RAW message or body]
pollita Wed Aug 25 23:54:07 2004 EDT
Modified files:
/pecl/classkit classkit.c php_classkit.h
Log:
Add classkit_doc_comments(). Reflection style function... ZE2 only
http://cvs.php.net/diff.php/pecl/classkit/classkit.c?r1=1.9&r2=1.10&ty=u
Index: pecl/classkit/classkit.c
diff -u pecl/classkit/classkit.c:1.9 pecl/classkit/classkit.c:1.10
--- pecl/classkit/classkit.c:1.9 Wed Aug 25 20:57:58 2004
+++ pecl/classkit/classkit.c Wed Aug 25 23:54:07 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: classkit.c,v 1.9 2004/08/26 00:57:58 pollita Exp $ */
+/* $Id: classkit.c,v 1.10 2004/08/26 03:54:07 pollita Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -28,7 +28,7 @@
#include "php_classkit.h"
/* Generic Constants */
-#define CLASSKIT_VERSION "0.3"
+#define CLASSKIT_VERSION "0.4"
/* Aggregation Flags */
#define CLASSKIT_AGGREGATE_OVERRIDE 0x0001
@@ -45,6 +45,9 @@
PHP_FE(classkit_method_copy, NULL)
PHP_FE(classkit_aggregate_methods, NULL)
PHP_FE(classkit_import, NULL)
+#ifdef ZEND_ENGINE_2
+ PHP_FE(classkit_doc_comments, NULL)
+#endif
{NULL, NULL, NULL}
};
/* }}} */
@@ -1055,6 +1058,64 @@
}
/* }}} */
+
+#ifdef ZEND_ENGINE_2
+/* {{{ proto mixed classkit_doc_comments(string classname[, string methodname])
+ Returns doc_comments associated with a user defined class
+ Without methodname, it will return an array: 0=>class_comments, \
'methodname'=>method_comments, 'methodname'=>method_comments, ... + With methodname \
passed as '' returns class's comments as a string + With methodname passed as any \
other string returns that method's comments as a string */ \
+PHP_FUNCTION(classkit_doc_comments) +{
+ char *classname, *methodname = NULL, *key;
+ int classname_len, methodname_len = -1;
+ long idx;
+ zend_class_entry *ce;
+ zend_function *fe;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &classname, \
&classname_len, &methodname, &methodname_len) == FAILURE) { + RETURN_FALSE;
+ }
+
+ if (methodname_len > 0) {
+ if (php_classkit_fetch_class_method(classname, classname_len, methodname, \
methodname_len, &ce, &fe TSRMLS_CC) == FAILURE) { + RETURN_FALSE;
+ }
+ if (fe->op_array.doc_comment) {
+ RETURN_STRINGL(fe->op_array.doc_comment, fe->op_array.doc_comment_len, 1);
+ }
+ RETURN_STRINGL("", 0, 1);
+ }
+
+ if (php_classkit_fetch_class(classname, classname_len, &ce TSRMLS_CC) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (methodname_len == 0) {
+ if (ce->doc_comment) {
+ RETURN_STRINGL(ce->doc_comment, ce->doc_comment_len, 1);
+ }
+ RETURN_STRINGL("", 0, 1);
+ }
+
+ array_init(return_value);
+ if (ce->doc_comment) {
+ add_index_stringl(return_value, 0, ce->doc_comment, ce->doc_comment_len, 1);
+ }
+ zend_hash_internal_pointer_reset(&ce->function_table);
+ while (zend_hash_get_current_data(&ce->function_table, (void**)&fe) == SUCCESS) {
+ if (fe->op_array.doc_comment) {
+ if (zend_hash_get_current_key(&ce->function_table, &key, &idx, 0) == \
HASH_KEY_IS_STRING) { + add_assoc_stringl(return_value, key, \
fe->op_array.doc_comment, fe->op_array.doc_comment_len, 1); + } else {
+ add_assoc_stringl(return_value, fe->common.function_name, \
fe->op_array.doc_comment, fe->op_array.doc_comment_len, 1); + }
+ }
+ zend_hash_move_forward(&ce->function_table);
+ }
+}
+/* }}} */
+#endif
/* {{{ PHP_MINIT_FUNCTION
*/
http://cvs.php.net/diff.php/pecl/classkit/php_classkit.h?r1=1.4&r2=1.5&ty=u
Index: pecl/classkit/php_classkit.h
diff -u pecl/classkit/php_classkit.h:1.4 pecl/classkit/php_classkit.h:1.5
--- pecl/classkit/php_classkit.h:1.4 Wed Aug 25 20:57:58 2004
+++ pecl/classkit/php_classkit.h Wed Aug 25 23:54:07 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_classkit.h,v 1.4 2004/08/26 00:57:58 pollita Exp $ */
+/* $Id: php_classkit.h,v 1.5 2004/08/26 03:54:07 pollita Exp $ */
#ifndef PHP_CLASSKIT_H
#define PHP_CLASSKIT_H
@@ -34,6 +34,9 @@
PHP_FUNCTION(classkit_method_copy);
PHP_FUNCTION(classkit_aggregate_methods);
PHP_FUNCTION(classkit_import);
+#ifdef ZEND_ENGINE_2
+PHP_FUNCTION(classkit_doc_comments);
+#endif
#endif /* PHP_CLASSKIT_H */
--
PECL CVS Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic