tammela added inline comments.

================
Comment at: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp:60-78
+static int runCallback(lua_State *L) {
+  LuaCallback *callback = static_cast<LuaCallback *>(lua_touserdata(L, -1));
+  return (*callback)(L);
+}
+
+llvm::Error Lua::Run(LuaCallback &callback) {
+  lua_pushcfunction(m_lua_state, runCallback);
----------------
labath wrote:
> I'm confused. Why use lua to call a c callback, when you could just do 
> `calllback()`?
Some Lua API functions throw errors, if there's any it will `abort()` the 
program if no panic handler or protected call is provided.
To guarantee that the callback always runs in a protected environment and it 
has error handling, we do the above.
Delegating this to the callback itself makes it cumbersome to write.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91508/new/

https://reviews.llvm.org/D91508

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to