SKYRAY_METHOD(HttpRequest, setMethod) { zend_string *name; int i; if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) { return; } skyray_http_request_t *intern = skyray_http_request_from_obj(Z_OBJ_P(getThis())); for (i = 0; i < SR_HTTP_METHOD_LAST; i ++) { if (strcasecmp(name->val, SR_HTTP_METHOD_GET_NAME(i)) == 0) { intern->method = i; break; } } RETURN_ZVAL(getThis(), 1, 0); }
PHP_METHOD(Test_Strings, testExplodeStr) { zval *str, str_sub; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&str_sub); zephir_fetch_params(0, 1, 0, &str); zephir_fast_explode_str(return_value, SL(","), str, LONG_MAX TSRMLS_CC); return; }
PHP_METHOD(Test_Flow, testIf8) { int a = 0; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; a = 0; if (a) { RETURN_LONG(1); } else { RETURN_LONG(0); } }
PHP_METHOD(Test_Bench_Foo, empty_for_in_range) { int _1; zend_bool _0; zval *n, n_sub, i, _2; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&n_sub); ZVAL_UNDEF(&i); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n); ZEPHIR_CPY_WRT(&_2, n); _1 = 1; _0 = 0; if (ZEPHIR_GE_LONG(&_2, _1)) { while (1) { if (_0) { _1++; if (!(ZEPHIR_GE_LONG(&_2, _1))) { break; } } else { _0 = 1; } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); } } ZEPHIR_MM_RESTORE(); }
PHP_METHOD(Test_Flow, testLoop1) { zend_bool a = 0; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; a = 1; while (1) { if (a) { break; } } RETURN_BOOL(a); }
static void call_resolved_handlers(skyray_promise_t *self, zend_array *on_fulfilled, zend_array *on_rejected) { skyray_promise_t *promise = skyray_promise_from_obj(Z_OBJ_P(&self->result)); zend_array *handlers; if (instanceof_function(Z_OBJCE_P(&self->result), skyray_ce_FulfilledPromise)) { handlers = on_fulfilled; } else { handlers = on_rejected; } zend_hash_internal_pointer_reset(handlers); while(zend_hash_has_more_elements(handlers) == SUCCESS) { promise_resolve_context_t *context = zend_hash_get_current_data_ptr(handlers); promise_resolve_context_call(context, &promise->result); zend_hash_move_forward(handlers); } zend_hash_destroy(&self->on_fulfilled); zend_hash_destroy(&self->on_rejcted); }
PHP_METHOD(Test_Strings, testTrim2Params) { zval *str, str_sub, *charlist, charlist_sub; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&str_sub); ZVAL_UNDEF(&charlist_sub); zephir_fetch_params(0, 2, 0, &str, &charlist); zephir_fast_trim(return_value, str, charlist, ZEPHIR_TRIM_BOTH TSRMLS_CC); return; }
PHP_METHOD(Test_Strings, testStrpos) { zval *haystack, haystack_sub, *needle, needle_sub; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&haystack_sub); ZVAL_UNDEF(&needle_sub); zephir_fetch_params(0, 2, 0, &haystack, &needle); zephir_fast_strpos(return_value, haystack, needle, 0 ); return; }
int zend_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr) /* {{{ */ { zend_closure *closure; if (Z_TYPE_P(obj) != IS_OBJECT) { return FAILURE; } closure = (zend_closure *)Z_OBJ_P(obj); *fptr_ptr = &closure->func; *ce_ptr = closure->called_scope; if (obj_ptr) { if (Z_TYPE(closure->this_ptr) != IS_UNDEF) { *obj_ptr = Z_OBJ(closure->this_ptr); } else { *obj_ptr = NULL; } } return SUCCESS; }
PHP_METHOD(Test_Strings, testImplode) { zval *glue, glue_sub, *pieces, pieces_sub; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&glue_sub); ZVAL_UNDEF(&pieces_sub); zephir_fetch_params(0, 2, 0, &glue, &pieces); zephir_fast_join(return_value, glue, pieces TSRMLS_CC); return; }
PHP_METHOD(Test_Vars, testVarDump2param) { zval *p1, p1_sub, *p2, p2_sub; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&p1_sub); ZVAL_UNDEF(&p2_sub); zephir_fetch_params(0, 2, 0, &p1, &p2); zephir_var_dump(p1 TSRMLS_CC); zephir_var_dump(p2 TSRMLS_CC); }
PHP_METHOD(Test_Oo, testInstance10) { zval o; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&o); ZEPHIR_MM_GROW(); ZEPHIR_CALL_CE_STATIC(&o, test_oo_oodynamicb_ce, "getnew", &_0, 49); zephir_check_call_status(); RETURN_CCTOR(o); }
PHP_METHOD(Test_Optimizers_ACos, testIntValue1) { zval _0; int ZEPHIR_LAST_CALL_STATUS; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZVAL_LONG(&_0, 0); ZEPHIR_RETURN_CALL_FUNCTION("acos", NULL, 10, &_0); zephir_check_call_status(); RETURN_MM(); }
PHP_METHOD(Test_Fibonnaci, fibonacciFinalRecursive) { zephir_fcall_cache_entry *_2 = NULL; zval *n_param = NULL, _0$$6, _1$$6, _3$$6; int n, ZEPHIR_LAST_CALL_STATUS; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&_0$$6); ZVAL_UNDEF(&_1$$6); ZVAL_UNDEF(&_3$$6); 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 { ZVAL_LONG(&_1$$6, (n - 1)); ZEPHIR_CALL_METHOD(&_0$$6, this_ptr, "fibonaccifinalrecursive", &_2, 36, &_1$$6); zephir_check_call_status(); ZVAL_LONG(&_1$$6, (n - 2)); ZEPHIR_CALL_METHOD(&_3$$6, this_ptr, "fibonaccifinalrecursive", &_2, 36, &_1$$6); zephir_check_call_status(); zephir_add_function(return_value, &_0$$6, &_3$$6); RETURN_MM(); } } }
PHP_METHOD(Test_Flow, testWhile11) { double c = 0; int b = 0; zval *a, a_sub, *d, d_sub; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&a_sub); ZVAL_UNDEF(&d_sub); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &a, &d); ZEPHIR_SEPARATE_PARAM(a); b = 0; while (1) { if (!(zephir_is_true(a))) { break; } b = zephir_get_numberval(d); while (1) { if (!(b)) { break; } b--; } ZEPHIR_SEPARATE(a); zephir_decrement(a); } c = (double) ((zephir_get_numberval(a) + b)); RETURN_MM_DOUBLE(c); }
/* {{{ proto Closure Closure::bind(Closure $old, object $to [, mixed $scope = "static" ] ) Create a closure from another one and bind to another object and scope */ ZEND_METHOD(Closure, bind) { zval *newthis, *zclosure, *scope_arg = NULL; zend_closure *closure; zend_class_entry *ce; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo!|z", &zclosure, zend_ce_closure, &newthis, &scope_arg) == FAILURE) { RETURN_NULL(); } closure = (zend_closure *)Z_OBJ_P(zclosure); if ((newthis != NULL) && (closure->func.common.fn_flags & ZEND_ACC_STATIC)) { zend_error(E_WARNING, "Cannot bind an instance to a static closure"); } if (scope_arg != NULL) { /* scope argument was given */ if (IS_ZEND_STD_OBJECT(*scope_arg)) { ce = Z_OBJCE_P(scope_arg); } else if (Z_TYPE_P(scope_arg) == IS_NULL) { ce = NULL; } else { zend_string *class_name = zval_get_string(scope_arg); if ((class_name->len == sizeof("static") - 1) && (memcmp("static", class_name->val, sizeof("static") - 1) == 0)) { ce = closure->func.common.scope; } else if ((ce = zend_lookup_class_ex(class_name, NULL, 1 TSRMLS_CC)) == NULL) { zend_error(E_WARNING, "Class '%s' not found", class_name->val); STR_RELEASE(class_name); RETURN_NULL(); } STR_RELEASE(class_name); } } else { /* scope argument not given; do not change the scope by default */ ce = closure->func.common.scope; } zend_create_closure(return_value, &closure->func, ce, newthis TSRMLS_CC); }
PHP_METHOD(Test_BuiltIn_StringMethods, getLength4) { zval *a_param = NULL; zval a; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&a); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &a_param); zephir_get_strval(&a, a_param); RETURN_MM_LONG(zephir_fast_strlen_ev(&a)); }
void stream_client_do_connect_blocking( skyray_stream_client_t *self, zend_object *protocol_obj, zend_string *host, zend_long port, zval *return_value) { int fd = stream_client_do_connect(host->val, port); if (fd < 0) { return; } zval zstream; object_init_ex(&zstream, skyray_ce_Stream); zend_object *stream = Z_OBJ_P(&zstream); skyray_stream_t * stream_intern = skyray_stream_from_obj(stream); skyray_stream_init_blocking(stream_intern, SR_TCP, fd, protocol_obj); skyray_stream_on_opened(stream_intern, SR_READABLE | SR_WRITABLE); if (!self->protocol_creator) { ZVAL_COPY(return_value, &zstream); return; } zend_string *buffer; ++GC_REFCOUNT(protocol_obj); //preventing protocol instance be free'd after connection closed. while((buffer = skyray_stream_read(stream_intern, 0))) { if (buffer->len == 0) { zend_string_free(buffer); break; } skyray_stream_on_data(stream_intern, buffer); zend_string_free(buffer); } RETURN_OBJ(protocol_obj); }
PHP_METHOD(Test_Strings, testInternedString2) { zval _0, _1; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZEPHIR_INIT_VAR(&_1); ZVAL_STRING(&_1, "\" hello "); zephir_fast_trim(&_0, &_1, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); RETURN_CCTOR(_0); }
PHP_METHOD(Test_Flow, testWhile8) { double a = 0; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; a = (double) (5); while (1) { if (!(a)) { break; } a--; } RETURN_DOUBLE(a); }
PHP_METHOD(Test_Instanceoff, testInstanceOf4) { zval *a, a_sub; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&a_sub); zephir_fetch_params(0, 1, 0, &a); if (zephir_zval_is_traversable(a TSRMLS_CC)) { RETURN_BOOL(1); } RETURN_BOOL(0); }
PHP_METHOD(Test_Oo, testInstance2) { zval o; int ZEPHIR_LAST_CALL_STATUS; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&o); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&o); object_init_ex(&o, test_oo_ooconstruct_ce); ZEPHIR_CALL_METHOD(NULL, &o, "__construct", NULL, 47); zephir_check_call_status(); RETURN_CCTOR(o); }
PHP_METHOD(Test_EmptyTest, testString) { zval *a_param = NULL; zval a; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&a); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &a_param); zephir_get_strval(&a, a_param); RETURN_MM_BOOL(ZEPHIR_IS_EMPTY(&a)); }
PHP_METHOD(Test_Flow, testWhileNextTest) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL, *_3 = NULL; zval *variable, variable_sub, returnValue, _0, _2$$3; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&variable_sub); ZVAL_UNDEF(&returnValue); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2$$3); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &variable); ZEPHIR_INIT_VAR(&returnValue); array_init(&returnValue); while (1) { ZEPHIR_MAKE_REF(variable); ZEPHIR_CALL_FUNCTION(&_0, "next", &_1, 37, variable); ZEPHIR_UNREF(variable); zephir_check_call_status(); if (!(zephir_is_true(&_0))) { break; } ZEPHIR_CALL_FUNCTION(&_2$$3, "current", &_3, 38, variable); zephir_check_call_status(); zephir_array_append(&returnValue, &_2$$3, PH_SEPARATE, "test/flow.zep", 420); } RETURN_CCTOR(returnValue); }
PHP_METHOD(Test_Strings, testSubstr3) { zval *str, str_sub, _0; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&str_sub); ZVAL_UNDEF(&_0); zephir_fetch_params(0, 1, 0, &str); ZVAL_LONG(&_0, -1); zephir_substr(return_value, str, -1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); return; }
PHP_METHOD(Test_Optimizers_Sqrt, testIntParameter) { zval *a_param = NULL, _0; int a; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&_0); zephir_fetch_params(0, 1, 0, &a_param); a = zephir_get_intval(a_param); ZVAL_LONG(&_0, a); RETURN_DOUBLE(sqrt(a)); }
PHP_METHOD(Test_ResourceTest, testTypeOffResource) { zval a, _0; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&a); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&a); ZEPHIR_GET_CONSTANT(&a, "STDIN"); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, &a TSRMLS_CC); RETURN_CCTOR(_0); }
PHP_METHOD(Test_Flow, testFor1) { int c = 0; zval v, b, _0, *_1; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&v); ZVAL_UNDEF(&b); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); c = 0; ZEPHIR_INIT_VAR(&b); zephir_create_array(&b, 4, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(&_0); ZVAL_LONG(&_0, 1); zephir_array_fast_append(&b, &_0); ZEPHIR_INIT_NVAR(&_0); ZVAL_LONG(&_0, 2); zephir_array_fast_append(&b, &_0); ZEPHIR_INIT_NVAR(&_0); ZVAL_LONG(&_0, 3); zephir_array_fast_append(&b, &_0); ZEPHIR_INIT_NVAR(&_0); ZVAL_LONG(&_0, 4); zephir_array_fast_append(&b, &_0); zephir_is_iterable(&b, 0, "test/flow.zep", 443); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&b), _1) { ZEPHIR_INIT_NVAR(&v); ZVAL_COPY(&v, _1); c += zephir_get_numberval(&v); } ZEND_HASH_FOREACH_END();
/* {{{ zend_user_unserialize */ ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) { zval zdata; if (UNEXPECTED(object_init_ex(object, ce) != SUCCESS)) { return FAILURE; } ZVAL_STRINGL(&zdata, (char*)buf, buf_len); zend_call_method_with_1_params(Z_OBJ_P(object), ce, &ce->unserialize_func, "unserialize", NULL, &zdata); zval_ptr_dtor(&zdata); if (EG(exception)) { return FAILURE; } else { return SUCCESS; } }
PHP_METHOD(Test_Flow, testIf14) { int a = 0, b = 0; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; a = 1; b = 2; if ((a + b)) { RETURN_LONG(74); } RETURN_LONG(0); }