Uses the default copy operator to copy engine_converter.

PiperOrigin-RevId: 731200351
This commit is contained in:
Taku Kudo
2025-02-26 08:47:16 +00:00
committed by Hiroyuki Komatsu
parent f35915da57
commit 914e13462e
4 changed files with 13 additions and 27 deletions

View File

@ -113,6 +113,15 @@ class CandidateList final {
rotate_(rotate),
focused_(false) {}
// Minimum copy operator.
// TODO(all): Support full copy operation of CandidateList as EngineConverter
// is currently copyable. Since the CandidateList contractor is
// initialized with `rotate`, `rotate_` is copied in the copy operator.
CandidateList &operator=(const CandidateList &candidate_list) {
rotate_ = candidate_list.rotate_;
return *this;
}
void Clear();
const Candidate &GetDeepestFocusedCandidate() const;

View File

@ -1151,26 +1151,7 @@ void EngineConverter::FillOutput(const composer::Composer &composer,
EngineConverter *EngineConverter::Clone() const {
EngineConverter *engine_converter =
new EngineConverter(converter_, request_, config_);
// Copy the members in order of their declarations.
engine_converter->state_ = state_;
// TODO(team): copy of |converter_| member.
// We cannot copy the member converter_ from EngineConverterInterface because
// it doesn't (and shouldn't) define a method like GetConverter(). At the
// moment it's ok because the current design guarantees that the converter is
// singleton. However, we should refactor such bad design; see also the
// comment right above.
engine_converter->segments_ = segments_;
engine_converter->incognito_segments_ = incognito_segments_;
engine_converter->segment_index_ = segment_index_;
engine_converter->previous_suggestions_ = previous_suggestions_;
engine_converter->conversion_preferences_ = conversion_preferences();
engine_converter->result_ = result_;
engine_converter->request_ = request_;
engine_converter->config_ = config_;
engine_converter->use_cascading_window_ = use_cascading_window_;
engine_converter->selected_candidate_indices_ = selected_candidate_indices_;
engine_converter->request_type_ = request_type_;
*engine_converter = *this;
if (engine_converter->CheckState(SUGGESTION | PREDICTION | CONVERSION)) {
// UpdateCandidateList() is not simple setter and it uses some members.

View File

@ -61,7 +61,6 @@ class EngineConverter : public EngineConverterInterface {
std::shared_ptr<const config::Config> config);
explicit EngineConverter(std::shared_ptr<const ConverterInterface> converter);
EngineConverter(const EngineConverter &) = delete;
EngineConverter &operator=(const EngineConverter &) = delete;
// Checks if the current state is in the state bitmap.
bool CheckState(States) const override;
@ -245,8 +244,6 @@ class EngineConverter : public EngineConverterInterface {
void OnStartComposition(const commands::Context &context) override;
// Copies EngineConverter
// TODO(hsumita): Copy all member variables.
// Currently, converter_ is not copied.
EngineConverter *Clone() const override;
void set_selection_shortcut(
@ -264,6 +261,9 @@ class EngineConverter : public EngineConverterInterface {
std::numeric_limits<size_t>::max();
private:
// Uses default copy operator to simply copy all members.
EngineConverter &operator=(const EngineConverter &) = default;
friend class EngineConverterTest;
// Resets the result value stored at the previous command.

View File

@ -66,10 +66,6 @@ struct ConversionPreferences {
// support stateful operations related with the converter.
class EngineConverterInterface {
public:
EngineConverterInterface() = default;
EngineConverterInterface(const EngineConverterInterface &) = delete;
EngineConverterInterface &operator=(const EngineConverterInterface &) =
delete;
virtual ~EngineConverterInterface() = default;
typedef int States;