PHP_METHOD(Test_NativeArray, testArray24) { double b = 0; zval a, _0; zval *this_ptr = getThis(); ZVAL_UNDEF(&a); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); b = 0.0; ZEPHIR_INIT_VAR(&a); zephir_create_array(&a, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(&_0); ZVAL_DOUBLE(&_0, b); zephir_array_update_long(&a, 0, &_0, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); ZEPHIR_INIT_NVAR(&_0); ZVAL_DOUBLE(&_0, b); zephir_array_update_long(&a, 1, &_0, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); ZEPHIR_INIT_NVAR(&_0); ZVAL_DOUBLE(&_0, b); zephir_array_update_long(&a, 2, &_0, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); RETURN_CCTOR(&a); }
PHP_METHOD(Test_Vars, testDoubleVarDump) { zval _0, _1; 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; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); a = (double) (1); ZEPHIR_INIT_VAR(&_0); ZEPHIR_INIT_NVAR(&_0); ZVAL_DOUBLE(&_0, a); zephir_var_dump(&_0 TSRMLS_CC); ZEPHIR_INIT_VAR(&_1); ZEPHIR_INIT_NVAR(&_1); ZVAL_DOUBLE(&_1, a); zephir_var_export(&_1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
static void json_create_zval(zval **z, smart_str *buf, int type) { ALLOC_INIT_ZVAL(*z); if (type == IS_LONG) { double d = zend_strtod(buf->c, NULL); if (d > LONG_MAX || d < -LONG_MAX) { ZVAL_DOUBLE(*z, d); } else { ZVAL_LONG(*z, (long)d); } } else if (type == IS_DOUBLE) { ZVAL_DOUBLE(*z, zend_strtod(buf->c, NULL)); } else if (type == IS_STRING) { ZVAL_STRINGL(*z, buf->c, buf->len, 1); } else if (type == IS_BOOL) { ZVAL_BOOL(*z, (*(buf->c) == 't')); } else /* type == IS_NULL) || type unknown */ { ZVAL_NULL(*z); } }
PHP_METHOD(Test_Oo, testInstance8) { zval o, _0, _1; 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); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&o); object_init_ex(&o, test_oo_ooconstructparams_ce); ZVAL_DOUBLE(&_0, 1.2); ZVAL_DOUBLE(&_1, 7.30); ZEPHIR_CALL_METHOD(NULL, &o, "__construct", NULL, 48, &_0, &_1); zephir_check_call_status(); RETURN_CCTOR(o); }
PHP_METHOD(Test_NativeArray, testArray8) { double a = 0, b = 0, c = 0; zval d, _0; zval *this_ptr = getThis(); ZVAL_UNDEF(&d); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); a = (double) (1); b = (double) (2); c = (double) (3); ZEPHIR_INIT_VAR(&d); zephir_create_array(&d, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(&_0); ZVAL_DOUBLE(&_0, a); zephir_array_fast_append(&d, &_0); ZEPHIR_INIT_NVAR(&_0); ZVAL_DOUBLE(&_0, b); zephir_array_fast_append(&d, &_0); ZEPHIR_INIT_NVAR(&_0); ZVAL_DOUBLE(&_0, c); zephir_array_fast_append(&d, &_0); RETURN_CCTOR(&d); }
PHP_METHOD(PocketMine_Level_Generator_Noise_Generator, noise3D) { zephir_fcall_cache_entry *_5 = NULL; int i = 0, ZEPHIR_LAST_CALL_STATUS; zend_bool normalized; zval *x_param = NULL, *y_param = NULL, *z_param = NULL, *normalized_param = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_6, *_7; double x, y, z, result = 0, amp = 1, freq = 1, max = 0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &x_param, &y_param, &z_param, &normalized_param); x = zephir_get_doubleval(x_param); y = zephir_get_doubleval(y_param); z = zephir_get_doubleval(z_param); if (!normalized_param) { normalized = 0; } else { normalized = zephir_get_boolval(normalized_param); } while (1) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("octaves"), PH_NOISY_CC); if (!(ZEPHIR_GT_LONG(_0, i))) { break; } ZEPHIR_INIT_NVAR(_2); ZVAL_DOUBLE(_2, (x * freq)); ZEPHIR_INIT_NVAR(_3); ZVAL_DOUBLE(_3, (y * freq)); ZEPHIR_INIT_NVAR(_4); ZVAL_DOUBLE(_4, (z * freq)); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getnoise3d", &_5, _2, _3, _4); zephir_check_call_status(); result += (double) (zephir_get_doubleval(_1) * amp); max += amp; _6 = zephir_fetch_nproperty_this(this_ptr, SL("frequency"), PH_NOISY_CC); freq *= zephir_get_numberval(_6); _7 = zephir_fetch_nproperty_this(this_ptr, SL("amplitude"), PH_NOISY_CC); amp *= zephir_get_numberval(_7); i++; } if (normalized == 1) { result = (result / max); } RETURN_MM_DOUBLE(result); }
static VALUE set(VALUE self, VALUE key, VALUE value) { zval *php_value; MAKE_STD_ZVAL(php_value); switch(TYPE(value)) { case T_FIXNUM: ZVAL_LONG(php_value, NUM2INT(value)); break; case T_TRUE: ZVAL_BOOL(php_value, value == Qtrue ? 1 : 0); break; case T_FLOAT: case T_BIGNUM: ZVAL_DOUBLE(php_value, NUM2DBL(value)); break; case T_STRING: ZVAL_STRINGL(php_value, StringValuePtr(value), RSTRING_LEN(value), 1); break; } ZEND_SET_SYMBOL(EG(active_symbol_table), StringValuePtr(key), php_value); return value; }
/* {{{ php_register_server_variables */ static inline void php_register_server_variables(void) { zval tmp; zval *arr = &PG(http_globals)[TRACK_VARS_SERVER]; HashTable *ht; zval_ptr_dtor_nogc(arr); array_init(arr); /* Server variables */ if (sapi_module.register_server_variables) { sapi_module.register_server_variables(arr); } ht = Z_ARRVAL_P(arr); /* PHP Authentication support */ if (SG(request_info).auth_user) { ZVAL_STRING(&tmp, SG(request_info).auth_user); php_register_variable_quick("PHP_AUTH_USER", sizeof("PHP_AUTH_USER")-1, &tmp, ht); } if (SG(request_info).auth_password) { ZVAL_STRING(&tmp, SG(request_info).auth_password); php_register_variable_quick("PHP_AUTH_PW", sizeof("PHP_AUTH_PW")-1, &tmp, ht); } if (SG(request_info).auth_digest) { ZVAL_STRING(&tmp, SG(request_info).auth_digest); php_register_variable_quick("PHP_AUTH_DIGEST", sizeof("PHP_AUTH_DIGEST")-1, &tmp, ht); } /* store request init time */ ZVAL_DOUBLE(&tmp, sapi_get_request_time()); php_register_variable_quick("REQUEST_TIME_FLOAT", sizeof("REQUEST_TIME_FLOAT")-1, &tmp, ht); ZVAL_LONG(&tmp, zend_dval_to_lval(Z_DVAL(tmp))); php_register_variable_quick("REQUEST_TIME", sizeof("REQUEST_TIME")-1, &tmp, ht); }
PHP_METHOD(Test_Geometry, distanceStatic) { zval *x1_param = NULL, *y1_param = NULL, *x2_param = NULL, *y2_param = NULL, _0; double x1, y1, x2, y2; 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, 4, 0, &x1_param, &y1_param, &x2_param, &y2_param); x1 = zephir_get_doubleval(x1_param); y1 = zephir_get_doubleval(y1_param); x2 = zephir_get_doubleval(x2_param); y2 = zephir_get_doubleval(y2_param); ZVAL_DOUBLE(&_0, ((((x1 - x2)) * ((x1 - x2))) + (((y1 - y2)) * ((y1 - y2))))); RETURN_DOUBLE(sqrt(((((x1 - x2)) * ((x1 - x2))) + (((y1 - y2)) * ((y1 - y2)))))); }
/* {{{ static void php_couchbase_storage_callback(...) */ static void php_couchbase_storage_callback(libcouchbase_t handle, const void *cookie, libcouchbase_storage_t operation, libcouchbase_error_t error, const void *key, size_t nkey, uint64_t cas) { php_couchbase_ctx *ctx = (php_couchbase_ctx *)cookie; php_ignore_value(handle); php_ignore_value(operation); php_ignore_value(key); php_ignore_value(nkey); php_ignore_value(cas); if (--ctx->res->seqno == 0) { ctx->res->io->stop_event_loop(ctx->res->io); } ctx->exception = error; if (error != LIBCOUCHBASE_SUCCESS && error != LIBCOUCHBASE_AUTH_CONTINUE) { return; } ZVAL_DOUBLE(ctx->rv, cas); }
PHP_METHOD(PocketMine_Math_Vector2, normalize) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3; double len; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "length", NULL); zephir_check_call_status(); len = zephir_get_doubleval(_0); if (len != 0) { ZEPHIR_INIT_VAR(_2); ZVAL_DOUBLE(_2, len); ZEPHIR_CALL_METHOD(&_1, this_ptr, "divide", NULL, _2); zephir_check_call_status(); RETURN_CCTOR(_1); } object_init_ex(return_value, pocketmine_math_vector2_ce); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, _2, _3); zephir_check_call_status(); RETURN_MM(); }
static int tidy_doc_cast_handler(zval *in, zval *out, int type) { TidyBuffer output; PHPTidyObj *obj; switch (type) { case IS_LONG: ZVAL_LONG(out, 0); break; case IS_DOUBLE: ZVAL_DOUBLE(out, 0); break; case _IS_BOOL: ZVAL_TRUE(out); break; case IS_STRING: obj = Z_TIDY_P(in); tidyBufInit(&output); tidySaveBuffer (obj->ptdoc->doc, &output); ZVAL_STRINGL(out, (char *) output.bp, output.size ? output.size-1 : 0); tidyBufFree(&output); break; default: return FAILURE; } return SUCCESS; }
/* {{{ pip_pyobject_to_zval(PyObject *obj) Converts the given PyObject into an equivalent zval */ zval * pip_pyobject_to_zval(PyObject *obj) { zval *ret; if (obj == NULL) { return NULL; } /* Initialize the return value */ MAKE_STD_ZVAL(ret); if (PyInt_Check(obj)) { ZVAL_LONG(ret, PyInt_AsLong(obj)); } else if (PyLong_Check(obj)) { ZVAL_LONG(ret, PyLong_AsLong(obj)); } else if (PyFloat_Check(obj)) { ZVAL_DOUBLE(ret, PyFloat_AsDouble(obj)); } else if (PyString_Check(obj)) { ZVAL_STRINGL(ret, PyString_AsString(obj), PyString_Size(obj), 1); } else if (obj == Py_None) { ZVAL_NULL(ret); } else if (PyTuple_Check(obj) || PyList_Check(obj)) { ret = pip_sequence_to_hash(obj); } else if (PyDict_Check(obj)) { ret = pip_mapping_to_hash(obj); } else { ret = pip_pyobject_to_zobject(obj); } return ret; }
/* {{{ * Internal function which calls the udat_parse * param int store_error acts like a boolean * if set to 1 - store any error encountered in the parameter parse_error * if set to 0 - no need to store any error encountered in the parameter parse_error */ static void internal_parse_to_timestamp(IntlDateFormatter_object *dfo, char* text_to_parse, int32_t text_len, int32_t *parse_pos, zval *return_value) { double result = 0; UDate timestamp =0; UChar* text_utf16 = NULL; int32_t text_utf16_len = 0; /* Convert timezone to UTF-16. */ intl_convert_utf8_to_utf16(&text_utf16, &text_utf16_len, text_to_parse, text_len, &INTL_DATA_ERROR_CODE(dfo)); INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" ); timestamp = udat_parse( DATE_FORMAT_OBJECT(dfo), text_utf16, text_utf16_len, parse_pos, &INTL_DATA_ERROR_CODE(dfo)); if( text_utf16 ){ efree(text_utf16); } INTL_METHOD_CHECK_STATUS( dfo, "Date parsing failed" ); /* Since return is in sec. */ result = (double)timestamp / U_MILLIS_PER_SECOND; if(result > LONG_MAX || result < -LONG_MAX) { ZVAL_DOUBLE(return_value, result<0?ceil(result):floor(result)); } else { ZVAL_LONG(return_value, (zend_long)result); } }
static int swVal_to_zval(swVal *val, zval *zv) { uint8_t _bool_val = 0; long _int_val = 0; double _float_val = 0.0; if (val == NULL) { return SW_ERR; } switch(val->type) { case SW_VAL_BOOL: memcpy(&_bool_val, val->value, sizeof(_bool_val)); ZVAL_BOOL(zv, _bool_val); break; case SW_VAL_DOUBLE: memcpy(&_float_val, val->value, sizeof(_float_val)); ZVAL_DOUBLE(zv, _float_val); break; case SW_VAL_LONG: memcpy(&_int_val, val->value, sizeof(_int_val)); ZVAL_LONG(zv, _int_val); break; case SW_VAL_STRING: SW_ZVAL_STRINGL(zv, val->value, val->length, 1); break; default: swWarn("unknown type."); return SW_ERR; } return SW_OK; }
static int _common_callback_double_arg(void *yajl_ctx, char *type, double v) { php_yajl_record *instance = (php_yajl_record *)yajl_ctx; zval *return_handle = NULL; HashTable *hash; zval zType, zArg, *pzType=&zType, *pzArg=&zArg; /* Tell PHP where to put the return value */ php_printf("%p\n", &instance->fci); instance->fci.retval_ptr_ptr = &return_handle; /* Bundle all the input parameters into an array. */ instance->fci.params = safe_emalloc(sizeof(zval *), 3, 0); instance->fci.param_count = 3; instance->fci.params[0] = &instance->php_ctx; ZVAL_STRING(pzType, type, 1); instance->fci.params[1] = &pzType; ZVAL_DOUBLE(pzArg, v); instance->fci.params[2] = &pzArg; /* Call the supplied function. */ zend_call_function(&instance->fci, &instance->fci_cache TSRMLS_CC); /* If the allocation succeeded, free the parameter array. */ if(instance->fci.params) { efree(instance->fci.params); } /* Without this, PHP seems to want to abort trap on me. */ return 1; }
int zephir_declare_class_constant_double(zend_class_entry *ce, const char *name, size_t name_length, double value) { zval constant; ZVAL_DOUBLE(&constant, value); return zephir_declare_class_constant(ce, name, name_length, &constant); }
PHP_METHOD(Test_NativeArray, testArrayAppend2) { int f = 5; double e = 1.10; zend_bool d = 0; zval *b; zval *a, *c = NULL, *g, *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(b); ZVAL_STRING(b, "hello", 1); ZEPHIR_INIT_VAR(c); ZVAL_NULL(c); ZEPHIR_INIT_VAR(g); array_init(g); ZEPHIR_INIT_VAR(a); array_init(a); zephir_array_append(&a, b, PH_SEPARATE); zephir_array_append(&a, c, PH_SEPARATE); ZEPHIR_INIT_VAR(_0); ZVAL_BOOL(_0, d); zephir_array_append(&a, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_DOUBLE(_0, e); zephir_array_append(&a, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_LONG(_0, f); zephir_array_append(&a, _0, PH_SEPARATE); zephir_array_append(&a, g, PH_SEPARATE); RETURN_CCTOR(a); }
/* {{{ php_register_server_variables */ static inline void php_register_server_variables(void) { zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_SERVER]); array_init(&PG(http_globals)[TRACK_VARS_SERVER]); /* Server variables */ if (sapi_module.register_server_variables) { sapi_module.register_server_variables(&PG(http_globals)[TRACK_VARS_SERVER]); } /* PHP Authentication support */ if (SG(request_info).auth_user) { php_register_variable("PHP_AUTH_USER", SG(request_info).auth_user, &PG(http_globals)[TRACK_VARS_SERVER]); } if (SG(request_info).auth_password) { php_register_variable("PHP_AUTH_PW", SG(request_info).auth_password, &PG(http_globals)[TRACK_VARS_SERVER]); } if (SG(request_info).auth_digest) { php_register_variable("PHP_AUTH_DIGEST", SG(request_info).auth_digest, &PG(http_globals)[TRACK_VARS_SERVER]); } /* store request init time */ { zval request_time_float, request_time_long; ZVAL_DOUBLE(&request_time_float, sapi_get_request_time()); php_register_variable_ex("REQUEST_TIME_FLOAT", &request_time_float, &PG(http_globals)[TRACK_VARS_SERVER]); ZVAL_LONG(&request_time_long, zend_dval_to_lval(Z_DVAL(request_time_float))); php_register_variable_ex("REQUEST_TIME", &request_time_long, &PG(http_globals)[TRACK_VARS_SERVER]); } }
int zend_declare_property_double(zend_class_entry *ce, char *name, int name_length, double value, int access_type TSRMLS_DC) { zval *property = pemalloc(sizeof(zval), ce->type & ZEND_INTERNAL_CLASS); INIT_PZVAL(property); ZVAL_DOUBLE(property, value); return zend_declare_property(ce, name, name_length, property, access_type TSRMLS_CC); }
PHP_METHOD(Test_Oo, testInstance8) { zval *o, *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(o); object_init_ex(o, test_oo_ooconstructparams_ce); ZEPHIR_INIT_VAR(_0); ZVAL_DOUBLE(_0, 1.2); ZEPHIR_INIT_VAR(_1); ZVAL_DOUBLE(_1, 7.30); zephir_call_method_p2_noret(o, "__construct", _0, _1); RETURN_CCTOR(o); }
/** * Natural compare with double operandus on right */ int phalcon_compare_strict_double(zval *op1, double op2 TSRMLS_DC) { int bool_result; switch (Z_TYPE_P(op1)) { case IS_LONG: return Z_LVAL_P(op1) == (long) op2; case IS_DOUBLE: return Z_DVAL_P(op1) == op2; case IS_NULL: return 0 == op2; case IS_BOOL: if (Z_BVAL_P(op1)) { return 1 == op2; } else { return 0 == op2; } default: { zval result, op2_tmp; ZVAL_DOUBLE(&op2_tmp, op2); is_equal_function(&result, op1, &op2_tmp TSRMLS_CC); bool_result = Z_BVAL(result); return bool_result; } } return 0; }
PHP_METHOD(Test_Oo_PropertyAccess, __construct) { zval *test, *test1, *_0, *_1, *_2, *_3, *_4, *_5, *_6, *_7 = NULL, *_8, *_9; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(test); object_init(test); ZEPHIR_INIT_VAR(_0); array_init_size(_0, 6); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 1); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_BNVAR(_1); ZVAL_LONG(_1, 2); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_BNVAR(_1); ZVAL_LONG(_1, 3); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_BNVAR(_1); ZVAL_LONG(_1, 5); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_BNVAR(_1); ZVAL_DOUBLE(_1, 6.00); zephir_array_fast_append(_0, _1); zephir_update_property_zval(test, SL("test"), _0 TSRMLS_CC); ZEPHIR_OBS_VAR(_2); zephir_read_property(&_2, test, SL("test"), PH_NOISY_CC); zephir_array_fetch_long(&_3, _2, 0, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_update_property_zval(test, SL("test2"), _3 TSRMLS_CC); ZEPHIR_OBS_VAR(_4); zephir_read_property(&_4, test, SL("test"), PH_NOISY_CC); zephir_array_fetch_long(&_5, _4, 1, PH_NOISY | PH_READONLY TSRMLS_CC); zephir_update_property_zval(test, SL("test3"), _5 TSRMLS_CC); ZEPHIR_INIT_BNVAR(_1); array_init_size(_1, 5); ZEPHIR_OBS_VAR(_6); zephir_read_property(&_6, test, SL("test"), PH_NOISY_CC); ZEPHIR_OBS_VAR(_7); zephir_array_fetch_long(&_7, _6, 1, PH_NOISY TSRMLS_CC); zephir_array_fast_append(_1, _7); ZEPHIR_INIT_VAR(_8); ZVAL_LONG(_8, 1); zephir_array_fast_append(_1, _8); ZEPHIR_INIT_BNVAR(_8); ZVAL_LONG(_8, 2); zephir_array_fast_append(_1, _8); ZEPHIR_INIT_BNVAR(_8); ZVAL_LONG(_8, 3); zephir_array_fast_append(_1, _8); zephir_update_property_zval(test, SL("test3"), _1 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("a"), test TSRMLS_CC); _9 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(_7); zephir_read_property(&_7, _9, SL("test2"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("b"), _7 TSRMLS_CC); test1 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); ZEPHIR_MM_RESTORE(); }
U_CFUNC PHP_FUNCTION(intltz_create_enumeration) { zval *arg = NULL; StringEnumeration *se = NULL; intl_error_reset(NULL); /* double indirection to have the zend engine destroy the new zval that * results from separation */ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &arg) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intltz_create_enumeration: bad arguments", 0); RETURN_FALSE; } if (arg == NULL || Z_TYPE_P(arg) == IS_NULL) { se = TimeZone::createEnumeration(); } else if (Z_TYPE_P(arg) == IS_LONG) { int_offset: if (Z_LVAL_P(arg) < (zend_long)INT32_MIN || Z_LVAL_P(arg) > (zend_long)INT32_MAX) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intltz_create_enumeration: value is out of range", 0); RETURN_FALSE; } else { se = TimeZone::createEnumeration((int32_t) Z_LVAL_P(arg)); } } else if (Z_TYPE_P(arg) == IS_DOUBLE) { double_offset: convert_to_long_ex(arg); goto int_offset; } else if (Z_TYPE_P(arg) == IS_OBJECT || Z_TYPE_P(arg) == IS_STRING) { zend_long lval; double dval; convert_to_string_ex(arg); switch (is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &lval, &dval, 0)) { case IS_DOUBLE: zval_ptr_dtor(arg); ZVAL_DOUBLE(arg, dval); goto double_offset; case IS_LONG: zval_ptr_dtor(arg); ZVAL_LONG(arg, lval); goto int_offset; } /* else call string version */ se = TimeZone::createEnumeration(Z_STRVAL_P(arg)); } else { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intltz_create_enumeration: invalid argument type", 0); RETURN_FALSE; } if (se) { IntlIterator_from_StringEnumeration(se, return_value); } else { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intltz_create_enumeration: error obtaining enumeration", 0); RETVAL_FALSE; } }
BUESSION_API int buession_hash_add_double_ex(HashTable *ht, const char *key, uint key_length, double d TSRMLS_DC){ zval *value; MAKE_STD_ZVAL(value); ZVAL_DOUBLE(value, d); return zend_hash_add(ht, key, key_length, (void *) &value, sizeof(zval *), NULL); }
BUESSION_API int buession_hash_next_index_add_double(HashTable *ht, double d TSRMLS_DC){ zval *value; MAKE_STD_ZVAL(value); ZVAL_DOUBLE(value, d); return zend_hash_next_index_insert(ht, (void *) &value, sizeof(zval *), NULL); }
PHP_METHOD(Test_Optimizers_Ldexp, testDouble) { zval _0, _1; double x, exponent; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); x = 2.0; exponent = 3.0; ZVAL_DOUBLE(&_0, x); ZVAL_DOUBLE(&_1, exponent); RETURN_DOUBLE(zephir_ldexp(&_0, &_1 TSRMLS_CC)); }
/* CONVERSIONS for integers */ static zend_long from_zval_integer_common(const zval *arr_value, ser_context *ctx) { zend_long ret = 0; zval lzval; ZVAL_NULL(&lzval); if (Z_TYPE_P(arr_value) != IS_LONG) { ZVAL_COPY(&lzval, (zval *)arr_value); arr_value = &lzval; } switch (Z_TYPE_P(arr_value)) { case IS_LONG: long_case: ret = Z_LVAL_P(arr_value); break; /* if not long we're operating on lzval */ case IS_DOUBLE: double_case: convert_to_long(&lzval); goto long_case; case IS_OBJECT: case IS_STRING: { zend_long lval; double dval; convert_to_string(&lzval); switch (is_numeric_string(Z_STRVAL(lzval), Z_STRLEN(lzval), &lval, &dval, 0)) { case IS_DOUBLE: zval_dtor(&lzval); ZVAL_DOUBLE(&lzval, dval); goto double_case; case IS_LONG: zval_dtor(&lzval); ZVAL_LONG(&lzval, lval); goto long_case; } /* if we get here, we don't have a numeric string */ do_from_zval_err(ctx, "expected an integer, but got a non numeric " "string (possibly from a converted object): '%s'", Z_STRVAL_P(arr_value)); break; } default: do_from_zval_err(ctx, "%s", "expected an integer, either of a PHP " "integer type or of a convertible type"); break; } zval_dtor(&lzval); return ret; }
static void json_create_zval(zval **z, smart_str *buf, int type, int options) { ALLOC_INIT_ZVAL(*z); if (type == IS_LONG) { zend_bool bigint = 0; if (buf->c[0] == '-') { buf->len--; } if (buf->len >= MAX_LENGTH_OF_LONG - 1) { if (buf->len == MAX_LENGTH_OF_LONG - 1) { int cmp = strcmp(buf->c + (buf->c[0] == '-'), long_min_digits); if (!(cmp < 0 || (cmp == 0 && buf->c[0] == '-'))) { bigint = 1; } } else { bigint = 1; } } if (bigint) { /* value too large to represent as a long */ if (options & PHP_JSON_BIGINT_AS_STRING) { if (buf->c[0] == '-') { /* Restore last char consumed above */ buf->len++; } goto use_string; } else { goto use_double; } } ZVAL_LONG(*z, strtol(buf->c, NULL, 10)); } else if (type == IS_DOUBLE) { use_double: ZVAL_DOUBLE(*z, zend_strtod(buf->c, NULL)); } else if (type == IS_STRING) { use_string: ZVAL_STRINGL(*z, buf->c, buf->len, 1); } else if (type == IS_BOOL) { ZVAL_BOOL(*z, (*(buf->c) == 't')); } else /* type == IS_NULL) || type unknown */ { ZVAL_NULL(*z); } }
PHP_METHOD(PocketMine_Math_Vector2, distanceSquared) { zephir_nts_static zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *x, *y = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, _3 = zval_used_for_init, _4 = zval_used_for_init, *_6 = NULL, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &x, &y); if (!y) { ZEPHIR_INIT_VAR(y); ZVAL_LONG(y, 0); } if (zephir_instance_of_ev(x, pocketmine_math_vector2_ce TSRMLS_CC)) { ZEPHIR_OBS_VAR(_1); zephir_read_property(&_1, x, SL("x"), PH_NOISY_CC); ZEPHIR_OBS_VAR(_2); zephir_read_property(&_2, x, SL("y"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, this_ptr, "distancesquared", NULL, _1, _2); zephir_check_call_status(); RETURN_MM_DOUBLE(zephir_get_doubleval(_0)); } ZEPHIR_OBS_NVAR(_1); zephir_read_property_this(&_1, this_ptr, SL("x"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_3); ZVAL_DOUBLE(&_3, (zephir_get_doubleval(_1) - zephir_get_doubleval(x))); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 2); ZEPHIR_CALL_FUNCTION(&_0, "pow", &_5, &_3, &_4); zephir_check_call_status(); ZEPHIR_OBS_NVAR(_2); zephir_read_property_this(&_2, this_ptr, SL("y"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_3); ZVAL_DOUBLE(&_3, (zephir_get_doubleval(_2) - zephir_get_doubleval(y))); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 2); ZEPHIR_CALL_FUNCTION(&_6, "pow", &_5, &_3, &_4); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); zephir_add_function(_7, _0, _6 TSRMLS_CC); RETURN_MM_DOUBLE(zephir_get_doubleval(_7)); }