-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5,001 changed files
with
2,118,714 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
cmake_minimum_required(VERSION 3.11) # FetchContent requires CMake 3.11 | ||
project(chaiscript_extras) | ||
|
||
# MINGW does not yet support C++11's concurrency features | ||
if(MINGW) | ||
option(MULTITHREAD_SUPPORT_ENABLED "Multithreaded Support Enabled" FALSE) | ||
else() | ||
option(MULTITHREAD_SUPPORT_ENABLED "Multithreaded Support Enabled" TRUE) | ||
endif() | ||
|
||
option(BUILD_IN_CPP17_MODE "Build with C++17 flags" FALSE) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCC) | ||
option(ENABLE_COVERAGE "Enable Coverage Reporting in GCC" FALSE) | ||
|
||
if(ENABLE_COVERAGE) | ||
add_definitions(--coverage -O0) | ||
set(LINKER_FLAGS "${LINKER_FLAGS} --coverage") | ||
endif() | ||
endif() | ||
|
||
if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
option(ENABLE_THREAD_SANITIZER "Enable thread sanitizer testing in gcc/clang" FALSE) | ||
if(ENABLE_THREAD_SANITIZER) | ||
add_definitions(-fsanitize=thread -g) | ||
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=thread") | ||
endif() | ||
|
||
option(ENABLE_ADDRESS_SANITIZER "Enable address sanitizer testing in gcc/clang" FALSE) | ||
if(ENABLE_ADDRESS_SANITIZER) | ||
add_definitions(-fsanitize=address -g) | ||
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=address") | ||
endif() | ||
|
||
option(ENABLE_MEMORY_SANITIZER "Enable memory sanitizer testing in gcc/clang" FALSE) | ||
if(ENABLE_MEMORY_SANITIZER) | ||
add_definitions(-fsanitize=memory -g) | ||
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=memory") | ||
endif() | ||
|
||
option(ENABLE_UNDEFINED_SANITIZER "Enable undefined behavior sanitizer testing in gcc/clang" FALSE) | ||
if(ENABLE_UNDEFINED_SANITIZER) | ||
add_definitions(-fsanitize=undefined -g) | ||
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=undefined") | ||
endif() | ||
|
||
option(ENABLE_LTO "Enable Link Time Optimization" FALSE) | ||
|
||
if (ENABLE_LTO) | ||
add_definitions(-flto) | ||
set(LINKER_FLAGS "${LINKER_FLAGS} -flto") | ||
endif() | ||
|
||
option(PROFILE_GENERATE "Generate profile data" FALSE) | ||
if (PROFILE_GENERATE) | ||
add_definitions(-fprofile-generate) | ||
set(LINKER_FLAGS "${LINKER_FLAGS} -fprofile-generate") | ||
endif() | ||
|
||
option(PROFILE_USE "Use profile data" FALSE) | ||
if (PROFILE_USE) | ||
add_definitions(-fprofile-use) | ||
set(LINKER_FLAGS "${LINKER_FLAGS} -fprofile-use") | ||
endif() | ||
|
||
|
||
endif() | ||
|
||
|
||
include(CTest) | ||
enable_testing() | ||
|
||
if(CMAKE_COMPILER_IS_GNUCC) | ||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) | ||
|
||
if(GCC_VERSION VERSION_LESS 4.9) | ||
set(CPP14_FLAG "-std=c++1y") | ||
else() | ||
if (BUILD_IN_CPP17_MODE) | ||
set(CPP14_FLAG "-std=c++1z") | ||
else() | ||
set(CPP14_FLAG "-std=c++14") | ||
endif() | ||
endif() | ||
else() | ||
if (BUILD_IN_CPP17_MODE) | ||
set(CPP14_FLAG "-std=c++1z") | ||
else() | ||
set(CPP14_FLAG "-std=c++14") | ||
endif() | ||
endif() | ||
|
||
if(MSVC) | ||
add_definitions(/W4 /w44640) | ||
add_definitions(/bigobj) | ||
# Note on MSVC compiler flags. | ||
# The code base selective disables warnings as necessary when the compiler is complaining too much | ||
# about something that is perfectly valid, or there is simply no technical way around it | ||
# This particular warning, C4503 is in regards to the decorated names that MSVC generates internally. | ||
# The error did not come up until the move to C++11, but the compiler doesn't give enough information | ||
# to determine where the error is coming from, and the internet provides no real information for | ||
# 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 ${CPP14_FLAG}) | ||
|
||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
add_definitions(-Weverything -Wno-c++98-compat -Wno-documentation -Wno-switch-enum -Wno-weak-vtables -Wno-sign-conversion -Wno-missing-prototypes -Wno-padded -Wno-missing-noreturn) | ||
else() | ||
add_definitions(-Wnoexcept) | ||
endif() | ||
|
||
if(APPLE) | ||
add_definitions(-Wno-sign-compare) | ||
endif() | ||
endif() | ||
|
||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
option(USE_LIBCXX "Use clang's libcxx" TRUE) | ||
|
||
if(USE_LIBCXX) | ||
add_definitions(-stdlib=libc++) | ||
set(LINKER_FLAGS "${LINKER_FLAGS} ${CPP14_FLAG} -stdlib=libc++") | ||
else() | ||
set(LINKER_FLAGS "${LINKER_FLAGS} ${CPP14_FLAG}") | ||
endif() | ||
elseif(CMAKE_COMPILER_IS_GNUCC) | ||
set(LINKER_FLAGS "${LINKER_FLAGS} ${CPP14_FLAG}") | ||
endif() | ||
|
||
# limitations in MinGW require us to make an optimized build | ||
# for the sake of object sizes or something | ||
if(MINGW OR CYGWIN) | ||
add_definitions(-O3) | ||
endif() | ||
|
||
if(NOT MULTITHREAD_SUPPORT_ENABLED) | ||
add_definitions(-DCHAISCRIPT_NO_THREADS) | ||
endif() | ||
|
||
if(CMAKE_HOST_UNIX) | ||
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Haiku") | ||
list(APPEND LIBS "dl") | ||
endif() | ||
|
||
if(MULTITHREAD_SUPPORT_ENABLED) | ||
if(CMAKE_COMPILER_IS_GNUCC) | ||
execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE GCC_FULL_VERSION) | ||
if(GCC_FULL_VERSION MATCHES "4.8.1.*ubuntu") | ||
set(LINKER_FLAGS "${LINKER_FLAGS} -Wl,--no-as-needed -pthread") | ||
else() | ||
set(LINKER_FLAGS "${LINKER_FLAGS} -pthread") | ||
endif() | ||
else() | ||
set(LINKER_FLAGS "${LINKER_FLAGS} -pthread") | ||
endif() | ||
|
||
add_definitions(-pthread) | ||
endif() | ||
endif() | ||
|
||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}") | ||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}") | ||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAGS}") | ||
|
||
add_subdirectory(cmake) | ||
add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Copyright 2015 Jason Turner | ||
|
||
All Rights Reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Jason Turner nor the | ||
name of contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# ChaiScript Extras | ||
|
||
User contributed wrappers and modules for ChaiScript. | ||
|
||
## Modules | ||
|
||
- [Math](#math): Adds common math methods to ChaiScript. | ||
- [String ID](#string-id): String hashing with [string_id](https://github.com/foonathan/string_id) | ||
- [String](#string): Adds some extra string methods to ChaiScript strings | ||
|
||
## Math | ||
|
||
The Math module adds some standard math functions to ChaiScript. | ||
|
||
### Install | ||
``` cpp | ||
#include "chaiscript/extras/math.hpp" | ||
``` | ||
``` cpp | ||
chaiscript::ChaiScript chai; | ||
auto mathlib = chaiscript::extras::math::bootstrap(); | ||
chai.add(mathlib); | ||
``` | ||
|
||
### Usage | ||
|
||
``` chaiscript | ||
var result = cos(0.5f) | ||
``` | ||
|
||
### Options | ||
|
||
Compile with one of the following flags to enable or disable features... | ||
- `CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED` When enabled, will skip some of the advanced math functions. | ||
|
||
## String ID | ||
|
||
Adds [String ID](https://github.com/foonathan/string_id) support to ChaiScript. | ||
|
||
### Install | ||
|
||
``` cpp | ||
#include "chaiscript/extras/string_id.hpp" | ||
``` | ||
|
||
``` cpp | ||
auto string_idlib = chaiscript::extras::string_id::bootstrap(); | ||
chai.add(string_idlib); | ||
``` | ||
|
||
## String | ||
|
||
Adds various string methods to extend how strings can be used in ChaiScript: | ||
- `string::replace(string, string)` | ||
- `string::trim()` | ||
- `string::trimStart()` | ||
- `string::trimEnd()` | ||
- `string::split(string)` | ||
- `string::toLowerCase()` | ||
- `string::toUpperCase()` | ||
- `string::includes()` | ||
|
||
### Install | ||
|
||
``` cpp | ||
#include "chaiscript/extras/string_methods.hpp" | ||
``` | ||
|
||
``` cpp | ||
auto stringmethods = chaiscript::extras::string_methods::bootstrap(); | ||
chai.add(stringmethods); | ||
``` | ||
|
||
### Usage | ||
|
||
``` chaiscript | ||
var input = "Hello, World!" | ||
var output = input.replace("Hello", "Goodbye") | ||
// => "Goodbye, World!" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include(chaiscript.cmake) | ||
|
||
# TODO: Fix string_id_test. | ||
#include(foonathan_string_id.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
set(CHAISCRIPT_VERSION 5.8.6) | ||
find_package(chaiscript ${CHAISCRIPT_VERSION} QUIET) | ||
|
||
if (NOT chaiscript_FOUND) | ||
include(FetchContent) | ||
|
||
FetchContent_Declare( | ||
chaiscript | ||
GIT_REPOSITORY https://github.com/ChaiScript/ChaiScript.git | ||
GIT_TAG v${CHAISCRIPT_VERSION} | ||
) | ||
|
||
FetchContent_GetProperties(chaiscript) | ||
if (NOT chaiscript_POPULATED) | ||
set(FETCHCONTENT_QUIET NO) | ||
FetchContent_Populate(chaiscript) | ||
|
||
set(BUILD_SAMPLES OFF CACHE BOOL "" FORCE) | ||
set(BUILD_MODULES ON CACHE BOOL "" FORCE) | ||
set(BUILD_TESTING OFF CACHE BOOL "" FORCE) | ||
set(BUILD_LIBFUZZ_TESTER OFF CACHE BOOL "" FORCE) | ||
|
||
add_subdirectory(${chaiscript_SOURCE_DIR} ${chaiscript_BINARY_DIR}) | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
set(STRING_ID_VERSION 6e2e5c48ee4a3ac0c54ba505f0a573561f2979ec) | ||
find_package(foonathan_string_id 2.0.3 QUIET) | ||
|
||
if (NOT foonathan_string_id_FOUND) | ||
include(FetchContent) | ||
|
||
FetchContent_Declare( | ||
foonathan_string_id | ||
GIT_REPOSITORY https://github.com/foonathan/string_id.git | ||
GIT_TAG ${STRING_ID_VERSION} | ||
) | ||
|
||
FetchContent_GetProperties(foonathan_string_id) | ||
if (NOT foonathan_string_id_POPULATED) | ||
set(FETCHCONTENT_QUIET NO) | ||
FetchContent_Populate(foonathan_string_id) | ||
|
||
add_subdirectory(${foonathan_string_id_SOURCE_DIR} ${foonathan_string_id_BINARY_DIR}) | ||
endif() | ||
endif() |
Oops, something went wrong.