 5ff97979fd
			
		
	
	5ff97979fd
	
	
	
		
			
			This gives a small but noticeable compile time improvement as well as a measurable, albeit not great, reduction in size of the stdlib.
		
			
				
	
	
		
			68 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // This file is distributed under the BSD License.
 | |
| // See "license.txt" for details.
 | |
| // Copyright 2009-2012, Jonathan Turner (jonathan@emptycrate.com)
 | |
| // and Jason Turner (jason@emptycrate.com)
 | |
| // http://www.chaiscript.com
 | |
| 
 | |
| #ifndef CHAISCRIPT_STDLIB_HPP_
 | |
| #define CHAISCRIPT_STDLIB_HPP_
 | |
| 
 | |
| #include <map>
 | |
| #include <memory>
 | |
| #include <string>
 | |
| #include <utility>
 | |
| #include <vector>
 | |
| 
 | |
| #include "chaiscript_defines.hpp"
 | |
| #include "dispatchkit/dispatchkit.hpp"
 | |
| #include "dispatchkit/bootstrap.hpp"
 | |
| #include "dispatchkit/bootstrap_stl.hpp"
 | |
| #include "dispatchkit/boxed_value.hpp"
 | |
| #include "language/chaiscript_prelude.hpp"
 | |
| #include "utility/json_wrap.hpp"
 | |
| 
 | |
| #ifndef CHAISCRIPT_NO_THREADS
 | |
| #include <future>
 | |
| #endif
 | |
| 
 | |
| 
 | |
| /// @file
 | |
| ///
 | |
| /// This file generates the standard library that normal ChaiScript usage requires.
 | |
| 
 | |
| namespace chaiscript
 | |
| {
 | |
|   class Std_Lib
 | |
|   {
 | |
|     public:
 | |
| 
 | |
|       static ModulePtr library()
 | |
|       {
 | |
|         using namespace bootstrap;
 | |
| 
 | |
|         auto lib = std::make_shared<Module>();
 | |
|         Bootstrap::bootstrap(*lib);
 | |
| 
 | |
|         standard_library::vector_type<std::vector<Boxed_Value> >("Vector", *lib);
 | |
|         standard_library::string_type<std::string>("string", *lib);
 | |
|         standard_library::map_type<std::map<std::string, Boxed_Value> >("Map", *lib);
 | |
|         standard_library::pair_type<std::pair<Boxed_Value, Boxed_Value > >("Pair", *lib);
 | |
| 
 | |
| #ifndef CHAISCRIPT_NO_THREADS
 | |
|         standard_library::future_type<std::future<chaiscript::Boxed_Value>>("future", *lib);
 | |
|         lib->add(chaiscript::fun([](const std::function<chaiscript::Boxed_Value ()> &t_func){ return std::async(std::launch::async, t_func);}), "async");
 | |
| #endif
 | |
| 
 | |
|         json_wrap::library(*lib);
 | |
| 
 | |
|         lib->eval(ChaiScript_Prelude::chaiscript_prelude() /*, "standard prelude"*/ );
 | |
| 
 | |
|         return lib;
 | |
|       }
 | |
| 
 | |
|   };
 | |
| }
 | |
| 
 | |
| #endif
 | |
| 
 |