• Stars
    star
    205
  • Rank 191,264 (Top 4 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 11 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A C++11 Lua wrapper

Sol

Build Status

Sol is a C++ library binding to Lua. It currently supports Lua 5.2. Sol aims to be easy to use and easy to add to a project. At this time, the library is header-only for easy integration with projects.

Sneak Peek

#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);
}
#include <sol.hpp>
#include <cassert>

struct vars {
    int boop = 0;
};

int main() {
    sol::state lua;
    lua.new_userdata<vars>("vars", "boop", &vars::boop);
    lua.script("beep = vars.new()\n"
               "beep.boop = 1");
    assert(lua.get<vars>("beep").boop == 1);
}

More examples are given in the examples directory.

Features

  • Supports retrieval and setting of multiple types including std::string.
  • Lambda, function, and member function bindings are supported.
  • Intermediate type for checking if a variable exists.
  • Simple API that completely abstracts away the C stack API.
  • operator[]-style manipulation of tables is provided.
  • Support for tables.

Supported Compilers

Sol makes use of C++11 features. GCC 4.7 and Clang 3.3 or higher should be able to compile without problems. However, the officially supported compilers are:

  • GCC 4.8.0
  • GCC 4.9.0
  • Clang 3.4

Visual Studio 2013 with the November CTP could possibly compile it, despite not being explicitly supported. The last version that Visual Studio 2013 was supported was on tag v1.1.0. Anything after that is wishful thinking. In order to retrieve that tagged version, just do git checkout v1.1.0.

Caveats

Due to how this library is used compared to the C API, the Lua Stack is completely abstracted away. Not only that, but all Lua errors are thrown as exceptions instead. This allows you to handle the errors gracefully without being forced to exit.

It should be noted that the library itself depends on lua.hpp to be found by your compiler. It uses angle brackets, e.g. #include <lua.hpp>.

License

Sol is distributed with an MIT License. You can see LICENSE.txt for more info.

More Repositories

1

discord.py

An API wrapper for Discord written in Python.
Python
14,368
star
2

RoboDanny

A discord bot for servers that I like.
Python
797
star
3

discord-ext-menus

Python
232
star
4

asqlite

A simple async wrapper for sqlite3
Python
112
star
5

cpp-sublime-snippet

C++11 Sublime Text Snippets
JavaScript
92
star
6

eos

A simple and easy to use datetime library for Rust
Rust
51
star
7

jimaku

A site for hosting (Japanese) subtitles
Rust
38
star
8

discord-event-bot

Python
34
star
9

discord-ext-native-voice

Rust
33
star
10

Reddit-Imgur-Scraper

Python script that scraps images from imgur on reddit.
Python
30
star
11

DoxyDoc

A sublime text plugin for C++ document autocompletion
Python
27
star
12

power-tabs

Vertical tab groups for Firefox
JavaScript
25
star
13

Gears

C++ Utilities
C++
25
star
14

jsonpp

C++11 JSON parser and writer
C++
21
star
15

aoc2021

Solutions for Advent of Code 2021
Rust
15
star
16

open-collective-discord-auth

The server component for Open Collective Linked Role integration
TypeScript
15
star
17

gum

Thin C++11 SDL 2 wrapper with other nice things.
C++
15
star
18

google-lens-ocr

A simple CLI to invoke Google Lens OCR
Rust
6
star
19

Sky

SFML tools to aid in game development.
C++
5
star
20

sqlitexx

A C++14 SQLite3 wrapper
C++
4
star
21

Lia

List comprehensions for C++
C++
3
star
22

hacktober-cheese

Cheese
3
star
23

Shinobi

A meta build system for ninja
C++
2
star
24

sub-tools

Rust
1
star
25

git-utils

Scripts that I use for custom git commands.
Shell
1
star
26

compo-two

2nd Great Lounge Game Jam.
Lua
1
star
27

rapptz.github.io

Github page for my projects.
CSS
1
star
28

sen.py

A pseudo meta build system for ninja.
Python
1
star
29

splatoon

Splatoon data related nonsense.
1
star
30

Project-Euler

Project Euler solutions
C++
1
star
31

anitomy-rs

A pure Rust port of anitomy, an anime filename parser
Rust
1
star
32

libnet

A C++11 library for networking.
C++
1
star