-- $LastChangedDate: 2011-03-17 19:59:52 -0400 (Thu, 17 Mar 2011) $
-- Macros written in Lua to expand C++ code for bindings between C++/Lua.
-- Avoid lua_/LUA_ which is reserved by Lua.

-- AircraftPhysics isn't reference-counted as it is an actual member of Craft.

bindTable = {

class = "AircraftPhysics",
typesig = nil,
luaCanInstantiate = false,

headers =
[[
#include "base/module.hh"
using namespace base;
#include "physics/module.hh"
#include "physics/physics_aircraft.hh"
using namespace physics;
]],

func_Enable = {
    comments = "AircraftPhysics:Enable( bool )",
    code = [[
        const bool enable = POP_BOOL( L );
        SafePtr<AircraftPhysics> physics = POP_USERDATA_AS_PTR<AircraftPhysics>( L );
        CHECK_TYPESIG(physics,TYPESIG_AIRCRAFT_PHYSICS);
        physics->Enable( enable );
    ]]
},

func_SetSpeed = {
    comments = "AircraftPhysics:SetSpeed( Speed )",
    code = [[
        const Speed speed( POP_NUMBER( L ) );
        SafePtr<AircraftPhysics> physics = POP_USERDATA_AS_PTR<AircraftPhysics>( L );
        CHECK_TYPESIG(physics,TYPESIG_AIRCRAFT_PHYSICS);
        physics->SetSpeed( speed );
    ]]
},

func_ComputeSpeed = {
    comments = "Speed AircraftPhysics:ComputeSpeed()",
    code = [[
        SafePtr<AircraftPhysics> physics = POP_USERDATA_AS_PTR<AircraftPhysics>( L );
        CHECK_TYPESIG(physics,TYPESIG_AIRCRAFT_PHYSICS);
        lua_pushnumber( L, physics->ComputeSpeed().FP() );
        return 1;  // stack items to return
    ]]
},

func_ComputeThrustForce = {
    comments = "Newton[vec3] AircraftPhysics:ComputeThrustForce()",
    code = [[
        SafePtr<AircraftPhysics> physics = POP_USERDATA_AS_PTR<AircraftPhysics>( L );
        CHECK_TYPESIG(physics,TYPESIG_AIRCRAFT_PHYSICS);
        PUSH_VECTOR3( L, physics->ComputeThrustForce() );
        return 1;  // stack items to return
    ]]
},

func_ComputeLiftForce = {
    comments = "Newton[vec3] AircraftPhysics:ComputeLiftForce()",
    code = [[
        SafePtr<AircraftPhysics> physics = POP_USERDATA_AS_PTR<AircraftPhysics>( L );
        CHECK_TYPESIG(physics,TYPESIG_AIRCRAFT_PHYSICS);
        PUSH_VECTOR3( L, physics->ComputeLiftForce() );
        return 1;  // stack items to return
    ]]
},

func_ComputeDragForce = {
    comments = "Newton[vec3] AircraftPhysics:ComputeDragForce()",
    code = [[
        SafePtr<AircraftPhysics> physics = POP_USERDATA_AS_PTR<AircraftPhysics>( L );
        CHECK_TYPESIG(physics,TYPESIG_AIRCRAFT_PHYSICS);
        PUSH_VECTOR3( L, physics->ComputeDragForce() );
        return 1;  // stack items to return
    ]]
},

func_ComputeWeightForce = {
    comments = "Newton[vec3] AircraftPhysics:ComputeWeightForce()",
    code = [[
        SafePtr<AircraftPhysics> physics = POP_USERDATA_AS_PTR<AircraftPhysics>( L );
        CHECK_TYPESIG(physics,TYPESIG_AIRCRAFT_PHYSICS);
        PUSH_VECTOR3( L, physics->ComputeWeightForce() );
        return 1;  // stack items to return
    ]]
},

func_ComputeAngleOfAttack = {
    comments = "Degree AircraftPhysics:ComputeAngleOfAttack()",
    code = [[
        SafePtr<AircraftPhysics> physics = POP_USERDATA_AS_PTR<AircraftPhysics>( L );
        CHECK_TYPESIG(physics,TYPESIG_AIRCRAFT_PHYSICS);
        lua_pushnumber( L, physics->ComputeAngleOfAttack() );
        return 1;  // stack items to return
    ]]
},

func_IfStall = {
    comments = "bool AircraftPhysics:IfStall()",
    code = [[
        SafePtr<AircraftPhysics> physics = POP_USERDATA_AS_PTR<AircraftPhysics>( L );
        CHECK_TYPESIG(physics,TYPESIG_AIRCRAFT_PHYSICS);
        lua_pushboolean( L, physics->IfStall() );
        return 1;  // stack items to return
    ]]
},

}
