-- $LastChangedDate: 2010-05-28 23:19:39 -0400 (Fri, 28 May 2010) $
-- Macros written in Lua to expand C++ code for bindings between C++/Lua.
-- Avoid lua_/LUA_ which is reserved by Lua.

bindTable = {

class = "Missile",
typesig = "TYPESIG_MISSILE",
luaCanInstantiate = true,

headers =
[[
#include "base/module.hh"
using namespace base;
#include "object/module.hh"
#include "object/dyna.hh"
using namespace object;
#include "game/module.hh"
#include "game/missile.hh"
using namespace game;
]],

func_New = {
    comments = "Missile:New( target, launcher, launcherSpeed, radiusGeo, malfunction )",
    code = [[
        const bool malfunction        = POP_BOOL( L );
        const Meter particleRadiusGeo = Meter( POP_FP( L ) );
        const Speed launcherSpeed     = Speed( POP_FP( L ) );
        shptr<Dyna> launcher          = POP_USERDATA_AS_SHPTR<Dyna>( L );
        shptr<Dyna> target            = POP_USERDATA_AS_SHPTR<Dyna>( L );
        CHECK_TYPESIG(launcher,TYPESIG_OBJECT);
        CHECK_TYPESIG(target,TYPESIG_OBJECT);
        shptr<Missile> missile = new Missile( target, *launcher, launcherSpeed, particleRadiusGeo, malfunction );
        return NEW_USERDATA_SHPTR<Missile>( L, missile, BIND_METATABLE_NAME );
    ]]
},

func_Destroy = {
    comments = "Lua's garbage collector indirectly invokes this C++ destructor.",
    code = [[
        return DESTROY_USERDATA_SHPTR<Missile>( L, CheckTypesigMissile );
    ]]
},

}

--------------------------------------------------------------------------------
-- Inherit Object methods.
function InheritMethod( code )
    code = string.gsub( code, "object", "missile" )
    code = string.gsub( code, "Object", "Missile" )
    code = string.gsub( code, "OBJECT", "MISSILE" )
    return code
end
dofile( srcDir .. "bind_object_common.lua" )
