Questions tagged [chaiscript]

ChaiScript is an embeddable scripting language inspired by JavaScript. It is designed as header-only library that is directly targeted at C++.

ChaiScript describes itself as an easy to use embedded scripting language for C++. Some key features:

  • Header only; no external library is necessary, just a C++11 compiler.
  • Thread safe by default
  • Portable; tested on 32 and 64 bit Windows, clang++ and g++
  • BSD licensed

More info:

A tiny example:

#include <chaiscript/chaiscript.hpp>

std::string helloWorld(const std::string &t_name)
{
  return "Hello " + t_name + "!";
}

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

  chai.eval("puts(helloWorld(\"Bob\"));");
}
48 questions
1
vote
0 answers

How to use templates with ChaiScript

I'm working on a game engine, and I'm working on adding scripting to it using ChaiScript. In my engine, I have a simple Entity Component System that uses templates. It has a struct for each object, and then structures for different components. Each…
veridis_quo_t
  • 342
  • 3
  • 14
1
vote
1 answer

exposing nonstatic member function of class to chaiscript

I have a project that tries to implement keyboard macro scripting with chaiscript. I am writing a class based on xlib to wrap the xlib code. I have a member function to add a modifier key to an ignored list, because of a xlib quirk. how could i do…
1
vote
1 answer

Passing a C++ Object to a ChaiScript Function

I am trying to pass a custom c++ object reference to a simple chai script so that the chai script can eventually read/access/call public variables & methods. I'm not certain if this is even possible, nor if once it is passed inside of the chai…
Rick
  • 97
  • 1
  • 8
1
vote
1 answer

Documentation about AppScript and ModScript (Serena)

I'm currently working for a bank as an analyst developper. The bank uses SBM from Serena (recently buy back by Micro Focus). The problem is that the scripts are coded in AppScript (VBScript 4.0) and in ModScript (ChaiScript/C++) and I can't find any…
1
vote
0 answers

What is the C++ performance monitoring tool being refered to in the following cppcon video?

What is the name of the performance monitoring tool being referenced in this talk: https://youtu.be/uzF4u9KgUWI?t=50m11s?
Greg
  • 8,175
  • 16
  • 72
  • 125
1
vote
1 answer

Error: "Can not find object: use"

I am currently using ChaiScript version 6.0.0 and Visual Studio 2017. In my C++, I am retrieving a reference to a function on_init() from a script file, and executing it. The ChaiScript object was constructed with the default/empty constructor. …
1
vote
1 answer

How call a constructor with std::initializer_list of a user type in ChaiScript?

I have the next definition class: class MyType { public: MyType(); MyType(int x); MyType(std::initializer_list list); } I register my custom class and its constructors in ChaiScript v6.0.0 as…
chema989
  • 3,962
  • 2
  • 20
  • 33
1
vote
1 answer

Move semantics and std::unique_ptr in chaiscript

How can I register a method that relies on move semantics and std::unique_ptr with chaiscript's engine? Here's an example piece of code I cannot get to work using chaiscript 5.8.5 : class Element; class MyClass { public: void…
Dalzhim
  • 1,970
  • 1
  • 17
  • 34
1
vote
1 answer

Recommendations for returning const char * as a string value using chaiscript?

Running into a very odd challenge with Chaiscript today, I'm sure it's lack of understanding but I haven't been able to resolve it yet. Hoped lefticus or others could shed some light on it. When my C++ class returns a "const char *" calling that…
OldSchool
  • 152
  • 9
1
vote
2 answers

Can chaiscript string split like lua?

I am porting lua to chaiscript. The original lua code uses split: function string:split(delimiter) local result = { } local from = 1 local delim_from, delim_to = string.find( self, delimiter, from ) while delim_from do …
Kokoas
  • 9
  • 3
1
vote
1 answer

ChaiScript: loading preprocessed script file from memory

In ChaiScript, there is a .use() function which takes a file path and loads the file and makes every function and variable available in the script. This is great functionality if you want a file from disk, however I'm looking to do the same but from…
Tobias
  • 924
  • 9
  • 23
1
vote
1 answer

Coroutines or Stateful/resumable tasks with Chaiscript

I would like to use Chaiscript to let users of my application implement tasks or stateful algorithms by using a scripting language. These algorithms "depend on events during time". In other words, the algorithms, which are scheduled by the…
Martin
  • 9,089
  • 11
  • 52
  • 87
1
vote
3 answers

C++11 std::function: Binding a method without a particular instance

Continuing this thread I'd like to split it off into another more specific question. I want to bind a function using ChaiScript, and I can do that using std::function, but I can't seem to let std::function know which overload it should…
Ilija Boshkov
  • 149
  • 2
  • 10
0
votes
0 answers

Is it possible to generate C++ code from a ChaiScript snippet?

I have a bunch of simple ChaiScript snippets that I want to run in an very resource-limited embedded context without heap memory. I cannot afford the ChaiScript engine. The snippets are guaranteed to contain only basic expressions like arithemtic…
Richard W
  • 631
  • 4
  • 15
0
votes
1 answer

chaiscript returning user defined type in script function

For the following code: #include struct Str {}; Str cppfun() { return Str{}; } int main() { chaiscript::ChaiScript chai; chai.add(chaiscript::fun(&cppfun), "cppfun"); chai.eval(R"( def MyFun() {…
Wei Li
  • 1,847
  • 2
  • 10
  • 10