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,
// with the required 4 arguments, then return false
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"``
* ``"{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:

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.
.. 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 <sol.hpp>
#include <cassert>
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 <sol.hpp>
#include <cassert>
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>("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>("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<vars>("beep").boop == 1);
assert(beep.bop() == 2);
assert(bopvalue == 2);
assert(beep.boop == 1);
assert(lua.get<vars>("beep").boop == 1);
assert(beep.bop() == 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...
}
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!

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
:linenos:
:caption: test.cpp: the first snippet
:name: the-first-snippet
:name: the-second-snippet
#include <sol.hpp>