PHP_METHOD(PocketMine_Math_Vector2, divide) { int ZEPHIR_LAST_CALL_STATUS; zval *number, *_0, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &number); object_init_ex(return_value, pocketmine_math_vector2_ce); _0 = zephir_fetch_nproperty_this(this_ptr, SL("x"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); div_function(_1, _0, number TSRMLS_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("y"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); div_function(_2, _0, number TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, _1, _2); zephir_check_call_status(); RETURN_MM(); }
/** * Returns a slice of the resultset to show in the pagination */ PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, getPaginate) { zval *_6$$14, *_8$$15; zend_bool hasHaving = 0, hasGroup = 0, _2; zval *originalBuilder = NULL, *builder = NULL, *totalBuilder = NULL, *totalPages = NULL, *limit = NULL, *number = NULL, *query = NULL, *page = NULL, *items = NULL, *totalQuery = NULL, *result = NULL, *row = NULL, *rowcount = NULL, *next = NULL, *sql = NULL, *columns = NULL, *db = NULL, *_0, *_1 = NULL, *groups = NULL, *_10, *_22, *_3$$10, *groupColumn$$11 = NULL, *_4$$14 = NULL, *_5$$14, *_7$$14, *_9$$15, *_11$$16 = NULL, *_12$$16 = NULL, *_13$$16, *_14$$16, *_15$$16, *_16$$16, _17$$16, _18$$16, *_19$$17, _20$$17, _21$$17; zend_long ZEPHIR_LAST_CALL_STATUS, numberPage = 0, before = 0; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(originalBuilder); zephir_read_property_this(&originalBuilder, this_ptr, SL("_builder"), PH_NOISY_CC); ZEPHIR_OBS_VAR(columns); zephir_read_property_this(&columns, this_ptr, SL("_columns"), PH_NOISY_CC); ZEPHIR_INIT_VAR(builder); if (zephir_clone(builder, originalBuilder TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_INIT_VAR(totalBuilder); if (zephir_clone(totalBuilder, builder TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_OBS_VAR(limit); zephir_read_property_this(&limit, this_ptr, SL("_limitRows"), PH_NOISY_CC); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_page"), PH_NOISY_CC); numberPage = zephir_get_intval(_0); if (!(numberPage)) { numberPage = 1; } ZEPHIR_INIT_VAR(number); ZVAL_LONG(number, (zephir_get_numberval(limit) * ((numberPage - 1)))); if (ZEPHIR_LT(number, limit)) { ZEPHIR_CALL_METHOD(NULL, builder, "limit", NULL, 0, limit); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(NULL, builder, "limit", NULL, 0, limit, number); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&query, builder, "getquery", NULL, 0); zephir_check_call_status(); if (numberPage == 1) { before = 1; } else { before = (numberPage - 1); } ZEPHIR_CALL_METHOD(&items, query, "execute", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, totalBuilder, "gethaving", NULL, 0); zephir_check_call_status(); hasHaving = !(ZEPHIR_IS_EMPTY(_1)); ZEPHIR_CALL_METHOD(&groups, totalBuilder, "getgroupby", NULL, 0); zephir_check_call_status(); hasGroup = !(ZEPHIR_IS_EMPTY(groups)); _2 = hasHaving; if (_2) { _2 = !hasGroup; } if (_2) { if (ZEPHIR_IS_EMPTY(columns)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "When having is set there should be columns option provided for which calculate row count", "phalcon/paginator/adapter/querybuilder.zep", 186); return; } ZEPHIR_CALL_METHOD(NULL, totalBuilder, "columns", NULL, 0, columns); zephir_check_call_status(); } else { ZEPHIR_INIT_VAR(_3$$10); ZVAL_STRING(_3$$10, "COUNT(*) [rowcount]", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, totalBuilder, "columns", NULL, 0, _3$$10); zephir_check_temp_parameter(_3$$10); zephir_check_call_status(); } if (hasGroup) { if (Z_TYPE_P(groups) == IS_ARRAY) { ZEPHIR_INIT_VAR(groupColumn$$11); zephir_fast_join_str(groupColumn$$11, SL(", "), groups TSRMLS_CC); } else { ZEPHIR_CPY_WRT(groupColumn$$11, groups); } if (!(hasHaving)) { ZEPHIR_INIT_VAR(_5$$14); ZVAL_NULL(_5$$14); ZEPHIR_CALL_METHOD(&_4$$14, totalBuilder, "groupby", NULL, 0, _5$$14); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6$$14); zephir_create_array(_6$$14, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_7$$14); ZEPHIR_CONCAT_SVS(_7$$14, "COUNT(DISTINCT ", groupColumn$$11, ") AS rowcount"); zephir_array_fast_append(_6$$14, _7$$14); ZEPHIR_CALL_METHOD(NULL, _4$$14, "columns", NULL, 0, _6$$14); zephir_check_call_status(); } else { ZEPHIR_INIT_VAR(_8$$15); zephir_create_array(_8$$15, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_9$$15); ZEPHIR_CONCAT_SV(_9$$15, "DISTINCT ", groupColumn$$11); zephir_array_fast_append(_8$$15, _9$$15); ZEPHIR_CALL_METHOD(NULL, totalBuilder, "columns", NULL, 0, _8$$15); zephir_check_call_status(); } } ZEPHIR_INIT_VAR(_10); ZVAL_NULL(_10); ZEPHIR_CALL_METHOD(NULL, totalBuilder, "orderby", NULL, 0, _10); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&totalQuery, totalBuilder, "getquery", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(rowcount); if (hasHaving) { ZEPHIR_CALL_METHOD(&sql, totalQuery, "getsql", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_11$$16, totalBuilder, "getdi", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_12$$16); ZVAL_STRING(_12$$16, "db", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&db, _11$$16, "get", NULL, 0, _12$$16); zephir_check_temp_parameter(_12$$16); zephir_check_call_status(); zephir_array_fetch_string(&_13$$16, sql, SL("sql"), PH_NOISY | PH_READONLY, "phalcon/paginator/adapter/querybuilder.zep", 228 TSRMLS_CC); ZEPHIR_INIT_VAR(_14$$16); ZEPHIR_CONCAT_SVS(_14$$16, "SELECT COUNT(*) as rowcount FROM (", _13$$16, ") as T1"); zephir_array_fetch_string(&_15$$16, sql, SL("bind"), PH_NOISY | PH_READONLY, "phalcon/paginator/adapter/querybuilder.zep", 228 TSRMLS_CC); ZEPHIR_INIT_NVAR(_12$$16); ZVAL_LONG(_12$$16, 2); ZEPHIR_CALL_METHOD(&row, db, "fetchone", NULL, 0, _14$$16, _12$$16, _15$$16); zephir_check_call_status(); if (zephir_is_true(row)) { zephir_array_fetch_string(&_16$$16, row, SL("rowcount"), PH_NOISY | PH_READONLY, "phalcon/paginator/adapter/querybuilder.zep", 229 TSRMLS_CC); ZVAL_LONG(rowcount, zephir_get_intval(_16$$16)); } else { ZVAL_LONG(rowcount, 0); } ZEPHIR_SINIT_VAR(_17$$16); div_function(&_17$$16, rowcount, limit TSRMLS_CC); ZEPHIR_SINIT_VAR(_18$$16); ZVAL_DOUBLE(&_18$$16, zephir_ceil(&_17$$16 TSRMLS_CC)); ZEPHIR_INIT_VAR(totalPages); ZVAL_LONG(totalPages, zephir_get_intval(&_18$$16)); } else { ZEPHIR_CALL_METHOD(&result, totalQuery, "execute", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&row, result, "getfirst", NULL, 0); zephir_check_call_status(); if (zephir_is_true(row)) { ZEPHIR_OBS_VAR(_19$$17); zephir_read_property(&_19$$17, row, SL("rowcount"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(rowcount); ZVAL_LONG(rowcount, zephir_get_intval(_19$$17)); } else { ZEPHIR_INIT_NVAR(rowcount); ZVAL_LONG(rowcount, 0); } ZEPHIR_SINIT_VAR(_20$$17); div_function(&_20$$17, rowcount, limit TSRMLS_CC); ZEPHIR_SINIT_VAR(_21$$17); ZVAL_DOUBLE(&_21$$17, zephir_ceil(&_20$$17 TSRMLS_CC)); ZEPHIR_INIT_NVAR(totalPages); ZVAL_LONG(totalPages, zephir_get_intval(&_21$$17)); } if (ZEPHIR_GT_LONG(totalPages, numberPage)) { ZEPHIR_INIT_VAR(next); ZVAL_LONG(next, (numberPage + 1)); } else { ZEPHIR_CPY_WRT(next, totalPages); } ZEPHIR_INIT_VAR(page); object_init(page); zephir_update_property_zval(page, SL("items"), items TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_22); ZVAL_LONG(_22, 1); zephir_update_property_zval(page, SL("first"), _22 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_22); ZVAL_LONG(_22, before); zephir_update_property_zval(page, SL("before"), _22 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_22); ZVAL_LONG(_22, numberPage); zephir_update_property_zval(page, SL("current"), _22 TSRMLS_CC); zephir_update_property_zval(page, SL("last"), totalPages TSRMLS_CC); zephir_update_property_zval(page, SL("next"), next TSRMLS_CC); zephir_update_property_zval(page, SL("total_pages"), totalPages TSRMLS_CC); zephir_update_property_zval(page, SL("total_items"), rowcount TSRMLS_CC); _22 = zephir_fetch_nproperty_this(this_ptr, SL("_limitRows"), PH_NOISY_CC); zephir_update_property_zval(page, SL("limit"), _22 TSRMLS_CC); RETURN_CCTOR(page); }
/** * Returns a slice of the resultset to show in the pagination * * @return stdClass */ PHP_METHOD(Phalcon_Paginator_Adapter_Model, getPaginate){ zval *v0 = NULL, *v1 = NULL, *v2 = NULL, *v3 = NULL, *v4 = NULL, *v5 = NULL, *v6 = NULL; zval *v7 = NULL, *v8 = NULL, *v9 = NULL, *v10 = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL, *t6 = NULL; zval *t7 = NULL, *t8 = NULL, *t9 = NULL, *t10 = NULL, *t11 = NULL, *t12 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL, *r13 = NULL; zval *r14 = NULL, *r15 = NULL, *r16 = NULL, *r17 = NULL, *r18 = NULL, *r19 = NULL, *r20 = NULL; zval *r21 = NULL, *r22 = NULL, *r23 = NULL, *r24 = NULL, *r25 = NULL, *r26 = NULL, *r27 = NULL; zval *r28 = NULL; zval *i0 = NULL, *i1 = NULL, *i2 = NULL; zval *a0 = NULL; zval *p2[] = { NULL }, *p3[] = { NULL }, *p4[] = { NULL }, *p5[] = { NULL }; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_limitRows", sizeof("_limitRows")-1, PHALCON_NOISY_FETCH TSRMLS_CC); PHALCON_CPY_WRT(v0, t0); PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, "_config", sizeof("_config")-1, PHALCON_NOISY_FETCH TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r0); phalcon_array_fetch_string(&r0, t1, "data", strlen("data"), PHALCON_NOISY_FETCH TSRMLS_CC); PHALCON_CPY_WRT(v1, r0); PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, "_page", sizeof("_page")-1, PHALCON_NOISY_FETCH TSRMLS_CC); PHALCON_CPY_WRT(v2, t2); if (Z_TYPE_P(v2) == IS_NULL) { PHALCON_INIT_VAR(v2); ZVAL_LONG(v2, 1); } PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_FUNC_PARAMS_1(r1, "count", v1, 0x008); PHALCON_CPY_WRT(v3, r1); PHALCON_ALLOC_ZVAL_MM(i0); object_init(i0); PHALCON_CPY_WRT(v4, i0); PHALCON_INIT_VAR(t3); ZVAL_LONG(t3, 1); PHALCON_ALLOC_ZVAL_MM(r2); sub_function(r2, v2, t3 TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r3); mul_function(r3, v0, r2 TSRMLS_CC); PHALCON_CPY_WRT(v5, r3); PHALCON_ALLOC_ZVAL_MM(r4); PHALCON_INIT_VAR(t4); ZVAL_LONG(t4, 1); PHALCON_ALLOC_ZVAL_MM(r5); sub_function(r5, v3, t4 TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r6); div_function(r6, r5, v0 TSRMLS_CC); Z_ADDREF_P(r6); PHALCON_CALL_FUNC_PARAMS_1(r4, "ceil", r6, 0x00D); Z_DELREF_P(r6); PHALCON_CPY_WRT(v6, r4); if (Z_TYPE_P(v1) != IS_OBJECT) { PHALCON_ALLOC_ZVAL_MM(i1); object_init_ex(i1, phalcon_paginator_exception_class_entry); PHALCON_INIT_VAR(p2[0]); ZVAL_STRING(p2[0], "Invalid data for paginator", 1); PHALCON_CALL_METHOD_PARAMS_NORETURN(i1, "__construct", 1, p2, PHALCON_CALL_CHECK); zend_throw_exception_object(i1 TSRMLS_CC); Z_ADDREF_P(i1); PHALCON_MM_RESTORE(); return; } if (Z_TYPE_P(v2) == IS_NULL) { PHALCON_INIT_VAR(v2); ZVAL_LONG(v2, 0); } PHALCON_INIT_VAR(t5); ZVAL_LONG(t5, 0); PHALCON_INIT_VAR(r7); is_smaller_function(r7, v5, t5 TSRMLS_CC); if (zend_is_true(r7)) { PHALCON_ALLOC_ZVAL_MM(i2); object_init_ex(i2, phalcon_paginator_exception_class_entry); PHALCON_INIT_VAR(p3[0]); ZVAL_STRING(p3[0], "The start page number is zero or less", 1); PHALCON_CALL_METHOD_PARAMS_NORETURN(i2, "__construct", 1, p3, PHALCON_CALL_CHECK); zend_throw_exception_object(i2 TSRMLS_CC); Z_ADDREF_P(i2); PHALCON_MM_RESTORE(); return; } PHALCON_INIT_VAR(a0); array_init(a0); phalcon_update_property_zval(v4, "items", strlen("items"), a0 TSRMLS_CC); PHALCON_INIT_VAR(t6); ZVAL_LONG(t6, 0); PHALCON_INIT_VAR(r8); is_smaller_function(r8, t6, v3 TSRMLS_CC); if (zend_is_true(r8)) { PHALCON_INIT_VAR(r9); is_smaller_or_equal_function(r9, v5, v3 TSRMLS_CC); if (zend_is_true(r9)) { Z_ADDREF_P(v5); p4[0] = v5; PHALCON_CALL_METHOD_PARAMS_NORETURN(v1, "seek", 1, p4, PHALCON_CALL_DEFAULT); Z_DELREF_P(p4[0]); } else { PHALCON_INIT_VAR(p5[0]); ZVAL_LONG(p5[0], 1); PHALCON_CALL_METHOD_PARAMS_NORETURN(v1, "seek", 1, p5, PHALCON_CALL_DEFAULT); PHALCON_INIT_VAR(v2); ZVAL_LONG(v2, 1); } PHALCON_INIT_VAR(v7); ZVAL_LONG(v7, 1); ws_e435_0: PHALCON_INIT_VAR(r10); PHALCON_CALL_METHOD(r10, v1, "valid", PHALCON_CALL_DEFAULT); if (!zend_is_true(r10)) { goto we_e435_0; } PHALCON_INIT_VAR(r11); PHALCON_CALL_METHOD(r11, v1, "current", PHALCON_CALL_DEFAULT); PHALCON_INIT_VAR(t7); phalcon_read_property(&t7, v4, "items", sizeof("items")-1, PHALCON_NOISY_FETCH TSRMLS_CC); Z_ADDREF_P(r11); phalcon_array_append(t7, r11 TSRMLS_CC); phalcon_update_property_zval(v4, "items", strlen("items"), t7 TSRMLS_CC); PHALCON_INIT_VAR(r12); is_smaller_or_equal_function(r12, v0, v7 TSRMLS_CC); if (zend_is_true(r12)) { goto we_e435_0; } PHALCON_SEPARATE(v7); increment_function(v7); goto ws_e435_0; we_e435_0: if(0) { }; } phalcon_update_property_long(v4, "first", strlen("first"), 1 TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r13); phalcon_add_function(r13, v5, v0 TSRMLS_CC); PHALCON_INIT_VAR(r14); is_smaller_function(r14, r13, v3 TSRMLS_CC); if (zend_is_true(r14)) { PHALCON_INIT_VAR(t8); ZVAL_LONG(t8, 1); PHALCON_ALLOC_ZVAL_MM(r15); phalcon_add_function(r15, v2, t8 TSRMLS_CC); PHALCON_CPY_WRT(v8, r15); } else { PHALCON_ALLOC_ZVAL_MM(r16); phalcon_add_function(r16, v5, v0 TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r17); is_equal_function(r17, r16, v3 TSRMLS_CC); if (zend_is_true(r17)) { PHALCON_CPY_WRT(v8, v3); } else { PHALCON_ALLOC_ZVAL_MM(r18); PHALCON_ALLOC_ZVAL_MM(r19); div_function(r19, v3, v0 TSRMLS_CC); PHALCON_CALL_FUNC_PARAMS_1(r18, "intval", r19, 0x00E); PHALCON_INIT_VAR(t9); ZVAL_LONG(t9, 1); PHALCON_ALLOC_ZVAL_MM(r20); phalcon_add_function(r20, r18, t9 TSRMLS_CC); PHALCON_CPY_WRT(v8, r20); } } PHALCON_INIT_VAR(r21); is_smaller_function(r21, v6, v8 TSRMLS_CC); if (zend_is_true(r21)) { PHALCON_CPY_WRT(v8, v6); } phalcon_update_property_zval(v4, "next", strlen("next"), v8 TSRMLS_CC); PHALCON_INIT_VAR(t10); ZVAL_LONG(t10, 1); PHALCON_INIT_VAR(r22); is_smaller_function(r22, t10, v2 TSRMLS_CC); if (zend_is_true(r22)) { PHALCON_INIT_VAR(t11); ZVAL_LONG(t11, 1); PHALCON_ALLOC_ZVAL_MM(r23); sub_function(r23, v2, t11 TSRMLS_CC); PHALCON_CPY_WRT(v9, r23); } else { PHALCON_INIT_VAR(v9); ZVAL_LONG(v9, 1); } phalcon_update_property_zval(v4, "before", strlen("before"), v9 TSRMLS_CC); phalcon_update_property_zval(v4, "current", strlen("current"), v2 TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r24); mod_function(r24, v3, v0 TSRMLS_CC); if (zend_is_true(r24)) { PHALCON_ALLOC_ZVAL_MM(r25); PHALCON_ALLOC_ZVAL_MM(r26); div_function(r26, v3, v0 TSRMLS_CC); PHALCON_CALL_FUNC_PARAMS_1(r25, "intval", r26, 0x00E); PHALCON_INIT_VAR(t12); ZVAL_LONG(t12, 1); PHALCON_ALLOC_ZVAL_MM(r27); phalcon_add_function(r27, r25, t12 TSRMLS_CC); PHALCON_CPY_WRT(v10, r27); } else { PHALCON_ALLOC_ZVAL_MM(r28); div_function(r28, v3, v0 TSRMLS_CC); PHALCON_CPY_WRT(v10, r28); } phalcon_update_property_zval(v4, "last", strlen("last"), v10 TSRMLS_CC); phalcon_update_property_zval(v4, "total_pages", strlen("total_pages"), v10 TSRMLS_CC); PHALCON_RETURN_CTOR(v4); }
/** * Returns a slice of the resultset to show in the pagination * * @return stdClass */ PHP_METHOD(Phalcon_Paginator_Adapter_Model, getPaginate){ zval *show = NULL, *config = NULL, *items = NULL, *page_number = NULL, *zero = NULL, *one = NULL; zval *smaller = NULL, *n = NULL, *page = NULL, *last_show_page = NULL, *start = NULL; zval *last_page = NULL, *possible_pages = NULL, *total_pages = NULL; zval *compare = NULL, *page_items = NULL, *i = NULL, *valid = NULL, *current = NULL, *maximum_pages = NULL; zval *next = NULL, *additional_page = NULL, *before = NULL, *remainder = NULL; zval *pages_total = NULL; zval *r0 = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(show); phalcon_read_property(&show, this_ptr, SL("_limitRows"), PH_NOISY_CC); PHALCON_INIT_VAR(config); phalcon_read_property(&config, this_ptr, SL("_config"), PH_NOISY_CC); PHALCON_INIT_VAR(items); phalcon_array_fetch_string(&items, config, SL("data"), PH_NOISY_CC); PHALCON_INIT_VAR(page_number); phalcon_read_property(&page_number, this_ptr, SL("_page"), PH_NOISY_CC); if (Z_TYPE_P(page_number) == IS_NULL) { PHALCON_INIT_VAR(page_number); ZVAL_LONG(page_number, 1); } PHALCON_INIT_VAR(zero); ZVAL_LONG(zero, 0); PHALCON_INIT_VAR(one); ZVAL_LONG(one, 1); PHALCON_INIT_VAR(smaller); is_smaller_function(smaller, show, zero TSRMLS_CC); if (Z_TYPE_P(smaller) == IS_BOOL && Z_BVAL_P(smaller)) { PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "The start page number is zero or less"); return; } PHALCON_INIT_VAR(n); phalcon_fast_count(n, items TSRMLS_CC); PHALCON_INIT_VAR(page); object_init(page); PHALCON_INIT_VAR(last_show_page); sub_function(last_show_page, page_number, one TSRMLS_CC); PHALCON_INIT_VAR(start); mul_function(start, show, last_show_page TSRMLS_CC); PHALCON_INIT_VAR(last_page); sub_function(last_page, n, one TSRMLS_CC); PHALCON_INIT_VAR(possible_pages); div_function(possible_pages, last_page, show TSRMLS_CC); PHALCON_INIT_VAR(total_pages); PHALCON_CALL_FUNC_PARAMS_1(total_pages, "ceil", possible_pages); if (Z_TYPE_P(items) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "Invalid data for paginator"); return; } if (Z_TYPE_P(page_number) == IS_NULL) { PHALCON_INIT_VAR(page_number); ZVAL_LONG(page_number, 0); } PHALCON_INIT_VAR(compare); is_smaller_function(compare, start, zero TSRMLS_CC); if (Z_TYPE_P(compare) == IS_BOOL && Z_BVAL_P(compare)) { PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "The start page number is zero or less"); return; } PHALCON_INIT_VAR(page_items); array_init(page_items); PHALCON_INIT_VAR(compare); is_smaller_function(compare, zero, n TSRMLS_CC); if (Z_TYPE_P(compare) == IS_BOOL && Z_BVAL_P(compare)) { PHALCON_INIT_VAR(compare); is_smaller_or_equal_function(compare, start, n TSRMLS_CC); if (Z_TYPE_P(compare) == IS_BOOL && Z_BVAL_P(compare)) { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(items, "seek", start, PH_NO_CHECK); } else { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(items, "seek", one, PH_NO_CHECK); PHALCON_INIT_VAR(page_number); ZVAL_LONG(page_number, 1); } PHALCON_INIT_VAR(i); ZVAL_LONG(i, 1); ws_e435_0: PHALCON_INIT_VAR(r0); PHALCON_CALL_METHOD(r0, items, "valid", PH_NO_CHECK); PHALCON_CPY_WRT(valid, r0); if (Z_TYPE_P(valid) != IS_BOOL || (Z_TYPE_P(valid) == IS_BOOL && !Z_BVAL_P(valid))) { goto we_e435_0; } PHALCON_INIT_VAR(current); PHALCON_CALL_METHOD(current, items, "current", PH_NO_CHECK); phalcon_array_append(&page_items, current, PH_SEPARATE TSRMLS_CC); PHALCON_INIT_VAR(compare); is_smaller_or_equal_function(compare, show, i TSRMLS_CC); if (Z_TYPE_P(compare) == IS_BOOL && Z_BVAL_P(compare)) { goto we_e435_0; } PHALCON_SEPARATE(i); increment_function(i); goto ws_e435_0; we_e435_0: if(0){} } phalcon_update_property_zval(page, SL("items"), page_items TSRMLS_CC); phalcon_update_property_long(page, SL("first"), 1 TSRMLS_CC); PHALCON_INIT_VAR(maximum_pages); phalcon_add_function(maximum_pages, start, show TSRMLS_CC); PHALCON_INIT_VAR(compare); is_smaller_function(compare, maximum_pages, n TSRMLS_CC); if (Z_TYPE_P(compare) == IS_BOOL && Z_BVAL_P(compare)) { PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 1); PHALCON_INIT_VAR(next); phalcon_add_function(next, page_number, t0 TSRMLS_CC); } else { PHALCON_INIT_VAR(compare); is_equal_function(compare, maximum_pages, n TSRMLS_CC); if (Z_TYPE_P(compare) == IS_BOOL && Z_BVAL_P(compare)) { PHALCON_CPY_WRT(next, n); } else { PHALCON_INIT_VAR(possible_pages); div_function(possible_pages, n, show TSRMLS_CC); PHALCON_INIT_VAR(additional_page); phalcon_add_function(additional_page, possible_pages, one TSRMLS_CC); PHALCON_INIT_VAR(next); PHALCON_CALL_FUNC_PARAMS_1(next, "intval", additional_page); } } PHALCON_INIT_VAR(compare); is_smaller_function(compare, total_pages, next TSRMLS_CC); if (Z_TYPE_P(compare) == IS_BOOL && Z_BVAL_P(compare)) { PHALCON_CPY_WRT(next, total_pages); } phalcon_update_property_zval(page, SL("next"), next TSRMLS_CC); PHALCON_INIT_VAR(compare); is_smaller_function(compare, one, page_number TSRMLS_CC); if (Z_TYPE_P(compare) == IS_BOOL && Z_BVAL_P(compare)) { PHALCON_INIT_VAR(before); sub_function(before, page_number, one TSRMLS_CC); } else { PHALCON_INIT_VAR(before); ZVAL_LONG(before, 1); } phalcon_update_property_zval(page, SL("before"), before TSRMLS_CC); phalcon_update_property_zval(page, SL("current"), page_number TSRMLS_CC); PHALCON_INIT_VAR(remainder); mod_function(remainder, n, show TSRMLS_CC); PHALCON_INIT_VAR(possible_pages); div_function(possible_pages, n, show TSRMLS_CC); if (!phalcon_compare_strict_long(remainder, 0 TSRMLS_CC)) { PHALCON_INIT_VAR(next); phalcon_add_function(next, possible_pages, one TSRMLS_CC); PHALCON_INIT_VAR(pages_total); PHALCON_CALL_FUNC_PARAMS_1(pages_total, "intval", possible_pages); } else { PHALCON_CPY_WRT(pages_total, possible_pages); } phalcon_update_property_zval(page, SL("last"), pages_total TSRMLS_CC); phalcon_update_property_zval(page, SL("total_pages"), pages_total TSRMLS_CC); RETURN_CTOR(page); }
PHP_METHOD(Test_Quantum, harmos) { zend_bool _13, _16, _32, _35; zval *_10 = NULL, *_11 = NULL, *_12 = NULL; zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_8 = NULL, *_36 = NULL; int i, j, n, ZEPHIR_LAST_CALL_STATUS, _14, _15, _17, _18, _33, _34; zval *x_param = NULL, *psr, *psi, *p2, *v, *paramater, *fp = NULL, *tmp, *_0 = NULL, _1 = zval_used_for_init, _2 = zval_used_for_init, *_3 = NULL, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_19, *_20, *_21, *_22, *_23, *_24, *_25, *_26, _27 = zval_used_for_init, *_28, *_29, *_30, *_31; double x, dt, dx, k0, item_psr, item_psi; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &x_param); x = zephir_get_doubleval(x_param); dx = 0.02; k0 = (3.0 * 3.14159265358979323846); dt = zephir_safe_div_double_long((dx * dx), 4.0 TSRMLS_CC); ZEPHIR_INIT_VAR(paramater); zephir_create_array(paramater, 4, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); ZVAL_DOUBLE(_0, dx); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, k0); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, dt); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, x); zephir_array_fast_append(paramater, _0); i = 0; ZEPHIR_INIT_VAR(psr); array_init(psr); ZEPHIR_INIT_VAR(psi); array_init(psi); ZEPHIR_INIT_VAR(p2); array_init(p2); ZEPHIR_INIT_VAR(v); array_init(v); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "harmos.txt", 0); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "w", 0); ZEPHIR_CALL_FUNCTION(&fp, "fopen", NULL, 30, &_1, &_2); zephir_check_call_status(); if (!(zephir_is_true(fp))) { RETURN_MM_LONG(1); } while (1) { if (!(i <= 751)) { break; } ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, (k0 * x)); ZEPHIR_CALL_FUNCTION(&_3, "sin", &_4, 10, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, ((x * x) * 2.0)); ZEPHIR_CALL_FUNCTION(&_5, "exp", &_6, 1, &_1); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_7); div_function(_7, _3, _5 TSRMLS_CC); item_psi = zephir_get_numberval(_7); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, (k0 * x)); ZEPHIR_CALL_FUNCTION(&_3, "cos", &_8, 11, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, ((x * x) * 2.0)); ZEPHIR_CALL_FUNCTION(&_5, "exp", &_6, 1, &_1); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_9); div_function(_9, _3, _5 TSRMLS_CC); item_psr = zephir_get_numberval(_9); ZEPHIR_INIT_NVAR(_10); zephir_create_array(_10, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, item_psr); zephir_array_fast_append(_10, _0); zephir_array_update_long(&psr, i, &_10, PH_COPY | PH_SEPARATE, "test/quantum.zep", 39); ZEPHIR_INIT_NVAR(_11); zephir_create_array(_11, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, item_psi); zephir_array_fast_append(_11, _0); zephir_array_update_long(&psi, i, &_11, PH_COPY | PH_SEPARATE, "test/quantum.zep", 40); ZEPHIR_INIT_NVAR(_12); zephir_create_array(_12, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, (double) ((double) (5.0 * x) * x)); zephir_array_fast_append(_12, _0); zephir_array_update_long(&v, i, &_12, PH_COPY | PH_SEPARATE, "test/quantum.zep", 41); x = (x + dx); i++; } i = 1; j = 1; ZEPHIR_INIT_VAR(tmp); zephir_create_array(tmp, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, 2.0); zephir_array_fast_append(tmp, _0); _15 = 20000; _14 = 0; _13 = 0; if (_14 <= _15) { while (1) { if (_13) { _14++; if (!(_14 <= _15)) { break; } } else { _13 = 1; } n = _14; _18 = (751 - 1); _17 = 1; _16 = 0; if (_17 <= _18) { while (1) { if (_16) { _17++; if (!(_17 <= _18)) { break; } } else { _16 = 1; } i = _17; zephir_array_fetch_long(&_19, psr, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_20, _19, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_22, psi, (i + 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_23, _22, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_24, psi, (i - 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_25, _24, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function_ex(&_1, _23, _25 TSRMLS_CC); zephir_array_fetch_long(&_23, tmp, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_25, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_26, _25, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _23, _26 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); sub_function(_7, &_1, &_2 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _21, _7 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_23, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); mul_function(_7, _21, _23 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); div_function(&_2, &_1, _7 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); sub_function(&_1, _20, &_2 TSRMLS_CC); zephir_array_fetch_long(&_20, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_21, v, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_23, _21, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _20, _23 TSRMLS_CC); zephir_array_fetch_long(&_20, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_23, _20, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_27); mul_function(&_27, &_2, _23 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); zephir_add_function_ex(_7, &_1, &_27 TSRMLS_CC); zephir_array_update_multi(&psr, &_7 TSRMLS_CC, SL("ll"), 2, i, 1); zephir_array_fetch_long(&_23, psr, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_26, _23, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_28, psr, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_29, _28, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _26, _29 TSRMLS_CC); zephir_array_fetch_long(&_26, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_29, _26, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_30, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_31, _30, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _29, _31 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); zephir_add_function_ex(_7, &_1, &_2 TSRMLS_CC); zephir_array_update_long(&p2, i, &_7, PH_COPY | PH_SEPARATE, "test/quantum.zep", 53); } } _34 = (751 - 1); _33 = 1; _32 = 0; if (_33 <= _34) { while (1) { if (_32) { _33++; if (!(_33 <= _34)) { break; } } else { _32 = 1; } j = _33; ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 0, 1); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 751, 1); zephir_array_fetch_long(&_19, psi, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_20, _19, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_22, psr, (j + 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_23, _22, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_24, psr, (j - 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_25, _24, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function_ex(&_1, _23, _25 TSRMLS_CC); zephir_array_fetch_long(&_23, tmp, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_25, psr, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_26, _25, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _23, _26 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_9); sub_function(_9, &_1, &_2 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _21, _9 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_23, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_9); mul_function(_9, _21, _23 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); div_function(&_2, &_1, _9 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function_ex(&_1, _20, &_2 TSRMLS_CC); zephir_array_fetch_long(&_20, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_21, v, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_23, _21, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _20, _23 TSRMLS_CC); zephir_array_fetch_long(&_20, psr, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_23, _20, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_27); mul_function(&_27, &_2, _23 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_9); sub_function(_9, &_1, &_27 TSRMLS_CC); zephir_array_update_multi(&psi, &_9 TSRMLS_CC, SL("ll"), 2, j, 1); } } _35 = n == 0; if (!(_35)) { _35 = zephir_safe_mod_long_long(n, 2000 TSRMLS_CC) == 0; } if (_35) { i = 1; while (1) { if (!(i < (751 - 1))) { break; } zephir_array_fetch_long(&_19, p2, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 67 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "%16.8lf %16.8lf %16.8lf \n", 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_DOUBLE(&_2, ((double) i * dx)); ZEPHIR_SINIT_NVAR(_27); ZVAL_DOUBLE(&_27, ((double) n * dt)); ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_36, 57, fp, &_1, &_2, &_27, _19); zephir_check_call_status(); i = (i + 10); } ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "\n", 0); ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_36, 57, fp, &_1); zephir_check_call_status(); } j = 1; while (1) { if (!(j < (751 - 1))) { break; } zephir_array_fetch_long(&_19, psi, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 76 TSRMLS_CC); zephir_array_fetch_long(&_20, _19, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 76 TSRMLS_CC); zephir_array_update_multi(&psi, &_20 TSRMLS_CC, SL("ll"), 2, j, 0); zephir_array_fetch_long(&_20, psr, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 77 TSRMLS_CC); zephir_array_fetch_long(&_21, _20, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 77 TSRMLS_CC); zephir_array_update_multi(&psr, &_21 TSRMLS_CC, SL("ll"), 2, j, 0); j++; } } } RETURN_MM_BOOL(1); }
/** * Rebuild the list of access from the inherit lists * */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, _rebuildAccessList){ zval *roles, *number_roles, *pow_roles, *two, *middle_roles; zval *middle, *roles_names, *roles_inherits; zval *changed = NULL, *i, *internal_access = NULL, *one = NULL, *role_name = NULL; zval *role_inherit = NULL, *inherit_internal = NULL, *access = NULL; zval *resource_name = NULL, *value = NULL, *name = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL; HashTable *ah0, *ah1, *ah2, *ah3; HashPosition hp0, hp1, hp2, hp3; zval **hd; PHALCON_MM_GROW(); PHALCON_OBS_VAR(roles); phalcon_read_property(&roles, this_ptr, SL("_roles"), PH_NOISY_CC); PHALCON_INIT_VAR(number_roles); phalcon_fast_count(number_roles, roles TSRMLS_CC); PHALCON_INIT_VAR(pow_roles); Z_LVAL_P(pow_roles) = Z_LVAL_P(number_roles) * Z_LVAL_P(number_roles); PHALCON_INIT_VAR(two); ZVAL_LONG(two, 2); PHALCON_INIT_VAR(middle_roles); div_function(middle_roles, pow_roles, two TSRMLS_CC); PHALCON_INIT_VAR(middle); PHALCON_CALL_FUNC_PARAMS_1(middle, "ceil", middle_roles); PHALCON_OBS_VAR(roles_names); phalcon_read_property(&roles_names, this_ptr, SL("_rolesNames"), PH_NOISY_CC); PHALCON_OBS_VAR(roles_inherits); phalcon_read_property(&roles_inherits, this_ptr, SL("_roleInherits"), PH_NOISY_CC); PHALCON_INIT_VAR(changed); ZVAL_BOOL(changed, 1); PHALCON_INIT_VAR(i); ZVAL_LONG(i, 0); while (1) { PHALCON_INIT_NVAR(r0); is_smaller_or_equal_function(r0, i, middle TSRMLS_CC); if (!zend_is_true(r0)) { break; } PHALCON_OBS_NVAR(internal_access); phalcon_read_property(&internal_access, this_ptr, SL("_access"), PH_NOISY_CC); if (!phalcon_is_iterable(roles_names, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_KEY(role_name, ah0, hp0); PHALCON_GET_FOREACH_VALUE(one); if (phalcon_array_isset(roles_inherits, role_name)) { PHALCON_OBS_NVAR(r1); phalcon_array_fetch(&r1, roles_inherits, role_name, PH_NOISY_CC); if (!phalcon_is_iterable(r1, &ah1, &hp1, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) == SUCCESS) { PHALCON_GET_FOREACH_VALUE(role_inherit); if (phalcon_array_isset(internal_access, role_inherit)) { PHALCON_OBS_NVAR(inherit_internal); phalcon_array_fetch(&inherit_internal, internal_access, role_inherit, PH_NOISY_CC); if (!phalcon_is_iterable(inherit_internal, &ah2, &hp2, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah2, (void**) &hd, &hp2) == SUCCESS) { PHALCON_GET_FOREACH_KEY(resource_name, ah2, hp2); PHALCON_GET_FOREACH_VALUE(access); if (!phalcon_is_iterable(access, &ah3, &hp3, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah3, (void**) &hd, &hp3) == SUCCESS) { PHALCON_GET_FOREACH_KEY(name, ah3, hp3); PHALCON_GET_FOREACH_VALUE(value); if (phalcon_array_isset(internal_access, role_name)) { PHALCON_OBS_NVAR(r2); phalcon_array_fetch(&r2, internal_access, role_name, PH_NOISY_CC); if (phalcon_array_isset(r2, resource_name)) { PHALCON_OBS_NVAR(r3); phalcon_array_fetch(&r3, internal_access, role_name, PH_NOISY_CC); PHALCON_OBS_NVAR(r4); phalcon_array_fetch(&r4, r3, resource_name, PH_NOISY_CC); if (phalcon_array_isset(r4, name)) { zend_hash_move_forward_ex(ah3, &hp3); continue; } } } phalcon_array_update_zval_zval_zval_multi_3(&internal_access, role_name, resource_name, name, &value, 0 TSRMLS_CC); PHALCON_INIT_NVAR(changed); ZVAL_BOOL(changed, 1); zend_hash_move_forward_ex(ah3, &hp3); } zend_hash_move_forward_ex(ah2, &hp2); } } zend_hash_move_forward_ex(ah1, &hp1); } } zend_hash_move_forward_ex(ah0, &hp0); } if (zend_is_true(changed)) { phalcon_update_property_zval(this_ptr, SL("_access"), internal_access TSRMLS_CC); } PHALCON_SEPARATE(i); increment_function(i); } PHALCON_MM_RESTORE(); }
/** * Returns a slice of the resultset to show in the pagination */ PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, getPaginate) { zval *_4$$8; zval *originalBuilder = NULL, *builder = NULL, *totalBuilder = NULL, *totalPages = NULL, *limit = NULL, *number = NULL, *query = NULL, *page = NULL, *items = NULL, *totalQuery = NULL, *result = NULL, *row = NULL, *rowcount = NULL, *next = NULL, *_0, *_1 = NULL, *groups = NULL, *_6, _7, _8, *_9, *groupColumn$$8 = NULL, *_2$$8 = NULL, *_3$$8, *_5$$8; int ZEPHIR_LAST_CALL_STATUS, numberPage = 0, before = 0; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(originalBuilder); zephir_read_property_this(&originalBuilder, this_ptr, SL("_builder"), PH_NOISY_CC); ZEPHIR_INIT_VAR(builder); if (zephir_clone(builder, originalBuilder TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_INIT_VAR(totalBuilder); if (zephir_clone(totalBuilder, builder TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_OBS_VAR(limit); zephir_read_property_this(&limit, this_ptr, SL("_limitRows"), PH_NOISY_CC); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_page"), PH_NOISY_CC); numberPage = zephir_get_intval(_0); if (!(numberPage)) { numberPage = 1; } ZEPHIR_INIT_VAR(number); ZVAL_LONG(number, (zephir_get_numberval(limit) * ((numberPage - 1)))); if (ZEPHIR_LT(number, limit)) { ZEPHIR_CALL_METHOD(NULL, builder, "limit", NULL, 0, limit); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(NULL, builder, "limit", NULL, 0, limit, number); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&query, builder, "getquery", NULL, 0); zephir_check_call_status(); if (numberPage == 1) { before = 1; } else { before = (numberPage - 1); } ZEPHIR_CALL_METHOD(&items, query, "execute", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "COUNT(*) [rowcount]", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, totalBuilder, "columns", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&groups, totalBuilder, "getgroupby", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(groups))) { if (Z_TYPE_P(groups) == IS_ARRAY) { ZEPHIR_INIT_VAR(groupColumn$$8); zephir_fast_join_str(groupColumn$$8, SL(", "), groups TSRMLS_CC); } else { ZEPHIR_CPY_WRT(groupColumn$$8, groups); } ZEPHIR_INIT_VAR(_3$$8); ZVAL_NULL(_3$$8); ZEPHIR_CALL_METHOD(&_2$$8, totalBuilder, "groupby", NULL, 0, _3$$8); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4$$8); zephir_create_array(_4$$8, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_5$$8); ZEPHIR_CONCAT_SVS(_5$$8, "COUNT(DISTINCT ", groupColumn$$8, ") AS rowcount"); zephir_array_fast_append(_4$$8, _5$$8); ZEPHIR_CALL_METHOD(NULL, _2$$8, "columns", NULL, 0, _4$$8); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_NULL(_1); ZEPHIR_CALL_METHOD(NULL, totalBuilder, "orderby", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&totalQuery, totalBuilder, "getquery", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&result, totalQuery, "execute", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&row, result, "getfirst", NULL, 0); zephir_check_call_status(); if (zephir_is_true(row)) { ZEPHIR_OBS_VAR(_6); zephir_read_property(&_6, row, SL("rowcount"), PH_NOISY_CC); ZEPHIR_INIT_VAR(rowcount); ZVAL_LONG(rowcount, zephir_get_intval(_6)); } else { ZEPHIR_INIT_NVAR(rowcount); ZVAL_LONG(rowcount, 0); } ZEPHIR_SINIT_VAR(_7); div_function(&_7, rowcount, limit TSRMLS_CC); ZEPHIR_SINIT_VAR(_8); ZVAL_DOUBLE(&_8, zephir_ceil(&_7 TSRMLS_CC)); ZEPHIR_INIT_VAR(totalPages); ZVAL_LONG(totalPages, zephir_get_intval(&_8)); if (ZEPHIR_GT_LONG(totalPages, numberPage)) { ZEPHIR_INIT_VAR(next); ZVAL_LONG(next, (numberPage + 1)); } else { ZEPHIR_CPY_WRT(next, totalPages); } ZEPHIR_INIT_VAR(page); object_init(page); zephir_update_property_zval(page, SL("items"), items TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_9); ZVAL_LONG(_9, 1); zephir_update_property_zval(page, SL("first"), _9 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_9); ZVAL_LONG(_9, before); zephir_update_property_zval(page, SL("before"), _9 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_9); ZVAL_LONG(_9, numberPage); zephir_update_property_zval(page, SL("current"), _9 TSRMLS_CC); zephir_update_property_zval(page, SL("last"), totalPages TSRMLS_CC); zephir_update_property_zval(page, SL("next"), next TSRMLS_CC); zephir_update_property_zval(page, SL("total_pages"), totalPages TSRMLS_CC); zephir_update_property_zval(page, SL("total_items"), rowcount TSRMLS_CC); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_limitRows"), PH_NOISY_CC); zephir_update_property_zval(page, SL("limit"), _9 TSRMLS_CC); RETURN_CCTOR(page); }
/** * Returns a slice of the resultset to show in the pagination */ PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, getPaginate) { int numberPage, before, ZEPHIR_LAST_CALL_STATUS; zval *originalBuilder, *builder, *totalBuilder, *totalPages, *limit, *number, *query = NULL, *page, *items = NULL, *totalQuery = NULL, *result = NULL, *row = NULL, *rowcount, *next = NULL, *_0, *_1 = NULL, *_2, _3, _4, *_5; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(originalBuilder); zephir_read_property_this(&originalBuilder, this_ptr, SL("_builder"), PH_NOISY_CC); ZEPHIR_INIT_VAR(builder); if (zephir_clone(builder, originalBuilder TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_INIT_VAR(totalBuilder); if (zephir_clone(totalBuilder, builder TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_OBS_VAR(limit); zephir_read_property_this(&limit, this_ptr, SL("_limitRows"), PH_NOISY_CC); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_page"), PH_NOISY_CC); numberPage = zephir_get_intval(_0); if (!(numberPage)) { numberPage = 1; } ZEPHIR_INIT_VAR(number); ZVAL_LONG(number, (zephir_get_numberval(limit) * ((numberPage - 1)))); if (ZEPHIR_LT(number, limit)) { ZEPHIR_CALL_METHOD(NULL, builder, "limit", NULL, 0, limit); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(NULL, builder, "limit", NULL, 0, limit, number); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&query, builder, "getquery", NULL, 0); zephir_check_call_status(); if (numberPage == 1) { before = 1; } else { before = (numberPage - 1); } ZEPHIR_CALL_METHOD(&items, query, "execute", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "COUNT(*) [rowcount]", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, totalBuilder, "columns", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_NULL(_1); ZEPHIR_CALL_METHOD(NULL, totalBuilder, "orderby", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&totalQuery, totalBuilder, "getquery", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&result, totalQuery, "execute", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&row, result, "getfirst", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(_2); zephir_read_property(&_2, row, SL("rowcount"), PH_NOISY_CC); ZEPHIR_INIT_VAR(rowcount); ZVAL_LONG(rowcount, zephir_get_intval(_2)); ZEPHIR_SINIT_VAR(_3); div_function(&_3, rowcount, limit TSRMLS_CC); ZEPHIR_SINIT_VAR(_4); ZVAL_DOUBLE(&_4, zephir_ceil(&_3 TSRMLS_CC)); ZEPHIR_INIT_VAR(totalPages); ZVAL_LONG(totalPages, zephir_get_intval(&_4)); if (ZEPHIR_GT_LONG(totalPages, numberPage)) { ZEPHIR_INIT_VAR(next); ZVAL_LONG(next, (numberPage + 1)); } else { ZEPHIR_CPY_WRT(next, totalPages); } ZEPHIR_INIT_VAR(page); object_init(page); zephir_update_property_zval(page, SL("items"), items TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, 1); zephir_update_property_zval(page, SL("first"), _5 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, before); zephir_update_property_zval(page, SL("before"), _5 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, numberPage); zephir_update_property_zval(page, SL("current"), _5 TSRMLS_CC); zephir_update_property_zval(page, SL("last"), totalPages TSRMLS_CC); zephir_update_property_zval(page, SL("next"), next TSRMLS_CC); zephir_update_property_zval(page, SL("total_pages"), totalPages TSRMLS_CC); zephir_update_property_zval(page, SL("total_items"), rowcount TSRMLS_CC); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_limitRows"), PH_NOISY_CC); zephir_update_property_zval(page, SL("limit"), _5 TSRMLS_CC); RETURN_CCTOR(page); }
/** * Returns a slice of the resultset to show in the pagination * * @return stdClass */ PHP_METHOD(Phalcon_Paginator_Adapter_NativeArray, getPaginate){ zval *one, *config, *items, *show, *page_number = NULL, *page; zval *number, *rounded_total, *total_pages, *before_page_number; zval *start, *slice, *compare = NULL, *next = NULL, *before = NULL; PHALCON_MM_GROW(); /** * TODO: Rewrite the whole method! */ PHALCON_INIT_VAR(one); ZVAL_LONG(one, 1); PHALCON_OBS_VAR(config); phalcon_read_property_this(&config, this_ptr, SL("_config"), PH_NOISY_CC); PHALCON_OBS_VAR(items); phalcon_array_fetch_string(&items, config, SL("data"), PH_NOISY_CC); if (Z_TYPE_P(items) != IS_ARRAY) { PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "Invalid data for paginator"); return; } PHALCON_OBS_VAR(show); phalcon_read_property_this(&show, this_ptr, SL("_limitRows"), PH_NOISY_CC); PHALCON_OBS_VAR(page_number); phalcon_read_property_this(&page_number, this_ptr, SL("_page"), PH_NOISY_CC); if (!zend_is_true(page_number)) { PHALCON_CPY_WRT(page_number, one); } PHALCON_INIT_VAR(page); object_init(page); PHALCON_INIT_VAR(number); phalcon_fast_count(number, items TSRMLS_CC); PHALCON_INIT_VAR(rounded_total); div_function(rounded_total, number, show TSRMLS_CC); PHALCON_INIT_VAR(total_pages); PHALCON_CALL_FUNC_PARAMS_1(total_pages, "intval", rounded_total); /** * Increase total_pages if wasn't integer */ if (!PHALCON_IS_EQUAL(total_pages, rounded_total)) { PHALCON_SEPARATE_NMO(total_pages); increment_function(total_pages); } PHALCON_INIT_VAR(before_page_number); sub_function(before_page_number, page_number, one TSRMLS_CC); PHALCON_INIT_VAR(start); mul_function(start, show, before_page_number TSRMLS_CC); PHALCON_INIT_VAR(slice); PHALCON_CALL_FUNC_PARAMS_3(slice, "array_slice", items, start, show); phalcon_update_property_zval(page, SL("items"), slice TSRMLS_CC); PHALCON_INIT_VAR(compare); is_smaller_function(compare, page_number, total_pages TSRMLS_CC); if (PHALCON_IS_TRUE(compare)) { PHALCON_INIT_VAR(next); phalcon_add_function(next, page_number, one TSRMLS_CC); } else { PHALCON_CPY_WRT(next, total_pages); } phalcon_update_property_zval(page, SL("next"), next TSRMLS_CC); is_smaller_function(compare, one, page_number TSRMLS_CC); if (PHALCON_IS_TRUE(compare)) { PHALCON_INIT_VAR(before); sub_function(before, page_number, one TSRMLS_CC); } else { PHALCON_CPY_WRT(before, one); } phalcon_update_property_zval(page, SL("first"), one TSRMLS_CC); phalcon_update_property_zval(page, SL("before"), before TSRMLS_CC); phalcon_update_property_zval(page, SL("current"), page_number TSRMLS_CC); phalcon_update_property_zval(page, SL("last"), total_pages TSRMLS_CC); phalcon_update_property_zval(page, SL("total_pages"), total_pages TSRMLS_CC); phalcon_update_property_zval(page, SL("total_items"), number TSRMLS_CC); RETURN_CTOR(page); }
PHP_METHOD(Test_Quantum, Harmos) { zend_bool _14, _17, _33, _36; zval *_11 = NULL, *_12 = NULL, *_13 = NULL; zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_37 = NULL; int i, j, n, ZEPHIR_LAST_CALL_STATUS, _15, _16, _18, _19, _34, _35; zval *x_param = NULL, *psr, *psi, *p2, *v, *paramater, *fp = NULL, *_0 = NULL, _1 = zval_used_for_init, _2 = zval_used_for_init, *_4 = NULL, *_6 = NULL, *_8 = NULL, *_10 = NULL, *tmp, *_20, *_21, *_22, *_23, *_24, *_25, *_26, *_27, _28 = zval_used_for_init, *_29, *_30, *_31, *_32; double x, dt, dx, k0, item_psr, item_psi; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &x_param); x = zephir_get_doubleval(x_param); dx = 0.02; k0 = (3.0 * 3.14159265358979323846); dt = ((dx * dx) / 4.0); ZEPHIR_INIT_VAR(paramater); array_init_size(paramater, 7); ZEPHIR_INIT_VAR(_0); ZVAL_DOUBLE(_0, dx); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_DOUBLE(_0, k0); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_DOUBLE(_0, dt); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_DOUBLE(_0, x); zephir_array_fast_append(paramater, _0); i = 0; ZEPHIR_INIT_VAR(psr); array_init(psr); ZEPHIR_INIT_VAR(psi); array_init(psi); ZEPHIR_INIT_VAR(p2); array_init(p2); ZEPHIR_INIT_VAR(v); array_init(v); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "harmos.txt", 0); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "w", 0); ZEPHIR_CALL_FUNCTION(&fp, "fopen", &_3, &_1, &_2); zephir_check_call_status(); if (!(zephir_is_true(fp))) { RETURN_MM_LONG(1); } while (1) { if (!(i <= 751)) { break; } ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, (k0 * x)); ZEPHIR_CALL_FUNCTION(&_4, "sin", &_5, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, ((x * x) * 2.0)); ZEPHIR_CALL_FUNCTION(&_6, "exp", &_7, &_1); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_8); div_function(_8, _4, _6 TSRMLS_CC); item_psi = zephir_get_numberval(_8); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, (k0 * x)); ZEPHIR_CALL_FUNCTION(&_4, "cos", &_9, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, ((x * x) * 2.0)); ZEPHIR_CALL_FUNCTION(&_6, "exp", &_7, &_1); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_10); div_function(_10, _4, _6 TSRMLS_CC); item_psr = zephir_get_numberval(_10); ZEPHIR_INIT_NVAR(_11); array_init_size(_11, 2); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, item_psr); zephir_array_fast_append(_11, _0); zephir_array_update_long(&psr, i, &_11, PH_COPY | PH_SEPARATE, "test/quantum.zep", 38); ZEPHIR_INIT_NVAR(_12); array_init_size(_12, 2); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, item_psi); zephir_array_fast_append(_12, _0); zephir_array_update_long(&psi, i, &_12, PH_COPY | PH_SEPARATE, "test/quantum.zep", 39); ZEPHIR_INIT_NVAR(_13); array_init_size(_13, 2); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, (double) ((double) (5.0 * x) * x)); zephir_array_fast_append(_13, _0); zephir_array_update_long(&v, i, &_13, PH_COPY | PH_SEPARATE, "test/quantum.zep", 40); x = (x + dx); i++; } i = 1; j = 1; ZEPHIR_INIT_VAR(tmp); array_init_size(tmp, 2); ZEPHIR_INIT_BNVAR(_0); ZVAL_DOUBLE(_0, 2.0); zephir_array_fast_append(tmp, _0); _16 = 20000; _15 = 0; _14 = 0; if (_15 <= _16) { while (1) { if (_14) { _15++; if (!(_15 <= _16)) { break; } } else { _14 = 1; } n = _15; _19 = (751 - 1); _18 = 1; _17 = 0; if (_18 <= _19) { while (1) { if (_17) { _18++; if (!(_18 <= _19)) { break; } } else { _17 = 1; } i = _18; zephir_array_fetch_long(&_20, psr, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_21, _20, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_22, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_23, psi, (i + 1), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _23, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_25, psi, (i - 1), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_26, _25, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function(&_1, _24, _26 TSRMLS_CC); zephir_array_fetch_long(&_24, tmp, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_26, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_27, _26, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _24, _27 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); zephir_sub_function(_8, &_1, &_2 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _22, _8 TSRMLS_CC); zephir_array_fetch_long(&_22, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); mul_function(_8, _22, _24 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); div_function(&_2, &_1, _8 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_sub_function(&_1, _21, &_2 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_22, v, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _22, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _21, _24 TSRMLS_CC); zephir_array_fetch_long(&_21, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _21, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_28); mul_function(&_28, &_2, _24 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); zephir_add_function(_8, &_1, &_28 TSRMLS_CC); zephir_array_update_multi(&psr, &_8 TSRMLS_CC, SL("ll"), 2, i, 1); zephir_array_fetch_long(&_24, psr, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_27, _24, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_29, psr, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_30, _29, 1, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _27, _30 TSRMLS_CC); zephir_array_fetch_long(&_27, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_30, _27, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_31, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_32, _31, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _30, _32 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); zephir_add_function(_8, &_1, &_2 TSRMLS_CC); zephir_array_update_long(&p2, i, &_8, PH_COPY | PH_SEPARATE, "test/quantum.zep", 53); } } _35 = (751 - 1); _34 = 1; _33 = 0; if (_34 <= _35) { while (1) { if (_33) { _34++; if (!(_34 <= _35)) { break; } } else { _33 = 1; } j = _34; ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 0, 1); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 751, 1); zephir_array_fetch_long(&_20, psi, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_21, _20, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_22, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_23, psr, (j + 1), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _23, 1, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_25, psr, (j - 1), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_26, _25, 1, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function(&_1, _24, _26 TSRMLS_CC); zephir_array_fetch_long(&_24, tmp, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_26, psr, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_27, _26, 1, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _24, _27 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_10); zephir_sub_function(_10, &_1, &_2 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _22, _10 TSRMLS_CC); zephir_array_fetch_long(&_22, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_INIT_LNVAR(_10); mul_function(_10, _22, _24 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); div_function(&_2, &_1, _10 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function(&_1, _21, &_2 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_22, v, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _22, 0, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _21, _24 TSRMLS_CC); zephir_array_fetch_long(&_21, psr, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_24, _21, 1, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_28); mul_function(&_28, &_2, _24 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_10); zephir_sub_function(_10, &_1, &_28 TSRMLS_CC); zephir_array_update_multi(&psi, &_10 TSRMLS_CC, SL("ll"), 2, j, 1); } } _36 = n == 0; if (!(_36)) { _36 = (n % 2000) == 0; } if (_36) { i = 1; while (1) { if (!(i < (751 - 1))) { break; } zephir_array_fetch_long(&_20, p2, i, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "%16.8lf %16.8lf %16.8lf \n", 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_DOUBLE(&_2, ((double) i * dx)); ZEPHIR_SINIT_NVAR(_28); ZVAL_DOUBLE(&_28, ((double) n * dt)); ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_37, fp, &_1, &_2, &_28, _20); zephir_check_call_status(); i = (i + 10); } ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "\n", 0); ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_37, fp, &_1); zephir_check_call_status(); } j = 1; while (1) { if (!(j < (751 - 1))) { break; } zephir_array_fetch_long(&_20, psi, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_21, _20, 1, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_update_multi(&psi, &_21 TSRMLS_CC, SL("ll"), 2, j, 0); zephir_array_fetch_long(&_21, psr, j, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_22, _21, 1, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_update_multi(&psr, &_22 TSRMLS_CC, SL("ll"), 2, j, 0); j++; } } } RETURN_MM_BOOL(1); }
/** * Returns a slice of the resultset to show in the pagination * * @return stdClass */ PHP_METHOD(Phalcon_Paginator_Adapter_Model, getPaginate){ zval *one, *zero, *show, *config, *items, *page_number = NULL; zval *smaller, *n, *page, *last_show_page, *start; zval *last_page, *possible_pages = NULL, *total_pages; zval *compare = NULL, *page_items, *i, *valid = NULL, *current = NULL, *maximum_pages; zval *next = NULL, *additional_page, *before = NULL, *remainder; zval *pages_total = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(one); ZVAL_LONG(one, 1); PHALCON_INIT_VAR(zero); ZVAL_LONG(zero, 0); PHALCON_OBS_VAR(show); phalcon_read_property(&show, this_ptr, SL("_limitRows"), PH_NOISY_CC); PHALCON_OBS_VAR(config); phalcon_read_property(&config, this_ptr, SL("_config"), PH_NOISY_CC); PHALCON_OBS_VAR(items); phalcon_array_fetch_string(&items, config, SL("data"), PH_NOISY_CC); PHALCON_OBS_VAR(page_number); phalcon_read_property(&page_number, this_ptr, SL("_page"), PH_NOISY_CC); if (Z_TYPE_P(page_number) == IS_NULL) { PHALCON_CPY_WRT(page_number, one); } PHALCON_INIT_VAR(smaller); is_smaller_function(smaller, show, zero TSRMLS_CC); if (PHALCON_IS_TRUE(smaller)) { PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "The start page number is zero or less"); return; } PHALCON_INIT_VAR(n); phalcon_fast_count(n, items TSRMLS_CC); PHALCON_INIT_VAR(page); object_init(page); PHALCON_INIT_VAR(last_show_page); sub_function(last_show_page, page_number, one TSRMLS_CC); PHALCON_INIT_VAR(start); mul_function(start, show, last_show_page TSRMLS_CC); PHALCON_INIT_VAR(last_page); sub_function(last_page, n, one TSRMLS_CC); PHALCON_INIT_VAR(possible_pages); div_function(possible_pages, last_page, show TSRMLS_CC); PHALCON_INIT_VAR(total_pages); PHALCON_CALL_FUNC_PARAMS_1(total_pages, "ceil", possible_pages); if (Z_TYPE_P(items) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "Invalid data for paginator"); return; } if (Z_TYPE_P(page_number) == IS_NULL) { PHALCON_CPY_WRT(page_number, zero); } PHALCON_INIT_VAR(compare); is_smaller_function(compare, start, zero TSRMLS_CC); if (PHALCON_IS_TRUE(compare)) { PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "The start page number is zero or less"); return; } PHALCON_INIT_VAR(page_items); array_init(page_items); is_smaller_function(compare, zero, n TSRMLS_CC); if (PHALCON_IS_TRUE(compare)) { /** * Seek to the desired position */ is_smaller_or_equal_function(compare, start, n TSRMLS_CC); if (PHALCON_IS_TRUE(compare)) { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(items, "seek", start); } else { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(items, "seek", one); PHALCON_CPY_WRT(page_number, one); } /** * The record must be iterable */ PHALCON_INIT_VAR(i); ZVAL_LONG(i, 1); while (1) { PHALCON_INIT_NVAR(r0); PHALCON_CALL_METHOD(r0, items, "valid"); PHALCON_CPY_WRT(valid, r0); if (PHALCON_IS_NOT_FALSE(valid)) { } else { break; } PHALCON_INIT_NVAR(current); PHALCON_CALL_METHOD(current, items, "current"); phalcon_array_append(&page_items, current, PH_SEPARATE TSRMLS_CC); PHALCON_INIT_NVAR(compare); is_smaller_or_equal_function(compare, show, i TSRMLS_CC); if (PHALCON_IS_TRUE(compare)) { break; } PHALCON_SEPARATE(i); increment_function(i); } } phalcon_update_property_zval(page, SL("items"), page_items TSRMLS_CC); phalcon_update_property_zval(page, SL("first"), one TSRMLS_CC); PHALCON_INIT_VAR(maximum_pages); phalcon_add_function(maximum_pages, start, show TSRMLS_CC); is_smaller_function(compare, maximum_pages, n TSRMLS_CC); if (PHALCON_IS_TRUE(compare)) { PHALCON_INIT_VAR(next); phalcon_add_function(next, page_number, one TSRMLS_CC); } else { is_equal_function(compare, maximum_pages, n TSRMLS_CC); if (PHALCON_IS_TRUE(compare)) { PHALCON_CPY_WRT(next, n); } else { div_function(possible_pages, n, show TSRMLS_CC); PHALCON_INIT_VAR(additional_page); phalcon_add_function(additional_page, possible_pages, one TSRMLS_CC); PHALCON_INIT_NVAR(next); PHALCON_CALL_FUNC_PARAMS_1(next, "intval", additional_page); } } is_smaller_function(compare, total_pages, next TSRMLS_CC); if (PHALCON_IS_TRUE(compare)) { PHALCON_CPY_WRT(next, total_pages); } phalcon_update_property_zval(page, SL("next"), next TSRMLS_CC); is_smaller_function(compare, one, page_number TSRMLS_CC); if (PHALCON_IS_TRUE(compare)) { PHALCON_INIT_VAR(before); sub_function(before, page_number, one TSRMLS_CC); } else { PHALCON_CPY_WRT(before, one); } phalcon_update_property_zval(page, SL("before"), before TSRMLS_CC); phalcon_update_property_zval(page, SL("current"), page_number TSRMLS_CC); PHALCON_INIT_VAR(remainder); mod_function(remainder, n, show TSRMLS_CC); div_function(possible_pages, n, show TSRMLS_CC); if (!PHALCON_IS_LONG(remainder, 0)) { PHALCON_INIT_NVAR(next); phalcon_add_function(next, possible_pages, one TSRMLS_CC); PHALCON_INIT_VAR(pages_total); PHALCON_CALL_FUNC_PARAMS_1(pages_total, "intval", next); } else { PHALCON_CPY_WRT(pages_total, possible_pages); } phalcon_update_property_zval(page, SL("last"), pages_total TSRMLS_CC); phalcon_update_property_zval(page, SL("total_pages"), pages_total TSRMLS_CC); RETURN_CTOR(page); }
/** * Resize the image to the given size */ PHP_METHOD(Phalcon_Image_Adapter, resize) { zephir_fcall_cache_entry *_12 = NULL; zend_bool _0, _4; double ratio; zval *width_param = NULL, *height_param = NULL, *master_param = NULL, *_1 = NULL, *_2, *_3, *_5, *_6, *_7 = NULL, *_8, _9, *_10 = NULL, *_11 = NULL, _13, *_14 = NULL, *_15 = NULL, *_16; int width, height, master, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &width_param, &height_param, &master_param); if (!width_param) { width = 0; } else { width = zephir_get_intval(width_param); } if (!height_param) { height = 0; } else { height = zephir_get_intval(height_param); } if (!master_param) { master = 4; } else { master = zephir_get_intval(master_param); } if (master == 7) { _0 = !width; if (!(_0)) { _0 = !height; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 80); return; } } else { if (master == 4) { _0 = !width; if (!(_0)) { _0 = !height; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 88); return; } ZEPHIR_INIT_VAR(_1); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); if ((zephir_safe_div_zval_long(_2, width TSRMLS_CC)) > (int) (zephir_safe_div_zval_long(_3, height TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 2); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 3); } master = zephir_get_numberval(_1); } if (master == 5) { _4 = !width; if (!(_4)) { _4 = !height; } if (_4) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 97); return; } ZEPHIR_INIT_LNVAR(_1); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); if ((zephir_safe_div_zval_long(_2, width TSRMLS_CC)) > (int) (zephir_safe_div_zval_long(_3, height TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 3); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 2); } master = zephir_get_numberval(_1); } do { if (master == 2) { if (!(width)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width must be specified", "phalcon/image/adapter.zep", 107); return; } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * width), _3 TSRMLS_CC)); break; } if (master == 3) { if (!(height)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "height must be specified", "phalcon/image/adapter.zep", 114); return; } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * height), _3 TSRMLS_CC)); break; } if (master == 6) { _4 = !width; if (!(_4)) { _4 = !height; } if (_4) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 121); return; } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_1); div_function(_1, _2, _3 TSRMLS_CC); ratio = zephir_get_numberval(_1); if ((zephir_safe_div_long_long(width, height TSRMLS_CC)) > ratio) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * width), _3 TSRMLS_CC)); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_5) * height), _6 TSRMLS_CC)); } break; } if (master == 1) { if (!(width)) { ZEPHIR_OBS_VAR(_7); zephir_read_property_this(&_7, this_ptr, SL("_width"), PH_NOISY_CC); width = zephir_get_intval(_7); } if (!(height)) { ZEPHIR_OBS_NVAR(_7); zephir_read_property_this(&_7, this_ptr, SL("_height"), PH_NOISY_CC); width = zephir_get_intval(_7); } break; } } while(0); } ZEPHIR_INIT_VAR(_8); ZEPHIR_SINIT_VAR(_9); ZVAL_LONG(&_9, width); zephir_round(_8, &_9, NULL, NULL TSRMLS_CC); ZEPHIR_INIT_VAR(_10); ZVAL_LONG(_10, 1); ZEPHIR_CALL_FUNCTION(&_11, "max", &_12, 68, _8, _10); zephir_check_call_status(); width = zephir_get_intval(_11); ZEPHIR_INIT_NVAR(_10); ZEPHIR_SINIT_VAR(_13); ZVAL_LONG(&_13, height); zephir_round(_10, &_13, NULL, NULL TSRMLS_CC); ZEPHIR_INIT_VAR(_14); ZVAL_LONG(_14, 1); ZEPHIR_CALL_FUNCTION(&_15, "max", &_12, 68, _10, _14); zephir_check_call_status(); height = zephir_get_intval(_15); ZEPHIR_INIT_NVAR(_14); ZVAL_LONG(_14, width); ZEPHIR_INIT_VAR(_16); ZVAL_LONG(_16, height); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_resize", NULL, 0, _14, _16); zephir_check_call_status(); RETURN_THIS(); }