Browse Source

Changed the native ctors by value to also be wrapped by static methods.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/366/head
Dimitar Dobrev 11 years ago
parent
commit
bc140e13be
  1. 457
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs
  2. 32
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppParser.cs
  3. 7
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Sources.cs
  4. 7
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Target.cs
  5. 457
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs
  6. 32
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppParser.cs
  7. 7
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Sources.cs
  8. 7
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Target.cs
  9. 457
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs
  10. 32
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppParser.cs
  11. 7
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Sources.cs
  12. 7
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Target.cs
  13. 2
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  14. 15
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

457
src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs

File diff suppressed because it is too large Load Diff

32
src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppParser.cs

@ -239,6 +239,11 @@ namespace CppSharp
return new ParserOptions((ParserOptions.Internal*) native); return new ParserOptions((ParserOptions.Internal*) native);
} }
public static ParserOptions __CreateInstance(ParserOptions.Internal native)
{
return new ParserOptions(native);
}
private static ParserOptions.Internal* __CopyValue(ParserOptions.Internal native) private static ParserOptions.Internal* __CopyValue(ParserOptions.Internal native)
{ {
var ret = Marshal.AllocHGlobal(116); var ret = Marshal.AllocHGlobal(116);
@ -246,7 +251,7 @@ namespace CppSharp
return (ParserOptions.Internal*) ret; return (ParserOptions.Internal*) ret;
} }
internal ParserOptions(ParserOptions.Internal native) private ParserOptions(ParserOptions.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;
@ -661,6 +666,11 @@ namespace CppSharp
return new ParserDiagnostic((ParserDiagnostic.Internal*) native); return new ParserDiagnostic((ParserDiagnostic.Internal*) native);
} }
public static ParserDiagnostic __CreateInstance(ParserDiagnostic.Internal native)
{
return new ParserDiagnostic(native);
}
private static ParserDiagnostic.Internal* __CopyValue(ParserDiagnostic.Internal native) private static ParserDiagnostic.Internal* __CopyValue(ParserDiagnostic.Internal native)
{ {
var ret = Marshal.AllocHGlobal(36); var ret = Marshal.AllocHGlobal(36);
@ -668,7 +678,7 @@ namespace CppSharp
return (ParserDiagnostic.Internal*) ret; return (ParserDiagnostic.Internal*) ret;
} }
internal ParserDiagnostic(ParserDiagnostic.Internal native) private ParserDiagnostic(ParserDiagnostic.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;
@ -843,6 +853,11 @@ namespace CppSharp
return new ParserResult((ParserResult.Internal*) native); return new ParserResult((ParserResult.Internal*) native);
} }
public static ParserResult __CreateInstance(ParserResult.Internal native)
{
return new ParserResult(native);
}
private static ParserResult.Internal* __CopyValue(ParserResult.Internal native) private static ParserResult.Internal* __CopyValue(ParserResult.Internal native)
{ {
var ret = Marshal.AllocHGlobal(28); var ret = Marshal.AllocHGlobal(28);
@ -850,7 +865,7 @@ namespace CppSharp
return (ParserResult.Internal*) ret; return (ParserResult.Internal*) ret;
} }
internal ParserResult(ParserResult.Internal native) private ParserResult(ParserResult.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;
@ -887,7 +902,7 @@ namespace CppSharp
{ {
var __ret = new CppSharp.Parser.ParserDiagnostic.Internal(); var __ret = new CppSharp.Parser.ParserDiagnostic.Internal();
Internal.getDiagnostics_0(new IntPtr(&__ret), __Instance, i); Internal.getDiagnostics_0(new IntPtr(&__ret), __Instance, i);
return new CppSharp.Parser.ParserDiagnostic(__ret); return CppSharp.Parser.ParserDiagnostic.__CreateInstance(__ret);
} }
public void addDiagnostics(CppSharp.Parser.ParserDiagnostic s) public void addDiagnostics(CppSharp.Parser.ParserDiagnostic s)
@ -991,14 +1006,19 @@ namespace CppSharp
return new ClangParser((ClangParser.Internal*) native); return new ClangParser((ClangParser.Internal*) native);
} }
public static ClangParser __CreateInstance(ClangParser.Internal native)
{
return new ClangParser(native);
}
private static ClangParser.Internal* __CopyValue(ClangParser.Internal native) private static ClangParser.Internal* __CopyValue(ClangParser.Internal native)
{ {
ClangParser.Internal* ret = (ClangParser.Internal*) Marshal.AllocHGlobal(1); var ret = (ClangParser.Internal*) Marshal.AllocHGlobal(1);
*ret = native; *ret = native;
return ret; return ret;
} }
internal ClangParser(ClangParser.Internal native) private ClangParser(ClangParser.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;

7
src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Sources.cs

@ -39,7 +39,12 @@ namespace CppSharp
return new SourceLocation((SourceLocation.Internal*) native); return new SourceLocation((SourceLocation.Internal*) native);
} }
internal SourceLocation(SourceLocation.Internal native) public static SourceLocation __CreateInstance(SourceLocation.Internal native)
{
return new SourceLocation(native);
}
private SourceLocation(SourceLocation.Internal native)
: this(&native) : this(&native)
{ {
} }

7
src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Target.cs

@ -179,6 +179,11 @@ namespace CppSharp
return new ParserTargetInfo((ParserTargetInfo.Internal*) native); return new ParserTargetInfo((ParserTargetInfo.Internal*) native);
} }
public static ParserTargetInfo __CreateInstance(ParserTargetInfo.Internal native)
{
return new ParserTargetInfo(native);
}
private static ParserTargetInfo.Internal* __CopyValue(ParserTargetInfo.Internal native) private static ParserTargetInfo.Internal* __CopyValue(ParserTargetInfo.Internal native)
{ {
var ret = Marshal.AllocHGlobal(164); var ret = Marshal.AllocHGlobal(164);
@ -186,7 +191,7 @@ namespace CppSharp
return (ParserTargetInfo.Internal*) ret; return (ParserTargetInfo.Internal*) ret;
} }
internal ParserTargetInfo(ParserTargetInfo.Internal native) private ParserTargetInfo(ParserTargetInfo.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;

457
src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs

File diff suppressed because it is too large Load Diff

32
src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppParser.cs

@ -239,6 +239,11 @@ namespace CppSharp
return new ParserOptions((ParserOptions.Internal*) native); return new ParserOptions((ParserOptions.Internal*) native);
} }
public static ParserOptions __CreateInstance(ParserOptions.Internal native)
{
return new ParserOptions(native);
}
private static ParserOptions.Internal* __CopyValue(ParserOptions.Internal native) private static ParserOptions.Internal* __CopyValue(ParserOptions.Internal native)
{ {
var ret = Marshal.AllocHGlobal(140); var ret = Marshal.AllocHGlobal(140);
@ -246,7 +251,7 @@ namespace CppSharp
return (ParserOptions.Internal*) ret; return (ParserOptions.Internal*) ret;
} }
internal ParserOptions(ParserOptions.Internal native) private ParserOptions(ParserOptions.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;
@ -661,6 +666,11 @@ namespace CppSharp
return new ParserDiagnostic((ParserDiagnostic.Internal*) native); return new ParserDiagnostic((ParserDiagnostic.Internal*) native);
} }
public static ParserDiagnostic __CreateInstance(ParserDiagnostic.Internal native)
{
return new ParserDiagnostic(native);
}
private static ParserDiagnostic.Internal* __CopyValue(ParserDiagnostic.Internal native) private static ParserDiagnostic.Internal* __CopyValue(ParserDiagnostic.Internal native)
{ {
var ret = Marshal.AllocHGlobal(60); var ret = Marshal.AllocHGlobal(60);
@ -668,7 +678,7 @@ namespace CppSharp
return (ParserDiagnostic.Internal*) ret; return (ParserDiagnostic.Internal*) ret;
} }
internal ParserDiagnostic(ParserDiagnostic.Internal native) private ParserDiagnostic(ParserDiagnostic.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;
@ -843,6 +853,11 @@ namespace CppSharp
return new ParserResult((ParserResult.Internal*) native); return new ParserResult((ParserResult.Internal*) native);
} }
public static ParserResult __CreateInstance(ParserResult.Internal native)
{
return new ParserResult(native);
}
private static ParserResult.Internal* __CopyValue(ParserResult.Internal native) private static ParserResult.Internal* __CopyValue(ParserResult.Internal native)
{ {
var ret = Marshal.AllocHGlobal(28); var ret = Marshal.AllocHGlobal(28);
@ -850,7 +865,7 @@ namespace CppSharp
return (ParserResult.Internal*) ret; return (ParserResult.Internal*) ret;
} }
internal ParserResult(ParserResult.Internal native) private ParserResult(ParserResult.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;
@ -887,7 +902,7 @@ namespace CppSharp
{ {
var __ret = new CppSharp.Parser.ParserDiagnostic.Internal(); var __ret = new CppSharp.Parser.ParserDiagnostic.Internal();
Internal.getDiagnostics_0(__Instance, new IntPtr(&__ret), i); Internal.getDiagnostics_0(__Instance, new IntPtr(&__ret), i);
return new CppSharp.Parser.ParserDiagnostic(__ret); return CppSharp.Parser.ParserDiagnostic.__CreateInstance(__ret);
} }
public void addDiagnostics(CppSharp.Parser.ParserDiagnostic s) public void addDiagnostics(CppSharp.Parser.ParserDiagnostic s)
@ -991,14 +1006,19 @@ namespace CppSharp
return new ClangParser((ClangParser.Internal*) native); return new ClangParser((ClangParser.Internal*) native);
} }
public static ClangParser __CreateInstance(ClangParser.Internal native)
{
return new ClangParser(native);
}
private static ClangParser.Internal* __CopyValue(ClangParser.Internal native) private static ClangParser.Internal* __CopyValue(ClangParser.Internal native)
{ {
ClangParser.Internal* ret = (ClangParser.Internal*) Marshal.AllocHGlobal(1); var ret = (ClangParser.Internal*) Marshal.AllocHGlobal(1);
*ret = native; *ret = native;
return ret; return ret;
} }
internal ClangParser(ClangParser.Internal native) private ClangParser(ClangParser.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;

7
src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Sources.cs

@ -39,7 +39,12 @@ namespace CppSharp
return new SourceLocation((SourceLocation.Internal*) native); return new SourceLocation((SourceLocation.Internal*) native);
} }
internal SourceLocation(SourceLocation.Internal native) public static SourceLocation __CreateInstance(SourceLocation.Internal native)
{
return new SourceLocation(native);
}
private SourceLocation(SourceLocation.Internal native)
: this(&native) : this(&native)
{ {
} }

7
src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Target.cs

@ -179,6 +179,11 @@ namespace CppSharp
return new ParserTargetInfo((ParserTargetInfo.Internal*) native); return new ParserTargetInfo((ParserTargetInfo.Internal*) native);
} }
public static ParserTargetInfo __CreateInstance(ParserTargetInfo.Internal native)
{
return new ParserTargetInfo(native);
}
private static ParserTargetInfo.Internal* __CopyValue(ParserTargetInfo.Internal native) private static ParserTargetInfo.Internal* __CopyValue(ParserTargetInfo.Internal native)
{ {
var ret = Marshal.AllocHGlobal(176); var ret = Marshal.AllocHGlobal(176);
@ -186,7 +191,7 @@ namespace CppSharp
return (ParserTargetInfo.Internal*) ret; return (ParserTargetInfo.Internal*) ret;
} }
internal ParserTargetInfo(ParserTargetInfo.Internal native) private ParserTargetInfo(ParserTargetInfo.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;

457
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs

File diff suppressed because it is too large Load Diff

32
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppParser.cs

@ -239,6 +239,11 @@ namespace CppSharp
return new ParserOptions((ParserOptions.Internal*) native); return new ParserOptions((ParserOptions.Internal*) native);
} }
public static ParserOptions __CreateInstance(ParserOptions.Internal native)
{
return new ParserOptions(native);
}
private static ParserOptions.Internal* __CopyValue(ParserOptions.Internal native) private static ParserOptions.Internal* __CopyValue(ParserOptions.Internal native)
{ {
var ret = Marshal.AllocHGlobal(192); var ret = Marshal.AllocHGlobal(192);
@ -246,7 +251,7 @@ namespace CppSharp
return (ParserOptions.Internal*) ret; return (ParserOptions.Internal*) ret;
} }
internal ParserOptions(ParserOptions.Internal native) private ParserOptions(ParserOptions.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;
@ -661,6 +666,11 @@ namespace CppSharp
return new ParserDiagnostic((ParserDiagnostic.Internal*) native); return new ParserDiagnostic((ParserDiagnostic.Internal*) native);
} }
public static ParserDiagnostic __CreateInstance(ParserDiagnostic.Internal native)
{
return new ParserDiagnostic(native);
}
private static ParserDiagnostic.Internal* __CopyValue(ParserDiagnostic.Internal native) private static ParserDiagnostic.Internal* __CopyValue(ParserDiagnostic.Internal native)
{ {
var ret = Marshal.AllocHGlobal(32); var ret = Marshal.AllocHGlobal(32);
@ -668,7 +678,7 @@ namespace CppSharp
return (ParserDiagnostic.Internal*) ret; return (ParserDiagnostic.Internal*) ret;
} }
internal ParserDiagnostic(ParserDiagnostic.Internal native) private ParserDiagnostic(ParserDiagnostic.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;
@ -843,6 +853,11 @@ namespace CppSharp
return new ParserResult((ParserResult.Internal*) native); return new ParserResult((ParserResult.Internal*) native);
} }
public static ParserResult __CreateInstance(ParserResult.Internal native)
{
return new ParserResult(native);
}
private static ParserResult.Internal* __CopyValue(ParserResult.Internal native) private static ParserResult.Internal* __CopyValue(ParserResult.Internal native)
{ {
var ret = Marshal.AllocHGlobal(56); var ret = Marshal.AllocHGlobal(56);
@ -850,7 +865,7 @@ namespace CppSharp
return (ParserResult.Internal*) ret; return (ParserResult.Internal*) ret;
} }
internal ParserResult(ParserResult.Internal native) private ParserResult(ParserResult.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;
@ -887,7 +902,7 @@ namespace CppSharp
{ {
var __ret = new CppSharp.Parser.ParserDiagnostic.Internal(); var __ret = new CppSharp.Parser.ParserDiagnostic.Internal();
Internal.getDiagnostics_0(new IntPtr(&__ret), __Instance, i); Internal.getDiagnostics_0(new IntPtr(&__ret), __Instance, i);
return new CppSharp.Parser.ParserDiagnostic(__ret); return CppSharp.Parser.ParserDiagnostic.__CreateInstance(__ret);
} }
public void addDiagnostics(CppSharp.Parser.ParserDiagnostic s) public void addDiagnostics(CppSharp.Parser.ParserDiagnostic s)
@ -991,14 +1006,19 @@ namespace CppSharp
return new ClangParser((ClangParser.Internal*) native); return new ClangParser((ClangParser.Internal*) native);
} }
public static ClangParser __CreateInstance(ClangParser.Internal native)
{
return new ClangParser(native);
}
private static ClangParser.Internal* __CopyValue(ClangParser.Internal native) private static ClangParser.Internal* __CopyValue(ClangParser.Internal native)
{ {
ClangParser.Internal* ret = (ClangParser.Internal*) Marshal.AllocHGlobal(1); var ret = (ClangParser.Internal*) Marshal.AllocHGlobal(1);
*ret = native; *ret = native;
return ret; return ret;
} }
internal ClangParser(ClangParser.Internal native) private ClangParser(ClangParser.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;

7
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Sources.cs

@ -39,7 +39,12 @@ namespace CppSharp
return new SourceLocation((SourceLocation.Internal*) native); return new SourceLocation((SourceLocation.Internal*) native);
} }
internal SourceLocation(SourceLocation.Internal native) public static SourceLocation __CreateInstance(SourceLocation.Internal native)
{
return new SourceLocation(native);
}
private SourceLocation(SourceLocation.Internal native)
: this(&native) : this(&native)
{ {
} }

7
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Target.cs

@ -179,6 +179,11 @@ namespace CppSharp
return new ParserTargetInfo((ParserTargetInfo.Internal*) native); return new ParserTargetInfo((ParserTargetInfo.Internal*) native);
} }
public static ParserTargetInfo __CreateInstance(ParserTargetInfo.Internal native)
{
return new ParserTargetInfo(native);
}
private static ParserTargetInfo.Internal* __CopyValue(ParserTargetInfo.Internal native) private static ParserTargetInfo.Internal* __CopyValue(ParserTargetInfo.Internal native)
{ {
var ret = Marshal.AllocHGlobal(160); var ret = Marshal.AllocHGlobal(160);
@ -186,7 +191,7 @@ namespace CppSharp
return (ParserTargetInfo.Internal*) ret; return (ParserTargetInfo.Internal*) ret;
} }
internal ParserTargetInfo(ParserTargetInfo.Internal native) private ParserTargetInfo(ParserTargetInfo.Internal native)
: this(__CopyValue(native)) : this(__CopyValue(native))
{ {
__ownsNativeInstance = true; __ownsNativeInstance = true;

2
src/Generator/Generators/CSharp/CSharpMarshal.cs

@ -269,7 +269,7 @@ namespace CppSharp.Generators.CSharp
@class.IsRefType ? "null" : string.Format("new {0}()", type), @class.IsRefType ? "null" : string.Format("new {0}()", type),
type, Helpers.CreateInstanceIdentifier); type, Helpers.CreateInstanceIdentifier);
else else
Context.Return.Write("new {0}({1})", type, instance); Context.Return.Write("{0}.{1}({2})", type, Helpers.CreateInstanceIdentifier, instance);
return true; return true;
} }

15
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -1908,9 +1908,9 @@ namespace CppSharp.Generators.CSharp
WriteLine("return new {0}(({1}.Internal*) native);", safeIdentifier, className); WriteLine("return new {0}(({1}.Internal*) native);", safeIdentifier, className);
WriteCloseBraceIndent(); WriteCloseBraceIndent();
PopBlock(NewLineKind.BeforeNextBlock); PopBlock(NewLineKind.BeforeNextBlock);
}
GenerateNativeConstructorByValue(@class, className, safeIdentifier); GenerateNativeConstructorByValue(@class, className, safeIdentifier);
}
PushBlock(CSharpBlockKind.Method); PushBlock(CSharpBlockKind.Method);
WriteLine("{0} {1}({2}.Internal* native, bool isInternalImpl = false){3}", WriteLine("{0} {1}({2}.Internal* native, bool isInternalImpl = false){3}",
@ -1963,6 +1963,13 @@ namespace CppSharp.Generators.CSharp
private void GenerateNativeConstructorByValue(Class @class, string className, string safeIdentifier) private void GenerateNativeConstructorByValue(Class @class, string className, string safeIdentifier)
{ {
PushBlock(CSharpBlockKind.Method);
WriteLine("public static {0} {1}({0}.Internal native)", className, Helpers.CreateInstanceIdentifier);
WriteStartBraceIndent();
WriteLine("return new {0}(native);", safeIdentifier);
WriteCloseBraceIndent();
PopBlock(NewLineKind.BeforeNextBlock);
if (@class.IsRefType) if (@class.IsRefType)
{ {
PushBlock(CSharpBlockKind.Method); PushBlock(CSharpBlockKind.Method);
@ -1985,7 +1992,7 @@ namespace CppSharp.Generators.CSharp
} }
else else
{ {
WriteLine("{0}.Internal* ret = ({0}.Internal*) Marshal.AllocHGlobal({1});", WriteLine("var ret = ({0}.Internal*) Marshal.AllocHGlobal({1});",
className, @class.Layout.Size); className, @class.Layout.Size);
WriteLine("*ret = native;", className); WriteLine("*ret = native;", className);
WriteLine("return ret;"); WriteLine("return ret;");
@ -1994,7 +2001,7 @@ namespace CppSharp.Generators.CSharp
PopBlock(NewLineKind.BeforeNextBlock); PopBlock(NewLineKind.BeforeNextBlock);
} }
PushBlock(CSharpBlockKind.Method); PushBlock(CSharpBlockKind.Method);
WriteLine("internal {0}({1}.Internal native)", safeIdentifier, className); WriteLine("private {0}({1}.Internal native)", safeIdentifier, className);
WriteLineIndent(@class.IsRefType ? ": this(__CopyValue(native))" : ": this(&native)"); WriteLineIndent(@class.IsRefType ? ": this(__CopyValue(native))" : ": this(&native)");
WriteStartBraceIndent(); WriteStartBraceIndent();
if (@class.IsRefType) if (@class.IsRefType)

Loading…
Cancel
Save