Как мне отследить мой комплиментарный заказ? (Чтобы я мог заказать его повторно)
Моя проблема: я запускаю Visual Studio 2012, пишу приложение на C++. Я привязал систему сценариев Lua к своему проекту с помощью LuaBind.
LuaBind прячет вещи Lua и выясняет, как связать их с языком Lua (или какой-то магией)
Я могу взять объект, вызвать для него функцию и передать объект C++ для передачи функции сценария lua.
// ScriptComponent.h
class ScriptComponent : public Component
{
public:
virtual void Initialize();
virtual void Update();
protected:
luabind::object luaDataTable;
Entity* mOwner;
-
// ScriptComponent.cpp
void ScriptComponent::Initialize() {
luabind::object compiledScript;
luaL_loadfile(L, "myScript.lua");
luabind::object compiledScript(luabind::from_stack(L, -1));
luaDataTable = compiledScript();
lua_pop(L, 1);
}
void ScriptComponent::Update() {
luaDataTable["run"](mOwner); // Compiler breaks here.
// Note: if I remove mOwner from the mix (and in the script file) everything works and runs fine.
}
Прохладный! Но чтобы это заработало, luabind нужно знать, что такое mOwner (Entity*), и определить ti. Итак, я определяю его в другом файле:
// GameScriptingSystem.cpp
using namespace luabind;
module(inLuaState)
[
class_<GameObject>("GameObject"),
class_<Entity, bases<GameObject> >("Entity")
.def("DebugGetName", &Entity::DebugGetName)
];
Процесс выглядит примерно так:
Результат:
ошибка C2504: «Сущность»: базовый класс не определен
Полная ошибка по запросу:
...
2> Component.cpp
2> ScriptComponent.cpp
2>boost/type_traits/is_polymorphic.hpp(46): error C2504: 'Entity' : base class undefined
2> boost/type_traits/is_polymorphic.hpp(62) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp1<T>::d2' being compiled
2> with
2> [
2> T=Entity
2> ]
2> boost/type_traits/is_polymorphic.hpp(97) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp1<T>' being compiled
2> with
2> [
2> T=Entity
2> ]
2> boost/type_traits/is_polymorphic.hpp(102) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp<T>' being compiled
2> with
2> [
2> T=Entity
2> ]
2> luabind/detail/make_instance.hpp(42) : see reference to class template instantiation 'boost::is_polymorphic<T>' being compiled
2> with
2> [
2> T=Entity
2> ]
2> luabind/detail/make_instance.hpp(74) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2> luabind::detail::get_dynamic_class<T>(lua_State *,T *)' being compiled
2> with
2> [
2> _Ty1=luabind::detail::class_id,
2> _Ty2=void *,
2> T=Entity
2> ]
2> luabind/detail/policy.hpp(228) : see reference to function template instantiation 'void luabind::detail::make_instance<T*>(lua_State *,P)' being compiled
2> with
2> [
2> T=Entity,
2> P=Entity *
2> ]
2> luabind/detail/convert_to_lua.hpp(87) : see reference to function template instantiation 'void luabind::detail::pointer_converter::apply<Entity>(lua_State *,T *)' being compiled
2> with
2> [
2> T=Entity
2> ]
2> luabind/object.hpp(1072) : see reference to function template instantiation 'void luabind::detail::convert_to_lua_p<1,Entity*,Policies>(lua_State *,const T &,const Policies &)' being compiled
2> with
2> [
2> Policies=luabind::detail::null_type,
2> T=Entity *
2> ]
2> luabind/object.hpp(1140) : see reference to function template instantiation 'void luabind::detail::push_args_from_tuple<Index>::apply<T0,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type,luabind::detail::null_type>(lua_State *,const boost::tuples::cons<HT,TT> &,const Policies &)' being compiled
2> with
2> [
2> Index=1,
2> T0=Entity *const *,
2> HT=Entity *const *,
2> TT=boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type,
2> Policies=luabind::detail::null_type
2> ]
2> luabind/object.hpp(1140) : see reference to function template instantiation 'void luabind::detail::push_args_from_tuple<Index>::apply<T0,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type,luabind::detail::null_type>(lua_State *,const boost::tuples::cons<HT,TT> &,const Policies &)' being compiled
2> with
2> [
2> Index=1,
2> T0=Entity *const *,
2> HT=Entity *const *,
2> TT=boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type,
2> Policies=luabind::detail::null_type
2> ]
2> luabind/object.hpp(1112) : see reference to function template instantiation 'luabind::adl::object luabind::adl::call_proxy<ValueWrapper,Arguments>::call<luabind::detail::null_type>(Policies *)' being compiled
2> with
2> [
2> ValueWrapper=luabind::adl::index_proxy<luabind::adl::object>,
2> Arguments=boost::tuples::tuple<Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>,
2> Policies=luabind::detail::null_type
2> ]
2> luabind/object.hpp(1112) : see reference to function template instantiation 'luabind::adl::object luabind::adl::call_proxy<ValueWrapper,Arguments>::call<luabind::detail::null_type>(Policies *)' being compiled
2> with
2> [
2> ValueWrapper=luabind::adl::index_proxy<luabind::adl::object>,
2> Arguments=boost::tuples::tuple<Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>,
2> Policies=luabind::detail::null_type
2> ]
2> luabind/object.hpp(1110) : while compiling class template member function 'luabind::adl::call_proxy<ValueWrapper,Arguments>::~call_proxy(void)'
2> with
2> [
2> ValueWrapper=luabind::adl::index_proxy<luabind::adl::object>,
2> Arguments=boost::tuples::tuple<Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>
2> ]
2> ..\src\Game\GameObjects\Components\ScriptComponent.cpp(75) : see reference to function template instantiation 'luabind::adl::call_proxy<ValueWrapper,Arguments>::~call_proxy(void)' being compiled
2> with
2> [
2> ValueWrapper=luabind::adl::index_proxy<luabind::adl::object>,
2> Arguments=boost::tuples::tuple<Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>
2> ]
2> ..\src\Game\GameObjects\Components\ScriptComponent.cpp(75) : see reference to class template instantiation 'luabind::adl::call_proxy<ValueWrapper,Arguments>' being compiled
2> with
2> [
2> ValueWrapper=luabind::adl::index_proxy<luabind::adl::object>,
2> Arguments=boost::tuples::tuple<Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>
2> ]
2>boost/type_traits/is_polymorphic.hpp(34): error C2504: 'Entity' : base class undefined
2> boost/type_traits/is_polymorphic.hpp(62) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp1<T>::d1' being compiled
2> with
2> [
2> T=Entity
2> ]
2> Map.cpp
2> Generating Code...
2> Compiling...
2> GameScriptingSystem.cpp
2> PoCToolsInterface.cpp
..
Насколько я могу судить, это связано с порядком сборки. Насколько я понимаю, Luabind делает все это во время компиляции, и когда я сначала смотрю на компиляцию, ScriptComponent компилируется первым, а GameScriptSystem компилируется после. Когда ScriptComponent строится, все ошибки luabind проходят. ТОГДА после сборки GameScriptSystem (которая определяет все, на что жалуется LuaBind)
So:
Как отследить заказ на сборку? Посмотрите, какие файлы запускают сборку других, чтобы я мог изменить их по своему вкусу? (это большой проект, это не так просто, как смотреть на него 2 секунды)
Если вы знаете luabind, я прав в том, что это проблема?
Другие данные:
-- myScript.lua
local Cat = {}
local ticks = 0
function Cat.run(entity)
ticks = ticks + 1
LOG(tostring(ticks))
LOG(entity:DebugGetName())
end
return Cat