Indentation fixes

This commit is contained in:
ThePhD 2016-04-11 02:15:06 -04:00
parent 42f4455383
commit 30415845df
5 changed files with 40 additions and 38 deletions

View File

@ -162,7 +162,7 @@ This is an SFINAE-friendly struct that is meant to expose static function ``push
// otherwise, call the handler function, // otherwise, call the handler function,
// with the required 4 arguments, then return false // with the required 4 arguments, then return false
handler(L, index, expected, indextype); handler(L, index, expected, indextype);
return false; return false;
} }
}; };

View File

@ -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"`` - 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, ... )`` * ``"{name}", initializers( func1, func2, ... )``
- Creates initializers that, given one or more functions, provides an overloaded lua function for creating a the specified type. - 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: .. _destructor:

View File

@ -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. 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 .. image:: https://travis-ci.org/ThePhD/sol2.svg?branch=develop
:target: https://travis-ci.org/ThePhD/sol2 :target: https://travis-ci.org/ThePhD/sol2
:alt: build status :alt: build status
get going: get going:
---------- ----------
@ -43,61 +43,63 @@ the basics:
.. note:: .. note::
More examples can be found in the `examples directory`_ More examples can be found in the `examples directory`_
.. code-block:: c++ .. code-block:: c++
:caption: functions :caption: functions
:linenos: :linenos:
#include <sol.hpp> #include <sol.hpp>
#include <cassert> #include <cassert>
int main() { int main() {
sol::state lua; sol::state lua;
int x = 0; int x = 0;
lua.set_function("beep", [&x]{ ++x; }); lua.set_function("beep", [&x]{ ++x; });
lua.script("beep()"); lua.script("beep()");
assert(x == 1); assert(x == 1);
sol::function beep = lua["beep"]; sol::function beep = lua["beep"];
beep(); beep();
assert(x == 2); assert(x == 2);
return 0; return 0;
} }
.. code-block:: c++ .. code-block:: c++
:caption: linking C++ structures to Lua :caption: linking C++ structures to Lua
:linenos: :linenos:
#include <sol.hpp> #include <sol.hpp>
#include <cassert> #include <cassert>
struct vars { struct vars {
int boop = 0; int boop = 0;
int bop () const { int bop () const {
return boop + 1; return boop + 1;
} }
}; };
int main() { int main() {
sol::state lua; sol::state lua;
lua.new_usertype<vars>("vars", lua.new_usertype<vars>("vars",
"boop", &vars::boop "boop", &vars::boop
"bop", &vars::bop); "bop", &vars::bop);
lua.script("beep = vars.new()\n" lua.script("beep = vars.new()\n"
"beep.boop = 1\n" "beep.boop = 1\n"
"bopvalue = beep:bop()"); "bopvalue = beep:bop()");
vars& beep = lua["beep"]; vars& beep = lua["beep"];
int bopvalue = lua["bopvalue"]; int bopvalue = lua["bopvalue"];
assert(beep.boop == 1); assert(beep.boop == 1);
assert(lua.get<vars>("beep").boop == 1); assert(lua.get<vars>("beep").boop == 1);
assert(beep.bop() == 2); assert(beep.bop() == 2);
assert(bopvalue == 2); assert(bopvalue == 2);
return 0; return 0;
} }

View File

@ -18,6 +18,6 @@ If you're already using lua and you just want to use ``sol`` in some places, you
// start using it... // 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! 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!

View File

@ -46,7 +46,7 @@ If this works, you're ready to start! The first line creates the ``lua_State`` a
.. code-block:: cpp .. code-block:: cpp
:linenos: :linenos:
:caption: test.cpp: the first snippet :caption: test.cpp: the first snippet
:name: the-first-snippet :name: the-second-snippet
#include <sol.hpp> #include <sol.hpp>