2016-03-12 06:47:15 +08:00
.. Sol documentation master file, created by
sphinx-quickstart on Mon Feb 29 21:49:51 2016.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
2016-04-26 03:58:13 +08:00
.. image :: sol.png
:target: https://github.com/ThePhD/sol2
:alt: sol2 repository
2016-11-06 11:17:31 +08:00
Sol |version|
=============
2016-03-12 06:47:15 +08:00
a fast, simple C++ and Lua Binding
----------------------------------
2016-03-12 10:45:41 +08:00
When you need to hit the ground running with Lua and C++, `Sol`_ is the go-to framework for high-performance binding with an easy to use API.
2016-03-13 21:03:47 +08:00
.. image :: https://travis-ci.org/ThePhD/sol2.svg?branch=develop
2016-04-11 14:15:06 +08:00
:target: https://travis-ci.org/ThePhD/sol2
:alt: build status
2016-03-13 21:03:47 +08:00
2016-10-24 07:17:33 +08:00
.. image :: https://badges.gitter.im/chat-sol2/Lobby.svg
2016-11-06 11:17:31 +08:00
:target: https://gitter.im/chat-sol2/Lobby
2016-10-24 07:17:33 +08:00
:alt: chat about sol2 on gitter
2016-03-12 10:45:41 +08:00
get going:
----------
2016-03-12 06:47:15 +08:00
.. toctree ::
2016-08-25 00:22:51 +08:00
:maxdepth: 1
2016-04-09 12:55:12 +08:00
:name: mastertoc
2016-03-12 06:47:15 +08:00
2016-04-24 05:07:51 +08:00
tutorial/all-the-things
2016-04-24 05:16:56 +08:00
tutorial/tutorial-top
2016-11-06 08:08:07 +08:00
errors
2016-12-10 13:25:25 +08:00
compilation
2016-04-09 12:55:12 +08:00
features
2016-10-24 07:17:33 +08:00
usertypes
2017-04-03 04:28:57 +08:00
threading
2016-11-06 08:08:07 +08:00
traits
2016-05-13 23:50:06 +08:00
api/api-top
2016-08-12 23:06:14 +08:00
mentions
2016-04-09 12:55:12 +08:00
benchmarks
2016-08-17 03:19:51 +08:00
performance
2016-04-09 12:55:12 +08:00
safety
exceptions
rtti
2016-08-13 01:08:59 +08:00
codecvt
2016-05-13 23:50:06 +08:00
cmake
2016-04-09 12:55:12 +08:00
licenses
origin
2016-03-12 06:47:15 +08:00
2016-03-12 10:45:41 +08:00
2016-03-12 06:47:15 +08:00
"I need feature X, maybe you have it?"
--------------------------------------
2016-10-24 07:17:33 +08:00
Take a look at the :doc: `Features<features>` page: it links to much of the API. You can also just straight up browse the :doc: `api<api/api-top>` or ease in with the :doc: `tutorials<tutorial/tutorial-top>` . To know more about the implementation for usertypes, see :doc: `here<usertypes>` To know how function arguments are handled, see :ref: `this note<function-argument-handling>` . Don't see a feature you want? Send inquiries for support for a particular abstraction to the `issues`_ tracker.
2016-03-12 06:47:15 +08:00
2016-03-12 10:45:41 +08:00
the basics:
2016-03-12 06:47:15 +08:00
-----------
.. note ::
More examples can be found in the `examples directory`_
2016-04-11 14:15:06 +08:00
2016-03-12 06:47:15 +08:00
.. code-block :: c++
2016-04-11 14:15:06 +08:00
:caption: functions
:linenos:
2016-03-12 06:47:15 +08:00
#include <sol.hpp>
#include <cassert>
int main() {
2016-04-11 14:15:06 +08:00
sol::state lua;
int x = 0;
lua.set_function("beep", [&x]{ ++x; });
lua.script("beep()");
assert(x == 1);
2016-03-12 06:47:15 +08:00
2016-04-11 14:15:06 +08:00
sol::function beep = lua["beep"];
beep();
assert(x == 2);
2016-03-12 06:47:15 +08:00
2016-04-11 14:15:06 +08:00
return 0;
2016-03-12 06:47:15 +08:00
}
2016-04-11 14:15:06 +08:00
2016-03-12 06:47:15 +08:00
.. code-block :: c++
2016-04-11 14:15:06 +08:00
:caption: linking C++ structures to Lua
:linenos:
2016-03-12 06:47:15 +08:00
#include <sol.hpp>
#include <cassert>
struct vars {
2016-04-11 14:15:06 +08:00
int boop = 0;
2016-03-12 06:47:15 +08:00
2016-04-11 14:15:06 +08:00
int bop () const {
return boop + 1;
}
2016-03-12 06:47:15 +08:00
};
int main() {
2016-04-11 14:15:06 +08:00
sol::state lua;
lua.new_usertype<vars>("vars",
"boop", &vars::boop
"bop", &vars::bop);
lua.script("beep = vars.new()\n"
"beep.boop = 1\n"
"bopvalue = beep:bop()");
vars& beep = lua["beep"];
int bopvalue = lua["bopvalue"];
assert(beep.boop == 1);
assert(lua.get<vars>("beep").boop == 1);
assert(beep.bop() == 2);
assert(bopvalue == 2);
return 0;
}
2016-03-12 06:47:15 +08:00
Indices and tables
==================
* :ref: `genindex`
* :ref: `search`
2016-03-12 10:45:41 +08:00
.. _Sol: https://github.com/ThePhD/sol2
.. _issues: https://github.com/ThePhD/sol2/issues
2016-03-12 06:47:15 +08:00
.. _examples directory: https://github.com/ThePhD/sol2/tree/develop/examples