-- $LastChangedDate: 2010-04-16 23:43:07 -0400 (Fri, 16 Apr 2010) $
-- Macros written in Lua to expand C++ code for bindings between C++/Lua.

bindTable = {

class = "Carrier",
typesig = "TYPESIG_CARRIER",
luaCanInstantiate = true,

headers =
[[
#include "base/module.hh"
using namespace base;
#include "object/module.hh"
#include "object/aircraft.hh"
using namespace object;
#include "program/module.hh"
#include "program/carrier.hh"
using namespace program;
]],

func_New = {
    comments = "Carrier:New( x,y,z|Vec, carrierNum )",
    code = [[
        const int         carrierNum = POP_INT( L );
        const WorldVertex carrierPos = POP_VECTOR3<WorldVertex>( L );
        shptr<Carrier> carrier = Carrier::MakeCarrier( carrierPos, carrierNum );
        return NEW_USERDATA_SHPTR<Carrier>( L, carrier, BIND_METATABLE_NAME );
    ]]
},

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

func_PlaceAircraft = {
    comments = "Carrier:PlaceAircraft( aircraft, meterX,meterY,meterZ|Vec3 )",
    code = [[
        const GeoVertex geoPos   = POP_VECTOR3<GeoVertex>( L );
        shptr<Aircraft> aircraft = POP_USERDATA_AS_SHPTR<Aircraft>( L );
        shptr<Carrier>  carrier  = POP_USERDATA_AS_SHPTR<Carrier>( L );   // self
        CHECK_TYPESIG(aircraft,TYPESIG_AIRCRAFT);
        CHECK_TYPESIG(carrier,TYPESIG_CARRIER);
        carrier->PlaceAircraft( aircraft, geoPos );
    ]]
},

}

--------------------------------------------------------------------------------
-- Inherit Object methods.
function InheritMethod( code )
    code = string.gsub( code, "object", "carrier" )
    code = string.gsub( code, "Object", "Carrier" )
    code = string.gsub( code, "OBJECT", "CARRIER" )
    return code
end
dofile( srcDir .. "bind_object_common.lua" )
