Skip to content

Commit

Permalink
Merging the Extensions and Wrappers folders
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Nov 23, 2019
1 parent 0c1f271 commit 163326a
Show file tree
Hide file tree
Showing 156 changed files with 496 additions and 732 deletions.
19 changes: 0 additions & 19 deletions sources/LLVMSharp/Extensions/LLVMMemoryBufferRef.cs

This file was deleted.

19 changes: 0 additions & 19 deletions sources/LLVMSharp/Extensions/LLVMTargetLibraryInfoRef.cs

This file was deleted.

19 changes: 0 additions & 19 deletions sources/LLVMSharp/Extensions/LLVMTargetMachineRef.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,25 @@

namespace LLVMSharp
{
public partial struct LLVMAttributeRef : IEquatable<LLVMAttributeRef>
public unsafe partial struct LLVMAttributeRef : IEquatable<LLVMAttributeRef>
{
public LLVMAttributeRef(IntPtr pointer)
{
Pointer = pointer;
}

public IntPtr Pointer;

public static implicit operator LLVMAttributeRef(LLVMOpaqueAttributeRef* value)
{
return new LLVMAttributeRef((IntPtr)value);
}

public static implicit operator LLVMOpaqueAttributeRef*(LLVMAttributeRef value)
{
return (LLVMOpaqueAttributeRef*)value.Pointer;
}

public static bool operator ==(LLVMAttributeRef left, LLVMAttributeRef right) => left.Equals(right);

public static bool operator !=(LLVMAttributeRef left, LLVMAttributeRef right) => !(left == right);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@ namespace LLVMSharp
{
public unsafe partial struct LLVMBasicBlockRef : IEquatable<LLVMBasicBlockRef>
{
public LLVMBasicBlockRef(IntPtr pointer)
{
Pointer = pointer;
}

public IntPtr Pointer;

public static explicit operator LLVMBasicBlockRef(LLVMOpaqueValue* value)
{
return new LLVMBasicBlockRef((IntPtr)value);
}

public static implicit operator LLVMBasicBlockRef(LLVMOpaqueBasicBlock* value)
{
return new LLVMBasicBlockRef((IntPtr)value);
}

public static implicit operator LLVMOpaqueBasicBlock*(LLVMBasicBlockRef value)
{
return (LLVMOpaqueBasicBlock*)value.Pointer;
}

public static implicit operator LLVMOpaqueValue*(LLVMBasicBlockRef value)
{
return (LLVMOpaqueValue*)value.Pointer;
}

public LLVMValueRef FirstInstruction => (Pointer != IntPtr.Zero) ? LLVM.GetFirstInstruction(this) : default;

public LLVMValueRef LastInstruction => (Pointer != IntPtr.Zero) ? LLVM.GetLastInstruction(this) : default;
Expand All @@ -22,18 +49,18 @@ public unsafe partial struct LLVMBasicBlockRef : IEquatable<LLVMBasicBlockRef>

public static bool operator !=(LLVMBasicBlockRef left, LLVMBasicBlockRef right) => !(left == right);

public override bool Equals(object obj) => obj is LLVMBasicBlockRef other && Equals(other);

public bool Equals(LLVMBasicBlockRef other) => Pointer == other.Pointer;

public override int GetHashCode() => Pointer.GetHashCode();

public LLVMValueRef AsValue() => LLVM.BasicBlockAsValue(this);

public void Delete() => LLVM.DeleteBasicBlock(this);

public void Dump() => LLVM.DumpValue(this);

public override bool Equals(object obj) => obj is LLVMBasicBlockRef other && Equals(other);

public bool Equals(LLVMBasicBlockRef other) => Pointer == other.Pointer;

public override int GetHashCode() => Pointer.GetHashCode();

public LLVMBasicBlockRef InsertBasicBlock(string Name)
{
using (var marshaledName = new MarshaledString(Name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,34 @@ namespace LLVMSharp
{
public unsafe partial struct LLVMBuilderRef : IDisposable, IEquatable<LLVMBuilderRef>
{
public LLVMValueRef CurrentDebugLocation
public LLVMBuilderRef(IntPtr pointer)
{
get => (Pointer != IntPtr.Zero) ? LLVM.GetCurrentDebugLocation(this) : default;
set => LLVM.SetCurrentDebugLocation(this, value);
Pointer = pointer;
}

public LLVMBasicBlockRef InsertBlock => (Pointer != IntPtr.Zero) ? LLVM.GetInsertBlock(this) : default;
public IntPtr Pointer;

public static bool operator ==(LLVMBuilderRef left, LLVMBuilderRef right) => left.Equals(right);
public static implicit operator LLVMBuilderRef(LLVMOpaqueBuilder* Builder)
{
return new LLVMBuilderRef((IntPtr)Builder);
}

public static bool operator !=(LLVMBuilderRef left, LLVMBuilderRef right) => !(left == right);
public static implicit operator LLVMOpaqueBuilder*(LLVMBuilderRef Builder)
{
return (LLVMOpaqueBuilder*)Builder.Pointer;
}

public void Dispose()
public LLVMValueRef CurrentDebugLocation
{
if (Pointer != IntPtr.Zero)
{
LLVM.DisposeBuilder(this);
Pointer = IntPtr.Zero;
}
get => (Pointer != IntPtr.Zero) ? LLVM.GetCurrentDebugLocation(this) : default;
set => LLVM.SetCurrentDebugLocation(this, value);
}

public override bool Equals(object obj) => obj is LLVMBuilderRef other && Equals(other);
public LLVMBasicBlockRef InsertBlock => (Pointer != IntPtr.Zero) ? LLVM.GetInsertBlock(this) : default;

public bool Equals(LLVMBuilderRef other) => Pointer == other.Pointer;
public static bool operator ==(LLVMBuilderRef left, LLVMBuilderRef right) => left.Equals(right);

public override int GetHashCode() => Pointer.GetHashCode();
public static bool operator !=(LLVMBuilderRef left, LLVMBuilderRef right) => !(left == right);

public LLVMValueRef BuildAdd(LLVMValueRef LHS, LLVMValueRef RHS, string Name = "")
{
Expand Down Expand Up @@ -120,10 +122,10 @@ public LLVMValueRef BuildBitCast(LLVMValueRef Val, LLVMTypeRef DestTy, string Na
public LLVMValueRef BuildCall(LLVMValueRef Fn, LLVMValueRef[] Args, string Name = "")
{
fixed (LLVMValueRef* pArgs = Args)
using (var marshaledName = new MarshaledString(Name))
{
return LLVM.BuildCall(this, Fn, (LLVMOpaqueValue**)pArgs, (uint)Args?.Length, marshaledName);
}
using (var marshaledName = new MarshaledString(Name))
{
return LLVM.BuildCall(this, Fn, (LLVMOpaqueValue**)pArgs, (uint)Args?.Length, marshaledName);
}
}

public LLVMValueRef BuildCast(LLVMOpcode Op, LLVMValueRef Val, LLVMTypeRef DestTy, string Name = "")
Expand Down Expand Up @@ -692,9 +694,22 @@ public LLVMValueRef BuildZExtOrBitCast(LLVMValueRef Val, LLVMTypeRef DestTy, str
return LLVM.BuildZExtOrBitCast(this, Val, DestTy, marshaledName);
}
}
public void ClearInsertionPosition() => LLVM.ClearInsertionPosition(this);

public void Dispose()
{
if (Pointer != IntPtr.Zero)
{
LLVM.DisposeBuilder(this);
Pointer = IntPtr.Zero;
}
}

public void ClearInsertionPosition() => LLVM.ClearInsertionPosition(this);
public override bool Equals(object obj) => obj is LLVMBuilderRef other && Equals(other);

public bool Equals(LLVMBuilderRef other) => Pointer == other.Pointer;

public override int GetHashCode() => Pointer.GetHashCode();

public void Insert(LLVMValueRef Instr) => LLVM.InsertIntoBuilder(this, Instr);

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ namespace LLVMSharp
{
public unsafe partial struct LLVMContextRef : IDisposable, IEquatable<LLVMContextRef>
{
public LLVMContextRef(IntPtr pointer)
{
Pointer = pointer;
}

public IntPtr Pointer;

public static implicit operator LLVMContextRef(LLVMOpaqueContext* value)
{
return new LLVMContextRef((IntPtr)value);
}

public static implicit operator LLVMOpaqueContext*(LLVMContextRef value)
{
return (LLVMOpaqueContext*)value.Pointer;
}

public static LLVMContextRef Global => LLVM.GetGlobalContext();

public LLVMTypeRef DoubleType => (Pointer != IntPtr.Zero) ? LLVM.DoubleTypeInContext(this) : default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,25 @@

namespace LLVMSharp
{
public partial struct LLVMDiagnosticInfoRef : IEquatable<LLVMDiagnosticInfoRef>
public unsafe partial struct LLVMDiagnosticInfoRef : IEquatable<LLVMDiagnosticInfoRef>
{
public LLVMDiagnosticInfoRef(IntPtr pointer)
{
Pointer = pointer;
}

public IntPtr Pointer;

public static implicit operator LLVMDiagnosticInfoRef(LLVMOpaqueDiagnosticInfo* value)
{
return new LLVMDiagnosticInfoRef((IntPtr)value);
}

public static implicit operator LLVMOpaqueDiagnosticInfo*(LLVMDiagnosticInfoRef value)
{
return (LLVMOpaqueDiagnosticInfo*)value.Pointer;
}

public static bool operator ==(LLVMDiagnosticInfoRef left, LLVMDiagnosticInfoRef right) => left.Equals(right);

public static bool operator !=(LLVMDiagnosticInfoRef left, LLVMDiagnosticInfoRef right) => !(left == right);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,25 @@

namespace LLVMSharp
{
public partial struct LLVMDisasmContextRef : IEquatable<LLVMDisasmContextRef>
public unsafe partial struct LLVMDisasmContextRef : IEquatable<LLVMDisasmContextRef>
{
public LLVMDisasmContextRef(IntPtr pointer)
{
Pointer = pointer;
}

public IntPtr Pointer;

public static explicit operator LLVMDisasmContextRef(void* value)
{
return new LLVMDisasmContextRef((IntPtr)value);
}

public static implicit operator void*(LLVMDisasmContextRef value)
{
return (void*)value.Pointer;
}

public static bool operator ==(LLVMDisasmContextRef left, LLVMDisasmContextRef right) => left.Pointer == right.Pointer;

public static bool operator !=(LLVMDisasmContextRef left, LLVMDisasmContextRef right) => !(left == right);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ namespace LLVMSharp
{
public unsafe partial struct LLVMExecutionEngineRef : IDisposable, IEquatable<LLVMExecutionEngineRef>
{
public LLVMExecutionEngineRef(IntPtr pointer)
{
Pointer = pointer;
}

public IntPtr Pointer;

public static implicit operator LLVMExecutionEngineRef(LLVMOpaqueExecutionEngine* value)
{
return new LLVMExecutionEngineRef((IntPtr)value);
}

public static implicit operator LLVMOpaqueExecutionEngine*(LLVMExecutionEngineRef value)
{
return (LLVMOpaqueExecutionEngine*)value.Pointer;
}

public LLVMTargetDataRef TargetData => (Pointer != IntPtr.Zero) ? LLVM.GetExecutionEngineTargetData(this) : default;

public LLVMTargetMachineRef TargetMachine => (Pointer != IntPtr.Zero) ? LLVM.GetExecutionEngineTargetMachine(this) : default;
Expand All @@ -17,12 +34,6 @@ public unsafe partial struct LLVMExecutionEngineRef : IDisposable, IEquatable<LL

public void AddGlobalMapping(LLVMValueRef Global, IntPtr Addr) => LLVM.AddGlobalMapping(this, Global, (void*)Addr);

public override bool Equals(object obj) => obj is LLVMExecutionEngineRef other && Equals(other);

public bool Equals(LLVMExecutionEngineRef other) => Pointer == other.Pointer;

public override int GetHashCode() => Pointer.GetHashCode();

public void AddModule(LLVMModuleRef M) => LLVM.AddModule(this, M);

public void Dispose()
Expand All @@ -34,6 +45,10 @@ public void Dispose()
}
}

public override bool Equals(object obj) => obj is LLVMExecutionEngineRef other && Equals(other);

public bool Equals(LLVMExecutionEngineRef other) => Pointer == other.Pointer;

public LLVMValueRef FindFunction(string Name)
{
if (!TryFindFunction(Name, out var Fn))
Expand Down Expand Up @@ -62,6 +77,8 @@ public ulong GetGlobalValueAddress(string Name)
}
}

public override int GetHashCode() => Pointer.GetHashCode();

public IntPtr GetPointerToGlobal(LLVMValueRef Global) => (IntPtr)LLVM.GetPointerToGlobal(this, Global);

public TDelegate GetPointerToGlobal<TDelegate>(LLVMValueRef Global)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ namespace LLVMSharp
{
public unsafe partial struct LLVMGenericValueRef : IEquatable<LLVMGenericValueRef>
{
public LLVMGenericValueRef(IntPtr pointer)
{
Pointer = pointer;
}

public IntPtr Pointer;

public static implicit operator LLVMGenericValueRef(LLVMOpaqueGenericValue* GenericValue)
{
return new LLVMGenericValueRef((IntPtr)GenericValue);
}

public static implicit operator LLVMOpaqueGenericValue*(LLVMGenericValueRef GenericValue)
{
return (LLVMOpaqueGenericValue*)GenericValue.Pointer;
}

public static bool operator ==(LLVMGenericValueRef left, LLVMGenericValueRef right) => left.Pointer == right.Pointer;

public static bool operator !=(LLVMGenericValueRef left, LLVMGenericValueRef right) => !(left == right);
Expand Down
Loading

0 comments on commit 163326a

Please sign in to comment.