-- $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 = "Dyna",
typesig = "TYPESIG_DYNA",
luaCanInstantiate = true,

headers =
[[
#include "base/module.hh"
using namespace base;
#include "object/module.hh"
#include "object/dyna.hh"
using namespace object;
#include "graph/module.hh"
#include "graph/model_cache.hh"
using namespace graph;
]],

func_New = {
    comments = "Dyna:New( x,y,z|Vec3, modelPathname, scale, ModelCache.LOAD_SHARED|LOAD_COPY )",
    code = [[
        const bool        loadCopy  = POP_BOOL( L );
        const fp          scale     = POP_FP( L );
        const string      modelName = POP_STRING( L );
        const WorldVertex pos       = POP_VECTOR3<WorldVertex>( L );

        // Load 3D model.
        shptr<Graph> graph = GET_MODEL_CACHE().LoadModel( modelName, scale, loadCopy );
        shptr<Dyna>  dyna  = new Dyna( graph, pos );

        return NEW_USERDATA_SHPTR<Dyna>( L, dyna, BIND_METATABLE_NAME );
    ]]
},

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

}

--------------------------------------------------------------------------------
-- Inherit Object methods.
function InheritMethod( code )
    code = string.gsub( code, "object", "dyna" )
    code = string.gsub( code, "Object", "Dyna" )
    code = string.gsub( code, "OBJECT", "DYNA" )
    return code
end
dofile( srcDir .. "bind_object_common.lua" )
