These are chat archives for ChaiScript/ChaiScript

29th
Mar 2017
Akilan Elango
@aki237
Mar 29 2017 06:34
guys i'm new here. i want to embed chai script in my prj. I get a huge error : https://paste.fedoraproject.org/paste/LIBmxYK0KN7gJ28rFndH1l5M1UNdIGYhyRLivL9gydE=
Akilan Elango
@aki237
Mar 29 2017 11:51
I checked the issues. But ChaiScript/ChaiScript#267 didnt help me.
g++ (GCC) 6.3.1 20170306
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
branch : tag v 6.0.0
David Marchbanks
@ptdave20
Mar 29 2017 12:09
What version of c++ are you compiling with?
Akilan Elango
@aki237
Mar 29 2017 12:10
c++14
David Marchbanks
@ptdave20
Mar 29 2017 12:10
What about your build flags?
Akilan Elango
@aki237
Mar 29 2017 12:14
-ldl -pthread -std=c++11 -I./external/ChaiScript/ -g -Wall -O3 -pg
and numerous other include dirs.
David Marchbanks
@ptdave20
Mar 29 2017 12:15
Your build flags say c++11 not 14.
I don't know if that's the problem, but give that a try
Akilan Elango
@aki237
Mar 29 2017 12:16
sorry that should be 14... typo here.
David Marchbanks
@ptdave20
Mar 29 2017 12:18
I'll take a closer look when I get into my office. About a half hour ish
Akilan Elango
@aki237
Mar 29 2017 12:19
sure thanks.
David Marchbanks
@ptdave20
Mar 29 2017 13:14
can you post your main?
Akilan Elango
@aki237
Mar 29 2017 13:15
Wait
This message was deleted
#include <FL/Fl.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Double_Window.H>
#include <FL/x.H>
#include <FL/Fl_Button.H>
#include <fstream>
#include "Const.hpp"
#include "chaiscript/chaiscript.hpp"
#include "TextView.hpp"
#include "Manager.hpp"


void msgout(std::string &a) {
    std::cout << a << std::endl;
}

std::string readScript(std::string filename) {
    std::string line, text;
    std::ifstream f(filename);
    if (!f.is_open()) {
    std::cout << "Unable to open the file" << std::endl;
    return "";
    }
    while ( std::getline(f, line) ) {
    text += line + '\n';
    }
    f.close();
    return text;
}

void setupChai(chaiscript::ChaiScript* chai) {
    chai->add(chaiscript::user_type<Manager>(), "Manager");
    chai->add(chaiscript::constructor<Manager()>(), "Manager");
    chai->add(chaiscript::fun(&Manager::insertChar), "insertChar");
    chai->add(chaiscript::fun(&Manager::insertText), "insertText");
    chai->add(chaiscript::fun(&Manager::insertStdString), "insertStdString");
    chai->add(chaiscript::fun(&Manager::bkspcChar), "bkspcChar");
    chai->add(chaiscript::fun(&Manager::deleteChar), "deleteChar");
    chai->add(chaiscript::fun(&Manager::cursorUp), "cursorUp");
    chai->add(chaiscript::fun(&Manager::cursorDown), "cursorDown");
    chai->add(chaiscript::fun(&Manager::cursorLeft), "cursorLeft");
    chai->add(chaiscript::fun(&Manager::cursorRight), "cursorRight");
    chai->add(chaiscript::fun(&Manager::cursorBeginLine), "cursorBeginLine");
    chai->add(chaiscript::fun(&Manager::cursorEndLine), "cursorEndLine");
    chai->add(chaiscript::fun(&Manager::cursorBeginBuffer), "cursorBeginBuffer");
    chai->add(chaiscript::fun(&Manager::cursorEndBuffer), "cursorEndBuffer");
    chai->add(chaiscript::fun(&Manager::getCursorPosX), "getCursorPosX");
    chai->add(chaiscript::fun(&Manager::getCursorPosY), "getCursorPosY");
    chai->add(chaiscript::fun(&Manager::getTop), "getTop");
    chai->add(chaiscript::fun(&Manager::selectionStart), "selectionStart");
    chai->add(chaiscript::fun(&Manager::selectionCancel), "selectionCancel");
    chai->add(chaiscript::fun(&Manager::getSelectionStartY), "getSelectionStartY");
    chai->add(chaiscript::fun(&Manager::getSelectionStartY), "getSelectionStartY");
    chai->add(chaiscript::fun(&msgout), "msgout");
}

int main(int argc, char **argv) {
    if ( argc < 2 ) {
    return 2;
    }
    Fl_Double_Window* win     = (Fl_Double_Window *) 0;
    TextView*         canvas  = (TextView *) 0;
    Manager m(argv[1]);
    chaiscript::ChaiScript* chai;
    setupChai(&chai);
    chai.eval("msgout(\"Hello from Tide\");");
    win = new Fl_Double_Window(WINDOW_WIDTH, WINDOW_HEIGHT);
    win->begin();
    canvas  = new TextView(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, m);
    win->end();
    canvas->box(FL_FLAT_BOX);

    win->resizable(canvas);
    win->label("Tide Editor");
    win->show(argc, argv);

    return Fl::run();
}
Am I doing something wrong? (Manager class is in another file)
David Marchbanks
@ptdave20
Mar 29 2017 13:22
hmmm, I don't notice anything wrong other than maybe your chai pointer doesn't appear to be initialized, but that would give you an error when you ran, not compiled
maybe that would help
uses sfml, boost, and chai
Akilan Elango
@aki237
Mar 29 2017 13:22
ya thats what I was thinking... When I saw the json.hpp I didn't see any errors.
Jason Turner
@lefticus
Mar 29 2017 21:21
You should start with the minimal example and make sure you can compile / run that: https://gist.github.com/lefticus/9190735#file-chaiscript_basic_example-cpp
but you will definitely have problems without an initialized chai object