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:
@@ -33,9 +33,12 @@ if (Boost_FOUND)
|
|||||||
#add_executable(dispatchkit_test contrib/test/dispatchkit_test.cpp)
|
#add_executable(dispatchkit_test contrib/test/dispatchkit_test.cpp)
|
||||||
target_link_libraries(chaiscript_eval dl ${Boost_LIBRARIES} ${READLINE_LIB})
|
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})
|
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)
|
install(TARGETS chaiscript_eval DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||||
|
|
||||||
else(Boost_FOUND)
|
else(Boost_FOUND)
|
||||||
|
@@ -21,6 +21,16 @@
|
|||||||
#include "dispatchkit/bootstrap.hpp"
|
#include "dispatchkit/bootstrap.hpp"
|
||||||
#include "dispatchkit/bootstrap_stl.hpp"
|
#include "dispatchkit/bootstrap_stl.hpp"
|
||||||
#include "dispatchkit/function_call.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
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
typedef ModulePtr (*Create_Module_Func)();
|
typedef ModulePtr (*Create_Module_Func)();
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
successes=0
|
successes=0
|
||||||
failures=0
|
failures=0
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@ for file in unittests/*.chai
|
|||||||
do
|
do
|
||||||
tstname=${file%.*}
|
tstname=${file%.*}
|
||||||
tst="$tstname.txt"
|
tst="$tstname.txt"
|
||||||
./chaiscript_eval $file > /tmp/tstout.txt
|
LD_LIBRARY_PATH=. ./chaiscript_eval $file > /tmp/tstout.txt
|
||||||
diff $tst /tmp/tstout.txt
|
diff $tst /tmp/tstout.txt
|
||||||
if [ "$?" -eq "0" ]
|
if [ "$?" -eq "0" ]
|
||||||
then
|
then
|
||||||
|
@@ -40,7 +40,6 @@ int main(int argc, char *argv[]) {
|
|||||||
std::string input;
|
std::string input;
|
||||||
chaiscript::ChaiScript chai;
|
chaiscript::ChaiScript chai;
|
||||||
|
|
||||||
chai.add(chaiscript::bootstrap::list_type<std::list<chaiscript::Boxed_Value> >("List"));
|
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
//std::cout << "eval> ";
|
//std::cout << "eval> ";
|
||||||
|
@@ -13,14 +13,15 @@
|
|||||||
|
|
||||||
void do_work(chaiscript::ChaiScript &c)
|
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[]) {
|
int main(int argc, char *argv[]) {
|
||||||
std::string input;
|
std::string input;
|
||||||
chaiscript::ChaiScript chai;
|
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;
|
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";
|
return "Hello World";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test()
|
||||||
#define EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define EXPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
{
|
||||||
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");
|
m->add(chaiscript::fun(hello_world), "hello_world");
|
||||||
return m;
|
return m;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
load_module("stl_extra")
|
||||||
|
|
||||||
var x = List()
|
var x = List()
|
||||||
x.push_back(3)
|
x.push_back(3)
|
||||||
x.push_back("A")
|
x.push_back("A")
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
load_module("stl_extra")
|
||||||
|
|
||||||
var x = List()
|
var x = List()
|
||||||
x.push_front(3)
|
x.push_front(3)
|
||||||
x.push_front("A")
|
x.push_front("A")
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
load_module("test", "./libtest.so")
|
load_module("test")
|
||||||
print(hello_world())
|
print(hello_world())
|
||||||
|
Reference in New Issue
Block a user