// Copyright 2011 Google Inc.1// All rights reserved.2//3// Redistribution and use in source and binary forms, with or without4// modification, are permitted provided that the following conditions are5// met:6//7// * Redistributions of source code must retain the above copyright8// notice, this list of conditions and the following disclaimer.9// * Redistributions in binary form must reproduce the above copyright10// notice, this list of conditions and the following disclaimer in the11// documentation and/or other materials provided with the distribution.12// * Neither the name of Google Inc. nor the names of its contributors13// may be used to endorse or promote products derived from this software14// without specific prior written permission.15//16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2728/// \file debug.hpp29/// Provides the debug wrapper class for the Lua C debug state.3031#if !defined(LUTOK_DEBUG_HPP)32#define LUTOK_DEBUG_HPP3334#include <string>35#if defined(_LIBCPP_VERSION) || __cplusplus >= 201103L36#include <memory>37#else38#include <tr1/memory>39#endif4041namespace lutok {424344class state;454647/// A model for the Lua debug state.48///49/// This extremely-simple class provides a mechanism to hide the internals of50/// the C native lua_Debug type, exposing its internal fields using friendlier51/// C++ types.52///53/// This class also acts as a complement to the state class by exposing any54/// state-related functions as methods of this function. For example, while it55/// might seem that get_info() belongs in state, we expose it from here because56/// its result is really mutating a debug object, not the state object.57class debug {58struct impl;5960/// Pointer to the shared internal implementation.61#if defined(_LIBCPP_VERSION) || __cplusplus >= 201103L62std::shared_ptr< impl > _pimpl;63#else64std::tr1::shared_ptr< impl > _pimpl;65#endif6667public:68debug(void);69~debug(void);7071void get_info(state&, const std::string&);72void get_stack(state&, const int);7374int event(void) const;75std::string name(void) const;76std::string name_what(void) const;77std::string what(void) const;78std::string source(void) const;79int current_line(void) const;80int n_ups(void) const;81int line_defined(void) const;82int last_line_defined(void) const;83std::string short_src(void) const;84};858687} // namespace lutok8889#endif // !defined(LUTOK_DEBUG_HPP)909192