Skip to content

Commit

Permalink
yaf_dispather some functions edit
Browse files Browse the repository at this point in the history
  • Loading branch information
zxcvdavid committed Sep 20, 2012
1 parent 79a3ce6 commit 0520214
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 20 deletions.
19 changes: 19 additions & 0 deletions tests/055.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
check for Yaf_Dispatcher::autoRender
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
--FILE--
<?php
define("APPLICATION_PATH", dirname(__FILE__));
$app = new Yaf_Application(APPLICATION_PATH . '/simple.ini');
Yaf_Dispatcher::getInstance()->autoRender(true);
var_dump(Yaf_Dispatcher::getInstance()->autoRender());
Yaf_Dispatcher::getInstance()->autoRender(false);
var_dump(Yaf_Dispatcher::getInstance()->autoRender());
?>
--EXPECTF--
bool(true)
bool(false)
19 changes: 19 additions & 0 deletions tests/056.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
check for Yaf_Dispatcher::throwException
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
--FILE--
<?php
define("APPLICATION_PATH", dirname(__FILE__));
$app = new Yaf_Application(APPLICATION_PATH . '/simple.ini');
Yaf_Dispatcher::getInstance()->throwException(true);
var_dump(Yaf_Dispatcher::getInstance()->throwException());
Yaf_Dispatcher::getInstance()->throwException(false);
var_dump(Yaf_Dispatcher::getInstance()->throwException());
?>
--EXPECTF--
bool(true)
bool(false)
19 changes: 19 additions & 0 deletions tests/057.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
check for Yaf_Dispatcher::catchException
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
--FILE--
<?php
define("APPLICATION_PATH", dirname(__FILE__));
$app = new Yaf_Application(APPLICATION_PATH . '/simple.ini');
Yaf_Dispatcher::getInstance()->catchException(true);
var_dump(Yaf_Dispatcher::getInstance()->catchException());
Yaf_Dispatcher::getInstance()->catchException(false);
var_dump(Yaf_Dispatcher::getInstance()->catchException());
?>
--EXPECTF--
bool(true)
bool(false)
19 changes: 19 additions & 0 deletions tests/058.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
check for Yaf_Dispatcher::flushInstantly
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
--FILE--
<?php
define("APPLICATION_PATH", dirname(__FILE__));
$app = new Yaf_Application(APPLICATION_PATH . '/simple.ini');
Yaf_Dispatcher::getInstance()->flushInstantly(true);
var_dump(Yaf_Dispatcher::getInstance()->flushInstantly());
Yaf_Dispatcher::getInstance()->flushInstantly(false);
var_dump(Yaf_Dispatcher::getInstance()->flushInstantly());
?>
--EXPECTF--
bool(true)
bool(false)
54 changes: 34 additions & 20 deletions yaf_dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,16 +1046,19 @@ PHP_METHOD(yaf_dispatcher, returnResponse) {
/** {{{ proto public Yaf_Dispatcher::flushInstantly(bool $flag)
*/
PHP_METHOD(yaf_dispatcher, flushInstantly) {
long instantly_flush;
zend_bool instantly_flush;
yaf_dispatcher_t *self = getThis();

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &instantly_flush) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &instantly_flush) == FAILURE) {
return;
}

zend_update_property_bool(yaf_dispatcher_ce, self, ZEND_STRL(YAF_DISPATCHER_PROPERTY_NAME_FLUSH), (instantly_flush)? 1:0 TSRMLS_CC);

RETURN_ZVAL(self, 1, 0);
if (ZEND_NUM_ARGS() != 0) {
zend_update_property_bool(yaf_dispatcher_ce, self, ZEND_STRL(YAF_DISPATCHER_PROPERTY_NAME_FLUSH), (instantly_flush)? 1:0 TSRMLS_CC);
RETURN_ZVAL(self, 1, 0);
} else {
RETURN_BOOL(Z_BVAL_P(zend_read_property(yaf_dispatcher_ce, self, ZEND_STRL(YAF_DISPATCHER_PROPERTY_NAME_FLUSH), 1 TSRMLS_CC)));
}
}
/* }}} */

Expand Down Expand Up @@ -1163,42 +1166,53 @@ PHP_METHOD(yaf_dispatcher, dispatch) {
/** {{{ proto public Yaf_Dispatcher::throwException(bool $flag=0)
*/
PHP_METHOD(yaf_dispatcher, throwException) {
int flag;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) {
zend_bool flag;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &flag) == FAILURE) {
return;
}

YAF_G(throw_exception) = flag? 1: 0;
RETURN_ZVAL(getThis(), 1, 0);
if (ZEND_NUM_ARGS() != 0) {
YAF_G(throw_exception) = flag? 1: 0;
RETURN_ZVAL(getThis(), 1, 0);
} else {
RETURN_BOOL(YAF_G(throw_exception));
}
}
/* }}} */

/** {{{ proto public Yaf_Dispatcher::catchException(bool $flag=0)
*/
PHP_METHOD(yaf_dispatcher, catchException) {
int flag;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) {
zend_bool flag;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &flag) == FAILURE) {
return;
}

YAF_G(catch_exception) = flag? 1: 0;
RETURN_ZVAL(getThis(), 1, 0);
if (ZEND_NUM_ARGS() != 0) {
YAF_G(catch_exception) = flag? 1: 0;
RETURN_ZVAL(getThis(), 1, 0);
} else {
RETURN_BOOL(YAF_G(catch_exception));
}
}
/* }}} */

/** {{{ proto public Yaf_Dispatcher::autoRender(int $flag)
*/
PHP_METHOD(yaf_dispatcher, autoRender) {
long flag;
yaf_dispatcher_t *self = getThis();
zend_bool flag;
yaf_dispatcher_t *self = getThis();

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &flag) == FAILURE) {
return;
}

zend_update_property_bool(yaf_dispatcher_ce, self, ZEND_STRL(YAF_DISPATCHER_PROPERTY_NAME_RENDER), flag? 1 : 0 TSRMLS_CC);
}

RETURN_ZVAL(self, 1, 0);
if (ZEND_NUM_ARGS() != 0) {
zend_update_property_bool(yaf_dispatcher_ce, self, ZEND_STRL(YAF_DISPATCHER_PROPERTY_NAME_RENDER), flag? 1 : 0 TSRMLS_CC);
RETURN_ZVAL(self, 1, 0);
} else {
RETURN_BOOL(Z_BVAL_P(zend_read_property(yaf_dispatcher_ce, self, ZEND_STRL(YAF_DISPATCHER_PROPERTY_NAME_RENDER), 1 TSRMLS_CC)));
}
}
/* }}} */

Expand Down

0 comments on commit 0520214

Please sign in to comment.