Skip to content

Commit

Permalink
Finished implementation of CASE/WHEN/ELSE in PHQL #651
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutierrez committed Jun 5, 2015
1 parent e4c390d commit 503274b
Show file tree
Hide file tree
Showing 208 changed files with 1,517 additions and 5,205 deletions.
113 changes: 82 additions & 31 deletions ext/kernel/fcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,134 +192,185 @@ typedef enum _zephir_call_type {

#define ZEPHIR_RETURN_CALL_INTERNAL_METHOD_P0(object, method) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
zval *old_this_ptr = this_ptr; \
EG(This) = object; \
method(0, return_value, return_value_ptr, object, 1 TSRMLS_CC); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
EG(This) = old_this_ptr; \
} while (0)

#define ZEPHIR_RETURN_CALL_INTERNAL_METHOD_P1(object, method, p1) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
zval *old_this_ptr = this_ptr; \
EG(This) = object; \
Z_ADDREF_P(p1); \
method(0, return_value, return_value_ptr, object, 1, p1 TSRMLS_CC); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
Z_DELREF_P(p1); \
EG(This) = old_this_ptr; \
} while (0)


#define ZEPHIR_RETURN_CALL_INTERNAL_METHOD_P2(object, method, p1, p2) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
zval *old_this_ptr = this_ptr; \
EG(This) = object; \
Z_ADDREF_P(p1); \
Z_ADDREF_P(p2); \
method(0, return_value, return_value_ptr, object, 1, p1, p2 TSRMLS_CC); \
Z_DELREF_P(p1); \
Z_DELREF_P(p2); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
EG(This) = old_this_ptr; \
} while (0)

#define ZEPHIR_RETURN_CALL_INTERNAL_METHOD_P3(object, method, p1, p2, p3) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
zval *old_this_ptr = this_ptr; \
EG(This) = object; \
Z_ADDREF_P(p1); \
Z_ADDREF_P(p2); \
Z_ADDREF_P(p3); \
method(0, return_value, return_value_ptr, object, 1, p1, p2, p3 TSRMLS_CC); \
Z_DELREF_P(p1); \
Z_DELREF_P(p2); \
Z_DELREF_P(p3); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
EG(This) = old_this_ptr; \
} while (0)

#define ZEPHIR_RETURN_CALL_INTERNAL_METHOD_P4(object, method, p1, p2, p3, p4) \
do { \
zval *old_this_ptr = this_ptr; \
EG(This) = object; \
Z_ADDREF_P(p1); \
Z_ADDREF_P(p2); \
Z_ADDREF_P(p3); \
Z_ADDREF_P(p4); \
method(0, return_value, return_value_ptr, object, 1, p1, p2, p3 TSRMLS_CC); \
Z_DELREF_P(p1); \
Z_DELREF_P(p2); \
Z_DELREF_P(p3); \
Z_DELREF_P(p4); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = old_this_ptr; \
} while (0)

/**
* Call a internal method using a local return value ptr, since the return value isn't used
*/
#define ZEPHIR_CALL_INTERNAL_METHOD_NORETURN_P0(object, method) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
zval *old_this_ptr = this_ptr; \
zval *rv = NULL; \
zval **rvp = &rv; \
ALLOC_INIT_ZVAL(rv); \
EG(This) = object; \
method(0, rv, rvp, object, 0 TSRMLS_CC); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
EG(This) = old_this_ptr; \
zval_ptr_dtor(rvp); \
} while (0)

#define ZEPHIR_CALL_INTERNAL_METHOD_NORETURN_P1(object, method, p1) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
zval *old_this_ptr = this_ptr; \
zval *rv = NULL; \
zval **rvp = &rv; \
ALLOC_INIT_ZVAL(rv); \
EG(This) = object; \
Z_ADDREF_P(p1); \
method(0, rv, rvp, object, 0, p1 TSRMLS_CC); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
Z_DELREF_P(p1); \
EG(This) = old_this_ptr; \
zval_ptr_dtor(rvp); \
} while (0)

#define ZEPHIR_CALL_INTERNAL_METHOD_NORETURN_P2(object, method, p1, p2) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
zval *old_this_ptr = this_ptr; \
zval *rv = NULL; \
zval **rvp = &rv; \
ALLOC_INIT_ZVAL(rv); \
EG(This) = object; \
Z_ADDREF_P(p1); \
Z_ADDREF_P(p2); \
method(0, rv, rvp, object, 0, p1, p2 TSRMLS_CC); \
Z_DELREF_P(p1); \
Z_DELREF_P(p2); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
EG(This) = old_this_ptr; \
zval_ptr_dtor(rvp); \
} while (0)

#define ZEPHIR_CALL_INTERNAL_METHOD_NORETURN_P3(object, method, p1, p2, p3) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
zval *old_this_ptr = this_ptr; \
zval *rv = NULL; \
zval **rvp = &rv; \
ALLOC_INIT_ZVAL(rv); \
EG(This) = object; \
Z_ADDREF_P(p1); \
Z_ADDREF_P(p2); \
Z_ADDREF_P(p3); \
method(0, rv, rvp, object, 0, p1, p2, p3 TSRMLS_CC); \
Z_DELREF_P(p1); \
Z_DELREF_P(p2); \
Z_DELREF_P(p3); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
EG(This) = old_this_ptr; \
zval_ptr_dtor(rvp); \
} while (0)

#define ZEPHIR_CALL_INTERNAL_METHOD_P0(return_value_ptr, object, method) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
EG(This) = object; \
ZEPHIR_INIT_NVAR(*return_value_ptr); \
method(0, *return_value_ptr, return_value_ptr, object, 1 TSRMLS_CC); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
} while (0)
do { \
zval *old_this_ptr = this_ptr; \
EG(This) = object; \
ZEPHIR_INIT_NVAR(*return_value_ptr); \
method(0, *return_value_ptr, return_value_ptr, object, 1 TSRMLS_CC); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = old_this_ptr; \
} while (0)

#define ZEPHIR_CALL_INTERNAL_METHOD_P1(return_value_ptr, object, method, p1) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
zval *old_this_ptr = this_ptr; \
EG(This) = object; \
ZEPHIR_INIT_NVAR(*return_value_ptr); \
Z_ADDREF_P(p1); \
method(0, *return_value_ptr, return_value_ptr, object, 1, p1 TSRMLS_CC); \
Z_DELREF_P(p1); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
EG(This) = old_this_ptr; \
} while (0)

#define ZEPHIR_CALL_INTERNAL_METHOD_P2(return_value_ptr, object, method, p1, p2) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
zval *old_this_ptr = this_ptr; \
EG(This) = object; \
ZEPHIR_INIT_NVAR(*return_value_ptr); \
Z_ADDREF_P(p1); \
method(0, *return_value_ptr, return_value_ptr, object, 1, p1, p2 TSRMLS_CC); \
Z_DELREF_P(p1); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
EG(This) = old_this_ptr; \
} while (0)

#define ZEPHIR_CALL_INTERNAL_METHOD_P3(return_value_ptr, object, method, p1, p2, p3) \
do { \
zval *ZEPHIR_OLD_THIS_PTR = this_ptr; \
zval *old_this_ptr = this_ptr; \
EG(This) = object; \
ZEPHIR_INIT_NVAR(*return_value_ptr); \
Z_ADDREF_P(p1); \
Z_ADDREF_P(p2); \
Z_ADDREF_P(p3); \
method(0, *return_value_ptr, return_value_ptr, object, 1, p1, p2, p3 TSRMLS_CC); \
Z_DELREF_P(p1); \
Z_DELREF_P(p2); \
Z_DELREF_P(p3); \
ZEPHIR_LAST_CALL_STATUS = EG(exception) ? FAILURE : SUCCESS; \
EG(This) = ZEPHIR_OLD_THIS_PTR; \
EG(This) = old_this_ptr; \
} while (0)

#define ZEPHIR_CALL_METHODW(return_value_ptr, object, method, cache, cache_slot, ...) \
Expand Down
21 changes: 0 additions & 21 deletions ext/phalcon/acl/adapter/memory.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 503274b

Please sign in to comment.