2015-06-01 16:08:04 -06:00
cmake add support for biicode 2015-03-18 19:23:04 -06:00
contrib Don't use scopes around arithmetic operators 2015-04-24 22:36:22 -06:00
include/chaiscript g++4.6 correction 2015-06-01 16:08:04 -06:00
samples Reorg of parsing code for maintainability / performance 2015-04-30 22:05:56 -06:00
src Add test, tweak coverage reporting 2015-05-20 15:04:04 -06:00
unittests Add failing non-polymorphic Derived->Base test 2015-05-20 09:48:46 -06:00
.decent_ci-Linux.yaml More catch() analysis warning cleanups 2015-04-24 14:29:15 -06:00
.decent_ci-MacOS.yaml Change to TBZ2 for MacOS packages 2015-01-17 07:09:47 -07:00
.decent_ci-Windows.yaml Remove all /analyze from VS12, it's too slow 2015-04-29 16:59:17 -06:00
.decent_ci.yaml Fix results location 2014-09-13 23:11:17 -06:00
.travis.yml Wrap up the coveralls / codecov choices 2015-05-30 18:48:27 -06:00
biicode.conf Update biicode and get master updated to v5.6.0 2015-03-19 20:03:12 -06:00
cheatsheet.md Fixed minor typos in cheatsheet 2015-05-08 15:57:59 +02:00
CMakeLists.txt Add test, tweak coverage reporting 2015-05-20 15:04:04 -06: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
Doxyfile.in Fix Doxygen configuration 2015-01-06 13:35:52 -07:00
LICENSE Create LICENSE 2015-04-01 08:07:19 -06:00
license.txt Get ready for 5.6.0 release 2015-01-17 07:05:10 -07:00
readme.md Update readme.md 2015-05-30 18:48:55 -06:00
releasenotes.md Add release notes for 5.7.0 2015-05-06 14:15:29 -06:00

Master Status: Linux Build Status Windows Build status Coverage Status

Develop Status: Linux Build Status Windows Build status Coverage Status

Coverity Scan Build Status

ChaiScript

http://www.chaiscript.com

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

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

Introduction

![Gitter](https://badges.gitter.im/Join Chat.svg)

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++11 compiler to build with support for variadic templates. It has been tested with gcc 4.6 and clang 3.1 (with libcxx). MacOS 10.8 (Mountain Lion) is also known to support the C++11 build with Apple's clang 4.0. MSVC 2013 or newer is supports also. 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 "src" 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);");
}

Or, if you want to compile the std lib into your code, which reduces runtime requirements.

/// main.cpp

#include <chaiscript/chaiscript.hpp>
#include <chaiscript/chaiscript_stdlib.hpp>

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

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

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