Move std::list<> support from main.cpp into a module, stl_extra.cpp, to better allow for measuring of core compile times / performance.
This commit is contained in:
parent
63de0fd33c
commit
4bdbcf30ff
@ -33,9 +33,12 @@ if (Boost_FOUND)
|
||||
#add_executable(dispatchkit_test contrib/test/dispatchkit_test.cpp)
|
||||
target_link_libraries(chaiscript_eval dl ${Boost_LIBRARIES} ${READLINE_LIB})
|
||||
|
||||
add_library(test MODULE src/test_module.cpp)
|
||||
add_library(test MODULE src/test_module.cpp)
|
||||
target_link_libraries(test ${Boost_LIBRARIES})
|
||||
|
||||
add_library(stl_extra MODULE src/stl_extra.cpp)
|
||||
target_link_libraries(stl_extra ${Boost_LIBRARIES})
|
||||
|
||||
install(TARGETS chaiscript_eval DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
|
||||
else(Boost_FOUND)
|
||||
|
@ -21,6 +21,16 @@
|
||||
#include "dispatchkit/bootstrap.hpp"
|
||||
#include "dispatchkit/bootstrap_stl.hpp"
|
||||
#include "dispatchkit/function_call.hpp"
|
||||
|
||||
|
||||
#ifdef BOOST_HAS_DECLSPEC
|
||||
#define CHAISCRIPT_MODULE_EXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define CHAISCRIPT_MODULE_EXPORT extern "C"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace chaiscript
|
||||
{
|
||||
typedef ModulePtr (*Create_Module_Func)();
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
successes=0
|
||||
failures=0
|
||||
|
||||
@ -8,7 +9,7 @@ for file in unittests/*.chai
|
||||
do
|
||||
tstname=${file%.*}
|
||||
tst="$tstname.txt"
|
||||
./chaiscript_eval $file > /tmp/tstout.txt
|
||||
LD_LIBRARY_PATH=. ./chaiscript_eval $file > /tmp/tstout.txt
|
||||
diff $tst /tmp/tstout.txt
|
||||
if [ "$?" -eq "0" ]
|
||||
then
|
||||
|
@ -40,7 +40,6 @@ int main(int argc, char *argv[]) {
|
||||
std::string input;
|
||||
chaiscript::ChaiScript chai;
|
||||
|
||||
chai.add(chaiscript::bootstrap::list_type<std::list<chaiscript::Boxed_Value> >("List"));
|
||||
|
||||
if (argc < 2) {
|
||||
//std::cout << "eval> ";
|
||||
|
@ -13,14 +13,15 @@
|
||||
|
||||
void do_work(chaiscript::ChaiScript &c)
|
||||
{
|
||||
c("use(\"work.chai\"); do_chai_work(num_iterations);");
|
||||
// c("use(\"work.chai\"); do_chai_work(num_iterations);");
|
||||
c("use(\"work.chai\"); do_chai_work(10000);");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::string input;
|
||||
chaiscript::ChaiScript chai;
|
||||
|
||||
chai.add_shared_object(chaiscript::Boxed_Value(10000), "num_iterations");
|
||||
//chai.add_shared_object(chaiscript::Boxed_Value(10000), "num_iterations");
|
||||
|
||||
std::vector<boost::shared_ptr<boost::thread> > threads;
|
||||
|
||||
|
9
src/stl_extra.cpp
Normal file
9
src/stl_extra.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
#include <chaiscript/chaiscript.hpp>
|
||||
#include <string>
|
||||
|
||||
|
||||
CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_stl_extra()
|
||||
{
|
||||
return chaiscript::bootstrap::list_type<std::list<chaiscript::Boxed_Value> >("List");
|
||||
}
|
@ -7,19 +7,10 @@ std::string hello_world()
|
||||
return "Hello World";
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test()
|
||||
{
|
||||
EXPORT chaiscript::ModulePtr create_chaiscript_module_test()
|
||||
{
|
||||
chaiscript::ModulePtr m(new chaiscript::Module());
|
||||
chaiscript::ModulePtr m(new chaiscript::Module());
|
||||
|
||||
m->add(chaiscript::fun(hello_world), "hello_world");
|
||||
return m;
|
||||
}
|
||||
m->add(chaiscript::fun(hello_world), "hello_world");
|
||||
return m;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
load_module("stl_extra")
|
||||
|
||||
var x = List()
|
||||
x.push_back(3)
|
||||
x.push_back("A")
|
||||
|
@ -1,3 +1,5 @@
|
||||
load_module("stl_extra")
|
||||
|
||||
var x = List()
|
||||
x.push_front(3)
|
||||
x.push_front("A")
|
||||
|
@ -1,2 +1,2 @@
|
||||
load_module("test", "./libtest.so")
|
||||
load_module("test")
|
||||
print(hello_world())
|
||||
|
Loading…
x
Reference in New Issue
Block a user