xLua - Lua C++ API

Check-in [1152ce8736]
Login
Overview
Comment:update
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:1152ce8736beaabd79dc41df2b2edbed01c7c3b0fa7ce2999834350abe11f667
User & Date: xjail 2018-07-12 02:21:19
Context
2019-03-18
10:31
switch to mk-configure check-in: 67fcc7c7b0 user: xjail tags: master, trunk
2018-07-12
02:21
update check-in: 1152ce8736 user: xjail tags: master, trunk
2018-07-05
21:11
xlua check-in: 9ebeabe199 user: xjail tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to compiler.config.

1
2
3
4
5
CXXFLAGS += -std=c++14 -stdlib=libc++
LDFLAGS += -lc++ -lm -lthr -pthread
CC = clang
CXX = clang++
CPP = clang-cpp
|




1
2
3
4
5
CXXFLAGS += -std=c++17 -stdlib=libc++
LDFLAGS += -lc++ -lm -lthr -pthread
CC = clang
CXX = clang++
CPP = clang-cpp

Changes to include/xlua/c_gate.hpp.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
64
65
66
67
68
69
70
71
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file c_gate.hpp
/// Provides direct access to the C state of the Lua wrappers.

#if !defined(LUTOK_C_GATE_HPP)
#define LUTOK_C_GATE_HPP

#include <lua.hpp>

namespace xlua {


class state;
................................................................................

    lua_State* c_state(void);
};


}  // namespace xlua

#endif  // !defined(LUTOK_C_GATE_HPP)







|
|







 







|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
64
65
66
67
68
69
70
71
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file c_gate.hpp
/// Provides direct access to the C state of the Lua wrappers.

#if !defined(XLUA_C_GATE_HPP)
#define XLUA_C_GATE_HPP

#include <lua.hpp>

namespace xlua {


class state;
................................................................................

    lua_State* c_state(void);
};


}  // namespace xlua

#endif  // !defined(XLUA_C_GATE_HPP)

Changes to include/xlua/debug.hpp.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
83
84
85
86
87
88
89
90
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file debug.hpp
/// Provides the debug wrapper class for the Lua C debug state.

#if !defined(LUTOK_DEBUG_HPP)
#define LUTOK_DEBUG_HPP

#include <string>
#if defined(_LIBCPP_VERSION) || __cplusplus >= 201103L
#include <memory>
#else
#include <tr1/memory>
#endif
................................................................................
    int last_line_defined(void) const;
    std::string short_src(void) const;
};


}  // namespace xlua

#endif  // !defined(LUTOK_DEBUG_HPP)







|
|







 







|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
83
84
85
86
87
88
89
90
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file debug.hpp
/// Provides the debug wrapper class for the Lua C debug state.

#if !defined(XLUA_DEBUG_HPP)
#define XLUA_DEBUG_HPP

#include <string>
#if defined(_LIBCPP_VERSION) || __cplusplus >= 201103L
#include <memory>
#else
#include <tr1/memory>
#endif
................................................................................
    int last_line_defined(void) const;
    std::string short_src(void) const;
};


}  // namespace xlua

#endif  // !defined(XLUA_DEBUG_HPP)

Changes to include/xlua/exceptions.hpp.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
76
77
78
79
80
81
82
83
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file exceptions.hpp
/// Exception types raised by xlua.

#if !defined(LUTOK_EXCEPTIONS_HPP)
#define LUTOK_EXCEPTIONS_HPP

#include <stdexcept>
#include <string>

namespace xlua {


................................................................................
    const std::string& filename(void) const;
};


}  // namespace xlua


#endif  // !defined(LUTOK_EXCEPTIONS_HPP)







|
|







 







|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
76
77
78
79
80
81
82
83
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file exceptions.hpp
/// Exception types raised by xlua.

#if !defined(XLUA_EXCEPTIONS_HPP)
#define XLUA_EXCEPTIONS_HPP

#include <stdexcept>
#include <string>

namespace xlua {


................................................................................
    const std::string& filename(void) const;
};


}  // namespace xlua


#endif  // !defined(XLUA_EXCEPTIONS_HPP)

Changes to include/xlua/operations.hpp.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
48
49
50
51
52
53
54
55
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file operations.hpp
/// Extra generic functions to interact with Lua.

#if !defined(LUTOK_OPERATIONS_HPP)
#define LUTOK_OPERATIONS_HPP

#include <map>
#include <string>
#include <vector>

#include <xlua/state.hpp>

................................................................................
unsigned int do_string(state&, const std::string&, const int, const int,
                       const int);
void eval(state&, const std::string&, const int);


}  // namespace xlua

#endif  // !defined(LUTOK_OPERATIONS_HPP)







|
|







 







|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
48
49
50
51
52
53
54
55
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file operations.hpp
/// Extra generic functions to interact with Lua.

#if !defined(XLUA_OPERATIONS_HPP)
#define XLUA_OPERATIONS_HPP

#include <map>
#include <string>
#include <vector>

#include <xlua/state.hpp>

................................................................................
unsigned int do_string(state&, const std::string&, const int, const int,
                       const int);
void eval(state&, const std::string&, const int);


}  // namespace xlua

#endif  // !defined(XLUA_OPERATIONS_HPP)

Changes to include/xlua/stack_cleaner.hpp.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
..
86
87
88
89
90
91
92
93
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file stack_cleaner.hpp
/// Provides the stack_cleaner class.

#if !defined(LUTOK_STACK_CLEANER_HPP)
#define LUTOK_STACK_CLEANER_HPP

#include <memory>

#include <xlua/state.hpp>

namespace xlua {

................................................................................
/// You must give a name to the instantiated objects even if they cannot be
/// accessed later.  Otherwise, the instance will be destroyed right away and
/// will not have the desired effect.
class stack_cleaner {
    struct impl;

    /// Pointer to the shared internal implementation.
    std::auto_ptr< impl > _pimpl;

    /// Disallow copies.
    stack_cleaner(const stack_cleaner&);

    /// Disallow assignment.
    stack_cleaner& operator=(const stack_cleaner&);

................................................................................

    void forget(void);
};


}  // namespace xlua

#endif  // !defined(LUTOK_STACK_CLEANER_HPP)







|
|







 







|







 







|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
..
86
87
88
89
90
91
92
93
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file stack_cleaner.hpp
/// Provides the stack_cleaner class.

#if !defined(XLUA_STACK_CLEANER_HPP)
#define XLUA_STACK_CLEANER_HPP

#include <memory>

#include <xlua/state.hpp>

namespace xlua {

................................................................................
/// You must give a name to the instantiated objects even if they cannot be
/// accessed later.  Otherwise, the instance will be destroyed right away and
/// will not have the desired effect.
class stack_cleaner {
    struct impl;

    /// Pointer to the shared internal implementation.
    std::unique_ptr<impl> _pimpl;

    /// Disallow copies.
    stack_cleaner(const stack_cleaner&);

    /// Disallow assignment.
    stack_cleaner& operator=(const stack_cleaner&);

................................................................................

    void forget(void);
};


}  // namespace xlua

#endif  // !defined(XLUA_STACK_CLEANER_HPP)

Changes to include/xlua/state.hpp.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
...
138
139
140
141
142
143
144
145
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file state.hpp
/// Provides the state wrapper class for the Lua C state.

#if !defined(LUTOK_STATE_HPP)
#define LUTOK_STATE_HPP

#include <string>

#if defined(_LIBCPP_VERSION) || __cplusplus >= 201103L
#include <memory>
#else
#include <tr1/memory>
................................................................................
    std::string to_string(const int);
    int upvalue_index(const int);
};


}  // namespace xlua

#endif  // !defined(LUTOK_STATE_HPP)







|
|







 







|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
...
138
139
140
141
142
143
144
145
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// \file state.hpp
/// Provides the state wrapper class for the Lua C state.

#if !defined(XLUA_STATE_HPP)
#define XLUA_STATE_HPP

#include <string>

#if defined(_LIBCPP_VERSION) || __cplusplus >= 201103L
#include <memory>
#else
#include <tr1/memory>
................................................................................
    std::string to_string(const int);
    int upvalue_index(const int);
};


}  // namespace xlua

#endif  // !defined(XLUA_STATE_HPP)

Changes to include/xlua/state.ipp.

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
60
61
62
63
64
65
66
67
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#if !defined(LUTOK_STATE_IPP)
#define LUTOK_STATE_IPP

#include <xlua/state.hpp>

namespace xlua {


/// Wrapper around lua_newuserdata.
................................................................................
{
    return static_cast< Type* >(to_userdata_voidp(index));
}


}  // namespace xlua

#endif  // !defined(LUTOK_STATE_IPP)







|
|







 







|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
60
61
62
63
64
65
66
67
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#if !defined(XLUA_STATE_IPP)
#define XLUA_STATE_IPP

#include <xlua/state.hpp>

namespace xlua {


/// Wrapper around lua_newuserdata.
................................................................................
{
    return static_cast< Type* >(to_userdata_voidp(index));
}


}  // namespace xlua

#endif  // !defined(XLUA_STATE_IPP)

Changes to include/xlua/test_utils.hpp.

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/// \file test_utils.hpp
/// Utilities for tests of the lua modules.
///
/// This file is intended to be included once, and only once, for every test
/// program that needs it.  All the code is herein contained to simplify the
/// dependency chain in the build rules.

#if !defined(LUTOK_TEST_UTILS_HPP)
#   define LUTOK_TEST_UTILS_HPP
#else
#   error "test_utils.hpp can only be included once"
#endif

#include <atf-c++.hpp>

#include <xlua/c_gate.hpp>







|
|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/// \file test_utils.hpp
/// Utilities for tests of the lua modules.
///
/// This file is intended to be included once, and only once, for every test
/// program that needs it.  All the code is herein contained to simplify the
/// dependency chain in the build rules.

#if !defined(XLUA_TEST_UTILS_HPP)
#   define XLUA_TEST_UTILS_HPP
#else
#   error "test_utils.hpp can only be included once"
#endif

#include <atf-c++.hpp>

#include <xlua/c_gate.hpp>