[Pkg-cli-libs-commits] [SCM] db4o branch, master, updated. debian/7.4.121.14026+dfsg-3-22-g8e3de09
Jo Shields
directhex at apebox.org
Sun Aug 14 19:04:38 UTC 2011
The following commit has been merged in the master branch:
commit bd2d9b22a55ec4876a771fb63120149560101028
Author: Jo Shields <directhex at apebox.org>
Date: Sun Aug 14 17:24:22 2011 +0100
The bundled Cecil with Db4o upstream doesn't quite match what we ship in
Debian. Add a couple of copy-paste methods to an interface implementation, to
match the current specification.
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..81228e6
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+use_cecil_0.9.5_api.patch
diff --git a/debian/patches/use_cecil_0.9.5_api.patch b/debian/patches/use_cecil_0.9.5_api.patch
new file mode 100644
index 0000000..91273a2
--- /dev/null
+++ b/debian/patches/use_cecil_0.9.5_api.patch
@@ -0,0 +1,422 @@
+Index: db4o/src/Db4oTool/Db4oTool/Core/CecilReflector.cs
+===================================================================
+--- db4o.orig/src/Db4oTool/Db4oTool/Core/CecilReflector.cs 2011-08-14 17:23:05.000000000 +0100
++++ db4o/src/Db4oTool/Db4oTool/Core/CecilReflector.cs 2011-08-14 17:23:26.000000000 +0100
+@@ -13,202 +13,218 @@
+
+ You should have received a copy of the GNU General Public License along
+ with this program. If not, see http://www.gnu.org/licenses/. */
+-using System;
+-using System.Collections;
+-using System.Collections.Generic;
+-using Db4objects.Db4o.Foundation;
+-using Mono.Cecil;
+-
+-namespace Db4oTool.Core
+-{
+- public class CecilReflector
+- {
+- private readonly InstrumentationContext _context;
+- private readonly IAssemblyResolver _resolver;
+-
+- public CecilReflector(InstrumentationContext context)
+- {
+- _context = context;
+- _resolver = new RelativeAssemblyResolver(_context);
+-
+- if (_context.AlternateAssemblyLocation != null)
+- {
+- _resolver = new CompositeAssemblyResolver(
+- new RelativeAssemblyResolver(_context.AlternateAssemblyLocation),
+- _resolver);
+- }
+- }
+-
+- public bool Implements(TypeDefinition type, Type interfaceType)
+- {
+- return Implements(type, interfaceType.FullName);
+- }
+-
+- private bool Implements(TypeDefinition type, string interfaceName)
+- {
+- if (Contains(type.Interfaces, interfaceName)) return true;
+- if (null == type.BaseType) return false;
+-
+- TypeDefinition baseType = ResolveTypeReference(type.BaseType);
+- if (null != baseType) return Implements(baseType, interfaceName);
+-
+- return false;
+- }
+-
+- public TypeDefinition ResolveTypeReference(TypeReference typeRef)
+- {
+- if (null == typeRef) throw new ArgumentNullException("typeRef");
+-
+- TypeDefinition type = typeRef as TypeDefinition;
+- if (null != type) return type;
+-
+- GenericParameter parameter = typeRef as GenericParameter;
+- if (parameter != null) return null;
+-
+- TypeSpecification typeSpecification = typeRef as TypeSpecification;
+- if (typeSpecification != null) return ResolveTypeReference(typeSpecification.ElementType);
+-
+- AssemblyDefinition assembly = ResolveAssembly(typeRef.Scope as AssemblyNameReference);
+- if (null == assembly) return null;
+-
+- return FindType(assembly, typeRef);
+- }
+-
+- private AssemblyDefinition ResolveAssembly(AssemblyNameReference assemblyRef)
+- {
+- return _resolver.Resolve(assemblyRef);
+- }
+-
+- private TypeDefinition FindType(AssemblyDefinition assembly, TypeReference typeRef)
+- {
+- foreach (ModuleDefinition m in assembly.Modules)
+- {
+- foreach (TypeDefinition t in m.Types)
+- {
+- if (t.FullName == typeRef.FullName) return t;
+- }
+- }
+- return null;
+- }
+-
+- private static bool Contains(IEnumerable<TypeReference> collection, string fullName)
+- {
+- foreach (TypeReference typeRef in collection)
+- {
+- if (typeRef.FullName == fullName) return true;
+- }
+- return false;
+- }
+-
+- public static MethodDefinition GetMethod(TypeDefinition type, string methodName)
+- {
+- if (type == null) throw new ArgumentNullException("type");
+- if (methodName == null) throw new ArgumentNullException("methodName");
+-
+- foreach (MethodDefinition method in type.Methods)
+- {
+- if (method.Name == methodName) return method;
+- }
+-
+- return null;
+- }
+-
+- public static MethodDefinition GetMethod(TypeDefinition type, MethodReference template)
+- {
+- return GetMethodInternal(type, template.Name, template.Parameters);
+- }
+-
+- public static MethodDefinition GetMethod(TypeDefinition type, string methodName, Type [] parameterTypes)
+- {
+- return GetMethodInternal(type, methodName, parameterTypes);
+- }
+-
+- static MethodDefinition GetMethodInternal(TypeDefinition type, string name, IList parameters)
+- {
+- if (type == null) throw new ArgumentNullException ("type");
+-
+- foreach (MethodDefinition method in type.Methods)
+- {
+- if (method.Name != name) continue;
+- if (!ParametersMatch(method.Parameters, parameters)) continue;
+-
+- return method;
+- }
+-
+- return null;
+- }
+-
+- static bool ParametersMatch(IList<ParameterDefinition> parameters, IList candidates)
+- {
+- if (parameters.Count != candidates.Count) return false;
+-
+- for (int i = 0; i < parameters.Count; i++) {
+- string candidateTypeName;
+- object candidate = candidates[i];
+-
+- if (candidate is Type)
+- candidateTypeName = (candidate as Type).FullName.Replace('+', '/');
+- else if (candidate is TypeReference)
+- candidateTypeName = (candidate as TypeReference).FullName;
+- else if (candidate is ParameterDefinition)
+- candidateTypeName = (candidate as ParameterDefinition).ParameterType.FullName;
+- else
+- return false;
+-
+- if (parameters[i].ParameterType.FullName != candidateTypeName) return false;
+- }
+-
+- return true;
+- }
+-
+- public static FieldDefinition GetField(TypeDefinition type, string fieldName)
+- {
+- if (type == null) throw new ArgumentNullException("type");
+- if (fieldName == null) throw new ArgumentNullException("fieldName");
+-
+- foreach (FieldDefinition field in type.Fields)
+- {
+- if (field.Name == fieldName) return field;
+- }
+-
+- return null;
+- }
+- }
+-
+- internal class CompositeAssemblyResolver : IAssemblyResolver
+- {
+- private readonly IAssemblyResolver[] _resolvers;
+-
+- public CompositeAssemblyResolver(params IAssemblyResolver[] resolvers)
+- {
+- _resolvers = resolvers;
+- }
+-
+- public AssemblyDefinition Resolve(string fullName)
+- {
+- return InternalResolve(delegate(IAssemblyResolver resolver)
+- {
+- return resolver.Resolve(fullName);
+- });
+- }
+-
+- public AssemblyDefinition Resolve(AssemblyNameReference name)
+- {
+- return InternalResolve(delegate(IAssemblyResolver resolver)
+- {
+- return resolver.Resolve(name);
+- });
+- }
+-
+- private AssemblyDefinition InternalResolve(Function<IAssemblyResolver, AssemblyDefinition> @delegate)
+- {
+- foreach (IAssemblyResolver resolver in _resolvers)
+- {
+- AssemblyDefinition assemblyDefinition = @delegate(resolver);
+- if (assemblyDefinition != null) return assemblyDefinition;
+- }
+-
+- return null;
+- }
+- }
+-}
++using System;
++using System.Collections;
++using System.Collections.Generic;
++using Db4objects.Db4o.Foundation;
++using Mono.Cecil;
++
++namespace Db4oTool.Core
++{
++ public class CecilReflector
++ {
++ private readonly InstrumentationContext _context;
++ private readonly IAssemblyResolver _resolver;
++
++ public CecilReflector(InstrumentationContext context)
++ {
++ _context = context;
++ _resolver = new RelativeAssemblyResolver(_context);
++
++ if (_context.AlternateAssemblyLocation != null)
++ {
++ _resolver = new CompositeAssemblyResolver(
++ new RelativeAssemblyResolver(_context.AlternateAssemblyLocation),
++ _resolver);
++ }
++ }
++
++ public bool Implements(TypeDefinition type, Type interfaceType)
++ {
++ return Implements(type, interfaceType.FullName);
++ }
++
++ private bool Implements(TypeDefinition type, string interfaceName)
++ {
++ if (Contains(type.Interfaces, interfaceName)) return true;
++ if (null == type.BaseType) return false;
++
++ TypeDefinition baseType = ResolveTypeReference(type.BaseType);
++ if (null != baseType) return Implements(baseType, interfaceName);
++
++ return false;
++ }
++
++ public TypeDefinition ResolveTypeReference(TypeReference typeRef)
++ {
++ if (null == typeRef) throw new ArgumentNullException("typeRef");
++
++ TypeDefinition type = typeRef as TypeDefinition;
++ if (null != type) return type;
++
++ GenericParameter parameter = typeRef as GenericParameter;
++ if (parameter != null) return null;
++
++ TypeSpecification typeSpecification = typeRef as TypeSpecification;
++ if (typeSpecification != null) return ResolveTypeReference(typeSpecification.ElementType);
++
++ AssemblyDefinition assembly = ResolveAssembly(typeRef.Scope as AssemblyNameReference);
++ if (null == assembly) return null;
++
++ return FindType(assembly, typeRef);
++ }
++
++ private AssemblyDefinition ResolveAssembly(AssemblyNameReference assemblyRef)
++ {
++ return _resolver.Resolve(assemblyRef);
++ }
++
++ private TypeDefinition FindType(AssemblyDefinition assembly, TypeReference typeRef)
++ {
++ foreach (ModuleDefinition m in assembly.Modules)
++ {
++ foreach (TypeDefinition t in m.Types)
++ {
++ if (t.FullName == typeRef.FullName) return t;
++ }
++ }
++ return null;
++ }
++
++ private static bool Contains(IEnumerable<TypeReference> collection, string fullName)
++ {
++ foreach (TypeReference typeRef in collection)
++ {
++ if (typeRef.FullName == fullName) return true;
++ }
++ return false;
++ }
++
++ public static MethodDefinition GetMethod(TypeDefinition type, string methodName)
++ {
++ if (type == null) throw new ArgumentNullException("type");
++ if (methodName == null) throw new ArgumentNullException("methodName");
++
++ foreach (MethodDefinition method in type.Methods)
++ {
++ if (method.Name == methodName) return method;
++ }
++
++ return null;
++ }
++
++ public static MethodDefinition GetMethod(TypeDefinition type, MethodReference template)
++ {
++ return GetMethodInternal(type, template.Name, template.Parameters);
++ }
++
++ public static MethodDefinition GetMethod(TypeDefinition type, string methodName, Type [] parameterTypes)
++ {
++ return GetMethodInternal(type, methodName, parameterTypes);
++ }
++
++ static MethodDefinition GetMethodInternal(TypeDefinition type, string name, IList parameters)
++ {
++ if (type == null) throw new ArgumentNullException ("type");
++
++ foreach (MethodDefinition method in type.Methods)
++ {
++ if (method.Name != name) continue;
++ if (!ParametersMatch(method.Parameters, parameters)) continue;
++
++ return method;
++ }
++
++ return null;
++ }
++
++ static bool ParametersMatch(IList<ParameterDefinition> parameters, IList candidates)
++ {
++ if (parameters.Count != candidates.Count) return false;
++
++ for (int i = 0; i < parameters.Count; i++) {
++ string candidateTypeName;
++ object candidate = candidates[i];
++
++ if (candidate is Type)
++ candidateTypeName = (candidate as Type).FullName.Replace('+', '/');
++ else if (candidate is TypeReference)
++ candidateTypeName = (candidate as TypeReference).FullName;
++ else if (candidate is ParameterDefinition)
++ candidateTypeName = (candidate as ParameterDefinition).ParameterType.FullName;
++ else
++ return false;
++
++ if (parameters[i].ParameterType.FullName != candidateTypeName) return false;
++ }
++
++ return true;
++ }
++
++ public static FieldDefinition GetField(TypeDefinition type, string fieldName)
++ {
++ if (type == null) throw new ArgumentNullException("type");
++ if (fieldName == null) throw new ArgumentNullException("fieldName");
++
++ foreach (FieldDefinition field in type.Fields)
++ {
++ if (field.Name == fieldName) return field;
++ }
++
++ return null;
++ }
++ }
++
++ internal class CompositeAssemblyResolver : IAssemblyResolver
++ {
++ private readonly IAssemblyResolver[] _resolvers;
++
++ public CompositeAssemblyResolver(params IAssemblyResolver[] resolvers)
++ {
++ _resolvers = resolvers;
++ }
++
++ public AssemblyDefinition Resolve(string fullName, ReaderParameters parameters)
++ {
++ return InternalResolve(delegate(IAssemblyResolver resolver)
++ {
++ return resolver.Resolve(fullName);
++ });
++ }
++
++ public AssemblyDefinition Resolve(string fullName)
++ {
++ return InternalResolve(delegate(IAssemblyResolver resolver)
++ {
++ return resolver.Resolve(fullName);
++ });
++ }
++
++ public AssemblyDefinition Resolve(AssemblyNameReference name)
++ {
++ return InternalResolve(delegate(IAssemblyResolver resolver)
++ {
++ return resolver.Resolve(name);
++ });
++ }
++
++ public AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters)
++ {
++ return InternalResolve(delegate(IAssemblyResolver resolver)
++ {
++ return resolver.Resolve(name);
++ });
++ }
++
++ private AssemblyDefinition InternalResolve(Function<IAssemblyResolver, AssemblyDefinition> @delegate)
++ {
++ foreach (IAssemblyResolver resolver in _resolvers)
++ {
++ AssemblyDefinition assemblyDefinition = @delegate(resolver);
++ if (assemblyDefinition != null) return assemblyDefinition;
++ }
++
++ return null;
++ }
++ }
++}
--
db4o
More information about the Pkg-cli-libs-commits
mailing list