Created
August 17, 2014 18:20
Revisions
-
lucidguppy created this gist
Aug 17, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ cmake_minimum_required (VERSION 2.8) add_definitions(-std=c++11) project (ChaiTutorial) add_library(myModule SHARED myModule.cpp) list(APPEND LIBS ${READLINE_LIB}) include_directories(/usr/local/include) install(TARGETS myModule DESTINATION /usr/local/lib/chaiscript) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ mkdir build cd build cmake ../ make make install chai testModule.chai This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ #include <chaiscript/chaiscript.hpp> #include <string> std::string helloWorld() { return "Hello World"; } int addTwoNumbers(int a, int b) { return a + b; } CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_myModule() { chaiscript::ModulePtr m(new chaiscript::Module()); m->add(chaiscript::fun(helloWorld), "helloWorld"); m->add(chaiscript::fun(addTwoNumbers), "addTwoNumbers"); return m; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ load_module("myModule"); print(helloWorld()); var x = addTwoNumbers(3,5); print("The value of x is " + x.to_string());