summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2013-12-27 19:50:41 (GMT)
committerRemko Tronçon <git@el-tramo.be>2014-01-03 11:09:07 (GMT)
commita260aa27ab2af0c71d29b3e18cfa30569d3bcd7d (patch)
tree3629bd64f53e8e2f355725ddd07ee5e8e9815f02 /Sluift/main.cpp
parent9d787c6337d7080cb32af800a96cf64d43373514 (diff)
downloadswift-a260aa27ab2af0c71d29b3e18cfa30569d3bcd7d.zip
swift-a260aa27ab2af0c71d29b3e18cfa30569d3bcd7d.tar.bz2
Sluift: Add with() function
Change-Id: Ife0a7748c2b354017bec5cfdddb0d096950dd15b
Diffstat (limited to 'Sluift/main.cpp')
-rw-r--r--Sluift/main.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/Sluift/main.cpp b/Sluift/main.cpp
index e2fa9c8..76ba572 100644
--- a/Sluift/main.cpp
+++ b/Sluift/main.cpp
@@ -14,6 +14,7 @@
#include <boost/program_options.hpp>
#include <boost/version.hpp>
#include <boost/numeric/conversion/cast.hpp>
+#include <boost/assign/list_of.hpp>
#include <Sluift/Console.h>
#include <Sluift/StandardTerminal.h>
#include <Sluift/sluift.h>
@@ -151,8 +152,13 @@ int main(int argc, char* argv[]) {
if (arguments.count("interactive") || arguments.count("script") == 0) {
// Import some useful functions into the global namespace
lua_getglobal(L, "sluift");
- lua_getfield(L, -1, "help");
- lua_setglobal(L, "help");
+ std::vector<std::string> globalImports = boost::assign::list_of
+ ("help")("with");
+ foreach (const std::string& globalImport, globalImports) {
+ lua_getfield(L, -1, globalImport.c_str());
+ lua_setglobal(L, globalImport.c_str());
+ }
+ lua_pop(L, 1);
std::cout << SLUIFT_WELCOME_STRING << std::endl;
#ifdef HAVE_EDITLINE