Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 06 21:19
  • Feb 23 14:09
    Build #910 passed
  • Feb 23 14:09
    Build #910 passed
  • Feb 22 21:19
    Build #909 passed
  • Feb 22 21:19
    Build #909 passed
  • Sep 02 2021 17:24
    Build #908 passed
  • Sep 02 2021 17:24
    Build #908 passed
  • Sep 02 2021 12:25
    Build #907 passed
  • Sep 02 2021 12:25
    Build #907 passed
  • Aug 19 2021 20:06
    Build #906 passed
  • Aug 19 2021 20:06
    Build #906 passed
  • Aug 19 2021 20:00
    Build #905 passed
  • Aug 19 2021 20:00
    Build #905 passed
  • Jul 28 2021 14:10
    Build #904 passed
  • Jul 28 2021 14:10
    Build #904 passed
  • Jul 08 2021 23:59
    Build #903 passed
  • Jul 08 2021 23:59
    Build #903 passed
  • Jul 08 2021 17:04
    Build #902 passed
  • Jul 08 2021 17:04
    Build #902 passed
  • Jun 18 2021 14:53
    Build #901 passed
vocaviking
@vocaviking
@0xd800 Going by the documentation, t_bv has to be constant! See: chai.add_global_const(chaiscript::const_var(somevar), "somevar"); // global const. Throws if value is non-const, throws if object exists
I haven't checked the internals, but I think constness is required because ChaiScript does some performance optimization on these variables, which it cannot do if you want the value to change during evaluation...
vocaviking
@vocaviking
@curtiplas ChaiScript supports some string functions via the Extras library However, it probably not enough for the average string tasks. You will need to either hook up the STL into ChaiScript, or write your own functions.
alanyangbo
@alanyangbo
Translate chai into c++
zhanglistar
@zhanglistar
hi there
first time to hear chaiscript
do u guys know to use chaiscript ?
compare to lua ?
Rob Loach
@RobLoach
I use ChaiScript. It's slower than Lua, but I find it easier to use and more powerful.
GrahamAsher
@GrahamAsher
ChaiScript is now an integral part of CartoType's data import system. I wrote some brief notes here to help people use it: http://www.cartotype.com/developers/documentation/125-notes-on-chaiscript. And there are some useful links here (in the section Notes on ChaiScript): http://www.cartotype.com/developers/documentation .
smalldy
@Smalldy
do I have a shell tool like python or lua that can type some var and print it ?
Rico P
@RicoP
Hi there. I wanted to ask how do I correctly reset the state of chai? I want to execute a script several times and have always clean slate global namespace. I try the following but executing the script twice will raise a exception because x is already declared
static std::string chai_message = "";
static chaiscript::ChaiScript::State default_state;

void ros_print(const std::string &s) { chai_message = s; }

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

ChaiSystem::ChaiSystem() : chai(nullptr) {}

void ChaiSystem::initialize() {
  chai = new chaiscript::ChaiScript();
  chai->add(chaiscript::fun(&helloWorld), "helloWorld");
  chai->add(chaiscript::fun(&ros_print), "ros_print");
  default_state = chai->get_state();
}

void ChaiSystem::execute() {
  static char script[16 * 1024] = "var x= 1\nros_print(helloWorld(\" Bob \"));";

    try {
      chai->set_state(default_state);

      chai->eval(script);
    } catch (chaiscript::exception::eval_error &ee) {
      chai_message = "Error: " + ee.reason;
      throw;
    } catch (...) {
      chai_message = "Unknown Error: ";
    }
}
chai->set_state(default_state) doesn't seem to reset my global state
I am on version 6.1. revision ac0d7ce. The master branch currently doesnt compile with VS2019
Jean-André Santoni
@kivutar

Hi, I'm trying to do a double map like this:

        this.anims = [
            "stand": [
                "left": Animation(love.graphics.newImage("assets/bomberman_stand_left.png"), 24, 24, 0.2f),
                "right": Animation(love.graphics.newImage("assets/bomberman_stand_right.png"), 24, 24, 0.2f),
                "up": Animation(love.graphics.newImage("assets/bomberman_stand_up.png"), 24, 24, 0.2f),
                "down": Animation(love.graphics.newImage("assets/bomberman_stand_down.png"), 24, 24, 0.2f)
            ],
            "walk": [
                "left": Animation(love.graphics.newImage("assets/bomberman_walk_left.png"), 24, 24, 0.2f),
                "right": Animation(love.graphics.newImage("assets/bomberman_walk_right.png"), 24, 24, 0.2f),
                "up": Animation(love.graphics.newImage("assets/bomberman_walk_up.png"), 24, 24, 0.2f),
                "down": Animation(love.graphics.newImage("assets/bomberman_walk_down.png"), 24, 24, 0.2f)
            ]
        ]

        this.anim = this.anims[this.stance][this.direction]

But I'm getting this error: Error: "Missing clone or copy constructor for right hand side of equation" With parameters: (Image)

Jean-André Santoni
@kivutar
Ok, I had to do this.anim := this.anims[this.stance][this.direction] with the reference assignment
Adam Brown
@Wavesonics
I've got a frustrating crash I can't figure out. I have a chai script that loops, accepting input from the user. It uses that input as a script name, to load and run another script, and get a return code back. Some times it's the int return code, and some times it's a string that the user entered in the 2nd script?!
that var status is some times an int, and some times a string, and it should always be an int
run() is a C++ function that always returns an int, and internally does an eval() on a script
var running = true;
while(running)
{
    printRaw("/");
    var line = readLine();
    if(line == "exit")
    {
        running = false;
        print("Good bye.");
    }
    else
    {
        var status = run(line);
        print(status);
        if(status == 0)
        {
            print("Success");
        }
        else
        {
            print("Program returned error");
        }
    }
}
int ChaiOs::run(const string& path)
{
    if(fileExists(path))
    {
        try
        {
            auto script = loadScript(path);
            int r = chai.eval<int>(script);

            return r;
        }
        catch(chaiscript::exception::eval_error& e)
        {
            cout << "eval_error: " << endl << e.pretty_print();
            return 1;
        }
        catch(chaiscript::exception::bad_boxed_cast& e)
        {
            cout << "bad_boxed_cast" << endl << e.what();
            return 1;
        }
    }
    else
    {
        cout << "Program not found" << endl;
        return 1;
    }
}
Adam Brown
@Wavesonics
here's the test script it's loading:
printRaw("Test Program, type something:");

var input = readLine();
print("You entered: " + input);

return 0;
Pat Callahan
@callahanp
hmm.just ran into chaiscript for the first time.
Douglas Tinkham
@dtinkham_gitlab
Just ran across this. If I have a c++ app, for example a Qt gui app, I could have a text control where users write chaiscript code (or opens existing chaiscript files) that calls my C++ functions inside my app. Is this correct?
jhihn
@jhihn
@dtinkham_gitlab , why would you do that when Qt already has a JS engine?
or, PyQt (or PySide2)
Douglas Tinkham
@dtinkham_gitlab
Why? Because I didn't know qt had js or pyqt that would do such things. I'll have a look.
Daniel Brunner
@0xFEEDC0DE64
Hi, I am trying to embed chaiscript in a small microcontroller (ESP32) and I have problems while compiling
I do not have rtti, there is simply not enough space on the flash
Can I use ChaiScript without all the dynamic_casts all over the place?
Ambrase
@Ambrase
Hello, I'm working on an app where users provide a script function that is executed with objects that I get from my infrastructure. Can I limit the execution time of the user's script and its memory consumption? I assume for the memory limit I can override STL in ChaiScript with a custom allocator. But I have no idea about the execution time limit. Is it possible? Thanks
Branimir Malesevic
@penumbra23

Hi all!

I have a question regarding the chai embedded interpreter in C++. Is there any kind of environment/isolation/sandbox (milion of names) while doing eval so that the objects/variables/functions declared inside the script reside only in the environment?

Example would be

auto script = R("
hp = 10";
def attack() { hp -= 5; }
");

chai.eval(script, env1);
chai.eval(script, env2);

chai.eval("attack()", env1);

assert.true(env1["hp"], 5);
assert.true(env2["hp"], 10);
Tony
@DigDyn
Is chaiscript dead? -- Seems no new version for 2 1/2 years.
Tony
@DigDyn
Seems even more dead, if my question gets no response in a month.
linweiyang
@linweiyang
Does anyone know how to compile the chai script file to be another file to protect programmers’ code.
Does anyone know how to compile the chai script file to be another file to protect programmers’ code?
Patrick Mulder
@mulderp
hello, i was wondering how to pass a map from chaiscript language to a c++ function
AI-Messiah
@AI-Messiah
How do I pass a Chaiscript vector to and from my C++ classes and functions
daneldanel
@daneldanel
Hi
6.1.0 is compatible with c++17 from VS2019?
A default console project in VS2019, append #include "chaiscript/chaiscript.hpp" in the main.cpp and build
the result: many warnings
Rebuild started...
1>------ Rebuild All started: Project: test_chai, Configuration: Debug Win32 ------
1>test_chai.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(2575,23): warning C4244: 'argument': conversion from 'const wchar_t' to 'const _Elem', possible loss of data
1> with
1> [
1> _Elem=char
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(2586): message : see reference to function template instantiation 'void std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Construct<const wchar_t*>(_Iter,const _Iter,std::input_iterator_tag)' being compiled
1> with
1> [
1> _Iter=const wchar_t
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(2586): message : see reference to function template instantiation 'void std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Construct<const wchar_t
>(_Iter,const _Iter,std::input_iterator_tag)' being compiled
1> with
1> [
1> _Iter=const wchar_t
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(2566): message : see reference to function template instantiation 'void std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Construct<const wchar_t
>(const _Iter,const _Iter,std::forward_iterator_tag)' being compiled
1> with
1> [
1> _Iter=const wchar_t
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(2566): message : see reference to function template instantiation 'void std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Construct<const wchar_t
>(const _Iter,const _Iter,std::forward_iterator_tag)' being compiled
1> with
1> [
1> _Iter=const wchar_t *
1> ]
1>D:\work\src\3rdparty\ChaiScript-6.1.0\include\chaiscript\language\chaiscript_windows.hpp(36): message : see reference to function template instantiation 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string<std::_String_const_iterator<std::_String_val<std::_Simple_types<_Elem>>>,0>(_Iter,_Iter,const _Alloc &)' being compiled
1> with
1> [
1> _Elem=wchar_t,
1> _Iter=std::_String_const_iterator<std::_String_val<std::_Simple_types<wchar_t>>>,
1> _Alloc=std::allocator<char>
1> ]
1>D:\work\src\3rdparty\ChaiScript-6.1.0\include\chaiscript\language\chaiscript_windows.hpp(36): message : see reference to function template instantiation 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string<std::_String_const_iterator<std::_String_val<std::_Simple_types<_Elem>>>,0>(_Iter,_Iter,const _Alloc &)' being compiled
1> with
1> [
1> _Elem=wchar_t,
1> _Iter=std::_String_const_iterator<std::_String_val<std::_Simple_types<wchar_t>>>,
1> _Alloc=std::allocator<char>
1> ]
1>D:\work\src\3rdparty\ChaiScript-6.1.0\include\chaiscript\language\chaiscript_windows.hpp(78): message : see reference to function template instantiation 'std::string chaiscript::detail::Loadable_Module::to_string<std::wstring>(const T &)' being compiled
1> with
1> [
1> T=std::wstring
1> ]
1>test_chai.vcxproj -> D:\work\src\test\test_chai\Debug\test_chai.exe
1>Done building project "test_chai.vcxproj".
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
the code is dummy:

include "chaiscript/chaiscript.hpp"

include <iostream>

int main()
{
std::cout << "Hello World!\n";
}
daneldanel
@daneldanel
for me, default settings must be with Warning Level: Level4 (/W4) and Threat Warnings as Error: true
so, the dummy project will never compile
daneldanel
@daneldanel
the problem is in static std::string get_error_message(DWORD t_err) if defined UNICODE