/*****************************************************************************
 * $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 "view/module.hh"
#include "view/observer_matrix.hh"
using namespace view;
#include "lua_bind/module.hh"
#include "lua_bind/bind.hh"

namespace lua {


namespace bind {

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

//==============================================================================
// C functions called by Lua that access C++ objects.
//==============================================================================
// Need a function to check typesig because of macro/template limitations.
#if ! DOXYGEN
INTERN void
CheckTypesigObserverMatrix( shptr<ObserverMatrix> obj )
{
    CHECK_TYPESIG(obj,TYPESIG_OBSERVER_MATRIX);
}
#endif // ! DOXYGEN

/*****************************************************************************
 * Lua's garbage collector indirectly invokes this C++ destructor.
 *****************************************************************************/
INTERN int 
ObserverMatrix_Destroy( lua_State* L ) 
{ 
   try { 

        return DESTROY_USERDATA_SHPTR<ObserverMatrix>( L, CheckTypesigObserverMatrix );
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * table ObserverMatrix:GetObserverMatrix()
 *****************************************************************************/
INTERN int 
ObserverMatrix_GetObserverMatrix( lua_State* L ) 
{ 
   try { 

        shptr<ObserverMatrix> observerMatrix = POP_USERDATA_AS_SHPTR<ObserverMatrix>( L );
        CHECK_TYPESIG(observerMatrix,TYPESIG_OBSERVER_MATRIX);
        PUSH_TABLE_FROM_MATRIX( L, observerMatrix->GetObserverMatrix() );  // actual matrix
        return 1;  // stack items to return
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * ObserverMatrix:New()
 *****************************************************************************/
INTERN int 
ObserverMatrix_New( lua_State* L ) 
{ 
   try { 

        shptr<ObserverMatrix> observerMatrix = new ObserverMatrix;
        return NEW_USERDATA_SHPTR<ObserverMatrix>( L, observerMatrix, BIND_METATABLE_NAME );
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * ObserverMatrix:SetObserverMatrix( matrix )
 *****************************************************************************/
INTERN int 
ObserverMatrix_SetObserverMatrix( lua_State* L ) 
{ 
   try { 

        Matrix matrix; POP_TABLE_INTO_MATRIX( L, matrix );
        shptr<ObserverMatrix> observerMatrix = POP_USERDATA_AS_SHPTR<ObserverMatrix>( L );
        CHECK_TYPESIG(observerMatrix,TYPESIG_OBSERVER_MATRIX);
        observerMatrix->SetObserverMatrix( matrix );
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

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

#if ! DOXYGEN 

INTERN const struct luaL_reg sMethodTable[] =
{
  { "New", ObserverMatrix_New },
  { "__gc", ObserverMatrix_Destroy },
  { "GetObserverMatrix", ObserverMatrix_GetObserverMatrix },
  { "SetObserverMatrix", ObserverMatrix_SetObserverMatrix },
  { NULL, NULL }
};

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

#endif // ! DOXYGEN 

} // namespace bind 

} // namespace lua 
