mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 08:15:59 -10:00
This introduces type parsing for all types used within the scripting documentation. This improves the generated JSON output and also validates new code via the unit test.
49 lines
967 B
C++
49 lines
967 B
C++
//
|
|
//
|
|
|
|
#include "LuaSEXP.h"
|
|
|
|
namespace scripting {
|
|
namespace api {
|
|
|
|
lua_sexp_h::lua_sexp_h(sexp::LuaSEXP* handle) : sexp_handle(handle) {
|
|
}
|
|
lua_sexp_h::lua_sexp_h() : sexp_handle(nullptr) {
|
|
}
|
|
bool lua_sexp_h::isValid() {
|
|
return sexp_handle != nullptr;
|
|
}
|
|
|
|
ADE_OBJ(l_LuaSEXP, lua_sexp_h, "LuaSEXP", "Lua SEXP handle");
|
|
|
|
ADE_VIRTVAR(Action,
|
|
l_LuaSEXP,
|
|
"function(any... args) => void action",
|
|
"The action of this SEXP",
|
|
"function(any... args) => void action",
|
|
"The action function or nil on error")
|
|
{
|
|
lua_sexp_h lua_sexp;
|
|
luacpp::LuaFunction action_arg;
|
|
if (!ade_get_args(L, "o|u", l_LuaSEXP.Get(&lua_sexp), &action_arg)) {
|
|
return ADE_RETURN_NIL;
|
|
}
|
|
|
|
if (!lua_sexp.isValid()) {
|
|
return ADE_RETURN_NIL;
|
|
}
|
|
|
|
if (ADE_SETTING_VAR) {
|
|
Assertion(action_arg.isValid(), "Action function reference must be valid!");
|
|
|
|
lua_sexp.sexp_handle->setAction(action_arg);
|
|
}
|
|
|
|
auto action = lua_sexp.sexp_handle->getAction();
|
|
return ade_set_args(L, "u", &action);
|
|
}
|
|
|
|
}
|
|
}
|
|
|