-- $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 = "Base",
typesig = nil,
luaCanInstantiate = false,

headers =
[[
#include "base/module.hh"
using namespace base;
#include "physics/module.hh"
#include "physics/physics_control.hh" // GetSimulationSpeed()
using namespace physics;
#include "program/module.hh"
using namespace program;
]],

func_IfGfxSysIsOSG = {
    comments = "bool Base:IfGfxSysIsOSG()  -- if graphics system is OpenSceneGraph",
    code = [[
#if COMPILE_OSG
        lua_pushboolean( L, true );
#else
        lua_pushboolean( L, false );
#endif
        return 1;  // stack items to return
    ]]
},

func_IfDebug = {
    comments = "bool Base:IfDebug()",
    code = [[
#if DEBUG
        lua_pushboolean( L, true );
#else
        lua_pushboolean( L, false );
#endif
        return 1;  // stack items to return
    ]]
},

func_GetMemoryUsed = {
    comments = "int Base:GetMemoryUsed()",
    code = [[
#if DEBUG
        lua_pushnumber( L, MemoryUsed() );
#else
        lua_pushnumber( L, 0 );  // N/A in non-DEBUG
#endif
        return 1;  // stack items to return
    ]]
},

func_GetScriptDir = {
    comments = "string Base:GetScriptDir()",
    code = [[
        lua_pushstring( L, GET_LUA().GetScriptDir().c_str() );
        return 1;  // stack items to return
    ]]
},

func_GetElapsedTime = {
    comments = "milliseconds Base:GetElapsedTime()",
    code = [[
        // Since Lua's tick handler cannot be disabled (active while paused),
        // return the elapsed time counted even while paused.
        lua_pushnumber( L, GET_TIMER().GetElapsedTimeTotal().INT() );
        return 1;  // stack items to return
    ]]
},

func_GetTickFreq = {
    comments = "milliseconds Base:GetTickFreq()\n * Frequency of program's timer-tick (its pulse).",
    code = [[
        lua_pushnumber( L, PROGRAM_CONF.mTimerTickFreq.INT() );
        return 1;  // stack items to return
    ]]
},

func_GetSimulationSpeed = {
    comments = "f Base:GetSimulationSpeed()",
    code = [[
        lua_pushnumber( L, PhysicsControl::GetSimulationSpeed() );
        return 1;  // stack items to return
    ]]
},

func_SetSimulationSpeed = {
    comments = "Base:SetSimulationSpeed(f)",
    code = [[
        const fp simulationSpeed = POP_FP( L );
        PhysicsControl::SetSimulationSpeed( simulationSpeed );
        return 0;  // stack items to return
    ]]
},

}
