-- $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.

bindTable = {

class = "ObserverMatrix",
typesig = "TYPESIG_OBSERVER_MATRIX",
luaCanInstantiate = true,

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

func_New = {
    comments = "ObserverMatrix:New()",
    code = [[
        shptr<ObserverMatrix> observerMatrix = new ObserverMatrix;
        return NEW_USERDATA_SHPTR<ObserverMatrix>( L, observerMatrix, BIND_METATABLE_NAME );
    ]]
},

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

func_GetObserverMatrix = {
    comments = "table ObserverMatrix:GetObserverMatrix()",
    code = [[
        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
    ]]
},

func_SetObserverMatrix = {
    comments = "ObserverMatrix:SetObserverMatrix( matrix )",
    code = [[
        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 );
    ]]
},

}
