Alek Mosingiewicz d880d46214 Type cast fix.
2018-05-22 16:23:22 +02:00
.github Create CONTRIBUTING.md 2016-02-23 14:08:22 -07:00
cmake Prep for moving to Catch2 official test parsing 2018-02-19 11:34:16 -07:00
contrib Remove outdated vim support 2017-11-30 10:19:56 -07:00
include/chaiscript Type cast fix. 2018-05-22 16:23:22 +02:00
performance_tests Add slow test for creating variables 2017-11-21 07:12:17 -07:00
samples Upgrade samples where it improves readability 2017-09-14 17:41:11 +02:00
src Fix some new clang related warnings 2018-05-08 10:05:10 -06:00
static_libs Cleanups and split up into _basic options 2016-08-27 10:33:44 -06:00
unittests Merge branch 'develop' into handle-bom-in-script 2018-05-22 05:00:41 +02:00
.buckconfig * Added Buck build 2017-03-08 19:47:07 +00:00
.clang-format Formatting updates 2017-12-16 10:21:02 -07:00
.decent_ci-Linux.yaml Remove g++ 4.8 from builds 2016-03-10 14:06:43 -07:00
.decent_ci-MacOS.yaml Move debug over to windows build 2016-03-05 12:04:30 -07:00
.decent_ci-Windows.yaml Merge branch 'develop' into update_travis_toolchain 2016-03-05 21:12:14 -07:00
.decent_ci.yaml Fix results location 2014-09-13 23:11:17 -06:00
.gitignore * Added Buck build 2017-03-08 19:47:07 +00:00
.travis.yml Remove DYNLIB disabled build for linux from travis 2018-02-02 22:19:31 -07:00
appveyor.yml Attempt to add visual studio 2017 to appveyor 2017-05-31 14:56:51 -06:00
biicode.conf Update biicode and get master updated to v5.6.0 2015-03-19 20:03:12 -06:00
BUCK * Added Buckaroo.pm package 2017-07-21 11:09:53 +01:00
buckaroo.json * Added Buckaroo.pm package 2017-07-21 11:09:53 +01:00
cheatsheet.md docs: Add Switch Statement example 2018-05-09 19:18:34 -04:00
CMakeLists.txt Prep for moving to Catch2 official test parsing 2018-02-19 11:34:16 -07:00
description.txt Get cpack working for source and deb distribtions. Still need to check nsis and rpm 2010-03-29 15:32:20 +00:00
DesignGoals.md Create DesignGoals.md 2016-06-28 10:34:30 -06:00
Doxyfile.in Fix Doxygen configuration 2015-01-06 13:35:52 -07:00
LICENSE Update copyrights 2016-02-14 20:04:17 -07:00
license.txt Update copyrights 2016-02-14 20:04:17 -07:00
readme.md Fix link in readme 2017-10-21 15:14:27 -07:00
releasenotes.md Update release notes for 6.0.0 2017-02-22 15:33:42 -07:00
supporters.md Create supporters.md 2016-03-05 18:32:44 -07:00

Master Status: Linux Build Status Windows Build status codecov.io

Develop Status: Linux Build Status Windows Build status codecov.io

Coverity Scan Build Status

ChaiScript

http://www.chaiscript.com

(c) 2009-2012 Jonathan Turner (c) 2009-2017 Jason Turner

Release under the BSD license, see "license.txt" for details.

Introduction

Gitter

ChaiScript is one of the only embedded scripting language designed from the ground up to directly target C++ and take advantage of modern C++ development techniques, working with the developer like he expects it to work. Being a native C++ application, it has some advantages over existing embedded scripting languages:

  1. It uses a header-only approach, which makes it easy to integrate with existing projects.
  2. It maintains type safety between your C++ application and the user scripts.
  3. It supports a variety of C++ techniques including callbacks, overloaded functions, class methods, and stl containers.

Requirements

ChaiScript requires a C++14 compiler to build with support for variadic templates. It has been tested with gcc 4.9 and clang 3.6 (with libcxx). For more information see the build dashboard.

Usage

  • Add the ChaiScript include directory to your project's header search path
  • Add #include <chaiscript/chaiscript.hpp> to your source file
  • Instantiate the ChaiScript engine in your application. For example, create a new engine with the name chai like so: chaiscript::ChaiScript chai
  • The default behavior is to load the ChaiScript standard library from a loadable module. A second option is to compile the library into your code, see below for an example.

Once instantiated, the engine is ready to start running ChaiScript source. You have two main options for processing ChaiScript source: a line at a time using chai.eval(string) and a file at a time using chai.eval_file(fname)

To make functions in your C++ code visible to scripts, they must be registered with the scripting engine. To do so, call add:

chai.add(chaiscript::fun(&my_function), "my_function_name");

Once registered the function will be visible to scripts as "my_function_name"

Examples

ChaiScript is similar to ECMAScript (aka JavaScript(tm)), but with some modifications to make it easier to use. For usage examples see the "samples" directory, and for more in-depth look at the language, the unit tests in the "unittests" directory cover the most ground.

For examples of how to register parts of your C++ application, see "example.cpp" in the "samples" directory. Example.cpp is verbose and shows every possible way of working with the library. For further documentation generate the doxygen documentation in the build folder or see the website http://www.chaiscript.com.

The shortest complete example possible follows:

/// main.cpp

#include <chaiscript/chaiscript.hpp>

double function(int i, double j)
{
  return i * j;
}

int main()
{
  chaiscript::ChaiScript chai;
  chai.add(chaiscript::fun(&function), "function");

  double d = chai.eval<double>("function(3, 4.75);");
}