Skip to content

Commit

Permalink
clang-format 排版
Browse files Browse the repository at this point in the history
Signed-off-by: shewer <[email protected]>
  • Loading branch information
shewer committed Oct 26, 2023
1 parent fc78224 commit f0915e6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 38 deletions.
49 changes: 23 additions & 26 deletions src/script_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace rime;

class LScriptTranslator : public ScriptTranslator {
public:
LScriptTranslator(const Ticket& ticket, Lua* lua);
LScriptTranslator(const Ticket& ticket, Lua* lua);
virtual bool Memorize(const CommitEntry& commit_entry);
bool memorize(const CommitEntry& commit_entry);
bool update_entry(const DictEntry& index,
Expand All @@ -32,15 +32,14 @@ class LScriptTranslator : public ScriptTranslator {
ACCESS_(memorize_callback, an<LuaObj>);

// ScriptTranslator member
ACCESS_(spelling_hints, int); // ok
ACCESS_(always_show_comments, bool); // ok
ACCESS_(max_homophones, int); // ok
GET_(enable_correction, bool); // ok
ACCESS_(spelling_hints, int); // ok
ACCESS_(always_show_comments, bool); // ok
ACCESS_(max_homophones, int); // ok
GET_(enable_correction, bool); // ok
void set_enable_correction(bool);
// TranslatorOptions
void set_contextual_suggestions(bool);
SET_(delimiters, string&);


protected:
Lua* lua_;
Expand All @@ -64,14 +63,15 @@ bool LScriptTranslator::Memorize(const CommitEntry& commit_entry) {
return r.get();
}


bool LScriptTranslator::memorize(const CommitEntry& commit_entry) {
return ScriptTranslator::Memorize(commit_entry);
}

LScriptTranslator::LScriptTranslator(const Ticket& ticket, Lua* lua)
: lua_(lua), ScriptTranslator(ticket), schema_id_(ticket.schema->schema_id()){
memorize_callback_ = lua_->getglobal("___");
: lua_(lua),
ScriptTranslator(ticket),
schema_id_(ticket.schema->schema_id()) {
memorize_callback_ = lua_->getglobal("___");
}

void LScriptTranslator::set_enable_correction(bool enable) {
Expand All @@ -81,7 +81,7 @@ void LScriptTranslator::set_enable_correction(bool enable) {

if (auto* corrector = Corrector::Require("corrector")) {
Schema schema = Schema(schema_id_);
Ticket ticket( &schema, name_space_);
Ticket ticket(&schema, name_space_);
corrector_.reset(corrector->Create(ticket));
}
}
Expand All @@ -93,17 +93,15 @@ void LScriptTranslator::set_contextual_suggestions(bool enable) {
poet_.reset(new Poet(language(), config, Poet::LeftAssociateCompare));
}


bool LScriptTranslator::update_entry(const DictEntry& entry,
int commits,
const string& new_entory_prefix) {
int commits,
const string& new_entory_prefix) {
if (user_dict_ && user_dict_->loaded())
return user_dict_->UpdateEntry(entry, commits, new_entory_prefix);

return false;
}


namespace ScriptTranslatorReg {
using T = LScriptTranslator;

Expand All @@ -125,10 +123,10 @@ static const luaL_Reg vars_get[] = {
Get_WMEM(memorize_callback), // an<LuaObj> callback

// ScriptTranslator member
Get_WMEM(max_homophones), // int
Get_WMEM(spelling_hints), // int
Get_WMEM(always_show_comments), // bool
Get_WMEM(enable_correction), // bool
Get_WMEM(max_homophones), // int
Get_WMEM(spelling_hints), // int
Get_WMEM(always_show_comments), // bool
Get_WMEM(enable_correction), // bool
// TranslatorOptions
Get_WMEM(delimiters), // string&
Get_WMEM(tag), // string
Expand All @@ -143,10 +141,10 @@ static const luaL_Reg vars_set[] = {
Set_WMEM(memorize_callback), // an<LuaObj> callback

// ScriptTranslator member
Set_WMEM(max_homophones), // int
Set_WMEM(spelling_hints), // int
Set_WMEM(always_show_comments), // bool
Set_WMEM(enable_correction), // bool
Set_WMEM(max_homophones), // int
Set_WMEM(spelling_hints), // int
Set_WMEM(always_show_comments), // bool
Set_WMEM(enable_correction), // bool
// TranslatorOptions
Set_WMEM(delimiters), // string&
Set_WMEM(tag), // string
Expand All @@ -160,17 +158,16 @@ static const luaL_Reg vars_set[] = {
void reg_Component(lua_State* L) {
lua_getglobal(L, "Component");
if (lua_type(L, -1) != LUA_TTABLE) {
LOG(ERROR) << "table of _G[\"Component\"] not found.";
}
else {
LOG(ERROR) << "table of _G[\"Component\"] not found.";
} else {
int index = lua_absindex(L, -1);
lua_pushcfunction(L, raw_make_translator<LScriptTranslator>);
lua_setfield(L, index, "ScriptTranslator");
}
lua_pop(L, 1);
}

} // namespace StriptTranslatorReg
} // namespace ScriptTranslatorReg
} // namespace

void LUAWRAPPER_LOCAL script_translator_init(lua_State* L) {
Expand Down
21 changes: 9 additions & 12 deletions src/table_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <boost/regex.hpp>


namespace {
using namespace rime;

Expand All @@ -29,13 +28,11 @@ class LTableTranslator : public TableTranslator {
//
GET_(enable_encoder, bool); // ok
void set_enable_encoder(bool); // bool
//
//
GET_(enable_sentence, bool);
void set_enable_sentence(bool);
// ACCESS_(enable_sentence, bool);//ok
GET_(sentence_over_completion, bool);
void set_sentence_over_completion(bool);
// ACCESS_(sentence_over_completion, bool);
void set_contextual_suggestions(bool);

ACCESS_(encode_commit_history, bool);
Expand All @@ -47,7 +44,7 @@ class LTableTranslator : public TableTranslator {

protected:
Lua* lua_;
an<LuaObj> memorize_callback_ = {};
an<LuaObj> memorize_callback_;
bool disable_userdict_ = false;
string schema_id_;
};
Expand Down Expand Up @@ -82,9 +79,10 @@ bool LTableTranslator::memorize(const CommitEntry& commit_entry) {
}

LTableTranslator::LTableTranslator(const Ticket& ticket, Lua* lua)
: lua_(lua), TableTranslator(ticket), schema_id_(ticket.schema->schema_id()){

memorize_callback_ = lua_->getglobal("___");
: lua_(lua),
TableTranslator(ticket),
schema_id_(ticket.schema->schema_id()) {
memorize_callback_ = lua_->getglobal("___");
bool disable_userdict;
Config* config = ticket.schema->config();
config->GetBool(name_space_ + "/disable_userdict", &disable_userdict);
Expand All @@ -97,7 +95,7 @@ void LTableTranslator::set_enable_encoder(bool enable_encoder) {
return;
encoder_.reset(new UnityTableEncoder(user_dict_.get()));
Schema schema = Schema(schema_id_);
Ticket ticket( &schema, name_space_);
Ticket ticket(&schema, name_space_);
encoder_->Load(ticket);
}

Expand Down Expand Up @@ -202,9 +200,8 @@ static const luaL_Reg vars_set[] = {
void reg_Component(lua_State* L) {
lua_getglobal(L, "Component");
if (lua_type(L, -1) != LUA_TTABLE) {
LOG(ERROR) << "table of _G[\"Component\"] not found.";
}
else {
LOG(ERROR) << "table of _G[\"Component\"] not found.";
} else {
int index = lua_absindex(L, -1);
lua_pushcfunction(L, raw_make_translator<LTableTranslator>);
lua_setfield(L, index, "TableTranslator");
Expand Down

0 comments on commit f0915e6

Please sign in to comment.