stringT& es_replace_helper( stringT& /* in */ given_string, IPrimitive& /* in */ match_result, IPrimitive const& /* in */ last_index, stringT const& /* in */ replace_value ) throw() { ES_ASSERT(L"array" == match_result.typeof__().operator const_string_t const()); // ES_ASSERT(1 <= match_result.length__().operator ecmascript::uint32_t()); ES_ASSERT(VT::String == match_result.operator[](0).type__()); size_t size = match_result.operator[](0).operator const_string_t const().length(); size_t begin_index = last_index.operator ecmascript::uint32_t() - size; return given_string.replace(begin_index, size, replace_value); }
static int es_read_reg(uint8_t reg_add, uint8_t *pData) { uint8_t data; int res = 0; i2c_cmd_handle_t cmd = i2c_cmd_link_create(); res |= i2c_master_start(cmd); res |= i2c_master_write_byte(cmd, ES8388_ADDR, 1 /*ACK_CHECK_EN*/); res |= i2c_master_write_byte(cmd, reg_add, 1 /*ACK_CHECK_EN*/); res |= i2c_master_stop(cmd); res |= i2c_master_cmd_begin(0, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); cmd = i2c_cmd_link_create(); res |= i2c_master_start(cmd); res |= i2c_master_write_byte(cmd, ES8388_ADDR | 0x01, 1 /*ACK_CHECK_EN*/); res |= i2c_master_read_byte(cmd, &data, 0x01/*NACK_VAL*/); res |= i2c_master_stop(cmd); res |= i2c_master_cmd_begin(0, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); ES_ASSERT(res, "es_read_reg error", -1); *pData = data; return res; }
static int i2c_init() { int res; res = i2c_param_config(I2C_NUM_0, &es_i2c_cfg); res |= i2c_driver_install(I2C_NUM_0, es_i2c_cfg.mode, 0, 0, 0); ES_ASSERT(res, "i2c_init error", -1); return res; }
~es_match_results_stack() { if (0 == p_match_result_) return; ES_ASSERT(0 != p_match_result_); es_match_result current = *p_match_result_; delete p_match_result_; p_match_result_ = current.get_prev(); current.apply(result_string_); this->~es_match_results_stack(); }
static int es_write_reg(uint8_t slave_add, uint8_t reg_add, uint8_t data) { int res = 0; i2c_cmd_handle_t cmd = i2c_cmd_link_create(); res |= i2c_master_start(cmd); res |= i2c_master_write_byte(cmd, slave_add, 1 /*ACK_CHECK_EN*/); res |= i2c_master_write_byte(cmd, reg_add, 1 /*ACK_CHECK_EN*/); res |= i2c_master_write_byte(cmd, data, 1 /*ACK_CHECK_EN*/); res |= i2c_master_stop(cmd); res |= i2c_master_cmd_begin(0, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); ES_ASSERT(res, "es_write_reg error", -1); return res; }
static IString const& do_replace( IString& lhs_string, IPrimitive& search_value, es_string_or_binded_function<stringT> const& replace_value ) throw() { ES_ASSERT(L"RegExp" == search_value.class__()); IRegExp& regexp = reinterpret_cast<IRegExp&>(search_value); return regexp.global().operator bool() ? es_replace_when_global_flag_is_on<stringT>( regexp, lhs_string, replace_value): es_replace_when_global_flag_is_off<stringT>( regexp, lhs_string, replace_value); }