Changed signatures back to IEnumerable and added full enumeration to list where needed.
This commit is contained in:
parent
b420ce8735
commit
1cda816b97
1 changed files with 14 additions and 11 deletions
|
@ -44,7 +44,7 @@ namespace OpenTK.Rewrite
|
||||||
var file = args[0];
|
var file = args[0];
|
||||||
var key = args[1];
|
var key = args[1];
|
||||||
var options = args.Where(a => a.StartsWith("-") || a.StartsWith("/"));
|
var options = args.Where(a => a.StartsWith("-") || a.StartsWith("/"));
|
||||||
program.Rewrite(file, key, options.ToList());
|
program.Rewrite(file, key, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mscorlib types
|
// mscorlib types
|
||||||
|
@ -60,9 +60,10 @@ namespace OpenTK.Rewrite
|
||||||
|
|
||||||
static bool dllimport;
|
static bool dllimport;
|
||||||
|
|
||||||
void Rewrite(string file, string keyfile, List<string> options)
|
void Rewrite(string file, string keyfile, IEnumerable<string> options)
|
||||||
{
|
{
|
||||||
dllimport = options.Contains("-dllimport");
|
IEnumerable<string> optionsEnumerated = options as IList<string> ?? options.ToList();
|
||||||
|
dllimport = optionsEnumerated.Contains("-dllimport");
|
||||||
|
|
||||||
// Specify assembly read and write parameters
|
// Specify assembly read and write parameters
|
||||||
// We want to keep a valid symbols file (pdb or mdb)
|
// We want to keep a valid symbols file (pdb or mdb)
|
||||||
|
@ -130,7 +131,7 @@ namespace OpenTK.Rewrite
|
||||||
{
|
{
|
||||||
foreach (var type in module.Types)
|
foreach (var type in module.Types)
|
||||||
{
|
{
|
||||||
Rewrite(type, options);
|
Rewrite(type, optionsEnumerated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +145,7 @@ namespace OpenTK.Rewrite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rewrite(TypeDefinition type, List<string> options)
|
void Rewrite(TypeDefinition type, IEnumerable<string> options)
|
||||||
{
|
{
|
||||||
var entry_points = type.Fields.FirstOrDefault(f => f.Name == "EntryPoints");
|
var entry_points = type.Fields.FirstOrDefault(f => f.Name == "EntryPoints");
|
||||||
if (entry_points != null)
|
if (entry_points != null)
|
||||||
|
@ -186,13 +187,14 @@ namespace OpenTK.Rewrite
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rewrite(TypeDefinition type, FieldDefinition entry_points,
|
void Rewrite(TypeDefinition type, FieldDefinition entry_points,
|
||||||
List<MethodDefinition> entry_signatures, List<string> options)
|
List<MethodDefinition> entry_signatures, IEnumerable<string> options)
|
||||||
{
|
{
|
||||||
// Rewrite all wrapper methods
|
// Rewrite all wrapper methods
|
||||||
var wrapper_signatures = new List<MethodDefinition>();
|
var wrapper_signatures = new List<MethodDefinition>();
|
||||||
wrapper_signatures.AddRange(type.Methods
|
wrapper_signatures.AddRange(type.Methods
|
||||||
.Where(m => m.IsPublic && m.CustomAttributes.Any(a => a.AttributeType.Name == "AutoGeneratedAttribute")));
|
.Where(m => m.IsPublic && m.CustomAttributes.Any(a => a.AttributeType.Name == "AutoGeneratedAttribute")));
|
||||||
|
|
||||||
|
IEnumerable<string> optionsEnumerated = options as IList<string> ?? options.ToList();
|
||||||
foreach (var wrapper in wrapper_signatures)
|
foreach (var wrapper in wrapper_signatures)
|
||||||
{
|
{
|
||||||
var autogenerated = wrapper.CustomAttributes
|
var autogenerated = wrapper.CustomAttributes
|
||||||
|
@ -204,7 +206,7 @@ namespace OpenTK.Rewrite
|
||||||
var signature = entry_signatures.FirstOrDefault(s => s.Name == signature_name);
|
var signature = entry_signatures.FirstOrDefault(s => s.Name == signature_name);
|
||||||
int slot = GetSlot(signature);
|
int slot = GetSlot(signature);
|
||||||
|
|
||||||
ProcessMethod(wrapper, signature, slot, entry_points, options);
|
ProcessMethod(wrapper, signature, slot, entry_points, optionsEnumerated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +216,7 @@ namespace OpenTK.Rewrite
|
||||||
{
|
{
|
||||||
foreach (var nested_type in type.NestedTypes)
|
foreach (var nested_type in type.NestedTypes)
|
||||||
{
|
{
|
||||||
Rewrite(nested_type, entry_points, entry_signatures, options);
|
Rewrite(nested_type, entry_points, entry_signatures, optionsEnumerated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,7 +250,7 @@ namespace OpenTK.Rewrite
|
||||||
|
|
||||||
// Create body for method
|
// Create body for method
|
||||||
static void ProcessMethod(MethodDefinition wrapper, MethodDefinition native, int slot,
|
static void ProcessMethod(MethodDefinition wrapper, MethodDefinition native, int slot,
|
||||||
FieldDefinition entry_points, List<string> options)
|
FieldDefinition entry_points, IEnumerable<string> options)
|
||||||
{
|
{
|
||||||
var body = wrapper.Body;
|
var body = wrapper.Body;
|
||||||
var il = body.GetILProcessor();
|
var il = body.GetILProcessor();
|
||||||
|
@ -259,7 +261,8 @@ namespace OpenTK.Rewrite
|
||||||
// and push each parameter on the stack
|
// and push each parameter on the stack
|
||||||
|
|
||||||
DebugVariables vars = null;
|
DebugVariables vars = null;
|
||||||
if (options.Contains("-debug"))
|
IEnumerable<string> optionsEnumerated = options as IList<string> ?? options.ToList();
|
||||||
|
if (optionsEnumerated.Contains("-debug"))
|
||||||
{
|
{
|
||||||
vars = EmitDebugPrologue(wrapper, il);
|
vars = EmitDebugPrologue(wrapper, il);
|
||||||
}
|
}
|
||||||
|
@ -297,7 +300,7 @@ namespace OpenTK.Rewrite
|
||||||
|
|
||||||
EmitParameterEpilogues(wrapper, native, body, il, generatedVariables);
|
EmitParameterEpilogues(wrapper, native, body, il, generatedVariables);
|
||||||
|
|
||||||
if (options.Contains("-debug"))
|
if (optionsEnumerated.Contains("-debug"))
|
||||||
{
|
{
|
||||||
EmitDebugEpilogue(wrapper, il, vars);
|
EmitDebugEpilogue(wrapper, il, vars);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue