Browse Source

Extracted the information for wrapped libraries to a separate class.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
cpp_module_crash
Dimitar Dobrev 10 years ago
parent
commit
6855901ca6
  1. 60
      src/Generator/Module.cs
  2. 65
      src/Generator/Options.cs

60
src/Generator/Module.cs

@ -0,0 +1,60 @@
using System.Collections.Generic;
namespace CppSharp
{
public class Module
{
public Module()
{
Headers = new List<string>();
Libraries = new List<string>();
}
public List<string> Headers { get; private set; }
public List<string> Libraries { get; private set; }
public string OutputNamespace { get; set; }
public string SharedLibraryName
{
get
{
if (string.IsNullOrEmpty(sharedLibraryName))
return LibraryName;
return sharedLibraryName;
}
set { sharedLibraryName = value; }
}
public string InlinesLibraryName
{
get
{
if (string.IsNullOrEmpty(inlinesLibraryName))
{
return string.Format("{0}-inlines", OutputNamespace);
}
return inlinesLibraryName;
}
set { inlinesLibraryName = value; }
}
public string TemplatesLibraryName
{
get
{
if (string.IsNullOrEmpty(templatesLibraryName))
{
return string.Format("{0}-templates", OutputNamespace);
}
return templatesLibraryName;
}
set { templatesLibraryName = value; }
}
public string LibraryName { get; set; }
private string sharedLibraryName;
private string inlinesLibraryName;
private string templatesLibraryName;
}
}

65
src/Generator/Options.cs

@ -19,17 +19,15 @@ namespace CppSharp
return platform == PlatformID.Unix || platform == PlatformID.MacOSX; return platform == PlatformID.Unix || platform == PlatformID.MacOSX;
} }
} }
public DriverOptions() public DriverOptions()
{ {
Headers = new List<string>();
Libraries = new List<string>();
Abi = IsUnixPlatform ? CppAbi.Itanium : CppAbi.Microsoft; Abi = IsUnixPlatform ? CppAbi.Itanium : CppAbi.Microsoft;
MicrosoftMode = !IsUnixPlatform; MicrosoftMode = !IsUnixPlatform;
OutputDir = Directory.GetCurrentDirectory(); OutputDir = Directory.GetCurrentDirectory();
Libraries = new List<string>();
CheckSymbols = false; Module = new Module();
GeneratorKind = GeneratorKind.CSharp; GeneratorKind = GeneratorKind.CSharp;
GenerateLibraryNamespace = true; GenerateLibraryNamespace = true;
@ -62,34 +60,42 @@ namespace CppSharp
public bool DryRun; public bool DryRun;
// Parser options // Parser options
public List<string> Headers; public List<string> Headers { get { return Module.Headers; } }
public bool IgnoreParseWarnings; public bool IgnoreParseWarnings;
public bool IgnoreParseErrors; public bool IgnoreParseErrors;
public Module Module { get; set; }
public bool IsItaniumLikeAbi { get { return Abi != CppAbi.Microsoft; } } public bool IsItaniumLikeAbi { get { return Abi != CppAbi.Microsoft; } }
public bool IsMicrosoftAbi { get { return Abi == CppAbi.Microsoft; } } public bool IsMicrosoftAbi { get { return Abi == CppAbi.Microsoft; } }
// Library options // Library options
public List<string> Libraries; public List<string> Libraries { get { return Module.Headers; } }
public bool CheckSymbols; public bool CheckSymbols;
private string sharedLibraryName;
public string SharedLibraryName public string SharedLibraryName
{ {
get get { return Module.SharedLibraryName; }
{ set { Module.SharedLibraryName = value; }
if (string.IsNullOrEmpty(sharedLibraryName))
return LibraryName;
return sharedLibraryName;
}
set { sharedLibraryName = value; }
} }
// Generator options // Generator options
public GeneratorKind GeneratorKind; public GeneratorKind GeneratorKind;
public string OutputNamespace;
public string OutputNamespace
{
get { return Module.OutputNamespace; }
set { Module.OutputNamespace = value; }
}
public string OutputDir; public string OutputDir;
public string LibraryName;
public string LibraryName
{
get { return Module.LibraryName; }
set { Module.LibraryName = value; }
}
public bool OutputInteropIncludes; public bool OutputInteropIncludes;
public bool GenerateLibraryNamespace; public bool GenerateLibraryNamespace;
public bool GenerateFunctionTemplates; public bool GenerateFunctionTemplates;
@ -152,28 +158,14 @@ namespace CppSharp
public string InlinesLibraryName public string InlinesLibraryName
{ {
get get { return Module.InlinesLibraryName; }
{ set { Module.InlinesLibraryName = value; }
if (string.IsNullOrEmpty(inlinesLibraryName))
{
return string.Format("{0}-inlines", OutputNamespace);
}
return inlinesLibraryName;
}
set { inlinesLibraryName = value; }
} }
public string TemplatesLibraryName public string TemplatesLibraryName
{ {
get get { return Module.TemplatesLibraryName; }
{ set { Module.TemplatesLibraryName = value; }
if (string.IsNullOrEmpty(templatesLibraryName))
{
return string.Format("{0}-templates", OutputNamespace);
}
return templatesLibraryName;
}
set { templatesLibraryName = value; }
} }
public bool IsCSharpGenerator public bool IsCSharpGenerator
@ -205,9 +197,6 @@ namespace CppSharp
/// C# end only: force patching of the virtual entries of the functions in this list. /// C# end only: force patching of the virtual entries of the functions in this list.
/// </summary> /// </summary>
public List<string> ExplicitlyPatchedVirtualFunctions { get; private set; } public List<string> ExplicitlyPatchedVirtualFunctions { get; private set; }
private string inlinesLibraryName;
private string templatesLibraryName;
} }
public class InvalidOptionException : Exception public class InvalidOptionException : Exception

Loading…
Cancel
Save