Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/lutok/dist Initial import of Lutok, version 0.2.
details: https://anonhg.NetBSD.org/src/rev/b66a622044f2
branches: trunk
changeset: 784983:b66a622044f2
user: jmmv <jmmv%NetBSD.org@localhost>
date: Sat Feb 16 15:06:52 2013 +0000
description:
Initial import of Lutok, version 0.2.
This is a required component of Kyua and its build will be guarded by
the MKKYUA knob. core@ has approved this import.
Description:
Lutok is a lightweight C++ API library for Lua.
Lutok provides thin C++ wrappers around the Lua C API to ease the
interaction between C++ and Lua. These wrappers make intensive use of
RAII to prevent resource leakage, expose C++-friendly data types, report
errors by means of exceptions and ensure that the Lua stack is always
left untouched in the face of errors. The library also provides a small
subset of miscellaneous utility functions built on top of the wrappers.
Lutok focuses on providing a clean and safe C++ interface; the drawback
is that it is not suitable for performance-critical environments. In
order to implement error-safe C++ wrappers on top of a Lua C binary
library, Lutok adds several layers or abstraction and error checking
that go against the original spirit of the Lua C API and thus degrade
performance.
diffstat:
external/bsd/lutok/dist/AUTHORS | 1 +
external/bsd/lutok/dist/Atffile | 11 +
external/bsd/lutok/dist/COPYING | 27 +
external/bsd/lutok/dist/Kyuafile | 11 +
external/bsd/lutok/dist/NEWS | 19 +
external/bsd/lutok/dist/README | 27 +
external/bsd/lutok/dist/c_gate.cpp | 76 +
external/bsd/lutok/dist/c_gate.hpp | 71 +
external/bsd/lutok/dist/c_gate_test.cpp | 74 +
external/bsd/lutok/dist/debug.cpp | 192 +++
external/bsd/lutok/dist/debug.hpp | 83 +
external/bsd/lutok/dist/debug_test.cpp | 68 +
external/bsd/lutok/dist/examples/bindings.cpp | 133 ++
external/bsd/lutok/dist/examples/hello.cpp | 58 +
external/bsd/lutok/dist/examples/interpreter.cpp | 83 +
external/bsd/lutok/dist/examples/raii.cpp | 125 +
external/bsd/lutok/dist/examples_test.sh | 114 +
external/bsd/lutok/dist/exceptions.cpp | 126 +
external/bsd/lutok/dist/exceptions.hpp | 83 +
external/bsd/lutok/dist/exceptions_test.cpp | 88 +
external/bsd/lutok/dist/lutok.pc.in | 8 +
external/bsd/lutok/dist/operations.cpp | 143 ++
external/bsd/lutok/dist/operations.hpp | 53 +
external/bsd/lutok/dist/operations_test.cpp | 296 ++++
external/bsd/lutok/dist/stack_cleaner.cpp | 91 +
external/bsd/lutok/dist/stack_cleaner.hpp | 93 +
external/bsd/lutok/dist/stack_cleaner_test.cpp | 108 +
external/bsd/lutok/dist/state.cpp | 862 +++++++++++++
external/bsd/lutok/dist/state.hpp | 134 ++
external/bsd/lutok/dist/state.ipp | 67 +
external/bsd/lutok/dist/state_test.cpp | 1404 ++++++++++++++++++++++
external/bsd/lutok/dist/test_utils.hpp | 141 ++
32 files changed, 4870 insertions(+), 0 deletions(-)
diffs (truncated from 4998 to 300 lines):
diff -r 43fa2f1689f1 -r b66a622044f2 external/bsd/lutok/dist/AUTHORS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/lutok/dist/AUTHORS Sat Feb 16 15:06:52 2013 +0000
@@ -0,0 +1,1 @@
+* Julio Merino <jmmv%google.com@localhost>
diff -r 43fa2f1689f1 -r b66a622044f2 external/bsd/lutok/dist/Atffile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/lutok/dist/Atffile Sat Feb 16 15:06:52 2013 +0000
@@ -0,0 +1,11 @@
+Content-Type: application/X-atf-atffile; version="1"
+
+prop: test-suite = lutok
+
+tp: c_gate_test
+tp: debug_test
+tp: examples_test
+tp: exceptions_test
+tp: operations_test
+tp: stack_cleaner_test
+tp: state_test
diff -r 43fa2f1689f1 -r b66a622044f2 external/bsd/lutok/dist/COPYING
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/lutok/dist/COPYING Sat Feb 16 15:06:52 2013 +0000
@@ -0,0 +1,27 @@
+Copyright 2011, 2012 Google Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+* Neither the name of Google Inc. nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+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.
diff -r 43fa2f1689f1 -r b66a622044f2 external/bsd/lutok/dist/Kyuafile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/lutok/dist/Kyuafile Sat Feb 16 15:06:52 2013 +0000
@@ -0,0 +1,11 @@
+syntax("kyuafile", 1)
+
+test_suite("lutok")
+
+atf_test_program{name="c_gate_test"}
+atf_test_program{name="debug_test"}
+atf_test_program{name="examples_test"}
+atf_test_program{name="exceptions_test"}
+atf_test_program{name="operations_test"}
+atf_test_program{name="stack_cleaner_test"}
+atf_test_program{name="state_test"}
diff -r 43fa2f1689f1 -r b66a622044f2 external/bsd/lutok/dist/NEWS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/lutok/dist/NEWS Sat Feb 16 15:06:52 2013 +0000
@@ -0,0 +1,19 @@
+Changes in version 0.2
+======================
+
+Released on 2012/05/30.
+
+* New global constants: globals_index.
+
+* New methods added to the state class: get_metafield, get_metatable,
+ insert, push_value, raw_get and raw_set.
+
+* Acknowledged that Lua 5.2 is currently not supported.
+
+
+Changes in version 0.1
+======================
+
+Released on 2012/01/29.
+
+* This is the first public release of the Lutok package.
diff -r 43fa2f1689f1 -r b66a622044f2 external/bsd/lutok/dist/README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/lutok/dist/README Sat Feb 16 15:06:52 2013 +0000
@@ -0,0 +1,27 @@
+Lutok is a lightweight C++ API library for Lua.
+
+Lutok provides thin C++ wrappers around the Lua C API to ease the
+interaction between C++ and Lua. These wrappers make intensive use of
+RAII to prevent resource leakage, expose C++-friendly data types, report
+errors by means of exceptions and ensure that the Lua stack is always
+left untouched in the face of errors. The library also provides a small
+subset of miscellaneous utility functions built on top of the wrappers.
+
+Lutok focuses on providing a clean and safe C++ interface; the drawback
+is that it is not suitable for performance-critical environments. In
+order to implement error-safe C++ wrappers on top of a Lua C binary
+library, Lutok adds several layers or abstraction and error checking
+that go against the original spirit of the Lua C API and thus degrade
+performance.
+
+For further information on the contents of this distribution file,
+please refer to the following other documents:
+
+* AUTHORS: List of authors and contributors to this project.
+* COPYING: License information.
+* INSTALL: Compilation and installation instructions.
+* NEWS: List of major changes between formal releases.
+
+For general project information, please visit:
+
+ http://code.google.com/p/lutok/
diff -r 43fa2f1689f1 -r b66a622044f2 external/bsd/lutok/dist/c_gate.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/lutok/dist/c_gate.cpp Sat Feb 16 15:06:52 2013 +0000
@@ -0,0 +1,76 @@
+// Copyright 2011 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Google Inc. nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// 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.
+
+#include "c_gate.hpp"
+#include "state.ipp"
+
+
+/// Creates a new gateway to an existing C++ Lua state.
+///
+/// \param state_ The state to connect to. This object must remain alive while
+/// the newly-constructed state_c_gate is alive.
+lutok::state_c_gate::state_c_gate(state& state_) :
+ _state(state_)
+{
+}
+
+
+/// Destructor.
+///
+/// Destroying this object has no implications on the life cycle of the Lua
+/// state. Only the corresponding state object controls when the Lua state is
+/// closed.
+lutok::state_c_gate::~state_c_gate(void)
+{
+}
+
+
+/// Creates a C++ state for a C Lua state.
+///
+/// \warning The created state object does NOT own the C state. You must take
+/// care to properly destroy the input lua_State when you are done with it to
+/// not leak resources.
+///
+/// \param raw_state The raw state to wrap temporarily.
+///
+/// \return The wrapped state without strong ownership on the input state.
+lutok::state
+lutok::state_c_gate::connect(lua_State* raw_state)
+{
+ return state(static_cast< void* >(raw_state));
+}
+
+
+/// Returns the C native Lua state.
+///
+/// \return A native lua_State object holding the Lua C API state.
+lua_State*
+lutok::state_c_gate::c_state(void)
+{
+ return static_cast< lua_State* >(_state.raw_state());
+}
diff -r 43fa2f1689f1 -r b66a622044f2 external/bsd/lutok/dist/c_gate.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/lutok/dist/c_gate.hpp Sat Feb 16 15:06:52 2013 +0000
@@ -0,0 +1,71 @@
+// Copyright 2011 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Google Inc. nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// 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.
+
+/// \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 lutok {
+
+
+class state;
+
+
+/// Gateway to the raw C state of Lua.
+///
+/// This class provides a mechanism to muck with the internals of the state
+/// wrapper class. Client code may wish to do so if Lutok is missing some
+/// features of the performance of Lutok in a particular situation is not
+/// reasonable.
+///
+/// \warning The use of this class is discouraged. By using this class, you are
+/// entering the world of unsafety. Anything you do through the objects exposed
+/// through this class will not be controlled by RAII patterns not validated in
+/// any other way, so you can end up corrupting the Lua state and later get
+/// crashes on otherwise perfectly-valid C++ code.
+class state_c_gate {
+ /// The C++ state that this class wraps.
+ state& _state;
+
+public:
+ state_c_gate(state&);
+ ~state_c_gate(void);
+
+ static state connect(lua_State*);
+
+ lua_State* c_state(void);
+};
+
+
+} // namespace lutok
+
+#endif // !defined(LUTOK_C_GATE_HPP)
diff -r 43fa2f1689f1 -r b66a622044f2 external/bsd/lutok/dist/c_gate_test.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/lutok/dist/c_gate_test.cpp Sat Feb 16 15:06:52 2013 +0000
@@ -0,0 +1,74 @@
+// Copyright 2011 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Google Inc. nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Home |
Main Index |
Thread Index |
Old Index