Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Embedded Scripting Language Designed for C++

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
license.txt
NotificationsYou must be signed in to change notification settings

ChaiScript/ChaiScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Master Status:Linux Build StatusWindows Build statuscodecov.io

Develop Status:Linux Build StatusWindows Build statuscodecov.io

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 theground up to directly target C++ and take advantage of modern C++ developmenttechniques, working with the developer how they would expect it to work. Being anative C++ application, it has some advantages over existing embedded scriptinglanguages:

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

Requirements

ChaiScript requires a C++17 compiler to build with support for variadictemplates. It has been tested with gcc 7 and clang 6 (with libcxx).

Installation using vcpkg

You can download and install ChaiScript using thevcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.gitcd vcpkg./bootstrap-vcpkg.sh./vcpkg integrate installvcpkg install chaiscript

The ChaiScript port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, pleasecreate an issue or pull request on the vcpkg repository.

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 anew engine with the namechai like so:chaiscript::ChaiScript chai
  • The default behavior is to load the ChaiScript standard library from aloadable 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. Youhave two main options for processing ChaiScript source: a line at a time usingchai.eval(string) and a file at a time usingchai.eval_file(fname)

To make functions in your C++ code visible to scripts, they must be registeredwith 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 somemodifications 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 everypossible way of working with the library. For further documentation generatethe doxygen documentation in the build folder or see the websitehttp://www.chaiscript.com.

The shortest complete example possible follows:

/// main.cpp#include<chaiscript/chaiscript.hpp>doublefunction(int i,double j){return i * j;}intmain(){  chaiscript::ChaiScript chai;  chai.add(chaiscript::fun(&function),"function");double d = chai.eval<double>("function(3, 4.75);");}

About

Embedded Scripting Language Designed for C++

Topics

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
license.txt

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors62

Languages


[8]ページ先頭

©2009-2025 Movatter.jp