diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f463b45..cefe9ecb 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/contrib/codeanalysis/runcppcheck.sh b/contrib/codeanalysis/runcppcheck.sh index 5e79737a..54e9a823 100755 --- a/contrib/codeanalysis/runcppcheck.sh +++ b/contrib/codeanalysis/runcppcheck.sh @@ -4,9 +4,9 @@ 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.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 --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 diff --git a/include/chaiscript/chaiscript.hpp b/include/chaiscript/chaiscript.hpp index c8e9e9a0..4acabcf9 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 diff --git a/include/chaiscript/chaiscript_defines.hpp b/include/chaiscript/chaiscript_defines.hpp index cacb8bfb..59e302ee 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/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index fbe2fd7d..32aa9391 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 ec006d0e..09987fa1 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 426dc3b3..b4c0bc41 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()); diff --git a/releasenotes.md b/releasenotes.md index a60227ec..5a2d8bfc 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