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:
Jason Turner 2009-09-15 01:30:51 +00:00
parent 63de0fd33c
commit 4bdbcf30ff
10 changed files with 37 additions and 19 deletions

View File

@ -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)

View File

@ -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)();

View File

@ -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

View File

@ -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> ";

View File

@ -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
View 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");
}

View File

@ -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;
}

View File

@ -1,3 +1,5 @@
load_module("stl_extra")
var x = List()
x.push_back(3)
x.push_back("A")

View File

@ -1,3 +1,5 @@
load_module("stl_extra")
var x = List()
x.push_front(3)
x.push_front("A")

View File

@ -1,2 +1,2 @@
load_module("test", "./libtest.so")
load_module("test")
print(hello_world())