Skip to content

Commit

Permalink
fix build & controllers method noneed to be final now
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Sep 9, 2012
1 parent 5aa72a1 commit 70d9fd2
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 67 deletions.
4 changes: 3 additions & 1 deletion php_yaf.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: php_yaf.h 327524 2012-09-07 08:13:57Z laruence $ */
/* $Id: php_yaf.h 327561 2012-09-09 06:30:22Z laruence $ */

#ifndef PHP_YAF_H
#define PHP_YAF_H
Expand Down Expand Up @@ -52,6 +52,8 @@ extern zend_module_entry yaf_module_entry;
#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION > 2)) || (PHP_MAJOR_VERSION > 5)
#define YAF_HAVE_NAMESPACE
#else
#define Z_SET_REFCOUNT_P(pz, rc) (pz)->refcount = rc
#define Z_SET_REFCOUNT_PP(ppz, rc) Z_SET_REFCOUNT_P(*(ppz), rc)
#define Z_ADDREF_P ZVAL_ADDREF
#define Z_REFCOUNT_P ZVAL_REFCOUNT
#define Z_DELREF_P ZVAL_DELREF
Expand Down
39 changes: 22 additions & 17 deletions yaf_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: yaf_controller.c 327558 2012-09-09 05:59:24Z laruence $ */
/* $Id: yaf_controller.c 327561 2012-09-09 06:30:22Z laruence $ */

#ifdef HAVE_CONFIG_H
#include "config.h"
Expand Down Expand Up @@ -502,9 +502,14 @@ PHP_METHOD(yaf_controller, render) {
} else {
zval *output = yaf_controller_render(getThis(), action_name, action_name_len, var_array TSRMLS_CC);
if (output) {
ZVAL_STRINGL(return_value, Z_STRVAL_P(output), Z_STRLEN_P(output), 0);
efree(output);
return;
if (IS_STRING == Z_TYPE_P(output)) {
/* save a string copy here */
ZVAL_STRINGL(return_value, Z_STRVAL_P(output), Z_STRLEN_P(output), 0);
efree(output);
return;
} else {
RETURN_ZVAL(output, 1, 1);
}
} else {
RETURN_FALSE;
}
Expand Down Expand Up @@ -536,19 +541,19 @@ PHP_METHOD(yaf_controller, __clone) {
/** {{{ yaf_controller_methods
*/
zend_function_entry yaf_controller_methods[] = {
PHP_ME(yaf_controller, render, yaf_controller_render_arginfo, ZEND_ACC_PROTECTED|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, display, yaf_controller_display_arginfo, ZEND_ACC_PROTECTED|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, getRequest, yaf_controller_void_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, getResponse, yaf_controller_void_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, getModuleName,yaf_controller_void_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, getView, yaf_controller_void_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, initView, yaf_controller_initview_arginfo,ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, setViewpath, yaf_controller_setvdir_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, getViewpath, yaf_controller_void_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, forward, yaf_controller_forward_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, redirect, yaf_controller_redirect_arginfo,ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, getInvokeArgs,yaf_controller_void_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, getInvokeArg, yaf_controller_getiarg_arginfo,ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_controller, render, yaf_controller_render_arginfo, ZEND_ACC_PROTECTED)
PHP_ME(yaf_controller, display, yaf_controller_display_arginfo, ZEND_ACC_PROTECTED)
PHP_ME(yaf_controller, getRequest, yaf_controller_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, getResponse, yaf_controller_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, getModuleName,yaf_controller_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, getView, yaf_controller_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, initView, yaf_controller_initview_arginfo,ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, setViewpath, yaf_controller_setvdir_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, getViewpath, yaf_controller_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, forward, yaf_controller_forward_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, redirect, yaf_controller_redirect_arginfo,ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, getInvokeArgs,yaf_controller_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, getInvokeArg, yaf_controller_getiarg_arginfo,ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, __construct, NULL, ZEND_ACC_CTOR|ZEND_ACC_FINAL|ZEND_ACC_PUBLIC)
PHP_ME(yaf_controller, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
{NULL, NULL, NULL}
Expand Down
71 changes: 24 additions & 47 deletions yaf_dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: yaf_dispatcher.c 327558 2012-09-09 05:59:24Z laruence $ */
/* $Id: yaf_dispatcher.c 327561 2012-09-09 06:30:22Z laruence $ */

#ifdef HAVE_CONFIG_H
#include "config.h"
Expand Down Expand Up @@ -751,58 +751,35 @@ int yaf_dispatcher_handle(yaf_dispatcher_t *dispatcher, yaf_request_t *request,

if (auto_render) {
ret = NULL;
if (ce == yaf_controller_ce || ce == yaf_action_ce) {
if (!Z_BVAL_P(instantly_flush)) {
ret = yaf_controller_render(executor, Z_STRVAL_P(action), Z_STRLEN_P(action), NULL TSRMLS_CC);
zval_ptr_dtor(&executor);
if (!Z_BVAL_P(instantly_flush)) {
zend_call_method_with_1_params(&executor, ce, NULL, "render", &ret, action);
zval_ptr_dtor(&executor);

if (ret && Z_TYPE_P(ret) == IS_STRING && Z_STRLEN_P(ret)) {
yaf_response_alter_body(response, NULL, 0, Z_STRVAL_P(ret), Z_STRLEN_P(ret), YAF_RESPONSE_APPEND TSRMLS_CC);
zval_ptr_dtor(&ret);
} else if (ret) {
zval_ptr_dtor(&ret);
zval_ptr_dtor(&action);
if (ret) {
yaf_response_alter_body(response, NULL, 0, Z_STRVAL_P(ret), Z_STRLEN_P(ret), YAF_RESPONSE_APPEND TSRMLS_CC);
zval_ptr_dtor(&ret);
return 1;
}
return 0;
} else {
if (yaf_controller_display(executor, Z_STRVAL_P(action), Z_STRLEN_P(action), NULL TSRMLS_CC)) {
zval_ptr_dtor(&executor);
zval_ptr_dtor(&action);
return 1;
}
zval_ptr_dtor(&executor);
}
} else {
zend_call_method_with_1_params(&executor, ce, NULL, "display", &ret, action);
zval_ptr_dtor(&executor);

if (!ret) {
zval_ptr_dtor(&action);
return 0;
}
} else {
if (!Z_BVAL_P(instantly_flush)) {
zend_call_method_with_1_params(&executor, ce, NULL, "render", &ret, action);
zval_ptr_dtor(&executor);

if (ret && Z_TYPE_P(ret) == IS_STRING && Z_STRLEN_P(ret)) {
yaf_response_alter_body(response, NULL, 0, Z_STRVAL_P(ret), Z_STRLEN_P(ret), YAF_RESPONSE_APPEND TSRMLS_CC);
zval_ptr_dtor(&ret);
} else if (ret) {
zval_ptr_dtor(&ret);
zval_ptr_dtor(&action);
return 0;
}

if ((Z_TYPE_P(ret) == IS_BOOL && !Z_BVAL_P(ret))) {
zval_ptr_dtor(&ret);
zval_ptr_dtor(&action);
return 0;
} else {
zend_call_method_with_1_params(&executor, ce, NULL, "display", &ret, action);
zval_ptr_dtor(&executor);

if (!ret) {
zval_ptr_dtor(&action);
return 0;
}

if ((Z_TYPE_P(ret) == IS_BOOL && !Z_BVAL_P(ret))) {
zval_ptr_dtor(&ret);
zval_ptr_dtor(&action);
return 0;
} else {
zval_ptr_dtor(&ret);
zval_ptr_dtor(&action);
return 1;
}
zval_ptr_dtor(&ret);
zval_ptr_dtor(&action);
return 1;
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion yaf_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: yaf_loader.c 327558 2012-09-09 05:59:24Z laruence $ */
/* $Id: yaf_loader.c 327560 2012-09-09 06:09:27Z laruence $ */

#ifdef HAVE_CONFIG_H
#include "config.h"
Expand Down
2 changes: 1 addition & 1 deletion yaf_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: yaf_response.c 327510 2012-09-07 04:16:31Z laruence $ */
/* $Id: yaf_response.c 327560 2012-09-09 06:09:27Z laruence $ */

#ifdef HAVE_CONFIG_H
#include "config.h"
Expand Down

0 comments on commit 70d9fd2

Please sign in to comment.