/*****************************************************************************
 * $LastChangedDate: 2011-03-17 19:59:52 -0400 (Thu, 17 Mar 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Interface of C functions for Lua scripts.
 * @remarks @remarks module.txt documents how to export new C++ classes to Lua.
 *
 * ----------------------------
 * -- THIS IS AUTO-GENERATED --
 * ----------------------------
 *
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#include "base/module.hh"
using namespace base;
#include "physics/module.hh"
#include "physics/physics_aircraft.hh"
using namespace physics;
#include "lua_bind/module.hh"
#include "lua_bind/bind.hh"

namespace lua {


namespace bind {

#define BIND_CLASS_NAME      "AircraftPhysics"
#define BIND_METATABLE_NAME  LUABIND_METATABLE_STRING(BIND_CLASS_NAME)

//==============================================================================
// C functions called by Lua that access C++ objects.
//==============================================================================

/*****************************************************************************
 * Degree AircraftPhysics:ComputeAngleOfAttack()
 *****************************************************************************/
INTERN int 
AircraftPhysics_ComputeAngleOfAttack( lua_State* L ) 
{ 
   try { 

        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
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * Newton[vec3] AircraftPhysics:ComputeDragForce()
 *****************************************************************************/
INTERN int 
AircraftPhysics_ComputeDragForce( lua_State* L ) 
{ 
   try { 

        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
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * Newton[vec3] AircraftPhysics:ComputeLiftForce()
 *****************************************************************************/
INTERN int 
AircraftPhysics_ComputeLiftForce( lua_State* L ) 
{ 
   try { 

        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
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * Speed AircraftPhysics:ComputeSpeed()
 *****************************************************************************/
INTERN int 
AircraftPhysics_ComputeSpeed( lua_State* L ) 
{ 
   try { 

        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
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * Newton[vec3] AircraftPhysics:ComputeThrustForce()
 *****************************************************************************/
INTERN int 
AircraftPhysics_ComputeThrustForce( lua_State* L ) 
{ 
   try { 

        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
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * Newton[vec3] AircraftPhysics:ComputeWeightForce()
 *****************************************************************************/
INTERN int 
AircraftPhysics_ComputeWeightForce( lua_State* L ) 
{ 
   try { 

        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
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * AircraftPhysics:Enable( bool )
 *****************************************************************************/
INTERN int 
AircraftPhysics_Enable( lua_State* L ) 
{ 
   try { 

        const bool enable = POP_BOOL( L );
        SafePtr<AircraftPhysics> physics = POP_USERDATA_AS_PTR<AircraftPhysics>( L );
        CHECK_TYPESIG(physics,TYPESIG_AIRCRAFT_PHYSICS);
        physics->Enable( enable );
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * bool AircraftPhysics:IfStall()
 *****************************************************************************/
INTERN int 
AircraftPhysics_IfStall( lua_State* L ) 
{ 
   try { 

        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
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * AircraftPhysics:SetSpeed( Speed )
 *****************************************************************************/
INTERN int 
AircraftPhysics_SetSpeed( lua_State* L ) 
{ 
   try { 

        const Speed speed( POP_NUMBER( L ) );
        SafePtr<AircraftPhysics> physics = POP_USERDATA_AS_PTR<AircraftPhysics>( L );
        CHECK_TYPESIG(physics,TYPESIG_AIRCRAFT_PHYSICS);
        physics->SetSpeed( speed );
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

//==============================================================================
// Register binding with Lua. 
//==============================================================================

#if ! DOXYGEN 

INTERN const struct luaL_reg sMethodTable[] =
{
  // New(),__gc() omitted as Lua cannot instantiate this C++ class.
  { "ComputeAngleOfAttack", AircraftPhysics_ComputeAngleOfAttack },
  { "ComputeDragForce", AircraftPhysics_ComputeDragForce },
  { "ComputeLiftForce", AircraftPhysics_ComputeLiftForce },
  { "ComputeSpeed", AircraftPhysics_ComputeSpeed },
  { "ComputeThrustForce", AircraftPhysics_ComputeThrustForce },
  { "ComputeWeightForce", AircraftPhysics_ComputeWeightForce },
  { "Enable", AircraftPhysics_Enable },
  { "IfStall", AircraftPhysics_IfStall },
  { "SetSpeed", AircraftPhysics_SetSpeed },
  { NULL, NULL }
};

void
RegisterAircraftPhysics( lua_State* L )
{
    REGISTER_BINDING( L,
                      BIND_METATABLE_NAME,
                      BIND_CLASS_NAME,
                      sMethodTable );
}

#endif // ! DOXYGEN 

} // namespace bind 

} // namespace lua 
