Merge branch 'develop' of https://github.com/ChaiScript/ChaiScript into develop

Conflicts:
	include/chaiscript/language/chaiscript_common.hpp
	include/chaiscript/language/chaiscript_parser.hpp
This commit is contained in:
Jason Turner 2014-05-11 12:02:33 -06:00
commit 61cd633084
32 changed files with 603 additions and 355 deletions

View File

@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8)
project(chaiscript) project(chaiscript)
# MINGW does not yet support C++11's concurrency features # MINGW does not yet support C++11's concurrency features
if (MINGW) if(MINGW)
option(MULTITHREAD_SUPPORT_ENABLED "Multithreaded Support Enabled" FALSE) option(MULTITHREAD_SUPPORT_ENABLED "Multithreaded Support Enabled" FALSE)
else() else()
option(MULTITHREAD_SUPPORT_ENABLED "Multithreaded Support Enabled" TRUE) option(MULTITHREAD_SUPPORT_ENABLED "Multithreaded Support Enabled" TRUE)
@ -14,30 +14,30 @@ option(BUILD_MODULES "Build Extra Modules (stl, reflection)" TRUE)
option(BUILD_SAMPLES "Build Samples Folder" FALSE) option(BUILD_SAMPLES "Build Samples Folder" FALSE)
if (CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_GNUCC)
option(ENABLE_COVERAGE "Enable Coverage Reporting in GCC" FALSE) option(ENABLE_COVERAGE "Enable Coverage Reporting in GCC" FALSE)
if (ENABLE_COVERAGE) if(ENABLE_COVERAGE)
add_definitions(--coverage -O0) add_definitions(--coverage -O0)
set(LINKER_FLAGS "${LINKER_FLAGS} --coverage") set(LINKER_FLAGS "${LINKER_FLAGS} --coverage")
endif() endif()
endif() endif()
if (CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
option(ENABLE_THREAD_SANITIZER "Enable thread sanitizer testing in gcc/clang" FALSE) option(ENABLE_THREAD_SANITIZER "Enable thread sanitizer testing in gcc/clang" FALSE)
if (ENABLE_THREAD_SANITIZER) if(ENABLE_THREAD_SANITIZER)
add_definitions(-fsanitize=thread -g) add_definitions(-fsanitize=thread -g)
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=thread") set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=thread")
endif() endif()
option(ENABLE_ADDRESS_SANITIZER "Enable address sanitizer testing in gcc/clang" FALSE) option(ENABLE_ADDRESS_SANITIZER "Enable address sanitizer testing in gcc/clang" FALSE)
if (ENABLE_ADDRESS_SANITIZER) if(ENABLE_ADDRESS_SANITIZER)
add_definitions(-fsanitize=address -g) add_definitions(-fsanitize=address -g)
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=address") set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=address")
endif() endif()
option(ENABLE_UNDEFINED_SANITIZER "Enable undefined behavior sanitizer testing in gcc/clang" FALSE) option(ENABLE_UNDEFINED_SANITIZER "Enable undefined behavior sanitizer testing in gcc/clang" FALSE)
if (ENABLE_UNDEFINED_SANITIZER) if(ENABLE_UNDEFINED_SANITIZER)
add_definitions(-fsanitize=undefined -g) add_definitions(-fsanitize=undefined -g)
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=undefined") set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=undefined")
endif() endif()
@ -91,20 +91,20 @@ enable_testing()
message(STATUS "Detecting readline support") message(STATUS "Detecting readline support")
if (READLINE_LIBRARY) if(READLINE_LIBRARY)
message(STATUS "Found: ${READLINE_LIBRARY}") message(STATUS "Found: ${READLINE_LIBRARY}")
set (READLINE_LIB readline) set(READLINE_LIB readline)
add_definitions(/DREADLINE_AVAILABLE) add_definitions(/DREADLINE_AVAILABLE)
else(READLINE_LIBRARY) else()
message(STATUS "Not Found") message(STATUS "Not Found")
set (READLINE_LIB ) set(READLINE_LIB)
set (READLINE_FLAG ) set(READLINE_FLAG)
endif(READLINE_LIBRARY) endif()
if (CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_LESS 4.8) if(GCC_VERSION VERSION_LESS 4.8)
set(CPP11_FLAG "-std=c++0x") set(CPP11_FLAG "-std=c++0x")
else() else()
set(CPP11_FLAG "-std=c++11") set(CPP11_FLAG "-std=c++11")
@ -123,22 +123,22 @@ if(MSVC)
# The error did not come up until the move to C++11, but the compiler doesn't give enough information # The error did not come up until the move to C++11, but the compiler doesn't give enough information
# to determine where the error is coming from, and the internet provides no real information for # to determine where the error is coming from, and the internet provides no real information for
# how to workaround or fix the error. So I'm disabling it globally. # how to workaround or fix the error. So I'm disabling it globally.
ADD_DEFINITIONS(/wd4503) add_definitions(/wd4503)
else() else()
add_definitions(-Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic ${CPP11_FLAG}) add_definitions(-Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic ${CPP11_FLAG})
if (APPLE) if(APPLE)
add_definitions(-Wno-sign-compare) add_definitions(-Wno-sign-compare)
endif() endif()
endif() endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
option(USE_LIBCXX "Use clang's libcxx" TRUE) option(USE_LIBCXX "Use clang's libcxx" TRUE)
if (USE_LIBCXX) if(USE_LIBCXX)
add_definitions(-stdlib=libc++) add_definitions(-stdlib=libc++)
set(LINKER_FLAGS "${LINKER_FLAGS} ${CPP11_FLAG} -stdlib=libc++") set(LINKER_FLAGS "${LINKER_FLAGS} ${CPP11_FLAG} -stdlib=libc++")
else () else()
set(LINKER_FLAGS "${LINKER_FLAGS} ${CPP11_FLAG}") set(LINKER_FLAGS "${LINKER_FLAGS} ${CPP11_FLAG}")
endif() endif()
elseif(CMAKE_COMPILER_IS_GNUCC) elseif(CMAKE_COMPILER_IS_GNUCC)
@ -147,31 +147,30 @@ endif()
# limitations in MinGW require us to make an optimized build # limitations in MinGW require us to make an optimized build
# for the sake of object sizes or something # for the sake of object sizes or something
if (MINGW) if(MINGW)
add_definitions(-O3) add_definitions(-O3)
endif() endif()
include_directories(include) include_directories(include)
set (Chai_INCLUDES include/chaiscript/chaiscript.hpp include/chaiscript/chaiscript_threading.hpp include/chaiscript/dispatchkit/bad_boxed_cast.hpp include/chaiscript/dispatchkit/bind_first.hpp include/chaiscript/dispatchkit/bootstrap.hpp include/chaiscript/dispatchkit/bootstrap_stl.hpp include/chaiscript/dispatchkit/boxed_cast.hpp include/chaiscript/dispatchkit/boxed_cast_helper.hpp include/chaiscript/dispatchkit/boxed_number.hpp include/chaiscript/dispatchkit/boxed_value.hpp include/chaiscript/dispatchkit/dispatchkit.hpp include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp include/chaiscript/dispatchkit/dynamic_object.hpp include/chaiscript/dispatchkit/exception_specification.hpp include/chaiscript/dispatchkit/function_call.hpp include/chaiscript/dispatchkit/function_call_detail.hpp include/chaiscript/dispatchkit/handle_return.hpp include/chaiscript/dispatchkit/operators.hpp include/chaiscript/dispatchkit/proxy_constructors.hpp include/chaiscript/dispatchkit/proxy_functions.hpp include/chaiscript/dispatchkit/proxy_functions_detail.hpp include/chaiscript/dispatchkit/register_function.hpp include/chaiscript/dispatchkit/type_info.hpp include/chaiscript/language/chaiscript_algebraic.hpp include/chaiscript/language/chaiscript_common.hpp include/chaiscript/language/chaiscript_engine.hpp include/chaiscript/language/chaiscript_eval.hpp include/chaiscript/language/chaiscript_parser.hpp include/chaiscript/language/chaiscript_prelude.chai include/chaiscript/language/chaiscript_prelude_docs.hpp include/chaiscript/utility/utility.hpp) set(Chai_INCLUDES include/chaiscript/chaiscript.hpp include/chaiscript/chaiscript_threading.hpp include/chaiscript/dispatchkit/bad_boxed_cast.hpp include/chaiscript/dispatchkit/bind_first.hpp include/chaiscript/dispatchkit/bootstrap.hpp include/chaiscript/dispatchkit/bootstrap_stl.hpp include/chaiscript/dispatchkit/boxed_cast.hpp include/chaiscript/dispatchkit/boxed_cast_helper.hpp include/chaiscript/dispatchkit/boxed_number.hpp include/chaiscript/dispatchkit/boxed_value.hpp include/chaiscript/dispatchkit/dispatchkit.hpp include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp include/chaiscript/dispatchkit/dynamic_object.hpp include/chaiscript/dispatchkit/exception_specification.hpp include/chaiscript/dispatchkit/function_call.hpp include/chaiscript/dispatchkit/function_call_detail.hpp include/chaiscript/dispatchkit/handle_return.hpp include/chaiscript/dispatchkit/operators.hpp include/chaiscript/dispatchkit/proxy_constructors.hpp include/chaiscript/dispatchkit/proxy_functions.hpp include/chaiscript/dispatchkit/proxy_functions_detail.hpp include/chaiscript/dispatchkit/register_function.hpp include/chaiscript/dispatchkit/type_info.hpp include/chaiscript/language/chaiscript_algebraic.hpp include/chaiscript/language/chaiscript_common.hpp include/chaiscript/language/chaiscript_engine.hpp include/chaiscript/language/chaiscript_eval.hpp include/chaiscript/language/chaiscript_parser.hpp include/chaiscript/language/chaiscript_prelude.chai include/chaiscript/language/chaiscript_prelude_docs.hpp include/chaiscript/utility/utility.hpp)
set_source_files_properties(${Chai_INCLUDES} PROPERTIES HEADER_FILE_ONLY TRUE) set_source_files_properties(${Chai_INCLUDES} PROPERTIES HEADER_FILE_ONLY TRUE)
if (MULTITHREAD_SUPPORT_ENABLED) if(NOT MULTITHREAD_SUPPORT_ENABLED)
else()
add_definitions(-DCHAISCRIPT_NO_THREADS) add_definitions(-DCHAISCRIPT_NO_THREADS)
endif() endif()
if (CMAKE_HOST_UNIX) if(CMAKE_HOST_UNIX)
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
list(APPEND LIBS "dl") list(APPEND LIBS "dl")
endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") endif()
if (MULTITHREAD_SUPPORT_ENABLED) if(MULTITHREAD_SUPPORT_ENABLED)
if (CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE GCC_FULL_VERSION) execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE GCC_FULL_VERSION)
if (GCC_FULL_VERSION MATCHES "4.8.1.*ubuntu") if(GCC_FULL_VERSION MATCHES "4.8.1.*ubuntu")
set(LINKER_FLAGS "${LINKER_FLAGS} -Wl,--no-as-needed -pthread") set(LINKER_FLAGS "${LINKER_FLAGS} -Wl,--no-as-needed -pthread")
else() else()
set(LINKER_FLAGS "${LINKER_FLAGS} -pthread") set(LINKER_FLAGS "${LINKER_FLAGS} -pthread")
@ -183,7 +182,7 @@ if (CMAKE_HOST_UNIX)
add_definitions(-pthread) add_definitions(-pthread)
endif() endif()
endif(CMAKE_HOST_UNIX) endif()
list(APPEND LIBS ${READLINE_LIB}) list(APPEND LIBS ${READLINE_LIB})
@ -199,7 +198,7 @@ add_executable(chai src/main.cpp ${Chai_INCLUDES})
target_link_libraries(chai ${LIBS}) target_link_libraries(chai ${LIBS})
add_dependencies(chai chaiscript_stdlib-${CHAI_VERSION}) add_dependencies(chai chaiscript_stdlib-${CHAI_VERSION})
if (BUILD_SAMPLES) if(BUILD_SAMPLES)
add_executable(example samples/example.cpp) add_executable(example samples/example.cpp)
target_link_libraries(example ${LIBS}) target_link_libraries(example ${LIBS})
add_executable(memory_leak_test samples/memory_leak_test.cpp) add_executable(memory_leak_test samples/memory_leak_test.cpp)
@ -207,7 +206,7 @@ if (BUILD_SAMPLES)
endif() endif()
if (BUILD_MODULES) if(BUILD_MODULES)
add_library(stl_extra MODULE src/stl_extra.cpp) add_library(stl_extra MODULE src/stl_extra.cpp)
target_link_libraries(stl_extra ${LIBS}) target_link_libraries(stl_extra ${LIBS})
@ -225,7 +224,7 @@ if(BUILD_TESTING)
add_test(version_check chai -c "if(\"\\\${ version() };\\\${version_major()};\\\${version_minor()};\\\${version_patch()}\" != \"${CHAI_VERSION};${CPACK_PACKAGE_VERSION_MAJOR};${CPACK_PACKAGE_VERSION_MINOR};${CPACK_PACKAGE_VERSION_PATCH}\") { exit(-1) }") add_test(version_check chai -c "if(\"\\\${ version() };\\\${version_major()};\\\${version_minor()};\\\${version_patch()}\" != \"${CHAI_VERSION};${CPACK_PACKAGE_VERSION_MAJOR};${CPACK_PACKAGE_VERSION_MINOR};${CPACK_PACKAGE_VERSION_PATCH}\") { exit(-1) }")
set_property(TEST version_check set_property(TEST version_check
PROPERTY ENVIRONMENT PROPERTY ENVIRONMENT
"CHAI_USE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/unittests/" "CHAI_USE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/unittests/"
"CHAI_MODULE_PATH=${CMAKE_CURRENT_BINARY_DIR}/" "CHAI_MODULE_PATH=${CMAKE_CURRENT_BINARY_DIR}/"
) )
@ -234,15 +233,15 @@ if(BUILD_TESTING)
foreach(filename ${UNIT_TESTS}) foreach(filename ${UNIT_TESTS})
message(STATUS "Adding test ${filename}") message(STATUS "Adding test ${filename}")
add_test(${filename} chai ${CMAKE_CURRENT_SOURCE_DIR}/unittests/unit_test.inc ${CMAKE_CURRENT_SOURCE_DIR}/unittests/${filename}) add_test(${filename} chai ${CMAKE_CURRENT_SOURCE_DIR}/unittests/unit_test.inc ${CMAKE_CURRENT_SOURCE_DIR}/unittests/${filename})
endforeach(filename) endforeach()
set_property(TEST ${UNIT_TESTS} set_property(TEST ${UNIT_TESTS}
PROPERTY ENVIRONMENT PROPERTY ENVIRONMENT
"CHAI_USE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/unittests/" "CHAI_USE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/unittests/"
"CHAI_MODULE_PATH=${CMAKE_CURRENT_BINARY_DIR}/" "CHAI_MODULE_PATH=${CMAKE_CURRENT_BINARY_DIR}/"
) )
if (NOT UNIT_TEST_LIGHT) if(NOT UNIT_TEST_LIGHT)
# commented out because uniform initializer syntax is not working properly in MSVC 2013 # commented out because uniform initializer syntax is not working properly in MSVC 2013
add_executable(utility_test unittests/utility_test.cpp) add_executable(utility_test unittests/utility_test.cpp)
target_link_libraries(utility_test ${LIBS}) target_link_libraries(utility_test ${LIBS})
@ -316,7 +315,7 @@ if(BUILD_TESTING)
target_link_libraries(arithmetic_conversions_test ${LIBS}) target_link_libraries(arithmetic_conversions_test ${LIBS})
add_test(NAME Arithmetic_Conversions_Test COMMAND arithmetic_conversions_test) add_test(NAME Arithmetic_Conversions_Test COMMAND arithmetic_conversions_test)
if (MULTITHREAD_SUPPORT_ENABLED) if(MULTITHREAD_SUPPORT_ENABLED)
add_executable(multithreaded_test unittests/multithreaded_test.cpp) add_executable(multithreaded_test unittests/multithreaded_test.cpp)
target_link_libraries(multithreaded_test ${LIBS}) target_link_libraries(multithreaded_test ${LIBS})
add_test(NAME Multithreaded_Test COMMAND multithreaded_test) add_test(NAME Multithreaded_Test COMMAND multithreaded_test)
@ -324,13 +323,16 @@ if(BUILD_TESTING)
PROPERTY ENVIRONMENT PROPERTY ENVIRONMENT
"CHAI_USE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/unittests/" "CHAI_USE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/unittests/"
"CHAI_MODULE_PATH=${CMAKE_CURRENT_BINARY_DIR}/" "CHAI_MODULE_PATH=${CMAKE_CURRENT_BINARY_DIR}/"
) )
endif() endif()
add_executable(multifile_test unittests/multifile_test_main.cpp unittests/multifile_test_chai.cpp add_executable(multifile_test
unittests/multifile_test_module.cpp) unittests/multifile_test_main.cpp
unittests/multifile_test_chai.cpp
unittests/multifile_test_module.cpp
)
target_link_libraries(multifile_test ${LIBS}) target_link_libraries(multifile_test ${LIBS})
add_test(NAME MultiFile_Test COMMAND multifile_test) add_test(NAME MultiFile_Test COMMAND multifile_test)
@ -339,26 +341,26 @@ if(BUILD_TESTING)
install(TARGETS test_module RUNTIME DESTINATION bin LIBRARY DESTINATION lib/chaiscript) install(TARGETS test_module RUNTIME DESTINATION bin LIBRARY DESTINATION lib/chaiscript)
endif() endif()
endif(BUILD_TESTING) endif()
install(TARGETS chai chaiscript_stdlib-${CHAI_VERSION} ${MODULES} RUNTIME DESTINATION bin LIBRARY DESTINATION lib/chaiscript ) install(TARGETS chai chaiscript_stdlib-${CHAI_VERSION} ${MODULES} RUNTIME DESTINATION bin LIBRARY DESTINATION lib/chaiscript)
install(DIRECTORY include/chaiscript DESTINATION include install(DIRECTORY include/chaiscript DESTINATION include
PATTERN "*.hpp" PATTERN "*.hpp"
PATTERN "*/.svn*" EXCLUDE PATTERN "*/.svn*" EXCLUDE
PATTERN "*/.git*" EXCLUDE PATTERN "*/.git*" EXCLUDE
PATTERN "*~" EXCLUDE) PATTERN "*~" EXCLUDE)
install(DIRECTORY unittests DESTINATION share/chaiscript install(DIRECTORY unittests DESTINATION share/chaiscript
PATTERN "*.chai" PATTERN "*.chai"
PATTERN "*.inc" PATTERN "*.inc"
PATTERN "*/.svn*" EXCLUDE PATTERN "*/.svn*" EXCLUDE
PATTERN "*/.git*" EXCLUDE PATTERN "*/.git*" EXCLUDE
PATTERN "*~" EXCLUDE) PATTERN "*~" EXCLUDE)
install(DIRECTORY samples DESTINATION share/chaiscript install(DIRECTORY samples DESTINATION share/chaiscript
PATTERN "*.chai" PATTERN "*.chai"
PATTERN "*/.svn*" EXCLUDE PATTERN "*/.svn*" EXCLUDE
PATTERN "*/.git*" EXCLUDE PATTERN "*/.git*" EXCLUDE
PATTERN "*~" EXCLUDE) PATTERN "*~" EXCLUDE)
configure_file(contrib/pkgconfig/chaiscript.pc.in lib/pkgconfig/chaiscript.pc @ONLY) configure_file(contrib/pkgconfig/chaiscript.pc.in lib/pkgconfig/chaiscript.pc @ONLY)
install(FILES "${chaiscript_BINARY_DIR}/lib/pkgconfig/chaiscript.pc" install(FILES "${chaiscript_BINARY_DIR}/lib/pkgconfig/chaiscript.pc"

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
pushd .. pushd ..
wget http://sourceforge.net/projects/cppcheck/files/cppcheck/1.64/cppcheck-1.64.tar.bz2 wget http://sourceforge.net/projects/cppcheck/files/cppcheck/1.64/cppcheck-1.65.tar.bz2
tar -xvf cppcheck-1.64.tar.bz2 tar -xvf cppcheck-1.65.tar.bz2
cd cppcheck-1.64 cd cppcheck-1.65
make -j2 make -j2
popd popd
../cppcheck-1.64/cppcheck --enable=all --inconclusive -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.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
sed -i "s/TRAVIS_COMMIT/${TRAVIS_COMMIT}/g" output sed -i "s/TRAVIS_COMMIT/${TRAVIS_COMMIT}/g" output
echo -n '{ "body": " ' > output.json echo -n '{ "body": " ' > output.json
echo -n `awk '{printf "%s\\\\n", $0;}' output` >> output.json echo -n `awk '{printf "%s\\\\n", $0;}' output` >> output.json

View File

@ -16,12 +16,19 @@
#define CHAISCRIPT_WINDOWS #define CHAISCRIPT_WINDOWS
#endif #endif
#if defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) #if (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
/// Currently only g++>=4.8supports this natively /// Currently only g++>=4.8supports this natively
/// \todo Make this support other compilers when possible /// \todo Make this support other compilers when possible
#define CHAISCRIPT_HAS_THREAD_LOCAL #define CHAISCRIPT_HAS_THREAD_LOCAL
#endif #endif
#if (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || defined(CHAISCRIPT_MSVC) || defined(__llvm__)
#define CHAISCRIPT_OVERRIDE override
#else
#define CHAISCRIPT_OVERRIDE
#endif
#ifdef CHAISCRIPT_HAS_DECLSPEC #ifdef CHAISCRIPT_HAS_DECLSPEC
#define CHAISCRIPT_MODULE_EXPORT extern "C" __declspec(dllexport) #define CHAISCRIPT_MODULE_EXPORT extern "C" __declspec(dllexport)
#else #else

View File

@ -7,9 +7,17 @@
#ifndef CHAISCRIPT_STDLIB_HPP_ #ifndef CHAISCRIPT_STDLIB_HPP_
#define CHAISCRIPT_STDLIB_HPP_ #define CHAISCRIPT_STDLIB_HPP_
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "chaiscript_defines.hpp" #include "chaiscript_defines.hpp"
#include "dispatchkit/dispatchkit.hpp"
#include "dispatchkit/bootstrap.hpp" #include "dispatchkit/bootstrap.hpp"
#include "dispatchkit/bootstrap_stl.hpp" #include "dispatchkit/bootstrap_stl.hpp"
#include "dispatchkit/boxed_value.hpp"
/// @file /// @file
/// ///

View File

@ -7,6 +7,8 @@
#ifndef CHAISCRIPT_ANY_HPP_ #ifndef CHAISCRIPT_ANY_HPP_
#define CHAISCRIPT_ANY_HPP_ #define CHAISCRIPT_ANY_HPP_
#include <utility>
namespace chaiscript { namespace chaiscript {
namespace detail { namespace detail {
namespace exception namespace exception
@ -27,7 +29,7 @@ namespace chaiscript {
virtual ~bad_any_cast() CHAISCRIPT_NOEXCEPT {} virtual ~bad_any_cast() CHAISCRIPT_NOEXCEPT {}
/// \brief Description of what error occured /// \brief Description of what error occured
virtual const char * what() const CHAISCRIPT_NOEXCEPT virtual const char * what() const CHAISCRIPT_NOEXCEPT CHAISCRIPT_OVERRIDE
{ {
return m_what.c_str(); return m_what.c_str();
} }
@ -51,25 +53,25 @@ namespace chaiscript {
template<typename T> template<typename T>
struct Data_Impl : Data struct Data_Impl : Data
{ {
Data_Impl(const T &t_type) Data_Impl(T t_type)
: m_type(typeid(T)), : m_type(typeid(T)),
m_data(t_type) m_data(std::move(t_type))
{ {
} }
virtual ~Data_Impl() {} virtual ~Data_Impl() {}
virtual void *data() virtual void *data() CHAISCRIPT_OVERRIDE
{ {
return &m_data; return &m_data;
} }
const std::type_info &type() const const std::type_info &type() const CHAISCRIPT_OVERRIDE
{ {
return m_type; return m_type;
} }
std::shared_ptr<Data> clone() const std::shared_ptr<Data> clone() const CHAISCRIPT_OVERRIDE
{ {
return std::shared_ptr<Data>(new Data_Impl<T>(m_data)); return std::shared_ptr<Data>(new Data_Impl<T>(m_data));
} }

View File

@ -7,8 +7,15 @@
#ifndef CHAISCRIPT_BAD_BOXED_CAST_HPP_ #ifndef CHAISCRIPT_BAD_BOXED_CAST_HPP_
#define CHAISCRIPT_BAD_BOXED_CAST_HPP_ #define CHAISCRIPT_BAD_BOXED_CAST_HPP_
#include <string>
#include <typeinfo>
#include "type_info.hpp" #include "type_info.hpp"
namespace chaiscript {
class Type_Info;
} // namespace chaiscript
namespace chaiscript namespace chaiscript
{ {
namespace exception namespace exception
@ -22,8 +29,8 @@ namespace chaiscript
{ {
public: public:
bad_boxed_cast(const Type_Info &t_from, const std::type_info &t_to, bad_boxed_cast(const Type_Info &t_from, const std::type_info &t_to,
const std::string &t_what) CHAISCRIPT_NOEXCEPT std::string t_what) CHAISCRIPT_NOEXCEPT
: from(t_from), to(&t_to), m_what(t_what) : from(t_from), to(&t_to), m_what(std::move(t_what))
{ {
} }
@ -32,15 +39,15 @@ namespace chaiscript
{ {
} }
bad_boxed_cast(const std::string &t_what) CHAISCRIPT_NOEXCEPT bad_boxed_cast(std::string t_what) CHAISCRIPT_NOEXCEPT
: to(0), m_what(t_what) : to(nullptr), m_what(std::move(t_what))
{ {
} }
virtual ~bad_boxed_cast() CHAISCRIPT_NOEXCEPT {} virtual ~bad_boxed_cast() CHAISCRIPT_NOEXCEPT {}
/// \brief Description of what error occured /// \brief Description of what error occured
virtual const char * what() const CHAISCRIPT_NOEXCEPT virtual const char * what() const CHAISCRIPT_NOEXCEPT CHAISCRIPT_OVERRIDE
{ {
return m_what.c_str(); return m_what.c_str();
} }

View File

@ -7,13 +7,31 @@
#ifndef CHAISCRIPT_BOOTSTRAP_HPP_ #ifndef CHAISCRIPT_BOOTSTRAP_HPP_
#define CHAISCRIPT_BOOTSTRAP_HPP_ #define CHAISCRIPT_BOOTSTRAP_HPP_
#include "dispatchkit.hpp" #include <cstdint>
#include "dynamic_object.hpp" #include <exception>
#include "register_function.hpp" #include <functional>
#include "operators.hpp" #include <iostream>
#include "boxed_number.hpp" #include <map>
#include <memory>
#include <sstream> #include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits> #include <type_traits>
#include <vector>
#include "bad_boxed_cast.hpp"
#include "boxed_cast.hpp"
#include "boxed_number.hpp"
#include "boxed_value.hpp"
#include "dispatchkit.hpp"
#include "dynamic_cast_conversion.hpp"
#include "dynamic_object.hpp"
#include "operators.hpp"
#include "proxy_constructors.hpp"
#include "proxy_functions.hpp"
#include "proxy_functions_detail.hpp"
#include "register_function.hpp"
#include "type_info.hpp"
namespace chaiscript namespace chaiscript
{ {

View File

@ -13,9 +13,21 @@
#ifndef CHAISCRIPT_BOOTSTRAP_STL_HPP_ #ifndef CHAISCRIPT_BOOTSTRAP_STL_HPP_
#define CHAISCRIPT_BOOTSTRAP_STL_HPP_ #define CHAISCRIPT_BOOTSTRAP_STL_HPP_
#include "dispatchkit.hpp" #include <functional>
#include <iterator>
#include <memory>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include <vector>
#include "bootstrap.hpp" #include "bootstrap.hpp"
#include "boxed_value.hpp"
#include "dispatchkit.hpp"
#include "operators.hpp"
#include "proxy_constructors.hpp"
#include "register_function.hpp" #include "register_function.hpp"
#include "type_info.hpp"
namespace chaiscript namespace chaiscript
{ {
@ -189,8 +201,8 @@ namespace chaiscript
template<typename Type> template<typename Type>
void insert_at(Type &container, int pos, const typename Type::value_type &v) void insert_at(Type &container, int pos, const typename Type::value_type &v)
{ {
typename Type::iterator itr = container.begin(); auto itr = container.begin();
typename Type::iterator end = container.end(); auto end = container.end();
if (pos < 0 || std::distance(itr, end) < pos) if (pos < 0 || std::distance(itr, end) < pos)
{ {
@ -206,8 +218,8 @@ namespace chaiscript
template<typename Type> template<typename Type>
void erase_at(Type &container, int pos) void erase_at(Type &container, int pos)
{ {
typename Type::iterator itr = container.begin(); auto itr = container.begin();
typename Type::iterator end = container.end(); auto end = container.end();
if (pos < 0 || std::distance(itr, end) < (pos-1)) if (pos < 0 || std::distance(itr, end) < (pos-1))
{ {

View File

@ -7,14 +7,24 @@
#ifndef CHAISCRIPT_BOXED_CAST_HPP_ #ifndef CHAISCRIPT_BOXED_CAST_HPP_
#define CHAISCRIPT_BOXED_CAST_HPP_ #define CHAISCRIPT_BOXED_CAST_HPP_
#include <type_traits>
#include "../chaiscript_defines.hpp" #include "../chaiscript_defines.hpp"
#include "type_info.hpp"
#include "boxed_value.hpp"
#include "boxed_cast_helper.hpp"
#include "dynamic_cast_conversion.hpp"
#include "../chaiscript_threading.hpp" #include "../chaiscript_threading.hpp"
#include "bad_boxed_cast.hpp"
#include "boxed_cast_helper.hpp"
#include "boxed_value.hpp"
#include "dynamic_cast_conversion.hpp"
#include "type_info.hpp"
namespace chaiscript {
class Dynamic_Cast_Conversions;
namespace detail {
namespace exception {
class bad_any_cast;
} // namespace exception
} // namespace detail
} // namespace chaiscript
namespace chaiscript namespace chaiscript
{ {

View File

@ -7,8 +7,12 @@
#ifndef CHAISCRIPT_BOXED_CAST_HELPER_HPP_ #ifndef CHAISCRIPT_BOXED_CAST_HELPER_HPP_
#define CHAISCRIPT_BOXED_CAST_HELPER_HPP_ #define CHAISCRIPT_BOXED_CAST_HELPER_HPP_
#include "type_info.hpp" #include <functional>
#include <memory>
#include <type_traits>
#include "boxed_value.hpp" #include "boxed_value.hpp"
#include "type_info.hpp"
namespace chaiscript namespace chaiscript

View File

@ -7,10 +7,20 @@
#ifndef CHAISCRIPT_BOXED_NUMERIC_HPP_ #ifndef CHAISCRIPT_BOXED_NUMERIC_HPP_
#define CHAISCRIPT_BOXED_NUMERIC_HPP_ #define CHAISCRIPT_BOXED_NUMERIC_HPP_
#include "boxed_value.hpp"
#include "../language/chaiscript_algebraic.hpp"
#include <sstream>
#include <cstdint> #include <cstdint>
#include <sstream>
#include <string>
#include "../language/chaiscript_algebraic.hpp"
#include "any.hpp"
#include "boxed_cast.hpp"
#include "boxed_cast_helper.hpp"
#include "boxed_value.hpp"
#include "type_info.hpp"
namespace chaiscript {
class Dynamic_Cast_Conversions;
} // namespace chaiscript
namespace chaiscript namespace chaiscript
{ {

View File

@ -7,12 +7,14 @@
#ifndef CHAISCRIPT_BOXED_VALUE_HPP_ #ifndef CHAISCRIPT_BOXED_VALUE_HPP_
#define CHAISCRIPT_BOXED_VALUE_HPP_ #define CHAISCRIPT_BOXED_VALUE_HPP_
#include "type_info.hpp" #include <functional>
#include <map>
#include <memory>
#include <type_traits>
#include "../chaiscript_threading.hpp" #include "../chaiscript_threading.hpp"
#include <map>
#include "any.hpp" #include "any.hpp"
#include "type_info.hpp"
namespace chaiscript namespace chaiscript
{ {
@ -36,7 +38,7 @@ namespace chaiscript
const chaiscript::detail::Any &to, const chaiscript::detail::Any &to,
bool tr, bool tr,
const void *t_void_ptr) const void *t_void_ptr)
: m_type_info(ti), m_obj(to), m_data_ptr(ti.is_const()?0:const_cast<void *>(t_void_ptr)), m_const_data_ptr(t_void_ptr), : m_type_info(ti), m_obj(to), m_data_ptr(ti.is_const()?nullptr:const_cast<void *>(t_void_ptr)), m_const_data_ptr(t_void_ptr),
m_is_ref(tr) m_is_ref(tr)
{ {
} }
@ -201,7 +203,7 @@ namespace chaiscript
bool is_null() const bool is_null() const
{ {
return (m_data->m_data_ptr == 0 && m_data->m_const_data_ptr == 0); return (m_data->m_data_ptr == nullptr && m_data->m_const_data_ptr == nullptr);
} }
const chaiscript::detail::Any & get() const const chaiscript::detail::Any & get() const

View File

@ -7,23 +7,43 @@
#ifndef CHAISCRIPT_DISPATCHKIT_HPP_ #ifndef CHAISCRIPT_DISPATCHKIT_HPP_
#define CHAISCRIPT_DISPATCHKIT_HPP_ #define CHAISCRIPT_DISPATCHKIT_HPP_
#include <typeinfo> #include <algorithm>
#include <string> #include <cassert>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map> #include <map>
#include <memory>
#include <set> #include <set>
#include <stdexcept> #include <stdexcept>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector> #include <vector>
#include <iostream>
#include <deque>
#include <list>
#include <algorithm>
#include "boxed_value.hpp" #include "../chaiscript_defines.hpp"
#include "type_info.hpp"
#include "proxy_functions.hpp"
#include "proxy_constructors.hpp"
#include "dynamic_object.hpp"
#include "../chaiscript_threading.hpp" #include "../chaiscript_threading.hpp"
#include "boxed_cast.hpp"
#include "boxed_cast_helper.hpp"
#include "boxed_value.hpp"
#include "dynamic_cast_conversion.hpp"
#include "dynamic_object.hpp"
#include "proxy_constructors.hpp"
#include "proxy_functions.hpp"
#include "type_info.hpp"
namespace chaiscript {
class Boxed_Number;
} // namespace chaiscript
namespace chaiscript {
namespace dispatch {
class Dynamic_Proxy_Function;
class Proxy_Function_Base;
struct Placeholder_Object;
} // namespace dispatch
} // namespace chaiscript
/// \namespace chaiscript::dispatch /// \namespace chaiscript::dispatch
@ -188,7 +208,7 @@ namespace chaiscript
std::vector<Dynamic_Cast_Conversion> m_conversions; std::vector<Dynamic_Cast_Conversion> m_conversions;
template<typename T, typename InItr> template<typename T, typename InItr>
void apply(InItr begin, InItr end, T &t) const static void apply(InItr begin, InItr end, T &t)
{ {
while (begin != end) while (begin != end)
{ {
@ -203,7 +223,7 @@ namespace chaiscript
} }
template<typename T, typename InItr> template<typename T, typename InItr>
void apply_globals(InItr begin, InItr end, T &t) const static void apply_globals(InItr begin, InItr end, T &t)
{ {
while (begin != end) while (begin != end)
{ {
@ -213,7 +233,7 @@ namespace chaiscript
} }
template<typename T, typename InItr> template<typename T, typename InItr>
void apply_single(InItr begin, InItr end, T &t) const static void apply_single(InItr begin, InItr end, T &t)
{ {
while (begin != end) while (begin != end)
{ {
@ -223,7 +243,7 @@ namespace chaiscript
} }
template<typename T, typename InItr> template<typename T, typename InItr>
void apply_eval(InItr begin, InItr end, T &t) const static void apply_eval(InItr begin, InItr end, T &t)
{ {
while (begin != end) while (begin != end)
{ {
@ -252,7 +272,7 @@ namespace chaiscript
{ {
} }
virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE
{ {
try { try {
const Dispatch_Function &dispatchfun = dynamic_cast<const Dispatch_Function &>(rhs); const Dispatch_Function &dispatchfun = dynamic_cast<const Dispatch_Function &>(rhs);
@ -264,17 +284,17 @@ namespace chaiscript
virtual ~Dispatch_Function() {} virtual ~Dispatch_Function() {}
virtual std::vector<Const_Proxy_Function> get_contained_functions() const virtual std::vector<Const_Proxy_Function> get_contained_functions() const CHAISCRIPT_OVERRIDE
{ {
return std::vector<Const_Proxy_Function>(m_funcs.begin(), m_funcs.end()); return std::vector<Const_Proxy_Function>(m_funcs.begin(), m_funcs.end());
} }
virtual int get_arity() const virtual int get_arity() const CHAISCRIPT_OVERRIDE
{ {
typedef std::vector<Proxy_Function> function_vec; typedef std::vector<Proxy_Function> function_vec;
function_vec::const_iterator begin = m_funcs.begin(); auto begin = m_funcs.begin();
const function_vec::const_iterator end = m_funcs.end(); const function_vec::const_iterator end = m_funcs.end();
if (begin != end) if (begin != end)
@ -300,12 +320,10 @@ namespace chaiscript
return -1; // unknown arity return -1; // unknown arity
} }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
typedef std::vector<Proxy_Function> function_vec; auto begin = m_funcs.begin();
auto end = m_funcs.end();
function_vec::const_iterator begin = m_funcs.begin();
function_vec::const_iterator end = m_funcs.end();
while (begin != end) while (begin != end)
{ {
@ -320,13 +338,13 @@ namespace chaiscript
return false; return false;
} }
virtual std::string annotation() const virtual std::string annotation() const CHAISCRIPT_OVERRIDE
{ {
return "Multiple method dispatch function wrapper."; return "Multiple method dispatch function wrapper.";
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
return dispatch::dispatch(m_funcs.begin(), m_funcs.end(), params, t_conversions); return dispatch::dispatch(m_funcs.begin(), m_funcs.end(), params, t_conversions);
} }
@ -338,7 +356,7 @@ namespace chaiscript
{ {
typedef std::vector<Proxy_Function> function_vec; typedef std::vector<Proxy_Function> function_vec;
function_vec::const_iterator begin = t_funcs.begin(); auto begin = t_funcs.begin();
const function_vec::const_iterator end = t_funcs.end(); const function_vec::const_iterator end = t_funcs.end();
if (begin != end) if (begin != end)
@ -466,18 +484,18 @@ namespace chaiscript
add_object(name, obj); add_object(name, obj);
} }
/** /**
* Adds a named object to the current scope * Adds a named object to the current scope
*/ */
void add_object(const std::string &name, const Boxed_Value &obj) void add_object(const std::string &name, const Boxed_Value &obj) const
{ {
StackData &stack = get_stack_data(); StackData &stack = get_stack_data();
validate_object_name(name); validate_object_name(name);
Scope &scope = stack.back(); Scope &scope = stack.back();
Scope::iterator itr = scope.find(name); auto itr = scope.find(name);
if (itr != stack.back().end()) if (itr != stack.back().end())
{ {
throw chaiscript::exception::name_conflict_error(name); throw chaiscript::exception::name_conflict_error(name);
@ -598,7 +616,7 @@ namespace chaiscript
{ {
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_global_object_mutex); chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_global_object_mutex);
std::map<std::string, Boxed_Value>::const_iterator itr = m_state.m_global_objects.find(name); auto itr = m_state.m_global_objects.find(name);
if (itr != m_state.m_global_objects.end()) if (itr != m_state.m_global_objects.end())
{ {
return itr->second; return itr->second;
@ -628,7 +646,7 @@ namespace chaiscript
{ {
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex); chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex);
Type_Name_Map::const_iterator itr = m_state.m_types.find(name); auto itr = m_state.m_types.find(name);
if (itr != m_state.m_types.end()) if (itr != m_state.m_types.end())
{ {
@ -647,13 +665,11 @@ namespace chaiscript
{ {
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex); chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex);
for (Type_Name_Map::const_iterator itr = m_state.m_types.begin(); for (const auto & elem : m_state.m_types)
itr != m_state.m_types.end();
++itr)
{ {
if (itr->second.bare_equal(ti)) if (elem.second.bare_equal(ti))
{ {
return itr->first; return elem.first;
} }
} }
@ -680,7 +696,7 @@ namespace chaiscript
const std::map<std::string, std::vector<Proxy_Function> > &funs = get_functions_int(); const std::map<std::string, std::vector<Proxy_Function> > &funs = get_functions_int();
std::map<std::string, std::vector<Proxy_Function> >::const_iterator itr auto itr
= funs.find(t_name); = funs.find(t_name);
if (itr != funs.end()) if (itr != funs.end())
@ -699,7 +715,7 @@ namespace chaiscript
const std::map<std::string, Proxy_Function> &funs = get_function_objects_int(); const std::map<std::string, Proxy_Function> &funs = get_function_objects_int();
std::map<std::string, Proxy_Function>::const_iterator itr = funs.find(t_name); auto itr = funs.find(t_name);
if (itr != funs.end()) if (itr != funs.end())
{ {
@ -756,7 +772,7 @@ namespace chaiscript
// note: map insert doesn't overwrite existing values, which is why this works // note: map insert doesn't overwrite existing values, which is why this works
for (StackData::reverse_iterator itr = stack.rbegin(); itr != stack.rend(); ++itr) for (auto itr = stack.rbegin(); itr != stack.rend(); ++itr)
{ {
retval.insert(itr->begin(), itr->end()); retval.insert(itr->begin(), itr->end());
} }
@ -783,11 +799,9 @@ namespace chaiscript
std::map<std::string, Boxed_Value> objs; std::map<std::string, Boxed_Value> objs;
for (std::map<std::string, Proxy_Function>::const_iterator itr = funs.begin(); for (const auto & fun : funs)
itr != funs.end();
++itr)
{ {
objs.insert(std::make_pair(itr->first, const_var(itr->second))); objs.insert(std::make_pair(fun.first, const_var(fun.second)));
} }
return objs; return objs;
@ -805,15 +819,11 @@ namespace chaiscript
const std::map<std::string, std::vector<Proxy_Function> > &functions = get_functions_int(); const std::map<std::string, std::vector<Proxy_Function> > &functions = get_functions_int();
for (std::map<std::string, std::vector<Proxy_Function> >::const_iterator itr = functions.begin(); for (const auto & function : functions)
itr != functions.end();
++itr)
{ {
for (std::vector<Proxy_Function>::const_iterator itr2 = itr->second.begin(); for (const auto & internal_func : function.second)
itr2 != itr->second.end();
++itr2)
{ {
rets.push_back(std::make_pair(itr->first, *itr2)); rets.push_back(std::make_pair(function.first, internal_func));
} }
} }
@ -977,7 +987,7 @@ namespace chaiscript
return get_type_name(obj.get_type_info()); return get_type_name(obj.get_type_info());
} }
State get_state() State get_state() const
{ {
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex); chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex);
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l2(m_global_object_mutex); chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l2(m_global_object_mutex);
@ -1171,7 +1181,7 @@ namespace chaiscript
std::map<std::string, std::vector<Proxy_Function> > &funcs = get_functions_int(); std::map<std::string, std::vector<Proxy_Function> > &funcs = get_functions_int();
std::map<std::string, std::vector<Proxy_Function> >::iterator itr auto itr
= funcs.find(t_name); = funcs.find(t_name);
std::map<std::string, Proxy_Function> &func_objs = get_function_objects_int(); std::map<std::string, Proxy_Function> &func_objs = get_function_objects_int();

View File

@ -9,11 +9,16 @@
#include <memory> #include <memory>
#include <set> #include <set>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <typeinfo>
#include "type_info.hpp" #include "../chaiscript_threading.hpp"
#include "boxed_value.hpp"
#include "boxed_cast_helper.hpp"
#include "bad_boxed_cast.hpp" #include "bad_boxed_cast.hpp"
#include "boxed_cast_helper.hpp"
#include "boxed_value.hpp"
#include "type_info.hpp"
namespace chaiscript namespace chaiscript
{ {
@ -109,11 +114,11 @@ namespace chaiscript
// Pull the reference out of the contained boxed value, which we know is the type we want // Pull the reference out of the contained boxed value, which we know is the type we want
if (t_from.is_const()) if (t_from.is_const())
{ {
const From &d = detail::Cast_Helper<const From &>::cast(t_from, 0); const From &d = detail::Cast_Helper<const From &>::cast(t_from, nullptr);
const To &data = dynamic_cast<const To &>(d); const To &data = dynamic_cast<const To &>(d);
return Boxed_Value(std::cref(data)); return Boxed_Value(std::cref(data));
} else { } else {
From &d = detail::Cast_Helper<From &>::cast(t_from, 0); From &d = detail::Cast_Helper<From &>::cast(t_from, nullptr);
To &data = dynamic_cast<To &>(d); To &data = dynamic_cast<To &>(d);
return Boxed_Value(std::ref(data)); return Boxed_Value(std::ref(data));
} }
@ -133,12 +138,12 @@ namespace chaiscript
{ {
} }
virtual Boxed_Value convert_down(const Boxed_Value &t_base) const virtual Boxed_Value convert_down(const Boxed_Value &t_base) const CHAISCRIPT_OVERRIDE
{ {
return Dynamic_Caster<Base, Derived>::cast(t_base); return Dynamic_Caster<Base, Derived>::cast(t_base);
} }
virtual Boxed_Value convert(const Boxed_Value &t_derived) const virtual Boxed_Value convert(const Boxed_Value &t_derived) const CHAISCRIPT_OVERRIDE
{ {
return Dynamic_Caster<Derived, Base>::cast(t_derived); return Dynamic_Caster<Derived, Base>::cast(t_derived);
} }
@ -209,7 +214,7 @@ namespace chaiscript
{ {
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex); chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex);
std::set<std::shared_ptr<detail::Dynamic_Conversion> >::const_iterator itr = auto itr =
find(base, derived); find(base, derived);
if (itr != m_conversions.end()) if (itr != m_conversions.end())
@ -224,7 +229,7 @@ namespace chaiscript
std::set<std::shared_ptr<detail::Dynamic_Conversion> >::const_iterator find( std::set<std::shared_ptr<detail::Dynamic_Conversion> >::const_iterator find(
const Type_Info &base, const Type_Info &derived) const const Type_Info &base, const Type_Info &derived) const
{ {
for (std::set<std::shared_ptr<detail::Dynamic_Conversion> >::const_iterator itr = m_conversions.begin(); for (auto itr = m_conversions.begin();
itr != m_conversions.end(); itr != m_conversions.end();
++itr) ++itr)
{ {

View File

@ -7,6 +7,27 @@
#ifndef CHAISCRIPT_DYNAMIC_OBJECT_HPP_ #ifndef CHAISCRIPT_DYNAMIC_OBJECT_HPP_
#define CHAISCRIPT_DYNAMIC_OBJECT_HPP_ #define CHAISCRIPT_DYNAMIC_OBJECT_HPP_
#include <cassert>
#include <map>
#include <memory>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#include "../chaiscript_defines.hpp"
#include "boxed_cast.hpp"
#include "boxed_cast_helper.hpp"
#include "boxed_value.hpp"
#include "proxy_functions.hpp"
#include "type_info.hpp"
namespace chaiscript {
class Dynamic_Cast_Conversions;
namespace dispatch {
class Proxy_Function_Base;
} // namespace dispatch
} // namespace chaiscript
namespace chaiscript namespace chaiscript
{ {
@ -15,8 +36,8 @@ namespace chaiscript
class Dynamic_Object class Dynamic_Object
{ {
public: public:
Dynamic_Object(const std::string &t_type_name) Dynamic_Object(std::string t_type_name)
: m_type_name(t_type_name) : m_type_name(std::move(t_type_name))
{ {
} }
@ -52,21 +73,21 @@ namespace chaiscript
{ {
public: public:
Dynamic_Object_Function( Dynamic_Object_Function(
const std::string &t_type_name, std::string t_type_name,
const Proxy_Function &t_func) const Proxy_Function &t_func)
: Proxy_Function_Base(t_func->get_param_types()), : Proxy_Function_Base(t_func->get_param_types()),
m_type_name(t_type_name), m_func(t_func), m_doti(user_type<Dynamic_Object>()) m_type_name(std::move(t_type_name)), m_func(t_func), m_doti(user_type<Dynamic_Object>())
{ {
assert( (t_func->get_arity() > 0 || t_func->get_arity() < 0) assert( (t_func->get_arity() > 0 || t_func->get_arity() < 0)
&& "Programming error, Dynamic_Object_Function must have at least one parameter (this)"); && "Programming error, Dynamic_Object_Function must have at least one parameter (this)");
} }
Dynamic_Object_Function( Dynamic_Object_Function(
const std::string &t_type_name, std::string t_type_name,
const Proxy_Function &t_func, const Proxy_Function &t_func,
const Type_Info &t_ti) const Type_Info &t_ti)
: Proxy_Function_Base(build_param_types(t_func->get_param_types(), t_ti)), : Proxy_Function_Base(build_param_types(t_func->get_param_types(), t_ti)),
m_type_name(t_type_name), m_func(t_func), m_ti(new Type_Info(t_ti)), m_doti(user_type<Dynamic_Object>()) m_type_name(std::move(t_type_name)), m_func(t_func), m_ti(new Type_Info(t_ti)), m_doti(user_type<Dynamic_Object>())
{ {
assert( (t_func->get_arity() > 0 || t_func->get_arity() < 0) assert( (t_func->get_arity() > 0 || t_func->get_arity() < 0)
&& "Programming error, Dynamic_Object_Function must have at least one parameter (this)"); && "Programming error, Dynamic_Object_Function must have at least one parameter (this)");
@ -76,7 +97,7 @@ namespace chaiscript
Dynamic_Object_Function &operator=(const Dynamic_Object_Function) = delete; Dynamic_Object_Function &operator=(const Dynamic_Object_Function) = delete;
virtual bool operator==(const Proxy_Function_Base &f) const virtual bool operator==(const Proxy_Function_Base &f) const CHAISCRIPT_OVERRIDE
{ {
const Dynamic_Object_Function *df = dynamic_cast<const Dynamic_Object_Function *>(&f); const Dynamic_Object_Function *df = dynamic_cast<const Dynamic_Object_Function *>(&f);
if (df) if (df)
@ -87,7 +108,7 @@ namespace chaiscript
} }
} }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
if (dynamic_object_typename_match(vals, m_type_name, m_ti, t_conversions)) if (dynamic_object_typename_match(vals, m_type_name, m_ti, t_conversions))
{ {
@ -97,25 +118,25 @@ namespace chaiscript
} }
} }
virtual std::vector<Const_Proxy_Function> get_contained_functions() const virtual std::vector<Const_Proxy_Function> get_contained_functions() const CHAISCRIPT_OVERRIDE
{ {
return {m_func}; return {m_func};
} }
virtual int get_arity() const virtual int get_arity() const CHAISCRIPT_OVERRIDE
{ {
return m_func->get_arity(); return m_func->get_arity();
} }
virtual std::string annotation() const virtual std::string annotation() const CHAISCRIPT_OVERRIDE
{ {
return m_func->annotation(); return m_func->annotation();
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
if (dynamic_object_typename_match(params, m_type_name, m_ti, t_conversions)) if (dynamic_object_typename_match(params, m_type_name, m_ti, t_conversions))
{ {
@ -125,7 +146,7 @@ namespace chaiscript
} }
} }
virtual bool compare_first_type(const Boxed_Value &bv, const Dynamic_Cast_Conversions &t_conversions) const virtual bool compare_first_type(const Boxed_Value &bv, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
return dynamic_object_typename_match(bv, m_type_name, m_ti, t_conversions); return dynamic_object_typename_match(bv, m_type_name, m_ti, t_conversions);
} }
@ -194,10 +215,10 @@ namespace chaiscript
{ {
public: public:
Dynamic_Object_Constructor( Dynamic_Object_Constructor(
const std::string &t_type_name, std::string t_type_name,
const Proxy_Function &t_func) const Proxy_Function &t_func)
: Proxy_Function_Base(build_type_list(t_func->get_param_types())), : Proxy_Function_Base(build_type_list(t_func->get_param_types())),
m_type_name(t_type_name), m_func(t_func) m_type_name(std::move(t_type_name)), m_func(t_func)
{ {
assert( (t_func->get_arity() > 0 || t_func->get_arity() < 0) assert( (t_func->get_arity() > 0 || t_func->get_arity() < 0)
&& "Programming error, Dynamic_Object_Function must have at least one parameter (this)"); && "Programming error, Dynamic_Object_Function must have at least one parameter (this)");
@ -205,8 +226,8 @@ namespace chaiscript
static std::vector<Type_Info> build_type_list(const std::vector<Type_Info> &tl) static std::vector<Type_Info> build_type_list(const std::vector<Type_Info> &tl)
{ {
std::vector<Type_Info>::const_iterator begin = tl.begin(); auto begin = tl.begin();
std::vector<Type_Info>::const_iterator end = tl.end(); auto end = tl.end();
if (begin != end) if (begin != end)
{ {
@ -218,7 +239,7 @@ namespace chaiscript
virtual ~Dynamic_Object_Constructor() {} virtual ~Dynamic_Object_Constructor() {}
virtual bool operator==(const Proxy_Function_Base &f) const virtual bool operator==(const Proxy_Function_Base &f) const CHAISCRIPT_OVERRIDE
{ {
const Dynamic_Object_Constructor *dc = dynamic_cast<const Dynamic_Object_Constructor*>(&f); const Dynamic_Object_Constructor *dc = dynamic_cast<const Dynamic_Object_Constructor*>(&f);
if (dc) if (dc)
@ -229,7 +250,7 @@ namespace chaiscript
} }
} }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
std::vector<Boxed_Value> new_vals; std::vector<Boxed_Value> new_vals;
new_vals.push_back(Boxed_Value(Dynamic_Object(m_type_name))); new_vals.push_back(Boxed_Value(Dynamic_Object(m_type_name)));
@ -239,19 +260,19 @@ namespace chaiscript
} }
virtual int get_arity() const virtual int get_arity() const CHAISCRIPT_OVERRIDE
{ {
// "this" is not considered part of the arity // "this" is not considered part of the arity
return m_func->get_arity() - 1; return m_func->get_arity() - 1;
} }
virtual std::string annotation() const virtual std::string annotation() const CHAISCRIPT_OVERRIDE
{ {
return m_func->annotation(); return m_func->annotation();
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
std::vector<Boxed_Value> new_params; std::vector<Boxed_Value> new_params;
chaiscript::Boxed_Value bv = var(Dynamic_Object(m_type_name)); chaiscript::Boxed_Value bv = var(Dynamic_Object(m_type_name));

View File

@ -7,8 +7,18 @@
#ifndef CHAISCRIPT_EXCEPTION_SPECIFICATION_HPP_ #ifndef CHAISCRIPT_EXCEPTION_SPECIFICATION_HPP_
#define CHAISCRIPT_EXCEPTION_SPECIFICATION_HPP_ #define CHAISCRIPT_EXCEPTION_SPECIFICATION_HPP_
#include <memory>
#include "../chaiscript_defines.hpp"
#include "boxed_cast.hpp" #include "boxed_cast.hpp"
namespace chaiscript {
class Boxed_Value;
namespace exception {
class bad_boxed_cast;
} // namespace exception
} // namespace chaiscript
namespace chaiscript namespace chaiscript
{ {
namespace detail namespace detail
@ -32,7 +42,7 @@ namespace chaiscript
{ {
virtual ~Exception_Handler_Impl1() {} virtual ~Exception_Handler_Impl1() {}
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
{ {
throw_type<T1>(bv, t_engine); throw_type<T1>(bv, t_engine);
} }
@ -42,7 +52,7 @@ namespace chaiscript
{ {
virtual ~Exception_Handler_Impl2() {} virtual ~Exception_Handler_Impl2() {}
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
{ {
throw_type<T1>(bv, t_engine); throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine); throw_type<T2>(bv, t_engine);
@ -54,7 +64,7 @@ namespace chaiscript
{ {
virtual ~Exception_Handler_Impl3() {} virtual ~Exception_Handler_Impl3() {}
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
{ {
throw_type<T1>(bv, t_engine); throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine); throw_type<T2>(bv, t_engine);
@ -66,7 +76,7 @@ namespace chaiscript
{ {
virtual ~Exception_Handler_Impl4() {} virtual ~Exception_Handler_Impl4() {}
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
{ {
throw_type<T1>(bv, t_engine); throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine); throw_type<T2>(bv, t_engine);
@ -79,7 +89,7 @@ namespace chaiscript
{ {
virtual ~Exception_Handler_Impl5() {} virtual ~Exception_Handler_Impl5() {}
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
{ {
throw_type<T1>(bv, t_engine); throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine); throw_type<T2>(bv, t_engine);

View File

@ -7,13 +7,22 @@
#ifndef CHAISCRIPT_FUNCTION_CALL_HPP_ #ifndef CHAISCRIPT_FUNCTION_CALL_HPP_
#define CHAISCRIPT_FUNCTION_CALL_HPP_ #define CHAISCRIPT_FUNCTION_CALL_HPP_
#include <functional>
#include <iostream>
#include <string> #include <string>
#include <vector> #include <vector>
#include "proxy_functions.hpp"
#include "boxed_cast.hpp"
#include "function_call_detail.hpp" #include "function_call_detail.hpp"
#include "proxy_functions.hpp"
namespace chaiscript {
#include <iostream> class Boxed_Value;
class Dynamic_Cast_Conversions;
namespace detail {
template <typename T> struct Cast_Helper;
} // namespace detail
} // namespace chaiscript
namespace chaiscript namespace chaiscript
{ {
@ -31,7 +40,7 @@ namespace chaiscript
std::function<FunctionType> std::function<FunctionType>
functor(const std::vector<Const_Proxy_Function> &funcs, const Dynamic_Cast_Conversions *t_conversions) functor(const std::vector<Const_Proxy_Function> &funcs, const Dynamic_Cast_Conversions *t_conversions)
{ {
FunctionType *p=0; FunctionType *p=nullptr;
return detail::build_function_caller_helper(p, funcs, t_conversions); return detail::build_function_caller_helper(p, funcs, t_conversions);
} }

View File

@ -7,8 +7,17 @@
#ifndef CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_ #ifndef CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_
#define CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_ #define CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_
#include <algorithm>
#include <functional>
#include <memory>
#include <string> #include <string>
#include <type_traits>
#include <vector> #include <vector>
#include "boxed_cast.hpp"
#include "boxed_number.hpp"
#include "boxed_value.hpp"
#include "dynamic_cast_conversion.hpp"
#include "proxy_functions.hpp" #include "proxy_functions.hpp"
namespace chaiscript namespace chaiscript
@ -64,8 +73,8 @@ namespace chaiscript
template<typename Ret, typename ... Param> template<typename Ret, typename ... Param>
struct Build_Function_Caller_Helper struct Build_Function_Caller_Helper
{ {
Build_Function_Caller_Helper(const std::vector<Const_Proxy_Function> &t_funcs, const Dynamic_Cast_Conversions &t_conversions) Build_Function_Caller_Helper(std::vector<Const_Proxy_Function> t_funcs, const Dynamic_Cast_Conversions &t_conversions)
: m_funcs(t_funcs), : m_funcs(std::move(t_funcs)),
m_conversions(t_conversions) m_conversions(t_conversions)
{ {
} }

View File

@ -7,14 +7,20 @@
#ifndef CHAISCRIPT_HANDLE_RETURN_HPP_ #ifndef CHAISCRIPT_HANDLE_RETURN_HPP_
#define CHAISCRIPT_HANDLE_RETURN_HPP_ #define CHAISCRIPT_HANDLE_RETURN_HPP_
#include "boxed_value.hpp" #include <functional>
#include "boxed_number.hpp" #include <memory>
#include "type_info.hpp"
#include <string>
#include <stdexcept> #include <stdexcept>
#include <string>
#include <vector> #include <vector>
#include "boxed_number.hpp"
#include "boxed_value.hpp"
#include "type_info.hpp"
namespace chaiscript {
class Boxed_Number;
} // namespace chaiscript
namespace chaiscript namespace chaiscript
{ {
namespace dispatch namespace dispatch

View File

@ -48,7 +48,7 @@ namespace chaiscript
template<typename T> template<typename T>
Proxy_Function constructor() Proxy_Function constructor()
{ {
T *f = 0; T *f = nullptr;
return (dispatch::detail::build_constructor_(f)); return (dispatch::detail::build_constructor_(f));
} }

View File

@ -9,14 +9,29 @@
#define CHAISCRIPT_PROXY_FUNCTIONS_HPP_ #define CHAISCRIPT_PROXY_FUNCTIONS_HPP_
#include "boxed_value.hpp" #include <algorithm>
#include "type_info.hpp" #include <cassert>
#include <functional>
#include <memory>
#include <stdexcept>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include <stdexcept>
#include <vector> #include <vector>
#include <cassert>
#include "../chaiscript_defines.hpp"
#include "boxed_cast.hpp"
#include "boxed_cast_helper.hpp"
#include "boxed_value.hpp"
#include "proxy_functions_detail.hpp" #include "proxy_functions_detail.hpp"
#include "type_info.hpp"
namespace chaiscript {
class Dynamic_Cast_Conversions;
namespace exception {
class bad_boxed_cast;
struct arity_error;
} // namespace exception
} // namespace chaiscript
namespace chaiscript namespace chaiscript
{ {
@ -112,8 +127,8 @@ namespace chaiscript
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const = 0; virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const = 0;
Proxy_Function_Base(const std::vector<Type_Info> &t_types) Proxy_Function_Base(std::vector<Type_Info> t_types)
: m_types(t_types), m_has_arithmetic_param(false) : m_types(std::move(t_types)), m_has_arithmetic_param(false)
{ {
for (size_t i = 1; i < m_types.size(); ++i) for (size_t i = 1; i < m_types.size(); ++i)
{ {
@ -196,19 +211,19 @@ namespace chaiscript
{ {
public: public:
Dynamic_Proxy_Function( Dynamic_Proxy_Function(
const std::function<Boxed_Value (const std::vector<Boxed_Value> &)> &t_f, std::function<Boxed_Value (const std::vector<Boxed_Value> &)> t_f,
int t_arity=-1, int t_arity=-1,
const AST_NodePtr &t_parsenode = AST_NodePtr(), AST_NodePtr t_parsenode = AST_NodePtr(),
const std::string &t_description = "", std::string t_description = "",
const Proxy_Function &t_guard = Proxy_Function()) Proxy_Function t_guard = Proxy_Function())
: Proxy_Function_Base(build_param_type_list(t_arity)), : Proxy_Function_Base(build_param_type_list(t_arity)),
m_f(t_f), m_arity(t_arity), m_description(t_description), m_guard(t_guard), m_parsenode(t_parsenode) m_f(std::move(t_f)), m_arity(t_arity), m_description(std::move(t_description)), m_guard(std::move(t_guard)), m_parsenode(std::move(t_parsenode))
{ {
} }
virtual ~Dynamic_Proxy_Function() {} virtual ~Dynamic_Proxy_Function() {}
virtual bool operator==(const Proxy_Function_Base &rhs) const virtual bool operator==(const Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE
{ {
const Dynamic_Proxy_Function *prhs = dynamic_cast<const Dynamic_Proxy_Function *>(&rhs); const Dynamic_Proxy_Function *prhs = dynamic_cast<const Dynamic_Proxy_Function *>(&rhs);
@ -218,13 +233,13 @@ namespace chaiscript
&& !this->m_guard && !prhs->m_guard); && !this->m_guard && !prhs->m_guard);
} }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
return (m_arity < 0 || vals.size() == size_t(m_arity)) return (m_arity < 0 || vals.size() == size_t(m_arity))
&& test_guard(vals, t_conversions); && test_guard(vals, t_conversions);
} }
virtual int get_arity() const virtual int get_arity() const CHAISCRIPT_OVERRIDE
{ {
return m_arity; return m_arity;
} }
@ -239,13 +254,13 @@ namespace chaiscript
return m_parsenode; return m_parsenode;
} }
virtual std::string annotation() const virtual std::string annotation() const CHAISCRIPT_OVERRIDE
{ {
return m_description; return m_description;
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
if (m_arity < 0 || params.size() == size_t(m_arity)) if (m_arity < 0 || params.size() == size_t(m_arity))
{ {
@ -329,19 +344,19 @@ namespace chaiscript
assert(m_f->get_arity() < 0 || m_f->get_arity() == static_cast<int>(m_args.size())); assert(m_f->get_arity() < 0 || m_f->get_arity() == static_cast<int>(m_args.size()));
} }
virtual bool operator==(const Proxy_Function_Base &t_f) const virtual bool operator==(const Proxy_Function_Base &t_f) const CHAISCRIPT_OVERRIDE
{ {
return &t_f == this; return &t_f == this;
} }
virtual ~Bound_Function() {} virtual ~Bound_Function() {}
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
return m_f->call_match(build_param_list(vals), t_conversions); return m_f->call_match(build_param_list(vals), t_conversions);
} }
virtual std::vector<Const_Proxy_Function> get_contained_functions() const virtual std::vector<Const_Proxy_Function> get_contained_functions() const CHAISCRIPT_OVERRIDE
{ {
std::vector<Const_Proxy_Function> fs; std::vector<Const_Proxy_Function> fs;
fs.push_back(m_f); fs.push_back(m_f);
@ -351,10 +366,8 @@ namespace chaiscript
std::vector<Boxed_Value> build_param_list(const std::vector<Boxed_Value> &params) const std::vector<Boxed_Value> build_param_list(const std::vector<Boxed_Value> &params) const
{ {
typedef std::vector<Boxed_Value>::const_iterator pitr; auto parg = params.begin();
auto barg = m_args.begin();
pitr parg = params.begin();
pitr barg = m_args.begin();
std::vector<Boxed_Value> args; std::vector<Boxed_Value> args;
@ -382,12 +395,12 @@ namespace chaiscript
return args; return args;
} }
virtual int get_arity() const virtual int get_arity() const CHAISCRIPT_OVERRIDE
{ {
return m_arity; return m_arity;
} }
virtual std::string annotation() const virtual std::string annotation() const CHAISCRIPT_OVERRIDE
{ {
return "Bound: " + m_f->annotation(); return "Bound: " + m_f->annotation();
} }
@ -416,7 +429,7 @@ namespace chaiscript
return retval; return retval;
} }
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
return (*m_f)(build_param_list(params), t_conversions); return (*m_f)(build_param_list(params), t_conversions);
} }
@ -436,26 +449,26 @@ namespace chaiscript
class Proxy_Function_Impl : public Proxy_Function_Base class Proxy_Function_Impl : public Proxy_Function_Base
{ {
public: public:
Proxy_Function_Impl(const std::function<Func> &f) Proxy_Function_Impl(std::function<Func> f)
: Proxy_Function_Base(detail::build_param_type_list(static_cast<Func *>(0))), : Proxy_Function_Base(detail::build_param_type_list(static_cast<Func *>(nullptr))),
m_f(f), m_dummy_func(0) m_f(std::move(f)), m_dummy_func(nullptr)
{ {
} }
virtual ~Proxy_Function_Impl() {} virtual ~Proxy_Function_Impl() {}
virtual bool operator==(const Proxy_Function_Base &t_func) const virtual bool operator==(const Proxy_Function_Base &t_func) const CHAISCRIPT_OVERRIDE
{ {
const Proxy_Function_Impl *pimpl = dynamic_cast<const Proxy_Function_Impl<Func> *>(&t_func); const Proxy_Function_Impl *pimpl = dynamic_cast<const Proxy_Function_Impl<Func> *>(&t_func);
return pimpl != 0; return pimpl != nullptr;
} }
virtual int get_arity() const virtual int get_arity() const CHAISCRIPT_OVERRIDE
{ {
return static_cast<int>(m_types.size()) - 1; return static_cast<int>(m_types.size()) - 1;
} }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
if (int(vals.size()) != get_arity()) if (int(vals.size()) != get_arity())
{ {
@ -465,7 +478,7 @@ namespace chaiscript
return compare_types(m_types, vals) || detail::compare_types_cast(m_dummy_func, vals, t_conversions); return compare_types(m_types, vals) || detail::compare_types_cast(m_dummy_func, vals, t_conversions);
} }
virtual std::string annotation() const virtual std::string annotation() const CHAISCRIPT_OVERRIDE
{ {
return ""; return "";
} }
@ -476,7 +489,7 @@ namespace chaiscript
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
return detail::Do_Call<typename std::function<Func>::result_type>::go(m_f, params, t_conversions); return detail::Do_Call<typename std::function<Func>::result_type>::go(m_f, params, t_conversions);
} }
@ -501,7 +514,7 @@ namespace chaiscript
virtual ~Attribute_Access() {} virtual ~Attribute_Access() {}
virtual bool operator==(const Proxy_Function_Base &t_func) const virtual bool operator==(const Proxy_Function_Base &t_func) const CHAISCRIPT_OVERRIDE
{ {
const Attribute_Access<T, Class> * aa const Attribute_Access<T, Class> * aa
= dynamic_cast<const Attribute_Access<T, Class> *>(&t_func); = dynamic_cast<const Attribute_Access<T, Class> *>(&t_func);
@ -514,12 +527,12 @@ namespace chaiscript
} }
virtual int get_arity() const virtual int get_arity() const CHAISCRIPT_OVERRIDE
{ {
return 1; return 1;
} }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &) const virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &) const CHAISCRIPT_OVERRIDE
{ {
if (vals.size() != 1) if (vals.size() != 1)
{ {
@ -529,13 +542,13 @@ namespace chaiscript
return vals[0].get_type_info().bare_equal(user_type<Class>()); return vals[0].get_type_info().bare_equal(user_type<Class>());
} }
virtual std::string annotation() const virtual std::string annotation() const CHAISCRIPT_OVERRIDE
{ {
return ""; return "";
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{ {
if (params.size() == 1) if (params.size() == 1)
{ {
@ -573,9 +586,9 @@ namespace chaiscript
class dispatch_error : public std::runtime_error class dispatch_error : public std::runtime_error
{ {
public: public:
dispatch_error(const std::vector<Boxed_Value> &t_parameters, dispatch_error(std::vector<Boxed_Value> t_parameters,
const std::vector<Const_Proxy_Function> &t_functions) std::vector<Const_Proxy_Function> t_functions)
: std::runtime_error("Error with function dispatch"), parameters(t_parameters), functions(t_functions) : std::runtime_error("Error with function dispatch"), parameters(std::move(t_parameters)), functions(std::move(t_functions))
{ {
} }

View File

@ -7,15 +7,24 @@
#ifndef CHAISCRIPT_PROXY_FUNCTIONS_DETAIL_HPP_ #ifndef CHAISCRIPT_PROXY_FUNCTIONS_DETAIL_HPP_
#define CHAISCRIPT_PROXY_FUNCTIONS_DETAIL_HPP_ #define CHAISCRIPT_PROXY_FUNCTIONS_DETAIL_HPP_
#include "boxed_value.hpp" #include <algorithm>
#include "boxed_cast.hpp"
#include "type_info.hpp"
#include "handle_return.hpp"
#include <string>
#include <stdexcept>
#include <vector>
#include <functional> #include <functional>
#include <stdexcept>
#include <string>
#include <vector>
#include "../chaiscript_defines.hpp"
#include "boxed_cast.hpp"
#include "boxed_value.hpp"
#include "handle_return.hpp"
#include "type_info.hpp"
namespace chaiscript {
class Dynamic_Cast_Conversions;
namespace exception {
class bad_boxed_cast;
} // namespace exception
} // namespace chaiscript
namespace chaiscript namespace chaiscript
{ {

View File

@ -7,8 +7,12 @@
#ifndef CHAISCRIPT_REGISTER_FUNCTION_HPP_ #ifndef CHAISCRIPT_REGISTER_FUNCTION_HPP_
#define CHAISCRIPT_REGISTER_FUNCTION_HPP_ #define CHAISCRIPT_REGISTER_FUNCTION_HPP_
#include "dispatchkit.hpp" #include <functional>
#include <type_traits>
#include "bind_first.hpp" #include "bind_first.hpp"
#include "dispatchkit.hpp"
#include "proxy_functions.hpp"
namespace chaiscript namespace chaiscript
{ {

View File

@ -7,10 +7,11 @@
#ifndef CHAISCRIPT_TYPE_INFO_HPP_ #ifndef CHAISCRIPT_TYPE_INFO_HPP_
#define CHAISCRIPT_TYPE_INFO_HPP_ #define CHAISCRIPT_TYPE_INFO_HPP_
#include <string> #include <functional>
#include <typeinfo>
#include <memory> #include <memory>
#include <string>
#include <type_traits> #include <type_traits>
#include <typeinfo>
namespace chaiscript namespace chaiscript
{ {
@ -38,7 +39,7 @@ namespace chaiscript
} }
Type_Info() Type_Info()
: m_type_info(0), m_bare_type_info(0), : m_type_info(nullptr), m_bare_type_info(nullptr),
m_is_const(false), m_is_reference(false), m_is_pointer(false), m_is_const(false), m_is_reference(false), m_is_pointer(false),
m_is_void(false), m_is_arithmetic(false), m_is_void(false), m_is_arithmetic(false),
m_is_undef(true) m_is_undef(true)
@ -81,7 +82,7 @@ namespace chaiscript
bool operator==(const std::type_info &ti) const bool operator==(const std::type_info &ti) const
{ {
return m_type_info != 0 && (*m_type_info) == ti; return m_type_info != nullptr && (*m_type_info) == ti;
} }
bool bare_equal(const Type_Info &ti) const bool bare_equal(const Type_Info &ti) const
@ -92,7 +93,7 @@ namespace chaiscript
bool bare_equal_type_info(const std::type_info &ti) const bool bare_equal_type_info(const std::type_info &ti) const
{ {
return m_bare_type_info != 0 return m_bare_type_info != nullptr
&& (*m_bare_type_info) == ti; && (*m_bare_type_info) == ti;
} }
@ -100,7 +101,7 @@ namespace chaiscript
bool is_reference() const { return m_is_reference; } bool is_reference() const { return m_is_reference; }
bool is_void() const { return m_is_void; } bool is_void() const { return m_is_void; }
bool is_arithmetic() const { return m_is_arithmetic; } bool is_arithmetic() const { return m_is_arithmetic; }
bool is_undef() const { return m_is_undef || m_bare_type_info == 0; } bool is_undef() const { return m_is_undef || m_bare_type_info == nullptr; }
bool is_pointer() const { return m_is_pointer; } bool is_pointer() const { return m_is_pointer; }
std::string name() const std::string name() const

View File

@ -7,6 +7,8 @@
#ifndef CHAISCRIPT_ALGEBRAIC_HPP_ #ifndef CHAISCRIPT_ALGEBRAIC_HPP_
#define CHAISCRIPT_ALGEBRAIC_HPP_ #define CHAISCRIPT_ALGEBRAIC_HPP_
#include <string>
#include "../dispatchkit/dispatchkit.hpp" #include "../dispatchkit/dispatchkit.hpp"
namespace chaiscript namespace chaiscript

View File

@ -5,10 +5,24 @@
// http://www.chaiscript.com // http://www.chaiscript.com
#ifndef CHAISCRIPT_COMMON_HPP_ #ifndef CHAISCRIPT_COMMON_HPP_
#define CHAISCRIPT_COMMON_HPP_ #define CHAISCRIPT_COMMON_HPP_
#include <algorithm>
#include <memory>
#include <sstream> #include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include "../chaiscript_defines.hpp"
#include "../dispatchkit/boxed_value.hpp"
#include "../dispatchkit/dispatchkit.hpp" #include "../dispatchkit/dispatchkit.hpp"
#include "../dispatchkit/proxy_functions.hpp"
#include "../dispatchkit/type_info.hpp"
namespace chaiscript {
struct AST_Node;
} // namespace chaiscript
namespace chaiscript namespace chaiscript
{ {
@ -253,11 +267,9 @@ namespace chaiscript
} else { } else {
ss << " " << t_functions.size() << " overloads available:" << std::endl; ss << " " << t_functions.size() << " overloads available:" << std::endl;
for (std::vector<chaiscript::Const_Proxy_Function>::const_iterator itr = t_functions.begin(); for (const auto & t_function : t_functions)
itr != t_functions.end();
++itr)
{ {
ss << " " << format_types((*itr), t_dot_notation, t_ss) << std::endl; ss << " " << format_types((t_function), t_dot_notation, t_ss) << std::endl;
} }
} }
@ -277,7 +289,7 @@ namespace chaiscript
{ {
std::string paramstr; std::string paramstr;
for (std::vector<Boxed_Value>::const_iterator itr = t_parameters.begin(); for (auto itr = t_parameters.begin();
itr != t_parameters.end(); itr != t_parameters.end();
++itr) ++itr)
{ {
@ -404,8 +416,8 @@ namespace chaiscript
oss << text; oss << text;
for (size_t j = 0; j < this->children.size(); ++j) { for (auto & elem : this->children) {
oss << this->children[j]->pretty_print(); oss << elem->pretty_print();
} }
return oss.str(); return oss.str();
@ -446,15 +458,15 @@ namespace chaiscript
} }
protected: protected:
AST_Node(const std::string &t_ast_node_text, int t_id, const std::shared_ptr<std::string> &t_fname, AST_Node(std::string t_ast_node_text, int t_id, const std::shared_ptr<std::string> &t_fname,
int t_start_line, int t_start_col, int t_end_line, int t_end_col) : int t_start_line, int t_start_col, int t_end_line, int t_end_col) :
text(t_ast_node_text), identifier(t_id), filename(t_fname), text(std::move(t_ast_node_text)), identifier(t_id), filename(t_fname),
start(t_start_line, t_start_col), end(t_end_line, t_end_col) start(t_start_line, t_start_col), end(t_end_line, t_end_col)
{ {
} }
AST_Node(const std::string &t_ast_node_text, int t_id, const std::shared_ptr<std::string> &t_fname) : AST_Node(std::string t_ast_node_text, int t_id, const std::shared_ptr<std::string> &t_fname) :
text(t_ast_node_text), identifier(t_id), filename(t_fname) {} text(std::move(t_ast_node_text)), identifier(t_id), filename(t_fname) {}
virtual ~AST_Node() {} virtual ~AST_Node() {}

View File

@ -7,10 +7,27 @@
#ifndef CHAISCRIPT_ENGINE_HPP_ #ifndef CHAISCRIPT_ENGINE_HPP_
#define CHAISCRIPT_ENGINE_HPP_ #define CHAISCRIPT_ENGINE_HPP_
#include <cassert>
#include <cstring>
#include <algorithm>
#include <exception> #include <exception>
#include <fstream> #include <fstream>
#include <functional>
#include <map>
#include <memory>
#include <mutex>
#include <set>
#include <stdexcept>
#include <string>
#include <vector>
#include "../chaiscript_defines.hpp" #include "../chaiscript_defines.hpp"
#include "../chaiscript_threading.hpp"
#include "../dispatchkit/boxed_cast_helper.hpp"
#include "../dispatchkit/boxed_value.hpp"
#include "../dispatchkit/dispatchkit.hpp"
#include "../dispatchkit/dynamic_cast_conversion.hpp"
#include "../dispatchkit/proxy_functions.hpp"
#include "chaiscript_common.hpp" #include "chaiscript_common.hpp"
#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) #if defined(__linux__) || defined(__unix__) || defined(__APPLE__)
@ -28,9 +45,9 @@
#endif #endif
#include "chaiscript_prelude.chai"
#include "chaiscript_parser.hpp"
#include "../dispatchkit/exception_specification.hpp" #include "../dispatchkit/exception_specification.hpp"
#include "chaiscript_parser.hpp"
#include "chaiscript_prelude.chai"
namespace chaiscript namespace chaiscript
{ {
@ -355,7 +372,7 @@ namespace chaiscript
/// Helper function for loading a file /// Helper function for loading a file
std::string load_file(const std::string &t_filename) { static std::string load_file(const std::string &t_filename) {
std::ifstream infile(t_filename.c_str(), std::ios::in | std::ios::ate | std::ios::binary ); std::ifstream infile(t_filename.c_str(), std::ios::in | std::ios::ate | std::ios::binary );
if (!infile.is_open()) { if (!infile.is_open()) {
@ -383,9 +400,9 @@ namespace chaiscript
/// \param[in] t_modulepaths Vector of paths to search when attempting to load a binary module /// \param[in] t_modulepaths Vector of paths to search when attempting to load a binary module
/// \param[in] t_usepaths Vector of paths to search when attempting to "use" an included ChaiScript file /// \param[in] t_usepaths Vector of paths to search when attempting to "use" an included ChaiScript file
ChaiScript(const ModulePtr &t_lib, ChaiScript(const ModulePtr &t_lib,
const std::vector<std::string> &t_modulepaths = std::vector<std::string>(), std::vector<std::string> t_modulepaths = std::vector<std::string>(),
const std::vector<std::string> &t_usepaths = std::vector<std::string>()) std::vector<std::string> t_usepaths = std::vector<std::string>())
: m_modulepaths(t_modulepaths), m_usepaths(t_usepaths) : m_modulepaths(std::move(t_modulepaths)), m_usepaths(std::move(t_usepaths))
{ {
if (m_modulepaths.empty()) if (m_modulepaths.empty())
{ {
@ -407,9 +424,9 @@ namespace chaiscript
/// ///
/// \param[in] t_modulepaths Vector of paths to search when attempting to load a binary module /// \param[in] t_modulepaths Vector of paths to search when attempting to load a binary module
/// \param[in] t_usepaths Vector of paths to search when attempting to "use" an included ChaiScript file /// \param[in] t_usepaths Vector of paths to search when attempting to "use" an included ChaiScript file
ChaiScript( const std::vector<std::string> &t_modulepaths = std::vector<std::string>(), ChaiScript( std::vector<std::string> t_modulepaths = std::vector<std::string>(),
const std::vector<std::string> &t_usepaths = std::vector<std::string>()) std::vector<std::string> t_usepaths = std::vector<std::string>())
: m_modulepaths(t_modulepaths), m_usepaths(t_usepaths) : m_modulepaths(std::move(t_modulepaths)), m_usepaths(std::move(t_usepaths))
{ {
if (m_modulepaths.empty()) if (m_modulepaths.empty())
{ {
@ -694,14 +711,14 @@ namespace chaiscript
postfixes.push_back(".so"); postfixes.push_back(".so");
postfixes.push_back(""); postfixes.push_back("");
for (size_t i = 0; i < m_modulepaths.size(); ++i) for (auto & elem : m_modulepaths)
{ {
for (size_t j = 0; j < prefixes.size(); ++j) for (auto & prefixe : prefixes)
{ {
for (size_t k = 0; k < postfixes.size(); ++k) for (auto & postfixe : postfixes)
{ {
try { try {
std::string name = m_modulepaths[i] + prefixes[j] + t_module_name + postfixes[k]; std::string name = elem + prefixe + t_module_name + postfixe;
// std::cerr << "trying location: " << name << std::endl; // std::cerr << "trying location: " << name << std::endl;
load_module(version_stripped_name, name); load_module(version_stripped_name, name);
return name; return name;

View File

@ -7,10 +7,36 @@
#ifndef CHAISCRIPT_EVAL_HPP_ #ifndef CHAISCRIPT_EVAL_HPP_
#define CHAISCRIPT_EVAL_HPP_ #define CHAISCRIPT_EVAL_HPP_
#include <assert.h>
#include <cstdlib>
#include <exception>
#include <functional>
#include <limits>
#include <map> #include <map>
#include <memory>
#include <ostream>
#include <stdexcept>
#include <string>
#include <vector>
#include "chaiscript_common.hpp" #include "../chaiscript_defines.hpp"
#include "../dispatchkit/boxed_cast.hpp"
#include "../dispatchkit/boxed_cast_helper.hpp"
#include "../dispatchkit/boxed_number.hpp"
#include "../dispatchkit/boxed_value.hpp"
#include "../dispatchkit/dispatchkit.hpp"
#include "../dispatchkit/proxy_functions.hpp"
#include "../dispatchkit/proxy_functions_detail.hpp"
#include "../dispatchkit/register_function.hpp" #include "../dispatchkit/register_function.hpp"
#include "../dispatchkit/type_info.hpp"
#include "chaiscript_algebraic.hpp"
#include "chaiscript_common.hpp"
namespace chaiscript {
namespace exception {
class bad_boxed_cast;
} // namespace exception
} // namespace chaiscript
namespace chaiscript namespace chaiscript
{ {
@ -44,13 +70,13 @@ namespace chaiscript
{ } { }
virtual ~Binary_Operator_AST_Node() {} virtual ~Binary_Operator_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
return do_oper(t_ss, Operators::to_operator(children[1]->text), children[1]->text, return do_oper(t_ss, Operators::to_operator(children[1]->text), children[1]->text,
this->children[0]->eval(t_ss), this->children[0]->eval(t_ss),
this->children[2]->eval(t_ss)); this->children[2]->eval(t_ss));
} }
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
if (children.size() == 3) if (children.size() == 3)
{ {
@ -108,7 +134,7 @@ namespace chaiscript
AST_Node(t_ast_node_text, AST_Node_Type::Int, t_fname, t_start_line, t_start_col, t_end_line, t_end_col), AST_Node(t_ast_node_text, AST_Node_Type::Int, t_fname, t_start_line, t_start_col, t_end_line, t_end_col),
m_value(t_bv) { } m_value(t_bv) { }
virtual ~Int_AST_Node() {} virtual ~Int_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &) CHAISCRIPT_OVERRIDE{
return m_value; return m_value;
} }
@ -126,7 +152,7 @@ namespace chaiscript
AST_Node(t_ast_node_text, AST_Node_Type::Float, t_fname, t_start_line, t_start_col, t_end_line, t_end_col), AST_Node(t_ast_node_text, AST_Node_Type::Float, t_fname, t_start_line, t_start_col, t_end_line, t_end_col),
m_value(t_bv) { } m_value(t_bv) { }
virtual ~Float_AST_Node() {} virtual ~Float_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &) CHAISCRIPT_OVERRIDE{
return m_value; return m_value;
} }
@ -143,7 +169,7 @@ namespace chaiscript
{ } { }
virtual ~Id_AST_Node() {} virtual ~Id_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
if (!m_value.is_undef()) if (!m_value.is_undef())
{ {
return m_value; return m_value;
@ -199,7 +225,7 @@ namespace chaiscript
AST_Node(t_ast_node_text, AST_Node_Type::Eol, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Eol, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Eol_AST_Node() {} virtual ~Eol_AST_Node() {}
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
return "\n"; return "\n";
} }
@ -210,7 +236,7 @@ namespace chaiscript
Fun_Call_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Fun_Call_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Fun_Call, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Fun_Call, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Fun_Call_AST_Node() {} virtual ~Fun_Call_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
std::vector<Boxed_Value> params; std::vector<Boxed_Value> params;
@ -254,7 +280,7 @@ namespace chaiscript
} }
} }
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
std::ostringstream oss; std::ostringstream oss;
@ -279,7 +305,7 @@ namespace chaiscript
Inplace_Fun_Call_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Inplace_Fun_Call_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Inplace_Fun_Call, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Inplace_Fun_Call, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Inplace_Fun_Call_AST_Node() {} virtual ~Inplace_Fun_Call_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
std::vector<Boxed_Value> params; std::vector<Boxed_Value> params;
if ((this->children.size() > 1) && (this->children[1]->identifier == AST_Node_Type::Arg_List)) { if ((this->children.size() > 1) && (this->children[1]->identifier == AST_Node_Type::Arg_List)) {
@ -320,7 +346,7 @@ namespace chaiscript
} }
} }
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
std::ostringstream oss; std::ostringstream oss;
for (size_t j = 0; j < this->children.size(); ++j) { for (size_t j = 0; j < this->children.size(); ++j) {
@ -345,7 +371,7 @@ namespace chaiscript
AST_Node(t_ast_node_text, AST_Node_Type::Arg_List, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Arg_List, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Arg_List_AST_Node() {} virtual ~Arg_List_AST_Node() {}
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
std::ostringstream oss; std::ostringstream oss;
for (unsigned int j = 0; j < this->children.size(); ++j) { for (unsigned int j = 0; j < this->children.size(); ++j) {
@ -375,7 +401,7 @@ namespace chaiscript
{} {}
virtual ~Equation_AST_Node() {} virtual ~Equation_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
Boxed_Value retval = this->children.back()->eval(t_ss); Boxed_Value retval = this->children.back()->eval(t_ss);
@ -443,7 +469,7 @@ namespace chaiscript
Var_Decl_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Var_Decl_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Var_Decl, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Var_Decl, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Var_Decl_AST_Node() {} virtual ~Var_Decl_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
if (this->children[0]->identifier == AST_Node_Type::Reference) if (this->children[0]->identifier == AST_Node_Type::Reference)
{ {
return this->children[0]->eval(t_ss); return this->children[0]->eval(t_ss);
@ -463,7 +489,7 @@ namespace chaiscript
} }
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
return "var " + this->children[0]->text; return "var " + this->children[0]->text;
} }
@ -484,7 +510,7 @@ namespace chaiscript
int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
Binary_Operator_AST_Node(t_ast_node_text, AST_Node_Type::Addition, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } Binary_Operator_AST_Node(t_ast_node_text, AST_Node_Type::Addition, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Addition_AST_Node() {} virtual ~Addition_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
return do_oper(t_ss, Operators::sum, "+", this->children[0]->eval(t_ss), this->children[1]->eval(t_ss)); return do_oper(t_ss, Operators::sum, "+", this->children[0]->eval(t_ss), this->children[1]->eval(t_ss));
} }
}; };
@ -496,7 +522,7 @@ namespace chaiscript
int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
Binary_Operator_AST_Node(t_ast_node_text, AST_Node_Type::Subtraction, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } Binary_Operator_AST_Node(t_ast_node_text, AST_Node_Type::Subtraction, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Subtraction_AST_Node() {} virtual ~Subtraction_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
return do_oper(t_ss, Operators::difference, "-", this->children[0]->eval(t_ss), this->children[1]->eval(t_ss)); return do_oper(t_ss, Operators::difference, "-", this->children[0]->eval(t_ss), this->children[1]->eval(t_ss));
} }
}; };
@ -508,7 +534,7 @@ namespace chaiscript
int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
Binary_Operator_AST_Node(t_ast_node_text, AST_Node_Type::Multiplication, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } Binary_Operator_AST_Node(t_ast_node_text, AST_Node_Type::Multiplication, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Multiplication_AST_Node() {} virtual ~Multiplication_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
return do_oper(t_ss, Operators::product, "*", this->children[0]->eval(t_ss), this->children[1]->eval(t_ss)); return do_oper(t_ss, Operators::product, "*", this->children[0]->eval(t_ss), this->children[1]->eval(t_ss));
} }
}; };
@ -520,7 +546,7 @@ namespace chaiscript
int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
Binary_Operator_AST_Node(t_ast_node_text, AST_Node_Type::Division, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } Binary_Operator_AST_Node(t_ast_node_text, AST_Node_Type::Division, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Division_AST_Node() {} virtual ~Division_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
return do_oper(t_ss, Operators::quotient, "/", this->children[0]->eval(t_ss), this->children[1]->eval(t_ss)); return do_oper(t_ss, Operators::quotient, "/", this->children[0]->eval(t_ss), this->children[1]->eval(t_ss));
} }
}; };
@ -532,7 +558,7 @@ namespace chaiscript
int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
Binary_Operator_AST_Node(t_ast_node_text, AST_Node_Type::Modulus, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } Binary_Operator_AST_Node(t_ast_node_text, AST_Node_Type::Modulus, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Modulus_AST_Node() {} virtual ~Modulus_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
return do_oper(t_ss, Operators::remainder, "%", this->children[0]->eval(t_ss), this->children[1]->eval(t_ss)); return do_oper(t_ss, Operators::remainder, "%", this->children[0]->eval(t_ss), this->children[1]->eval(t_ss));
} }
}; };
@ -542,7 +568,7 @@ namespace chaiscript
Array_Call_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Array_Call_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Array_Call, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Array_Call, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Array_Call_AST_Node() {} virtual ~Array_Call_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
Boxed_Value retval = this->children[0]->eval(t_ss); Boxed_Value retval = this->children[0]->eval(t_ss);
std::vector<Boxed_Value> params; std::vector<Boxed_Value> params;
@ -569,7 +595,7 @@ namespace chaiscript
return retval; return retval;
} }
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
std::ostringstream oss; std::ostringstream oss;
oss << this->children[0]->pretty_print(); oss << this->children[0]->pretty_print();
@ -590,7 +616,7 @@ namespace chaiscript
Dot_Access_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Dot_Access_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Dot_Access, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Dot_Access, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Dot_Access_AST_Node() {} virtual ~Dot_Access_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
Boxed_Value retval = this->children[0]->eval(t_ss); Boxed_Value retval = this->children[0]->eval(t_ss);
if (this->children.size() > 1) { if (this->children.size() > 1) {
@ -658,11 +684,11 @@ namespace chaiscript
AST_Node(t_ast_node_text, AST_Node_Type::Quoted_String, t_fname, t_start_line, t_start_col, t_end_line, t_end_col), AST_Node(t_ast_node_text, AST_Node_Type::Quoted_String, t_fname, t_start_line, t_start_col, t_end_line, t_end_col),
m_value(const_var(t_ast_node_text)) { } m_value(const_var(t_ast_node_text)) { }
virtual ~Quoted_String_AST_Node() {} virtual ~Quoted_String_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &) CHAISCRIPT_OVERRIDE {
return m_value; return m_value;
} }
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
return "\"" + text + "\""; return "\"" + text + "\"";
} }
@ -678,11 +704,11 @@ namespace chaiscript
AST_Node(t_ast_node_text, AST_Node_Type::Single_Quoted_String, t_fname, t_start_line, t_start_col, t_end_line, t_end_col), AST_Node(t_ast_node_text, AST_Node_Type::Single_Quoted_String, t_fname, t_start_line, t_start_col, t_end_line, t_end_col),
m_value(const_var(char(t_ast_node_text.at(0)))) { } m_value(const_var(char(t_ast_node_text.at(0)))) { }
virtual ~Single_Quoted_String_AST_Node() {} virtual ~Single_Quoted_String_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &) CHAISCRIPT_OVERRIDE{
return m_value; return m_value;
} }
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
return "'" + text + "'"; return "'" + text + "'";
} }
@ -696,7 +722,7 @@ namespace chaiscript
Lambda_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Lambda, const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Lambda_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Lambda, const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Lambda_AST_Node() {} virtual ~Lambda_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
std::vector<std::string> t_param_names; std::vector<std::string> t_param_names;
size_t numparams = 0; size_t numparams = 0;
@ -724,7 +750,7 @@ namespace chaiscript
Block_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Block_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Block, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Block, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Block_AST_Node() {} virtual ~Block_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
const size_t num_children = this->children.size(); const size_t num_children = this->children.size();
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
@ -753,7 +779,7 @@ namespace chaiscript
Def_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Def_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Def, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Def, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Def_AST_Node() {} virtual ~Def_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
std::vector<std::string> t_param_names; std::vector<std::string> t_param_names;
size_t numparams = 0; size_t numparams = 0;
AST_NodePtr guardnode; AST_NodePtr guardnode;
@ -809,7 +835,7 @@ namespace chaiscript
While_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : While_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::While, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::While, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~While_AST_Node() {} virtual ~While_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
try { try {
@ -838,7 +864,7 @@ namespace chaiscript
Ternary_Cond_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Ternary_Cond_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::If, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::If, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Ternary_Cond_AST_Node() {} virtual ~Ternary_Cond_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
bool cond; bool cond;
try { try {
cond = boxed_cast<bool>(this->children[0]->eval(t_ss)); cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
@ -861,7 +887,7 @@ namespace chaiscript
If_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : If_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::If, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::If, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~If_AST_Node() {} virtual ~If_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
bool cond; bool cond;
try { try {
cond = boxed_cast<bool>(this->children[0]->eval(t_ss)); cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
@ -906,7 +932,7 @@ namespace chaiscript
For_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : For_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::For, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::For, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~For_AST_Node() {} virtual ~For_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
// initial expression // initial expression
@ -945,7 +971,7 @@ namespace chaiscript
Switch_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Switch_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Switch, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Switch, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Switch_AST_Node() {} virtual ~Switch_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
Boxed_Value match_value; Boxed_Value match_value;
bool breaking = false; bool breaking = false;
size_t currentCase = 1; size_t currentCase = 1;
@ -988,7 +1014,7 @@ namespace chaiscript
Case_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Case_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Case, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Case, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Case_AST_Node() {} virtual ~Case_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
this->children[1]->eval(t_ss); this->children[1]->eval(t_ss);
@ -1002,7 +1028,7 @@ namespace chaiscript
Default_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Default_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Default, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Default, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Default_AST_Node() {} virtual ~Default_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
this->children[0]->eval(t_ss); this->children[0]->eval(t_ss);
@ -1017,7 +1043,7 @@ namespace chaiscript
Inline_Array_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Inline_Array_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Inline_Array, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Inline_Array, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Inline_Array_AST_Node() {} virtual ~Inline_Array_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
try { try {
std::vector<Boxed_Value> vec; std::vector<Boxed_Value> vec;
if (this->children.size() > 0) { if (this->children.size() > 0) {
@ -1034,7 +1060,7 @@ namespace chaiscript
} }
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
return "[" + AST_Node::pretty_print() + "]"; return "[" + AST_Node::pretty_print() + "]";
} }
@ -1045,7 +1071,7 @@ namespace chaiscript
Inline_Map_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Inline_Map_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Inline_Map, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Inline_Map, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Inline_Map_AST_Node() {} virtual ~Inline_Map_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
try { try {
std::map<std::string, Boxed_Value> retval; std::map<std::string, Boxed_Value> retval;
for (size_t i = 0; i < this->children[0]->children.size(); ++i) { for (size_t i = 0; i < this->children[0]->children.size(); ++i) {
@ -1067,7 +1093,7 @@ namespace chaiscript
Return_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Return_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Return, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Return, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Return_AST_Node() {} virtual ~Return_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
if (this->children.size() > 0) { if (this->children.size() > 0) {
throw detail::Return_Value(this->children[0]->eval(t_ss)); throw detail::Return_Value(this->children[0]->eval(t_ss));
} }
@ -1083,7 +1109,7 @@ namespace chaiscript
File_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : File_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::File, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::File, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~File_AST_Node() {} virtual ~File_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) { virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE {
const size_t size = this->children.size(); const size_t size = this->children.size();
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
const Boxed_Value &retval = this->children[i]->eval(t_ss); const Boxed_Value &retval = this->children[i]->eval(t_ss);
@ -1101,7 +1127,7 @@ namespace chaiscript
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col)
{ } { }
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
try { try {
t_ss.add_object(this->children[0]->text, Boxed_Value()); t_ss.add_object(this->children[0]->text, Boxed_Value());
} }
@ -1121,7 +1147,7 @@ namespace chaiscript
{ } { }
virtual ~Prefix_AST_Node() {} virtual ~Prefix_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
Boxed_Value bv(this->children[1]->eval(t_ss)); Boxed_Value bv(this->children[1]->eval(t_ss));
@ -1150,7 +1176,7 @@ namespace chaiscript
Break_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Break_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Break, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Break, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Break_AST_Node() {} virtual ~Break_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &) CHAISCRIPT_OVERRIDE{
throw detail::Break_Loop(); throw detail::Break_Loop();
} }
}; };
@ -1160,7 +1186,7 @@ namespace chaiscript
Continue_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Continue_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Continue, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Continue, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Continue_AST_Node() {} virtual ~Continue_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &) CHAISCRIPT_OVERRIDE{
throw detail::Continue_Loop(); throw detail::Continue_Loop();
} }
}; };
@ -1173,7 +1199,7 @@ namespace chaiscript
{ } { }
virtual ~Noop_AST_Node() {} virtual ~Noop_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &) CHAISCRIPT_OVERRIDE{
// It's a no-op, that evaluates to "true" // It's a no-op, that evaluates to "true"
return m_value; return m_value;
} }
@ -1201,7 +1227,7 @@ namespace chaiscript
Inline_Range_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Inline_Range_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Inline_Range, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Inline_Range, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Inline_Range_AST_Node() {} virtual ~Inline_Range_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
try { try {
return t_ss.call_function("generate_range", return t_ss.call_function("generate_range",
this->children[0]->children[0]->children[0]->eval(t_ss), this->children[0]->children[0]->children[0]->eval(t_ss),
@ -1226,7 +1252,7 @@ namespace chaiscript
Try_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Try_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Try, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Try, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Try_AST_Node() {} virtual ~Try_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
Boxed_Value retval; Boxed_Value retval;
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
@ -1369,7 +1395,7 @@ namespace chaiscript
Method_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Method_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Method, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Method, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Method_AST_Node() {} virtual ~Method_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
std::vector<std::string> t_param_names; std::vector<std::string> t_param_names;
AST_NodePtr guardnode; AST_NodePtr guardnode;
@ -1452,7 +1478,7 @@ namespace chaiscript
Attr_Decl_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Attr_Decl_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Attr_Decl, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Attr_Decl, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Attr_Decl_AST_Node() {} virtual ~Attr_Decl_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
try { try {
t_ss.add(Proxy_Function t_ss.add(Proxy_Function
@ -1516,7 +1542,7 @@ namespace chaiscript
Logical_And_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Logical_And_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Logical_And, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Logical_And, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Logical_And_AST_Node() {} virtual ~Logical_And_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
Boxed_Value retval = this->children[0]->eval(t_ss); Boxed_Value retval = this->children[0]->eval(t_ss);
if (this->children.size() > 1) { if (this->children.size() > 1) {
@ -1539,7 +1565,7 @@ namespace chaiscript
return retval; return retval;
} }
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
return "(" + AST_Node::pretty_print() + ")"; return "(" + AST_Node::pretty_print() + ")";
} }
@ -1550,7 +1576,7 @@ namespace chaiscript
Logical_Or_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Logical_Or_AST_Node(const std::string &t_ast_node_text = "", const std::shared_ptr<std::string> &t_fname=std::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, AST_Node_Type::Logical_Or, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, AST_Node_Type::Logical_Or, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Logical_Or_AST_Node() {} virtual ~Logical_Or_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_OVERRIDE{
Boxed_Value retval; Boxed_Value retval;
retval = this->children[0]->eval(t_ss); retval = this->children[0]->eval(t_ss);
@ -1570,7 +1596,7 @@ namespace chaiscript
return retval; return retval;
} }
virtual std::string pretty_print() const virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
{ {
return "(" + AST_Node::pretty_print() + ")"; return "(" + AST_Node::pretty_print() + ")";
} }

View File

@ -7,11 +7,17 @@
#ifndef CHAISCRIPT_PARSER_HPP_ #ifndef CHAISCRIPT_PARSER_HPP_
#define CHAISCRIPT_PARSER_HPP_ #define CHAISCRIPT_PARSER_HPP_
#include <cstdint>
#include <cstring>
#include <exception> #include <exception>
#include <fstream> #include <fstream>
#include <iostream>
#include <memory>
#include <sstream> #include <sstream>
#include <cstring> #include <string>
#include <vector>
#include "../dispatchkit/boxed_value.hpp"
#include "chaiscript_common.hpp" #include "chaiscript_common.hpp"
namespace chaiscript namespace chaiscript
@ -135,8 +141,8 @@ namespace chaiscript
m_operator_matches.push_back(multiplication); m_operator_matches.push_back(multiplication);
for ( int c = 0 ; c < detail::lengthof_alphabet ; ++c ) { for ( int c = 0 ; c < detail::lengthof_alphabet ; ++c ) {
for ( int a = 0 ; a < detail::max_alphabet ; a ++ ) { for (auto & elem : m_alphabet) {
m_alphabet[a][c]=false; elem[c]=false;
} }
} }
m_alphabet[detail::symbol_alphabet][static_cast<int>('?')]=true; m_alphabet[detail::symbol_alphabet][static_cast<int>('?')]=true;
@ -211,10 +217,10 @@ namespace chaiscript
/** /**
* Shows the current stack of matched ast_nodes * Shows the current stack of matched ast_nodes
*/ */
void show_match_stack() { void show_match_stack() const {
for (size_t i = 0; i < m_match_stack.size(); ++i) { for (auto & elem : m_match_stack) {
//debug_print(match_stack[i]); //debug_print(match_stack[i]);
std::cout << m_match_stack[i]->to_string(); std::cout << elem->to_string();
} }
} }
@ -274,7 +280,7 @@ namespace chaiscript
/** /**
* Check to see if there is more text parse * Check to see if there is more text parse
*/ */
inline bool has_more_input() { inline bool has_more_input() const {
return (m_input_pos != m_input_end); return (m_input_pos != m_input_end);
} }
@ -460,7 +466,7 @@ namespace chaiscript
return retval; return retval;
} }
Boxed_Value buildFloat(const std::string &t_val) static Boxed_Value buildFloat(const std::string &t_val)
{ {
bool float_ = false; bool float_ = false;
bool long_ = false; bool long_ = false;
@ -502,7 +508,7 @@ namespace chaiscript
template<typename IntType> template<typename IntType>
Boxed_Value buildInt(const IntType &t_type, const std::string &t_val) static Boxed_Value buildInt(const IntType &t_type, const std::string &t_val)
{ {
bool unsigned_ = false; bool unsigned_ = false;
bool long_ = false; bool long_ = false;
@ -2062,8 +2068,8 @@ namespace chaiscript
} }
bool Operator_Helper(size_t t_precedence) { bool Operator_Helper(size_t t_precedence) {
for (size_t i = 0; i < m_operator_matches[t_precedence].size(); ++i) { for (auto & elem : m_operator_matches[t_precedence]) {
if (Symbol(m_operator_matches[t_precedence][i].c_str(), true)) { if (Symbol(elem.c_str(), true)) {
return true; return true;
} }
} }

View File

@ -7,8 +7,13 @@
#ifndef CHAISCRIPT_UTILITY_UTILITY_HPP_ #ifndef CHAISCRIPT_UTILITY_UTILITY_HPP_
#define CHAISCRIPT_UTILITY_UTILITY_HPP_ #define CHAISCRIPT_UTILITY_UTILITY_HPP_
#include "../chaiscript.hpp"
#include <string> #include <string>
#include <utility>
#include <vector>
#include "../chaiscript.hpp"
#include "../dispatchkit/proxy_functions.hpp"
#include "../dispatchkit/type_info.hpp"
namespace chaiscript namespace chaiscript

View File

@ -23,7 +23,8 @@ char *mystrdup (const char *s) {
#ifdef CHAISCRIPT_MSVC #ifdef CHAISCRIPT_MSVC
strcpy_s(d, len, s); // Copy the characters strcpy_s(d, len, s); // Copy the characters
#else #else
strcpy(d,s); // Copy the characters strncpy(d,s,len); // Copy the characters
d[len] = '\0';
#endif #endif
return d; // Return the new string return d; // Return the new string
} }
@ -33,7 +34,7 @@ char* readline(const char* p)
std::string retval; std::string retval;
std::cout << p ; std::cout << p ;
std::getline(std::cin, retval); std::getline(std::cin, retval);
return std::cin.eof() ? NULL : mystrdup(retval.c_str()); return std::cin.eof() ? nullptr : mystrdup(retval.c_str());
} }

View File

@ -36,7 +36,7 @@ class TestDerivedType : public TestBaseType
{ {
public: public:
virtual ~TestDerivedType() {} virtual ~TestDerivedType() {}
virtual int func() { return 1; } virtual int func() CHAISCRIPT_OVERRIDE { return 1; }
int derived_only_func() { return 19; } int derived_only_func() { return 19; }
private: private: