yake-svn Mailing List for Yake Engine (Page 10)
Status: Beta
Brought to you by:
psyclonist
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(17) |
Sep
(51) |
Oct
(2) |
Nov
(18) |
Dec
(66) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(44) |
Feb
(13) |
Mar
(73) |
Apr
(61) |
May
|
Jun
(4) |
Jul
(19) |
Aug
(50) |
Sep
(47) |
Oct
(7) |
Nov
(7) |
Dec
(14) |
2008 |
Jan
(2) |
Feb
|
Mar
(4) |
Apr
(4) |
May
(5) |
Jun
(7) |
Jul
(4) |
Aug
|
Sep
(5) |
Oct
|
Nov
(1) |
Dec
(4) |
2009 |
Jan
|
Feb
(22) |
Mar
(12) |
Apr
(1) |
May
(1) |
Jun
(4) |
Jul
(4) |
Aug
|
Sep
|
Oct
(17) |
Nov
(3) |
Dec
|
2010 |
Jan
|
Feb
|
Mar
(12) |
Apr
(11) |
May
|
Jun
(5) |
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <psy...@us...> - 2007-08-23 23:25:11
|
Revision: 1812 http://yake.svn.sourceforge.net/yake/?rev=1812&view=rev Author: psyclonist Date: 2007-08-23 16:25:11 -0700 (Thu, 23 Aug 2007) Log Message: ----------- * [samples] fixed configuration for 'res/lua1' * [res] fixed typoes and invalid type name * [scripting.lua] scripting::LuaScript can now be used as a Resource * [scripting.lua] scripting::LuaScriptManager manages LuaScript resources Modified Paths: -------------- trunk/yake/common/media/scripts/res1.lua trunk/yake/samples/res/lua1/demo.cpp trunk/yake/scripts/premake/plugins.lua trunk/yake/scripts/premake/samples.lua trunk/yake/src/bindings.lua/bindings.lua.cpp trunk/yake/src/bindings.lua/detail/res.lua.cpp trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp trunk/yake/src/res/source_manager.cpp trunk/yake/yake/plugins/scriptingLua/ScriptingSystemLua.h trunk/yake/yake/res/source.h trunk/yake/yake/scripting/yakeScriptingSystem.h Modified: trunk/yake/common/media/scripts/res1.lua =================================================================== --- trunk/yake/common/media/scripts/res1.lua 2007-08-23 22:34:37 UTC (rev 1811) +++ trunk/yake/common/media/scripts/res1.lua 2007-08-23 23:25:11 UTC (rev 1812) @@ -1,14 +1,17 @@ -- acquire global res::SourceManager +print("acquire SourceManager") assert( yake.res ) local res = yake.res assert( res.global.sourceManager ) local sourceManager = res.global.sourceManager -- add some sources +print("add sources") sourceManager:addSource("file","./") -sourceManager:addSource("file","e:/dev/yake.trunk/yake/scripts/tools/luadocs/") +sourceManager:addSource("file","../../../scripts/tools/luadocs/") -- find resource using sourceManager: +print("locate project.txt...") local find = sourceManager:find("project.txt") if find.valid then print("found project.txt at: "..find.location) Modified: trunk/yake/samples/res/lua1/demo.cpp =================================================================== --- trunk/yake/samples/res/lua1/demo.cpp 2007-08-23 22:34:37 UTC (rev 1811) +++ trunk/yake/samples/res/lua1/demo.cpp 2007-08-23 23:25:11 UTC (rev 1812) @@ -5,6 +5,8 @@ #include <yake/bindings.lua/bindings.lua.h> #include <yake/bindings.lua/common/yake.lua.common.h> +#include <yake/res/res.h> + using namespace yake; /** Configuration of the application */ @@ -17,32 +19,20 @@ { return MakeStringVector() << "lua"; } }; -/** Main application state */ -class TheMainState : public raf::RtMainState +/** The mighty application itself! */ +class TheApp : public raf::ExampleApplication<TheConfiguration> { public: - TheMainState(raf::Application& owner) : raf::RtMainState(owner), app_(owner) - { - } + TheApp() {} protected: - virtual void onEnter() + virtual bool onRun() { - raf::RtMainState::onEnter(); - } - virtual void onExit() - { - raf::RtMainState::onExit(); - vm_.reset(); - } - virtual void onCreateScene() - { YAKE_LOG_INFORMATION("demo","Starting"); - scripting::IScriptingSystem* sys = app_.getScriptingSystem(); + scripting::IScriptingSystem* sys = getScriptingSystem("lua"); YAKE_ASSERT( sys ); - YAKE_ASSERT( !vm_ ); - vm_ = sys->createVM(); - bind_all(vm_.get()); + scripting::VMPtr vm = sys->createVM(); + bind_all(vm.get()); //bind { @@ -51,32 +41,27 @@ luabind::globals(L)["app"] = &app_; */ } + // + res::SourceFactory::global().reg<res::FileSource>("file"); + res::SourceManager::global().addSource("file","../../../common/media/scripts/"); - scripting::ScriptPtr script = sys->createScriptFromFile("../../../common/media/scripts/res1.lua"); - vm_->execute( script ); + //scripting::LuaScriptManager::global().create("res1.lua"); + //res::SourceManager::global().find("res1.lua"); + // + try + { + scripting::ScriptPtr script = sys->createScriptFromFile("res1.lua"); + vm->execute( script ); + } + catch (Exception& ex) + { + YAKE_LOG_INFORMATION("demo",ex.what()); + } - this->requestQuit(); + return true; } - virtual void onFrame(const real timeElapsed) - { - } -private: - raf::Application& app_; - scripting::VMPtr vm_; }; -/** The mighty application itself! */ -class TheApp : public raf::ExampleApplication<TheConfiguration> -{ -public: - TheApp() {} -protected: - virtual raf::MainState* createMainState() - { - return new TheMainState(*this); - } -}; - int main( int argc, char** argv ) { // Use default executor for convenience. Modified: trunk/yake/scripts/premake/plugins.lua =================================================================== --- trunk/yake/scripts/premake/plugins.lua 2007-08-23 22:34:37 UTC (rev 1811) +++ trunk/yake/scripts/premake/plugins.lua 2007-08-23 23:25:11 UTC (rev 1812) @@ -42,6 +42,7 @@ -------------------------------------- makeComponentPlugin("scriptingLua","YAKE_SCRIPTINGLUA_EXPORTS") addDependency("base") +addDependency("res") addDependency("scripting") if (windows) then Modified: trunk/yake/scripts/premake/samples.lua =================================================================== --- trunk/yake/scripts/premake/samples.lua 2007-08-23 22:34:37 UTC (rev 1811) +++ trunk/yake/scripts/premake/samples.lua 2007-08-23 23:25:11 UTC (rev 1812) @@ -94,6 +94,7 @@ -------------------------------------- if ENABLE_LUA_RES then makeSample("sampleResLuaDemo1","samples/res/lua1") + sampleUsesConsole() useComponent("base") useComponent("res") useComponent("bindings.lua") Modified: trunk/yake/src/bindings.lua/bindings.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/bindings.lua.cpp 2007-08-23 22:34:37 UTC (rev 1811) +++ trunk/yake/src/bindings.lua/bindings.lua.cpp 2007-08-23 23:25:11 UTC (rev 1812) @@ -88,6 +88,9 @@ #if YAKE_ENABLE_LUA_RAF == 1 bind_raf(L); #endif +#if YAKE_ENABLE_LUA_RES == 1 + bind_res(L); +#endif } void bind_all(scripting::IVM* vm) { Modified: trunk/yake/src/bindings.lua/detail/res.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/detail/res.lua.cpp 2007-08-23 22:34:37 UTC (rev 1811) +++ trunk/yake/src/bindings.lua/detail/res.lua.cpp 2007-08-23 23:25:11 UTC (rev 1812) @@ -64,11 +64,11 @@ class_<DataStreamBase,DataStreamPtr>("DataStreamBase") , class_<ResourceBase,ResourcePtr>("ResourceBase") + //, + //class_<SourceId>("SourceId") + //, + //class_<Location>("Location") , - class_<SourceId>("SourceId") - , - class_<Location>("Location") - , class_<Source,SourcePtr>("Source") .def("open",&Source::open) .def("exists",&Source::exists) Modified: trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp =================================================================== --- trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp 2007-08-23 22:34:37 UTC (rev 1811) +++ trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp 2007-08-23 23:25:11 UTC (rev 1812) @@ -120,17 +120,24 @@ YAKE_ASSERT( pScript ); std::string err; try { - YAKE_ASSERT( pScript->getCreator()->getLanguage() == scripting::IScriptingSystem::L_LUA ); - if ( ( pScript->getCreator()->getLanguage() != scripting::IScriptingSystem::L_LUA ) || - ( 0 == mLuaState ) ) + //YAKE_ASSERT( pScript->getCreator()->getLanguage() == scripting::IScriptingSystem::L_LUA ); + //if ( ( pScript->getCreator()->getLanguage() != scripting::IScriptingSystem::L_LUA ) || + // ( 0 == mLuaState ) ) + // return; + YAKE_ASSERT( dynamic_cast<LuaScript*>(pScript.get()) != 0 ).debug("incompatible language"); + if (dynamic_cast<LuaScript*>(pScript.get()) == 0) return; LuaScript* pLuaScript = static_cast<LuaScript*>( pScript.get() ); - const String& rFileName = pLuaScript->getData(); + const LuaScript::CodeBuffer& code = pLuaScript->getData(); + if (code.empty()) + return; //nothing to do lua_pushcclosure(mLuaState, &pcall_handler, 0); - if (luaL_loadfile(mLuaState, rFileName.c_str())) + //if (luaL_loadbuffer(mLuaState,(const char*)&code[0],code.size(),"buffer")) + if (luaL_loadstring(mLuaState,(const char*)&code[0])) + //if (luaL_loadfile(mLuaState, rFileName.c_str())) { err = lua_tostring(mLuaState, -1); lua_pop(mLuaState, 2); // pop 2: cclosure and error string @@ -199,17 +206,13 @@ //------------------------------------------------------ ScriptPtr ScriptingSystemLua::createScriptFromFile( const String & rFile ) { - ScriptPtr script( new LuaScript(this/*this->shared_from_this()*/) ); - - script->setData( rFile ); - + ScriptPtr script = LuaScriptManager::global().create( rFile ); return script; } //------------------------------------------------------ - LuaScript::LuaScript( ScriptingSystemLua* pCreator ) : mCreator( pCreator ) + LuaScript::LuaScript() { - YAKE_ASSERT( mCreator ).debug( "creator scripting system undefined!" ); } //------------------------------------------------------ @@ -218,29 +221,64 @@ } //------------------------------------------------------ - const IScriptingSystem* LuaScript::getCreator() const - { - return mCreator; - } - - //------------------------------------------------------ bool LuaScript::isLoaded() { - return mFileName.size() != 0; + return !mCode.empty(); } //------------------------------------------------------ void LuaScript::setData( const String& rData ) { - mFileName = rData; + if (rData.empty()) + { + mCode.clear(); + return; + } + mCode.resize( (rData.size()+1) * sizeof(String::value_type) ); + memcpy( &mCode[0], rData.c_str(), rData.size() * sizeof(String::value_type) ); + mCode[ rData.size() ] = '\0'; } + void LuaScript::setData(const yake::uint8 *data, const size_t length) + { + if (length == 0 || !data) + { + mCode.clear(); + return; + } + mCode.resize(length); + memcpy( &mCode[0], data, length ); + } + uint8* LuaScript::resizeData(const size_t length) + { + mCode.resize(length); + if (mCode.empty()) + return 0; + return &mCode[0]; + } //------------------------------------------------------ - const String& LuaScript::getData() const + const LuaScript::CodeBuffer& LuaScript::getData() const { - return mFileName; + return mCode; } + //------------------------------------------------------ + LuaScriptManager& LuaScriptManager::global() + { + static LuaScriptManager s_global; + return s_global; + } + res::ResourcePtr LuaScriptManager::createAndInitResource(res::DataStreamBase& data) + { + boost::shared_ptr<LuaScript> script( new LuaScript() ); + uint8* code = script->resizeData( data.size() ); + YAKE_ASSERT( code != 0 ).debug("stream empty? no data to fill the code buffer with."); + if (!code) + return res::ResourcePtr(); + data.read(code,data.size()); + return script; + } + //------------------------------------------------------ LuaThread::LuaThread(lua_State* parent) : parent_(parent), state_(0), parentRef_(-1) { parentRef_ = luaL_ref( parent, LUA_REGISTRYINDEX ); Modified: trunk/yake/src/res/source_manager.cpp =================================================================== --- trunk/yake/src/res/source_manager.cpp 2007-08-23 22:34:37 UTC (rev 1811) +++ trunk/yake/src/res/source_manager.cpp 2007-08-23 23:25:11 UTC (rev 1812) @@ -89,6 +89,7 @@ return stream; } } + assert( false && "failed to open data stream: could not locate" ); return DataStreamPtr(); } SourceManager& SourceManager::global() Modified: trunk/yake/yake/plugins/scriptingLua/ScriptingSystemLua.h =================================================================== --- trunk/yake/yake/plugins/scriptingLua/ScriptingSystemLua.h 2007-08-23 22:34:37 UTC (rev 1811) +++ trunk/yake/yake/plugins/scriptingLua/ScriptingSystemLua.h 2007-08-23 23:25:11 UTC (rev 1812) @@ -31,6 +31,7 @@ #include <boost/enable_shared_from_this.hpp> #include <boost/shared_ptr.hpp> #include <boost/noncopyable.hpp> +#include <yake/res/res.h> #if defined( YAKE_SCRIPTINGLUA_EXPORTS ) # define YAKE_SCRIPTINLUA_API YAKE_EXPORT_API @@ -149,25 +150,31 @@ }; //---------------------------------------------------- - class YAKE_SCRIPTINLUA_API LuaScript : public scripting::IScript + class YAKE_SCRIPTINLUA_API LuaScript : public res::Resource<LuaScript>, public scripting::IScript { public: - LuaScript( ScriptingSystemLua* pCreator ); + LuaScript(); virtual ~LuaScript(); - /** Get a pointer to the scripting system that - created this IScript object. - */ - virtual const IScriptingSystem* getCreator() const; + typedef std::vector<uint8> CodeBuffer; + virtual bool isLoaded(); virtual void setData( const String& rData ); + virtual void setData( const uint8* data, const size_t length ); + const CodeBuffer& getData() const; + uint8* resizeData(const size_t length); - const String& getData() const; + private: + CodeBuffer mCode; + }; + //---------------------------------------------------- + struct YAKE_SCRIPTINLUA_API LuaScriptManager : public res::ResourceManager<LuaScript> + { private: - String mFileName; - //SharedPtr<ScriptingSystemLua> mCreator; // to avoid destruction of system when VMs are still active - ScriptingSystemLua* mCreator; + virtual res::ResourcePtr createAndInitResource(res::DataStreamBase& data); + public: + static LuaScriptManager& global(); }; //---------------------------------------------------- @@ -186,6 +193,7 @@ lua_State* state_; }; + } // scripting } // yake #endif Modified: trunk/yake/yake/res/source.h =================================================================== --- trunk/yake/yake/res/source.h 2007-08-23 22:34:37 UTC (rev 1811) +++ trunk/yake/yake/res/source.h 2007-08-23 23:25:11 UTC (rev 1812) @@ -92,7 +92,7 @@ { assert( !id.empty() ); if (id.empty()) - throw InvalidParameterException("id is empty/null"); + throw InvalidInputException("id is empty/null"); creators_[ id ] = boost::bind(&T::create); } Modified: trunk/yake/yake/scripting/yakeScriptingSystem.h =================================================================== --- trunk/yake/yake/scripting/yakeScriptingSystem.h 2007-08-23 22:34:37 UTC (rev 1811) +++ trunk/yake/yake/scripting/yakeScriptingSystem.h 2007-08-23 23:25:11 UTC (rev 1812) @@ -100,7 +100,7 @@ /** Get a pointer to the scripting system that created this IScript object. */ - virtual const IScriptingSystem* getCreator() const = 0; + //virtual const IScriptingSystem* getCreator() const = 0; virtual bool isLoaded() = 0; virtual void setData( const String & data ) = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-23 22:34:37
|
Revision: 1811 http://yake.svn.sourceforge.net/yake/?rev=1811&view=rev Author: psyclonist Date: 2007-08-23 15:34:37 -0700 (Thu, 23 Aug 2007) Log Message: ----------- * [res] added library 'resource management' * [bindings.lua] added bindings for yake.res (resource management) * [samples] added sample 'res/lua' demonstrating the use of Lua bindings for yake.res * [premake] fixed naming in config.h Modified Paths: -------------- trunk/yake/scripts/premake/config.lua trunk/yake/scripts/premake/samples.lua trunk/yake/scripts/premake/yake.lua trunk/yake/yake/bindings.lua/bindings.lua.h Added Paths: ----------- trunk/yake/common/media/scripts/res1.lua trunk/yake/samples/res/ trunk/yake/samples/res/lua1/ trunk/yake/samples/res/lua1/demo.cpp trunk/yake/src/bindings.lua/detail/res.lua.cpp trunk/yake/src/res/ trunk/yake/src/res/datastream.cpp trunk/yake/src/res/res.cpp trunk/yake/src/res/resource_manager.cpp trunk/yake/src/res/source.cpp trunk/yake/src/res/source_manager.cpp trunk/yake/yake/res/ trunk/yake/yake/res/async_loader.h trunk/yake/yake/res/datastream.h trunk/yake/yake/res/prerequisites.h trunk/yake/yake/res/res.h trunk/yake/yake/res/resource.h trunk/yake/yake/res/resource_manager.h trunk/yake/yake/res/source.h trunk/yake/yake/res/source_manager.h Added: trunk/yake/common/media/scripts/res1.lua =================================================================== --- trunk/yake/common/media/scripts/res1.lua (rev 0) +++ trunk/yake/common/media/scripts/res1.lua 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,17 @@ +-- acquire global res::SourceManager +assert( yake.res ) +local res = yake.res +assert( res.global.sourceManager ) +local sourceManager = res.global.sourceManager + +-- add some sources +sourceManager:addSource("file","./") +sourceManager:addSource("file","e:/dev/yake.trunk/yake/scripts/tools/luadocs/") + +-- find resource using sourceManager: +local find = sourceManager:find("project.txt") +if find.valid then + print("found project.txt at: "..find.location) +else + print("could not find project.txt") +end \ No newline at end of file Added: trunk/yake/samples/res/lua1/demo.cpp =================================================================== --- trunk/yake/samples/res/lua1/demo.cpp (rev 0) +++ trunk/yake/samples/res/lua1/demo.cpp 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,86 @@ +#include <yake/scripting/yakeScriptingSystem.h> +#include <yake/raf/yakeRaf.h> + +#include <yake/plugins/scriptingLua/ScriptingSystemLua.h> +#include <yake/bindings.lua/bindings.lua.h> +#include <yake/bindings.lua/common/yake.lua.common.h> + +using namespace yake; + +/** Configuration of the application */ +struct TheConfiguration : public raf::ApplicationConfiguration +{ + virtual StringVector getLibraries() + { return MakeStringVector() << YAKE_LIB("scriptingLua"); } + + virtual StringVector getScriptingSystems() + { return MakeStringVector() << "lua"; } +}; + +/** Main application state */ +class TheMainState : public raf::RtMainState +{ +public: + TheMainState(raf::Application& owner) : raf::RtMainState(owner), app_(owner) + { + } +protected: + virtual void onEnter() + { + raf::RtMainState::onEnter(); + } + virtual void onExit() + { + raf::RtMainState::onExit(); + vm_.reset(); + } + virtual void onCreateScene() + { + YAKE_LOG_INFORMATION("demo","Starting"); + + scripting::IScriptingSystem* sys = app_.getScriptingSystem(); + YAKE_ASSERT( sys ); + YAKE_ASSERT( !vm_ ); + vm_ = sys->createVM(); + bind_all(vm_.get()); + + //bind + { + /* + lua_State* L = static_cast<scripting::LuaVM*>(vm_.get())->getLuaState(); + luabind::globals(L)["app"] = &app_; + */ + } + + scripting::ScriptPtr script = sys->createScriptFromFile("../../../common/media/scripts/res1.lua"); + vm_->execute( script ); + + this->requestQuit(); + } + virtual void onFrame(const real timeElapsed) + { + } +private: + raf::Application& app_; + scripting::VMPtr vm_; +}; + +/** The mighty application itself! */ +class TheApp : public raf::ExampleApplication<TheConfiguration> +{ +public: + TheApp() {} +protected: + virtual raf::MainState* createMainState() + { + return new TheMainState(*this); + } +}; + +int main( int argc, char** argv ) +{ + // Use default executor for convenience. + // It's always possible to manually execute TheApp::initialise() etc. + return (raf::runApplication( TheApp() )) ? 0 : 1; +} + Modified: trunk/yake/scripts/premake/config.lua =================================================================== --- trunk/yake/scripts/premake/config.lua 2007-08-23 16:32:21 UTC (rev 1810) +++ trunk/yake/scripts/premake/config.lua 2007-08-23 22:34:37 UTC (rev 1811) @@ -57,7 +57,8 @@ ENABLE_LUA_GRAPHICS = true ENABLE_LUA_PHYSICS = true ENABLE_LUA_INPUT = true -ENABLE_LUA_RAF = true +ENABLE_LUA_RAF = true -- example application framework +ENABLE_LUA_RES = true -- resource management -------------------------------------- -- Samples Modified: trunk/yake/scripts/premake/samples.lua =================================================================== --- trunk/yake/scripts/premake/samples.lua 2007-08-23 16:32:21 UTC (rev 1810) +++ trunk/yake/scripts/premake/samples.lua 2007-08-23 22:34:37 UTC (rev 1811) @@ -90,6 +90,19 @@ end -------------------------------------- +--if SAMPLES_RES then + -------------------------------------- + if ENABLE_LUA_RES then + makeSample("sampleResLuaDemo1","samples/res/lua1") + useComponent("base") + useComponent("res") + useComponent("bindings.lua") + useDep("lua") + useDep("luabind") + end +--end + +-------------------------------------- if SAMPLES_RAF then -------------------------------------- makeSample("sampleRafMinimal","samples/raf/minimal") Modified: trunk/yake/scripts/premake/yake.lua =================================================================== --- trunk/yake/scripts/premake/yake.lua 2007-08-23 16:32:21 UTC (rev 1810) +++ trunk/yake/scripts/premake/yake.lua 2007-08-23 22:34:37 UTC (rev 1811) @@ -75,8 +75,9 @@ f:write("#define YAKE_ENABLE_LUA_PROPERTY " .. bool_to_int(ENABLE_LUA_PROPERTY) .. "\n") f:write("#define YAKE_ENABLE_LUA_GRAPHICS " .. bool_to_int(ENABLE_LUA_GRAPHICS) .. "\n") f:write("#define YAKE_ENABLE_LUA_PHYSICS " .. bool_to_int(ENABLE_LUA_PHYSICS) .. "\n") - f:write("#define ENABLE_LUA_INPUT " .. bool_to_int(ENABLE_LUA_INPUT) .. "\n") + f:write("#define YAKE_ENABLE_LUA_INPUT " .. bool_to_int(ENABLE_LUA_INPUT) .. "\n") f:write("#define YAKE_ENABLE_LUA_RAF " .. bool_to_int(ENABLE_LUA_RAF) .. "\n") + f:write("#define YAKE_ENABLE_LUA_RES " .. bool_to_int(ENABLE_LUA_RES) .. "\n") f:write("\n") f:write("#endif\n") io.close(f) @@ -161,6 +162,10 @@ addDependency("model") -------------------------------------- +makeComponent("res","YAKE_RES_EXPORTS") +addDependency("base") + +-------------------------------------- -- net2 is a header-only library -- For MSVC8: Create project. -- For Linux/GCC: Do not create project. @@ -258,6 +263,9 @@ if ENABLE_LUA_RAF then addDependency("raf") end + if ENABLE_LUA_RES then + addDependency("res") + end if (windows) then --@todo still required? or does this get picked up automatically already? useDep("lua") useDep("luabind") Added: trunk/yake/src/bindings.lua/detail/res.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/detail/res.lua.cpp (rev 0) +++ trunk/yake/src/bindings.lua/detail/res.lua.cpp 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,133 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#include <yake/config.h> +#if YAKE_ENABLE_LUA_RES == 1 + +// See task.lua.cpp +#include <yake/bindings.lua/common/yake.lua.shared_ptr.h> + +#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport! + +#include <yake/base/templates/yakeSmartAssert.h> +#include <yake/base/yake.h> +#include <yake/res/res.h> + +#include <yake/bindings.lua/detail/private.h> +#include <yake/bindings.lua/common/yake.lua.any_converter.h> + +#include <luabind/discard_result_policy.hpp> +#include <luabind/iterator_policy.hpp> +#include <luabind/operator.hpp> +#include <luabind/adopt_policy.hpp> + +namespace yake { +namespace res { + + void bind( lua_State* L ) + { + YAKE_ASSERT( L ); + if (!L) + return; + + using namespace luabind; + +#define YAKE_RES_MODULE L, "yake" + + module( YAKE_RES_MODULE ) + [ + namespace_("res") + [ + class_<DataStreamBase,DataStreamPtr>("DataStreamBase") + , + class_<ResourceBase,ResourcePtr>("ResourceBase") + , + class_<SourceId>("SourceId") + , + class_<Location>("Location") + , + class_<Source,SourcePtr>("Source") + .def("open",&Source::open) + .def("exists",&Source::exists) + , + class_<SourceFactory>("SourceFactory") + .def("create",&SourceFactory::create) + .scope + [ + def("global",&SourceFactory::global) + ] + , + class_<FindResult>("FindResult") + .def(constructor<>()) + .property("location",&FindResult::location) + .property("source",&FindResult::source) + .property("valid",&FindResult::isValid) + , + class_<SourceManager>("SourceManager") + .def(constructor<>()) + .def("addSource", (void(SourceManager::*)(SourcePtr,const Location&))&SourceManager::addSource) + .def("addSource", (void(SourceManager::*)(const SourceId&,const SourceFactory&,const Location&))&SourceManager::addSource) + .def("addSource", (void(SourceManager::*)(const SourceId&,const Location&))&SourceManager::addSource) + .def("find", &SourceManager::find) + .def("open", (DataStreamPtr(SourceManager::*)(const Location&))&SourceManager::open) + .def("open", (DataStreamPtr(SourceManager::*)(const FindResult&))&SourceManager::open) + .scope + [ + def("global",&SourceFactory::global) + ] + , + class_<ResourceManagerBase>("ResourceManagerBase") + .def("find", &ResourceManagerBase::find) + .def("attach", &ResourceManagerBase::attach) + .def("detach", &ResourceManagerBase::detach, discard_result) + .def("create", (ResourcePtr(ResourceManagerBase::*)(const FindResult&))&ResourceManagerBase::create) + .def("create", (ResourcePtr(ResourceManagerBase::*)(const Location&))&ResourceManagerBase::create) + ] + ]; + { + luabind::object tblGlobal = luabind::newtable(L); + tblGlobal["sourceManager"] = &SourceManager::global(); + tblGlobal["sourceFactory"] = &SourceFactory::global(); + luabind::globals(L)["yake"]["res"]["global"] = tblGlobal; + } + } + + YAKE_WRAP_BINDER(res,::yake::res::bind); + +} // namespace input + void bind_res(lua_State* L) + { + YAKE_ASSERT(L); + res::bind(L); + } + void bind_res(scripting::IVM* vm) + { + scripting::LuaVM* luavm = static_cast<scripting::LuaVM*>(vm); + YAKE_ASSERT( luavm ); + bind_res(luavm->getLuaState()); + } +} // namespace yake +#endif // YAKE_ENABLE_LUA_RES Added: trunk/yake/src/res/datastream.cpp =================================================================== --- trunk/yake/src/res/datastream.cpp (rev 0) +++ trunk/yake/src/res/datastream.cpp 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,74 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#include "yake/base/templates/yakeSmartAssert.h" +#include "yake/res/datastream.h" + +#include <fstream> +#include <sys/stat.h> + +namespace yake { +namespace res { + + DataStreamBase::~DataStreamBase() {} + + + FileDataStream::FileDataStream(const std::string & fn) : in_(fn.c_str()), size_(0) + { + assert( in_.is_open() ); + + struct _stat32 s; + const int code = _stat32(fn.c_str(), &s); + assert(code == 0); + size_ = s.st_size; + } + size_t FileDataStream::read(void * out, size_t size) + { + assert( in_.is_open() ); + assert( !eof() ); + if (eof()) + return 0; + // NB use readsome() for async + std::streampos pre = in_.tellg(); + in_.read((char*)(out),std::streampos(size)); //@todo use boost safe numeric cast + return size_t(in_.tellg() - pre); + } + bool FileDataStream::eof() const + { + return in_.is_open() ? in_.eof() : false; + } + size_t FileDataStream::size() const + { + return size_; + } + void FileDataStream::close() + { + if (!in_.is_open()) + in_.close(); + } + +} // namespace res +} // namespace yake Added: trunk/yake/src/res/res.cpp =================================================================== --- trunk/yake/src/res/res.cpp (rev 0) +++ trunk/yake/src/res/res.cpp 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,36 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#include "yake/base/templates/yakeSmartAssert.h" +#include "yake/res/res.h" + +namespace yake { +namespace res { + + ResourceBase::~ResourceBase() {} + +} // namespace res +} // namespace yake Added: trunk/yake/src/res/resource_manager.cpp =================================================================== --- trunk/yake/src/res/resource_manager.cpp (rev 0) +++ trunk/yake/src/res/resource_manager.cpp 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,80 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#include "yake/base/templates/yakeSmartAssert.h" +#include "yake/res/resource_manager.h" + +namespace yake { +namespace res { + + //----------------------------------------------------- + + ResourceManagerBase::~ResourceManagerBase() {} + + ResourcePtr ResourceManagerBase::create(const FindResult& what) + { + if (!sourceMgr()) + return ResourcePtr(); + DataStreamPtr data = sourceMgr()->open( what ); + if (!data) + return ResourcePtr(); + return this->createAndInitResource( *data ); + } + ResourcePtr ResourceManagerBase::create(const Location& loc) + { + if (!sourceMgr()) + return ResourcePtr(); + DataStreamPtr data = sourceMgr()->open( loc ); + if (!data) + return ResourcePtr(); + return this->createAndInitResource( *data ); + } + FindResult ResourceManagerBase::find(const Location& loc) const + { + if (!sourceMgr_) + return FindResult(); + return sourceMgr_->find(loc); + } + void ResourceManagerBase::attach(SourceManager* mgr) + { + sourceMgr_ = mgr; + } + SourceManager* ResourceManagerBase::detach() + { + SourceManager* mgr = sourceMgr_; + sourceMgr_ = 0; + return mgr; + } + ResourceManagerBase::ResourceManagerBase() : sourceMgr_(&SourceManager::global()) + { + } + SourceManager* ResourceManagerBase::sourceMgr() + { + return sourceMgr_; + } + +} // namespace res +} // namespace yake Added: trunk/yake/src/res/source.cpp =================================================================== --- trunk/yake/src/res/source.cpp (rev 0) +++ trunk/yake/src/res/source.cpp 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,83 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#include "yake/base/templates/yakeSmartAssert.h" +#include "yake/res/source.h" + +#include <sys/stat.h> + +namespace yake { +namespace res { + + Source::~Source() {} + + //----------------------------------------------------- + + DataStreamPtr FileSource::open(const res::Location &loc) + { + if (exists(loc)) + return DataStreamPtr(new FileDataStream(loc)); + return DataStreamPtr(); + } + bool FileSource::exists(const Location& loc) const + { + struct _stat32 s; + const int code = _stat32(loc.c_str(), &s); + return (code == 0); + } + + //----------------------------------------------------- + + void SourceFactory::reg(const SourceId& id, CreateSourceFn creator) + { + assert( !id.empty() ); + if (id.empty()) + throw InvalidInputException("id is empty/null"); + assert( creator ); + if (!creator) + throw InvalidInputException("creator function is null"); + creators_[ id ] = creator; + } + SourcePtr SourceFactory::create(const SourceId& id) const + { + CreatorMap::const_iterator it = creators_.find(id); + //assert( it != creators_.end() ); + if (it == creators_.end()) + { + //return SourcePtr(); + throw UnknownResourceSourceTypeException(id); + } + assert( it->second ); + return SourcePtr(it->second()); + } + SourceFactory& SourceFactory::global() + { + static SourceFactory s_sourceFactory; + return s_sourceFactory; + } + +} // namespace res +} // namespace yake Added: trunk/yake/src/res/source_manager.cpp =================================================================== --- trunk/yake/src/res/source_manager.cpp (rev 0) +++ trunk/yake/src/res/source_manager.cpp 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,101 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#include "yake/base/templates/yakeSmartAssert.h" +#include "yake/res/source_manager.h" + +namespace yake { +namespace res { + + //----------------------------------------------------- + + SourceManager::SourceManager() + { + } + void SourceManager::addSource(SourcePtr source, const Location& locBase) + { + sources_[ locBase ] = source; + } + void SourceManager::addSource(const SourceId& id, const SourceFactory& factory, const Location& locBase) + { + SourcePtr source = factory.create( id ); + assert( source ); + addSource( source, locBase ); + } + void SourceManager::addSource(const SourceId& id, const Location& locBase) + { + addSource( id, SourceFactory::global(), locBase ); + } + FindResult SourceManager::find(const Location& loc) const + { + for (SourceMap::const_iterator it = sources_.begin(); it != sources_.end(); ++it) + { + const Location& locBase = it->first; + SourcePtr src = it->second; + const Location locToTest = locBase + loc; + if (src->exists(locToTest)) + { + assert( it->second ); + return FindResult( locToTest, src ); + } + } + return FindResult(); + } + DataStreamPtr SourceManager::open(const FindResult& what) + { + assert( what.isValid() ); + if (!what.isValid()) + return DataStreamPtr(); + assert( what.source_ != 0 ); + assert( !what.location_.empty() ); + DataStreamPtr stream = what.source_->open( what.location_ ); + assert( stream && "failed to open data stream" ); + return stream; + } + DataStreamPtr SourceManager::open(const Location& loc) + { + for (SourceMap::const_iterator it = sources_.begin(); it != sources_.end(); ++it) + { + const Location& locBase = it->first; + SourcePtr src = it->second; + const Location locToTest = locBase + loc; + if (src->exists(locToTest)) + { + assert( it->second ); + DataStreamPtr stream = it->second->open(locToTest); + return stream; + } + } + return DataStreamPtr(); + } + SourceManager& SourceManager::global() + { + static SourceManager s_sourceMgr; + return s_sourceMgr; + } + +} // namespace res +} // namespace yake Modified: trunk/yake/yake/bindings.lua/bindings.lua.h =================================================================== --- trunk/yake/yake/bindings.lua/bindings.lua.h 2007-08-23 16:32:21 UTC (rev 1810) +++ trunk/yake/yake/bindings.lua/bindings.lua.h 2007-08-23 22:34:37 UTC (rev 1811) @@ -72,6 +72,10 @@ YAKE_BINDINGS_LUA_API void bind_raf(lua_State*); YAKE_BINDINGS_LUA_API void bind_raf(scripting::IVM*); #endif +#if YAKE_ENABLE_LUA_RES == 1 + YAKE_BINDINGS_LUA_API void bind_res(lua_State*); + YAKE_BINDINGS_LUA_API void bind_res(scripting::IVM*); +#endif } // namespace yake #endif Added: trunk/yake/yake/res/async_loader.h =================================================================== --- trunk/yake/yake/res/async_loader.h (rev 0) +++ trunk/yake/yake/res/async_loader.h 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,60 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#ifndef YAKE_RES_ASYNCLOADER_H +#define YAKE_RES_ASYNCLOADER_H + +#include "prerequisites.h" +#include "source.h" + +namespace yake { +namespace res { + + typedef int TicketId; + struct AsyncLoaderManager : public noncopyable //@todo move into "detail"? + { + typedef boost::function<void(const Location&,DataStreamPtr)> HandlerFn; + + template<typename Handler> + TicketId async_open(Location loc, Handler handler) + { + io_.post( boost::bind(&AsyncLoaderManager::onOpen,loc,handler) ) + } + private: + void onOpen(const Location& loc, const HandlerFn& handler) + { + DataStreamPtr stream; // = ? + if (handler) + handler(loc,stream); + } + private: + boost::asio::io_service io_; + }; + +} // namespace res +} // namespace yake + +#endif Added: trunk/yake/yake/res/datastream.h =================================================================== --- trunk/yake/yake/res/datastream.h (rev 0) +++ trunk/yake/yake/res/datastream.h 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,70 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#ifndef YAKE_RES_DATASTREAM_H +#define YAKE_RES_DATASTREAM_H + +#include "prerequisites.h" +#include <fstream> +#include <boost/shared_ptr.hpp> + +namespace yake { +namespace res { + + /** Basic interface for data streams. + */ + struct YAKE_RES_API DataStreamBase : public noncopyable + { + virtual ~DataStreamBase() = 0; + + virtual size_t read(void*,size_t) = 0; + virtual bool eof() const = 0; + //virtual size_t tell() const = 0; + //virtual void skip(const size_t) = 0; + virtual size_t size() const = 0; + virtual void close() = 0; + }; + typedef boost::shared_ptr<DataStreamBase> DataStreamPtr; + + /** Implements the data stream interface for files. + */ + struct YAKE_RES_API FileDataStream : public DataStreamBase + { + FileDataStream(const std::string&); + + virtual size_t read(void*,size_t); + virtual bool eof() const; + virtual size_t size() const; + virtual void close(); + private: + std::ifstream in_; + size_t size_; //@todo fails if file is modified during read! + }; + +} // namespace res +} // namespace yake + +#endif Added: trunk/yake/yake/res/prerequisites.h =================================================================== --- trunk/yake/yake/res/prerequisites.h (rev 0) +++ trunk/yake/yake/res/prerequisites.h 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,48 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#ifndef YAKE_RES_PREREQUISITES_H +#define YAKE_RES_PREREQUISITES_H + +#include <yake/config.h> +#include <yake/base/yakePrerequisites.h> +#include <yake/base/yakeException.h> +#include <yake/base/yakeNoncopyable.h> + +#if defined(YAKE_RES_EXPORTS) +# define YAKE_RES_API YAKE_EXPORT_API +#else +# define YAKE_RES_API YAKE_IMPORT_API +#endif + +namespace yake { + YAKE_DEFINE_EXCEPTION(UnknownResourceSourceTypeException); +namespace res { + +} // namespace res +} // namespace yake + +#endif Added: trunk/yake/yake/res/res.h =================================================================== --- trunk/yake/yake/res/res.h (rev 0) +++ trunk/yake/yake/res/res.h 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,43 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#ifndef YAKE_RES_H +#define YAKE_RES_H + +#include "prerequisites.h" +#include "datastream.h" +#include "resource.h" +#include "source.h" +#include "source_manager.h" +#include "resource_manager.h" + +namespace yake { +namespace res { + +} // namespace res +} // namespace yake + +#endif Added: trunk/yake/yake/res/resource.h =================================================================== --- trunk/yake/yake/res/resource.h (rev 0) +++ trunk/yake/yake/res/resource.h 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,57 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#ifndef YAKE_RES_RESOURCE_H +#define YAKE_RES_RESOURCE_H + +#include "prerequisites.h" +#include <boost/shared_ptr.hpp> + +namespace yake { +namespace res { + + /** Base class for resource. */ + struct YAKE_RES_API ResourceBase : public noncopyable + { + virtual ~ResourceBase() = 0; + + typedef boost::shared_ptr<ResourceBase> pointer; + }; + typedef ResourceBase::pointer ResourcePtr; + + /** Optional intermediate class for user-defined resource types. + It provides information in a common way. + */ + template<typename T> + struct Resource : public ResourceBase + { + typedef T resource_type; + }; + +} // namespace res +} // namespace yake + +#endif Added: trunk/yake/yake/res/resource_manager.h =================================================================== --- trunk/yake/yake/res/resource_manager.h (rev 0) +++ trunk/yake/yake/res/resource_manager.h 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,86 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#ifndef YAKE_RES_RESOURCEMANAGER_H +#define YAKE_RES_RESOURCEMANAGER_H + +#include "prerequisites.h" +#include "source_manager.h" +#include "resource.h" + +namespace yake { +namespace res { + + /** Base class for resource managers. + This base class handles most of the dirty work (like + finding files/locations, opening data streams etc) + and provides a hook for derived classes to create + and initialize custom resources from data streams. + Derived classes have to override createAndInitResource(). + + For finding sources any instance of a ResourceManager + by default uses the global SourceManager. + A custom SourceManager can be specified + with attach(). + */ + struct YAKE_RES_API ResourceManagerBase : public noncopyable + { + virtual ~ResourceManagerBase() = 0; + + //virtual TicketId async_create(const Location&) = 0; + ResourcePtr create(const FindResult& what); + ResourcePtr create(const Location& loc); + FindResult find(const Location& loc) const; + void attach(SourceManager* mgr); + SourceManager* detach(); + private: + virtual ResourcePtr createAndInitResource(DataStreamBase& data) = 0; + protected: + ResourceManagerBase(); + SourceManager* sourceMgr(); + private: + SourceManager* sourceMgr_; + }; + + template<typename T> + struct ResourceManager : public ResourceManagerBase + { + typedef boost::shared_ptr<T> res_pointer; + public: + res_pointer create(const Location& loc) + { + return boost::static_pointer_cast<T>( ResourceManagerBase::create(loc) ); + } + res_pointer create(const FindResult& loc) + { + return boost::static_pointer_cast<T>( ResourceManagerBase::create(loc) ); + } + }; + +} // namespace res +} // namespace yake + +#endif Added: trunk/yake/yake/res/source.h =================================================================== --- trunk/yake/yake/res/source.h (rev 0) +++ trunk/yake/yake/res/source.h 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,111 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#ifndef YAKE_RES_SOURCE_H +#define YAKE_RES_SOURCE_H + +#include "prerequisites.h" +#include "datastream.h" +#include <deque> +#include <boost/shared_ptr.hpp> +#include <boost/function.hpp> + +namespace yake { +namespace res { + + /** ID of a ResourceSource in a ResourceFactory. + Such IDs are unique only within a given ResourceFactory. + */ + typedef std::string SourceId; + + /** Represents a location of a resource. + The string can be anything that ResourceSource's can handle. + */ + typedef std::string Location; + typedef std::deque<Location> LocationList; + + /** Interface for resource sources for querying information + on possible locations and opening data streams. + */ + struct YAKE_RES_API Source : public noncopyable + { + virtual ~Source() = 0; + virtual DataStreamPtr open(const Location&) = 0; + virtual bool exists(const Location&) const = 0; + //virtual LocationList list(/*const bool recursive = false*/) = 0; + }; + typedef boost::shared_ptr<Source> SourcePtr; + + /** Implements a resource source for files using the OS's file system + functionality (mostly through C++ streams). + */ + struct YAKE_RES_API FileSource : public Source + { + virtual DataStreamPtr open(const Location& loc); + virtual bool exists(const Location&) const; + + static Source* create() + { return new FileSource(); } + }; + + /** Implements a factory for ResourceSources. + Any number of factories can be created, but + to ease use in applications a single global + SourceFactory can be accessed through + SourceFactory::global(). + + @see Source + */ + struct YAKE_RES_API SourceFactory : public noncopyable + { + typedef boost::function<Source*()> CreateSourceFn; + + // @exception InvalidParameterException + void reg(const SourceId& id, CreateSourceFn creator); + + // @exception InvalidParameterException + template<typename T> + void reg(const SourceId& id) + { + assert( !id.empty() ); + if (id.empty()) + throw InvalidParameterException("id is empty/null"); + creators_[ id ] = boost::bind(&T::create); + } + + // @exception UnknownSourceTypeException + SourcePtr create(const SourceId& id) const; + // Helper: + static SourceFactory& global(); + private: + typedef std::map<SourceId,CreateSourceFn> CreatorMap; + CreatorMap creators_; + }; + +} // namespace res +} // namespace yake + +#endif Added: trunk/yake/yake/res/source_manager.h =================================================================== --- trunk/yake/yake/res/source_manager.h (rev 0) +++ trunk/yake/yake/res/source_manager.h 2007-08-23 22:34:37 UTC (rev 1811) @@ -0,0 +1,113 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#ifndef YAKE_RES_SOURCEMANAGER_H +#define YAKE_RES_SOURCEMANAGER_H + +#include "prerequisites.h" +#include "source.h" + +namespace yake { +namespace res { + + struct SourceManager; + struct ResourceManagerBase; + /** Contains information about the result of a 'find resource location' + operation. + @code + // Using a SourceManager: + FindResult findinfo = sourceMgr.find("myfile.txt"); + if (findinfo) + DataStreamPtr data = sourceMgr.open(findinfo); + @codeend + @code + // Using a ResourceManager: + FindResult findinfo = resourceMgr.find("myfile.txt"); + if (findinfo) + ResourcePtr res = resourceMgr.create(findinfo); + @codeend + */ + struct FindResult + { + friend struct SourceManager; + friend struct ResourceManagerBase; + private: + Location location_; + SourcePtr source_; //@todo use weak ptr? + public: + bool isValid() const + { + return (source_ != 0 && !location_.empty()); + } + operator bool() const + { + return isValid(); + } + FindResult() + { + } + const Location& location() const + { + return location_; + } + SourcePtr source() const + { + return source_; + } + private: + FindResult(const Location& loc, SourcePtr src) : location_(loc), source_(src) + { + } + }; + + /** Manages resource sources by Location base and SourceId and provides + functionality to search for 'locations/files' and open data streams. + + While it's possible to create any number of SourceManagers, + for simple uses there's also a global instance available through + SourceManager::global(). + */ + struct YAKE_RES_API SourceManager : public noncopyable + { + SourceManager(); + void addSource(SourcePtr source, const Location& locBase); + // @exception see SourceFactory::create() + void addSource(const SourceId& id, const SourceFactory& factory, const Location& locBase); + void addSource(const SourceId& id, const Location& locBase); + FindResult find(const Location& loc) const; + DataStreamPtr open(const FindResult& what); + DataStreamPtr open(const Location& loc); + // Helper: + static SourceManager& global(); + private: + typedef std::map<Location,SourcePtr> SourceMap; + SourceMap sources_; + }; + +} // namespace res +} // namespace yake + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-23 16:32:19
|
Revision: 1810 http://yake.svn.sourceforge.net/yake/?rev=1810&view=rev Author: psyclonist Date: 2007-08-23 09:32:21 -0700 (Thu, 23 Aug 2007) Log Message: ----------- * [ludocs] updated docs Modified Paths: -------------- tools/luadocs/project.html tools/luadocs/project.txt Modified: tools/luadocs/project.html =================================================================== --- tools/luadocs/project.html 2007-08-22 22:52:24 UTC (rev 1809) +++ tools/luadocs/project.html 2007-08-23 16:32:21 UTC (rev 1810) @@ -90,22 +90,41 @@ </div> <div class="section" id="color"> <h3><a class="toc-backref" href="#id16">Color</a></h3> +<p><strong>Code</strong></p> +<blockquote> +<p>Valid constructors::</p> +<pre class="literal-block"> +c = Color() -- all components set to zero (0) +c = Color(.5,.5,.5) -- middle gray +c = Color(0,0,0) -- opaque black, same as Color(0,0,0,1) +c = Color(1,0,0,.5) -- half-translucent black +</pre> +</blockquote> +<p><strong>Properties</strong></p> +<blockquote> +<ul class="simple"> +<li><strong>a</strong> of type <strong>real</strong></li> +<li><strong>b</strong> of type <strong>real</strong></li> +<li><strong>g</strong> of type <strong>real</strong></li> +<li><strong>r</strong> of type <strong>real</strong></li> +</ul> +</blockquote> <p><strong>Constructors</strong></p> <blockquote> <ul> <li><p class="first"><strong>Color(r,g,b)</strong></p> <blockquote> -<p><strong>r</strong> of type <strong>real</strong></p> -<p><strong>g</strong> of type <strong>real</strong></p> -<p><strong>b</strong> of type <strong>real</strong></p> +<p><strong>r</strong> of type <strong>real</strong> - red</p> +<p><strong>g</strong> of type <strong>real</strong> - green</p> +<p><strong>b</strong> of type <strong>real</strong> - blue</p> </blockquote> </li> <li><p class="first"><strong>Color(r,g,b,a)</strong></p> <blockquote> -<p><strong>r</strong> of type <strong>real</strong></p> -<p><strong>g</strong> of type <strong>real</strong></p> -<p><strong>b</strong> of type <strong>real</strong></p> -<p><strong>a</strong> of type <strong>real</strong></p> +<p><strong>r</strong> of type <strong>real</strong> - red</p> +<p><strong>g</strong> of type <strong>real</strong> - green</p> +<p><strong>b</strong> of type <strong>real</strong> - blue</p> +<p><strong>a</strong> of type <strong>real</strong> - alpha (opacity)</p> </blockquote> </li> <li><p class="first"><strong>Color()</strong></p> Modified: tools/luadocs/project.txt =================================================================== --- tools/luadocs/project.txt 2007-08-22 22:52:24 UTC (rev 1809) +++ tools/luadocs/project.txt 2007-08-23 16:32:21 UTC (rev 1810) @@ -4,16 +4,27 @@ @namespace base @class Color + + @code Valid constructors: + c = Color() -- all components set to zero (0) + c = Color(.5,.5,.5) -- middle gray + c = Color(0,0,0) -- opaque black, same as Color(0,0,0,1) + c = Color(1,0,0,.5) -- half-translucent black + @codeend @constructor Color() @constructor Color(r,g,b) - @param r (real) - @param g (real) - @param b (real) + @param r (real) red + @param g (real) green + @param b (real) blue @constructor Color(r,g,b,a) - @param r (real) - @param g (real) - @param b (real) - @param a (real) + @param r (real) red + @param g (real) green + @param b (real) blue + @param a (real) alpha (opacity) + @property r (real) - [0..1] + @property g (real) + @property b (real) + @property a (real) @end -- Color @class Math This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-22 22:52:28
|
Revision: 1809 http://yake.svn.sourceforge.net/yake/?rev=1809&view=rev Author: psyclonist Date: 2007-08-22 15:52:24 -0700 (Wed, 22 Aug 2007) Log Message: ----------- * [luadocs] updated tools and documentation Modified Paths: -------------- tools/luadocs/lua_bindings.css tools/luadocs/lua_bindings_2_rst.cmd tools/luadocs/lua_bindings_2_rst.lua tools/luadocs/project.txt Added Paths: ----------- tools/luadocs/project.html Modified: tools/luadocs/lua_bindings.css =================================================================== --- tools/luadocs/lua_bindings.css 2007-08-22 19:42:51 UTC (rev 1808) +++ tools/luadocs/lua_bindings.css 2007-08-22 22:52:24 UTC (rev 1809) @@ -1,6 +1,7 @@ body { font-family:Tahoma, Verdana, Arial; + font-size:medium; } a { @@ -29,26 +30,39 @@ p,li { margin-left: 5%; + margin-top: 0%; + margin-bottom: .5em; + /*border: 1px solid red;*/ } h1 { font-family: Georgia "Times New Roman", serif; color: #004090; border-bottom: 3px solid; + font-size: medium; + margin-right: 5%; + margin-right: 0; } h2 { font-family: Georgia "Times New Roman", serif; color: #004090; border-bottom: 3px solid; + font-size: medium; + margin-left: 2.5%; } +h3,h4,h5 +{ + font-size: medium; + margin-left: 3.5%; + margin-right: 5%; +} div h4.title /* 3rd level */ { margin-left: 2.5%; } div.author h3.author { - font-size: medium; } hr { @@ -65,11 +79,15 @@ border-top: 1px solid #707070; border-bottom: 1px solid #707070; background-color: #ffffd5; - margin-left: 7.5%; - margin-right: 5%; + margin-left: 5%; padding: 6px; color: #000000; + margin-right: 5%; } +li blockquote pre.literal-block +{ + margin-left: 0%; +} .tip,.note { @@ -131,6 +149,30 @@ font-family:Courier New,Courier,Verdana; } +div.section +{ + font-size: medium; + margin-right: 5%; + /*border: 1px solid green;*/ +} +div.section div +{ + margin-right: 0%; +} + +div.section p +{ + font-size: small; +} +div.section p strong +{ + font-size: small; +} +div.section blockquote +{ + font-size: small; +} + /** "Table of contents" */ div.toc { @@ -140,6 +182,10 @@ { margin-left:0%; } +div.section div +{ + font-size: small; +} /** Ordered lists */ div.orderedlist ol li p @@ -156,6 +202,33 @@ margin-left: 2.5%; /** Reduce intendation from 5% */ } +div.section ul +{ + margin: 0%; +} +div.section blockquote ul li +{ + margin-left: 2.5%; + margin-bottom: 0.25%; + margin-top: 0%; + margin-right: 0%; +} +div.section blockquote ul li p +{ + margin: 0; +} +div.section blockquote ul li blockquote +{ + margin-left: 2.5%; + margin-bottom: 0.25%; + margin-top: 0%; + margin-right: 0%; +} +div.section ol p +{ + margin: 0%; +} + /** "List of tables" (right below "Table of contents") */ div.list-of-tables { @@ -174,15 +247,36 @@ width: 80%; margin-left:5%; margin-right:5%; + color:gray; } -blockquote p +div.section p { color:gray; + margin-bottom: 0.25%; + /*border: 1px solid blue;*/ } -blockquote p strong +div.section blockquote { - color:Orange; + margin-top: 0; + margin-right: 0%; } +div.section blockquote p +{ + color:gray; + margin-bottom: 0.5%; + margin-right: 0%; + /*border: 1px solid blue;*/ +} +div.section blockquote p strong +{ + color: gray; + /*color:Orange;*/ +} +div.section blockquote pre.literal-block +{ + margin-right: 0%; +} + .literal { background-color: #ffffd5; /* light yellow background */ Modified: tools/luadocs/lua_bindings_2_rst.cmd =================================================================== --- tools/luadocs/lua_bindings_2_rst.cmd 2007-08-22 19:42:51 UTC (rev 1808) +++ tools/luadocs/lua_bindings_2_rst.cmd 2007-08-22 22:52:24 UTC (rev 1809) @@ -1,5 +1,5 @@ @echo off d:\tools\luabin\lua5.1 lua_bindings_2_rst.lua -d:\tools\doc\docutils\tools\rst2html.py --link-stylesheet --stylesheet-path lua_bindings.css project.rst.txt project.html +d:\doc\docutils\tools\rst2html.py --link-stylesheet --stylesheet-path lua_bindings.css project.rst.txt project.html pause Modified: tools/luadocs/lua_bindings_2_rst.lua =================================================================== --- tools/luadocs/lua_bindings_2_rst.lua 2007-08-22 19:42:51 UTC (rev 1808) +++ tools/luadocs/lua_bindings_2_rst.lua 2007-08-22 22:52:24 UTC (rev 1809) @@ -29,6 +29,7 @@ parent.scopes[id].scopes = {} parent.scopes[id].properties = {} parent.scopes[id].functions = {} + parent.scopes[id].constants = {} parent.scopes[id].codes = {} db.currScope = parent.scopes[id] @@ -66,26 +67,55 @@ assert(type) db.getCurrClass().properties[name] = type end -db.newFunction = function(name,paramNames) +db.newConstant = function(name,type,value) + assert(db.getCurrClass()) assert(name) + assert(type) + db.getCurrClass().constants[name] = {} + db.getCurrClass().constants[name].type = type + db.getCurrClass().constants[name].value = value +end +db.newFunction = function(name,paramNames,tag) + assert(name) assert(db.getCurrClass()) local scope = db.getCurrClass() - scope.functions[name] = {} - local fn = scope.functions[name] - fn.params = {} - fn.returnType = nil - fn.codes = {} -- signature (only parameters, at the moment: "a,b,c") - fn.signature = name.."(" + local signature = name.."(" local params = "" for _,v in pairs(paramNames) do if string.len(params) > 0 then params = params .. "," end params = params .. v + end + signature = signature .. params ..")" + + -- + if not scope.functions[name] then + scope.functions[name] = {} + scope.functions[name].overloads = {} + end + local fnBase = scope.functions[name] + --print("SIG",signature) + + local uniqueSignature = signature + while fnBase.overloads[uniqueSignature] do + uniqueSignature = uniqueSignature .. "_" + end + assert( not fnBase.overloads[uniqueSignature] ) + fnBase.overloads[uniqueSignature] = {} + + local fn = fnBase.overloads[uniqueSignature] + fn.params = {} + fn.returns = {} + fn.codes = {} + fn.signature = signature + fn.tag = tag + + for _,v in pairs(paramNames) do local paramEntry = { name = v } table.insert(fn.params,paramEntry) end - fn.signature = fn.signature .. params ..")" + db.currentFn = fn end db.findParam = function(fn,param) @@ -98,18 +128,26 @@ end return nil end - +db.newFunctionReturnInfo = function(types,desc) + local fn = db.currentFn + assert(fn) + table.insert( fn.returns, {} ) + local idx = getn(fn.returns) + fn.returns[ idx ].types = types + fn.returns[ idx ].desc = desc +end db.setFunctionParamInfo = function(paramName,paramType,paramDesc) local fn = db.currentFn assert(fn) local p = db.findParam(fn,paramName) if not p then print("ERROR: Parameter '"..paramName.."' not found in signature: " .. fn.signature) - return + return false end local p = db.findParam(fn,paramName) p.type = paramType p.desc = paramDesc + return true end db.getCurrClass = function() return db.currScope @@ -128,12 +166,14 @@ assert(db.currCodeScope) assert(line) - --print("newCodeLine '" .. db.currCode .. "': '" .. line .. "'") + print("newCodeLine '" .. db.currCode .. "': '" .. line .. "'") assert(db.currCodeScope) assert(db.currCodeScope[db.currCode]) - db.currCodeScope[db.currCode] = db.currCodeScope[db.currCode] .. line + db.currCodeScope[db.currCode] = db.currCodeScope[db.currCode] .. line .. "\n" + + return db.newCodeLine,"codeend" end db.endCode = function() db.currCode = nil @@ -142,9 +182,10 @@ jump = {} jump["class"] = function(line) - local from,to = string.find(line,"%a+",1) + local from,to = string.find(line,"%w+",1) if from and to then local name = string.sub(line,from,to) + print("CLASS",name) db.newClass(name) end end @@ -175,38 +216,95 @@ end jump["param"] = function(line) - local name = string.gmatch(line,"[%w]+") + local name = string.gmatch(line,"([%a%d]+)[%s]*%(") assert(name) if name then name = name() + if not name then + print("ERROR: Missing parameter name for @param command!") + print(line) + assert(false) + return + end end local type = string.gmatch(line,"[%w]*%(([%w]+)%)") - if type then - type = type() + type = type() + + local desc = string.gmatch(line,"[%w]*%([%w]+%)[%s]*([%w%p%s]*)") + desc = desc() + + if db.setFunctionParamInfo(name,type,desc) == false then + print(line,name,type) end - db.setFunctionParamInfo(name,type,"") end +jump["return"] = function(line) + local typeMatch = string.gmatch(line,"%(([%w+]+)%)") + local types = {} + while typeMatch do + local type = typeMatch() + if not type or string.len(type) == 0 then + break + end + print("RETURN VALUE",type) + table.insert(types,type) + end + + local desc = string.gmatch(line,"%([%w%p*]*%)[%s]*([%w%s%p]*)") + desc = desc() + print("RETURN DESC",desc) + + db.newFunctionReturnInfo(types,desc) +end jump["function"] = function(line) local sig = line --@todo trim assert(sig) - local patParamsOnly = "%([%w%p]+%)" - local patExtractParams = "%(([%w%p]+)%)" -- same as patParamsOnly but with captures to capture only the content between the braces - local patFunctionname = "[%w%p^,+]+" + local patParamsOnly = "%s*%([%w%p]*%)" + local patExtractParams = "%s*%(([%w%p]*)%)" -- same as patParamsOnly but with captures to capture only the content between the braces + local patFunctionname = "[%w%p^,+]+[%d]*" local w = string.gmatch(line,"("..patFunctionname..")"..patParamsOnly) + print(line) local name = w() - --print("FUN",name) + assert(name) + print("FUN",name) local params = string.gmatch(line,patFunctionname..patExtractParams) params = params() --print(" PARAMS",params) local paramNames = {} - for w in string.gmatch(params,"[%w+]") do - --print(" PARAM",w) - table.insert(paramNames,w) + if params and string.len(params) > 0 then + for w in string.gmatch(params,"[%w+]+") do + --print(" PARAM",w) + table.insert(paramNames,w) + end end db.newFunction(name,paramNames) end +jump["constructor"] = function(line) + jump["function"](line) + assert(db.currentFn) + db.currentFn.tag = "constructor" +end +jump["constant"] = function(line) + local patName = "[%w+]+"; + local name = string.gmatch(line,patName) + assert(name) + name = name() + + local patType = "%([%w+]+%)"; + local patExtractType = "%(([%w+]+)%)"; --using captions () + local type = string.gmatch(line,patName .. "%s*" .. patExtractType) + assert(type) + type = type() + + local patExtractValue = "([%w+])"; + local value = string.gmatch(line,patName .. "%s*" .. patType .. "%s*" ..patExtractValue) + assert(value) + value = value() + + print("CONST",name,type,value) + db.newConstant(name,type,value) +end jump["code"] = function(line) db.newCode(line) return db.newCodeLine,"codeend" @@ -235,11 +333,13 @@ local param = string.sub(line,to+1) if lineHandler and cmdStop ~= cmd then lineHandler,cmdStop = lineHandler(line) + print(line) elseif jump[cmd] then lineHandler,cmdStop = jump[cmd](param) end elseif lineHandler then lineHandler,cmdStop = lineHandler(line) + print(line) end end end @@ -254,7 +354,7 @@ io.close(rst.f) end -rst.underlineChars = "*+=-~" +rst.underlineChars = "+=-~" rst.currLevel = 0 rst.currScope = nil rst.underline = function(title) @@ -262,12 +362,39 @@ for i = 1,40 do s = s .. string.sub(rst.underlineChars,rst.currLevel,rst.currLevel) end - rst.f:write(s.."\n") + if rst.currLevel > 1 then + rst.f:write(s.."\n") + end rst.f:write(title.."\n") rst.f:write(s.."\n") + + if rst.currLevel == 1 then + rst.f:write("\n"); + rst.f:write("\n"); + rst.f:write(".. |date| date:: %d %b %Y\n"); + rst.f:write("\n"); + rst.f:write(":Author: Stephan Kaiser's LuaBindingsAutoDoc\n"); + rst.f:write("\n"); + rst.f:write(":Generated on: |date|\n"); + rst.f:write("\n"); + rst.f:write(":Status: Draft\n"); + rst.f:write("\n"); + rst.f:write(".. section-numbering::\n"); + rst.f:write(" :depth: 2\n"); + rst.f:write(" :start: 1\n"); + rst.f:write("\n"); + rst.f:write(".. meta::\n"); + rst.f:write(" :description: The official API documentation for the Yake Lua bindings.\n"); + rst.f:write("\n"); + rst.f:write("\n"); + end end rst.onScope = function(scope,scopeName,typeLookupFn) assert(scope) + if rst.currLevel == 1 then + rst.f:write("\n") + end + rst.currScope = scope rst.currLevel = rst.currLevel + 1 @@ -276,9 +403,19 @@ title = scope.kind .. ": " .. scopeName end - rst.f:write("\n") rst.underline(title) + if scope.kind and scope.kind == "namespace" then + rst.f:write("\n"); + rst.f:write(".. contents:: Table of Contents\n"); + if rst.currLevel == 1 then + rst.f:write(" :depth: 3\n"); + else + rst.f:write(" :local:\n"); + end + rst.f:write("\n") + end + if scope.parents and table.getn(scope.parents) > 0 then rst.f:write("\n") local first = true @@ -296,6 +433,30 @@ rst.f:write("\n") end end +rst.onBeginConstants = function() + rst.f:write("\n") + rst.f:write("**Constants**\n\n") +end +rst.onConstant = function(name,type,value,typeLookupFn) + assert( name and type ) + + local ti = type or "unknown" + local custom,_ = typeLookupFn:exec(type) + if custom then + ti = "`"..custom.."`_" + else + ti = "**"..ti.."**" + end + + rst.f:write(" * **" .. name .. "** of type " .. ti); + if value then + rst.f:write(" with value **" .. tostring(value) .. "**") + end + rst.f:write("\n") +end +rst.onEndConstants = function() + rst.f:write("\n") +end rst.onBeginProperties = function() rst.f:write("\n") rst.f:write("**Properties**\n\n") @@ -311,7 +472,7 @@ ti = "**"..ti.."**" end - rst.f:write("* **" .. name .. "** of type " .. ti .. "\n") + rst.f:write(" * **" .. name .. "** of type " .. ti .. "\n") end rst.onEndProperties = function() rst.f:write("\n") @@ -324,9 +485,12 @@ rst.f:write(" "..(name or "Code") .. "::\n\n") rst.f:write(content) rst.f:write("\n") + rst.f:write("\n") end -rst.onBeginFunctions = function() - if rst.currScope and rst.currScope.kind and rst.currScope.kind == "class" then +rst.onBeginFunctions = function(sectionName) + if sectionName then + rst.f:write("**"..sectionName.."**\n\n") + elseif rst.currScope and rst.currScope.kind and rst.currScope.kind == "class" then rst.f:write("**Methods**\n\n") else rst.f:write("**Functions**\n\n") @@ -351,11 +515,12 @@ return db.reverseLookupType(newScopes,type) end -rst.onFunction = function(name,signature,params,codes,typeLookupFn) +rst.onFunction = function(name,signature,params,returns,codes,typeLookupFn) + --print("rst.onFunction",name,signature) assert( name and signature ) -- signature - rst.f:write("* **" .. name .. "("); + rst.f:write(" * **" .. name .. "("); if params and getn(params) > 0 then local first = true for _,p in pairs(params) do @@ -367,7 +532,7 @@ -- param info if params and getn(params) > 0 then - rst.f:write(" Parameters\n") + --rst.f:write(" rst.f:write("Parameters\n") for _,p in pairs(params) do local ti = p.type or "unknown" local custom,_ = typeLookupFn(p.type) @@ -376,14 +541,47 @@ else ti = "**"..ti.."**" end - rst.f:write("\n " .. "**" .. p.name .. "** of type " .. ti .. "\n") + rst.f:write("\n " .. "**" .. p.name .. "** of type " .. ti) + if p.desc and string.len(p.desc) > 0 then + rst.f:write(" - "..p.desc) + end + rst.f:write("\n") end rst.f:write("\n") end + -- return info + if returns and getn(returns) > 0 then + for _,r in pairs(returns) do + rst.f:write("\n returns "); + local first = true + for k,t in pairs(r.types) do + if first == true then + first = false + else + rst.f:write(", ") + end + + local ti = t or "unknown" + local custom,_ = typeLookupFn(t) + if custom then + ti = "`"..custom.."`_" + else + ti = "**"..ti.."**" + end + rst.f:write(ti) + end + if r.desc and string.len(r.desc) > 0 then + rst.f:write(" - " .. r.desc) + end + rst.f:write("\n") + end + rst.f:write("\n") + end + -- code if codes and getn(codes) > 0 then - rst.f:write(" Code\n") + --rst.f:write(" Code\n\n") for k,v in pairs(codes) do rst.onCode(k,v) end @@ -407,7 +605,7 @@ return db.reverseLookupType(self.stack,t) end - -- + -- header rst.onScope(scope,scopeName,typeLookup) local strParents = "" @@ -437,23 +635,43 @@ end rst.onEndProperties() end + + -- constants + if scope.constants and getn(scope.constants) > 0 then + rst.onBeginConstants() + for name,c in pairs(scope.constants) do + print(lvl.." CONSTANT " .. name,"(" .. c.type .. ")=...") + rst.onConstant(name,c.type,c.value,typeLookup) + end + rst.onEndConstants() + end + + -- functions + local function doFunctions(sectionName,scope,tag) if scope.functions and getn(scope.functions) > 0 then - rst.onBeginFunctions() - for fnName,fnObj in pairs(scope.functions) do - local params = "" - for k,v in pairs(fnObj.params) do - if string.len(params) > 0 then params = params .. "," end - params = params .. k - end - print(lvl.." FUNCTION " .. fnName .. "(" .. params .. ")") - rst.onFunction(fnName,fnObj.signature,fnObj.params,fnObj.codes, - function(type) - return db.reverseLookupType(parents,type) - end - ) + rst.onBeginFunctions(sectionName) + for fnName,fnBase in pairs(scope.functions) do + for _,fnObj in pairs(fnBase.overloads) do + if fnObj.tag == tag then + local params = "" + for _,v in pairs(fnObj.params) do + if string.len(params) > 0 then params = params .. "," end + params = params .. v.name + end + print(lvl.." FUNCTION " .. fnName .. "(" .. params .. ")") + rst.onFunction(fnName,fnObj.signature,fnObj.params,fnObj.returns,fnObj.codes, + function(type) + return db.reverseLookupType(parents,type) + end + ) + end + end end rst.onEndFunctions() end + end + doFunctions("Constructors",scope,"constructor") + doFunctions("Functions",scope) local parentsForChilds = parents table.insert(parentsForChilds,scope) Added: tools/luadocs/project.html =================================================================== --- tools/luadocs/project.html (rev 0) +++ tools/luadocs/project.html 2007-08-22 22:52:24 UTC (rev 1809) @@ -0,0 +1,378 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" /> +<title>project</title> +<meta name="author" content="Stephan Kaiser's LuaBindingsAutoDoc" /> +<meta content="The official API documentation for the Yake Lua bindings." name="description" /> +<link rel="stylesheet" href="lua_bindings.css" type="text/css" /> +</head> +<body> +<div class="document" id="project"> +<h1 class="title">project</h1> +<table class="docinfo" frame="void" rules="none"> +<col class="docinfo-name" /> +<col class="docinfo-content" /> +<tbody valign="top"> +<tr><th class="docinfo-name">Author:</th> +<td>Stephan Kaiser's LuaBindingsAutoDoc</td></tr> +<tr class="field"><th class="docinfo-name">Generated on:</th><td class="field-body">23 Aug 2007</td> +</tr> +<tr><th class="docinfo-name">Status:</th> +<td>Draft</td></tr> +</tbody> +</table> +<div class="section" id="namespace-yake"> +<h1>1 namespace: yake</h1> +<div class="contents local topic" id="table-of-contents"> +<p class="topic-title first">Table of Contents</p> +<ul class="auto-toc simple"> +<li><a class="reference" href="#namespace-base" id="id3">1.1 namespace: base</a><ul> +<li><a class="reference" href="#quaternion" id="id4">Quaternion</a></li> +<li><a class="reference" href="#math" id="id5">Math</a></li> +<li><a class="reference" href="#color" id="id6">Color</a></li> +<li><a class="reference" href="#matrix3" id="id7">Matrix3</a></li> +<li><a class="reference" href="#vector4" id="id8">Vector4</a></li> +<li><a class="reference" href="#vector3" id="id9">Vector3</a></li> +</ul> +</li> +<li><a class="reference" href="#namespace-input" id="id10">1.2 namespace: input</a><ul> +<li><a class="reference" href="#device" id="id11">Device</a></li> +<li><a class="reference" href="#whateverdevice" id="id12">WhateverDevice</a></li> +<li><a class="reference" href="#keyboarddevice" id="id13">KeyboardDevice</a></li> +</ul> +</li> +</ul> +</div> +<div class="section" id="namespace-base"> +<h2><a class="toc-backref" href="#id3">1.1 namespace: base</a></h2> +<div class="contents local topic" id="id1"> +<p class="topic-title first">Table of Contents</p> +<ul class="simple"> +<li><a class="reference" href="#quaternion" id="id14">Quaternion</a></li> +<li><a class="reference" href="#math" id="id15">Math</a></li> +<li><a class="reference" href="#color" id="id16">Color</a></li> +<li><a class="reference" href="#matrix3" id="id17">Matrix3</a></li> +<li><a class="reference" href="#vector4" id="id18">Vector4</a></li> +<li><a class="reference" href="#vector3" id="id19">Vector3</a></li> +</ul> +</div> +<div class="section" id="quaternion"> +<h3><a class="toc-backref" href="#id14">Quaternion</a></h3> +<p><strong>Properties</strong></p> +<blockquote> +<ul class="simple"> +<li><strong>y</strong> of type <strong>real</strong></li> +<li><strong>x</strong> of type <strong>real</strong></li> +<li><strong>w</strong> of type <strong>real</strong></li> +<li><strong>z</strong> of type <strong>real</strong></li> +</ul> +</blockquote> +<p><strong>Constructors</strong></p> +<p><strong>Functions</strong></p> +<blockquote> +<ul> +<li><p class="first"><strong>inverse()</strong></p> +</li> +<li><p class="first"><strong>*(other)</strong></p> +<blockquote> +<p><strong>other</strong> of type <strong>Quaternion</strong></p> +<p>returns <strong>Quaternion</strong> - result of multiplication</p> +</blockquote> +</li> +</ul> +</blockquote> +</div> +<div class="section" id="math"> +<h3><a class="toc-backref" href="#id15">Math</a></h3> +</div> +<div class="section" id="color"> +<h3><a class="toc-backref" href="#id16">Color</a></h3> +<p><strong>Constructors</strong></p> +<blockquote> +<ul> +<li><p class="first"><strong>Color(r,g,b)</strong></p> +<blockquote> +<p><strong>r</strong> of type <strong>real</strong></p> +<p><strong>g</strong> of type <strong>real</strong></p> +<p><strong>b</strong> of type <strong>real</strong></p> +</blockquote> +</li> +<li><p class="first"><strong>Color(r,g,b,a)</strong></p> +<blockquote> +<p><strong>r</strong> of type <strong>real</strong></p> +<p><strong>g</strong> of type <strong>real</strong></p> +<p><strong>b</strong> of type <strong>real</strong></p> +<p><strong>a</strong> of type <strong>real</strong></p> +</blockquote> +</li> +<li><p class="first"><strong>Color()</strong></p> +</li> +</ul> +</blockquote> +<p><strong>Functions</strong></p> +</div> +<div class="section" id="matrix3"> +<h3><a class="toc-backref" href="#id17">Matrix3</a></h3> +<p><strong>Constants</strong></p> +<blockquote> +<ul class="simple"> +<li><strong>Zero</strong> of type <a class="reference" href="#matrix3">Matrix3</a></li> +<li><strong>Identity</strong> of type <a class="reference" href="#matrix3">Matrix3</a></li> +</ul> +</blockquote> +<p><strong>Constructors</strong></p> +<blockquote> +<ul class="simple"> +<li><strong>Matrix()</strong></li> +</ul> +</blockquote> +<p><strong>Functions</strong></p> +<blockquote> +<ul> +<li><p class="first"><strong>fromAxes(x,y,z)</strong></p> +<blockquote> +<p><strong>x</strong> of type <a class="reference" href="#vector3">Vector3</a></p> +<p><strong>y</strong> of type <a class="reference" href="#vector3">Vector3</a></p> +<p><strong>z</strong> of type <a class="reference" href="#vector3">Vector3</a></p> +</blockquote> +</li> +<li><p class="first"><strong>getColumn()</strong></p> +</li> +<li><p class="first"><strong>*(Matrix3)</strong></p> +<blockquote> +<p><strong>Matrix3</strong> of type <strong>unknown</strong></p> +</blockquote> +</li> +</ul> +</blockquote> +</div> +<div class="section" id="vector4"> +<h3><a class="toc-backref" href="#id18">Vector4</a></h3> +<p><strong>Constructors</strong></p> +<p><strong>Functions</strong></p> +<blockquote> +<ul> +<li><p class="first"><strong>Vector4(x,y,z,w)</strong></p> +<blockquote> +<p><strong>x</strong> of type <strong>real</strong></p> +<p><strong>y</strong> of type <strong>real</strong></p> +<p><strong>z</strong> of type <strong>real</strong></p> +<p><strong>w</strong> of type <strong>real</strong></p> +</blockquote> +</li> +<li><p class="first"><strong>Vector4()</strong></p> +</li> +</ul> +</blockquote> +</div> +<div class="section" id="vector3"> +<h3><a class="toc-backref" href="#id19">Vector3</a></h3> +<p><strong>Properties</strong></p> +<blockquote> +<ul class="simple"> +<li><strong>y</strong> of type <strong>real</strong></li> +<li><strong>x</strong> of type <strong>number</strong></li> +<li><strong>z</strong> of type <strong>real</strong></li> +</ul> +</blockquote> +<p><strong>Constants</strong></p> +<blockquote> +<ul class="simple"> +<li><strong>UnitScale</strong> of type <a class="reference" href="#vector3">Vector3</a></li> +<li><strong>Zero</strong> of type <a class="reference" href="#vector3">Vector3</a></li> +<li><strong>UnitY</strong> of type <a class="reference" href="#vector3">Vector3</a></li> +<li><strong>UnitX</strong> of type <a class="reference" href="#vector3">Vector3</a></li> +<li><strong>UnitZ</strong> of type <a class="reference" href="#vector3">Vector3</a></li> +</ul> +</blockquote> +<p><strong>Constructors</strong></p> +<blockquote> +<ul> +<li><p class="first"><strong>Vector3(x,y,z)</strong></p> +<blockquote> +<p><strong>x</strong> of type <strong>real</strong></p> +<p><strong>y</strong> of type <strong>real</strong></p> +<p><strong>z</strong> of type <strong>real</strong></p> +</blockquote> +</li> +</ul> +<blockquote> +<p>Valid constructors:</p> +<pre class="literal-block"> +v = Vector3() -- all components set to zero (0) +v = Vector3(1,2,0) -- custom values +v = Vector3.UnitZ -- set to constant +</pre> +</blockquote> +<ul class="simple"> +<li><strong>Vector3()</strong></li> +</ul> +</blockquote> +<p><strong>Functions</strong></p> +<blockquote> +<ul> +<li><p class="first"><strong>getRotationTo(destination)</strong></p> +<blockquote> +<p><strong>destination</strong> of type <a class="reference" href="#vector3">Vector3</a></p> +<p>returns <a class="reference" href="#quaternion">Quaternion</a></p> +</blockquote> +</li> +<li><p class="first"><strong>dotProduct(other)</strong></p> +<blockquote> +<p><strong>other</strong> of type <a class="reference" href="#vector3">Vector3</a></p> +<p>returns <strong>real</strong></p> +</blockquote> +</li> +<li><p class="first"><strong>perpendicular()</strong></p> +<blockquote> +<p>returns <a class="reference" href="#vector3">Vector3</a></p> +</blockquote> +</li> +<li><p class="first"><strong>normalise()</strong></p> +<blockquote> +<p>returns <strong>real</strong> - previous length of vector</p> +</blockquote> +</li> +<li><p class="first"><strong>reflect(normal)</strong></p> +<blockquote> +<p><strong>normal</strong> of type <a class="reference" href="#vector3">Vector3</a> - normal of reflection plane</p> +<p>returns <a class="reference" href="#vector3">Vector3</a> - reflected vector</p> +</blockquote> +</li> +<li><p class="first"><strong>/(factor)</strong></p> +<blockquote> +<p><strong>factor</strong> of type <strong>real</strong></p> +</blockquote> +</li> +</ul> +<blockquote> +<p>Example:</p> +<pre class="literal-block"> +v = Vector3(2,4,0) +v = v / 2 +print(v) -- prints "Vector3(1,2,0)" +</pre> +</blockquote> +<ul> +<li><p class="first"><strong>+(other)</strong></p> +<blockquote> +<p><strong>other</strong> of type <a class="reference" href="#vector3">Vector3</a></p> +</blockquote> +</li> +<li><p class="first"><strong>*(xform)</strong></p> +<blockquote> +<p><strong>xform</strong> of type <a class="reference" href="#matrix3">Matrix3</a></p> +</blockquote> +</li> +<li><p class="first"><strong>*(xform)</strong></p> +<blockquote> +<p><strong>xform</strong> of type <a class="reference" href="#quaternion">Quaternion</a></p> +</blockquote> +</li> +<li><p class="first"><strong>*(factor)</strong></p> +<blockquote> +<p><strong>factor</strong> of type <strong>real</strong></p> +</blockquote> +</li> +</ul> +<blockquote> +<p>Example:</p> +<pre class="literal-block"> +v = Vector3(1,2,0) +v = v * 2 +print(v) -- prints "Vector3(2,4,0)" +</pre> +</blockquote> +<ul> +<li><p class="first"><strong>-(other)</strong></p> +<blockquote> +<p><strong>other</strong> of type <a class="reference" href="#vector3">Vector3</a></p> +</blockquote> +</li> +<li><p class="first"><strong>length()</strong></p> +<blockquote> +<p>returns <strong>real</strong> - length</p> +</blockquote> +</li> +<li><p class="first"><strong>crossProduct(other)</strong></p> +<blockquote> +<p><strong>other</strong> of type <a class="reference" href="#vector3">Vector3</a></p> +<p>returns <a class="reference" href="#vector3">Vector3</a></p> +</blockquote> +</li> +</ul> +</blockquote> +</div> +</div> +<div class="section" id="namespace-input"> +<h2><a class="toc-backref" href="#id10">1.2 namespace: input</a></h2> +<div class="contents local topic" id="id2"> +<p class="topic-title first">Table of Contents</p> +<ul class="simple"> +<li><a class="reference" href="#device" id="id20">Device</a></li> +<li><a class="reference" href="#whateverdevice" id="id21">WhateverDevice</a></li> +<li><a class="reference" href="#keyboarddevice" id="id22">KeyboardDevice</a></li> +</ul> +</div> +<div class="section" id="device"> +<h3><a class="toc-backref" href="#id20">Device</a></h3> +</div> +<div class="section" id="whateverdevice"> +<h3><a class="toc-backref" href="#id21">WhateverDevice</a></h3> +<p><strong>inherits</strong> <a class="reference" href="#device">Device</a>, Parent2</p> +<p><strong>Properties</strong></p> +<blockquote> +<ul class="simple"> +<li><strong>stuffOk</strong> of type <strong>bool</strong></li> +<li><strong>isOk</strong> of type <strong>bool|readonly</strong></li> +</ul> +</blockquote> +</div> +<div class="section" id="keyboarddevice"> +<h3><a class="toc-backref" href="#id22">KeyboardDevice</a></h3> +<p><strong>inherits</strong> <a class="reference" href="#device">Device</a></p> +<p><strong>Code</strong></p> +<blockquote> +<p>Example #1:</p> +<pre class="literal-block"> +dev:poll(yeeha) +</pre> +</blockquote> +<p><strong>Properties</strong></p> +<blockquote> +<ul class="simple"> +<li><strong>enabled</strong> of type <strong>bool</strong></li> +<li><strong>name</strong> of type <strong>string</strong></li> +<li><strong>pseudo</strong> of type <a class="reference" href="#device">Device</a></li> +</ul> +</blockquote> +<p><strong>Constructors</strong></p> +<p><strong>Functions</strong></p> +<blockquote> +<ul> +<li><p class="first"><strong>poll(a,b,c,d)</strong></p> +<blockquote> +<p><strong>a</strong> of type <strong>string</strong> - ...</p> +<p><strong>b</strong> of type <strong>int</strong> - ...</p> +<p><strong>c</strong> of type <strong>whatever</strong></p> +<p><strong>d</strong> of type <a class="reference" href="#device">Device</a> - ...</p> +<p>returns <strong>bool</strong> - returns true on success</p> +</blockquote> +</li> +</ul> +<blockquote> +<p>Example for poll():</p> +<pre class="literal-block"> +dev:poll(yeeha) +</pre> +</blockquote> +</blockquote> +</div> +</div> +</div> +</div> +</body> +</html> Modified: tools/luadocs/project.txt =================================================================== --- tools/luadocs/project.txt 2007-08-22 19:42:51 UTC (rev 1808) +++ tools/luadocs/project.txt 2007-08-22 22:52:24 UTC (rev 1809) @@ -1,6 +1,122 @@ -@namespace y +@namespace yake +@namespace base + + @class Color + @constructor Color() + @constructor Color(r,g,b) + @param r (real) + @param g (real) + @param b (real) + @constructor Color(r,g,b,a) + @param r (real) + @param g (real) + @param b (real) + @param a (real) + @end -- Color + + @class Math + @enum AngleUnit + @end -- Math + + @class Vector3 + @property x (number) + @property y (real) + @property z (real) + @constructor Vector3() + @constructor Vector3(x,y,z) + @param x (real) + @param y (real) + @param z (real) + @code Valid constructors + v = Vector3() -- all components set to zero (0) + v = Vector3(1,2,0) -- custom values + v = Vector3.UnitZ -- set to constant + @codeend + @function length() + @return (real) length + @function normalise() + @return (real) previous length of vector + @function crossProduct(other) + @param other (Vector3) + @return (Vector3) + @function dotProduct(other) + @param other (Vector3) + @return (real) + @function reflect(normal) + @param normal (Vector3) normal of reflection plane + @return (Vector3) reflected vector + @function perpendicular() + @return (Vector3) + @function getRotationTo(destination) + @param destination (Vector3) + @return (Quaternion) + @function *(factor) + @param factor (real) + @code Example + v = Vector3(1,2,0) + v = v * 2 + print(v) -- prints "Vector3(2,4,0)" + @codeend + @function /(factor) + @param factor (real) + @code Example + v = Vector3(2,4,0) + v = v / 2 + print(v) -- prints "Vector3(1,2,0)" + @codeend + @function +(other) + @param other (Vector3) + @function -(other) + @param other (Vector3) + @function *(xform) + @param xform (Matrix3) + @function *(xform) + @param xform (Quaternion) + + @constant Zero (Vector3) + @constant UnitScale (Vector3) + @constant UnitX (Vector3) + @constant UnitY (Vector3) + @constant UnitZ (Vector3) + @end -- Vector3 + + @class Vector4 + @function Vector4() + @function Vector4(x,y,z,w) + @param x (real) + @param y (real) + @param z (real) + @param w (real) + @end -- Vector4 + + @class Matrix3 + @constructor Matrix() + @function getColumn() + @function fromAxes(x,y,z) + @param x (Vector3) + @param y (Vector3) + @param z (Vector3) + @function * (Matrix3) + + @constant Zero (Matrix3) + @constant Identity (Matrix3) + @end -- Matrix3 + + @class Quaternion + @property x (real) + @property y (real) + @property z (real) + @property w (real) + @function inverse() + @function * (other) + @param other(Quaternion) + @return (Quaternion) result of multiplication + @end -- Quaternion + +@end -- namespace base + @namespace input @class Device @@ -23,11 +139,10 @@ @function poll(a,b,c,d) description - @return ... - @return ... + @return (bool) returns true on success @param a (string) ... @param b (int) ... - @param c ... + @param c (whatever) @param d (Device) ... @code Example for poll() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-22 19:42:47
|
Revision: 1808 http://yake.svn.sourceforge.net/yake/?rev=1808&view=rev Author: psyclonist Date: 2007-08-22 12:42:51 -0700 (Wed, 22 Aug 2007) Log Message: ----------- [samples] gcc compliance Modified Paths: -------------- trunk/yake/samples/raf/lua1/demo.cpp Modified: trunk/yake/samples/raf/lua1/demo.cpp =================================================================== --- trunk/yake/samples/raf/lua1/demo.cpp 2007-08-22 18:51:45 UTC (rev 1807) +++ trunk/yake/samples/raf/lua1/demo.cpp 2007-08-22 19:42:51 UTC (rev 1808) @@ -108,7 +108,8 @@ int main( int argc, char** argv ) { // Use default executor for convenience. - // It's always possible to manually execute TheApp::initialise() etc. - return (raf::runApplication( TheApp() )) ? 0 : 1; + // It's always possible to manually execute TheApp::initialise() etc. + TheApp app; + return (raf::runApplication( app )) ? 0 : 1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-22 18:51:42
|
Revision: 1807 http://yake.svn.sourceforge.net/yake/?rev=1807&view=rev Author: psyclonist Date: 2007-08-22 11:51:45 -0700 (Wed, 22 Aug 2007) Log Message: ----------- replaced in-place tools by svn-external Property Changed: ---------------- trunk/yake/scripts/ Property changes on: trunk/yake/scripts ___________________________________________________________________ Name: svn:externals + tools https://yake.svn.sourceforge.net/svnroot/yake/tools This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-22 18:50:34
|
Revision: 1806 http://yake.svn.sourceforge.net/yake/?rev=1806&view=rev Author: psyclonist Date: 2007-08-22 11:50:32 -0700 (Wed, 22 Aug 2007) Log Message: ----------- moved tools Removed Paths: ------------- trunk/yake/scripts/tools/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-22 18:47:53
|
Revision: 1805 http://yake.svn.sourceforge.net/yake/?rev=1805&view=rev Author: psyclonist Date: 2007-08-22 11:47:54 -0700 (Wed, 22 Aug 2007) Log Message: ----------- moved tools Removed Paths: ------------- trunk/yake/scripts/tools/extract_input_kc.pl trunk/yake/scripts/tools/make_api.pl trunk/yake/scripts/tools/make_manual.pl Deleted: trunk/yake/scripts/tools/extract_input_kc.pl =================================================================== --- trunk/yake/scripts/tools/extract_input_kc.pl 2007-08-22 18:47:39 UTC (rev 1804) +++ trunk/yake/scripts/tools/extract_input_kc.pl 2007-08-22 18:47:54 UTC (rev 1805) @@ -1,55 +0,0 @@ -print "Extracting...\n\n"; - -$FILE = "../../yake/input/yakeInputSystem.h"; -$OUTFILE = ">../../yake/bindings.lua/detail/input.lua.keycodes.inl"; - -open OUT, $OUTFILE or die("Could not open '$OUT'."); - -$FIND = "enum KeyCode"; -$stage = "enumsearch"; - -$luatpl = "luabind::globals(L)[\"yake\"][\"input\"][\"%ID%\"] = %VALUE%;"; - -print($luatpl); - -open(FILE) or die("Could not open '$FILE'."); -foreach $line (<FILE>) { - #print($line); - chomp($line); # remove newline - if ($stage =~ m/enumsearch/) - { - if ($line =~ m/$FIND/) - { - #print("found"); - $stage = "extract"; - } - } - elsif ($stage =~ m/extract/) - { - if ($line =~ m/}/) - { - last; - } - #print($line); - ($id,$value) = split(' ',$line); - if (length($value) == 0) - { - next; - } - # value typically has the form: =0xCA, - #$value =~ s/=//; # remove = - #$value =~ s/,//; # remove , - - $decl = $luatpl; - $decl =~ s/%ID%/$id/; - $decl =~ s/%VALUE%/$id/; - print($decl,"\n"); - print OUT $decl,"\n"; - - #print($id, " => ", $value, "\n"); - print() - } -} -close(FILE); -close(OUT); - Deleted: trunk/yake/scripts/tools/make_api.pl =================================================================== --- trunk/yake/scripts/tools/make_api.pl 2007-08-22 18:47:39 UTC (rev 1804) +++ trunk/yake/scripts/tools/make_api.pl 2007-08-22 18:47:54 UTC (rev 1805) @@ -1,6 +0,0 @@ -print "Generating API reference...\n\n"; - -#`cd ../..` or die("Error: could not change directory."); -#`doxygen documentation/api/doxyfile` or die("Error: Failed to run doxygen.") -`cd ../.. && doxygen documentation/api/doxyfile`; - Deleted: trunk/yake/scripts/tools/make_manual.pl =================================================================== --- trunk/yake/scripts/tools/make_manual.pl 2007-08-22 18:47:39 UTC (rev 1804) +++ trunk/yake/scripts/tools/make_manual.pl 2007-08-22 18:47:54 UTC (rev 1805) @@ -1,4 +0,0 @@ -print "Generating manual...\n\n"; - -`cd ../../documentation/manual && rst2html.py --link-stylesheet --stylesheet "yake-manual.css" yake-manual.txt > yake-manual.html`; - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-22 18:47:40
|
Revision: 1804 http://yake.svn.sourceforge.net/yake/?rev=1804&view=rev Author: psyclonist Date: 2007-08-22 11:47:39 -0700 (Wed, 22 Aug 2007) Log Message: ----------- moved tools Added Paths: ----------- tools/extract_input_kc.pl tools/make_api.pl tools/make_manual.pl Copied: tools/extract_input_kc.pl (from rev 1803, trunk/yake/scripts/tools/extract_input_kc.pl) =================================================================== --- tools/extract_input_kc.pl (rev 0) +++ tools/extract_input_kc.pl 2007-08-22 18:47:39 UTC (rev 1804) @@ -0,0 +1,55 @@ +print "Extracting...\n\n"; + +$FILE = "../../yake/input/yakeInputSystem.h"; +$OUTFILE = ">../../yake/bindings.lua/detail/input.lua.keycodes.inl"; + +open OUT, $OUTFILE or die("Could not open '$OUT'."); + +$FIND = "enum KeyCode"; +$stage = "enumsearch"; + +$luatpl = "luabind::globals(L)[\"yake\"][\"input\"][\"%ID%\"] = %VALUE%;"; + +print($luatpl); + +open(FILE) or die("Could not open '$FILE'."); +foreach $line (<FILE>) { + #print($line); + chomp($line); # remove newline + if ($stage =~ m/enumsearch/) + { + if ($line =~ m/$FIND/) + { + #print("found"); + $stage = "extract"; + } + } + elsif ($stage =~ m/extract/) + { + if ($line =~ m/}/) + { + last; + } + #print($line); + ($id,$value) = split(' ',$line); + if (length($value) == 0) + { + next; + } + # value typically has the form: =0xCA, + #$value =~ s/=//; # remove = + #$value =~ s/,//; # remove , + + $decl = $luatpl; + $decl =~ s/%ID%/$id/; + $decl =~ s/%VALUE%/$id/; + print($decl,"\n"); + print OUT $decl,"\n"; + + #print($id, " => ", $value, "\n"); + print() + } +} +close(FILE); +close(OUT); + Copied: tools/make_api.pl (from rev 1803, trunk/yake/scripts/tools/make_api.pl) =================================================================== --- tools/make_api.pl (rev 0) +++ tools/make_api.pl 2007-08-22 18:47:39 UTC (rev 1804) @@ -0,0 +1,6 @@ +print "Generating API reference...\n\n"; + +#`cd ../..` or die("Error: could not change directory."); +#`doxygen documentation/api/doxyfile` or die("Error: Failed to run doxygen.") +`cd ../.. && doxygen documentation/api/doxyfile`; + Copied: tools/make_manual.pl (from rev 1803, trunk/yake/scripts/tools/make_manual.pl) =================================================================== --- tools/make_manual.pl (rev 0) +++ tools/make_manual.pl 2007-08-22 18:47:39 UTC (rev 1804) @@ -0,0 +1,4 @@ +print "Generating manual...\n\n"; + +`cd ../../documentation/manual && rst2html.py --link-stylesheet --stylesheet "yake-manual.css" yake-manual.txt > yake-manual.html`; + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-22 17:42:24
|
Revision: 1803 http://yake.svn.sourceforge.net/yake/?rev=1803&view=rev Author: psyclonist Date: 2007-08-22 10:42:26 -0700 (Wed, 22 Aug 2007) Log Message: ----------- * [tools] fixed lua bindings documentation tool Modified Paths: -------------- tools/luadocs/lua_bindings_2_rst.cmd tools/luadocs/lua_bindings_2_rst.lua Added Paths: ----------- tools/luadocs/project.txt tools/luadocs/stringutil.lua Removed Paths: ------------- tools/luadocs/project.rst.txt Modified: tools/luadocs/lua_bindings_2_rst.cmd =================================================================== --- tools/luadocs/lua_bindings_2_rst.cmd 2007-08-22 17:36:13 UTC (rev 1802) +++ tools/luadocs/lua_bindings_2_rst.cmd 2007-08-22 17:42:26 UTC (rev 1803) @@ -1,4 +1,5 @@ @echo off +d:\tools\luabin\lua5.1 lua_bindings_2_rst.lua d:\tools\doc\docutils\tools\rst2html.py --link-stylesheet --stylesheet-path lua_bindings.css project.rst.txt project.html pause Modified: tools/luadocs/lua_bindings_2_rst.lua =================================================================== --- tools/luadocs/lua_bindings_2_rst.lua 2007-08-22 17:36:13 UTC (rev 1802) +++ tools/luadocs/lua_bindings_2_rst.lua 2007-08-22 17:42:26 UTC (rev 1803) @@ -216,7 +216,7 @@ end -------------------------- M A I N -------------------------- -local f = io.open("lua_doc.txt") +local f = io.open("project.txt") if not f then print("Could not open input.") return @@ -225,7 +225,7 @@ local lineHandler = nil local cmdStop = nil -for line in io.lines("lua_doc.txt") do +for line in io.lines("project.txt") do --@todo trim if string.len(line) > 0 then --print(line) Deleted: tools/luadocs/project.rst.txt =================================================================== --- tools/luadocs/project.rst.txt 2007-08-22 17:36:13 UTC (rev 1802) +++ tools/luadocs/project.rst.txt 2007-08-22 17:42:26 UTC (rev 1803) @@ -1,66 +0,0 @@ - -**************************************** -project -**************************************** - -++++++++++++++++++++++++++++++++++++++++ -namespace: y -++++++++++++++++++++++++++++++++++++++++ - -======================================== -namespace: input -======================================== - ----------------------------------------- -Device ----------------------------------------- - ----------------------------------------- -WhateverDevice ----------------------------------------- - -**inherits** `Device`_, Parent2 - -**Properties** - -* **stuffOk** of type **bool** -* **isOk** of type **bool|readonly** - - ----------------------------------------- -KeyboardDevice ----------------------------------------- - -**inherits** `Device`_ - -**Code** - - Example #1:: - - dev:poll(yeeha) - -**Properties** - -* **enabled** of type **bool** -* **name** of type **string** -* **pseudo** of type `Device`_ - -**Methods** - -* **poll(a,b,c,d)** - - Parameters - - **a** of type **string** - - **b** of type **int** - - **c** of type **unknown** - - **d** of type `Device`_ - - Code - Example for poll():: - - dev:poll(yeeha) - Added: tools/luadocs/project.txt =================================================================== --- tools/luadocs/project.txt (rev 0) +++ tools/luadocs/project.txt 2007-08-22 17:42:26 UTC (rev 1803) @@ -0,0 +1,45 @@ + +@namespace y + +@namespace input + +@class Device +@end + +@class KeyboardDevice + @inherits Device + + @code Example #1 + dev:poll(yeeha) + @codeend + + @property enabled (bool) + description + + @property name (string) + + @property pseudo (Device) + + @function poll(a,b,c,d) + description + + @return ... + @return ... + @param a (string) ... + @param b (int) ... + @param c ... + @param d (Device) ... + + @code Example for poll() + dev:poll(yeeha) + @codeend + +@end -- KeyboardDevice + +@class WhateverDevice + @inherits Device Parent2 + @property isOk (bool|readonly) + @property stuffOk (bool) +@end + +@end -- input Added: tools/luadocs/stringutil.lua =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-22 17:36:10
|
Revision: 1802 http://yake.svn.sourceforge.net/yake/?rev=1802&view=rev Author: psyclonist Date: 2007-08-22 10:36:13 -0700 (Wed, 22 Aug 2007) Log Message: ----------- * [tools] added tools/luadocs for documenting Lua bindings Added Paths: ----------- tools/ tools/luadocs/ tools/luadocs/lua_bindings.css tools/luadocs/lua_bindings_2_rst.cmd tools/luadocs/lua_bindings_2_rst.lua tools/luadocs/project.rst.txt Added: tools/luadocs/lua_bindings.css =================================================================== --- tools/luadocs/lua_bindings.css (rev 0) +++ tools/luadocs/lua_bindings.css 2007-08-22 17:36:13 UTC (rev 1802) @@ -0,0 +1,312 @@ +body +{ + font-family:Tahoma, Verdana, Arial; +} +a +{ + color: #000000; + text-decoration: none; + border-bottom: 1px dotted #1010c0; +} +a:hover +{ + border-bottom: 1px solid #1010c0; +} +/* +a:visited +{ + border-bottom: 1px dotted #5050a0; +} +a:link +{ + border-bottom: 1px dotted #303070; +} +a:active +{ + border-bottom: 1px solid #303070; +} +*/ +p,li +{ + margin-left: 5%; +} +h1 +{ + font-family: Georgia "Times New Roman", serif; + color: #004090; + border-bottom: 3px solid; +} +h2 +{ + font-family: Georgia "Times New Roman", serif; + color: #004090; + border-bottom: 3px solid; +} +div h4.title /* 3rd level */ +{ + margin-left: 2.5%; +} +div.author h3.author +{ + font-size: medium; +} +hr +{ + color: #004090; +} + +/* generated by docbook->html: pre.programlisting + generated by rst2html: pre.literal-block +*/ +pre.programlisting, pre.literal-block +{ + border-left: 3px solid #707070; + border-right: 1px solid #707070; + border-top: 1px solid #707070; + border-bottom: 1px solid #707070; + background-color: #ffffd5; + margin-left: 7.5%; + margin-right: 5%; + padding: 6px; + color: #000000; +} + +.tip,.note +{ + border: 2px solid #00a0f0; /* blue border */ + background-color: #e0e0ff; /* light blue background */ + margin-bottom: 5px; + margin-left: 7.5%; + margin-right: 5%; + padding-top: 5px; + padding-bottom: 5px; +} +div.note h3.title /** header in case of docbook generator */ +{ + margin-left: 2%; + margin-top: 10px; +} +/*div.note*/ p.admonition-title /** header in case of rst2html */ +{ + margin-left: 2%; + margin-top: 10px; + font-weight: bold; +} +div.warning h3.title +{ + margin-left: 2%; + margin-top: 10px; +} +div.tip h3.title +{ + margin-left: 2%; + margin-top: 10px; +} +.tip h3 +{ + color: #0070c0; /* blue "Tip" or "Note" */ +} +.warning +{ + border: 2px solid red; + background-color: #ffe0b0; /* light orange background */ + margin-left: 7.5%; + margin-right: 5%; + margin-bottom: 5px; + padding-top: 5px; + padding-bottom: 5px; +} +.warning h3 +{ + color: #ffa040; /* red "Warning" */ +} + +li p /** <p> within <li> in regular paragraphs. */ +{ + margin-left:0; +} + +.emphasis +{ + font-family:Courier New,Courier,Verdana; +} + +/** "Table of contents" */ +div.toc +{ + margin-left:5%; +} +div.toc p +{ + margin-left:0%; +} + +/** Ordered lists */ +div.orderedlist ol li p +{ + margin: 0%; +} +/** Itemized lists: */ +div.itemizedlist ul li p +{ + margin: 0%; +} +div.itemizedlist li +{ + margin-left: 2.5%; /** Reduce intendation from 5% */ +} + +/** "List of tables" (right below "Table of contents") */ +div.list-of-tables +{ + margin-left:5%; +} +div.list-of-tables p +{ + margin-left:0%; +} + +/**-------------*/ +div.blockquote +{ + border-top: 1px solid gray; + border-bottom: 1px solid gray; + width: 80%; + margin-left:5%; + margin-right:5%; +} +blockquote p +{ + color:gray; +} +blockquote p strong +{ + color:Orange; +} +.literal +{ + background-color: #ffffd5; /* light yellow background */ +} + +/*--------- Tables in <section>s ----------------*/ +/* when generated by rst2html */ +table.docutils +{ + width: 87.5%; + margin-left: 7.5%; /* align with paragraph text */ + margin-right: 5%; + border: 1px solid gray; + border-collapse: collapse; +} +table.docutils tbody +{ + border: 1px solid gray; + padding: 0; + margin: 0; +} +table.docutils tbody tr +{ + border: 0; + margin: 0; + padding: 0; +} +table.docutils td +{ + border: 1px solid gray; + padding-left: 1em; + padding-right: 1em; + /*padding: 0;*/ + vertical-align: top; +} +table.docutils th +{ + border-bottom: 2px solid gray; + background-color: #f0f0f0; +} + +/*--------- Tables in <section>s ----------------*/ + +div.informaltable +{ + font-size: small; +} + +div.informaltable table +{ + width: 90%; + margin-left: 5%; /* align with paragraph text */ + margin-right: 5%; + border: 1px solid gray; + border-collapse: collapse; +} + +div.informaltable table tbody +{ + border: 1px solid gray; + padding: 0; + margin: 0; +} +div.informaltable table tbody tr +{ + border: 0; + margin: 0; + padding: 0; +} +div.informaltable table tbody tr td +{ + border: 1px solid gray; + margin: 0; + /*padding: 0;*/ + vertical-align: top; +} + +/*--------- Tables in <section>s ----------------*/ + +div.table p.title /* Title of a table */ +{ + font-size: small; +} +div.table-contents table +{ + margin-left: 5%; /* align with paragraph text */ + margin-right: 5%; + border-collapse:collapse; /* important! so that cells share the neighbouring borders */ + border: 1px solid gray; +} +div.table-contents table tbody +{ + border: 1px solid gray; + padding: 0; + margin: 0; +} +div.table-contents table tbody tr +{ + border: 0; + margin: 0; + padding: 0; +} +div.table-contents table tbody tr td +{ + border: 1px solid gray; + margin: 0; + /*padding: 0;*/ +} + +/** When using rst2html: document information +*/ +table.docinfo +{ + margin-left: 5%; + margin-right: 5%; + border-collapse:collapse; + border: 1px solid gray; +} +table.docinfo th +{ + text-align: right; +} +table.docinfo td +{ + text-align: left; + padding-left: 1em; +} Added: tools/luadocs/lua_bindings_2_rst.cmd =================================================================== --- tools/luadocs/lua_bindings_2_rst.cmd (rev 0) +++ tools/luadocs/lua_bindings_2_rst.cmd 2007-08-22 17:36:13 UTC (rev 1802) @@ -0,0 +1,4 @@ +@echo off +d:\tools\doc\docutils\tools\rst2html.py --link-stylesheet --stylesheet-path lua_bindings.css project.rst.txt project.html +pause + Added: tools/luadocs/lua_bindings_2_rst.lua =================================================================== --- tools/luadocs/lua_bindings_2_rst.lua (rev 0) +++ tools/luadocs/lua_bindings_2_rst.lua 2007-08-22 17:36:13 UTC (rev 1802) @@ -0,0 +1,471 @@ +local stringutil = require 'stringutil' + +function getn (t) + local max = 0 + for _,_ in pairs(t) do + max = max + 1 + end + return max +end +-- + +db = {} +db.scopeStack = {} +db.pushScope = function(scope) + db.scopeStack[ table.getn(db.scopeStack)+1 ] = scope +end + +db.scopes = {} +db.newScope = function(id,kind) + db.currentFn = nil + local parent = db.getCurrClass() + if not parent then + parent = db + end + assert(parent) + assert(parent.scopes) + parent.scopes[id] = {} + parent.scopes[id].kind = kind + parent.scopes[id].scopes = {} + parent.scopes[id].properties = {} + parent.scopes[id].functions = {} + parent.scopes[id].codes = {} + db.currScope = parent.scopes[id] + + db.pushScope( db.currScope ) + + return db.currScope +end +db.endScope = function() + assert(db.currScope ~= db) + local lastIdx = table.getn(db.scopeStack) + if lastIdx > 0 then + table.remove(db.scopeStack,lastIdx) + if lastIdx == 1 then + db.currScope = db + else + db.currScope = db.scopeStack[lastIdx - 1] + end + end +end +db.newNamespace = function(name) + assert(name) + --print("newNamespace",name) + db.newScope(name,"namespace") +end +db.newClass = function(name) + assert(name) + --print("newClass",name) + db.newScope(name,"class") + assert(db.currScope) + db.currScope.parents = {} +end +db.newProperty = function(name,type) + assert(db.getCurrClass()) + assert(name) + assert(type) + db.getCurrClass().properties[name] = type +end +db.newFunction = function(name,paramNames) + assert(name) + assert(db.getCurrClass()) + local scope = db.getCurrClass() + scope.functions[name] = {} + local fn = scope.functions[name] + fn.params = {} + fn.returnType = nil + fn.codes = {} + + -- signature (only parameters, at the moment: "a,b,c") + fn.signature = name.."(" + local params = "" + for _,v in pairs(paramNames) do + if string.len(params) > 0 then params = params .. "," end + params = params .. v + local paramEntry = { name = v } + table.insert(fn.params,paramEntry) + end + fn.signature = fn.signature .. params ..")" + db.currentFn = fn +end +db.findParam = function(fn,param) + assert( fn and param ) + assert( fn.params ) + for _,p in pairs(fn.params) do + if p.name == param then + return p + end + end + return nil +end + +db.setFunctionParamInfo = function(paramName,paramType,paramDesc) + local fn = db.currentFn + assert(fn) + local p = db.findParam(fn,paramName) + if not p then + print("ERROR: Parameter '"..paramName.."' not found in signature: " .. fn.signature) + return + end + local p = db.findParam(fn,paramName) + p.type = paramType + p.desc = paramDesc +end +db.getCurrClass = function() + return db.currScope +end +db.newCode = function(name,content) + local scope = db.currentFn or db.getCurrClass() + assert(scope) + assert(scope.codes) + --print("newCode '"..name.."'") + scope.codes[name] = "" + db.currCode = name + db.currCodeScope = scope.codes +end +db.newCodeLine = function(line) + assert(db.currCode) + assert(db.currCodeScope) + assert(line) + + --print("newCodeLine '" .. db.currCode .. "': '" .. line .. "'") + + assert(db.currCodeScope) + assert(db.currCodeScope[db.currCode]) + + db.currCodeScope[db.currCode] = db.currCodeScope[db.currCode] .. line +end +db.endCode = function() + db.currCode = nil + db.currCodeScope = nil +end + +jump = {} +jump["class"] = function(line) + local from,to = string.find(line,"%a+",1) + if from and to then + local name = string.sub(line,from,to) + db.newClass(name) + end +end +jump["inherits"] = function(line) + --print("PARENTS: ",line) + --print("currCls",db.getCurrClass()) + for w in string.gmatch(line,"[%w]+") do -- %w = alphanumeric + assert(db.getCurrClass()) + table.insert( db.getCurrClass().parents, w ) + --print(w) + end +end +jump["property"] = function(line) + local name = string.gmatch(line,"[%w]+") + --print(name()) + local thetype = string.gmatch(line,"%((.-)%)") + --print(thetype()) + db.newProperty(name(),thetype()) +end +jump["namespace"] = function(line) + local name = string.gmatch(line,"[%w]+") + assert(name) + name = name() + db.newNamespace(name) +end +jump["end"] = function(line) + db.endScope() +end +jump["param"] = function(line) + + local name = string.gmatch(line,"[%w]+") + assert(name) + if name then + name = name() + end + + local type = string.gmatch(line,"[%w]*%(([%w]+)%)") + if type then + type = type() + end + db.setFunctionParamInfo(name,type,"") +end +jump["function"] = function(line) + local sig = line --@todo trim + assert(sig) + local patParamsOnly = "%([%w%p]+%)" + local patExtractParams = "%(([%w%p]+)%)" -- same as patParamsOnly but with captures to capture only the content between the braces + local patFunctionname = "[%w%p^,+]+" + local w = string.gmatch(line,"("..patFunctionname..")"..patParamsOnly) + local name = w() + --print("FUN",name) + local params = string.gmatch(line,patFunctionname..patExtractParams) + params = params() + --print(" PARAMS",params) + local paramNames = {} + for w in string.gmatch(params,"[%w+]") do + --print(" PARAM",w) + table.insert(paramNames,w) + end + + db.newFunction(name,paramNames) +end +jump["code"] = function(line) + db.newCode(line) + return db.newCodeLine,"codeend" +end +jump["codeend"] = function(line) + db.endCode() +end + +-------------------------- M A I N -------------------------- +local f = io.open("lua_doc.txt") +if not f then + print("Could not open input.") + return +end +io.close(f) + +local lineHandler = nil +local cmdStop = nil +for line in io.lines("lua_doc.txt") do + --@todo trim + if string.len(line) > 0 then + --print(line) + local from,to = string.find(line,"@%a+",1) -- %a is single char, %a+ is 1 or more + if from and to then + local cmd = string.sub(line,from+1,to) + local param = string.sub(line,to+1) + if lineHandler and cmdStop ~= cmd then + lineHandler,cmdStop = lineHandler(line) + elseif jump[cmd] then + lineHandler,cmdStop = jump[cmd](param) + end + elseif lineHandler then + lineHandler,cmdStop = lineHandler(line) + end + end +end + +rst = {} +rst.f = nil +rst.open = function(filename) + rst.f = io.open(filename,"w") + assert(rst.f) +end +rst.close = function() + io.close(rst.f) +end + +rst.underlineChars = "*+=-~" +rst.currLevel = 0 +rst.currScope = nil +rst.underline = function(title) + local s = "" + for i = 1,40 do + s = s .. string.sub(rst.underlineChars,rst.currLevel,rst.currLevel) + end + rst.f:write(s.."\n") + rst.f:write(title.."\n") + rst.f:write(s.."\n") +end +rst.onScope = function(scope,scopeName,typeLookupFn) + assert(scope) + rst.currScope = scope + rst.currLevel = rst.currLevel + 1 + + local title = scopeName + if scope.kind and scope.kind ~= "class" then + title = scope.kind .. ": " .. scopeName + end + + rst.f:write("\n") + rst.underline(title) + + if scope.parents and table.getn(scope.parents) > 0 then + rst.f:write("\n") + local first = true + rst.f:write("**inherits** ") + for k,v in pairs(scope.parents) do + if first then first = false else rst.f:write(", ") end + + local name = typeLookupFn:exec(v) + if name then + rst.f:write("`" .. name .. "`_") + else + rst.f:write(v) + end + end + rst.f:write("\n") + end +end +rst.onBeginProperties = function() + rst.f:write("\n") + rst.f:write("**Properties**\n\n") +end +rst.onProperty = function(name,type,typeLookupFn) + assert( name and type ) + + local ti = type or "unknown" + local custom,_ = typeLookupFn:exec(type) + if custom then + ti = "`"..custom.."`_" + else + ti = "**"..ti.."**" + end + + rst.f:write("* **" .. name .. "** of type " .. ti .. "\n") +end +rst.onEndProperties = function() + rst.f:write("\n") +end +rst.onBeginCodes = function() + rst.f:write("\n") + rst.f:write("**Code**\n\n") +end +rst.onCode = function(name,content) + rst.f:write(" "..(name or "Code") .. "::\n\n") + rst.f:write(content) + rst.f:write("\n") +end +rst.onBeginFunctions = function() + if rst.currScope and rst.currScope.kind and rst.currScope.kind == "class" then + rst.f:write("**Methods**\n\n") + else + rst.f:write("**Functions**\n\n") + end +end + +db.reverseLookupType = function(scopeStack,type) + if not type then return nil end + --print("R",type,scopeStack,getn(scopeStack)) + if not scopeStack or getn(scopeStack) == 1 then return nil end + local scope = scopeStack[ getn(scopeStack)-1 ] + assert( scope ) + if scope.scopes[type] and scope.scopes[type].kind ~= "namespace" then + --print("FOUND") + return type,scope.scopes[type] + end + local newScopes = {} + for k,v in pairs(scopeStack) do + newScopes[k] = v + end + table.remove(newScopes,getn(newScopes)) + return db.reverseLookupType(newScopes,type) +end + +rst.onFunction = function(name,signature,params,codes,typeLookupFn) + assert( name and signature ) + + -- signature + rst.f:write("* **" .. name .. "("); + if params and getn(params) > 0 then + local first = true + for _,p in pairs(params) do + if first then first=false else rst.f:write(",") end + rst.f:write(p.name) + end + end + rst.f:write(")**\n\n") + + -- param info + if params and getn(params) > 0 then + rst.f:write(" Parameters\n") + for _,p in pairs(params) do + local ti = p.type or "unknown" + local custom,_ = typeLookupFn(p.type) + if custom then + ti = "`"..custom.."`_" + else + ti = "**"..ti.."**" + end + rst.f:write("\n " .. "**" .. p.name .. "** of type " .. ti .. "\n") + end + rst.f:write("\n") + end + + -- code + if codes and getn(codes) > 0 then + rst.f:write(" Code\n") + for k,v in pairs(codes) do + rst.onCode(k,v) + end + end +end +rst.onEndFunctions = function() + rst.f:write("\n") +end +rst.onLeaveScope = function() + rst.currLevel = rst.currLevel - 1 + rst.currScope = nil +end + +function dumpScope(parents,scope,scopeName,lvl) + if lvl then lvl = lvl .. " " else lvl = "" end + assert(scope) + assert(scopeName) + + local typeLookup = { stack = parents } + typeLookup.exec = function(self,t) + return db.reverseLookupType(self.stack,t) + end + + -- + rst.onScope(scope,scopeName,typeLookup) + + local strParents = "" + if scope.parents and table.getn(scope.parents) > 0 then + for k,v in pairs(scope.parents) do + if string.len(strParents) > 0 then strParents = strParents .. "," end + strParents = strParents .. v + end + strParents = ": " .. strParents + end + print(lvl.."SCOPE",scopeName,strParents) + + -- code + if scope.codes and getn(scope.codes) > 0 then + rst.onBeginCodes() + for k,v in pairs(scope.codes) do + rst.onCode(k,v) + end + end + + -- properties + if scope.properties and getn(scope.properties) > 0 then + rst.onBeginProperties() + for propName,propType in pairs(scope.properties) do + print(lvl.." PROPERTY " .. propName,"(" .. propType .. ")") + rst.onProperty(propName,propType,typeLookup) + end + rst.onEndProperties() + end + if scope.functions and getn(scope.functions) > 0 then + rst.onBeginFunctions() + for fnName,fnObj in pairs(scope.functions) do + local params = "" + for k,v in pairs(fnObj.params) do + if string.len(params) > 0 then params = params .. "," end + params = params .. k + end + print(lvl.." FUNCTION " .. fnName .. "(" .. params .. ")") + rst.onFunction(fnName,fnObj.signature,fnObj.params,fnObj.codes, + function(type) + return db.reverseLookupType(parents,type) + end + ) + end + rst.onEndFunctions() + end + + local parentsForChilds = parents + table.insert(parentsForChilds,scope) + for k,v in pairs(scope.scopes) do + dumpScope(parentsForChilds,v,k,lvl) + end + + rst.onLeaveScope() +end + +local projName = "project" +rst.open(projName .. ".rst.txt") +local parents = {} +dumpScope(parents,db,projName) +rst.close() Added: tools/luadocs/project.rst.txt =================================================================== --- tools/luadocs/project.rst.txt (rev 0) +++ tools/luadocs/project.rst.txt 2007-08-22 17:36:13 UTC (rev 1802) @@ -0,0 +1,66 @@ + +**************************************** +project +**************************************** + +++++++++++++++++++++++++++++++++++++++++ +namespace: y +++++++++++++++++++++++++++++++++++++++++ + +======================================== +namespace: input +======================================== + +---------------------------------------- +Device +---------------------------------------- + +---------------------------------------- +WhateverDevice +---------------------------------------- + +**inherits** `Device`_, Parent2 + +**Properties** + +* **stuffOk** of type **bool** +* **isOk** of type **bool|readonly** + + +---------------------------------------- +KeyboardDevice +---------------------------------------- + +**inherits** `Device`_ + +**Code** + + Example #1:: + + dev:poll(yeeha) + +**Properties** + +* **enabled** of type **bool** +* **name** of type **string** +* **pseudo** of type `Device`_ + +**Methods** + +* **poll(a,b,c,d)** + + Parameters + + **a** of type **string** + + **b** of type **int** + + **c** of type **unknown** + + **d** of type `Device`_ + + Code + Example for poll():: + + dev:poll(yeeha) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-20 19:53:46
|
Revision: 1801 http://yake.svn.sourceforge.net/yake/?rev=1801&view=rev Author: psyclonist Date: 2007-08-20 12:53:47 -0700 (Mon, 20 Aug 2007) Log Message: ----------- * updated reference to Luabind version Modified Paths: -------------- trunk/yake/BUILD trunk/yake/documentation/manual/yake-manual.txt Modified: trunk/yake/BUILD =================================================================== --- trunk/yake/BUILD 2007-08-19 00:06:49 UTC (rev 1800) +++ trunk/yake/BUILD 2007-08-20 19:53:47 UTC (rev 1801) @@ -84,7 +84,7 @@ * ODE 0.6/0.7 for physicsODE * OGRE 1.4.x+ for graphicsOGRE * Lua 5.x for scriptingLua, entLua etc - * Luabind 0.7+ for scriptingLua, entLua etc + * Luabind (.7+1, i.e. SVN) for scriptingLua, entLua etc * CEGUI 0.5.x * OpenAL 1.1 SDK for audioAL * OpenAL++ Modified: trunk/yake/documentation/manual/yake-manual.txt =================================================================== --- trunk/yake/documentation/manual/yake-manual.txt 2007-08-19 00:06:49 UTC (rev 1800) +++ trunk/yake/documentation/manual/yake-manual.txt 2007-08-20 19:53:47 UTC (rev 1801) @@ -94,7 +94,7 @@ 1. ODE 0.7/0.8 for physicsODE #. OGRE 1.3/1.4 for graphicsOGRE #. Lua 5.x for scriptingLua, entLua etc -#. Luabind 0.7+ for scriptingLua, entLua etc +#. Luabind (0.7+1, i.e. SVN) for scriptingLua, entLua etc #. CEGUI 0.5.x for graphical UI #. OpenAL 1.1 SDK for audioOpenAL #. OpenAL++ for audioOpenAL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-19 00:06:46
|
Revision: 1800 http://yake.svn.sourceforge.net/yake/?rev=1800&view=rev Author: psyclonist Date: 2007-08-18 17:06:49 -0700 (Sat, 18 Aug 2007) Log Message: ----------- * [manual] version 0.7.x Modified Paths: -------------- trunk/yake/documentation/manual/yake-manual.txt Modified: trunk/yake/documentation/manual/yake-manual.txt =================================================================== --- trunk/yake/documentation/manual/yake-manual.txt 2007-08-19 00:06:26 UTC (rev 1799) +++ trunk/yake/documentation/manual/yake-manual.txt 2007-08-19 00:06:49 UTC (rev 1800) @@ -1,5 +1,5 @@ +++++++++++++++++ -Yake 0.6.x Manual +Yake 0.7.x Manual +++++++++++++++++ .. |date| date:: %d %b %Y This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-19 00:06:27
|
Revision: 1799 http://yake.svn.sourceforge.net/yake/?rev=1799&view=rev Author: psyclonist Date: 2007-08-18 17:06:26 -0700 (Sat, 18 Aug 2007) Log Message: ----------- * [manual] clarifications Modified Paths: -------------- trunk/yake/documentation/manual/yake-manual.txt Modified: trunk/yake/documentation/manual/yake-manual.txt =================================================================== --- trunk/yake/documentation/manual/yake-manual.txt 2007-08-18 23:54:05 UTC (rev 1798) +++ trunk/yake/documentation/manual/yake-manual.txt 2007-08-19 00:06:26 UTC (rev 1799) @@ -842,6 +842,11 @@ registered with Lua. Therefore not all types may be available as parameters. If you use an unsupported type execution will stop and an error will be reported. + Note, that the available list of types can be extended by + registering a so-called "any convert". + The register_any_converter<T>() function does all the hard work. + As a side-effect all of the types registered in this fashion are + also automatically available in the yake.property library Lua bindings. Scheduler/Executor .................. @@ -852,7 +857,7 @@ wait(12) --waits 12 application time units before continuing execution print("after") -Schedule a function to be executed after a certain time:: +Schedule a function to be executed after a certain time ('sched' is the scheduler object):: function callback() print("callback triggered") @@ -1043,5 +1048,5 @@ * Forum (http://www.yake.org/forum/ ) * IRC (irc://freenode.net/#yake) -* E-Mail, Instant Messaging, Skype etc. The details are available at the website. +* E-Mail, Jabber, Skype etc. Up-to-date details are available on the website. * Website: http://www.yake.org/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-18 23:54:07
|
Revision: 1798 http://yake.svn.sourceforge.net/yake/?rev=1798&view=rev Author: psyclonist Date: 2007-08-18 16:54:05 -0700 (Sat, 18 Aug 2007) Log Message: ----------- * [tools] added scripts/tools/extract_input_kc.pl * [bindings.lua] input::KeyCode values can now be batch-extracted by running scripts/tools/extract_input_kc.pl Modified Paths: -------------- trunk/yake/src/bindings.lua/detail/input.lua.cpp trunk/yake/yake/input/yakeInputSystem.h Added Paths: ----------- trunk/yake/scripts/tools/extract_input_kc.pl trunk/yake/yake/bindings.lua/detail/input.lua.keycodes.inl Added: trunk/yake/scripts/tools/extract_input_kc.pl =================================================================== --- trunk/yake/scripts/tools/extract_input_kc.pl (rev 0) +++ trunk/yake/scripts/tools/extract_input_kc.pl 2007-08-18 23:54:05 UTC (rev 1798) @@ -0,0 +1,55 @@ +print "Extracting...\n\n"; + +$FILE = "../../yake/input/yakeInputSystem.h"; +$OUTFILE = ">../../yake/bindings.lua/detail/input.lua.keycodes.inl"; + +open OUT, $OUTFILE or die("Could not open '$OUT'."); + +$FIND = "enum KeyCode"; +$stage = "enumsearch"; + +$luatpl = "luabind::globals(L)[\"yake\"][\"input\"][\"%ID%\"] = %VALUE%;"; + +print($luatpl); + +open(FILE) or die("Could not open '$FILE'."); +foreach $line (<FILE>) { + #print($line); + chomp($line); # remove newline + if ($stage =~ m/enumsearch/) + { + if ($line =~ m/$FIND/) + { + #print("found"); + $stage = "extract"; + } + } + elsif ($stage =~ m/extract/) + { + if ($line =~ m/}/) + { + last; + } + #print($line); + ($id,$value) = split(' ',$line); + if (length($value) == 0) + { + next; + } + # value typically has the form: =0xCA, + #$value =~ s/=//; # remove = + #$value =~ s/,//; # remove , + + $decl = $luatpl; + $decl =~ s/%ID%/$id/; + $decl =~ s/%VALUE%/$id/; + print($decl,"\n"); + print OUT $decl,"\n"; + + #print($id, " => ", $value, "\n"); + print() + } +} +close(FILE); +close(OUT); + Modified: trunk/yake/src/bindings.lua/detail/input.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/detail/input.lua.cpp 2007-08-18 21:25:29 UTC (rev 1797) +++ trunk/yake/src/bindings.lua/detail/input.lua.cpp 2007-08-18 23:54:05 UTC (rev 1798) @@ -196,11 +196,7 @@ luabind::globals(L)["yake"]["input"]["ACTIONID_FIRE2"] = ACTIONID_FIRE2; luabind::globals(L)["yake"]["input"]["ACTIONID_USER"] = ACTIONID_USER; - luabind::globals(L)["yake"]["input"]["KC_ESCAPE"] = KC_ESCAPE; - luabind::globals(L)["yake"]["input"]["KC_LEFT"] = KC_LEFT; - luabind::globals(L)["yake"]["input"]["KC_RIGHT"] = KC_RIGHT; - luabind::globals(L)["yake"]["input"]["KC_UP"] = KC_UP; - luabind::globals(L)["yake"]["input"]["KC_DOWN"] = KC_DOWN; +#include "yake/bindings.lua/detail/input.lua.keycodes.inl" } YAKE_WRAP_BINDER(input,::yake::input::bind); Added: trunk/yake/yake/bindings.lua/detail/input.lua.keycodes.inl =================================================================== --- trunk/yake/yake/bindings.lua/detail/input.lua.keycodes.inl (rev 0) +++ trunk/yake/yake/bindings.lua/detail/input.lua.keycodes.inl 2007-08-18 23:54:05 UTC (rev 1798) @@ -0,0 +1,144 @@ +luabind::globals(L)["yake"]["input"]["KC_ESCAPE"] = KC_ESCAPE; +luabind::globals(L)["yake"]["input"]["KC_1"] = KC_1; +luabind::globals(L)["yake"]["input"]["KC_2"] = KC_2; +luabind::globals(L)["yake"]["input"]["KC_3"] = KC_3; +luabind::globals(L)["yake"]["input"]["KC_4"] = KC_4; +luabind::globals(L)["yake"]["input"]["KC_5"] = KC_5; +luabind::globals(L)["yake"]["input"]["KC_6"] = KC_6; +luabind::globals(L)["yake"]["input"]["KC_7"] = KC_7; +luabind::globals(L)["yake"]["input"]["KC_8"] = KC_8; +luabind::globals(L)["yake"]["input"]["KC_9"] = KC_9; +luabind::globals(L)["yake"]["input"]["KC_0"] = KC_0; +luabind::globals(L)["yake"]["input"]["KC_MINUS"] = KC_MINUS; +luabind::globals(L)["yake"]["input"]["KC_EQUALS"] = KC_EQUALS; +luabind::globals(L)["yake"]["input"]["KC_BACK"] = KC_BACK; +luabind::globals(L)["yake"]["input"]["KC_TAB"] = KC_TAB; +luabind::globals(L)["yake"]["input"]["KC_Q"] = KC_Q; +luabind::globals(L)["yake"]["input"]["KC_W"] = KC_W; +luabind::globals(L)["yake"]["input"]["KC_E"] = KC_E; +luabind::globals(L)["yake"]["input"]["KC_R"] = KC_R; +luabind::globals(L)["yake"]["input"]["KC_T"] = KC_T; +luabind::globals(L)["yake"]["input"]["KC_Y"] = KC_Y; +luabind::globals(L)["yake"]["input"]["KC_U"] = KC_U; +luabind::globals(L)["yake"]["input"]["KC_I"] = KC_I; +luabind::globals(L)["yake"]["input"]["KC_O"] = KC_O; +luabind::globals(L)["yake"]["input"]["KC_P"] = KC_P; +luabind::globals(L)["yake"]["input"]["KC_LBRACKET"] = KC_LBRACKET; +luabind::globals(L)["yake"]["input"]["KC_RBRACKET"] = KC_RBRACKET; +luabind::globals(L)["yake"]["input"]["KC_RETURN"] = KC_RETURN; +luabind::globals(L)["yake"]["input"]["KC_LCONTROL"] = KC_LCONTROL; +luabind::globals(L)["yake"]["input"]["KC_A"] = KC_A; +luabind::globals(L)["yake"]["input"]["KC_S"] = KC_S; +luabind::globals(L)["yake"]["input"]["KC_D"] = KC_D; +luabind::globals(L)["yake"]["input"]["KC_F"] = KC_F; +luabind::globals(L)["yake"]["input"]["KC_G"] = KC_G; +luabind::globals(L)["yake"]["input"]["KC_H"] = KC_H; +luabind::globals(L)["yake"]["input"]["KC_J"] = KC_J; +luabind::globals(L)["yake"]["input"]["KC_K"] = KC_K; +luabind::globals(L)["yake"]["input"]["KC_L"] = KC_L; +luabind::globals(L)["yake"]["input"]["KC_SEMICOLON"] = KC_SEMICOLON; +luabind::globals(L)["yake"]["input"]["KC_APOSTROPHE"] = KC_APOSTROPHE; +luabind::globals(L)["yake"]["input"]["KC_GRAVE"] = KC_GRAVE; +luabind::globals(L)["yake"]["input"]["KC_LSHIFT"] = KC_LSHIFT; +luabind::globals(L)["yake"]["input"]["KC_BACKSLASH"] = KC_BACKSLASH; +luabind::globals(L)["yake"]["input"]["KC_Z"] = KC_Z; +luabind::globals(L)["yake"]["input"]["KC_X"] = KC_X; +luabind::globals(L)["yake"]["input"]["KC_C"] = KC_C; +luabind::globals(L)["yake"]["input"]["KC_V"] = KC_V; +luabind::globals(L)["yake"]["input"]["KC_B"] = KC_B; +luabind::globals(L)["yake"]["input"]["KC_N"] = KC_N; +luabind::globals(L)["yake"]["input"]["KC_M"] = KC_M; +luabind::globals(L)["yake"]["input"]["KC_COMMA"] = KC_COMMA; +luabind::globals(L)["yake"]["input"]["KC_PERIOD"] = KC_PERIOD; +luabind::globals(L)["yake"]["input"]["KC_SLASH"] = KC_SLASH; +luabind::globals(L)["yake"]["input"]["KC_RSHIFT"] = KC_RSHIFT; +luabind::globals(L)["yake"]["input"]["KC_MULTIPLY"] = KC_MULTIPLY; +luabind::globals(L)["yake"]["input"]["KC_LMENU"] = KC_LMENU; +luabind::globals(L)["yake"]["input"]["KC_SPACE"] = KC_SPACE; +luabind::globals(L)["yake"]["input"]["KC_CAPITAL"] = KC_CAPITAL; +luabind::globals(L)["yake"]["input"]["KC_F1"] = KC_F1; +luabind::globals(L)["yake"]["input"]["KC_F2"] = KC_F2; +luabind::globals(L)["yake"]["input"]["KC_F3"] = KC_F3; +luabind::globals(L)["yake"]["input"]["KC_F4"] = KC_F4; +luabind::globals(L)["yake"]["input"]["KC_F5"] = KC_F5; +luabind::globals(L)["yake"]["input"]["KC_F6"] = KC_F6; +luabind::globals(L)["yake"]["input"]["KC_F7"] = KC_F7; +luabind::globals(L)["yake"]["input"]["KC_F8"] = KC_F8; +luabind::globals(L)["yake"]["input"]["KC_F9"] = KC_F9; +luabind::globals(L)["yake"]["input"]["KC_F10"] = KC_F10; +luabind::globals(L)["yake"]["input"]["KC_NUMLOCK"] = KC_NUMLOCK; +luabind::globals(L)["yake"]["input"]["KC_SCROLL"] = KC_SCROLL; +luabind::globals(L)["yake"]["input"]["KC_NUMPAD7"] = KC_NUMPAD7; +luabind::globals(L)["yake"]["input"]["KC_NUMPAD8"] = KC_NUMPAD8; +luabind::globals(L)["yake"]["input"]["KC_NUMPAD9"] = KC_NUMPAD9; +luabind::globals(L)["yake"]["input"]["KC_SUBTRACT"] = KC_SUBTRACT; +luabind::globals(L)["yake"]["input"]["KC_NUMPAD4"] = KC_NUMPAD4; +luabind::globals(L)["yake"]["input"]["KC_NUMPAD5"] = KC_NUMPAD5; +luabind::globals(L)["yake"]["input"]["KC_NUMPAD6"] = KC_NUMPAD6; +luabind::globals(L)["yake"]["input"]["KC_ADD"] = KC_ADD; +luabind::globals(L)["yake"]["input"]["KC_NUMPAD1"] = KC_NUMPAD1; +luabind::globals(L)["yake"]["input"]["KC_NUMPAD2"] = KC_NUMPAD2; +luabind::globals(L)["yake"]["input"]["KC_NUMPAD3"] = KC_NUMPAD3; +luabind::globals(L)["yake"]["input"]["KC_NUMPAD0"] = KC_NUMPAD0; +luabind::globals(L)["yake"]["input"]["KC_DECIMAL"] = KC_DECIMAL; +luabind::globals(L)["yake"]["input"]["KC_OEM_102"] = KC_OEM_102; +luabind::globals(L)["yake"]["input"]["KC_F11"] = KC_F11; +luabind::globals(L)["yake"]["input"]["KC_F12"] = KC_F12; +luabind::globals(L)["yake"]["input"]["KC_F13"] = KC_F13; +luabind::globals(L)["yake"]["input"]["KC_F14"] = KC_F14; +luabind::globals(L)["yake"]["input"]["KC_F15"] = KC_F15; +luabind::globals(L)["yake"]["input"]["KC_KANA"] = KC_KANA; +luabind::globals(L)["yake"]["input"]["KC_ABNT_C1"] = KC_ABNT_C1; +luabind::globals(L)["yake"]["input"]["KC_CONVERT"] = KC_CONVERT; +luabind::globals(L)["yake"]["input"]["KC_NOCONVERT"] = KC_NOCONVERT; +luabind::globals(L)["yake"]["input"]["KC_YEN"] = KC_YEN; +luabind::globals(L)["yake"]["input"]["KC_ABNT_C2"] = KC_ABNT_C2; +luabind::globals(L)["yake"]["input"]["KC_NUMPADEQUALS"] = KC_NUMPADEQUALS; +luabind::globals(L)["yake"]["input"]["KC_PREVTRACK"] = KC_PREVTRACK; +luabind::globals(L)["yake"]["input"]["KC_AT"] = KC_AT; +luabind::globals(L)["yake"]["input"]["KC_COLON"] = KC_COLON; +luabind::globals(L)["yake"]["input"]["KC_UNDERLINE"] = KC_UNDERLINE; +luabind::globals(L)["yake"]["input"]["KC_KANJI"] = KC_KANJI; +luabind::globals(L)["yake"]["input"]["KC_STOP"] = KC_STOP; +luabind::globals(L)["yake"]["input"]["KC_AX"] = KC_AX; +luabind::globals(L)["yake"]["input"]["KC_UNLABELED"] = KC_UNLABELED; +luabind::globals(L)["yake"]["input"]["KC_NEXTTRACK"] = KC_NEXTTRACK; +luabind::globals(L)["yake"]["input"]["KC_NUMPADENTER"] = KC_NUMPADENTER; +luabind::globals(L)["yake"]["input"]["KC_RCONTROL"] = KC_RCONTROL; +luabind::globals(L)["yake"]["input"]["KC_MUTE"] = KC_MUTE; +luabind::globals(L)["yake"]["input"]["KC_CALCULATOR"] = KC_CALCULATOR; +luabind::globals(L)["yake"]["input"]["KC_PLAYPAUSE"] = KC_PLAYPAUSE; +luabind::globals(L)["yake"]["input"]["KC_MEDIASTOP"] = KC_MEDIASTOP; +luabind::globals(L)["yake"]["input"]["KC_VOLUMEDOWN"] = KC_VOLUMEDOWN; +luabind::globals(L)["yake"]["input"]["KC_VOLUMEUP"] = KC_VOLUMEUP; +luabind::globals(L)["yake"]["input"]["KC_WEBHOME"] = KC_WEBHOME; +luabind::globals(L)["yake"]["input"]["KC_NUMPADCOMMA"] = KC_NUMPADCOMMA; +luabind::globals(L)["yake"]["input"]["KC_DIVIDE"] = KC_DIVIDE; +luabind::globals(L)["yake"]["input"]["KC_SYSRQ"] = KC_SYSRQ; +luabind::globals(L)["yake"]["input"]["KC_RMENU"] = KC_RMENU; +luabind::globals(L)["yake"]["input"]["KC_PAUSE"] = KC_PAUSE; +luabind::globals(L)["yake"]["input"]["KC_HOME"] = KC_HOME; +luabind::globals(L)["yake"]["input"]["KC_UP"] = KC_UP; +luabind::globals(L)["yake"]["input"]["KC_PGUP"] = KC_PGUP; +luabind::globals(L)["yake"]["input"]["KC_LEFT"] = KC_LEFT; +luabind::globals(L)["yake"]["input"]["KC_RIGHT"] = KC_RIGHT; +luabind::globals(L)["yake"]["input"]["KC_END"] = KC_END; +luabind::globals(L)["yake"]["input"]["KC_DOWN"] = KC_DOWN; +luabind::globals(L)["yake"]["input"]["KC_PGDOWN"] = KC_PGDOWN; +luabind::globals(L)["yake"]["input"]["KC_INSERT"] = KC_INSERT; +luabind::globals(L)["yake"]["input"]["KC_DELETE"] = KC_DELETE; +luabind::globals(L)["yake"]["input"]["KC_LWIN"] = KC_LWIN; +luabind::globals(L)["yake"]["input"]["KC_RWIN"] = KC_RWIN; +luabind::globals(L)["yake"]["input"]["KC_APPS"] = KC_APPS; +luabind::globals(L)["yake"]["input"]["KC_POWER"] = KC_POWER; +luabind::globals(L)["yake"]["input"]["KC_SLEEP"] = KC_SLEEP; +luabind::globals(L)["yake"]["input"]["KC_WAKE"] = KC_WAKE; +luabind::globals(L)["yake"]["input"]["KC_WEBSEARCH"] = KC_WEBSEARCH; +luabind::globals(L)["yake"]["input"]["KC_WEBFAVORITES"] = KC_WEBFAVORITES; +luabind::globals(L)["yake"]["input"]["KC_WEBREFRESH"] = KC_WEBREFRESH; +luabind::globals(L)["yake"]["input"]["KC_WEBSTOP"] = KC_WEBSTOP; +luabind::globals(L)["yake"]["input"]["KC_WEBFORWARD"] = KC_WEBFORWARD; +luabind::globals(L)["yake"]["input"]["KC_WEBBACK"] = KC_WEBBACK; +luabind::globals(L)["yake"]["input"]["KC_MYCOMPUTER"] = KC_MYCOMPUTER; +luabind::globals(L)["yake"]["input"]["KC_MAIL"] = KC_MAIL; +luabind::globals(L)["yake"]["input"]["KC_MEDIASELECT"] = KC_MEDIASELECT; Modified: trunk/yake/yake/input/yakeInputSystem.h =================================================================== --- trunk/yake/yake/input/yakeInputSystem.h 2007-08-18 21:25:29 UTC (rev 1797) +++ trunk/yake/yake/input/yakeInputSystem.h 2007-08-18 23:54:05 UTC (rev 1798) @@ -36,6 +36,12 @@ // Keyboard scan codes - copied from DirectInput for now for speed. // (SK: actually I copied them from Ogre again...) + // + // NB For the Lua bindings we parse this header and extract the + // key codes. This is done by: scripts/tools/extract_input_kc.pl + // + // If this enum is updated, remember to run this script (and commit + // the changes to the source repository, too)! enum KeyCode { KC_ESCAPE =0x01, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-18 21:26:54
|
Revision: 1797 http://yake.svn.sourceforge.net/yake/?rev=1797&view=rev Author: psyclonist Date: 2007-08-18 14:25:29 -0700 (Sat, 18 Aug 2007) Log Message: ----------- * [sample] raf/lua1: graphics + input completely handled from Lua now * [bindings.lua] added bindings for yake.input * [bindings.lua] improved bindings for Vector3, Matrix3 and Quaternion * [input] small non-breaking improvements in the ActionMap API Modified Paths: -------------- trunk/yake/common/media/scripts/raf1.lua trunk/yake/samples/raf/lua1/demo.cpp trunk/yake/samples/task/demo1/demo.cpp trunk/yake/scripts/premake/config.lua trunk/yake/scripts/premake/yake.lua trunk/yake/src/bindings.lua/bindings.lua.cpp trunk/yake/src/bindings.lua/detail/base.lua.cpp trunk/yake/src/input/yakeActionMap.cpp trunk/yake/yake/bindings.lua/bindings.lua.h trunk/yake/yake/input/yakeActionMap.h Added Paths: ----------- trunk/yake/src/bindings.lua/detail/input.lua.cpp Modified: trunk/yake/common/media/scripts/raf1.lua =================================================================== --- trunk/yake/common/media/scripts/raf1.lua 2007-08-17 19:20:50 UTC (rev 1796) +++ trunk/yake/common/media/scripts/raf1.lua 2007-08-18 21:25:29 UTC (rev 1797) @@ -1,6 +1,12 @@ local gworld = scene.gworld local defaultCam = scene.activeCamera +local actionMap = app.actionMap +local input = yake.input +-------------------------------------- +-- Configure graphics +-------------------------------------- + -- configure basic scene properties gworld:setShadowsEnabled(false) gworld:setAmbientLight(yake.Color(0,0,0,1)) @@ -10,17 +16,74 @@ local e = gworld:createEntity("ninja.mesh") sn:attach(e) --- create direction light -local lightnode = gworld:createSceneNode() -local l = gworld:createLight() -lightnode:attach(l) -l.type = yake.graphics.Light.LT_DIRECTIONAL -l:setDiffuseColour(yake.Color(1,1,1,1)) -l.direction = yake.Vector3(0,-1,1) +-- create directional light --- +local light = gworld:createLight() -- create light + +local lightnode = gworld:createSceneNode() -- attach light to node +lightnode:attach(light) + +light.type = yake.graphics.Light.LT_DIRECTIONAL -- configure light +light:setDiffuseColour(yake.Color(1,1,1,1)) +light.direction = yake.Vector3(0,-1,1) + +-- configure active (=default) camera + local cam = scene.activeCamera assert(cam) cam.position = yake.Vector3(100,20,-200) -cam:setFixedYawAxis( yake.Vector3.UnitY ) -cam:lookAt( yake.Vector3(0,100,0) ) +cam:setFixedYawAxis( yake.Vector3.UnitY ) -- keep upwards direction constant +cam:lookAt( yake.Vector3(0,100,0) ) -- look at our ninja! + +-------------------------------------- +-- Configure input +-------------------------------------- + +-- We demonstrate two ways to bind Lua callbacks to a keyboard action. +-- #1 demonstrates the details +-- #2 shows how to achieve the same thing fast and Lua-style + +------ #1: "The Long Way" + +--local idLeft = input.ActionId.fromName("left") -- look up ActionId by its name (useful for user-defined ones) +local idLeft = input.ACTIONID_LEFT -- using an ActionId constant + +-- Connect key "Cursor Left" to action "left": +local acLeft = input.KeyboardActionCondition(app.keyboard, input.KC_LEFT, input.KAM_CONTINUOUS) +actionMap:reg(idLeft,acLeft) + +-- Our Lua callback handler: +function onLeft() + cam:translate(yake.Vector3(-1,0,0)) +end + +actionMap:connectToAction(idLeft,onLeft) -- by Action ID + +------ #2: "Shortcut" (using action names and anonymous Lua functions) + +actionMap:reg("right", input.KeyboardActionCondition(app.keyboard, input.KC_RIGHT, input.KAM_CONTINUOUS)) +actionMap:connectToAction("right", + function() + cam:translate(yake.Vector3(1,0,0)) + end) + +------- Let's define a few helper functions to make things easier: + +function createKeyAction(action, key, keymode) + return actionMap:reg(action, input.KeyboardActionCondition(app.keyboard, key, keymode )) +end +function bindAction(action, handler) + return actionMap:connectToAction(action, handler) +end + +------- Bind the rest of the keys to actions: + +createKeyAction("forward", input.KC_UP, input.KAM_CONTINUOUS) +bindAction("forward", function() + cam:translate(yake.Vector3(0,0,-1)) + end) + +createKeyAction("reverse", input.KC_DOWN, input.KAM_CONTINUOUS) +bindAction("reverse", function() + cam:translate(yake.Vector3(0,0,1)) + end) Modified: trunk/yake/samples/raf/lua1/demo.cpp =================================================================== --- trunk/yake/samples/raf/lua1/demo.cpp 2007-08-17 19:20:50 UTC (rev 1796) +++ trunk/yake/samples/raf/lua1/demo.cpp 2007-08-18 21:25:29 UTC (rev 1797) @@ -38,36 +38,59 @@ enableInstantQuitByKey( input::KC_ESCAPE ); } protected: + virtual void onEnter() + { + raf::RtMainState::onEnter(); + actionMap_.start(); + } + virtual void onExit() + { + raf::RtMainState::onExit(); + actionMap_.stop(); + + actionMap_.clear(); // Do NOT forget to clear this! Otherwise we keep references to + // the callback functions created from the Lua VM which is about to + // be destroyed, too! + // @todo find a nice solution to this + vm_.reset(); // destroy the VM *before* the ActionMap gets destroyed! + } virtual void onCreateScene() { YAKE_LOG_INFORMATION("demo","Creating scene"); scripting::IScriptingSystem* sys = app_.getScriptingSystem(); YAKE_ASSERT( sys ); - scripting::VMPtr vm = sys->createVM(); - bind_all(vm.get()); + YAKE_ASSERT( !vm_ ); + vm_ = sys->createVM(); + bind_all(vm_.get()); //bind { - scripting::LuaVM* lvm = static_cast<scripting::LuaVM*>(vm.get()); - luabind::globals(lvm->getLuaState())["app"] = &app_; + scripting::LuaVM* lvm = static_cast<scripting::LuaVM*>(vm_.get()); + lua_State* L = lvm->getLuaState(); + luabind::globals(L)["app"] = &app_; - luabind::object scene = luabind::newtable(lvm->getLuaState()); + luabind::globals(L)["app"]["actionMap"] = &actionMap_; + + luabind::object scene = luabind::newtable(L); scene["gworld"] = this->getGraphicalWorld(); scene["activeCamera"] = this->getDefaultCamera(); - luabind::globals(lvm->getLuaState())["scene"] = scene; + luabind::globals(L)["scene"] = scene; } // Create ninja model, position camera and look at the ninja: All done in Lua script: scripting::ScriptPtr script = sys->createScriptFromFile("../../../common/media/scripts/raf1.lua"); - vm->execute( script ); + vm_->execute( script ); } virtual void onFrame(const real timeElapsed) { + actionMap_.update(); //@todo here OK? ... } private: raf::Application& app_; + input::ActionMap actionMap_; + scripting::VMPtr vm_; }; /** The mighty application itself! */ Modified: trunk/yake/samples/task/demo1/demo.cpp =================================================================== --- trunk/yake/samples/task/demo1/demo.cpp 2007-08-17 19:20:50 UTC (rev 1796) +++ trunk/yake/samples/task/demo1/demo.cpp 2007-08-18 21:25:29 UTC (rev 1797) @@ -30,7 +30,7 @@ // run executor for (size_t t=0; t<10; ++t) - exec->update(1); - + exec->update(1); + return 0; } Modified: trunk/yake/scripts/premake/config.lua =================================================================== --- trunk/yake/scripts/premake/config.lua 2007-08-17 19:20:50 UTC (rev 1796) +++ trunk/yake/scripts/premake/config.lua 2007-08-18 21:25:29 UTC (rev 1797) @@ -56,6 +56,7 @@ ENABLE_LUA_ENT = true -- 'ent' binder (requires BASE, MODEL and PROPERTY binders!) ENABLE_LUA_GRAPHICS = true ENABLE_LUA_PHYSICS = true +ENABLE_LUA_INPUT = true ENABLE_LUA_RAF = true -------------------------------------- Modified: trunk/yake/scripts/premake/yake.lua =================================================================== --- trunk/yake/scripts/premake/yake.lua 2007-08-17 19:20:50 UTC (rev 1796) +++ trunk/yake/scripts/premake/yake.lua 2007-08-18 21:25:29 UTC (rev 1797) @@ -75,6 +75,7 @@ f:write("#define YAKE_ENABLE_LUA_PROPERTY " .. bool_to_int(ENABLE_LUA_PROPERTY) .. "\n") f:write("#define YAKE_ENABLE_LUA_GRAPHICS " .. bool_to_int(ENABLE_LUA_GRAPHICS) .. "\n") f:write("#define YAKE_ENABLE_LUA_PHYSICS " .. bool_to_int(ENABLE_LUA_PHYSICS) .. "\n") + f:write("#define ENABLE_LUA_INPUT " .. bool_to_int(ENABLE_LUA_INPUT) .. "\n") f:write("#define YAKE_ENABLE_LUA_RAF " .. bool_to_int(ENABLE_LUA_RAF) .. "\n") f:write("\n") f:write("#endif\n") @@ -251,10 +252,13 @@ if ENABLE_LUA_PHYSICS then addDependency("physics") end + if ENABLE_LUA_INPUT then + addDependency("input") + end if ENABLE_LUA_RAF then addDependency("raf") end - if (windows) then + if (windows) then --@todo still required? or does this get picked up automatically already? useDep("lua") useDep("luabind") end Modified: trunk/yake/src/bindings.lua/bindings.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/bindings.lua.cpp 2007-08-17 19:20:50 UTC (rev 1796) +++ trunk/yake/src/bindings.lua/bindings.lua.cpp 2007-08-18 21:25:29 UTC (rev 1797) @@ -82,6 +82,9 @@ #if YAKE_ENABLE_LUA_PHYSICS == 1 bind_physics(L); #endif +#if YAKE_ENABLE_LUA_INPUT == 1 + bind_input(L); +#endif #if YAKE_ENABLE_LUA_RAF == 1 bind_raf(L); #endif Modified: trunk/yake/src/bindings.lua/detail/base.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-08-17 19:20:50 UTC (rev 1796) +++ trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-08-18 21:25:29 UTC (rev 1797) @@ -128,6 +128,7 @@ .def(const_self * other<real>()) .def(const_self * Quaternion()) .def(const_self * Matrix3()) + .def(tostring(const_self)) ]; luabind::globals(L)["yake"]["Vector3"]["Zero"] = Vector3::kZero; luabind::globals(L)["yake"]["Vector3"]["UnitScale"] = Vector3::kUnitScale; @@ -153,7 +154,10 @@ .def( constructor< Matrix3 const& >() ) .def( "getColumn", &Matrix3::GetColumn ) .def(const_self * other<Matrix3>()) + .def(tostring(const_self)) ]; + luabind::globals(L)["yake"]["Matrix3"]["Zero"] = Matrix3::ZERO; + luabind::globals(L)["yake"]["Matrix3"]["Identity"] = Matrix3::IDENTITY; // Quaternion module( YAKE_MATH_MODULE ) @@ -168,6 +172,8 @@ .def("inverse", &Quaternion::Inverse) .def(const_self * other<Quaternion>()) ]; + luabind::globals(L)["yake"]["Quaternion"]["Zero"] = Quaternion::kZero; + luabind::globals(L)["yake"]["Quaternion"]["Identity"] = Quaternion::kIdentity; // Ray module( YAKE_MATH_MODULE ) Added: trunk/yake/src/bindings.lua/detail/input.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/detail/input.lua.cpp (rev 0) +++ trunk/yake/src/bindings.lua/detail/input.lua.cpp 2007-08-18 21:25:29 UTC (rev 1797) @@ -0,0 +1,221 @@ +/* + ------------------------------------------------------------------------------------ + This file is part of YAKE + Copyright (c) 2004 - 2008 The YAKE Team + For the latest information visit http://www.yake.org + ------------------------------------------------------------------------------------ + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA, or go to + http://www.gnu.org/copyleft/lesser.txt. + ------------------------------------------------------------------------------------ + If you are interested in another license model contact the Yake Team via + E-Mail: te...@ya.... + For more information see the LICENSE file in the root directory of the + source code distribution. + ------------------------------------------------------------------------------------ +*/ +#include <yake/config.h> +#if YAKE_ENABLE_LUA_INPUT == 1 + +// See task.lua.cpp +#include <yake/bindings.lua/common/yake.lua.shared_ptr.h> + +#include <yake/bindings.lua/bindings.lua.h> // Don't forget to include this for proper dllexport! + +#include <yake/base/templates/yakeSmartAssert.h> +#include <yake/base/yake.h> +#include <yake/input/yakeInput.h> + +#include <yake/bindings.lua/detail/private.h> +#include <yake/bindings.lua/common/yake.lua.any_converter.h> + +#include <luabind/discard_result_policy.hpp> +#include <luabind/iterator_policy.hpp> +#include <luabind/operator.hpp> +#include <luabind/adopt_policy.hpp> + +namespace yake { +namespace input { + struct NullType {}; + SignalConnection* ActionMap_connectToAction(ActionMap* map, const ActionId& id, luabind::object o) + { + YAKE_ASSERT( map ); + //YAKE_ASSERT( luabind::type(o) == LUA_TFUNCTION ); + if (luabind::type(o) != LUA_TFUNCTION) + return 0; + return new SignalConnection(map->subscribeToActionIdV( id, o )); + } + SignalConnection* ActionMap_connectToActionByName(ActionMap* map, const char* name, luabind::object o) + { + const ActionId id = ActionIdRegistry::getByName(name); + return ActionMap_connectToAction( map, id, o ); + } + SignalConnection* ActionMap_connectToActionResult(ActionMap* map, const ActionId& id, luabind::object o) + { + YAKE_ASSERT( map ); + //YAKE_ASSERT( luabind::type(o) == LUA_TFUNCTION ); + if (luabind::type(o) != LUA_TFUNCTION) + return 0; + return new SignalConnection(map->subscribeToActionIdR( id, o )); + } + ConditionConnection* ActionMap_reg(ActionMap* map, const ActionId & actionId, SharedPtr<ActionCondition> condition) + { + if (!map) + return 0; + if (!condition) + return 0; + return new ConditionConnection( map->reg(actionId, condition) ); + } + ConditionConnection* ActionMap_regByName(ActionMap* map, const char* name, SharedPtr<ActionCondition> condition) + { + const ActionId id = ActionIdRegistry::getByName(name); + return ActionMap_reg( map, id, condition ); + } + luabind::object InputSystem_getAvailableDevices(IInputSystem* sys, lua_State* L) + { + YAKE_ASSERT( sys ); + luabind::object o = luabind::newtable(L); + + IInputSystem::DeviceEntryList devices = sys->getAvailableDevices(); + YAKE_FOR_EACH(IInputSystem::DeviceEntryList::const_iterator, it, devices) + { + const IInputSystem::DeviceListEntry& dev = *it; + o[ dev.name ] = dev.type; + } + + return o; + } + void bind( lua_State* L ) + { + YAKE_ASSERT( L ); + if (!L) + return; + + using namespace luabind; + +#define YAKE_INPUT_MODULE L, "yake" + + module( YAKE_INPUT_MODULE ) + [ + namespace_("input") + [ + class_<NullType>("MouseButton") + .enum_("MouseButton") + [ + value("MBT_LEFT",MBT_LEFT), + value("MBT_RIGHT",MBT_RIGHT), + value("MBT_MIDDLE",MBT_MIDDLE) + ] + , + class_<InputDevice>("InputDevice") + .property("type", &InputDevice::getType) + , + class_<MouseDevice,InputDevice>("MouseDevice") + , + class_<KeyboardDevice,InputDevice>("KeyboardDevice") + , + class_<IInputSystem>("InputSystem") + .def("getAvailableDevices", &InputSystem_getAvailableDevices, raw(_2)) + .def("getDevice", &IInputSystem::getDevice) + .def("activateDevice", &IInputSystem::activateDevice) + , + class_<ActionId>("ActionId") + .property("id", &ActionId::id) + .property("name", &ActionId::getName) + .scope + [ + def("fromName", &ActionIdRegistry::getByName) + ] + , + class_<ActionMap::ActionResult>("ActionResult") + .def_readonly("id", &ActionMap::ActionResult::id) + .def_readonly("signal", &ActionMap::ActionResult::signal) + , + class_<ActionCondition,SharedPtr<ActionCondition> >("ActionCondition") + , + class_<MouseActionCondition,ActionCondition>("MouseActionCondition") + //.def(constructor<MouseDevice*>()) + , + class_<MouseButtonActionCondition,MouseActionCondition>("MouseButtonActionCondition") + .def(constructor<MouseDevice*,MouseButton,MouseButtonActionMode>()) + , + class_<KeyboardActionCondition,ActionCondition,SharedPtr<ActionCondition> >("KeyboardActionCondition") + .def(constructor<KeyboardDevice*,KeyCode,KeyboardActionMode>()) + .def("setKey", &KeyboardActionCondition::setKey) + .def("setMode", &KeyboardActionCondition::setMode) + , + class_<ConditionConnection>("ConditionConnection") + .def("disconnect",&ConditionConnection::disconnect) + , + class_<SignalConnection>("SignalConnection") //@todo move out from "yake.input" into "yake" + .def("disconnect",&SignalConnection::disconnect) + , + class_<ActionMap>("ActionMap") + .def("start", &ActionMap::start) + .def("stop", &ActionMap::stop) + .def("clear", &ActionMap::clear) + .def("connectToAction", &ActionMap_connectToAction, adopt(result)) + .def("connectToAction", &ActionMap_connectToActionByName, adopt(result)) + .def("connectToActionResult", &ActionMap_connectToActionResult, adopt(result)) + .def("reg", &ActionMap_reg, adopt(result)) + .def("reg", &ActionMap_regByName, adopt(result)) + .def("save", &ActionMap::saveToFile) + ] + ]; + luabind::globals(L)["yake"]["input"]["KAM_CONTINUOUS"] = KAM_CONTINUOUS; + luabind::globals(L)["yake"]["input"]["KAM_PRESSED"] = KAM_PRESSED; + luabind::globals(L)["yake"]["input"]["KAM_RELEASED"] = KAM_RELEASED; + luabind::globals(L)["yake"]["input"]["KAM_PRESSED_AND_RELEASED"] = KAM_PRESSED_AND_RELEASED; + + //@todo keep this in sync with yake/input/yakeActionMap.h: + luabind::globals(L)["yake"]["input"]["ACTIONID_NONE"] = ACTIONID_NONE; + luabind::globals(L)["yake"]["input"]["ACTIONID_FORWARD"] = ACTIONID_FORWARD; + luabind::globals(L)["yake"]["input"]["ACTIONID_REVERSE"] = ACTIONID_REVERSE; + luabind::globals(L)["yake"]["input"]["ACTIONID_STRAFE_LEFT"] = ACTIONID_STRAFE_LEFT; + luabind::globals(L)["yake"]["input"]["ACTIONID_STRAFE_RIGHT"] = ACTIONID_STRAFE_RIGHT; + luabind::globals(L)["yake"]["input"]["ACTIONID_ROTATE_LEFT"] = ACTIONID_ROTATE_LEFT; + luabind::globals(L)["yake"]["input"]["ACTIONID_ROTATE_RIGHT"] = ACTIONID_ROTATE_RIGHT; + luabind::globals(L)["yake"]["input"]["ACTIONID_UP"] = ACTIONID_UP; + luabind::globals(L)["yake"]["input"]["ACTIONID_DOWN"] = ACTIONID_DOWN; + luabind::globals(L)["yake"]["input"]["ACTIONID_LEFT"] = ACTIONID_LEFT; + luabind::globals(L)["yake"]["input"]["ACTIONID_RIGHT"] = ACTIONID_RIGHT; + luabind::globals(L)["yake"]["input"]["ACTIONID_PITCH_UP"] = ACTIONID_PITCH_UP; + luabind::globals(L)["yake"]["input"]["ACTIONID_PITCH_DOWN"] = ACTIONID_PITCH_DOWN; + luabind::globals(L)["yake"]["input"]["ACTIONID_USE"] = ACTIONID_USE; + luabind::globals(L)["yake"]["input"]["ACTIONID_FIRE1"] = ACTIONID_FIRE1; + luabind::globals(L)["yake"]["input"]["ACTIONID_FIRE2"] = ACTIONID_FIRE2; + luabind::globals(L)["yake"]["input"]["ACTIONID_USER"] = ACTIONID_USER; + + luabind::globals(L)["yake"]["input"]["KC_ESCAPE"] = KC_ESCAPE; + luabind::globals(L)["yake"]["input"]["KC_LEFT"] = KC_LEFT; + luabind::globals(L)["yake"]["input"]["KC_RIGHT"] = KC_RIGHT; + luabind::globals(L)["yake"]["input"]["KC_UP"] = KC_UP; + luabind::globals(L)["yake"]["input"]["KC_DOWN"] = KC_DOWN; + } + + YAKE_WRAP_BINDER(input,::yake::input::bind); + +} // namespace input + void bind_input(lua_State* L) + { + YAKE_ASSERT(L); + input::bind(L); + } + void bind_input(scripting::IVM* vm) + { + scripting::LuaVM* luavm = static_cast<scripting::LuaVM*>(vm); + YAKE_ASSERT( luavm ); + bind_input(luavm->getLuaState()); + } +} // namespace yake +#endif // YAKE_ENABLE_LUA_INPUT Modified: trunk/yake/src/input/yakeActionMap.cpp =================================================================== --- trunk/yake/src/input/yakeActionMap.cpp 2007-08-17 19:20:50 UTC (rev 1796) +++ trunk/yake/src/input/yakeActionMap.cpp 2007-08-18 21:25:29 UTC (rev 1797) @@ -668,6 +668,12 @@ //----------------------------------------------------- ConditionConnection ActionMap::reg( const ActionId & actionId, ActionCondition* condition ) { + return this->reg( actionId, SharedPtr<ActionCondition>(condition) ); + } + + //----------------------------------------------------- + ConditionConnection ActionMap::reg( const ActionId & actionId, SharedPtr<ActionCondition> condition ) + { YAKE_ASSERT( condition ); ActionList::iterator it = mEntries.find( actionId ); @@ -675,15 +681,15 @@ { std::pair<ActionList::iterator,bool> vt = mEntries.insert( std::make_pair( actionId, new ActionMapEntry() ) ); YAKE_ASSERT( vt.second ); - vt.first->second->conditions.push_back( SharedPtr<ActionCondition>(condition)); + vt.first->second->conditions.push_back( condition ); } else - it->second->conditions.push_back( SharedPtr<ActionCondition>(condition)); + it->second->conditions.push_back( condition ); if (mProcessingInProgress) condition->onStartConditionProcessing(); - return ConditionConnection(this,actionId,condition); + return ConditionConnection(this,actionId,condition.get()); } //----------------------------------------------------- @@ -789,6 +795,10 @@ //----------------------------------------------------- void ActionMap::start() { + // guard against multiple calls to start(): + if (mProcessingInProgress) + return; + // for (ActionList::const_iterator it = mEntries.begin(); it != mEntries.end(); ++it) { ActionMapEntry* pEntry = it->second.get(); @@ -805,6 +815,10 @@ //----------------------------------------------------- void ActionMap::stop() { + // guard against multiple calls to stop(): + if (!mProcessingInProgress) + return; + // for (ActionList::const_iterator it = mEntries.begin(); it != mEntries.end(); ++it) { ActionMapEntry* pEntry = it->second.get(); Modified: trunk/yake/yake/bindings.lua/bindings.lua.h =================================================================== --- trunk/yake/yake/bindings.lua/bindings.lua.h 2007-08-17 19:20:50 UTC (rev 1796) +++ trunk/yake/yake/bindings.lua/bindings.lua.h 2007-08-18 21:25:29 UTC (rev 1797) @@ -64,6 +64,10 @@ YAKE_BINDINGS_LUA_API void bind_graphics(lua_State*); YAKE_BINDINGS_LUA_API void bind_graphics(scripting::IVM*); #endif +#if YAKE_ENABLE_LUA_INPUT == 1 + YAKE_BINDINGS_LUA_API void bind_input(lua_State*); + YAKE_BINDINGS_LUA_API void bind_input(scripting::IVM*); +#endif #if YAKE_ENABLE_LUA_RAF == 1 YAKE_BINDINGS_LUA_API void bind_raf(lua_State*); YAKE_BINDINGS_LUA_API void bind_raf(scripting::IVM*); Modified: trunk/yake/yake/input/yakeActionMap.h =================================================================== --- trunk/yake/yake/input/yakeActionMap.h 2007-08-17 19:20:50 UTC (rev 1796) +++ trunk/yake/yake/input/yakeActionMap.h 2007-08-18 21:25:29 UTC (rev 1797) @@ -126,7 +126,7 @@ }; enum KeyboardActionMode { - KAM_CONTINUOUS, + KAM_CONTINUOUS = 0, KAM_PRESSED, KAM_RELEASED, KAM_PRESSED_AND_RELEASED @@ -284,6 +284,12 @@ @note Any number of conditions can be registered for a single ActionId. */ ConditionConnection reg( const ActionId & actionId, ActionCondition* condition ); + + /** Add a condition for an action id. + @note Any number of conditions can be registered for a single ActionId. + */ + ConditionConnection reg( const ActionId & actionId, SharedPtr<ActionCondition> condition ); + /*@todo typedef ConditionConnection ConditionConnectionPtr; ConditionConnectionPtr addActionCondition( const ActionId & actionId, ActionCondition* condition ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-17 19:20:48
|
Revision: 1796 http://yake.svn.sourceforge.net/yake/?rev=1796&view=rev Author: psyclonist Date: 2007-08-17 12:20:50 -0700 (Fri, 17 Aug 2007) Log Message: ----------- [samples] raf/lua1: fixed comment Modified Paths: -------------- trunk/yake/samples/raf/lua1/demo.cpp Modified: trunk/yake/samples/raf/lua1/demo.cpp =================================================================== --- trunk/yake/samples/raf/lua1/demo.cpp 2007-08-17 19:19:25 UTC (rev 1795) +++ trunk/yake/samples/raf/lua1/demo.cpp 2007-08-17 19:20:50 UTC (rev 1796) @@ -58,11 +58,10 @@ luabind::globals(lvm->getLuaState())["scene"] = scene; } - // + // Create ninja model, position camera and look at the ninja: All done in Lua script: scripting::ScriptPtr script = sys->createScriptFromFile("../../../common/media/scripts/raf1.lua"); vm->execute( script ); - // position camera and look at the ninja } virtual void onFrame(const real timeElapsed) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-17 19:19:26
|
Revision: 1795 http://yake.svn.sourceforge.net/yake/?rev=1795&view=rev Author: psyclonist Date: 2007-08-17 12:19:25 -0700 (Fri, 17 Aug 2007) Log Message: ----------- [premake] Samples now correctly (& recursively) inherit link dependencies from component dependencies on PC/Windows, too. While this may result in a few superfluous link statements, these will be discarded by the linker, anyway, if not used. But the advantage is that the project dependencies in the Visual c++ solution (.sln) file are correctly set up. Modified Paths: -------------- trunk/yake/scripts/premake/samples.lua trunk/yake/scripts/premake/tools.lua Modified: trunk/yake/scripts/premake/samples.lua =================================================================== --- trunk/yake/scripts/premake/samples.lua 2007-08-17 19:17:01 UTC (rev 1794) +++ trunk/yake/scripts/premake/samples.lua 2007-08-17 19:19:25 UTC (rev 1795) @@ -111,6 +111,9 @@ useComponent("base") useComponent("raf") useComponent("bindings.lua") + --useComponent("scriptingLua") + useDep("lua") + useDep("luabind") end end Modified: trunk/yake/scripts/premake/tools.lua =================================================================== --- trunk/yake/scripts/premake/tools.lua 2007-08-17 19:17:01 UTC (rev 1794) +++ trunk/yake/scripts/premake/tools.lua 2007-08-17 19:19:25 UTC (rev 1795) @@ -8,37 +8,49 @@ -------------------------------------- g_libs = {} function store_current_lib() - --this just references: g_libs[package.name] = package - -- we have to 'copy' (!) to avoid a yake.vcproj and other junk. - - g_libs[package.name] = {} - g_libs[package.name].links = {} - g_libs[package.name].config = {} + --this just references: g_libs[package.name] = package + -- we have to 'copy' (!) to avoid a yake.vcproj and other junk. + + g_libs[package.name] = {} + g_libs[package.name].links = {} + g_libs[package.name].config = {} - for k,lib in package.links do - table.insert( g_libs[package.name].links, lib ) - end + for k,lib in package.links do + table.insert( g_libs[package.name].links, lib ) + end - --print("LIB " .. package.name) - for cfg,v in pairs(package.config) do - if type(cfg) == "string" then - table.insert( g_libs[package.name].config, cfg ) - - g_libs[package.name].config[cfg] = {} - g_libs[package.name].config[cfg].links = {} - if package.config[cfg].links then - for k,lib in pairs(package.config[cfg].links) do - table.insert( g_libs[package.name].config[cfg].links, lib ) - end + --print("LIB " .. package.name) + for cfg,v in pairs(package.config) do + if type(cfg) == "string" then + table.insert( g_libs[package.name].config, cfg ) + + g_libs[package.name].config[cfg] = {} + g_libs[package.name].config[cfg].links = {} + if package.config[cfg].links then + for k,lib in pairs(package.config[cfg].links) do + table.insert( g_libs[package.name].config[cfg].links, lib ) end end end + end end -------------------------------------- -- PUBLIC -------------------------------------- +function tinsert_unique(t,value) + if not t then + return false + end + for k,v in ipairs(t) do + if v == value then + return true + end + end + table.insert(t,value) +end + function addMatching(filter) tinsert(package.files,matchfiles(rootdir..filter)) end @@ -47,13 +59,13 @@ end function addDependency(lib,cfg) if (cfg) then - tinsert(package.config[cfg].links,lib) + tinsert_unique(package.config[cfg].links,lib) else - tinsert(package.links,lib) + tinsert_unique(package.links,lib) end end function addDefine(name) - tinsert(package.defines,name) + tinsert_unique(package.defines,name) end function addIncludePath(path) tinsert(package.includepaths,rootdir..path) @@ -332,37 +344,44 @@ end end -function priv_finishSample_lib(target,linksdone,lib) - --print("lib="..lib) - if g_libs[lib] then -- it's a Yake library - if g_libs[lib].config[target] and g_libs[lib].config[target].links then - for a,b in g_libs[lib].config[target].links do - if not g_libs[b] and not linksdone[b] and not package.config[target].links[b] then -- only non-Yake libraries as Yake libraries are already bound. - --print(" dep " .. b) - --addDependency(b,target) - linksdone[b] = true - end - end - end - for a,b in g_libs[lib].links do - local shouldLink = not package.links[b] and not linksdone[b] - if windows then - -- only non-Yake libraries as Yake libraries are already bound. - shouldLink = shouldLink and not g_libs[b] - end - if shouldLink then - --print(" dep " .. b) - addDependency(b,target) - -- follow the dep's deps... - priv_finishSample_lib(target,linksdone,b) +function priv_finishSample_lib(target,linksdone,lib,level) + level = level or 1 + local indent = "" + for i = 1,level do + indent = indent .. " " + end + -- + print(indent .. "lib="..lib .. " (level " .. tostring(level) .. ")") + if g_libs[lib] then -- it's a Yake library + if g_libs[lib].config[target] and g_libs[lib].config[target].links then + for a,b in g_libs[lib].config[target].links do + if not g_libs[b] and not linksdone[b] and not package.config[target].links[b] then -- only non-Yake libraries as Yake libraries are already bound. + print(indent .. " dep " .. b) + --addDependency(b,target) linksdone[b] = true end end - else -- it's an external lib - --print(" depx " .. lib) - addDependency(lib,target) - linksdone[lib] = true end + for a,b in g_libs[lib].links do + local shouldLink = not package.links[b] and not linksdone[b] + --if windows then + -- only non-Yake libraries as Yake libraries are already bound. + --shouldLink = shouldLink and not g_libs[b] + --end + if shouldLink then + print(indent .. " dep " .. b) + --addDependency(b,target) + addDependency(b) + -- follow the dep's deps... + priv_finishSample_lib(target,linksdone,b,level+1) + linksdone[b] = true + end + end + else -- it's an external lib + print(indent .. " depx " .. lib) + addDependency(lib,target) + linksdone[lib] = true + end end -- In case of static EXE targets we have to link to the -- dependencies of the immediate dependencies, too. @@ -371,7 +390,7 @@ -- Therefore, this function searches these libraries and -- adds them as dependencies to the EXE project for the given target. function priv_finishSample_Target(target) - --print(" TARGET " .. package.name .. " " .. target) + print(" TARGET " .. package.name .. " " .. (target or "ALL TARGETS")) local linkscopy = {} for k,v in pairs(package.links) do @@ -389,7 +408,7 @@ if linksdone[lib] then --print(" skipping " .. lib) else - --print(" applying " .. lib) + print(" applying " .. lib) linksdone[lib] = true priv_finishSample_lib(target,linksdone,lib) @@ -398,13 +417,17 @@ end function priv_finishSample() -- for static link targets only + --@todo priv_finishSample_Target() priv_finishSample_Target("DebugLib") priv_finishSample_Target("ReleaseLib") - if linux then -- for dynamic link targets only on Linux/GCC: + + --NB We now also do this for link targets on Windows/*. + -- This results in properly set project dependencies within the same solution (.sln). + --if linux then -- for dynamic link targets only on Linux/GCC: priv_finishSample_Target("Debug") priv_finishSample_Target("Release") priv_finishSample_Target("ReleaseWithSymbols") - end + --end end local g_first_sample = true This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-17 19:17:03
|
Revision: 1794 http://yake.svn.sourceforge.net/yake/?rev=1794&view=rev Author: psyclonist Date: 2007-08-17 12:17:01 -0700 (Fri, 17 Aug 2007) Log Message: ----------- * [bindings.lua] added Vector3 constants (UnitScale,UnitX,etc) * [bindings.lua] enhanced graphics::ILight bindings Modified Paths: -------------- trunk/yake/src/bindings.lua/detail/base.lua.cpp trunk/yake/src/bindings.lua/detail/graphics.lua.cpp trunk/yake/src/bindings.lua/detail/property.lua.cpp Modified: trunk/yake/src/bindings.lua/detail/base.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-08-17 19:15:52 UTC (rev 1793) +++ trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-08-17 19:17:01 UTC (rev 1794) @@ -129,6 +129,11 @@ .def(const_self * Quaternion()) .def(const_self * Matrix3()) ]; + luabind::globals(L)["yake"]["Vector3"]["Zero"] = Vector3::kZero; + luabind::globals(L)["yake"]["Vector3"]["UnitScale"] = Vector3::kUnitScale; + luabind::globals(L)["yake"]["Vector3"]["UnitX"] = Vector3::kUnitX; + luabind::globals(L)["yake"]["Vector3"]["UnitY"] = Vector3::kUnitY; + luabind::globals(L)["yake"]["Vector3"]["UnitZ"] = Vector3::kUnitZ; // Vector4 module( YAKE_MATH_MODULE ) Modified: trunk/yake/src/bindings.lua/detail/graphics.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/detail/graphics.lua.cpp 2007-08-17 19:15:52 UTC (rev 1793) +++ trunk/yake/src/bindings.lua/detail/graphics.lua.cpp 2007-08-17 19:17:01 UTC (rev 1794) @@ -111,7 +111,7 @@ .property("name", &ILight::getName) .property("type", &ILight::getType, &ILight::setType) .property("direction", &ILight::getDirection, &ILight::setDirection) - //@todo property "enabled" + .property("enabled", &ILight::isEnabled, &ILight::setEnabled) .def("setEnabled", &ILight::setEnabled) .def("setCastsShadows", &ILight::setCastsShadows) .def("setDiffuseColour", &ILight::setDiffuseColour) @@ -132,6 +132,15 @@ class_<ICamera,Movable>("Camera") //@todo .def("lookAt", &ICamera::lookAt) + .def("setFixedYawAxis", &ICamera::setFixedYawAxis) + .def("setFixedYawEnabled", &ICamera::setFixedYawEnabled) + .def("moveRelative", &ICamera::moveRelative) + .def("translate", &ICamera::moveRelative) //alias + .def("pitch", &ICamera::pitch) + .def("yaw", &ICamera::yaw) + .def("roll", &ICamera::roll) + .def("rotate", (void(ICamera::*)(const Quaternion&))&ICamera::rotate) + .def("rotate", (void(ICamera::*)(const Vector3&,real))&ICamera::rotate) .property("aspectRatio", &ICamera::getAspectRatio, &ICamera::setAspectRatio) , class_<IViewport>("Viewport") Modified: trunk/yake/src/bindings.lua/detail/property.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-08-17 19:15:52 UTC (rev 1793) +++ trunk/yake/src/bindings.lua/detail/property.lua.cpp 2007-08-17 19:17:01 UTC (rev 1794) @@ -131,7 +131,7 @@ prop.setAny( value ); return true; } - catch (BadCastException& ex) + catch (BadCastException&) { return false; } @@ -201,4 +201,4 @@ bind_property(luavm->getLuaState()); } } // namespace yake -#endif // YAKE_ENABLE_LUA_PROPERTY +#endif // YAKE_ENABLE_LUA_PROPERTY This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-17 19:15:55
|
Revision: 1793 http://yake.svn.sourceforge.net/yake/?rev=1793&view=rev Author: psyclonist Date: 2007-08-17 12:15:52 -0700 (Fri, 17 Aug 2007) Log Message: ----------- [graphics] added graphics::ILight::isEnabled() Modified Paths: -------------- trunk/yake/src/plugins/graphicsOgre/graphicsOgreLight.cpp trunk/yake/yake/graphics/yakeGraphicalWorld.h trunk/yake/yake/plugins/graphicsOgre/graphicsOgreLight.h Modified: trunk/yake/src/plugins/graphicsOgre/graphicsOgreLight.cpp =================================================================== --- trunk/yake/src/plugins/graphicsOgre/graphicsOgreLight.cpp 2007-08-17 19:15:13 UTC (rev 1792) +++ trunk/yake/src/plugins/graphicsOgre/graphicsOgreLight.cpp 2007-08-17 19:15:52 UTC (rev 1793) @@ -138,6 +138,13 @@ } //------------------------------------------------------ + bool OgreLight::isEnabled() const + { + YAKE_ASSERT( mLight ).debug( "need actual light!" ); + return mLight->isVisible(); + } + + //------------------------------------------------------ void OgreLight::setEnabled( bool enabled ) { YAKE_ASSERT( mLight ).debug( "need actual light!" ); Modified: trunk/yake/yake/graphics/yakeGraphicalWorld.h =================================================================== --- trunk/yake/yake/graphics/yakeGraphicalWorld.h 2007-08-17 19:15:13 UTC (rev 1792) +++ trunk/yake/yake/graphics/yakeGraphicalWorld.h 2007-08-17 19:15:52 UTC (rev 1793) @@ -100,6 +100,7 @@ virtual void setType( const LightType type ) = 0; virtual LightType getType() const = 0; + virtual bool isEnabled() const = 0; virtual void setEnabled( bool enabled ) = 0; virtual void setCastsShadows( bool enabled ) = 0; Modified: trunk/yake/yake/plugins/graphicsOgre/graphicsOgreLight.h =================================================================== --- trunk/yake/yake/plugins/graphicsOgre/graphicsOgreLight.h 2007-08-17 19:15:13 UTC (rev 1792) +++ trunk/yake/yake/plugins/graphicsOgre/graphicsOgreLight.h 2007-08-17 19:15:52 UTC (rev 1793) @@ -55,6 +55,7 @@ virtual void setDiffuseColour( const math::Color& colour ); virtual void setSpecularColour( const math::Color& colour ); + virtual bool isEnabled() const; virtual void setEnabled( bool enabled ); virtual void setCastsShadows( bool enabled ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-17 19:15:10
|
Revision: 1792 http://yake.svn.sourceforge.net/yake/?rev=1792&view=rev Author: psyclonist Date: 2007-08-17 12:15:13 -0700 (Fri, 17 Aug 2007) Log Message: ----------- * [samples] improved raf/lua1: scene setup is now done completely in Lua Modified Paths: -------------- trunk/yake/common/media/scripts/raf1.lua trunk/yake/samples/raf/lua1/demo.cpp Modified: trunk/yake/common/media/scripts/raf1.lua =================================================================== --- trunk/yake/common/media/scripts/raf1.lua 2007-08-16 18:54:29 UTC (rev 1791) +++ trunk/yake/common/media/scripts/raf1.lua 2007-08-17 19:15:13 UTC (rev 1792) @@ -1,9 +1,6 @@ -local gfx = yake.graphics +local gworld = scene.gworld +local defaultCam = scene.activeCamera --- ---local gsys = app.graphics ---local gsys = app:getGraphics("") - -- configure basic scene properties gworld:setShadowsEnabled(false) gworld:setAmbientLight(yake.Color(0,0,0,1)) @@ -17,7 +14,13 @@ local lightnode = gworld:createSceneNode() local l = gworld:createLight() lightnode:attach(l) -l.type = gfx.Light.LT_DIRECTIONAL +l.type = yake.graphics.Light.LT_DIRECTIONAL l:setDiffuseColour(yake.Color(1,1,1,1)) l.direction = yake.Vector3(0,-1,1) +-- +local cam = scene.activeCamera +assert(cam) +cam.position = yake.Vector3(100,20,-200) +cam:setFixedYawAxis( yake.Vector3.UnitY ) +cam:lookAt( yake.Vector3(0,100,0) ) Modified: trunk/yake/samples/raf/lua1/demo.cpp =================================================================== --- trunk/yake/samples/raf/lua1/demo.cpp 2007-08-16 18:54:29 UTC (rev 1791) +++ trunk/yake/samples/raf/lua1/demo.cpp 2007-08-17 19:15:13 UTC (rev 1792) @@ -51,8 +51,11 @@ { scripting::LuaVM* lvm = static_cast<scripting::LuaVM*>(vm.get()); luabind::globals(lvm->getLuaState())["app"] = &app_; - luabind::globals(lvm->getLuaState())["gworld"] = this->getGraphicalWorld(); - luabind::globals(lvm->getLuaState())["defaultCam"] = this->getDefaultCamera(); + + luabind::object scene = luabind::newtable(lvm->getLuaState()); + scene["gworld"] = this->getGraphicalWorld(); + scene["activeCamera"] = this->getDefaultCamera(); + luabind::globals(lvm->getLuaState())["scene"] = scene; } // @@ -60,9 +63,6 @@ vm->execute( script ); // position camera and look at the ninja - getDefaultCamera()->setFixedYawAxis(Vector3::kUnitY); - getDefaultCamera()->setPosition(Vector3(100,20,-400)); - getDefaultCamera()->lookAt(Vector3(0,100,0)); } virtual void onFrame(const real timeElapsed) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-16 18:54:26
|
Revision: 1791 http://yake.svn.sourceforge.net/yake/?rev=1791&view=rev Author: psyclonist Date: 2007-08-16 11:54:29 -0700 (Thu, 16 Aug 2007) Log Message: ----------- [physics,vehicle,loader] improved interface clarity Modified Paths: -------------- trunk/yake/src/loader/yakeXODEParser.cpp trunk/yake/src/vehicle/yakeDotVehicle.cpp trunk/yake/src/vehicle/yakeNativeOde.cpp trunk/yake/yake/physics/yakePhysicsShape.h Modified: trunk/yake/src/loader/yakeXODEParser.cpp =================================================================== --- trunk/yake/src/loader/yakeXODEParser.cpp 2007-08-16 18:42:07 UTC (rev 1790) +++ trunk/yake/src/loader/yakeXODEParser.cpp 2007-08-16 18:54:29 UTC (rev 1791) @@ -759,8 +759,7 @@ TriangleMeshDesc dataDesc( vertices, indices ); - shapeDesc = new IShape::TriMeshDesc( dataDesc, "", - geomTransform.position_, geomTransform.rotation_ ); + shapeDesc = new IShape::TriMeshDesc( dataDesc, geomTransform.position_, geomTransform.rotation_ ); } else if ( nodeName == "ext" ) { Modified: trunk/yake/src/vehicle/yakeDotVehicle.cpp =================================================================== --- trunk/yake/src/vehicle/yakeDotVehicle.cpp 2007-08-16 18:42:07 UTC (rev 1790) +++ trunk/yake/src/vehicle/yakeDotVehicle.cpp 2007-08-16 18:54:29 UTC (rev 1791) @@ -144,7 +144,7 @@ if (n.getNodeByName("position")) parsePosition( *n.getNodeByName("position"), pos ); mpCurrVehTpl->mChassis.mChassisShapes.push_back( - new physics::IShape::BoxDesc( dim, matId, pos ) ); + new physics::IShape::BoxDesc( dim, pos, Quaternion::kIdentity, matId ) ); } void DotVehicleParser::parseShapeSphere( const data::dom::INode& n, const String& matId ) @@ -154,7 +154,7 @@ if (n.getNodeByName("position")) parsePosition( *n.getNodeByName("position"), pos ); mpCurrVehTpl->mChassis.mChassisShapes.push_back( - new physics::IShape::SphereDesc( radius, matId, pos ) ); + new physics::IShape::SphereDesc( radius, pos, Quaternion::kIdentity, matId ) ); } void DotVehicleParser::parseEngine( const data::dom::INode& n ) Modified: trunk/yake/src/vehicle/yakeNativeOde.cpp =================================================================== --- trunk/yake/src/vehicle/yakeNativeOde.cpp 2007-08-16 18:42:07 UTC (rev 1790) +++ trunk/yake/src/vehicle/yakeNativeOde.cpp 2007-08-16 18:54:29 UTC (rev 1791) @@ -537,7 +537,7 @@ YAKE_ASSERT( chassisObj ); mpWheel = PWorld.createActor( physics::ACTOR_DYNAMIC ); - mpWheel->createShape( physics::IShape::SphereDesc( mRadius, tpl.mMaterial ) ); + mpWheel->createShape( physics::IShape::SphereDesc( mRadius, Vector3::kZero, Quaternion::kIdentity, tpl.mMaterial ) ); real mass = tpl.mMassRelativeToChassis ? (tpl.mMass * chassisObj->getBody().getMass()) : tpl.mMass; mpWheel->setPosition( tpl.mPosition ); Modified: trunk/yake/yake/physics/yakePhysicsShape.h =================================================================== --- trunk/yake/yake/physics/yakePhysicsShape.h 2007-08-16 18:42:07 UTC (rev 1790) +++ trunk/yake/yake/physics/yakePhysicsShape.h 2007-08-16 18:54:29 UTC (rev 1791) @@ -88,9 +88,10 @@ SphereDesc( real radius_ = real(1.), // base class: const Vector3& rPosition = Vector3::kZero, - const Quaternion& rOrientation = Quaternion::kIdentity + const Quaternion& rOrientation = Quaternion::kIdentity, + const String& material_ = "" ) : - Desc( ST_SPHERE, rPosition, rOrientation ), + Desc( ST_SPHERE, rPosition, rOrientation, material_ ), radius( radius_ ) {} real radius; @@ -100,9 +101,10 @@ { BoxDesc( const Vector3& rDimensions = Vector3(1,1,1), const Vector3& rPosition = Vector3::kZero, - const Quaternion& rOrientation = Quaternion::kIdentity + const Quaternion& rOrientation = Quaternion::kIdentity, + const String& material_ = "" ) : - Desc( ST_BOX, rPosition, rOrientation ), + Desc( ST_BOX, rPosition, rOrientation, material_ ), dimensions( rDimensions ) {} Vector3 dimensions; @@ -114,9 +116,10 @@ const real d_ = real(1.), // base class: const Vector3& rPosition = Vector3::kZero, - const Quaternion& rOrientation = Quaternion::kIdentity + const Quaternion& rOrientation = Quaternion::kIdentity, + const String& material_ = "" ) : - Desc( ST_PLANE, rPosition, rOrientation ), + Desc( ST_PLANE, rPosition, rOrientation, material_ ), normal( rNormal ), d( d_ ) {} @@ -130,9 +133,10 @@ const real radius_ = real(1.), // base class: const Vector3& rPosition = Vector3::kZero, - const Quaternion& rOrientation = Quaternion::kIdentity + const Quaternion& rOrientation = Quaternion::kIdentity, + const String& material_ = "" ) : - Desc( ST_CAPSULE, rPosition, rOrientation ), + Desc( ST_CAPSULE, rPosition, rOrientation, material_ ), height( height_ ), radius( radius_ ) {} @@ -144,9 +148,9 @@ { TriMeshDesc( const TriangleMeshDesc trimesh, // base class: - const String& material_ = "", const Vector3& rPosition = Vector3::kZero, - const Quaternion& rOrientation = Quaternion::kIdentity + const Quaternion& rOrientation = Quaternion::kIdentity, + const String& material_ = "" ) : Desc( ST_TRIANGLE_MESH, rPosition, rOrientation, material_ ), trimesh_( trimesh ), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-16 18:42:05
|
Revision: 1790 http://yake.svn.sourceforge.net/yake/?rev=1790&view=rev Author: psyclonist Date: 2007-08-16 11:42:07 -0700 (Thu, 16 Aug 2007) Log Message: ----------- [samples] fixed main() signature Modified Paths: -------------- trunk/yake/samples/task/demo1/demo.cpp Modified: trunk/yake/samples/task/demo1/demo.cpp =================================================================== --- trunk/yake/samples/task/demo1/demo.cpp 2007-08-16 18:40:10 UTC (rev 1789) +++ trunk/yake/samples/task/demo1/demo.cpp 2007-08-16 18:42:07 UTC (rev 1790) @@ -14,7 +14,7 @@ } } -void main() +int main() { using namespace yake; @@ -30,5 +30,7 @@ // run executor for (size_t t=0; t<10; ++t) - exec->update(1); + exec->update(1); + + return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-16 18:40:07
|
Revision: 1789 http://yake.svn.sourceforge.net/yake/?rev=1789&view=rev Author: psyclonist Date: 2007-08-16 11:40:10 -0700 (Thu, 16 Aug 2007) Log Message: ----------- [statemachine] added missing include Modified Paths: -------------- trunk/yake/yake/statemachine/fsm_oo_machine.h Modified: trunk/yake/yake/statemachine/fsm_oo_machine.h =================================================================== --- trunk/yake/yake/statemachine/fsm_oo_machine.h 2007-08-12 21:11:12 UTC (rev 1788) +++ trunk/yake/yake/statemachine/fsm_oo_machine.h 2007-08-16 18:40:10 UTC (rev 1789) @@ -28,6 +28,7 @@ #define FSM_OOMACHINE_H #include "yake/statemachine/fsm_core.h" +#include <boost/bind.hpp> namespace fsm { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <psy...@us...> - 2007-08-12 21:11:10
|
Revision: 1788 http://yake.svn.sourceforge.net/yake/?rev=1788&view=rev Author: psyclonist Date: 2007-08-12 14:11:12 -0700 (Sun, 12 Aug 2007) Log Message: ----------- * [raf/scripting] added demo 'raf/lua1' (same as raf/demo1 but done with Lua) * [scripting.Lua] IVM::execute() now also logs errors via yake.logging * [bindings.lua] added additional constructor for class Color * [bindings.lua] added graphics::Camera related bindings * [bindings.lua] fixed dependencies in premake scripts Modified Paths: -------------- trunk/yake/scripts/premake/samples.lua trunk/yake/scripts/premake/yake.lua trunk/yake/src/bindings.lua/bindings.lua.cpp trunk/yake/src/bindings.lua/detail/base.lua.cpp trunk/yake/src/bindings.lua/detail/graphics.lua.cpp trunk/yake/src/bindings.lua/detail/raf.lua.cpp trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp Added Paths: ----------- trunk/yake/common/media/scripts/raf1.lua trunk/yake/samples/raf/lua1/ trunk/yake/samples/raf/lua1/demo.cpp Added: trunk/yake/common/media/scripts/raf1.lua =================================================================== --- trunk/yake/common/media/scripts/raf1.lua (rev 0) +++ trunk/yake/common/media/scripts/raf1.lua 2007-08-12 21:11:12 UTC (rev 1788) @@ -0,0 +1,23 @@ +local gfx = yake.graphics + +-- +--local gsys = app.graphics +--local gsys = app:getGraphics("") + +-- configure basic scene properties +gworld:setShadowsEnabled(false) +gworld:setAmbientLight(yake.Color(0,0,0,1)) + +-- create ninja +local sn = gworld:createSceneNode() +local e = gworld:createEntity("ninja.mesh") +sn:attach(e) + +-- create direction light +local lightnode = gworld:createSceneNode() +local l = gworld:createLight() +lightnode:attach(l) +l.type = gfx.Light.LT_DIRECTIONAL +l:setDiffuseColour(yake.Color(1,1,1,1)) +l.direction = yake.Vector3(0,-1,1) + Added: trunk/yake/samples/raf/lua1/demo.cpp =================================================================== --- trunk/yake/samples/raf/lua1/demo.cpp (rev 0) +++ trunk/yake/samples/raf/lua1/demo.cpp 2007-08-12 21:11:12 UTC (rev 1788) @@ -0,0 +1,92 @@ +#include <yake/audio/yakeAudio.h> +#include <yake/input/yakeInput.h> +#include <yake/graphics/yakeGraphics.h> +#include <yake/physics/yakePhysics.h> +#include <yake/scripting/yakeScriptingSystem.h> +#include <yake/raf/yakeRaf.h> + +#include <yake/plugins/scriptingLua/ScriptingSystemLua.h> +#include <yake/bindings.lua/bindings.lua.h> +#include <yake/bindings.lua/common/yake.lua.common.h> + +using namespace yake; + +/** Configuration of the application */ +struct TheConfiguration : public raf::ApplicationConfiguration +{ + // Use "inputOgre" for Ogre 1.2/1.3, "inputOgreOIS" for Ogre 1.4+. + virtual StringVector getLibraries() + { return MakeStringVector() << YAKE_LIB("scriptingLua") << YAKE_LIB("graphicsOgre") << YAKE_LIB("inputOgreOIS"); } + + // Use "ogre" for Ogre 1.2/1.3, "ois" for Ogre 1.4+. + virtual StringVector getInputSystems() + { return MakeStringVector() << "ois"; } + + virtual StringVector getScriptingSystems() + { return MakeStringVector() << "lua"; } + + virtual StringVector getGraphicsSystems() + { return MakeStringVector() << "ogre3d"; } +}; + +/** Main application state */ +class TheMainState : public raf::RtMainState +{ +public: + TheMainState(raf::Application& owner) : raf::RtMainState(owner), app_(owner) + { + enableInstantQuitByKey( input::KC_ESCAPE ); + } +protected: + virtual void onCreateScene() + { + YAKE_LOG_INFORMATION("demo","Creating scene"); + + scripting::IScriptingSystem* sys = app_.getScriptingSystem(); + YAKE_ASSERT( sys ); + scripting::VMPtr vm = sys->createVM(); + bind_all(vm.get()); + + //bind + { + scripting::LuaVM* lvm = static_cast<scripting::LuaVM*>(vm.get()); + luabind::globals(lvm->getLuaState())["app"] = &app_; + luabind::globals(lvm->getLuaState())["gworld"] = this->getGraphicalWorld(); + luabind::globals(lvm->getLuaState())["defaultCam"] = this->getDefaultCamera(); + } + + // + scripting::ScriptPtr script = sys->createScriptFromFile("../../../common/media/scripts/raf1.lua"); + vm->execute( script ); + + // position camera and look at the ninja + getDefaultCamera()->setFixedYawAxis(Vector3::kUnitY); + getDefaultCamera()->setPosition(Vector3(100,20,-400)); + getDefaultCamera()->lookAt(Vector3(0,100,0)); + } + virtual void onFrame(const real timeElapsed) + { + } +private: + raf::Application& app_; +}; + +/** The mighty application itself! */ +class TheApp : public raf::ExampleApplication<TheConfiguration> +{ +public: + TheApp() {} +protected: + virtual raf::MainState* createMainState() + { + return new TheMainState(*this); + } +}; + +int main( int argc, char** argv ) +{ + // Use default executor for convenience. + // It's always possible to manually execute TheApp::initialise() etc. + return (raf::runApplication( TheApp() )) ? 0 : 1; +} + Modified: trunk/yake/scripts/premake/samples.lua =================================================================== --- trunk/yake/scripts/premake/samples.lua 2007-08-10 15:26:25 UTC (rev 1787) +++ trunk/yake/scripts/premake/samples.lua 2007-08-12 21:11:12 UTC (rev 1788) @@ -104,6 +104,14 @@ useComponent("base") useComponent("raf") end + + -------------------------------------- + if ENABLE_LUA_RAF then + makeSample("sampleRafLuaDemo1","samples/raf/lua1") + useComponent("base") + useComponent("raf") + useComponent("bindings.lua") + end end -------------------------------------- Modified: trunk/yake/scripts/premake/yake.lua =================================================================== --- trunk/yake/scripts/premake/yake.lua 2007-08-10 15:26:25 UTC (rev 1787) +++ trunk/yake/scripts/premake/yake.lua 2007-08-12 21:11:12 UTC (rev 1788) @@ -245,6 +245,15 @@ if ENABLE_LUA_TASK then addDependency("task") end + if ENABLE_LUA_GRAPHICS then + addDependency("graphics") + end + if ENABLE_LUA_PHYSICS then + addDependency("physics") + end + if ENABLE_LUA_RAF then + addDependency("raf") + end if (windows) then useDep("lua") useDep("luabind") Modified: trunk/yake/src/bindings.lua/bindings.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/bindings.lua.cpp 2007-08-10 15:26:25 UTC (rev 1787) +++ trunk/yake/src/bindings.lua/bindings.lua.cpp 2007-08-12 21:11:12 UTC (rev 1788) @@ -76,6 +76,15 @@ #if YAKE_ENABLE_LUA_ENT == 1 bind_ent(L); #endif +#if YAKE_ENABLE_LUA_GRAPHICS == 1 + bind_graphics(L); +#endif +#if YAKE_ENABLE_LUA_PHYSICS == 1 + bind_physics(L); +#endif +#if YAKE_ENABLE_LUA_RAF == 1 + bind_raf(L); +#endif } void bind_all(scripting::IVM* vm) { Modified: trunk/yake/src/bindings.lua/detail/base.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-08-10 15:26:25 UTC (rev 1787) +++ trunk/yake/src/bindings.lua/detail/base.lua.cpp 2007-08-12 21:11:12 UTC (rev 1788) @@ -79,6 +79,7 @@ [ class_<Color>("Color") .def( constructor<>() ) + .def( constructor<real,real,real>() ) .def( constructor<real,real,real,real>() ) .def( constructor< const Color& >() ) //FIXME some strange members in anonymous union::struct Modified: trunk/yake/src/bindings.lua/detail/graphics.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/detail/graphics.lua.cpp 2007-08-10 15:26:25 UTC (rev 1787) +++ trunk/yake/src/bindings.lua/detail/graphics.lua.cpp 2007-08-12 21:11:12 UTC (rev 1788) @@ -131,6 +131,8 @@ , class_<ICamera,Movable>("Camera") //@todo + .def("lookAt", &ICamera::lookAt) + .property("aspectRatio", &ICamera::getAspectRatio, &ICamera::setAspectRatio) , class_<IViewport>("Viewport") //@todo @@ -142,6 +144,7 @@ .def("createSceneNode", &IWorld_createSceneNode_NoName) .def("createEntity", &IWorld::createEntity) .def("createParticleSystem", &IWorld::createParticleSystem) + .def("createLight", &IWorld::createLight) .def("createCamera", &IWorld::createCamera) .def("createViewport", &IWorld::createViewport) .def("load", &IWorld::load) Modified: trunk/yake/src/bindings.lua/detail/raf.lua.cpp =================================================================== --- trunk/yake/src/bindings.lua/detail/raf.lua.cpp 2007-08-10 15:26:25 UTC (rev 1787) +++ trunk/yake/src/bindings.lua/detail/raf.lua.cpp 2007-08-12 21:11:12 UTC (rev 1788) @@ -91,6 +91,7 @@ .property("graphics", &getAppDefaultGraphics) .property("physics", &getAppDefaultPhysics) .property("audio", &getAppDefaultAudio) + .def("getGraphics", &raf::Application::getGraphicsSystem) , class_<raf::AppMachine>("AppMachine") .property("currentState", &raf::AppMachine::currentState) Modified: trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp =================================================================== --- trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp 2007-08-10 15:26:25 UTC (rev 1787) +++ trunk/yake/src/plugins/scriptingLua/ScriptingSystemLua.cpp 2007-08-12 21:11:12 UTC (rev 1788) @@ -148,22 +148,29 @@ } catch (luabind::error& e) { + logging::log(logging::S_ERROR,"scriptingLua","Luabind error"); throw Exception(String("LuaVM: caught Luabind error") + e.what()); } catch (luabind::cast_failed& e) { + logging::log(logging::S_ERROR,"scriptingLua","Luabind cast failed"); throw Exception(String("LuaVM: caught Luabind cast_failed") + e.what()); } catch (Exception&) { + logging::log(logging::S_ERROR,"scriptingLua","unknown exception"); throw; } catch (std::exception& e) { + logging::log(logging::S_ERROR,"scriptingLua",e.what()); throw Exception(String("LuaVM: caught exception: ") + e.what()); } if (!err.empty()) + { + logging::log(logging::S_ERROR,"scriptingLua",err); throw Exception(String("LuaVM: error: ") + err); + } } //------------------------------------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |