[Commits] [wesnoth/wesnoth] 76141a: new code for lua protected calls in lua_kernel_bas...

GitHub noreply at github.com
Tue Nov 11 00:16:44 UTC 2014


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 76141a0de1c9db55fd8238020cf5de4c144f36b8
      https://github.com/wesnoth/wesnoth/commit/76141a0de1c9db55fd8238020cf5de4c144f36b8
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-11-10 (Mon, 10 Nov 2014)

  Changed paths:
    M src/game_errors.hpp
    M src/scripting/application_lua_kernel.cpp
    M src/scripting/game_lua_kernel.cpp
    M src/scripting/game_lua_kernel.hpp
    M src/scripting/lua_kernel_base.cpp
    M src/scripting/lua_kernel_base.hpp

  Log Message:
  -----------
  new code for lua protected calls in lua_kernel_base

In initial commit of the new lua kernels, I introduced a problem
by trying to use luaW_pcall and lua_pcall interchangeably via
polymorphism. This doesn't work because their return types don't
match, and it's alot of work to change luaW_pcall syntax. Besides
this there's no reason we can't use the custom error handler
everywhere.

This commits adds protected_call and load_string functions to lua
kernel base. These are an intended replacement for luaW_pcall,
and replace the "run" function. They do better error reporting
and allow to specify an error handler.

The error reporting is very flexible -- by default we select a
an error reporting function associated polymorphically to the lua
kernel, so the in-game lua kernel can send chat messages, and
others can do something else. However an arbitrary handler may
be specified, and exceptions instead of logging may also be
requested.


  Commit: 720f4cdb836c6d0553e1ff9ec1a86854548f3d8d
      https://github.com/wesnoth/wesnoth/commit/720f4cdb836c6d0553e1ff9ec1a86854548f3d8d
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-11-10 (Mon, 10 Nov 2014)

  Changed paths:
    M src/scripting/game_lua_kernel.cpp

  Log Message:
  -----------
  use setfuncs instead of register, so we can do partial define


  Commit: 63399b47e919a7ef23d42ec23d43e79b87c44e4e
      https://github.com/wesnoth/wesnoth/commit/63399b47e919a7ef23d42ec23d43e79b87c44e4e
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-11-10 (Mon, 10 Nov 2014)

  Changed paths:
    M src/scripting/game_lua_kernel.cpp
    M src/scripting/lua_kernel_base.cpp

  Log Message:
  -----------
  move some callbacks (gettext, file ops) to lua kernel base


  Commit: 4134ef3a80a33dbdbb68ff0f3930215b1a3366ff
      https://github.com/wesnoth/wesnoth/commit/4134ef3a80a33dbdbb68ff0f3930215b1a3366ff
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-11-10 (Mon, 10 Nov 2014)

  Changed paths:
    M src/scripting/lua_kernel_base.cpp

  Log Message:
  -----------
  remove comment from dev concerned about a nonissue

read here: http://www.lua.org/manual/5.1/manual.html#lua_CFunction
When the C function returns with "1", all but the top entry are
discarded from the stack. If this function could be called again
and again without ever returning and without ever dumping the stack,
then there could be a stackoverflow, but in this case it's
not possible.


  Commit: c0335d38f73737bd952efb5bbedd953e68789146
      https://github.com/wesnoth/wesnoth/commit/c0335d38f73737bd952efb5bbedd953e68789146
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-11-10 (Mon, 10 Nov 2014)

  Changed paths:
    M src/CMakeLists.txt
    M src/SConscript
    M src/generators/lua_map_generator.cpp
    M src/generators/lua_map_generator.hpp
    A src/scripting/mapgen_lua_kernel.cpp
    A src/scripting/mapgen_lua_kernel.hpp

  Log Message:
  -----------
  refactor lua map generator to use a lua kernel object

This reduces the code complexity quite a bit. Now all the lua api
defn's are in the scripting folder, and the generator object itself
needs only construct a kernel and ask it to do things, and catch /
rethrow its exceptions with appropriate type and additional
descriptive info.


  Commit: 1967d52a5de55aa6b918cf48b2baefd5bf4d16f8
      https://github.com/wesnoth/wesnoth/commit/1967d52a5de55aa6b918cf48b2baefd5bf4d16f8
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-11-10 (Mon, 10 Nov 2014)

  Changed paths:
    M src/scripting/lua_kernel_base.cpp
    M src/scripting/mapgen_lua_kernel.cpp

  Log Message:
  -----------
  fixup stack discipline with error handling

When a C function terminates, it should not leave bogus elements
on the stack, or the stack can eventually overflow.

This is not as critical for C functions which are called by lua,
because they return an int explaining how many values on the stack
are important. But for C++ facing functions it is very important.


  Commit: ec6037644ff20ee3fefb99b7febedaa56f851d00
      https://github.com/wesnoth/wesnoth/commit/ec6037644ff20ee3fefb99b7febedaa56f851d00
  Author: Chris Beck <beck.ct at gmail.com>
  Date:   2014-11-10 (Mon, 10 Nov 2014)

  Changed paths:
    M src/CMakeLists.txt
    M src/SConscript
    M src/game_errors.hpp
    M src/generators/lua_map_generator.cpp
    M src/generators/lua_map_generator.hpp
    M src/scripting/application_lua_kernel.cpp
    M src/scripting/game_lua_kernel.cpp
    M src/scripting/game_lua_kernel.hpp
    M src/scripting/lua_kernel_base.cpp
    M src/scripting/lua_kernel_base.hpp
    A src/scripting/mapgen_lua_kernel.cpp
    A src/scripting/mapgen_lua_kernel.hpp

  Log Message:
  -----------
  Merge pull request #331 from cbeck88/fixup_lua

Fixup lua


Compare: https://github.com/wesnoth/wesnoth/compare/2264e9961d82...ec6037644ff2


More information about the Commits mailing list