From 30415845df00cf8f367ba356556f6fac8420f516 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Mon, 11 Apr 2016 02:15:06 -0400 Subject: [PATCH] Indentation fixes --- docs/source/api/stack.rst | 2 +- docs/source/api/usertype.rst | 2 +- docs/source/index.rst | 70 ++++++++++++------------ docs/source/tutorial/existing.rst | 2 +- docs/source/tutorial/getting-started.rst | 2 +- 5 files changed, 40 insertions(+), 38 deletions(-) diff --git a/docs/source/api/stack.rst b/docs/source/api/stack.rst index 9296448e..ed07d000 100644 --- a/docs/source/api/stack.rst +++ b/docs/source/api/stack.rst @@ -162,7 +162,7 @@ This is an SFINAE-friendly struct that is meant to expose static function ``push // otherwise, call the handler function, // with the required 4 arguments, then return false handler(L, index, expected, indextype); - return false; + return false; } }; diff --git a/docs/source/api/usertype.rst b/docs/source/api/usertype.rst index 2fa5165b..a05d09c0 100644 --- a/docs/source/api/usertype.rst +++ b/docs/source/api/usertype.rst @@ -148,7 +148,7 @@ The constructor of usertype takes a variable number of arguments. It takes an ev - If you pass the ``constructors<...>`` argument first when constructing the usertype, then it will automatically be given a ``"{name}"`` of ``"new"`` * ``"{name}", initializers( func1, func2, ... )`` - Creates initializers that, given one or more functions, provides an overloaded lua function for creating a the specified type. - + The function must have the argument signature ``func T*, Arguments... )`` or ``func( T&, Arguments... )``, where the pointer or reference will point to a place of allocated memory that has an unitialized ``T``. Note that lua controls the memory. + + The function must have the argument signature ``func T*, Arguments... )`` or ``func( T&, Arguments... )``, where the pointer or reference will point to a place of allocated memory that has an unitialized ``T``. Note that lua controls the memory. .. _destructor: diff --git a/docs/source/index.rst b/docs/source/index.rst index 897c28c3..35b813a4 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -11,8 +11,8 @@ a fast, simple C++ and Lua Binding 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. .. image:: https://travis-ci.org/ThePhD/sol2.svg?branch=develop - :target: https://travis-ci.org/ThePhD/sol2 - :alt: build status + :target: https://travis-ci.org/ThePhD/sol2 + :alt: build status get going: ---------- @@ -43,61 +43,63 @@ the basics: .. note:: More examples can be found in the `examples directory`_ + .. code-block:: c++ - :caption: functions - :linenos: + :caption: functions + :linenos: #include #include int main() { - sol::state lua; - int x = 0; - lua.set_function("beep", [&x]{ ++x; }); - lua.script("beep()"); - assert(x == 1); + sol::state lua; + int x = 0; + lua.set_function("beep", [&x]{ ++x; }); + lua.script("beep()"); + assert(x == 1); - sol::function beep = lua["beep"]; - beep(); - assert(x == 2); + sol::function beep = lua["beep"]; + beep(); + assert(x == 2); - return 0; + return 0; } + .. code-block:: c++ - :caption: linking C++ structures to Lua - :linenos: + :caption: linking C++ structures to Lua + :linenos: #include #include struct vars { - int boop = 0; + int boop = 0; - int bop () const { - return boop + 1; - } + int bop () const { + return boop + 1; + } }; int main() { - sol::state lua; - lua.new_usertype("vars", - "boop", &vars::boop - "bop", &vars::bop); - lua.script("beep = vars.new()\n" - "beep.boop = 1\n" - "bopvalue = beep:bop()"); + sol::state lua; + lua.new_usertype("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"]; + vars& beep = lua["beep"]; + int bopvalue = lua["bopvalue"]; - assert(beep.boop == 1); - assert(lua.get("beep").boop == 1); - assert(beep.bop() == 2); - assert(bopvalue == 2); + assert(beep.boop == 1); + assert(lua.get("beep").boop == 1); + assert(beep.bop() == 2); + assert(bopvalue == 2); - return 0; - } + return 0; + } diff --git a/docs/source/tutorial/existing.rst b/docs/source/tutorial/existing.rst index c9e48f05..4b018abd 100644 --- a/docs/source/tutorial/existing.rst +++ b/docs/source/tutorial/existing.rst @@ -18,6 +18,6 @@ If you're already using lua and you just want to use ``sol`` in some places, you // start using it... } -Sol has no initialization components that need to deliberately remain alive for the duration of the program. It's entirely self-containing and uses lua's garbage collectors and various implementation techniques to require no state C++-side. After you do that, all of the power of `Sol` is available to you, and then some! +:doc:`sol::state_view<../api/state` is exactly like ``sol::state``, but it doesn't manage the lifetime of a ``lua_State*``. Therefore, you get all the goodies that come with a ``sol::state`` without any of the ownership implications. Sol has no initialization components that need to deliberately remain alive for the duration of the program. It's entirely self-containing and uses lua's garbage collectors and various implementation techniques to require no state C++-side. After you do that, all of the power of `Sol` is available to you, and then some! Remember that Sol can be as lightweight as you want it: almost all of Sol's types take the ``lua_State*`` argument and then a second ``int index`` stack index argument, meaning you can use :doc:`tables<../api/table>`, :doc:`lua functions<../api/function>`, :doc:`coroutines<../api/coroutine>`, and other reference-derived objects that expose the proper constructor for your use. You can also set :doc:`usertypes<../api/usertype>` and other things you need without changing your entire architecture! \ No newline at end of file diff --git a/docs/source/tutorial/getting-started.rst b/docs/source/tutorial/getting-started.rst index aac971c0..e9685989 100644 --- a/docs/source/tutorial/getting-started.rst +++ b/docs/source/tutorial/getting-started.rst @@ -46,7 +46,7 @@ If this works, you're ready to start! The first line creates the ``lua_State`` a .. code-block:: cpp :linenos: :caption: test.cpp: the first snippet - :name: the-first-snippet + :name: the-second-snippet #include