-- $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.
-- Avoid lua_/LUA_ which is reserved by Lua.

bindTable = {

class = "ChaseViewpoint",
typesig = "TYPESIG_CHASE_VIEWPOINT",
luaCanInstantiate = true,

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

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

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

func_Save = {
    comments = "ChaseViewpoint:Save()",
    code = [[
        shptr<ChaseViewpoint> chaseViewpoint = POP_USERDATA_AS_SHPTR<ChaseViewpoint>( L );
        CHECK_TYPESIG(chaseViewpoint,TYPESIG_CHASE_VIEWPOINT);
        chaseViewpoint->Save();
    ]]
},

func_Reset = {
    comments = "ChaseViewpoint:Reset()",
    code = [[
        shptr<ChaseViewpoint> chaseViewpoint = POP_USERDATA_AS_SHPTR<ChaseViewpoint>( L );
        CHECK_TYPESIG(chaseViewpoint,TYPESIG_CHASE_VIEWPOINT);
        chaseViewpoint->Reset();
    ]]
},

func_SetTarget = {
    comments = "ChaseViewpoint:SetTarget( Object )",
    code = [[
        // Example of Lua passing an Object-derivative (usually Aircraft)
        // which C++ then casts to a base class.
        shptr<Object> target = POP_USERDATA_AS_SHPTR<Object>( L );
        CHECK_TYPESIG(target,TYPESIG_OBJECT);

        shptr<ChaseViewpoint> chaseViewpoint = POP_USERDATA_AS_SHPTR<ChaseViewpoint>( L );
        CHECK_TYPESIG(chaseViewpoint,TYPESIG_CHASE_VIEWPOINT);

        chaseViewpoint->SetTarget( target );
    ]]
},

func_SetDistance = {
    comments = "ChaseViewpoint:SetDistance( x,y,z|Vec3 )",
    code = [[
        const Vector3 distance = POP_VECTOR3<Vector3>( L );
        shptr<ChaseViewpoint> chaseViewpoint = POP_USERDATA_AS_SHPTR<ChaseViewpoint>( L );
        CHECK_TYPESIG(chaseViewpoint,TYPESIG_CHASE_VIEWPOINT);
        chaseViewpoint->SetDistance( distance );
    ]]
},

func_Rotate = {
    comments = "ChaseViewpoint:Rotate( axis, radian )",
    code = [[
        const Radian rad( POP_FP( L ) );
        const uint axis( POP_INT( L ) );
        shptr<ChaseViewpoint> chaseViewpoint = POP_USERDATA_AS_SHPTR<ChaseViewpoint>( L );
        CHECK_TYPESIG(chaseViewpoint,TYPESIG_CHASE_VIEWPOINT);
        chaseViewpoint->Rotate( axis, rad );
    ]]
},

func_Move = {
    comments = "ChaseViewpoint:Move( inc ) / inc is in world space.",
    code = [[
        const fp inc = POP_FP( L );
        shptr<ChaseViewpoint> chaseViewpoint = POP_USERDATA_AS_SHPTR<ChaseViewpoint>( L );
        CHECK_TYPESIG(chaseViewpoint,TYPESIG_CHASE_VIEWPOINT);
        chaseViewpoint->Move( inc );
    ]]
},

}
