Merge branch 'update_travis_toolchain' of github.com:ChaiScript/ChaiScript into update_travis_toolchain
This commit is contained in:
commit
c71dd8051b
@ -1,12 +1,12 @@
|
||||
compilers:
|
||||
- name: "clang"
|
||||
version: "3.5"
|
||||
version: "3.6"
|
||||
skip_packaging: true
|
||||
cmake_extra_flags: -DUSE_LIBCXX:BOOL=OFF -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DRUN_PERFORMANCE_TESTS:BOOL=ON
|
||||
collect_performance_results: true
|
||||
- name: "clang"
|
||||
build_tag: "LibC++"
|
||||
version: "3.5"
|
||||
version: "3.6"
|
||||
skip_packaging: true
|
||||
cmake_extra_flags: -DUSE_LIBCXX:BOOL=ON -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON
|
||||
- name: "clang"
|
||||
@ -19,17 +19,32 @@ compilers:
|
||||
version: "3.6"
|
||||
skip_packaging: true
|
||||
cmake_extra_flags: -DUSE_LIBCXX:BOOL=OFF -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_THREAD_SANITIZER:BOOL=ON
|
||||
- name: "clang"
|
||||
version: "3.7"
|
||||
skip_packaging: true
|
||||
cmake_extra_flags: -DUSE_LIBCXX:BOOL=OFF -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DRUN_PERFORMANCE_TESTS:BOOL=ON
|
||||
collect_performance_results: true
|
||||
- name: "clang"
|
||||
build_tag: "LibC++"
|
||||
version: "3.7"
|
||||
skip_packaging: true
|
||||
cmake_extra_flags: -DUSE_LIBCXX:BOOL=ON -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON
|
||||
- name: "gcc"
|
||||
version: "4.8"
|
||||
skip_packaging: true
|
||||
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DRUN_PERFORMANCE_TESTS:BOOL=ON
|
||||
collect_performance_results: true
|
||||
- name: "gcc"
|
||||
version: "4.9"
|
||||
cmake_extra_flags: -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DBUILD_TESTING:BOOL=ON -DRUN_PERFORMANCE_TESTS:BOOL=ON
|
||||
collect_performance_results: true
|
||||
- name: "gcc"
|
||||
version: "4.9"
|
||||
build_tag: "NoThreads"
|
||||
cmake_extra_flags: -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DBUILD_TESTING:BOOL=ON -DRUN_PERFORMANCE_TESTS:BOOL=ON -DMULTITHREAD_SUPPORT_ENABLED:BOOL=OFF
|
||||
collect_performance_results: true
|
||||
- name: "gcc"
|
||||
version: "4.8"
|
||||
cmake_extra_flags: -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DBUILD_TESTING:BOOL=ON -DRUN_PERFORMANCE_TESTS:BOOL=ON
|
||||
collect_performance_results: true
|
||||
- name: "gcc"
|
||||
version: "4.6"
|
||||
version: "5"
|
||||
skip_packaging: true
|
||||
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DRUN_PERFORMANCE_TESTS:BOOL=ON
|
||||
collect_performance_results: true
|
||||
@ -38,4 +53,5 @@ compilers:
|
||||
- name: custom_check
|
||||
commands:
|
||||
- ./contrib/check_for_tabs.rb
|
||||
- ./contrib/check_for_todos.rb
|
||||
|
||||
|
@ -2,8 +2,4 @@ compilers:
|
||||
- name: clang
|
||||
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCOMMIT_SHA=$COMMIT_SHA
|
||||
build_package_generator: TBZ2
|
||||
- name: clang
|
||||
build_type: Debug
|
||||
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCOMMIT_SHA=$COMMIT_SHA
|
||||
skip_packaging: true
|
||||
|
||||
|
@ -11,10 +11,11 @@ compilers:
|
||||
compiler_extra_flags: /analyze
|
||||
skip_packaging: true
|
||||
- name: Visual Studio
|
||||
version: 12
|
||||
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCOMMIT_SHA=%COMMIT_SHA%
|
||||
- name: Visual Studio
|
||||
version: 12
|
||||
version: 14
|
||||
build_type: Debug
|
||||
architecture: Win64
|
||||
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCOMMIT_SHA=%COMMIT_SHA%
|
||||
compiler_extra_flags: /analyze
|
||||
skip_packaging: true
|
||||
|
||||
|
||||
|
41
.github/CONTRIBUTING.md
vendored
Normal file
41
.github/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
# Contributing to ChaiScript
|
||||
|
||||
Thank you for contributing!
|
||||
|
||||
# Pull Requests
|
||||
|
||||
Please follow the existing style in the code you are patching.
|
||||
|
||||
- two space indent
|
||||
- no tabs EVER
|
||||
- match the existing indentation level
|
||||
|
||||
All ChaiScript commits are run through a large set of builds and analysis on all supported platforms. Those results are posted on the
|
||||
[build dashboard](http://chaiscript.com/ChaiScript-BuildResults/index.html). No PR will be accepted until all tests pass.
|
||||
|
||||
The build system has full integration with GitHub and you will be notified automatically if all tests have passed.
|
||||
|
||||
# Issues
|
||||
|
||||
Please do not post a "chaiscript is too slow", "chaiscript compiles too slowly", or "chaiscript needs more documentation" issue
|
||||
without first reading the following notes.
|
||||
|
||||
## ChaiScript is Too Slow
|
||||
|
||||
We are actively working on constently improving the runtime performance of ChaiScript. With the performance being
|
||||
[monitored with each commit](http://chaiscript.com/ChaiScript-BuildResults/performance.html).
|
||||
|
||||
If you feel you *must* post an issue about performance, please post a complete example that illustrates the exact case you
|
||||
feel should be better optimized.
|
||||
|
||||
Any issue request regarding performance without a complete example of the issue experienced will be closed.
|
||||
|
||||
## ChaiScript Compiles Too Slowly
|
||||
|
||||
This is also something we are actively working on. If you need highly optimized build times, please see [this discussion
|
||||
on the discourse site](http://discourse.chaiscript.com/t/slow-build-times/94).
|
||||
|
||||
## ChaiScript Needs More Documentation
|
||||
|
||||
If you have a question that is not addressed in the [cheatsheet](https://github.com/ChaiScript/ChaiScript/blob/develop/cheatsheet.md)
|
||||
please open an issue so we can get the Cheatsheet updated.
|
10
.github/ISSUE_TEMPLATE.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
* Compiler Used:
|
||||
* Operating System:
|
||||
* Architecture (ARM/x86/32bit/64bit/etc):
|
||||
|
||||
|
||||
### Expected Behavior
|
||||
|
||||
### Actual Behavior
|
||||
|
||||
### Minimal Example to Reproduce Behavior
|
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
Issue this pull request references: #
|
||||
|
||||
Changes proposed in this pull request
|
||||
|
||||
-
|
||||
-
|
||||
-
|
||||
|
@ -3,7 +3,6 @@ compiler:
|
||||
- gcc
|
||||
env:
|
||||
matrix:
|
||||
- GCC_VER="4.6"
|
||||
- GCC_VER="4.8"
|
||||
- GCC_VER="4.9"
|
||||
- GCC_VER="5"
|
||||
|
@ -101,8 +101,8 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt")
|
||||
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.md")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/description.txt")
|
||||
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR 5)
|
||||
set(CPACK_PACKAGE_VERSION_MINOR 8)
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR 6)
|
||||
set(CPACK_PACKAGE_VERSION_MINOR 0)
|
||||
set(CPACK_PACKAGE_VERSION_PATCH 0)
|
||||
|
||||
set(CPACK_PACKAGE_EXECUTABLES "chai;ChaiScript Eval")
|
||||
@ -148,21 +148,24 @@ endif()
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
|
||||
|
||||
if(GCC_VERSION VERSION_LESS 4.8)
|
||||
set(CPP11_FLAG "-std=c++0x")
|
||||
if(GCC_VERSION VERSION_LESS 4.9)
|
||||
set(CPP11_FLAG "-std=c++1y")
|
||||
else()
|
||||
set(CPP11_FLAG "-std=c++11")
|
||||
set(CPP11_FLAG "-std=c++14")
|
||||
endif()
|
||||
else()
|
||||
set(CPP11_FLAG "-std=c++11")
|
||||
set(CPP11_FLAG "-std=c++14")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(/W4)
|
||||
add_definitions(/W4 /w14545 /w34242 /w34254 /w34287 /w44263 /w44265 /w44296 /w44311 /w44826 /we4289 /w14546 /w14547 /w14549 /w14555 /w14619 /w14905 /w14906 /w14928)
|
||||
|
||||
# VS2013 doesn't have magic statics
|
||||
if (MSVC_VERSION STREQUAL "1800")
|
||||
# VS2013 doesn't have magic statics
|
||||
add_definitions(/w44640)
|
||||
else()
|
||||
# enum warnings are too noisy on MSVC2013
|
||||
add_definitions(/w34062)
|
||||
endif()
|
||||
|
||||
add_definitions(/bigobj)
|
||||
@ -175,10 +178,10 @@ if(MSVC)
|
||||
# how to workaround or fix the error. So I'm disabling it globally.
|
||||
add_definitions(/wd4503)
|
||||
else()
|
||||
add_definitions(-Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wcast-qual -Wunused -Woverloaded-virtual -pedantic ${CPP11_FLAG})
|
||||
add_definitions(-Wall -Wextra -Wconversion -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wcast-qual -Wunused -Woverloaded-virtual -pedantic ${CPP11_FLAG})
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
add_definitions(-Weverything -Wno-c++98-compat-pedantic -Wno-c++98-compat -Wno-documentation -Wno-switch-enum -Wno-weak-vtables -Wno-sign-conversion -Wno-missing-prototypes -Wno-padded -Wno-missing-noreturn -Wno-exit-time-destructors -Wno-documentation-unknown-command)
|
||||
add_definitions(-Weverything -Wno-c++98-compat-pedantic -Wno-c++98-compat -Wno-documentation -Wno-switch-enum -Wno-weak-vtables -Wno-missing-prototypes -Wno-padded -Wno-missing-noreturn -Wno-exit-time-destructors -Wno-documentation-unknown-command)
|
||||
else()
|
||||
add_definitions(-Wnoexcept)
|
||||
endif()
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: 5.7.2.{build}
|
||||
version: 5.8.x.{build}
|
||||
os: Visual Studio 2015
|
||||
environment:
|
||||
matrix:
|
||||
@ -14,3 +14,9 @@ build_script:
|
||||
cmake --build . --config Debug
|
||||
test_script:
|
||||
- cmd: ctest -C Debug
|
||||
notifications:
|
||||
- provider: Webhook
|
||||
url: https://webhooks.gitter.im/e/9ff725a985b5679d1d5d
|
||||
on_build_success: true
|
||||
on_build_failure: true
|
||||
on_build_status_changed: false
|
||||
|
11
contrib/check_for_todos.rb
Executable file
11
contrib/check_for_todos.rb
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'json'
|
||||
|
||||
`grep -rPIHni 'todo' src/* include/* samples/*`.lines { |line|
|
||||
if /(?<filename>.+(hpp|cpp|chai)):(?<linenumber>[0-9]+):(?<restofline>.+)/ =~ line
|
||||
puts(JSON.dump({:line => linenumber, :filename => filename, :tool => "todo_checker", :message => "todo: #{restofline.strip}", :messagetype => "info"}))
|
||||
end
|
||||
}
|
||||
|
||||
|
@ -12,17 +12,10 @@
|
||||
#define CHAISCRIPT_COMPILER_VERSION CHAISCRIPT_STRINGIZE(_MSC_FULL_VER)
|
||||
#define CHAISCRIPT_MSVC _MSC_VER
|
||||
#define CHAISCRIPT_HAS_DECLSPEC
|
||||
#if _MSC_VER <= 1800
|
||||
#define CHAISCRIPT_MSVC_12
|
||||
#endif
|
||||
#else
|
||||
#define CHAISCRIPT_COMPILER_VERSION __VERSION__
|
||||
#endif
|
||||
|
||||
#ifndef CHAISCRIPT_MSVC_12
|
||||
#define CHAISCRIPT_HAS_MAGIC_STATICS
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
#if defined( _LIBCPP_VERSION )
|
||||
@ -51,26 +44,15 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(CHAISCRIPT_MSVC) && !defined(CHAISCRIPT_MSVC_12)) || (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || (defined(__llvm__) && !defined(CHAISCRIPT_LIBCPP))
|
||||
/// Currently only g++>=4.8 supports this natively
|
||||
#if defined(CHAISCRIPT_MSVC) || (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || (defined(__llvm__) && !defined(CHAISCRIPT_LIBCPP))
|
||||
/// \todo Make this support other compilers when possible
|
||||
#define CHAISCRIPT_HAS_THREAD_LOCAL
|
||||
#endif
|
||||
|
||||
#if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 6)
|
||||
#define CHAISCRIPT_GCC_4_6
|
||||
#endif
|
||||
|
||||
#if defined(__llvm__)
|
||||
#define CHAISCRIPT_CLANG
|
||||
#endif
|
||||
|
||||
#if (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || defined(CHAISCRIPT_MSVC) || defined(CHAISCRIPT_CLANG)
|
||||
#define CHAISCRIPT_OVERRIDE override
|
||||
#else
|
||||
#define CHAISCRIPT_OVERRIDE
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CHAISCRIPT_HAS_DECLSPEC
|
||||
#define CHAISCRIPT_MODULE_EXPORT extern "C" __declspec(dllexport)
|
||||
@ -78,14 +60,6 @@
|
||||
#define CHAISCRIPT_MODULE_EXPORT extern "C"
|
||||
#endif
|
||||
|
||||
#ifdef CHAISCRIPT_MSVC_12
|
||||
#define CHAISCRIPT_NOEXCEPT throw()
|
||||
#define CHAISCRIPT_CONSTEXPR
|
||||
#else
|
||||
#define CHAISCRIPT_NOEXCEPT noexcept
|
||||
#define CHAISCRIPT_CONSTEXPR constexpr
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define CHAISCRIPT_DEBUG true
|
||||
#else
|
||||
@ -93,10 +67,12 @@
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
namespace chaiscript {
|
||||
static const int version_major = 5;
|
||||
static const int version_minor = 8;
|
||||
static const int version_major = 6;
|
||||
static const int version_minor = 0;
|
||||
static const int version_patch = 0;
|
||||
|
||||
static const char *compiler_version = CHAISCRIPT_COMPILER_VERSION;
|
||||
@ -113,6 +89,78 @@ namespace chaiscript {
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename Iter, typename Distance>
|
||||
Iter advance_copy(Iter iter, Distance distance) {
|
||||
std::advance(iter, static_cast<typename std::iterator_traits<Iter>::difference_type>(distance));
|
||||
return iter;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
auto parse_num(const char *t_str) -> typename std::enable_if<std::is_integral<T>::value, T>::type
|
||||
{
|
||||
T t = 0;
|
||||
for (char c = *t_str; (c = *t_str); ++t_str) {
|
||||
if (c < '0' || c > '9') {
|
||||
return t;
|
||||
}
|
||||
t *= 10;
|
||||
t += c - '0';
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
auto parse_num(const char *t_str) -> typename std::enable_if<!std::is_integral<T>::value, T>::type
|
||||
{
|
||||
T t = 0;
|
||||
T base = 0;
|
||||
T decimal_place = 0;
|
||||
bool exponent = false;
|
||||
bool neg_exponent = false;
|
||||
|
||||
const auto final_value = [](const T val, const T baseval, const bool hasexp, const bool negexp) -> T {
|
||||
if (!hasexp) {
|
||||
return val;
|
||||
} else {
|
||||
return baseval * std::pow(T(10), val*T(negexp?-1:1));
|
||||
}
|
||||
};
|
||||
|
||||
for(; *t_str != '\0'; ++t_str) {
|
||||
char c = *t_str;
|
||||
if (c == '.') {
|
||||
decimal_place = 10;
|
||||
} else if (c == 'e' || c == 'E') {
|
||||
exponent = true;
|
||||
decimal_place = 0;
|
||||
base = t;
|
||||
t = 0;
|
||||
} else if (c == '-' && exponent) {
|
||||
neg_exponent = true;
|
||||
} else if (c == '+' && exponent) {
|
||||
neg_exponent = false;
|
||||
} else if (c < '0' || c > '9') {
|
||||
return final_value(t, base, exponent, neg_exponent);
|
||||
} else if (decimal_place < T(10)) {
|
||||
t *= T(10);
|
||||
t += T(c - '0');
|
||||
} else {
|
||||
t += (T(c - '0') / (T(decimal_place)));
|
||||
decimal_place *= 10;
|
||||
}
|
||||
}
|
||||
|
||||
return final_value(t, base, exponent, neg_exponent);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T parse_num(const std::string &t_str)
|
||||
{
|
||||
return parse_num<T>(t_str.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -21,17 +21,17 @@ namespace chaiscript {
|
||||
class bad_any_cast : public std::bad_cast
|
||||
{
|
||||
public:
|
||||
bad_any_cast() CHAISCRIPT_NOEXCEPT
|
||||
bad_any_cast() noexcept
|
||||
: m_what("bad any cast")
|
||||
{
|
||||
}
|
||||
|
||||
bad_any_cast(const bad_any_cast &) = default;
|
||||
|
||||
virtual ~bad_any_cast() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~bad_any_cast() noexcept {}
|
||||
|
||||
/// \brief Description of what error occurred
|
||||
virtual const char * what() const CHAISCRIPT_NOEXCEPT CHAISCRIPT_OVERRIDE
|
||||
virtual const char * what() const noexcept override
|
||||
{
|
||||
return m_what.c_str();
|
||||
}
|
||||
@ -76,12 +76,12 @@ namespace chaiscript {
|
||||
|
||||
virtual ~Data_Impl() {}
|
||||
|
||||
virtual void *data() CHAISCRIPT_OVERRIDE
|
||||
virtual void *data() override
|
||||
{
|
||||
return &m_data;
|
||||
}
|
||||
|
||||
std::unique_ptr<Data> clone() const CHAISCRIPT_OVERRIDE
|
||||
std::unique_ptr<Data> clone() const override
|
||||
{
|
||||
return std::unique_ptr<Data>(new Data_Impl<T>(m_data));
|
||||
}
|
||||
@ -107,10 +107,8 @@ namespace chaiscript {
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER != 1800
|
||||
Any(Any &&) = default;
|
||||
Any &operator=(Any &&t_any) = default;
|
||||
#endif
|
||||
|
||||
template<typename ValueType,
|
||||
typename = typename std::enable_if<!std::is_same<Any, typename std::decay<ValueType>::type>::value>::type>
|
||||
|
@ -30,7 +30,7 @@ namespace chaiscript
|
||||
{
|
||||
public:
|
||||
bad_boxed_cast(Type_Info t_from, const std::type_info &t_to,
|
||||
std::string t_what) CHAISCRIPT_NOEXCEPT
|
||||
std::string t_what) noexcept
|
||||
: from(std::move(t_from)), to(&t_to), m_what(std::move(t_what))
|
||||
{
|
||||
}
|
||||
@ -40,16 +40,16 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
explicit bad_boxed_cast(std::string t_what) CHAISCRIPT_NOEXCEPT
|
||||
explicit bad_boxed_cast(std::string t_what) noexcept
|
||||
: to(nullptr), m_what(std::move(t_what))
|
||||
{
|
||||
}
|
||||
|
||||
bad_boxed_cast(const bad_boxed_cast &) = default;
|
||||
virtual ~bad_boxed_cast() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~bad_boxed_cast() noexcept {}
|
||||
|
||||
/// \brief Description of what error occurred
|
||||
virtual const char * what() const CHAISCRIPT_NOEXCEPT CHAISCRIPT_OVERRIDE
|
||||
virtual const char * what() const noexcept override
|
||||
{
|
||||
return m_what.c_str();
|
||||
}
|
||||
|
@ -248,13 +248,17 @@ namespace chaiscript
|
||||
m->add(
|
||||
fun(
|
||||
[](ContainerType &c, int index) -> typename ContainerType::reference {
|
||||
return c.at(index);
|
||||
/// \todo we are prefering to keep the key as 'int' to avoid runtime conversions
|
||||
/// during dispatch. reevaluate
|
||||
return c.at(static_cast<typename ContainerType::size_type>(index));
|
||||
}), "[]");
|
||||
|
||||
m->add(
|
||||
fun(
|
||||
[](const ContainerType &c, int index) -> typename ContainerType::const_reference {
|
||||
return c.at(index);
|
||||
/// \todo we are prefering to keep the key as 'int' to avoid runtime conversions
|
||||
/// during dispatch. reevaluate
|
||||
return c.at(static_cast<typename ContainerType::size_type>(index));
|
||||
}), "[]");
|
||||
|
||||
return m;
|
||||
|
@ -30,7 +30,7 @@ namespace chaiscript
|
||||
{
|
||||
arithmetic_error(const std::string& reason) : std::runtime_error("Arithmetic error: " + reason) {}
|
||||
arithmetic_error(const arithmetic_error &) = default;
|
||||
virtual ~arithmetic_error() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~arithmetic_error() noexcept {}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -43,16 +43,19 @@ namespace chaiscript
|
||||
// this is OK, so we're disabling size/and sign type warnings
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4244 4018 4389 4146 4365 4267)
|
||||
#pragma warning(disable : 4244 4018 4389 4146 4365 4267 4242)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma GCC diagnostic ignored "-Wpragmas"
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#pragma GCC diagnostic ignored "-Wfloat-conversion"
|
||||
#endif
|
||||
|
||||
/// \brief Represents any numeric type, generically. Used internally for generic operations between POD values
|
||||
@ -88,7 +91,7 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
static CHAISCRIPT_CONSTEXPR Common_Types get_common_type(size_t t_size, bool t_signed)
|
||||
static constexpr Common_Types get_common_type(size_t t_size, bool t_signed)
|
||||
{
|
||||
return (t_size == 1 && t_signed)?(Common_Types::t_int8)
|
||||
:(t_size == 1)?(Common_Types::t_uint8)
|
||||
@ -506,11 +509,8 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
Boxed_Number(const Boxed_Number &) = default;
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER != 1800
|
||||
Boxed_Number(Boxed_Number &&) = default;
|
||||
Boxed_Number& operator=(Boxed_Number &&) = default;
|
||||
#endif
|
||||
|
||||
template<typename T> explicit Boxed_Number(T t)
|
||||
: bv(Boxed_Value(t))
|
||||
|
@ -62,10 +62,8 @@ namespace chaiscript
|
||||
|
||||
Data(const Data &) = delete;
|
||||
|
||||
#if !defined(__APPLE__) && (!defined(_MSC_VER) || _MSC_VER != 1800)
|
||||
Data(Data &&) = default;
|
||||
Data &operator=(Data &&rhs) = default;
|
||||
#endif
|
||||
|
||||
|
||||
Type_Info m_type_info;
|
||||
@ -189,11 +187,8 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER != 1800
|
||||
Boxed_Value(Boxed_Value&&) = default;
|
||||
Boxed_Value& operator=(Boxed_Value&&) = default;
|
||||
#endif
|
||||
|
||||
Boxed_Value(const Boxed_Value&) = default;
|
||||
Boxed_Value& operator=(const Boxed_Value&) = default;
|
||||
|
||||
@ -210,63 +205,63 @@ namespace chaiscript
|
||||
return *this;
|
||||
}
|
||||
|
||||
const Type_Info &get_type_info() const CHAISCRIPT_NOEXCEPT
|
||||
const Type_Info &get_type_info() const noexcept
|
||||
{
|
||||
return m_data->m_type_info;
|
||||
}
|
||||
|
||||
/// return true if the object is uninitialized
|
||||
bool is_undef() const CHAISCRIPT_NOEXCEPT
|
||||
bool is_undef() const noexcept
|
||||
{
|
||||
return m_data->m_type_info.is_undef();
|
||||
}
|
||||
|
||||
bool is_const() const CHAISCRIPT_NOEXCEPT
|
||||
bool is_const() const noexcept
|
||||
{
|
||||
return m_data->m_type_info.is_const();
|
||||
}
|
||||
|
||||
bool is_type(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT
|
||||
bool is_type(const Type_Info &ti) const noexcept
|
||||
{
|
||||
return m_data->m_type_info.bare_equal(ti);
|
||||
}
|
||||
|
||||
bool is_null() const CHAISCRIPT_NOEXCEPT
|
||||
bool is_null() const noexcept
|
||||
{
|
||||
return (m_data->m_data_ptr == nullptr && m_data->m_const_data_ptr == nullptr);
|
||||
}
|
||||
|
||||
const chaiscript::detail::Any & get() const CHAISCRIPT_NOEXCEPT
|
||||
const chaiscript::detail::Any & get() const noexcept
|
||||
{
|
||||
return m_data->m_obj;
|
||||
}
|
||||
|
||||
bool is_ref() const CHAISCRIPT_NOEXCEPT
|
||||
bool is_ref() const noexcept
|
||||
{
|
||||
return m_data->m_is_ref;
|
||||
}
|
||||
|
||||
bool is_return_value() const CHAISCRIPT_NOEXCEPT
|
||||
bool is_return_value() const noexcept
|
||||
{
|
||||
return m_data->m_return_value;
|
||||
}
|
||||
|
||||
void reset_return_value() const CHAISCRIPT_NOEXCEPT
|
||||
void reset_return_value() const noexcept
|
||||
{
|
||||
m_data->m_return_value = false;
|
||||
}
|
||||
|
||||
bool is_pointer() const CHAISCRIPT_NOEXCEPT
|
||||
bool is_pointer() const noexcept
|
||||
{
|
||||
return !is_ref();
|
||||
}
|
||||
|
||||
void *get_ptr() const CHAISCRIPT_NOEXCEPT
|
||||
void *get_ptr() const noexcept
|
||||
{
|
||||
return m_data->m_data_ptr;
|
||||
}
|
||||
|
||||
const void *get_const_ptr() const CHAISCRIPT_NOEXCEPT
|
||||
const void *get_const_ptr() const noexcept
|
||||
{
|
||||
return m_data->m_const_data_ptr;
|
||||
}
|
||||
@ -306,7 +301,7 @@ namespace chaiscript
|
||||
|
||||
|
||||
/// \returns true if the two Boxed_Values share the same internal type
|
||||
static bool type_match(const Boxed_Value &l, const Boxed_Value &r) CHAISCRIPT_NOEXCEPT
|
||||
static bool type_match(const Boxed_Value &l, const Boxed_Value &r) noexcept
|
||||
{
|
||||
return l.get_type_info() == r.get_type_info();
|
||||
}
|
||||
@ -416,10 +411,9 @@ namespace chaiscript
|
||||
return detail::const_var_impl(t);
|
||||
}
|
||||
|
||||
#ifdef CHAISCRIPT_HAS_MAGIC_STATICS
|
||||
inline Boxed_Value const_var(bool b) {
|
||||
static auto t = detail::const_var_impl(true);
|
||||
static auto f = detail::const_var_impl(false);
|
||||
static const auto t = detail::const_var_impl(true);
|
||||
static const auto f = detail::const_var_impl(false);
|
||||
|
||||
if (b) {
|
||||
return t;
|
||||
@ -427,7 +421,6 @@ namespace chaiscript
|
||||
return f;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -56,14 +56,14 @@ namespace chaiscript
|
||||
class reserved_word_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
reserved_word_error(const std::string &t_word) CHAISCRIPT_NOEXCEPT
|
||||
reserved_word_error(const std::string &t_word) noexcept
|
||||
: std::runtime_error("Reserved word not allowed in object name: " + t_word), m_word(t_word)
|
||||
{
|
||||
}
|
||||
|
||||
reserved_word_error(const reserved_word_error &) = default;
|
||||
|
||||
virtual ~reserved_word_error() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~reserved_word_error() noexcept {}
|
||||
|
||||
std::string word() const
|
||||
{
|
||||
@ -78,14 +78,14 @@ namespace chaiscript
|
||||
class illegal_name_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
illegal_name_error(const std::string &t_name) CHAISCRIPT_NOEXCEPT
|
||||
illegal_name_error(const std::string &t_name) noexcept
|
||||
: std::runtime_error("Reserved name not allowed in object name: " + t_name), m_name(t_name)
|
||||
{
|
||||
}
|
||||
|
||||
illegal_name_error(const illegal_name_error &) = default;
|
||||
|
||||
virtual ~illegal_name_error() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~illegal_name_error() noexcept {}
|
||||
|
||||
std::string name() const
|
||||
{
|
||||
@ -101,14 +101,14 @@ namespace chaiscript
|
||||
class name_conflict_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
name_conflict_error(const std::string &t_name) CHAISCRIPT_NOEXCEPT
|
||||
name_conflict_error(const std::string &t_name) noexcept
|
||||
: std::runtime_error("Name already exists in current context " + t_name), m_name(t_name)
|
||||
{
|
||||
}
|
||||
|
||||
name_conflict_error(const name_conflict_error &) = default;
|
||||
|
||||
virtual ~name_conflict_error() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~name_conflict_error() noexcept {}
|
||||
|
||||
std::string name() const
|
||||
{
|
||||
@ -125,13 +125,13 @@ namespace chaiscript
|
||||
class global_non_const : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
global_non_const() CHAISCRIPT_NOEXCEPT
|
||||
global_non_const() noexcept
|
||||
: std::runtime_error("a global object must be const")
|
||||
{
|
||||
}
|
||||
|
||||
global_non_const(const global_non_const &) = default;
|
||||
virtual ~global_non_const() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~global_non_const() noexcept {}
|
||||
};
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const override
|
||||
{
|
||||
try {
|
||||
const auto &dispatch_fun = dynamic_cast<const Dispatch_Function &>(rhs);
|
||||
@ -288,7 +288,7 @@ namespace chaiscript
|
||||
|
||||
virtual ~Dispatch_Function() {}
|
||||
|
||||
virtual std::vector<Const_Proxy_Function> get_contained_functions() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::vector<Const_Proxy_Function> get_contained_functions() const override
|
||||
{
|
||||
return std::vector<Const_Proxy_Function>(m_funcs.begin(), m_funcs.end());
|
||||
}
|
||||
@ -314,19 +314,19 @@ namespace chaiscript
|
||||
return arity;
|
||||
}
|
||||
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
return std::any_of(m_funcs.cbegin(), m_funcs.cend(),
|
||||
[&vals, &t_conversions](const Proxy_Function &f){ return f->call_match(vals, t_conversions); });
|
||||
}
|
||||
|
||||
virtual std::string annotation() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string annotation() const override
|
||||
{
|
||||
return "Multiple method dispatch function wrapper.";
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
return dispatch::dispatch(m_funcs, params, t_conversions);
|
||||
}
|
||||
@ -591,14 +591,14 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
/// Adds a new scope to the stack
|
||||
void new_scope(Stack_Holder &t_holder)
|
||||
static void new_scope(Stack_Holder &t_holder)
|
||||
{
|
||||
get_stack_data(t_holder).emplace_back();
|
||||
t_holder.call_params.emplace_back();
|
||||
}
|
||||
|
||||
/// Pops the current scope from the stack
|
||||
void pop_scope(Stack_Holder &t_holder)
|
||||
static void pop_scope(Stack_Holder &t_holder)
|
||||
{
|
||||
t_holder.call_params.pop_back();
|
||||
StackData &stack = get_stack_data(t_holder);
|
||||
@ -635,7 +635,7 @@ namespace chaiscript
|
||||
loc_mask = 0x0000FFFF
|
||||
};
|
||||
|
||||
uint_fast32_t loc = t_loc.load(std::memory_order_relaxed);
|
||||
uint_fast32_t loc = t_loc;
|
||||
|
||||
if (loc == 0)
|
||||
{
|
||||
@ -647,17 +647,16 @@ namespace chaiscript
|
||||
for (auto s = stack_elem->begin(); s != stack_elem->end(); ++s )
|
||||
{
|
||||
if (s->first == name) {
|
||||
t_loc.store( static_cast<uint_fast32_t>(std::distance(stack.rbegin(), stack_elem) << 16)
|
||||
| static_cast<uint_fast32_t>(std::distance(stack_elem->begin(), s))
|
||||
| static_cast<uint_fast32_t>(Loc::located)
|
||||
| static_cast<uint_fast32_t>(Loc::is_local),
|
||||
std::memory_order_relaxed);
|
||||
t_loc = static_cast<uint_fast32_t>(std::distance(stack.rbegin(), stack_elem) << 16)
|
||||
| static_cast<uint_fast32_t>(std::distance(stack_elem->begin(), s))
|
||||
| static_cast<uint_fast32_t>(Loc::located)
|
||||
| static_cast<uint_fast32_t>(Loc::is_local);
|
||||
return s->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t_loc.store( static_cast<uint_fast32_t>(Loc::located), std::memory_order_relaxed);
|
||||
t_loc = static_cast<uint_fast32_t>(Loc::located);
|
||||
} else if (loc & static_cast<uint_fast32_t>(Loc::is_local)) {
|
||||
auto &stack = get_stack_data();
|
||||
|
||||
@ -675,7 +674,7 @@ namespace chaiscript
|
||||
|
||||
// no? is it a function object?
|
||||
auto obj = get_function_object_int(name, loc);
|
||||
if (obj.first != loc) t_loc.store(uint_fast32_t(obj.first), std::memory_order_relaxed);
|
||||
if (obj.first != loc) t_loc = uint_fast32_t(obj.first);
|
||||
return obj.second;
|
||||
|
||||
|
||||
@ -738,9 +737,9 @@ namespace chaiscript
|
||||
|
||||
std::shared_ptr<std::vector<Proxy_Function>> get_method_missing_functions() const
|
||||
{
|
||||
uint_fast32_t method_missing_loc = m_method_missing_loc.load(std::memory_order_relaxed);
|
||||
uint_fast32_t method_missing_loc = m_method_missing_loc;
|
||||
auto method_missing_funs = get_function("method_missing", method_missing_loc);
|
||||
if (method_missing_funs.first != method_missing_loc) m_method_missing_loc.store(uint_fast32_t(method_missing_funs.first), std::memory_order_relaxed);
|
||||
if (method_missing_funs.first != method_missing_loc) m_method_missing_loc = uint_fast32_t(method_missing_funs.first);
|
||||
return std::move(method_missing_funs.second);
|
||||
}
|
||||
|
||||
@ -911,8 +910,8 @@ namespace chaiscript
|
||||
return m_conversions;
|
||||
}
|
||||
|
||||
bool is_attribute_call(const std::vector<Proxy_Function> &t_funs, const std::vector<Boxed_Value> &t_params,
|
||||
bool t_has_params, const Type_Conversions_State &t_conversions) const
|
||||
static bool is_attribute_call(const std::vector<Proxy_Function> &t_funs, const std::vector<Boxed_Value> &t_params,
|
||||
bool t_has_params, const Type_Conversions_State &t_conversions)
|
||||
{
|
||||
if (!t_has_params || t_params.empty()) {
|
||||
return false;
|
||||
@ -938,9 +937,9 @@ namespace chaiscript
|
||||
Boxed_Value call_member(const std::string &t_name, std::atomic_uint_fast32_t &t_loc, const std::vector<Boxed_Value> ¶ms, bool t_has_params,
|
||||
const Type_Conversions_State &t_conversions)
|
||||
{
|
||||
uint_fast32_t loc = t_loc.load(std::memory_order_relaxed);
|
||||
uint_fast32_t loc = t_loc;
|
||||
const auto funs = get_function(t_name, loc);
|
||||
if (funs.first != loc) t_loc.store(uint_fast32_t(funs.first), std::memory_order_relaxed);
|
||||
if (funs.first != loc) t_loc = uint_fast32_t(funs.first);
|
||||
|
||||
const auto do_attribute_call =
|
||||
[this](int l_num_params, const std::vector<Boxed_Value> &l_params, const std::vector<Proxy_Function> &l_funs, const Type_Conversions_State &l_conversions)->Boxed_Value
|
||||
@ -1051,9 +1050,9 @@ namespace chaiscript
|
||||
Boxed_Value call_function(const std::string &t_name, std::atomic_uint_fast32_t &t_loc, const std::vector<Boxed_Value> ¶ms,
|
||||
const Type_Conversions_State &t_conversions) const
|
||||
{
|
||||
uint_fast32_t loc = t_loc.load(std::memory_order_relaxed);
|
||||
uint_fast32_t loc = t_loc;
|
||||
const auto funs = get_function(t_name, loc);
|
||||
if (funs.first != loc) t_loc.store(uint_fast32_t(funs.first), std::memory_order_relaxed);
|
||||
if (funs.first != loc) t_loc = uint_fast32_t(funs.first);
|
||||
return dispatch::dispatch(*funs.second, params, t_conversions);
|
||||
}
|
||||
|
||||
@ -1333,13 +1332,8 @@ namespace chaiscript
|
||||
const auto lhssize = lhsparamtypes.size();
|
||||
const auto rhssize = rhsparamtypes.size();
|
||||
|
||||
#ifdef CHAISCRIPT_HAS_MAGIC_STATICS
|
||||
static auto boxed_type = user_type<Boxed_Value>();
|
||||
static auto boxed_pod_type = user_type<Boxed_Number>();
|
||||
#else
|
||||
auto boxed_type = user_type<Boxed_Value>();
|
||||
auto boxed_pod_type = user_type<Boxed_Number>();
|
||||
#endif
|
||||
static const auto boxed_type = user_type<Boxed_Value>();
|
||||
static const auto boxed_pod_type = user_type<Boxed_Number>();
|
||||
|
||||
for (size_t i = 1; i < lhssize && i < rhssize; ++i)
|
||||
{
|
||||
@ -1446,7 +1440,7 @@ namespace chaiscript
|
||||
static typename Container::const_iterator find_keyed_value(const Container &t_c, const Key &t_key, const size_t t_hint)
|
||||
{
|
||||
if (t_c.size() > t_hint && t_c[t_hint].first == t_key) {
|
||||
return t_c.begin() + t_hint;
|
||||
return advance_copy(t_c.begin(), t_hint);
|
||||
} else {
|
||||
return find_keyed_value(t_c, t_key);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace chaiscript
|
||||
|
||||
option_explicit_set(const option_explicit_set &) = default;
|
||||
|
||||
virtual ~option_explicit_set() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~option_explicit_set() noexcept {}
|
||||
};
|
||||
|
||||
class Dynamic_Object
|
||||
|
@ -72,7 +72,7 @@ namespace chaiscript
|
||||
Dynamic_Object_Function &operator=(const Dynamic_Object_Function) = delete;
|
||||
Dynamic_Object_Function(Dynamic_Object_Function &) = delete;
|
||||
|
||||
virtual bool operator==(const Proxy_Function_Base &f) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool operator==(const Proxy_Function_Base &f) const override
|
||||
{
|
||||
if (const auto *df = dynamic_cast<const Dynamic_Object_Function *>(&f))
|
||||
{
|
||||
@ -82,9 +82,9 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool is_attribute_function() const CHAISCRIPT_OVERRIDE { return m_is_attribute; }
|
||||
virtual bool is_attribute_function() const override { return m_is_attribute; }
|
||||
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
if (dynamic_object_typename_match(vals, m_type_name, m_ti, t_conversions))
|
||||
{
|
||||
@ -94,19 +94,19 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
virtual std::vector<Const_Proxy_Function> get_contained_functions() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::vector<Const_Proxy_Function> get_contained_functions() const override
|
||||
{
|
||||
return {m_func};
|
||||
}
|
||||
|
||||
virtual std::string annotation() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string annotation() const override
|
||||
{
|
||||
return m_func->annotation();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
if (dynamic_object_typename_match(params, m_type_name, m_ti, t_conversions))
|
||||
{
|
||||
@ -116,7 +116,7 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool compare_first_type(const Boxed_Value &bv, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool compare_first_type(const Boxed_Value &bv, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
return dynamic_object_typename_match(bv, m_type_name, m_ti, t_conversions);
|
||||
}
|
||||
@ -210,13 +210,13 @@ namespace chaiscript
|
||||
|
||||
virtual ~Dynamic_Object_Constructor() {}
|
||||
|
||||
virtual bool operator==(const Proxy_Function_Base &f) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool operator==(const Proxy_Function_Base &f) const override
|
||||
{
|
||||
const Dynamic_Object_Constructor *dc = dynamic_cast<const Dynamic_Object_Constructor*>(&f);
|
||||
return dc && dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func);
|
||||
}
|
||||
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
std::vector<Boxed_Value> new_vals{Boxed_Value(Dynamic_Object(m_type_name))};
|
||||
new_vals.insert(new_vals.end(), vals.begin(), vals.end());
|
||||
@ -224,13 +224,13 @@ namespace chaiscript
|
||||
return m_func->call_match(new_vals, t_conversions);
|
||||
}
|
||||
|
||||
virtual std::string annotation() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string annotation() const override
|
||||
{
|
||||
return m_func->annotation();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
auto bv = Boxed_Value(Dynamic_Object(m_type_name), true);
|
||||
std::vector<Boxed_Value> new_params{bv};
|
||||
|
@ -43,7 +43,7 @@ namespace chaiscript
|
||||
{
|
||||
virtual ~Exception_Handler_Impl1() {}
|
||||
|
||||
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
|
||||
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
|
||||
{
|
||||
throw_type<T1>(bv, t_engine);
|
||||
}
|
||||
@ -53,7 +53,7 @@ namespace chaiscript
|
||||
{
|
||||
virtual ~Exception_Handler_Impl2() {}
|
||||
|
||||
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
|
||||
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
|
||||
{
|
||||
throw_type<T1>(bv, t_engine);
|
||||
throw_type<T2>(bv, t_engine);
|
||||
@ -65,7 +65,7 @@ namespace chaiscript
|
||||
{
|
||||
virtual ~Exception_Handler_Impl3() {}
|
||||
|
||||
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
|
||||
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
|
||||
{
|
||||
throw_type<T1>(bv, t_engine);
|
||||
throw_type<T2>(bv, t_engine);
|
||||
@ -77,7 +77,7 @@ namespace chaiscript
|
||||
{
|
||||
virtual ~Exception_Handler_Impl4() {}
|
||||
|
||||
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
|
||||
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
|
||||
{
|
||||
throw_type<T1>(bv, t_engine);
|
||||
throw_type<T2>(bv, t_engine);
|
||||
@ -90,7 +90,7 @@ namespace chaiscript
|
||||
{
|
||||
virtual ~Exception_Handler_Impl5() {}
|
||||
|
||||
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
|
||||
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
|
||||
{
|
||||
throw_type<T1>(bv, t_engine);
|
||||
throw_type<T2>(bv, t_engine);
|
||||
|
@ -282,13 +282,13 @@ namespace chaiscript
|
||||
class guard_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
guard_error() CHAISCRIPT_NOEXCEPT
|
||||
guard_error() noexcept
|
||||
: std::runtime_error("Guard evaluation failed")
|
||||
{ }
|
||||
|
||||
guard_error(const guard_error &) = default;
|
||||
|
||||
virtual ~guard_error() CHAISCRIPT_NOEXCEPT
|
||||
virtual ~guard_error() noexcept
|
||||
{ }
|
||||
};
|
||||
}
|
||||
@ -316,7 +316,7 @@ namespace chaiscript
|
||||
|
||||
virtual ~Dynamic_Proxy_Function() {}
|
||||
|
||||
virtual bool operator==(const Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool operator==(const Proxy_Function_Base &rhs) const override
|
||||
{
|
||||
const Dynamic_Proxy_Function *prhs = dynamic_cast<const Dynamic_Proxy_Function *>(&rhs);
|
||||
|
||||
@ -327,7 +327,7 @@ namespace chaiscript
|
||||
&& this->m_param_types == prhs->m_param_types);
|
||||
}
|
||||
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
return (m_arity < 0 || (vals.size() == size_t(m_arity) && m_param_types.match(vals, t_conversions)))
|
||||
&& test_guard(vals, t_conversions);
|
||||
@ -344,7 +344,7 @@ namespace chaiscript
|
||||
return m_parsenode;
|
||||
}
|
||||
|
||||
virtual std::string annotation() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string annotation() const override
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
@ -419,7 +419,7 @@ namespace chaiscript
|
||||
|
||||
|
||||
protected:
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
if (call_match(params, t_conversions) && test_guard(params, t_conversions))
|
||||
{
|
||||
@ -462,19 +462,19 @@ namespace chaiscript
|
||||
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 CHAISCRIPT_OVERRIDE
|
||||
virtual bool operator==(const Proxy_Function_Base &t_f) const override
|
||||
{
|
||||
return &t_f == this;
|
||||
}
|
||||
|
||||
virtual ~Bound_Function() {}
|
||||
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
return m_f->call_match(build_param_list(vals), t_conversions);
|
||||
}
|
||||
|
||||
virtual std::vector<Const_Proxy_Function> get_contained_functions() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::vector<Const_Proxy_Function> get_contained_functions() const override
|
||||
{
|
||||
return std::vector<Const_Proxy_Function>{m_f};
|
||||
}
|
||||
@ -511,7 +511,7 @@ namespace chaiscript
|
||||
return args;
|
||||
}
|
||||
|
||||
virtual std::string annotation() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string annotation() const override
|
||||
{
|
||||
return "Bound: " + m_f->annotation();
|
||||
}
|
||||
@ -527,15 +527,8 @@ namespace chaiscript
|
||||
std::vector<Type_Info> types = t_f->get_param_types();
|
||||
assert(types.size() == t_args.size() + 1);
|
||||
|
||||
#ifdef CHAISCRIPT_MSVC_12
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 6011)
|
||||
#endif
|
||||
// this analysis warning is invalid in MSVC12 and doesn't exist in MSVC14
|
||||
std::vector<Type_Info> retval{types[0]};
|
||||
#ifdef CHAISCRIPT_MSVC_12
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < types.size() - 1; ++i)
|
||||
{
|
||||
@ -548,7 +541,7 @@ namespace chaiscript
|
||||
return retval;
|
||||
}
|
||||
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
return (*m_f)(build_param_list(params), t_conversions);
|
||||
}
|
||||
@ -568,12 +561,12 @@ namespace chaiscript
|
||||
|
||||
virtual ~Proxy_Function_Impl_Base() {}
|
||||
|
||||
virtual std::string annotation() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string annotation() const override
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
return static_cast<int>(vals.size()) == get_arity() && (compare_types(m_types, vals, t_conversions) && compare_types_with_cast(vals, t_conversions));
|
||||
}
|
||||
@ -596,19 +589,19 @@ namespace chaiscript
|
||||
|
||||
virtual ~Proxy_Function_Callable_Impl() {}
|
||||
|
||||
virtual bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
return detail::compare_types_cast(static_cast<Func *>(nullptr), vals, t_conversions);
|
||||
}
|
||||
|
||||
virtual bool operator==(const Proxy_Function_Base &t_func) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool operator==(const Proxy_Function_Base &t_func) const override
|
||||
{
|
||||
return dynamic_cast<const Proxy_Function_Callable_Impl<Func, Callable> *>(&t_func) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
typedef typename detail::Function_Signature<Func>::Return_Type Return_Type;
|
||||
return detail::Do_Call<Return_Type>::template go<Func>(m_f, params, t_conversions);
|
||||
@ -648,12 +641,12 @@ namespace chaiscript
|
||||
|
||||
virtual ~Assignable_Proxy_Function_Impl() {}
|
||||
|
||||
virtual bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
return detail::compare_types_cast(static_cast<Func *>(nullptr), vals, t_conversions);
|
||||
}
|
||||
|
||||
virtual bool operator==(const Proxy_Function_Base &t_func) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool operator==(const Proxy_Function_Base &t_func) const override
|
||||
{
|
||||
return dynamic_cast<const Assignable_Proxy_Function_Impl<Func> *>(&t_func) != nullptr;
|
||||
}
|
||||
@ -663,12 +656,12 @@ namespace chaiscript
|
||||
return m_f.get();
|
||||
}
|
||||
|
||||
virtual void assign(const std::shared_ptr<const Proxy_Function_Base> &t_rhs) CHAISCRIPT_OVERRIDE {
|
||||
virtual void assign(const std::shared_ptr<const Proxy_Function_Base> &t_rhs) override {
|
||||
m_f.get() = dispatch::functor<Func>(t_rhs, nullptr);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
return detail::Do_Call<typename std::function<Func>::result_type>::template go<Func>(m_f.get(), params, t_conversions);
|
||||
}
|
||||
@ -691,9 +684,9 @@ namespace chaiscript
|
||||
|
||||
virtual ~Attribute_Access() {}
|
||||
|
||||
virtual bool is_attribute_function() const CHAISCRIPT_OVERRIDE { return true; }
|
||||
virtual bool is_attribute_function() const override { return true; }
|
||||
|
||||
virtual bool operator==(const Proxy_Function_Base &t_func) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool operator==(const Proxy_Function_Base &t_func) const override
|
||||
{
|
||||
const Attribute_Access<T, Class> * aa
|
||||
= dynamic_cast<const Attribute_Access<T, Class> *>(&t_func);
|
||||
@ -705,7 +698,7 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &) const CHAISCRIPT_OVERRIDE
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &) const override
|
||||
{
|
||||
if (vals.size() != 1)
|
||||
{
|
||||
@ -715,13 +708,13 @@ namespace chaiscript
|
||||
return vals[0].get_type_info().bare_equal(user_type<Class>());
|
||||
}
|
||||
|
||||
virtual std::string annotation() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string annotation() const override
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) const override
|
||||
{
|
||||
const Boxed_Value &bv = params[0];
|
||||
if (bv.is_const())
|
||||
@ -769,7 +762,7 @@ namespace chaiscript
|
||||
|
||||
|
||||
dispatch_error(const dispatch_error &) = default;
|
||||
virtual ~dispatch_error() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~dispatch_error() noexcept {}
|
||||
|
||||
std::vector<Boxed_Value> parameters;
|
||||
std::vector<Const_Proxy_Function> functions;
|
||||
|
@ -43,7 +43,7 @@ namespace chaiscript
|
||||
|
||||
arity_error(const arity_error &) = default;
|
||||
|
||||
virtual ~arity_error() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~arity_error() noexcept {}
|
||||
|
||||
int got;
|
||||
int expected;
|
||||
@ -66,103 +66,6 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
|
||||
#ifdef CHAISCRIPT_GCC_4_6
|
||||
/// \todo REMOVE THIS WHEN WE DROP G++4.6
|
||||
|
||||
|
||||
// Forward declaration
|
||||
template<typename ... Rest>
|
||||
struct Try_Cast;
|
||||
|
||||
template<typename Param, typename ... Rest>
|
||||
struct Try_Cast<Param, Rest...>
|
||||
{
|
||||
static void do_try(const std::vector<Boxed_Value> ¶ms, size_t generation, const Type_Conversions_State &t_conversions)
|
||||
{
|
||||
boxed_cast<Param>(params[generation], &t_conversions);
|
||||
Try_Cast<Rest...>::do_try(params, generation+1, t_conversions);
|
||||
}
|
||||
};
|
||||
|
||||
// 0th case
|
||||
template<>
|
||||
struct Try_Cast<>
|
||||
{
|
||||
static void do_try(const std::vector<Boxed_Value> &, size_t, const Type_Conversions_State &)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Used by Proxy_Function_Impl to determine if it is equivalent to another
|
||||
* Proxy_Function_Impl object. This function is primarily used to prevent
|
||||
* registration of two functions with the exact same signatures
|
||||
*/
|
||||
template<typename Ret, typename ... Params>
|
||||
bool compare_types_cast(Ret (*)(Params...),
|
||||
const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions)
|
||||
{
|
||||
try {
|
||||
Try_Cast<Params...>::do_try(params, 0, t_conversions);
|
||||
} catch (const exception::bad_boxed_cast &) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename Ret, int count, typename ... Params>
|
||||
struct Call_Func
|
||||
{
|
||||
|
||||
template<typename Callable, typename ... InnerParams>
|
||||
static Ret do_call(const Callable &f,
|
||||
const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions, InnerParams &&... innerparams)
|
||||
{
|
||||
return Call_Func<Ret, count - 1, Params...>::do_call(f, params, t_conversions, std::forward<InnerParams>(innerparams)..., params[sizeof...(Params) - count]);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Ret, typename ... Params>
|
||||
struct Call_Func<Ret, 0, Params...>
|
||||
{
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4100) /// Disable unreferenced formal parameter warning, which only shows up in MSVC I don't think there's any way around it \todo evaluate this
|
||||
#endif
|
||||
template<typename Callable, typename ... InnerParams>
|
||||
static Ret do_call(const Callable &f,
|
||||
const std::vector<Boxed_Value> &, const Type_Conversions_State &t_conversions, InnerParams &&... innerparams)
|
||||
{
|
||||
return f(boxed_cast<Params>(std::forward<InnerParams>(innerparams), &t_conversions)...);
|
||||
}
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Used by Proxy_Function_Impl to perform typesafe execution of a function.
|
||||
* The function attempts to unbox each parameter to the expected type.
|
||||
* if any unboxing fails the execution of the function fails and
|
||||
* the bad_boxed_cast is passed up to the caller.
|
||||
*/
|
||||
template<typename Callable, typename Ret, typename ... Params>
|
||||
Ret call_func(const chaiscript::dispatch::detail::Function_Signature<Ret (Params...)> &, const Callable &f,
|
||||
const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions)
|
||||
{
|
||||
if (params.size() == sizeof...(Params))
|
||||
{
|
||||
return Call_Func<Ret, sizeof...(Params), Params...>::do_call(f, params, t_conversions);
|
||||
}
|
||||
|
||||
throw exception::arity_error(static_cast<int>(params.size()), sizeof...(Params));
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
template<size_t ... I>
|
||||
struct Indexes
|
||||
@ -234,8 +137,6 @@ namespace chaiscript
|
||||
return call_func(sig, indexes(), f, params, t_conversions);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,48 +29,48 @@ namespace chaiscript
|
||||
{
|
||||
public:
|
||||
bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to,
|
||||
const std::string &t_what) CHAISCRIPT_NOEXCEPT
|
||||
const std::string &t_what) noexcept
|
||||
: bad_boxed_cast(t_from, t_to, t_what)
|
||||
{
|
||||
}
|
||||
|
||||
bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to) CHAISCRIPT_NOEXCEPT
|
||||
bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to) noexcept
|
||||
: bad_boxed_cast(t_from, t_to)
|
||||
{
|
||||
}
|
||||
|
||||
bad_boxed_dynamic_cast(const std::string &w) CHAISCRIPT_NOEXCEPT
|
||||
bad_boxed_dynamic_cast(const std::string &w) noexcept
|
||||
: bad_boxed_cast(w)
|
||||
{
|
||||
}
|
||||
|
||||
bad_boxed_dynamic_cast(const bad_boxed_dynamic_cast &) = default;
|
||||
|
||||
virtual ~bad_boxed_dynamic_cast() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~bad_boxed_dynamic_cast() noexcept {}
|
||||
};
|
||||
|
||||
class bad_boxed_type_cast : public bad_boxed_cast
|
||||
{
|
||||
public:
|
||||
bad_boxed_type_cast(const Type_Info &t_from, const std::type_info &t_to,
|
||||
const std::string &t_what) CHAISCRIPT_NOEXCEPT
|
||||
const std::string &t_what) noexcept
|
||||
: bad_boxed_cast(t_from, t_to, t_what)
|
||||
{
|
||||
}
|
||||
|
||||
bad_boxed_type_cast(const Type_Info &t_from, const std::type_info &t_to) CHAISCRIPT_NOEXCEPT
|
||||
bad_boxed_type_cast(const Type_Info &t_from, const std::type_info &t_to) noexcept
|
||||
: bad_boxed_cast(t_from, t_to)
|
||||
{
|
||||
}
|
||||
|
||||
bad_boxed_type_cast(const std::string &w) CHAISCRIPT_NOEXCEPT
|
||||
bad_boxed_type_cast(const std::string &w) noexcept
|
||||
: bad_boxed_cast(w)
|
||||
{
|
||||
}
|
||||
|
||||
bad_boxed_type_cast(const bad_boxed_type_cast &) = default;
|
||||
|
||||
virtual ~bad_boxed_type_cast() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~bad_boxed_type_cast() noexcept {}
|
||||
};
|
||||
}
|
||||
|
||||
@ -242,12 +242,12 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
virtual Boxed_Value convert_down(const Boxed_Value &t_base) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value convert_down(const Boxed_Value &t_base) const override
|
||||
{
|
||||
return Dynamic_Caster<Base, Derived>::cast(t_base);
|
||||
}
|
||||
|
||||
virtual Boxed_Value convert(const Boxed_Value &t_derived) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value convert(const Boxed_Value &t_derived) const override
|
||||
{
|
||||
return Static_Caster<Derived, Base>::cast(t_derived);
|
||||
}
|
||||
@ -262,17 +262,17 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
virtual Boxed_Value convert_down(const Boxed_Value &t_base) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value convert_down(const Boxed_Value &t_base) const override
|
||||
{
|
||||
throw chaiscript::exception::bad_boxed_dynamic_cast(t_base.get_type_info(), typeid(Derived), "Unable to cast down inheritance hierarchy with non-polymorphic types");
|
||||
}
|
||||
|
||||
virtual bool bidir() const CHAISCRIPT_OVERRIDE
|
||||
virtual bool bidir() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual Boxed_Value convert(const Boxed_Value &t_derived) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value convert(const Boxed_Value &t_derived) const override
|
||||
{
|
||||
return Static_Caster<Derived, Base>::cast(t_derived);
|
||||
}
|
||||
@ -290,18 +290,18 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
virtual Boxed_Value convert_down(const Boxed_Value &) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value convert_down(const Boxed_Value &) const override
|
||||
{
|
||||
throw chaiscript::exception::bad_boxed_type_cast("No conversion exists");
|
||||
}
|
||||
|
||||
virtual Boxed_Value convert(const Boxed_Value &t_from) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value convert(const Boxed_Value &t_from) const override
|
||||
{
|
||||
/// \todo better handling of errors from the conversion function
|
||||
return m_func(t_from);
|
||||
}
|
||||
|
||||
virtual bool bidir() const CHAISCRIPT_OVERRIDE
|
||||
virtual bool bidir() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -29,66 +29,63 @@ namespace chaiscript
|
||||
class Type_Info
|
||||
{
|
||||
public:
|
||||
CHAISCRIPT_CONSTEXPR Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void,
|
||||
constexpr Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void,
|
||||
bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti)
|
||||
: m_type_info(t_ti), m_bare_type_info(t_bare_ti),
|
||||
m_flags((t_is_const << is_const_flag)
|
||||
+ (t_is_reference << is_reference_flag)
|
||||
+ (t_is_pointer << is_pointer_flag)
|
||||
+ (t_is_void << is_void_flag)
|
||||
+ (t_is_arithmetic << is_arithmetic_flag))
|
||||
m_flags((static_cast<unsigned int>(t_is_const) << is_const_flag)
|
||||
+ (static_cast<unsigned int>(t_is_reference) << is_reference_flag)
|
||||
+ (static_cast<unsigned int>(t_is_pointer) << is_pointer_flag)
|
||||
+ (static_cast<unsigned int>(t_is_void) << is_void_flag)
|
||||
+ (static_cast<unsigned int>(t_is_arithmetic) << is_arithmetic_flag))
|
||||
{
|
||||
}
|
||||
|
||||
CHAISCRIPT_CONSTEXPR Type_Info()
|
||||
constexpr Type_Info()
|
||||
: m_type_info(nullptr), m_bare_type_info(nullptr),
|
||||
m_flags(1 << is_undef_flag)
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER != 1800
|
||||
Type_Info(Type_Info&&) = default;
|
||||
Type_Info& operator=(Type_Info&&) = default;
|
||||
#endif
|
||||
|
||||
Type_Info(const Type_Info&) = default;
|
||||
Type_Info& operator=(const Type_Info&) = default;
|
||||
|
||||
|
||||
CHAISCRIPT_CONSTEXPR bool operator<(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT
|
||||
constexpr bool operator<(const Type_Info &ti) const noexcept
|
||||
{
|
||||
return m_type_info < ti.m_type_info;
|
||||
}
|
||||
|
||||
CHAISCRIPT_CONSTEXPR bool operator==(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT
|
||||
constexpr bool operator==(const Type_Info &ti) const noexcept
|
||||
{
|
||||
return ti.m_type_info == m_type_info
|
||||
|| (ti.m_type_info && m_type_info && *ti.m_type_info == *m_type_info);
|
||||
}
|
||||
|
||||
CHAISCRIPT_CONSTEXPR bool operator==(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT
|
||||
constexpr bool operator==(const std::type_info &ti) const noexcept
|
||||
{
|
||||
return m_type_info != nullptr && (*m_type_info) == ti;
|
||||
}
|
||||
|
||||
CHAISCRIPT_CONSTEXPR bool bare_equal(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT
|
||||
constexpr bool bare_equal(const Type_Info &ti) const noexcept
|
||||
{
|
||||
return ti.m_bare_type_info == m_bare_type_info
|
||||
|| (ti.m_bare_type_info && m_bare_type_info && *ti.m_bare_type_info == *m_bare_type_info);
|
||||
}
|
||||
|
||||
CHAISCRIPT_CONSTEXPR bool bare_equal_type_info(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT
|
||||
constexpr bool bare_equal_type_info(const std::type_info &ti) const noexcept
|
||||
{
|
||||
return m_bare_type_info != nullptr
|
||||
&& (*m_bare_type_info) == ti;
|
||||
}
|
||||
|
||||
CHAISCRIPT_CONSTEXPR bool is_const() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_const_flag)) != 0; }
|
||||
CHAISCRIPT_CONSTEXPR bool is_reference() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_reference_flag)) != 0; }
|
||||
CHAISCRIPT_CONSTEXPR bool is_void() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_void_flag)) != 0; }
|
||||
CHAISCRIPT_CONSTEXPR bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_arithmetic_flag)) != 0; }
|
||||
CHAISCRIPT_CONSTEXPR bool is_undef() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_undef_flag)) != 0; }
|
||||
CHAISCRIPT_CONSTEXPR bool is_pointer() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_pointer_flag)) != 0; }
|
||||
constexpr bool is_const() const noexcept { return (m_flags & (1 << is_const_flag)) != 0; }
|
||||
constexpr bool is_reference() const noexcept { return (m_flags & (1 << is_reference_flag)) != 0; }
|
||||
constexpr bool is_void() const noexcept { return (m_flags & (1 << is_void_flag)) != 0; }
|
||||
constexpr bool is_arithmetic() const noexcept { return (m_flags & (1 << is_arithmetic_flag)) != 0; }
|
||||
constexpr bool is_undef() const noexcept { return (m_flags & (1 << is_undef_flag)) != 0; }
|
||||
constexpr bool is_pointer() const noexcept { return (m_flags & (1 << is_pointer_flag)) != 0; }
|
||||
|
||||
std::string name() const
|
||||
{
|
||||
@ -110,7 +107,7 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
CHAISCRIPT_CONSTEXPR const std::type_info *bare_type_info() const
|
||||
constexpr const std::type_info *bare_type_info() const
|
||||
{
|
||||
return m_bare_type_info;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ namespace chaiscript
|
||||
eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname,
|
||||
const std::vector<Boxed_Value> &t_parameters, const std::vector<chaiscript::Const_Proxy_Function> &t_functions,
|
||||
bool t_dot_notation,
|
||||
const chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_NOEXCEPT :
|
||||
const chaiscript::detail::Dispatch_Engine &t_ss) noexcept :
|
||||
std::runtime_error(format(t_why, t_where, t_fname, t_parameters, t_dot_notation, t_ss)),
|
||||
reason(t_why), start_position(t_where), filename(t_fname), detail(format_detail(t_functions, t_dot_notation, t_ss))
|
||||
{}
|
||||
@ -121,18 +121,18 @@ namespace chaiscript
|
||||
eval_error(const std::string &t_why,
|
||||
const std::vector<Boxed_Value> &t_parameters, const std::vector<chaiscript::Const_Proxy_Function> &t_functions,
|
||||
bool t_dot_notation,
|
||||
const chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_NOEXCEPT :
|
||||
const chaiscript::detail::Dispatch_Engine &t_ss) noexcept :
|
||||
std::runtime_error(format(t_why, t_parameters, t_dot_notation, t_ss)),
|
||||
reason(t_why), detail(format_detail(t_functions, t_dot_notation, t_ss))
|
||||
{}
|
||||
|
||||
|
||||
eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname) CHAISCRIPT_NOEXCEPT :
|
||||
eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname) noexcept :
|
||||
std::runtime_error(format(t_why, t_where, t_fname)),
|
||||
reason(t_why), start_position(t_where), filename(t_fname)
|
||||
{}
|
||||
|
||||
eval_error(const std::string &t_why) CHAISCRIPT_NOEXCEPT
|
||||
eval_error(const std::string &t_why) noexcept
|
||||
: std::runtime_error("Error: \"" + t_why + "\" "),
|
||||
reason(t_why)
|
||||
{}
|
||||
@ -161,7 +161,7 @@ namespace chaiscript
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
virtual ~eval_error() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~eval_error() noexcept {}
|
||||
|
||||
private:
|
||||
|
||||
@ -420,12 +420,12 @@ namespace chaiscript
|
||||
|
||||
/// Errors generated when loading a file
|
||||
struct file_not_found_error : std::runtime_error {
|
||||
file_not_found_error(const std::string &t_filename) CHAISCRIPT_NOEXCEPT
|
||||
file_not_found_error(const std::string &t_filename) noexcept
|
||||
: std::runtime_error("File Not Found: " + t_filename)
|
||||
{ }
|
||||
|
||||
file_not_found_error(const file_not_found_error &) = default;
|
||||
virtual ~file_not_found_error() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~file_not_found_error() noexcept {}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -54,13 +54,13 @@ namespace chaiscript
|
||||
/// \brief Thrown if an error occurs while attempting to load a binary module
|
||||
struct load_module_error : std::runtime_error
|
||||
{
|
||||
load_module_error(const std::string &t_reason) CHAISCRIPT_NOEXCEPT
|
||||
load_module_error(const std::string &t_reason) noexcept
|
||||
: std::runtime_error(t_reason)
|
||||
{
|
||||
}
|
||||
|
||||
load_module_error(const load_module_error &) = default;
|
||||
virtual ~load_module_error() CHAISCRIPT_NOEXCEPT {}
|
||||
virtual ~load_module_error() noexcept {}
|
||||
};
|
||||
}
|
||||
|
||||
@ -505,10 +505,10 @@ namespace chaiscript
|
||||
|
||||
// Let's see if this is a link that we should expand
|
||||
std::vector<char> buf(2048);
|
||||
const size_t pathlen = readlink(dllpath.c_str(), &buf.front(), buf.size());
|
||||
if (pathlen > 0 && pathlen < buf.size())
|
||||
const auto pathlen = readlink(dllpath.c_str(), &buf.front(), buf.size());
|
||||
if (pathlen > 0 && static_cast<size_t>(pathlen) < buf.size())
|
||||
{
|
||||
dllpath = std::string(&buf.front(), pathlen);
|
||||
dllpath = std::string(&buf.front(), static_cast<size_t>(pathlen));
|
||||
}
|
||||
|
||||
m_module_paths.insert(m_module_paths.begin(), dllpath+"/");
|
||||
|
@ -89,13 +89,13 @@ namespace chaiscript
|
||||
{ }
|
||||
|
||||
virtual ~Binary_Operator_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
auto lhs = this->children[0]->eval(t_ss);
|
||||
auto rhs = this->children[1]->eval(t_ss);
|
||||
return do_oper(t_ss, m_oper, text, lhs, rhs);
|
||||
}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
return "(" + this->children[0]->pretty_print() + " " + text + " " + this->children[1]->pretty_print() + ")";
|
||||
}
|
||||
@ -137,7 +137,7 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Int, std::move(t_loc)),
|
||||
m_value(std::move(t_bv)) { assert(text != ""); }
|
||||
virtual ~Int_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Float, std::move(t_loc)),
|
||||
m_value(std::move(t_bv)) { }
|
||||
virtual ~Float_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ namespace chaiscript
|
||||
{ }
|
||||
|
||||
virtual ~Id_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
if (!m_value.is_undef())
|
||||
{
|
||||
return m_value;
|
||||
@ -226,7 +226,7 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Eol, std::move(t_loc)) { }
|
||||
virtual ~Eol_AST_Node() {}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
return "\n";
|
||||
}
|
||||
@ -238,7 +238,7 @@ namespace chaiscript
|
||||
Fun_Call_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Fun_Call, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Fun_Call_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
|
||||
|
||||
std::vector<Boxed_Value> params;
|
||||
@ -278,7 +278,7 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
@ -308,7 +308,7 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Arg_List, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Arg_AST_Node() {}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
std::ostringstream oss;
|
||||
for (size_t j = 0; j < this->children.size(); ++j) {
|
||||
@ -330,7 +330,7 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Arg_List, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Arg_List_AST_Node() {}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
std::ostringstream oss;
|
||||
for (size_t j = 0; j < this->children.size(); ++j) {
|
||||
@ -401,7 +401,7 @@ namespace chaiscript
|
||||
mutable std::atomic_uint_fast32_t m_clone_loc;
|
||||
|
||||
virtual ~Equation_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
|
||||
Boxed_Value rhs = this->children[2]->eval(t_ss);
|
||||
Boxed_Value lhs = this->children[0]->eval(t_ss);
|
||||
@ -476,7 +476,7 @@ namespace chaiscript
|
||||
Global_Decl_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Global_Decl, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Global_Decl_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
|
||||
const std::string &idname =
|
||||
[&]()->const std::string &{
|
||||
@ -503,7 +503,7 @@ namespace chaiscript
|
||||
Var_Decl_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Var_Decl, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Var_Decl_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
if (this->children[0]->identifier == AST_Node_Type::Reference)
|
||||
{
|
||||
return this->children[0]->eval(t_ss);
|
||||
@ -524,7 +524,7 @@ namespace chaiscript
|
||||
|
||||
}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
return "var " + this->children[0]->text;
|
||||
}
|
||||
@ -537,7 +537,7 @@ namespace chaiscript
|
||||
Array_Call_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Array_Call, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Array_Call_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
|
||||
|
||||
std::vector<Boxed_Value> params{children[0]->eval(t_ss), children[1]->eval(t_ss)};
|
||||
@ -552,7 +552,7 @@ namespace chaiscript
|
||||
|
||||
}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << this->children[0]->pretty_print();
|
||||
@ -579,7 +579,7 @@ namespace chaiscript
|
||||
children[2]->children[0]->text:children[2]->text) { }
|
||||
|
||||
virtual ~Dot_Access_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
|
||||
|
||||
|
||||
@ -636,11 +636,11 @@ namespace chaiscript
|
||||
m_value(const_var(text)) { }
|
||||
virtual ~Quoted_String_AST_Node() {}
|
||||
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override {
|
||||
return m_value;
|
||||
}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
return "\"" + text + "\"";
|
||||
}
|
||||
@ -657,11 +657,11 @@ namespace chaiscript
|
||||
m_value(const_var(char(text.at(0)))) { }
|
||||
|
||||
virtual ~Single_Quoted_String_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
return "'" + text + "'";
|
||||
}
|
||||
@ -678,7 +678,7 @@ namespace chaiscript
|
||||
|
||||
virtual ~Lambda_AST_Node() {}
|
||||
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
|
||||
const auto captures = [&]()->std::map<std::string, Boxed_Value>{
|
||||
std::map<std::string, Boxed_Value> named_captures;
|
||||
@ -717,7 +717,7 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Block, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Block_AST_Node() {}
|
||||
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||
|
||||
const auto num_children = children.size();
|
||||
@ -735,7 +735,7 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Def, std::move(t_loc), std::move(t_children)) { }
|
||||
|
||||
virtual ~Def_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
std::vector<std::string> t_param_names;
|
||||
size_t numparams = 0;
|
||||
AST_NodePtr guardnode;
|
||||
@ -799,7 +799,7 @@ namespace chaiscript
|
||||
While_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::While, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~While_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||
|
||||
try {
|
||||
@ -825,7 +825,7 @@ namespace chaiscript
|
||||
Class_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Class, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Class_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||
|
||||
/// \todo do this better
|
||||
@ -844,7 +844,7 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::If, std::move(t_loc), std::move(t_children))
|
||||
{ assert(children.size() == 3); }
|
||||
virtual ~Ternary_Cond_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
if (get_bool_condition(children[0]->eval(t_ss))) {
|
||||
return children[1]->eval(t_ss);
|
||||
}
|
||||
@ -860,7 +860,7 @@ namespace chaiscript
|
||||
If_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::If, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~If_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
|
||||
if (get_bool_condition(children[0]->eval(t_ss))) {
|
||||
return children[1]->eval(t_ss);
|
||||
@ -893,7 +893,7 @@ namespace chaiscript
|
||||
{ assert(children.size() == 4); }
|
||||
virtual ~For_AST_Node() {}
|
||||
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||
|
||||
try {
|
||||
@ -925,7 +925,7 @@ namespace chaiscript
|
||||
Switch_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Switch, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Switch_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
bool breaking = false;
|
||||
size_t currentCase = 1;
|
||||
bool hasMatched = false;
|
||||
@ -971,7 +971,7 @@ namespace chaiscript
|
||||
{ assert(children.size() == 2); /* how many children does it have? */ }
|
||||
|
||||
virtual ~Case_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||
|
||||
children[1]->eval(t_ss);
|
||||
@ -986,7 +986,7 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Default, std::move(t_loc), std::move(t_children))
|
||||
{ assert(children.size() == 1); }
|
||||
virtual ~Default_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||
|
||||
children[0]->eval(t_ss);
|
||||
@ -1001,7 +1001,7 @@ namespace chaiscript
|
||||
Inline_Array_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Array, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Inline_Array_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
try {
|
||||
std::vector<Boxed_Value> vec;
|
||||
if (!children.empty()) {
|
||||
@ -1022,7 +1022,7 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
return "[" + AST_Node::pretty_print() + "]";
|
||||
}
|
||||
@ -1035,7 +1035,7 @@ namespace chaiscript
|
||||
Inline_Map_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Map, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Inline_Map_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
try {
|
||||
std::map<std::string, Boxed_Value> retval;
|
||||
|
||||
@ -1063,7 +1063,7 @@ namespace chaiscript
|
||||
Return_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Return, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Return_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
if (!this->children.empty()) {
|
||||
throw detail::Return_Value(children[0]->eval(t_ss));
|
||||
}
|
||||
@ -1079,7 +1079,7 @@ namespace chaiscript
|
||||
File_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::File, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~File_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
try {
|
||||
const auto num_children = children.size();
|
||||
|
||||
@ -1105,7 +1105,7 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Reference, std::move(t_loc), std::move(t_children))
|
||||
{ assert(children.size() == 1); }
|
||||
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
try {
|
||||
Boxed_Value bv;
|
||||
t_ss.add_object(this->children[0]->text, bv);
|
||||
@ -1127,7 +1127,7 @@ namespace chaiscript
|
||||
{ }
|
||||
|
||||
virtual ~Prefix_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
Boxed_Value bv(children[1]->eval(t_ss));
|
||||
|
||||
try {
|
||||
@ -1155,7 +1155,7 @@ namespace chaiscript
|
||||
Break_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Break, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Break_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
|
||||
throw detail::Break_Loop();
|
||||
}
|
||||
};
|
||||
@ -1165,7 +1165,7 @@ namespace chaiscript
|
||||
Continue_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Continue, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Continue_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
|
||||
throw detail::Continue_Loop();
|
||||
}
|
||||
};
|
||||
@ -1178,7 +1178,7 @@ namespace chaiscript
|
||||
{ }
|
||||
|
||||
virtual ~Noop_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
|
||||
// It's a no-op, that evaluates to "true"
|
||||
return m_value;
|
||||
}
|
||||
@ -1206,7 +1206,7 @@ namespace chaiscript
|
||||
Inline_Range_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Range, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Inline_Range_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
try {
|
||||
auto oper1 = children[0]->children[0]->children[0]->eval(t_ss);
|
||||
auto oper2 = children[0]->children[0]->children[1]->eval(t_ss);
|
||||
@ -1294,7 +1294,7 @@ namespace chaiscript
|
||||
return retval;
|
||||
}
|
||||
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
Boxed_Value retval;
|
||||
|
||||
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||
@ -1357,7 +1357,7 @@ namespace chaiscript
|
||||
Method_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Method, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Method_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
|
||||
AST_NodePtr guardnode;
|
||||
|
||||
@ -1448,7 +1448,7 @@ namespace chaiscript
|
||||
Attr_Decl_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Attr_Decl, std::move(t_loc), std::move(t_children)) { }
|
||||
virtual ~Attr_Decl_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override
|
||||
{
|
||||
const auto &d = t_ss->get_parent_locals();
|
||||
const auto itr = d.find("_current_class_name");
|
||||
@ -1487,12 +1487,12 @@ namespace chaiscript
|
||||
{ assert(children.size() == 3); }
|
||||
|
||||
virtual ~Logical_And_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
return const_var(get_bool_condition(children[0]->eval(t_ss))
|
||||
&& get_bool_condition(children[2]->eval(t_ss)));
|
||||
}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
return "(" + AST_Node::pretty_print() + ")";
|
||||
}
|
||||
@ -1504,12 +1504,12 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Logical_Or, std::move(t_loc), std::move(t_children))
|
||||
{ assert(children.size() == 3); }
|
||||
virtual ~Logical_Or_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
return const_var(get_bool_condition(children[0]->eval(t_ss))
|
||||
|| get_bool_condition(children[2]->eval(t_ss)));
|
||||
}
|
||||
|
||||
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE
|
||||
virtual std::string pretty_print() const override
|
||||
{
|
||||
return "(" + AST_Node::pretty_print() + ")";
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
size_t remaining() const {
|
||||
return std::distance(m_pos, m_end);
|
||||
return static_cast<size_t>(std::distance(m_pos, m_end));
|
||||
}
|
||||
|
||||
char operator*() const {
|
||||
@ -621,11 +621,11 @@ namespace chaiscript
|
||||
|
||||
if (float_)
|
||||
{
|
||||
return const_var(std::stof(t_val.substr(0,i)));
|
||||
return const_var(parse_num<float>(t_val.substr(0,i)));
|
||||
} else if (long_) {
|
||||
return const_var(std::stold(t_val.substr(0,i)));
|
||||
return const_var(parse_num<long double>(t_val.substr(0,i)));
|
||||
} else {
|
||||
return const_var(std::stod(t_val.substr(0,i)));
|
||||
return const_var(parse_num<double>(t_val.substr(0,i)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -893,8 +893,8 @@ namespace chaiscript
|
||||
in_quote = !in_quote;
|
||||
} else if (*m_position == '}' && !in_quote) {
|
||||
--in_interpolation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (prev_char == '\\') {
|
||||
prev_char = 0;
|
||||
} else {
|
||||
@ -2213,8 +2213,8 @@ namespace chaiscript
|
||||
|
||||
switch (m_operators[t_precedence]) {
|
||||
case(AST_Node_Type::Ternary_Cond) :
|
||||
m_match_stack.erase(m_match_stack.begin() + m_match_stack.size() - 2,
|
||||
m_match_stack.begin() + m_match_stack.size() - 1);
|
||||
m_match_stack.erase(advance_copy(m_match_stack.begin(), m_match_stack.size() - 2),
|
||||
advance_copy(m_match_stack.begin(), m_match_stack.size() - 1));
|
||||
if (Symbol(":")) {
|
||||
if (!Operator(t_precedence+1)) {
|
||||
throw exception::eval_error("Incomplete "
|
||||
@ -2239,7 +2239,8 @@ namespace chaiscript
|
||||
case(AST_Node_Type::Bitwise_Or) :
|
||||
case(AST_Node_Type::Comparison) :
|
||||
assert(m_match_stack.size() > 1);
|
||||
m_match_stack.erase(m_match_stack.begin() + m_match_stack.size() - 2, m_match_stack.begin() + m_match_stack.size() - 1);
|
||||
m_match_stack.erase(advance_copy(m_match_stack.begin(), m_match_stack.size() - 2),
|
||||
advance_copy(m_match_stack.begin(), m_match_stack.size() - 1));
|
||||
build_match<eval::Binary_Operator_AST_Node>(prev_stack_top, oper->text);
|
||||
break;
|
||||
|
||||
|
@ -212,16 +212,16 @@ class JSON
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
JSON( T b, typename enable_if<is_same<T,bool>::value>::type* = 0 ) : Internal( b ), Type( Class::Boolean ){}
|
||||
JSON( T b, typename enable_if<is_same<T,bool>::value>::type* = nullptr ) : Internal( b ), Type( Class::Boolean ){}
|
||||
|
||||
template <typename T>
|
||||
JSON( T i, typename enable_if<is_integral<T>::value && !is_same<T,bool>::value>::type* = 0 ) : Internal( long(i) ), Type( Class::Integral ){}
|
||||
JSON( T i, typename enable_if<is_integral<T>::value && !is_same<T,bool>::value>::type* = nullptr ) : Internal( long(i) ), Type( Class::Integral ){}
|
||||
|
||||
template <typename T>
|
||||
JSON( T f, typename enable_if<is_floating_point<T>::value>::type* = 0 ) : Internal( double(f) ), Type( Class::Floating ){}
|
||||
JSON( T f, typename enable_if<is_floating_point<T>::value>::type* = nullptr ) : Internal( double(f) ), Type( Class::Floating ){}
|
||||
|
||||
template <typename T>
|
||||
JSON( T s, typename enable_if<is_convertible<T,string>::value>::type* = 0 ) : Internal( string( s ) ), Type( Class::String ){}
|
||||
JSON( T s, typename enable_if<is_convertible<T,string>::value>::type* = nullptr ) : Internal( string( s ) ), Type( Class::String ){}
|
||||
|
||||
JSON( std::nullptr_t ) : Internal(), Type( Class::Null ){}
|
||||
|
||||
@ -605,7 +605,7 @@ namespace {
|
||||
Number = std::stod( val ) * std::pow( 10, exp );
|
||||
else {
|
||||
if( !exp_str.empty() )
|
||||
Number = std::stol( val ) * std::pow( 10, exp );
|
||||
Number = static_cast<double>(std::stol( val )) * std::pow( 10, exp );
|
||||
else
|
||||
Number = std::stol( val );
|
||||
}
|
||||
|
@ -69,11 +69,7 @@ namespace chaiscript
|
||||
typename std::enable_if<std::is_enum<Enum>::value, void>::type
|
||||
add_class(ModuleType &t_module,
|
||||
const std::string &t_class_name,
|
||||
#ifdef CHAISCRIPT_GCC_4_6
|
||||
const std::vector<std::pair<int, std::string>> &t_constants
|
||||
#else
|
||||
const std::vector<std::pair<typename std::underlying_type<Enum>::type, std::string>> &t_constants
|
||||
#endif
|
||||
)
|
||||
{
|
||||
t_module.add(chaiscript::user_type<Enum>(), t_class_name);
|
||||
@ -87,13 +83,8 @@ namespace chaiscript
|
||||
return assign<Enum>(not_equal<Enum>(equal<Enum>()));
|
||||
}());
|
||||
|
||||
#ifdef CHAISCRIPT_GCC_4_6
|
||||
t_module.add(chaiscript::fun([](const Enum &e, const int &i) { return e == i; }), "==");
|
||||
t_module.add(chaiscript::fun([](const int &i, const Enum &e) { return i == e; }), "==");
|
||||
#else
|
||||
t_module.add(chaiscript::fun([](const Enum &e, const typename std::underlying_type<Enum>::type &i) { return e == i; }), "==");
|
||||
t_module.add(chaiscript::fun([](const typename std::underlying_type<Enum>::type &i, const Enum &e) { return i == e; }), "==");
|
||||
#endif
|
||||
|
||||
for (const auto &constant : t_constants)
|
||||
{
|
||||
|
@ -1,3 +1,8 @@
|
||||
<a href="https://www.patreon.com/bePatron?u=2977989&redirect_uri=https%3A%2F%2Fwww.patreon.com%2Flefticus">
|
||||
<img height="40" width="204" src="https://s3-us-west-1.amazonaws.com/widget-images/become-patron-widget-medium%402x.png">
|
||||
</a>
|
||||
|
||||
|
||||
Master Status: [](https://travis-ci.org/ChaiScript/ChaiScript) [](https://ci.appveyor.com/project/lefticus/chaiscript) [](http://codecov.io/github/ChaiScript/ChaiScript?branch=master)
|
||||
|
||||
Develop Status: [](https://travis-ci.org/ChaiScript/ChaiScript) [](https://ci.appveyor.com/project/lefticus/chaiscript/branch/develop) [](http://codecov.io/github/ChaiScript/ChaiScript?branch=develop)
|
||||
|
@ -1,6 +1,11 @@
|
||||
Notes:
|
||||
=======
|
||||
Current Version: 5.8.0
|
||||
Current Version: 5.8.1
|
||||
|
||||
### Changes since 5.8.0
|
||||
* Fix parsing of floats to be locale independent #250
|
||||
* Various warning fixes on various platforms
|
||||
|
||||
|
||||
### Changes since 5.7.1
|
||||
* Make all parser iterator operations range checked
|
||||
|
@ -89,24 +89,24 @@ std::vector<std::string> default_search_paths()
|
||||
std::vector<char> buf(2048);
|
||||
ssize_t size = -1;
|
||||
|
||||
if ((size = readlink("/proc/self/exe", &buf.front(), buf.size())) != -1)
|
||||
if ((size = readlink("/proc/self/exe", &buf.front(), buf.size())) > 0)
|
||||
{
|
||||
exepath = std::string(&buf.front(), size);
|
||||
exepath = std::string(&buf.front(), static_cast<size_t>(size));
|
||||
}
|
||||
|
||||
if (exepath.empty())
|
||||
{
|
||||
if ((size = readlink("/proc/curproc/file", &buf.front(), buf.size())) != -1)
|
||||
if ((size = readlink("/proc/curproc/file", &buf.front(), buf.size())) > 0)
|
||||
{
|
||||
exepath = std::string(&buf.front(), size);
|
||||
exepath = std::string(&buf.front(), static_cast<size_t>(size));
|
||||
}
|
||||
}
|
||||
|
||||
if (exepath.empty())
|
||||
{
|
||||
if ((size = readlink("/proc/self/path/a.out", &buf.front(), buf.size())) != -1)
|
||||
if ((size = readlink("/proc/self/path/a.out", &buf.front(), buf.size())) > 0)
|
||||
{
|
||||
exepath = std::string(&buf.front(), size);
|
||||
exepath = std::string(&buf.front(), static_cast<size_t>(size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,14 +44,14 @@ class ChaiScriptDerived : public BaseClass
|
||||
tie(t_funcs.at(1), m_validateValueImpl);
|
||||
}
|
||||
|
||||
std::string doSomething(float f, double d) const CHAISCRIPT_OVERRIDE
|
||||
std::string doSomething(float f, double d) const override
|
||||
{
|
||||
assert(m_doSomethingImpl);
|
||||
return m_doSomethingImpl(*this, f, d);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool validateValue(const std::string &t_val) CHAISCRIPT_OVERRIDE
|
||||
bool validateValue(const std::string &t_val) override
|
||||
{
|
||||
assert(m_validateValueImpl);
|
||||
return m_validateValueImpl(*this, t_val);
|
||||
|
12
src/main.cpp
12
src/main.cpp
@ -88,24 +88,24 @@ std::vector<std::string> default_search_paths()
|
||||
std::vector<char> buf(2048);
|
||||
ssize_t size = -1;
|
||||
|
||||
if ((size = readlink("/proc/self/exe", &buf.front(), buf.size())) != -1)
|
||||
if ((size = readlink("/proc/self/exe", &buf.front(), buf.size())) >= 0)
|
||||
{
|
||||
exepath = std::string(&buf.front(), size);
|
||||
exepath = std::string(&buf.front(), static_cast<size_t>(size));
|
||||
}
|
||||
|
||||
if (exepath.empty())
|
||||
{
|
||||
if ((size = readlink("/proc/curproc/file", &buf.front(), buf.size())) != -1)
|
||||
if ((size = readlink("/proc/curproc/file", &buf.front(), buf.size())) >= 0)
|
||||
{
|
||||
exepath = std::string(&buf.front(), size);
|
||||
exepath = std::string(&buf.front(), static_cast<size_t>(size));
|
||||
}
|
||||
}
|
||||
|
||||
if (exepath.empty())
|
||||
{
|
||||
if ((size = readlink("/proc/self/path/a.out", &buf.front(), buf.size())) != -1)
|
||||
if ((size = readlink("/proc/self/path/a.out", &buf.front(), buf.size())) >= 0)
|
||||
{
|
||||
exepath = std::string(&buf.front(), size);
|
||||
exepath = std::string(&buf.front(), static_cast<size_t>(size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,17 +8,9 @@
|
||||
class TestBaseType
|
||||
{
|
||||
public:
|
||||
#ifdef CHAISCRIPT_MSVC_12
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4351)
|
||||
#endif
|
||||
// MSVC 12 warns that we are using new (correct) behavior
|
||||
TestBaseType() : val(10), const_val(15), mdarray{} { }
|
||||
TestBaseType(int) : val(10), const_val(15), mdarray{} { }
|
||||
TestBaseType(int *) : val(10), const_val(15), mdarray{} { }
|
||||
#ifdef CHAISCRIPT_MSVC_12
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
TestBaseType(const TestBaseType &) = default;
|
||||
virtual ~TestBaseType() {}
|
||||
@ -84,7 +76,7 @@ class TestDerivedType : public TestBaseType
|
||||
virtual ~TestDerivedType() {}
|
||||
TestDerivedType(const TestDerivedType &) = default;
|
||||
TestDerivedType() = default;
|
||||
virtual int func() CHAISCRIPT_OVERRIDE { return 1; }
|
||||
virtual int func() override { return 1; }
|
||||
int derived_only_func() { return 19; }
|
||||
|
||||
private:
|
||||
@ -179,16 +171,10 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_mo
|
||||
m->add(chaiscript::fun(&TestBaseType::base_only_func), "base_only_func");
|
||||
m->add(chaiscript::fun(&TestBaseType::set_string_val), "set_string_val");
|
||||
|
||||
#ifndef CHAISCRIPT_MSVC_12
|
||||
// we cannot support these in MSVC_12 because of a bug in the implementation of
|
||||
// std::reference_wrapper
|
||||
// Array types
|
||||
m->add(chaiscript::fun(&TestBaseType::mdarray), "mdarray");
|
||||
m->add(chaiscript::bootstrap::array<int[2][3][5]>("IntArray_2_3_5"));
|
||||
m->add(chaiscript::bootstrap::array<int[3][5]>("IntArray_3_5"));
|
||||
m->add(chaiscript::bootstrap::array<int[5]>("IntArray_5"));
|
||||
// end array types
|
||||
#endif
|
||||
|
||||
// member that is a function
|
||||
m->add(chaiscript::fun(&TestBaseType::func_member), "func_member");
|
||||
|
1
supporters.md
Normal file
1
supporters.md
Normal file
@ -0,0 +1 @@
|
||||
|
3223
unittests/catch.hpp
3223
unittests/catch.hpp
File diff suppressed because it is too large
Load Diff
@ -1,33 +1,31 @@
|
||||
// All of these are necessary because of catch.hpp. It's OK, they'll be
|
||||
// caught in other cpp files if chaiscript causes them
|
||||
|
||||
#include <chaiscript/utility/utility.hpp>
|
||||
#include <chaiscript/dispatchkit/bootstrap_stl.hpp>
|
||||
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4190 4640 28251 4702 6330)
|
||||
#pragma warning(disable : 4062 4242 4640 4702 6330 28251)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma GCC diagnostic ignored "-Wparentheses"
|
||||
#endif
|
||||
|
||||
#ifdef __llvm__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
|
||||
#pragma clang diagnostic ignored "-Wold-style-cast"
|
||||
#pragma clang diagnostic ignored "-Wexit-time-destructors"
|
||||
#pragma clang diagnostic ignored "-Wfloat-equal"
|
||||
#pragma clang diagnostic ignored "-Wunreachable-code"
|
||||
#endif
|
||||
|
||||
#include <chaiscript/chaiscript.hpp>
|
||||
#include <chaiscript/utility/utility.hpp>
|
||||
#include <chaiscript/dispatchkit/bootstrap_stl.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
|
||||
#include <clocale>
|
||||
|
||||
#include "catch.hpp"
|
||||
|
||||
// lambda_tests
|
||||
@ -933,7 +931,21 @@ TEST_CASE("Map conversions")
|
||||
)");
|
||||
|
||||
CHECK(c == 42);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Parse floats with non-posix locale")
|
||||
{
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
std::setlocale(LC_ALL, "en-ZA");
|
||||
#else
|
||||
std::setlocale(LC_ALL, "en_ZA.utf8");
|
||||
#endif
|
||||
chaiscript::ChaiScript chai;
|
||||
const double parsed = chai.eval<double>("print(1.3); 1.3");
|
||||
CHECK(parsed == Approx(1.3));
|
||||
const std::string str = chai.eval<std::string>("to_string(1.3)");
|
||||
CHECK(str == "1.3");
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ int expected_value(int num_iters)
|
||||
return i;
|
||||
}
|
||||
|
||||
void do_work(chaiscript::ChaiScript &c, int id)
|
||||
void do_work(chaiscript::ChaiScript &c, const size_t id)
|
||||
{
|
||||
try{
|
||||
std::stringstream ss;
|
||||
@ -67,23 +67,23 @@ int main()
|
||||
std::vector<std::shared_ptr<std::thread> > threads;
|
||||
|
||||
// Ensure at least two, but say only 7 on an 8 core processor
|
||||
int num_threads = std::max(static_cast<int>(std::thread::hardware_concurrency()) - 1, 2);
|
||||
size_t num_threads = static_cast<size_t>(std::max(static_cast<int>(std::thread::hardware_concurrency()) - 1, 2));
|
||||
|
||||
std::cout << "Num threads: " << num_threads << '\n';
|
||||
|
||||
for (int i = 0; i < num_threads; ++i)
|
||||
for (size_t i = 0; i < num_threads; ++i)
|
||||
{
|
||||
threads.push_back(std::make_shared<std::thread>(do_work, std::ref(chai), i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_threads; ++i)
|
||||
for (size_t i = 0; i < num_threads; ++i)
|
||||
{
|
||||
threads[i]->join();
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < num_threads; ++i)
|
||||
for (size_t i = 0; i < num_threads; ++i)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << i;
|
||||
@ -92,7 +92,7 @@ int main()
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (chai.eval<int>("getid(" + ss.str() + ")") != i)
|
||||
if (chai.eval<int>("getid(" + ss.str() + ")") != static_cast<int>(i))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -1,30 +1,22 @@
|
||||
// Tests to make sure that the order in which function dispatches occur is correct
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4062 4242 4640 4702 6330 28251)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma GCC diagnostic ignored "-Wparentheses"
|
||||
#endif
|
||||
|
||||
|
||||
#include <chaiscript/chaiscript_defines.hpp>
|
||||
#include <chaiscript/dispatchkit/type_info.hpp>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4190 4640 28251 4702 6330)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#endif
|
||||
|
||||
#ifdef __llvm__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
|
||||
#pragma clang diagnostic ignored "-Wold-style-cast"
|
||||
#pragma clang diagnostic ignored "-Wexit-time-destructors"
|
||||
#pragma clang diagnostic ignored "-Wfloat-equal"
|
||||
#pragma clang diagnostic ignored "-Wunreachable-code"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user