|
|
|
@ -91,27 +91,10 @@ namespace CppSharp.Generators.CLI |
|
|
|
WriteLine(forwardRef); |
|
|
|
WriteLine(forwardRef); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void GenerateNamespace(Namespace @namespace) |
|
|
|
public void GenerateDeclContext(DeclarationContext decl) |
|
|
|
{ |
|
|
|
|
|
|
|
var isTopLevel = @namespace is TranslationUnit; |
|
|
|
|
|
|
|
var generateNamespace = !isTopLevel || Options.GenerateLibraryNamespace; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (generateNamespace) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
PushBlock(CLIBlockKind.Namespace, @namespace); |
|
|
|
|
|
|
|
WriteLine("namespace {0}", isTopLevel |
|
|
|
|
|
|
|
? Options.OutputNamespace |
|
|
|
|
|
|
|
: SafeIdentifier(@namespace.Name)); |
|
|
|
|
|
|
|
WriteStartBraceIndent(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Generate the forward references.
|
|
|
|
|
|
|
|
PushBlock(CLIBlockKind.ForwardReferences); |
|
|
|
|
|
|
|
GenerateForwardRefs(@namespace); |
|
|
|
|
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Generate all the enum declarations for the module.
|
|
|
|
// Generate all the enum declarations for the module.
|
|
|
|
foreach (var @enum in @namespace.Enums) |
|
|
|
foreach (var @enum in decl.Enums) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (@enum.Ignore || @enum.IsIncomplete) |
|
|
|
if (@enum.Ignore || @enum.IsIncomplete) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
@ -122,10 +105,10 @@ namespace CppSharp.Generators.CLI |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Generate all the typedef declarations for the module.
|
|
|
|
// Generate all the typedef declarations for the module.
|
|
|
|
GenerateTypedefs(@namespace); |
|
|
|
GenerateTypedefs(decl); |
|
|
|
|
|
|
|
|
|
|
|
// Generate all the struct/class declarations for the module.
|
|
|
|
// Generate all the struct/class declarations for the module.
|
|
|
|
foreach (var @class in @namespace.Classes) |
|
|
|
foreach (var @class in decl.Classes) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (@class.Ignore || @class.IsIncomplete) |
|
|
|
if (@class.Ignore || @class.IsIncomplete) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
@ -138,11 +121,33 @@ namespace CppSharp.Generators.CLI |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (@namespace.HasFunctions) |
|
|
|
if (decl.HasFunctions) |
|
|
|
GenerateFunctions(@namespace); |
|
|
|
GenerateFunctions(decl); |
|
|
|
|
|
|
|
|
|
|
|
foreach(var childNamespace in @namespace.Namespaces) |
|
|
|
foreach (var childNamespace in decl.Namespaces) |
|
|
|
GenerateNamespace(childNamespace); |
|
|
|
GenerateNamespace(childNamespace); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void GenerateNamespace(Namespace @namespace) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var isTopLevel = @namespace is TranslationUnit; |
|
|
|
|
|
|
|
var generateNamespace = !isTopLevel || Options.GenerateLibraryNamespace; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (generateNamespace) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
PushBlock(CLIBlockKind.Namespace, @namespace); |
|
|
|
|
|
|
|
WriteLine("namespace {0}", isTopLevel |
|
|
|
|
|
|
|
? Options.OutputNamespace |
|
|
|
|
|
|
|
: SafeIdentifier(@namespace.Name)); |
|
|
|
|
|
|
|
WriteStartBraceIndent(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Generate the forward references.
|
|
|
|
|
|
|
|
PushBlock(CLIBlockKind.ForwardReferences); |
|
|
|
|
|
|
|
GenerateForwardRefs(@namespace); |
|
|
|
|
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GenerateDeclContext(@namespace); |
|
|
|
|
|
|
|
|
|
|
|
if (generateNamespace) |
|
|
|
if (generateNamespace) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -151,9 +156,9 @@ namespace CppSharp.Generators.CLI |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void GenerateTypedefs(Namespace @namespace) |
|
|
|
public void GenerateTypedefs(DeclarationContext decl) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (var typedef in @namespace.Typedefs) |
|
|
|
foreach (var typedef in decl.Typedefs) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (typedef.Ignore) |
|
|
|
if (typedef.Ignore) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
@ -162,7 +167,7 @@ namespace CppSharp.Generators.CLI |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void GenerateFunctions(Namespace @namespace) |
|
|
|
public void GenerateFunctions(DeclarationContext decl) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PushBlock(CLIBlockKind.FunctionsClass); |
|
|
|
PushBlock(CLIBlockKind.FunctionsClass); |
|
|
|
|
|
|
|
|
|
|
|
@ -173,7 +178,7 @@ namespace CppSharp.Generators.CLI |
|
|
|
PushIndent(); |
|
|
|
PushIndent(); |
|
|
|
|
|
|
|
|
|
|
|
// Generate all the function declarations for the module.
|
|
|
|
// Generate all the function declarations for the module.
|
|
|
|
foreach (var function in @namespace.Functions) |
|
|
|
foreach (var function in decl.Functions) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GenerateFunction(function); |
|
|
|
GenerateFunction(function); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -194,12 +199,10 @@ namespace CppSharp.Generators.CLI |
|
|
|
if (GenerateClassProlog(@class)) |
|
|
|
if (GenerateClassProlog(@class)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
foreach (var @enum in @class.Enums) |
|
|
|
// Process the nested types.
|
|
|
|
{ |
|
|
|
|
|
|
|
PushIndent(); |
|
|
|
PushIndent(); |
|
|
|
GenerateEnum(@enum); |
|
|
|
GenerateDeclContext(@class); |
|
|
|
PopIndent(); |
|
|
|
PopIndent(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var nativeType = string.Format("::{0}*", @class.QualifiedOriginalName); |
|
|
|
var nativeType = string.Format("::{0}*", @class.QualifiedOriginalName); |
|
|
|
|
|
|
|
|
|
|
|
@ -453,6 +456,12 @@ namespace CppSharp.Generators.CLI |
|
|
|
{ |
|
|
|
{ |
|
|
|
Write("public "); |
|
|
|
Write("public "); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Nested types cannot have visibility modifiers in C++/CLI.
|
|
|
|
|
|
|
|
var isTopLevel = @class.Namespace is TranslationUnit || |
|
|
|
|
|
|
|
@class.Namespace is Namespace; |
|
|
|
|
|
|
|
if (isTopLevel) |
|
|
|
|
|
|
|
Write("public "); |
|
|
|
|
|
|
|
|
|
|
|
Write(@class.IsValueType ? "value struct " : "ref class "); |
|
|
|
Write(@class.IsValueType ? "value struct " : "ref class "); |
|
|
|
|
|
|
|
|
|
|
|
Write("{0}", SafeIdentifier(@class.Name)); |
|
|
|
Write("{0}", SafeIdentifier(@class.Name)); |
|
|
|
|