[nemiver] Fix tr1 and pty.h compilation issues
- From: Dodji Seketeli <dodji src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver] Fix tr1 and pty.h compilation issues
- Date: Wed, 9 Jul 2014 11:06:29 +0000 (UTC)
commit 769da0d4d5173e12b3c92a3c806db502f7819a8a
Author: Juan R. GarcĂa Blanco <juanrgar gmail com>
Date: Mon Jan 6 17:40:00 2014 +0100
Fix tr1 and pty.h compilation issues
* configure.ac: Check for tr1/unordered_map, tr1/memory
and tr1/tuple, and their boost::tr1 counterparts.
Check for pty.h, util.h and libutil.h.
* src/common/nmv-log-stream.cc: Replace checks on compiler
defined macros with checks for required headers; in this
case tr1/unordered_map and boost/tr1/unordered_map.hpp.
* src/dbgengine/nmv-dbg-common.h: Check whether tr1/memory
or boost/tr1/memory.hpp is available and use accordingly.
* src/dbgengine/nmv-var-list-walker.cc (SafePtrCmp::operator()):
Compare method const-correctness.
* src/dbgengine/nmv-var-walker.cc (SafePtrCmp::operator()):
Compare method const-correctness.
* src/langs/nmv-cpp-ast.h: Replace checks on compiler
defined macros with checks for required headers; in this
case tr1/memory and boost/tr1/memory.hpp.
Rearrange various class definitions to make the compiler
aware of the class hierarchy ahead of forward-declaring
shared_ptr typedefs.
* src/persp/dbgperspective/nmv-find-text-dialog.h: Use
SafePtr, ObjectRef and ObjectUnref from nemiver::common.
* src/uicommon/nmv-terminal.cc: Check whether tr1/tuple or
boost/tr1/tuple.hpp is available and use accordingly.
Replace checks on platform defined macros with checks for
required headers; in this case pty.h, util.h and libutil.h.
* src/common/nmv-proc-utils.cc: Replace checks on
platform defined macros with checks for required headers;
in this case pty.h, util.h and libutil.h.
configure.ac | 10 +
src/common/nmv-log-stream.cc | 6 +-
src/common/nmv-proc-utils.cc | 8 +-
src/dbgengine/nmv-dbg-common.h | 4 +
src/dbgengine/nmv-var-list-walker.cc | 2 +-
src/dbgengine/nmv-var-walker.cc | 2 +-
src/langs/nmv-cpp-ast.h | 401 ++++++++++++-----------
src/persp/dbgperspective/nmv-find-text-dialog.h | 6 +-
src/uicommon/nmv-terminal.cc | 12 +-
9 files changed, 234 insertions(+), 217 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8b1f93f..b2fdbc7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -270,6 +270,16 @@ if test x$GLIBMM_USES_DEPRECATED_GLIB_FUNCS = xyes; then
AC_MSG_NOTICE(glibmm uses deprecated glib functions!)
fi
+dnl Check for tr1 headers
+AC_CHECK_HEADERS([tr1/unordered_map boost/tr1/unordered_map.hpp])
+AC_CHECK_HEADERS([tr1/memory boost/tr1/memory.hpp])
+AC_CHECK_HEADERS([tr1/tuple boost/tr1/tuple.hpp])
+
+dnl Check for pty.h and its alternatives
+dnl https://www.gnu.org/software/gnulib/manual/html_node/pty_002eh.html
+AC_CHECK_HEADERS([pty.h util.h libutil.h])
+
+
#######################################################
#boost build system sucks no end.
#it is damn hard to detect the version of boost
diff --git a/src/common/nmv-log-stream.cc b/src/common/nmv-log-stream.cc
index 0914a46..6822de1 100644
--- a/src/common/nmv-log-stream.cc
+++ b/src/common/nmv-log-stream.cc
@@ -43,8 +43,10 @@
#include "nmv-date-utils.h"
#include "nmv-safe-ptr-utils.h"
-#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 2
+#if defined(HAVE_TR1_UNORDERED_MAP)
#include <tr1/unordered_map>
+#elif defined(HAVE_BOOST_TR1_UNORDERED_MAP_HPP)
+#include <boost/tr1/unordered_map.hpp>
#else
#include <ext/hash_map>
@@ -64,7 +66,7 @@ namespace common {
using namespace std;
-#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 2
+#if defined(HAVE_TR1_UNORDERED_MAP) || defined(HAVE_BOOST_TR1_UNORDERED_MAP_HPP)
typedef std::tr1::unordered_map<std::string, bool> DomainMap;
#else
typedef __gnu_cxx::hash_map<std::string, bool> DomainMap;
diff --git a/src/common/nmv-proc-utils.cc b/src/common/nmv-proc-utils.cc
index cfa8d2a..0d99a55 100644
--- a/src/common/nmv-proc-utils.cc
+++ b/src/common/nmv-proc-utils.cc
@@ -28,13 +28,13 @@
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
-#if defined(_GNU_SOURCE)
+#if defined(HAVE_PTY_H)
# include <pty.h>
-#elif defined(__FreeBSD__)
+#elif defined(HAVE_LIBUTIL_H)
# include <sys/types.h>
# include <sys/ioctl.h>
# include <libutil.h>
-#elif defined(__OpenBSD__)
+#elif defined(HAVE_UTIL_H)
#include <util.h>
#endif
#include <termios.h>
@@ -45,7 +45,7 @@
#include "nmv-exception.h"
#include "nmv-log-stream-utils.h"
-#if (defined(__FreeBSD__) || defined(__OpenBSD__)) && !defined(__MAX_BAUD)
+#if !defined(__MAX_BAUD)
#define __MAX_BAUD B38400
#endif
diff --git a/src/dbgengine/nmv-dbg-common.h b/src/dbgengine/nmv-dbg-common.h
index 2645e84..ad3cc00 100644
--- a/src/dbgengine/nmv-dbg-common.h
+++ b/src/dbgengine/nmv-dbg-common.h
@@ -27,7 +27,11 @@
#ifndef __NMV_DBG_COMMON_H_H__
#define __NMV_DBG_COMMON_H_H__
#include "nmv-i-debugger.h"
+#if defined(HAVE_TR1_MEMORY)
#include <tr1/memory>
+#elif defined(HAVE_BOOST_TR1_MEMORY_HPP)
+#include <boost/tr1/memory.hpp>
+#endif
NEMIVER_BEGIN_NAMESPACE (nemiver)
diff --git a/src/dbgengine/nmv-var-list-walker.cc b/src/dbgengine/nmv-var-list-walker.cc
index bd63559..ea53dc2 100644
--- a/src/dbgengine/nmv-var-list-walker.cc
+++ b/src/dbgengine/nmv-var-list-walker.cc
@@ -31,7 +31,7 @@ NEMIVER_BEGIN_NAMESPACE (nemiver)
struct SafePtrCmp {
bool operator() (const IVarWalkerSafePtr l,
- const IVarWalkerSafePtr r)
+ const IVarWalkerSafePtr r) const
{
return (l.get () < r.get ());
}
diff --git a/src/dbgengine/nmv-var-walker.cc b/src/dbgengine/nmv-var-walker.cc
index 2059b88..964b6ea 100644
--- a/src/dbgengine/nmv-var-walker.cc
+++ b/src/dbgengine/nmv-var-walker.cc
@@ -52,7 +52,7 @@ get_sequence ()
struct SafePtrCmp {
bool operator() (const IDebugger::VariableSafePtr l,
- const IDebugger::VariableSafePtr r)
+ const IDebugger::VariableSafePtr r) const
{
return (l.get () < r.get ());
}
diff --git a/src/langs/nmv-cpp-ast.h b/src/langs/nmv-cpp-ast.h
index 98314d3..321f735 100644
--- a/src/langs/nmv-cpp-ast.h
+++ b/src/langs/nmv-cpp-ast.h
@@ -25,11 +25,12 @@
#ifndef __NMV_CPP_AST_H__
#define __NMV_CPP_AST_H__
+#include "config.h"
#include <string>
#include <list>
-#if __GNUC__ >= 4
+#if defined(HAVE_TR1_MEMORY)
#include <tr1/memory>
-#else
+#elif defined(HAVE_BOOST_TR1_MEMORY_HPP)
#include <boost/tr1/memory.hpp>
#endif
#include "common/nmv-namespace.h"
@@ -174,6 +175,204 @@ bool to_string (const TypeIDPtr, string &);
bool to_string (const UnqualifiedIDExprPtr, string &);
UnqualifiedIDPtr create_unqualified_id (const string &);
+/// the base class of all expressions
+class NEMIVER_API ExprBase {
+ ExprBase (const ExprBase&);
+ ExprBase& operator= (const ExprBase&);
+ ExprBase ();
+
+public:
+ enum Kind {
+ UNDEFINED=0,
+ PRIMARY_EXPRESSION,
+ CONDITIONAL_EXPRESSION,
+ ASSIGNMENT_EXPRESION,
+ THROW_EXPRESSION,
+ UNARY_EXPRESSION,
+ CAST_EXPRESSION,
+ PM_EXPRESSION,
+ MULT_EXPR,
+ ADD_EXPR,
+ SHIFT_EXPR,
+ RELATIONAL_EXPR,
+ EQUALITY_EXPR,
+ AND_EXPR,
+ XOR_EXPR,
+ INCL_OR_EXPR,
+ LOGICAL_AND_EXPR,
+ LOGICAL_OR_EXPR,
+ COND_EXPR,
+ ASSIGNMENT_EXPR,
+ ASSIGNMENT_LIST
+ };
+
+ enum Operator {
+ OP_UNDEFINED,
+ MULT,
+ DIV,
+ MOD,
+ PLUS,
+ MINUS,
+ LT,
+ GT,
+ LT_OR_EQ,
+ GT_OR_EQ,
+ LEFT_SHIFT,
+ RIGHT_SHIFT,
+ ASSIGN,
+ MULT_EQ,
+ DIV_EQ,
+ MOD_EQ,
+ PLUS_EQ,
+ MINUS_EQ,
+ RIGHT_SHIFT_EQ,
+ LEFT_SHIFT_EQ,
+ AND_EQ,
+ XOR_EQ,
+ OR_EQ,
+ EQUALS,
+ NOT_EQUALS,
+ BIT_AND,
+ LOG_AND,
+ LOG_OR
+ };
+
+private:
+ Kind m_kind;
+
+public:
+ ExprBase (Kind a_kind) :
+ m_kind (a_kind)
+ {
+ }
+ virtual ~ExprBase () {}
+ Kind get_kind () {return m_kind;}
+ virtual bool to_string (string &) const=0;
+ static const string& operator_to_string (Operator);
+};//end class ExprBase
+typedef shared_ptr<ExprBase> ExprBasePtr;
+
+class NEMIVER_API PrimaryExpr : public ExprBase {
+ PrimaryExpr (const PrimaryExpr&);
+ PrimaryExpr& operator= (const PrimaryExpr&);
+
+public:
+ enum Kind {
+ UNDEFINED,
+ LITERAL,
+ THIS,
+ PARENTHESIZED,
+ ID_EXPR,
+ };
+
+private:
+ Kind m_kind;
+ Token m_token;
+ IDExprPtr m_id_expr;
+ ExprBasePtr m_parenthesized;
+
+public:
+ PrimaryExpr () :
+ ExprBase (PRIMARY_EXPRESSION), m_kind (UNDEFINED)
+ {}
+ PrimaryExpr (Kind k) :
+ ExprBase (PRIMARY_EXPRESSION),
+ m_kind (k)
+ {}
+ ~PrimaryExpr () {}
+ Kind get_kind () const {return m_kind;}
+ void set_kind (Kind kind) {m_kind=kind;}
+ void set_token (Kind kind, const Token &token) {m_kind=kind, m_token=token;}
+ const Token& get_token () const {return m_token;}
+ void set_id_expr (IDExprPtr id_expr) {m_kind=ID_EXPR, m_id_expr=id_expr;}
+ const IDExprPtr get_id_expr () const {return m_id_expr;}
+ void set_parenthesized (ExprBasePtr expr)
+ {
+ m_kind=PARENTHESIZED, m_parenthesized=expr;
+ }
+ const ExprBasePtr get_parenthesized () const {return m_parenthesized;}
+};//end class PrimaryExpr
+typedef shared_ptr<PrimaryExpr> PrimaryExprPtr;
+
+class NEMIVER_API IDExpr : public PrimaryExpr {
+ IDExpr (const IDExpr&);
+ IDExpr& operator= (const IDExpr&);
+ IDExpr ();
+
+public:
+ enum Kind {
+ UNDEFINED,
+ QUALIFIED,
+ UNQUALIFIED
+ };
+
+private:
+ Kind m_kind;
+
+public:
+ IDExpr (Kind kind) :
+ PrimaryExpr (ID_EXPR),
+ m_kind (kind)
+ {
+ }
+ ~IDExpr ();
+ Kind get_kind () const {return m_kind;}
+};//end class ExprBase
+
+class NEMIVER_API UnqualifiedIDExpr : public IDExpr {
+ UnqualifiedIDExpr (const UnqualifiedIDExpr&);
+ UnqualifiedIDExpr& operator= (const UnqualifiedIDExpr&);
+
+public:
+ enum Kind {
+ UNDEFINED,
+ IDENTIFIER,
+ OP_FUNC_ID,
+ CONV_FUNC_ID, //TODO:not supported yet
+ DESTRUCTOR_ID,
+ TEMPLATE_ID
+ };
+
+private:
+ Kind m_kind;
+
+public:
+ UnqualifiedIDExpr () :
+ IDExpr (UNQUALIFIED),
+ m_kind (UNDEFINED)
+ {
+ }
+
+ UnqualifiedIDExpr (Kind kind) :
+ IDExpr (UNQUALIFIED),
+ m_kind (kind)
+
+ {
+ }
+ Kind get_kind () const {return m_kind;}
+ void set_kind (Kind kind) {m_kind=kind;}
+ virtual ~UnqualifiedIDExpr () {}
+ virtual bool to_string (string &) const=0;
+};//end class UnqualifiedIDExpr
+
+class NEMIVER_API UnqualifiedID : public UnqualifiedIDExpr {
+ string m_name;
+
+public:
+ UnqualifiedID ():
+ UnqualifiedIDExpr (UnqualifiedIDExpr::IDENTIFIER)
+ {}
+ UnqualifiedID (const string &a_s):
+ UnqualifiedIDExpr (UnqualifiedIDExpr::IDENTIFIER),
+ m_name (a_s)
+ {}
+ ~UnqualifiedID ()
+ {}
+ const string& get_name () const {return m_name;}
+ void set_name (const string &a_n) {m_name=a_n;}
+ bool to_string (string &a_s) const;
+};
+
/// \brief Qualified Name.
///
/// can contain the result of the parsing of
@@ -432,128 +631,9 @@ public:
};//end SimpleDeclaration
typedef shared_ptr<SimpleDeclaration> SimpleDeclarationPtr;
-/// the base class of all expressions
-class NEMIVER_API ExprBase {
- ExprBase (const ExprBase&);
- ExprBase& operator= (const ExprBase&);
- ExprBase ();
-
-public:
- enum Kind {
- UNDEFINED=0,
- PRIMARY_EXPRESSION,
- CONDITIONAL_EXPRESSION,
- ASSIGNMENT_EXPRESION,
- THROW_EXPRESSION,
- UNARY_EXPRESSION,
- CAST_EXPRESSION,
- PM_EXPRESSION,
- MULT_EXPR,
- ADD_EXPR,
- SHIFT_EXPR,
- RELATIONAL_EXPR,
- EQUALITY_EXPR,
- AND_EXPR,
- XOR_EXPR,
- INCL_OR_EXPR,
- LOGICAL_AND_EXPR,
- LOGICAL_OR_EXPR,
- COND_EXPR,
- ASSIGNMENT_EXPR,
- ASSIGNMENT_LIST
- };
-
- enum Operator {
- OP_UNDEFINED,
- MULT,
- DIV,
- MOD,
- PLUS,
- MINUS,
- LT,
- GT,
- LT_OR_EQ,
- GT_OR_EQ,
- LEFT_SHIFT,
- RIGHT_SHIFT,
- ASSIGN,
- MULT_EQ,
- DIV_EQ,
- MOD_EQ,
- PLUS_EQ,
- MINUS_EQ,
- RIGHT_SHIFT_EQ,
- LEFT_SHIFT_EQ,
- AND_EQ,
- XOR_EQ,
- OR_EQ,
- EQUALS,
- NOT_EQUALS,
- BIT_AND,
- LOG_AND,
- LOG_OR
- };
-
-private:
- Kind m_kind;
-
-public:
- ExprBase (Kind a_kind) :
- m_kind (a_kind)
- {
- }
- virtual ~ExprBase () {}
- Kind get_kind () {return m_kind;}
- virtual bool to_string (string &) const=0;
- static const string& operator_to_string (Operator);
-};//end class ExprBase
-typedef shared_ptr<ExprBase> ExprBasePtr;
-
class Expr;
typedef shared_ptr<Expr> ExprPtr;
-class NEMIVER_API PrimaryExpr : public ExprBase {
- PrimaryExpr (const PrimaryExpr&);
- PrimaryExpr& operator= (const PrimaryExpr&);
-
-public:
- enum Kind {
- UNDEFINED,
- LITERAL,
- THIS,
- PARENTHESIZED,
- ID_EXPR,
- };
-
-private:
- Kind m_kind;
- Token m_token;
- IDExprPtr m_id_expr;
- ExprBasePtr m_parenthesized;
-
-public:
- PrimaryExpr () :
- ExprBase (PRIMARY_EXPRESSION), m_kind (UNDEFINED)
- {}
- PrimaryExpr (Kind k) :
- ExprBase (PRIMARY_EXPRESSION),
- m_kind (k)
- {}
- ~PrimaryExpr () {}
- Kind get_kind () const {return m_kind;}
- void set_kind (Kind kind) {m_kind=kind;}
- void set_token (Kind kind, const Token &token) {m_kind=kind, m_token=token;}
- const Token& get_token () const {return m_token;}
- void set_id_expr (IDExprPtr id_expr) {m_kind=ID_EXPR, m_id_expr=id_expr;}
- const IDExprPtr get_id_expr () const {return m_id_expr;}
- void set_parenthesized (ExprBasePtr expr)
- {
- m_kind=PARENTHESIZED, m_parenthesized=expr;
- }
- const ExprBasePtr get_parenthesized () const {return m_parenthesized;}
-};//end class PrimaryExpr
-typedef shared_ptr<PrimaryExpr> PrimaryExprPtr;
-
class NEMIVER_API LiteralPrimaryExpr : public PrimaryExpr {
LiteralPrimaryExpr (const LiteralPrimaryExpr&);
LiteralPrimaryExpr& operator= (const LiteralPrimaryExpr&);
@@ -687,85 +767,6 @@ public:
}
};//end class TemplateID
-class NEMIVER_API IDExpr : public PrimaryExpr {
- IDExpr (const IDExpr&);
- IDExpr& operator= (const IDExpr&);
- IDExpr ();
-
-public:
- enum Kind {
- UNDEFINED,
- QUALIFIED,
- UNQUALIFIED
- };
-
-private:
- Kind m_kind;
-
-public:
- IDExpr (Kind kind) :
- PrimaryExpr (ID_EXPR),
- m_kind (kind)
- {
- }
- ~IDExpr ();
- Kind get_kind () const {return m_kind;}
-};//end class ExprBase
-
-class NEMIVER_API UnqualifiedIDExpr : public IDExpr {
- UnqualifiedIDExpr (const UnqualifiedIDExpr&);
- UnqualifiedIDExpr& operator= (const UnqualifiedIDExpr&);
-
-public:
- enum Kind {
- UNDEFINED,
- IDENTIFIER,
- OP_FUNC_ID,
- CONV_FUNC_ID, //TODO:not supported yet
- DESTRUCTOR_ID,
- TEMPLATE_ID
- };
-
-private:
- Kind m_kind;
-
-public:
- UnqualifiedIDExpr () :
- IDExpr (UNQUALIFIED),
- m_kind (UNDEFINED)
- {
- }
-
- UnqualifiedIDExpr (Kind kind) :
- IDExpr (UNQUALIFIED),
- m_kind (kind)
-
- {
- }
- Kind get_kind () const {return m_kind;}
- void set_kind (Kind kind) {m_kind=kind;}
- virtual ~UnqualifiedIDExpr () {}
- virtual bool to_string (string &) const=0;
-};//end class UnqualifiedIDExpr
-
-class NEMIVER_API UnqualifiedID : public UnqualifiedIDExpr {
- string m_name;
-
-public:
- UnqualifiedID ():
- UnqualifiedIDExpr (UnqualifiedIDExpr::IDENTIFIER)
- {}
- UnqualifiedID (const string &a_s):
- UnqualifiedIDExpr (UnqualifiedIDExpr::IDENTIFIER),
- m_name (a_s)
- {}
- ~UnqualifiedID ()
- {}
- const string& get_name () const {return m_name;}
- void set_name (const string &a_n) {m_name=a_n;}
- bool to_string (string &a_s) const;
-};
-
class UnqualifiedOpFuncID : public UnqualifiedIDExpr {
UnqualifiedOpFuncID (const UnqualifiedOpFuncID&);
UnqualifiedOpFuncID& operator= (const UnqualifiedOpFuncID&);
diff --git a/src/persp/dbgperspective/nmv-find-text-dialog.h b/src/persp/dbgperspective/nmv-find-text-dialog.h
index a16c1c7..63fd1ea 100644
--- a/src/persp/dbgperspective/nmv-find-text-dialog.h
+++ b/src/persp/dbgperspective/nmv-find-text-dialog.h
@@ -31,11 +31,9 @@ NEMIVER_BEGIN_NAMESPACE (nemiver)
class SourceEditor;
class FindTextDialog;
-class ObjectRef;
-class ObjectUnref;
-template <class A, class B, class C> class SafePtr;
+using nemiver::common::SafePtr;
-typedef SafePtr<FindTextDialog, ObjectRef, ObjectUnref> FindTextDialogSafePtr;
+typedef SafePtr<FindTextDialog, common::ObjectRef, common::ObjectUnref> FindTextDialogSafePtr;
class FindTextDialog : public Dialog {
class Priv;
diff --git a/src/uicommon/nmv-terminal.cc b/src/uicommon/nmv-terminal.cc
index 8ba9139..d24f1ab 100644
--- a/src/uicommon/nmv-terminal.cc
+++ b/src/uicommon/nmv-terminal.cc
@@ -24,21 +24,23 @@
*/
#include "config.h"
#include "nmv-terminal.h"
-#if !(defined(__FreeBSD__) || defined(__OpenBSD__))
+#if defined(HAVE_PTY_H)
# include <pty.h>
-#else
+#elif defined (HAVE_LIBUTIL_H)
# include <sys/types.h>
# include <sys/ioctl.h>
# include <termios.h>
-#if defined(__FreeBSD__)
# include <libutil.h>
-#else
+#elif defined(HAVE_UTIL_H)
# include <util.h>
#endif
-#endif
#include <unistd.h>
#include <iostream>
+#if defined(HAVE_TR1_TUPLE)
#include <tr1/tuple>
+#elif defined(HAVE_BOOST_TR1_TUPLE_HPP)
+#include <boost/tr1/tuple.hpp>
+#endif
#include <gtkmm/bin.h>
#include <gtkmm/main.h>
#include <gtkmm/window.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]