Пример #1
0
PHP_METHOD(Test_Fibonnaci, fibonacciFinalRecursive) {

	zval *n_param = NULL, *_0, _1 = zval_used_for_init, *_2;
	int n;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &n_param);

		n = zephir_get_intval(n_param);


	if ((n == 0)) {
		RETURN_MM_LONG(0);
	} else {
		if ((n == 1)) {
			RETURN_MM_LONG(1);
		} else {
			ZEPHIR_INIT_VAR(_0);
			ZEPHIR_SINIT_VAR(_1);
			ZVAL_LONG(&_1, (n - 1));
			zephir_call_internal_method_p1(_0, this_ptr, "fibonaccifinalrecursive", ZEND_MN(Test_Fibonnaci_fibonacciFinalRecursive), &_1);
			ZEPHIR_INIT_VAR(_2);
			ZEPHIR_SINIT_NVAR(_1);
			ZVAL_LONG(&_1, (n - 2));
			zephir_call_internal_method_p1(_2, this_ptr, "fibonaccifinalrecursive", ZEND_MN(Test_Fibonnaci_fibonacciFinalRecursive), &_1);
			zephir_add_function(return_value, _0, _2 TSRMLS_CC);
			RETURN_MM();
		}
	}
	ZEPHIR_MM_RESTORE();

}
Пример #2
0
ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object) /* {{{ */
{
	zend_closure *closure = (zend_closure *)object;
	zend_function *invoke = (zend_function*)emalloc(sizeof(zend_function));
	const uint32_t keep_flags =
		ZEND_ACC_RETURN_REFERENCE | ZEND_ACC_VARIADIC | ZEND_ACC_HAS_RETURN_TYPE;

	invoke->common = closure->func.common;
	/* We return ZEND_INTERNAL_FUNCTION, but arg_info representation is the
	 * same as for ZEND_USER_FUNCTION (uses zend_string* instead of char*).
	 * This is not a problem, because ZEND_ACC_HAS_TYPE_HINTS is never set,
	 * and we won't check arguments on internal function. We also set
	 * ZEND_ACC_USER_ARG_INFO flag to prevent invalid usage by Reflection */
	invoke->type = ZEND_INTERNAL_FUNCTION;
	invoke->internal_function.fn_flags =
		ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | (closure->func.common.fn_flags & keep_flags);
	if (closure->func.type != ZEND_INTERNAL_FUNCTION || (closure->func.common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
		invoke->internal_function.fn_flags |=
			ZEND_ACC_USER_ARG_INFO;
	}
	invoke->internal_function.handler = ZEND_MN(Closure___invoke);
	invoke->internal_function.module = 0;
	invoke->internal_function.scope = zend_ce_closure;
	invoke->internal_function.function_name = ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE);
	return invoke;
}
Пример #3
0
ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object) /* {{{ */
{
	zend_closure *closure = (zend_closure *)object;
	zend_function *invoke = (zend_function*)emalloc(sizeof(zend_function));

	invoke->common = closure->func.common;
	/* TODO: return ZEND_INTERNAL_FUNCTION, but arg_info representation is suitable for ZEND_USER_FUNCTION ??? */
	invoke->type = ZEND_INTERNAL_FUNCTION;
	invoke->internal_function.fn_flags = ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | (closure->func.common.fn_flags & ZEND_ACC_RETURN_REFERENCE);
	invoke->internal_function.handler = ZEND_MN(Closure___invoke);
	invoke->internal_function.module = 0;
	invoke->internal_function.scope = zend_ce_closure;
	invoke->internal_function.function_name = zend_string_init(ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1, 0);
	return invoke;
}
Пример #4
0
/* #include "msgpacki_debug.h" */

#define FILTER_FUNC "MessagePack filter"

ZEND_EXTERN_MODULE_GLOBALS(msgpacki);

static zend_class_entry *msgpacki_ce_filter;

ZEND_METHOD(MSGPACKI_FILTER_CLASS_NAME, nop) {}

ZEND_BEGIN_ARG_INFO_EX(arginfo_msgpacki_filter, 0, 0, 1)
    ZEND_ARG_INFO(0, in)
ZEND_END_ARG_INFO()

MSGPACKI_ZEND_FUNCTION_ENTRY msgpacki_filter_methods[] = {
    ZEND_FENTRY(pre_serialize, ZEND_MN(MSGPACKI_FILTER_CLASS_NAME_nop),
                arginfo_msgpacki_filter, ZEND_ACC_PUBLIC)
    ZEND_FENTRY(post_serialize, ZEND_MN(MSGPACKI_FILTER_CLASS_NAME_nop),
                arginfo_msgpacki_filter, ZEND_ACC_PUBLIC)
    ZEND_FENTRY(pre_unserialize, ZEND_MN(MSGPACKI_FILTER_CLASS_NAME_nop),
                arginfo_msgpacki_filter, ZEND_ACC_PUBLIC)
    ZEND_FENTRY(post_unserialize, ZEND_MN(MSGPACKI_FILTER_CLASS_NAME_nop),
                arginfo_msgpacki_filter, ZEND_ACC_PUBLIC)
    ZEND_FE_END
};

PHP_MSGPACKI_API void
msgpacki_filter_data_dtor(msgpacki_filter_data_t *data)
{
    if (data) {
        if (data->object) {