From 6bea42c1c09f3ad4111411ff3928ec07688f34ac Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 31 Aug 2014 16:03:42 -0600 Subject: [PATCH 1/6] Speed up to_string performance by relying on C++ versions Addresses #134, fixing issues introduced by #132 --- include/chaiscript/dispatchkit/bootstrap.hpp | 6 +++--- include/chaiscript/language/chaiscript_common.hpp | 6 +----- include/chaiscript/language/chaiscript_prelude.chai | 5 ----- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index fbe2fd7..32aa939 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -472,8 +472,8 @@ namespace chaiscript operators::assign(m); operators::equal(m); - m->add(fun(&to_string), "internal_to_string"); - m->add(fun(&Bootstrap::bool_to_string), "internal_to_string"); + m->add(fun(&to_string), "to_string"); + m->add(fun(&Bootstrap::bool_to_string), "to_string"); m->add(fun(&unknown_assign), "="); m->add(fun(&throw_exception), "throw"); m->add(fun(&what), "what"); @@ -553,7 +553,7 @@ namespace chaiscript {fun(&AST_Node::filename), "filename"}, {fun(&AST_Node::start), "start"}, {fun(&AST_Node::end), "end"}, - {fun(&AST_Node::internal_to_string), "internal_to_string"}, + {fun(&AST_Node::to_string), "to_string"}, {fun(std::function (const chaiscript::AST_Node &t_node)>([](const chaiscript::AST_Node &t_node) { std::vector retval; std::transform(t_node.children.begin(), t_node.children.end(), diff --git a/include/chaiscript/language/chaiscript_common.hpp b/include/chaiscript/language/chaiscript_common.hpp index ec006d0..09987fa 100644 --- a/include/chaiscript/language/chaiscript_common.hpp +++ b/include/chaiscript/language/chaiscript_common.hpp @@ -430,17 +430,13 @@ namespace chaiscript oss << t_prepend << "(" << ast_node_type_to_string(this->identifier) << ") " << this->text << " : " << this->start.line << ", " << this->start.column << std::endl; - + for (size_t j = 0; j < this->children.size(); ++j) { oss << this->children[j]->to_string(t_prepend + " "); } return oss.str(); } - std::string internal_to_string() { - return to_string(); - } - Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_e) { try { diff --git a/include/chaiscript/language/chaiscript_prelude.chai b/include/chaiscript/language/chaiscript_prelude.chai index 426dc3b..b4c0bc4 100644 --- a/include/chaiscript/language/chaiscript_prelude.chai +++ b/include/chaiscript/language/chaiscript_prelude.chai @@ -56,11 +56,6 @@ def to_string(x) : call_exists(range, x) && !x.is_type("string"){ "[" + x.join(", ") + "]"; } -# Basic to_string function -def to_string(x) { - internal_to_string(x); -} - # Prints to console with no carriage return def puts(x) { print_string(x.to_string()); From 6692607507499ee9b7fd8d74324e68098ebbd7aa Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 31 Aug 2014 19:45:07 -0600 Subject: [PATCH 2/6] Update version number to 5.4.0, update releasenotes --- CMakeLists.txt | 4 ++-- include/chaiscript/chaiscript_defines.hpp | 4 ++-- releasenotes.md | 10 +++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f463b4..cefe9ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,8 +54,8 @@ set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.md") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/description.txt") set(CPACK_PACKAGE_VERSION_MAJOR 5) -set(CPACK_PACKAGE_VERSION_MINOR 3) -set(CPACK_PACKAGE_VERSION_PATCH 2) +set(CPACK_PACKAGE_VERSION_MINOR 4) +set(CPACK_PACKAGE_VERSION_PATCH 0) set(CPACK_PACKAGE_EXECUTABLES "chai;ChaiScript Eval") set(CPACK_PACKAGE_VENDOR "ChaiScript.com") diff --git a/include/chaiscript/chaiscript_defines.hpp b/include/chaiscript/chaiscript_defines.hpp index cacb8bf..59e302e 100644 --- a/include/chaiscript/chaiscript_defines.hpp +++ b/include/chaiscript/chaiscript_defines.hpp @@ -45,8 +45,8 @@ namespace chaiscript { static const int version_major = 5; - static const int version_minor = 3; - static const int version_patch = 2; + static const int version_minor = 4; + static const int version_patch = 0; } #endif diff --git a/releasenotes.md b/releasenotes.md index a60227e..5a2d8bf 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -1,8 +1,16 @@ Notes: ======= -Current Version: 5.3.2 +Current Version: 5.4.0 ### Changes since 5.3.1 +* Decreased compile time and build size +* Make "reflection" module built in (losing some of the time / build size gains) +* Add new "class" syntax for ChaiScript defined methods and attributes see: [unittests/class.chai](unittests/class.chai) for examples +* Minor performance enhancements +* major to_string performance enhancements +* Provide API for retrieving registered type name #124 +* Added strong reference to container to range object #132 + ### Changes since 5.3.0 * Add automatic conversion of arithmetic return types, following the same From bb08cc3699635a8448f6eec74e732cf3a4eb4ebb Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 31 Aug 2014 19:54:43 -0600 Subject: [PATCH 3/6] Add documenation for "class" keyword --- include/chaiscript/chaiscript.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/chaiscript/chaiscript.hpp b/include/chaiscript/chaiscript.hpp index 903eb38..d541365 100644 --- a/include/chaiscript/chaiscript.hpp +++ b/include/chaiscript/chaiscript.hpp @@ -497,6 +497,21 @@ /// print(rect.area()) /// ~~~~~~~~~ /// +/// Since ChaiScript 5.4.0 it has been possible to use the "class" keyword to simplify this code. +/// +/// ~~~~~~~~~ +/// class Rectangle { +/// attr height +/// attr width +/// def Rectangle() { this.height = 10; this.width = 20 } +/// def area() { this.height * this.width } +/// } +/// +/// var rect = Rectangle() +/// rect.height = 30 +/// print(rect.area()) +/// ~~~~~~~~~ +/// /// @sa @ref keywordattr /// @sa @ref keyworddef From 8d36b66c89f7c13ecc6b27b384ebf9700c40fe9b Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 5 Sep 2014 07:45:36 -0600 Subject: [PATCH 4/6] Fix call to cppcheck --- contrib/codeanalysis/runcppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/codeanalysis/runcppcheck.sh b/contrib/codeanalysis/runcppcheck.sh index 5e79737..05a492d 100755 --- a/contrib/codeanalysis/runcppcheck.sh +++ b/contrib/codeanalysis/runcppcheck.sh @@ -6,7 +6,7 @@ tar -xvf cppcheck-1.66.tar.bz2 cd cppcheck-1.66 make -j2 popd -../cppcheck-1.65/cppcheck --enable=all -I include --inline-suppr --std=c++11 --platform=unix64 src/main.cpp src/chai*.cpp --template ' - __{severity}__: [{file}:{line}](../blob/TRAVIS_COMMIT/{file}#L{line}) {message} ({id})' 2>output +../cppcheck-1.66/cppcheck --enable=all -I include --inline-suppr --std=c++11 --platform=unix64 src/main.cpp src/chai*.cpp --template ' - __{severity}__: [{file}:{line}](../blob/TRAVIS_COMMIT/{file}#L{line}) {message} ({id})' 2>output sed -i "s/TRAVIS_COMMIT/${TRAVIS_COMMIT}/g" output echo -n '{ "body": " ' > output.json echo -n `awk '{printf "%s\\\\n", $0;}' output` >> output.json From 29b1fca76c512c730825d4e0a57070cedab406d2 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 5 Sep 2014 08:09:22 -0600 Subject: [PATCH 5/6] Use g++-4.8 for cppcheck building --- contrib/codeanalysis/runcppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/codeanalysis/runcppcheck.sh b/contrib/codeanalysis/runcppcheck.sh index 05a492d..79e6313 100755 --- a/contrib/codeanalysis/runcppcheck.sh +++ b/contrib/codeanalysis/runcppcheck.sh @@ -4,7 +4,7 @@ pushd .. wget http://sourceforge.net/projects/cppcheck/files/cppcheck/1.66/cppcheck-1.66.tar.bz2 tar -xvf cppcheck-1.66.tar.bz2 cd cppcheck-1.66 -make -j2 +CXX=g++-4.8 make -j2 popd ../cppcheck-1.66/cppcheck --enable=all -I include --inline-suppr --std=c++11 --platform=unix64 src/main.cpp src/chai*.cpp --template ' - __{severity}__: [{file}:{line}](../blob/TRAVIS_COMMIT/{file}#L{line}) {message} ({id})' 2>output sed -i "s/TRAVIS_COMMIT/${TRAVIS_COMMIT}/g" output From 166f3501c3fa0bc54413097073e207db1e73234f Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 5 Sep 2014 08:41:58 -0600 Subject: [PATCH 6/6] Ignore missing system include files --- contrib/codeanalysis/runcppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/codeanalysis/runcppcheck.sh b/contrib/codeanalysis/runcppcheck.sh index 79e6313..54e9a82 100755 --- a/contrib/codeanalysis/runcppcheck.sh +++ b/contrib/codeanalysis/runcppcheck.sh @@ -6,7 +6,7 @@ tar -xvf cppcheck-1.66.tar.bz2 cd cppcheck-1.66 CXX=g++-4.8 make -j2 popd -../cppcheck-1.66/cppcheck --enable=all -I include --inline-suppr --std=c++11 --platform=unix64 src/main.cpp src/chai*.cpp --template ' - __{severity}__: [{file}:{line}](../blob/TRAVIS_COMMIT/{file}#L{line}) {message} ({id})' 2>output +../cppcheck-1.66/cppcheck --enable=all -I include --inline-suppr --suppress=missingIncludeSystem --std=c++11 --platform=unix64 src/main.cpp src/chai*.cpp --template ' - __{severity}__: [{file}:{line}](../blob/TRAVIS_COMMIT/{file}#L{line}) {message} ({id})' 2>output sed -i "s/TRAVIS_COMMIT/${TRAVIS_COMMIT}/g" output echo -n '{ "body": " ' > output.json echo -n `awk '{printf "%s\\\\n", $0;}' output` >> output.json