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
15
votes
1 answer

Clang linking with a .so file

I keep getting ld: library not found for -lchaiscript_stdlib-5.3.1.so clang: error: linker command failed with exit code 1 (use -v to see invocation) When trying to link to a .so file. I'm using this command: clang++ Main.cpp -o foo -L./…
user245019
4
votes
1 answer

Is it possible to use custom c++ classes with overloaded operators in QtScript?

Does anyone know if it is possible to have a C++ class with overloaded operators such as +,-,* and declare it somehow (this is where the magic happens) to a QtScriptEngine such that js-expressions like "a+b" are evaluated as they would be on the C++…
FFox
  • 1,550
  • 2
  • 17
  • 26
4
votes
1 answer

Is it possible to add breakpoints to a ChaiScript execution?

Does ChaiScript support debugger-like behavior? For instance, can I set breakpoints at which should the execution pause, and allow me to inspect the stack before resuming? If so, how?
Tomáš M.
  • 752
  • 7
  • 24
3
votes
2 answers

How do I access members of a type defined in a script?

I am trying to access from C++ file members from a type I defined in a script. The problem is that Boxed_Value::get_attr always return a null value. Here is my C++ file: #include #include int main() { …
nounoursheureux
  • 167
  • 2
  • 11
3
votes
2 answers

compare std::wstring type and represent of wstring literal in ChaiScript

I want to write ChaiScript code using std::wstring type like below c++ code. #include int testfunc(std::wstring s, std::wstring t) { if(s==t) { std::cout << "1" << std::endl; } if(s[1]==t[1]) { …
marunguy
  • 91
  • 2
3
votes
2 answers

Chaiscript #include statement mapping in biicode.conf

I want to create a biicode block that depends on the chaiscript block (lefticus/ChaiScript). If I include the chaiscript headers this way #include bii find works fine. But I would like to include them…
Florian
  • 105
  • 1
  • 6
3
votes
1 answer

Evaluate chaiscript file within a chaiscript file

I'm starting to learn chaiscript and couldn't find this in the documentation. I know there is API to evaluate a chaiscript file from C++ by calling ChaiScript::eval_file But is it possible to do the same from a chaiscript file?
user3750790
  • 63
  • 1
  • 3
2
votes
1 answer

Return more than one value in ChaiScript?

In Lua it's possible to return more than one value, For example: function math.pos(x1, y1, x2, y2) return x2 - x1, y2 - y1 end distanceX, distanceY = math.pos(100, 100, 300, 300) --> distanceX = 0, distanceY = 0 Can I do something like this in…
Rabios
  • 77
  • 1
  • 7
2
votes
2 answers

Temporarily Disable Compile Warnings in Visual Studio for Includes

I'm running Visual Studio 2017. I'm trying to add a Scripting Language called ChaiScript to my project, but it generates A LOT of warnings when I have /Wall on, and I also have treat warnings as errors on (I prefer this to stay like this). So I…
Rick
  • 353
  • 1
  • 16
2
votes
1 answer

Can I parse/compile a ChaiScript script once and invoke it many times?

I'm trying to determine whether I can use ChaiScript but so far I'm very concerned that there doesn't seem to be a way to compile a script to use later. This would be a problem if a script has to be called hundreds of times per second, for…
David
  • 5,991
  • 5
  • 33
  • 39
2
votes
1 answer

How can I check if a function is defined in the chaiscript and how can I execute it with typed arguments?

I just discovered chaiscript and I like it a lot. Now I want to add support for my very simple opengl 3d engine. I have C++ math-classes: vec2T, vec3T, vec4T, mat2T, mat3T, mat4T, ... (they are actually template classes and there are typedefs that…
scippie
  • 2,011
  • 1
  • 26
  • 42
2
votes
1 answer

std::wstring in ChaiScript

I am a beginner for ChaiScript. I try to use std::wstring type in ChaiScript. std::string type is works well. #include #include #include int main() { …
marunguy
  • 91
  • 2
2
votes
1 answer

ChaiScript and STL

I am trying to use a std::list (arnAddr being a custom Struct) in a Chai scriptfile. But I get an error during parsing : Error: "Missing clone or copy constructor for right hand side of equation" With parameters:…
0xfee1dead
  • 116
  • 1
  • 8
2
votes
0 answers

How to expose C++ Code to another scripting language

Background: I have C++ DLL's which are part of a web application. I'm in the position where the UI, which is invoking parts of my code is under development and the C++ code is being developed as well. This creates a lot of integration issues. In…
qballer
  • 2,033
  • 2
  • 22
  • 40
1
vote
2 answers

Compiling Chaiscript with i686-w64-mingw32-g++ fails

I am trying to compile a simple chaiscript example for windows from Linux using the i686-w64-mingw32-g++ compiler. I have already gotten it to work with g++, but when compiling my app using the command i686-w64-mingw32-g++ ./main.cpp -pthread…
JSGuy
  • 76
  • 8
1
2 3 4