|
|
@@ -4,7 +4,7 @@ A header-only C++ library which provides a Lua wrapper with minimal overhead.
|
|
|
## Usage
|
|
|
Most of Luwra's features are based on template specialization. If you are not familiar with
|
|
|
templates in C++, I highly recommend you inform yourself about them. Otherwise the following
|
|
|
-examples will have no use to you.
|
|
|
+examples will not be of use to you.
|
|
|
|
|
|
### Types
|
|
|
A template `Value<T>` exists to capsulate push and check mechanisms for a type `T`. Default
|
|
|
@@ -38,7 +38,7 @@ struct Value<T> {
|
|
|
};
|
|
|
```
|
|
|
|
|
|
-Have a look at the [type example](https://github.com/vapourismo/luwra/blob/master/examples/types.cpp).
|
|
|
+[Example](https://github.com/vapourismo/luwra/blob/master/examples/types.cpp)
|
|
|
|
|
|
### Stack
|
|
|
Instead of retrieving each value from the stack seperately, you can make use of `apply` which lets
|
|
|
@@ -47,7 +47,7 @@ you invoke a function, whose parameters map to the stack layout, using the stack
|
|
|
Assuming your stack looks like this
|
|
|
|
|
|
Position | Value
|
|
|
----------|--------------------
|
|
|
+---------|-----------
|
|
|
3 | c = 42.32
|
|
|
2 | b = 73.31
|
|
|
1 | a = 13.37
|
|
|
@@ -74,11 +74,11 @@ lua_Integer result = foo(
|
|
|
);
|
|
|
```
|
|
|
|
|
|
-There is a [complete example](https://github.com/vapourismo/luwra/blob/master/examples/stack.cpp).
|
|
|
+[Example](https://github.com/vapourismo/luwra/blob/master/examples/stack.cpp)
|
|
|
|
|
|
### Functions
|
|
|
Luwra's core feature is to wrap C/C++ functions so they can be used with the Lua VM.
|
|
|
-
|
|
|
+All it takes is the signature of the function you want to wrap and a pointer to it.
|
|
|
Wrapping them is as easy as this:
|
|
|
|
|
|
```c++
|
|
|
@@ -93,25 +93,7 @@ lua_Number my_add(lua_Number a, lua_Number b) {
|
|
|
lua_CFunction cfunc = WrapFunction<lua_Number(lua_Number, lua_Number), my_add>;
|
|
|
```
|
|
|
|
|
|
-All it takes is the signature of the function you want to wrap and a pointer to it.
|
|
|
-See [another example](https://github.com/vapourismo/luwra/blob/master/examples/functions.cpp).
|
|
|
-
|
|
|
-### Methods
|
|
|
-Method-wrapping works analogously to the wrapping of functions.
|
|
|
-
|
|
|
-```c++
|
|
|
-// A meta table name is needed
|
|
|
-const char* MyClass::MetatableName = "MyClass";
|
|
|
-
|
|
|
-// The method to be wrapped
|
|
|
-lua_Number MyClass::my_method(lua_Number a, lua_Number b) {
|
|
|
- // ...
|
|
|
-}
|
|
|
-
|
|
|
-// ...
|
|
|
-
|
|
|
-lua_CFunction cfunc = WrapMethod<MyClass, lua_Number(lua_Number, lua_Number), &MyClass::my_method>;
|
|
|
-```
|
|
|
+[Example](https://github.com/vapourismo/luwra/blob/master/examples/functions.cpp)
|
|
|
|
|
|
### User types
|
|
|
Something is going be here soon.
|