Browse Source

Move helper ignore checker methods to Template.cs so they can be used by different generators.

pull/1/head
triton 12 years ago
parent
commit
6ad3cb59f6
  1. 8
      src/Generator/Driver.cs
  2. 37
      src/Generator/Generators/CLI/CLITextTemplate.cs
  3. 37
      src/Generator/Generators/Template.cs

8
src/Generator/Driver.cs

@ -178,6 +178,10 @@ namespace Cxxi @@ -178,6 +178,10 @@ namespace Cxxi
GenerateLibraryNamespace = true;
GenerateFunctionTemplates = false;
WriteOnlyWhenChanged = false;
var platform = Environment.OSVersion.Platform;
Abi = (platform == PlatformID.Unix || platform == PlatformID.MacOSX) ?
CppAbi.Itanium : CppAbi.Microsoft;
}
public bool Verbose = false;
@ -192,6 +196,7 @@ namespace Cxxi @@ -192,6 +196,7 @@ namespace Cxxi
public string OutputNamespace;
public string OutputDir;
public string LibraryName;
public CppAbi Abi;
public List<string> Defines;
public List<string> IncludeDirs;
public List<string> Headers;
@ -202,5 +207,8 @@ namespace Cxxi @@ -202,5 +207,8 @@ namespace Cxxi
public string WrapperSuffix;
public LanguageGeneratorKind GeneratorKind;
public bool WriteOnlyWhenChanged;
public bool IsItaniumAbi { get { return Abi == CppAbi.Itanium; } }
public bool IsMicrosoftAbi { get { return Abi == CppAbi.Microsoft; } }
}
}

37
src/Generator/Generators/CLI/CLITextTemplate.cs

@ -119,43 +119,6 @@ namespace Cxxi.Generators.CLI @@ -119,43 +119,6 @@ namespace Cxxi.Generators.CLI
return string.Join(", ", types);
}
public static bool CheckIgnoreMethod(Class @class, Method method)
{
if (method.Ignore) return true;
bool isEmptyCtor = method.IsConstructor && method.Parameters.Count == 0;
if (@class.IsValueType && isEmptyCtor)
return true;
if (method.IsCopyConstructor || method.IsMoveConstructor)
return true;
if (method.IsDestructor)
return true;
if (method.OperatorKind == CXXOperatorKind.Equal)
return true;
if (method.Kind == CXXMethodKind.Conversion)
return true;
if (method.Access != AccessSpecifier.Public)
return true;
return false;
}
public static bool CheckIgnoreField(Class @class, Field field)
{
if (field.Ignore) return true;
if (field.Access != AccessSpecifier.Public)
return true;
return false;
}
public static List<Parameter> GetEventParameters(Event @event)
{
var i = 0;

37
src/Generator/Generators/Template.cs

@ -22,5 +22,42 @@ @@ -22,5 +22,42 @@
Transform = driver.Transform;
TranslationUnit = unit;
}
public static bool CheckIgnoreMethod(Class @class, Method method)
{
if (method.Ignore) return true;
bool isEmptyCtor = method.IsConstructor && method.Parameters.Count == 0;
if (@class.IsValueType && isEmptyCtor)
return true;
if (method.IsCopyConstructor || method.IsMoveConstructor)
return true;
if (method.IsDestructor)
return true;
if (method.OperatorKind == CXXOperatorKind.Equal)
return true;
if (method.Kind == CXXMethodKind.Conversion)
return true;
if (method.Access != AccessSpecifier.Public)
return true;
return false;
}
public static bool CheckIgnoreField(Class @class, Field field)
{
if (field.Ignore) return true;
if (field.Access != AccessSpecifier.Public)
return true;
return false;
}
}
}
Loading…
Cancel
Save