Changeset 893
- Timestamp:
- 03/07/10 00:47:52 (5 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
client/Game2/Console.cpp (modified) (1 diff)
-
engine/Script/Env.cpp (modified) (4 diffs)
-
engine/Script/Env.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/Game2/Console.cpp
r879 r893 85 85 void Console::InitEnv(Script::Env *scripting) 86 86 { 87 scripting-> SetOutput(logStream);87 scripting->AddOutput(logStream); 88 88 } 89 89 -
trunk/engine/Script/Env.cpp
r705 r893 24 24 25 25 #include <iostream> 26 27 #include <boost/foreach.hpp> 26 28 27 29 #include "../Util/OS.h" … … 143 145 * @param out The output stream (wrapped in a shared pointer). 144 146 * May be @c NULL to use the system default. 145 */ 146 void Env::SetOutput(boost::shared_ptr<std::ostream> out) 147 { 148 this->out = out; 147 * @return A handle for removing the stream later. 148 */ 149 Env::OutHandle Env::AddOutput(boost::shared_ptr<std::ostream> out) 150 { 151 outs.push_back(out); 152 return --(outs.end()); 153 } 154 155 void Env::RemoveOutput(const OutHandle &handle) 156 { 157 outs.erase(handle); 149 158 } 150 159 … … 221 230 { 222 231 Env *self = static_cast<Env*>(lua_touserdata(state, lua_upvalueindex(1))); 223 std::ostream &oss = (self->out == NULL) ? std::cout : *(self->out); 232 //std::ostream &oss = (self->out == NULL) ? std::cout : *(self->out); 233 //bool hasOut = !outs.empty(); 224 234 225 235 int numParams = lua_gettop(state); … … 246 256 continue; 247 257 } 248 if (i > 1) oss << '\t'; 249 oss << s; 258 BOOST_FOREACH(boost::shared_ptr<std::ostream> &oss, self->outs) { 259 if (i > 1) *oss << '\t'; 260 *oss << s; 261 } 250 262 lua_pop(state, 1); 251 263 } 252 oss << std::endl; 264 BOOST_FOREACH(boost::shared_ptr<std::ostream> &oss, self->outs) { 265 *oss << std::endl; 266 } 253 267 254 268 return 0; -
trunk/engine/Script/Env.h
r703 r893 23 23 #pragma once 24 24 25 #include < queue>25 #include <list> 26 26 27 27 #include <lua.hpp> … … 64 64 void Reset(); 65 65 void ActivateSandbox(); 66 void SetOutput(boost::shared_ptr<std::ostream> out); 66 67 private: 68 typedef std::list<boost::shared_ptr<std::ostream> > outs_t; 69 public: 70 typedef outs_t::iterator OutHandle; 71 OutHandle AddOutput(boost::shared_ptr<std::ostream> out); 72 void RemoveOutput(const OutHandle &handle); 67 73 68 74 std::string GetVersionString() const; … … 78 84 79 85 private: 80 boost::shared_ptr<std::ostream> out;86 outs_t outs; 81 87 lua_State *state; 82 88 };
