[beagle] Enable building with mono-2.8 (#632282)



commit 43e1ecdf231c36edd10381559ede9ea21e534ea6
Author: Alexandre Rostovtsev <tetromino gmail com>
Date:   Sat Oct 16 03:46:10 2010 -0400

    Enable building with mono-2.8 (#632282)
    
    1. mono-2.8 uses mono-2.pc instead of mono.pc for setting cflags and
    libs; need to modify configure.in accordingly.
    2. mono-2.8 disables direct access to struct MonoType fields; use
    accessors instead (mono_type_get_type and mono_field_get_flags have
    been present in the API since at least mono-1.2, so we do not need any
    version ifdefs).
    3. Cast FSpot.MetadataStore to IEnumerable in foreach() to prevent
    CS1640 errors (non-unique enumeration of the type) with mono-2.8's gmcs.
    4. Fix incorrect capitalization of SQLiteErrorCode introduced in commit
    6710bab0c8e35ed2f6ebf7064c066e16da1602d8; for verification, see
    http://github.com/mono/mono/blob/master/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteException.cs
    
    Signed-off-by: Alexandre Rostovtsev <tetromino gmail com>

 beagle/Filters/FilterImage.cs |    4 ++--
 beagle/Filters/FilterPdf.cs   |    5 +++--
 beagle/Util/FSpotTools.cs     |    2 +-
 beagle/beagled/SqliteUtils.cs |    8 ++++----
 beagle/configure.in           |   25 +++++++++++++++++--------
 beagle/glue/mono-glue.c       |    6 +++---
 6 files changed, 30 insertions(+), 20 deletions(-)
---
diff --git a/beagle/Filters/FilterImage.cs b/beagle/Filters/FilterImage.cs
index d5ad2f0..75f80ce 100644
--- a/beagle/Filters/FilterImage.cs
+++ b/beagle/Filters/FilterImage.cs
@@ -141,7 +141,7 @@ namespace Beagle.Filters {
 			Resource rights_anon = null;
 			Resource title_anon = null;
 
-			foreach (Statement stmt in xmp.Store) {
+			foreach (Statement stmt in (IEnumerable)xmp.Store) {
 				if (stmt.Predicate == MetadataStore.Namespaces.Resolve ("dc:subject")) {
 					//Console.WriteLine ("found subject");
 					subject_anon = stmt.Object;
@@ -163,7 +163,7 @@ namespace Beagle.Filters {
 				}
 			}
 			
-			foreach (Statement stmt in xmp.Store) {
+			foreach (Statement stmt in (IEnumerable)xmp.Store) {
 				if (stmt.Subject == subject_anon && 
 				    stmt.Predicate != MetadataStore.Namespaces.Resolve ("rdf:type")) {
 					AddProperty (Beagle.Property.New ("dc:subject", ((Literal)stmt.Object).Value));
diff --git a/beagle/Filters/FilterPdf.cs b/beagle/Filters/FilterPdf.cs
index 4b10fc9..dbb42a5 100644
--- a/beagle/Filters/FilterPdf.cs
+++ b/beagle/Filters/FilterPdf.cs
@@ -8,6 +8,7 @@
 //
 
 using System;
+using System.Collections;
 using System.IO;
 using System.Diagnostics;
 
@@ -220,7 +221,7 @@ namespace Beagle.Filters {
 			Resource rights_anon = null;
 			Resource title_anon = null;
 
-			foreach (Statement stmt in xmp.Store) {
+			foreach (Statement stmt in (IEnumerable)xmp.Store) {
 				if (stmt.Predicate == MetadataStore.Namespaces.Resolve ("dc:subject")) {
 					//Console.WriteLine ("found subject");
 					subject_anon = stmt.Object;
@@ -239,7 +240,7 @@ namespace Beagle.Filters {
 				}
 			}
 			
-			foreach (Statement stmt in xmp.Store) {
+			foreach (Statement stmt in (IEnumerable)xmp.Store) {
 				if (stmt.Subject == subject_anon && 
 				    stmt.Predicate != MetadataStore.Namespaces.Resolve ("rdf:type")) {
 					AddProperty (Beagle.Property.New ("dc:subject", ((Literal)stmt.Object).Value));
diff --git a/beagle/Util/FSpotTools.cs b/beagle/Util/FSpotTools.cs
index bc95865..82f7752 100644
--- a/beagle/Util/FSpotTools.cs
+++ b/beagle/Util/FSpotTools.cs
@@ -86,7 +86,7 @@ namespace Beagle.Util {
 								try {
 									reader = command.ExecuteReader ();
 								} catch (SqliteException e) {
-									if (e.ErrorCode == SqliteErrorCode.Busy) {
+									if (e.ErrorCode == SQLiteErrorCode.Busy) {
 										Thread.Sleep (50);
 									} else {
 										throw;
diff --git a/beagle/beagled/SqliteUtils.cs b/beagle/beagled/SqliteUtils.cs
index eca1d52..f747db5 100644
--- a/beagle/beagled/SqliteUtils.cs
+++ b/beagle/beagled/SqliteUtils.cs
@@ -56,7 +56,7 @@ namespace Beagle.Util {
 						ret = command.ExecuteNonQuery ();
 						break;
 					} catch (SqliteException ex) {
-						if (ex.ErrorCode == SqliteErrorCode.Busy) {
+						if (ex.ErrorCode == SQLiteErrorCode.Busy) {
 							Thread.Sleep (50);
 						} else {
 							Log.Error (ex, "SQL that caused the exception: {0}", command_text);
@@ -85,7 +85,7 @@ namespace Beagle.Util {
 					ret = command.ExecuteNonQuery ();
 					break;
 				} catch (SqliteException ex) {
-					if (ex.ErrorCode == SqliteErrorCode.Busy) {
+					if (ex.ErrorCode == SQLiteErrorCode.Busy) {
 						Thread.Sleep (50);
 					} else {
 						Log.Error (ex, "SQL that caused the exception: {0}", command.CommandText);
@@ -107,7 +107,7 @@ namespace Beagle.Util {
 				try {
 					reader = command.ExecuteReader ();
 				} catch (SqliteException ex) {
-					if (ex.ErrorCode == SqliteErrorCode.Busy) {
+					if (ex.ErrorCode == SQLiteErrorCode.Busy) {
 						Thread.Sleep (50);
 					} else {
 						throw;
@@ -123,7 +123,7 @@ namespace Beagle.Util {
 				try {
 					return reader.Read ();
 				} catch (SqliteException ex) {
-					if (ex.ErrorCode == SqliteErrorCode.Busy) {
+					if (ex.ErrorCode == SQLiteErrorCode.Busy) {
 						Thread.Sleep (50);
 					} else {
 						throw;
diff --git a/beagle/configure.in b/beagle/configure.in
index e0122a0..31fabe5 100644
--- a/beagle/configure.in
+++ b/beagle/configure.in
@@ -59,11 +59,20 @@ if test "x$MCS" = "xno"; then
 	AC_MSG_ERROR([You need to install the Mono gmcs compiler])
 fi
 
-AC_MSG_CHECKING([for mono.pc])
-if test -z `$PKG_CONFIG --variable=prefix mono`; then
-  AC_MSG_ERROR([missing the mono.pc file, usually found in the mono-devel package])
+# mono-2.8 and higher uses mono-2.pc instead of mono.pc for cflags and libs
+AC_MSG_CHECKING([for mono-2.pc])
+if test -z `$PKG_CONFIG --variable=prefix mono-2`; then
+  AC_MSG_RESULT([not found])
+  AC_MSG_CHECKING([for mono.pc])
+  if test -z `$PKG_CONFIG --variable=prefix mono`; then
+    AC_MSG_ERROR([missing the mono.pc file, usually found in the mono-devel package])
+  else
+    AC_MSG_RESULT([found])
+    mono_pc=mono
+  fi
 else
   AC_MSG_RESULT([found])
+  mono_pc=mono-2
 fi
 
 BEAGLE_DEFINES=""
@@ -71,10 +80,10 @@ BEAGLE_DEFINES=""
 # check that we have the require version of mono
 
 # Temporary: check for mono-1.9
-PKG_CHECK_MODULES(MONO, mono >= 1.9, mono_1_9=yes, mono_1_9=no) 
+PKG_CHECK_MODULES(MONO, $mono_pc >= 1.9, mono_1_9=yes, mono_1_9=no)
 if test "x$mono_1_9" = "xno"; then
 	AC_MSG_RESULT([missing mono >= 1.9. Searching for mono >= 1.2.4])
-	PKG_CHECK_MODULES(MONO, mono >= $MONO_REQUIRED) 
+	PKG_CHECK_MODULES(MONO, $mono_pc >= $MONO_REQUIRED)
 else
 	AC_MSG_RESULT([found mono >= 1.9])
 	BEAGLE_DEFINES="$BEAGLE_DEFINES -define:MONO_1_9"
@@ -84,7 +93,7 @@ fi
 needed_dlls="Mono.Data.Sqlite Mono.Posix System.Data System.Web ICSharpCode.SharpZipLib"
 for i in $needed_dlls; do
   AC_MSG_CHECKING([for $i.dll])
-  if test ! -e `$PKG_CONFIG --variable=prefix mono`/lib/mono/2.0/$i.dll; then
+  if test ! -e `$PKG_CONFIG --variable=prefix $mono_pc`/lib/mono/2.0/$i.dll; then
     AC_MSG_ERROR([missing required mono DLL: $i.dll])
   else
     AC_MSG_RESULT([found])
@@ -195,7 +204,7 @@ AM_CONDITIONAL(ENABLE_GOOGLEBACKENDS, test "x$enable_google" = "xyes")
 if test "x$enable_google" = "xyes"; then
   i="System.Security"
   AC_MSG_CHECKING([for $i.dll (needed by Google backends)])
-  if test ! -e `$PKG_CONFIG --variable=prefix mono`/lib/mono/2.0/$i.dll; then
+  if test ! -e `$PKG_CONFIG --variable=prefix $mono_pc`/lib/mono/2.0/$i.dll; then
     AC_MSG_ERROR([missing required mono DLL: $i.dll])
   else
     AC_MSG_RESULT([found])
@@ -560,7 +569,7 @@ dnl I hope checking the presence of the qt-dotnet.dll should be enough
 if test "x$enable_qt" != "xno" -a "x$has_qyoto" = "xno"; then
 	i="qt-dotnet"
 	AC_MSG_CHECKING([for $i.dll])
-	if test ! -e `$PKG_CONFIG --variable=prefix mono`/lib/mono/2.0/$i.dll; then
+	if test ! -e `$PKG_CONFIG --variable=prefix $mono_pc`/lib/mono/2.0/$i.dll; then
 		AC_MSG_ERROR([missing required mono DLL: $i.dll])
 	else
 		AC_MSG_RESULT([found])
diff --git a/beagle/glue/mono-glue.c b/beagle/glue/mono-glue.c
index 6fe1bee..13203e0 100644
--- a/beagle/glue/mono-glue.c
+++ b/beagle/glue/mono-glue.c
@@ -79,18 +79,18 @@ memory_usage (MonoObject *obj, GHashTable *visited)
         type = mono_class_get_type (klass);
 
         /* This is an array, so drill down into it */
-        if (type->type == MONO_TYPE_SZARRAY)
+        if (mono_type_get_type (type) == MONO_TYPE_SZARRAY)
                 total += memory_usage_array ((MonoArray *) obj, visited);
 
         while ((field = mono_class_get_fields (klass, &iter)) != NULL) {
                 MonoType *ftype = mono_field_get_type (field);
                 gpointer value;
 
-                if ((ftype->attrs & (FIELD_ATTRIBUTE_STATIC | FIELD_ATTRIBUTE_HAS_FIELD_RVA)) != 0)
+                if ((mono_field_get_flags (field) & (FIELD_ATTRIBUTE_STATIC | FIELD_ATTRIBUTE_HAS_FIELD_RVA)) != 0)
                         continue;
 
                 /* FIXME: There are probably other types we need to drill down into */
-                switch (ftype->type) {
+                switch (mono_type_get_type (ftype)) {
 
                 case MONO_TYPE_CLASS:
                 case MONO_TYPE_OBJECT:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]