logo       

cvs: ZendEngine2 / zend_reflection_api.c: msg#00046

Subject: cvs: ZendEngine2 / zend_reflection_api.c
helly           Thu Aug 19 03:42:04 2004 EDT

  Modified files:              
    /ZendEngine2        zend_reflection_api.c 
  Log:
  - Implement #29728: Reflection API Feature: Default parameter value.
    . ReflectionParameter::isDefaultValueAvailable()
    . ReflectionParameter::getDefaultValue()
  
  
http://cvs.php.net/diff.php/ZendEngine2/zend_reflection_api.c?r1=1.122&r2=1.123&ty=u
Index: ZendEngine2/zend_reflection_api.c
diff -u ZendEngine2/zend_reflection_api.c:1.122 
ZendEngine2/zend_reflection_api.c:1.123
--- ZendEngine2/zend_reflection_api.c:1.122     Thu Aug 19 03:16:02 2004
+++ ZendEngine2/zend_reflection_api.c   Thu Aug 19 03:42:02 2004
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_reflection_api.c,v 1.122 2004/08/19 07:16:02 helly Exp $ */
+/* $Id: zend_reflection_api.c,v 1.123 2004/08/19 07:42:02 helly Exp $ */
 #include "zend.h"
 #include "zend_API.h"
 #include "zend_exceptions.h"
@@ -1680,6 +1680,66 @@
 }
 /* }}} */
 
+/* {{{ proto public bool ReflectionParameter::isDefaultValueAvailable()
+   Returns whether the default value of this parameter is available */
+ZEND_METHOD(reflection_parameter, isDefaultValueAvailable)
+{
+       reflection_object *intern;
+       parameter_reference *param;
+       zend_op *precv;
+
+       METHOD_NOTSTATIC_NUMPARAMS(0);
+       GET_REFLECTION_OBJECT_PTR(param);
+
+       if (param->fptr->type != ZEND_USER_FUNCTION)
+       {
+               RETURN_FALSE;
+       }
+       if (param->offset < param->required) {
+               RETURN_FALSE;
+       }
+       precv = &((zend_op_array*)param->fptr)->opcodes[param->offset*2 + 1];
+       if (precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) 
{
+               RETURN_FALSE;
+       }
+       RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto public bool ReflectionParameter::getDefaultValue()
+   Returns the default value of this parameter or throws an exception */
+ZEND_METHOD(reflection_parameter, getDefaultValue)
+{
+       reflection_object *intern;
+       parameter_reference *param;
+       zend_op *precv;
+       zval *zv, zv_copy;
+
+       METHOD_NOTSTATIC_NUMPARAMS(0);
+       GET_REFLECTION_OBJECT_PTR(param);
+
+       if (param->fptr->type != ZEND_USER_FUNCTION)
+       {
+               zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, 
"Cannot determine default value for internal functions");
+               return;
+       }
+       if (param->offset < param->required) {
+               zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, 
"Parameter is not optional"); 
+               return;
+       }
+       precv = &((zend_op_array*)param->fptr)->opcodes[param->offset*2 + 1];
+       if (precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) 
{
+               zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, 
"Internal error"); 
+               return;
+       }
+
+       zv_copy = precv->op2.u.constant;
+       zv = &zv_copy;
+       zval_update_constant(&zv, (void*)1 TSRMLS_CC);
+       RETURN_ZVAL(zv, 1, 1);
+}
+/* }}} */
+
 /* {{{ proto public static mixed ReflectionMethod::export(mixed class, 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_method, export)
@@ -3419,6 +3479,8 @@
        ZEND_ME(reflection_parameter, getClass, NULL, 0)
        ZEND_ME(reflection_parameter, allowsNull, NULL, 0)
        ZEND_ME(reflection_parameter, isOptional, NULL, 0)
+       ZEND_ME(reflection_parameter, isDefaultValueAvailable, NULL, 0)
+       ZEND_ME(reflection_parameter, getDefaultValue, NULL, 0)
        {NULL, NULL, NULL}
 };
 

-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe