fixed unit testing code
Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>
This commit is contained in:
@@ -22,12 +22,16 @@ namespace ScriptCanvas
|
||||
|
||||
Nodeable::Nodeable()
|
||||
: m_noOpFunctor(&NodeableOutCpp::NoOp)
|
||||
{}
|
||||
{
|
||||
AZ_TracePrintf("SCDB", "How many times does this get called? Because it should....NOT GET CALLED!");
|
||||
}
|
||||
|
||||
Nodeable::Nodeable(ExecutionStateWeakPtr executionState)
|
||||
: m_noOpFunctor(&NodeableOutCpp::NoOp)
|
||||
, m_executionState(executionState)
|
||||
{}
|
||||
{
|
||||
AZ_TracePrintf("SCDB", "How many times does this get called 2?");
|
||||
}
|
||||
|
||||
#if !defined(RELEASE)
|
||||
void Nodeable::CallOut(size_t index, AZ::BehaviorValueParameter* resultBVP, AZ::BehaviorValueParameter* argsBVPs, int numArguments) const
|
||||
@@ -80,6 +84,7 @@ namespace ScriptCanvas
|
||||
->Attribute(AZ::ScriptCanvasAttributes::VariableCreationForbidden, AZ::AttributeIsValid::IfPresent)
|
||||
->Attribute(AZ::Script::Attributes::UseClassIndexAllowNil, AZ::AttributeIsValid::IfPresent)
|
||||
->Constructor<ExecutionStateWeakPtr>()
|
||||
->Attribute(AZ::Script::Attributes::DefaultConstructorOverrideIndex, 0)
|
||||
->Method("Deactivate", &Nodeable::Deactivate)
|
||||
->Method("InitializeExecutionState", &Nodeable::InitializeExecutionState)
|
||||
->Method("InitializeExecutionOuts", &Nodeable::InitializeExecutionOuts)
|
||||
|
||||
+46
@@ -68,6 +68,8 @@ namespace ExecutionInterpretedAPICpp
|
||||
{
|
||||
if (lua_isstring(lua, -1))
|
||||
{
|
||||
AZStd::string errorResult = lua_tostring(lua, -1);
|
||||
AZ_TracePrintf("ScriptCanvas", errorResult.c_str());
|
||||
AZ::ScriptContext::FromNativeContext(lua)->Error(AZ::ScriptContext::ErrorType::Error, true, "%s", lua_tostring(lua, -1));
|
||||
}
|
||||
else
|
||||
@@ -402,6 +404,50 @@ namespace ScriptCanvas
|
||||
AZ_Assert(lua_isuserdata(lua, -2) && !lua_islightuserdata(lua, -2), "Error in compiled lua file, 1st argument to OverrideNodeableMetatable is not userdata (Nodeable)");
|
||||
AZ_Assert(lua_istable(lua, -1), "Error in compiled lua file, 2nd argument to OverrideNodeableMetatable is not a Lua table");
|
||||
|
||||
/* table is in the stack at index 't' */
|
||||
if (lua_istable(lua, -1))
|
||||
{
|
||||
lua_getfield(lua, -1, "__index");
|
||||
|
||||
if (lua_istable(lua, -1))
|
||||
{
|
||||
int t = -2;
|
||||
AZStd::string tableGuts;
|
||||
lua_pushnil(lua);
|
||||
/* first key */
|
||||
while (lua_next(lua, t) != 0)
|
||||
{
|
||||
/* uses 'key' (at index -2) and 'value' (at index -1) */
|
||||
if (lua_type(lua, -2) == LUA_TSTRING)
|
||||
{
|
||||
size_t len;
|
||||
tableGuts += AZStd::string::format("%s - %s\n",
|
||||
lua_tolstring(lua, -2, &len),
|
||||
lua_typename(lua, lua_type(lua, -1)));
|
||||
}
|
||||
else if (lua_type(lua, -2) == LUA_TNUMBER)
|
||||
{
|
||||
tableGuts += AZStd::string::format("%f - %s\n",
|
||||
lua_tonumber(lua, -2),
|
||||
lua_typename(lua, lua_type(lua, -1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
tableGuts += AZStd::string::format("%s - %s\n",
|
||||
lua_typename(lua, lua_type(lua, -2)),
|
||||
lua_typename(lua, lua_type(lua, -1)));
|
||||
}
|
||||
|
||||
/* removes 'value'; keeps 'key' for next iteration */
|
||||
lua_pop(lua, 1);
|
||||
}
|
||||
|
||||
AZ_TracePrintf("SCDB", tableGuts.c_str());
|
||||
}
|
||||
|
||||
lua_pop(lua, 1);
|
||||
}
|
||||
|
||||
[[maybe_unused]] auto userData = reinterpret_cast<AZ::LuaUserData*>(lua_touserdata(lua, -2));
|
||||
AZ_Assert(userData && userData->magicData == AZ_CRC_CE("AZLuaUserData"), "this isn't user data");
|
||||
// Lua: LuaUserData::nodeable, class_mt
|
||||
|
||||
+2
@@ -143,6 +143,8 @@ namespace ScriptCanvas
|
||||
AZ_Assert(m_luaRegistryIndex == LUA_NOREF, "ExecutionStateInterpreted already in the Lua registry and risks double deletion");
|
||||
// Lua: instance
|
||||
m_luaRegistryIndex = luaL_ref(m_luaState, LUA_REGISTRYINDEX);
|
||||
AZ_Assert(m_luaRegistryIndex != LUA_REFNIL, "ExecutionStateInterpreted was nil when trying to gain a reference");
|
||||
AZ_Assert(m_luaRegistryIndex != LUA_NOREF, "ExecutionStateInterpreted failed to gain a reference");
|
||||
}
|
||||
|
||||
void ExecutionStateInterpreted::Reflect(AZ::ReflectContext* reflectContext)
|
||||
|
||||
+62
@@ -111,10 +111,72 @@ namespace ScriptCanvas
|
||||
auto& lua = m_luaState;
|
||||
// Lua:
|
||||
lua_rawgeti(lua, LUA_REGISTRYINDEX, registryIndex);
|
||||
if (!lua_isuserdata(lua, -1))
|
||||
{
|
||||
AZ_TracePrintf("SCDB", "No light userdata");
|
||||
}
|
||||
// Lua: instance
|
||||
|
||||
lua_getmetatable(lua, -1);
|
||||
if (!lua_istable(lua, -1))
|
||||
{
|
||||
AZ_TracePrintf("SCDB", "no metatable");
|
||||
}
|
||||
|
||||
|
||||
/* table is in the stack at index 't' */
|
||||
if (lua_istable(lua, -1))
|
||||
{
|
||||
int t = -2;
|
||||
AZStd::string tableGuts;
|
||||
lua_pushnil(lua);
|
||||
/* first key */
|
||||
while (lua_next(lua, t) != 0)
|
||||
{
|
||||
/* uses 'key' (at index -2) and 'value' (at index -1) */
|
||||
if (lua_type(lua, -2) == LUA_TSTRING)
|
||||
{
|
||||
size_t len;
|
||||
tableGuts += AZStd::string::format("%s - %s\n",
|
||||
lua_tolstring(lua, -2, &len),
|
||||
lua_typename(lua, lua_type(lua, -1)));
|
||||
}
|
||||
else if (lua_type(lua, -2) == LUA_TNUMBER)
|
||||
{
|
||||
tableGuts += AZStd::string::format("%f - %s\n",
|
||||
lua_tonumber(lua, -2),
|
||||
lua_typename(lua, lua_type(lua, -1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
tableGuts += AZStd::string::format("%s - %s\n",
|
||||
lua_typename(lua, lua_type(lua, -2)),
|
||||
lua_typename(lua, lua_type(lua, -1)));
|
||||
}
|
||||
|
||||
/* removes 'value'; keeps 'key' for next iteration */
|
||||
lua_pop(lua, 1);
|
||||
}
|
||||
|
||||
AZ_TracePrintf("SCDB", tableGuts.c_str());
|
||||
}
|
||||
|
||||
// Lua: instance, instance_mt
|
||||
lua_pop (lua, 1);
|
||||
|
||||
|
||||
// Lua: instance
|
||||
lua_getfield(lua, -1, Grammar::k_OnGraphStartFunctionName);
|
||||
// Lua: instance, graph_VM.k_OnGraphStartFunctionName
|
||||
if (!lua_isfunction(lua, -1))
|
||||
{
|
||||
AZ_TracePrintf("SCDB", "No function");
|
||||
}
|
||||
lua_pushvalue(lua, -2);
|
||||
if (!lua_isuserdata(lua, -1))
|
||||
{
|
||||
AZ_TracePrintf("SCDB", "No light userdata");
|
||||
}
|
||||
// Lua: instance, graph_VM.k_OnGraphStartFunctionName, instance
|
||||
const int result = Execution::InterpretedSafeCall(lua, 1, 0);
|
||||
// Lua: instance ?
|
||||
|
||||
Reference in New Issue
Block a user