Skip to content

Commit ab08dd2

Browse files
committed
improve attach debugger
1 parent 0672cb0 commit ab08dd2

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

emmy_core/emmy_debugger.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ void Debugger::Detach(lua_State* L) {
105105
}
106106

107107
void Debugger::Hook(lua_State* L, lua_Debug* ar) {
108-
//CheckDoString(L);
109108
if (skipHook) {
110109
return;
111110
}

emmy_core/emmy_facade.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,6 @@ void EmmyFacade::Destroy() {
160160
void EmmyFacade::OnReceiveMessage(const rapidjson::Document& document) {
161161
const auto cmd = static_cast<MessageCMD>(document["cmd"].GetInt());
162162
switch (cmd) {
163-
#if EMMY_BUILD_AS_HOOK
164-
case MessageCMD::StartHookReq:
165-
StartHook();
166-
break;
167-
#endif
168163
case MessageCMD::InitReq:
169164
OnInitReq(document);
170165
break;
@@ -191,24 +186,28 @@ void EmmyFacade::OnReceiveMessage(const rapidjson::Document& document) {
191186
}
192187

193188
void EmmyFacade::OnInitReq(const rapidjson::Document& document) {
189+
#if EMMY_BUILD_AS_HOOK
190+
StartHook();
191+
#endif
194192
if (document.HasMember("emmyHelper")) {
195193
helperCode = document["emmyHelper"].GetString();
196-
//Debugger::Get()->AsyncDoString(helperCode.c_str());
197194
}
198195
Debugger::Get()->Start(helperCode);
199196
for (auto L : states)
200197
Debugger::Get()->Attach(L);
198+
199+
//file extension names: .lua, .txt, .lua.txt ...
200+
std::vector<std::string> extNames;
201201
if (document.HasMember("ext")) {
202-
std::vector<std::string> extNames;
203202
const auto ext = document["ext"].GetArray();
204203
auto it = ext.begin();
205204
while (it != ext.end()) {
206205
const auto extName = (*it).GetString();
207206
extNames.emplace_back(extName);
208207
++it;
209208
}
210-
Debugger::Get()->SetExtNames(extNames);
211209
}
210+
Debugger::Get()->SetExtNames(extNames);
212211
}
213212

214213
void EmmyFacade::OnReadyReq(const rapidjson::Document& document) {
@@ -398,11 +397,8 @@ void EmmyFacade::OnLuaStateGC(lua_State* L) {
398397
if (it != states.end())
399398
states.erase(it);
400399
Debugger::Get()->Detach(L);
401-
if (!states.empty())
402-
return;
403-
#if EMMY_BUILD_AS_HOOK
404-
OnDisconnect();
405-
#else
406-
Destroy();
400+
#if !EMMY_BUILD_AS_HOOK
401+
if (states.empty())
402+
Destroy();
407403
#endif
408404
}

emmy_core/emmy_facade.hook.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void EmmyFacade::StartupHookMode(int port) {
4141
}
4242

4343
void EmmyFacade::Attach(lua_State* L) {
44-
if (this->isIDEReady || !this->transporter->IsConnected())
44+
if (!this->transporter->IsConnected())
4545
return;
4646
if (this->states.find(L) == this->states.end()) {
4747
this->states.insert(L);

0 commit comments

Comments
 (0)