-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #526 from gircore/feature/tests_enforce_garbage_co…
…llection Do not free unowned record handles
- Loading branch information
Showing
22 changed files
with
260 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/Generation/Generator3/Model/Internal/ReturnType/CallbackReturnTypeFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace Generator3.Model.Internal | ||
{ | ||
public static class CallbackReturnTypeFactory | ||
{ | ||
public static ReturnType CreateInternalModelForCallback(this GirModel.ReturnType returnValue) => returnValue.AnyType.Match<ReturnType>( | ||
type => type switch | ||
{ | ||
GirModel.PrimitiveValueType => new PrimitiveValueReturnType(returnValue), | ||
GirModel.Bitfield => new BitfieldReturnType(returnValue), | ||
GirModel.Enumeration => new EnumerationReturnType(returnValue), | ||
GirModel.Utf8String => new Utf8StringReturnType(returnValue), | ||
GirModel.PlatformString => new PlatformStringReturnType(returnValue), | ||
GirModel.Record => new RecordReturnTypeForCallback(returnValue), | ||
GirModel.Union => new UnionReturnType(returnValue), | ||
GirModel.Class => new ClassReturnType(returnValue), | ||
GirModel.Interface => new InterfaceReturnType(returnValue), | ||
GirModel.Pointer => new PointerReturnType(returnValue), | ||
_ => new StandardReturnType(returnValue) | ||
}, | ||
arrayType => arrayType.AnyType.Match<ReturnType>( | ||
type => type switch | ||
{ | ||
GirModel.String => new ArrayStringReturnType(returnValue), | ||
GirModel.Record => new ArrayRecordReturnType(returnValue), | ||
GirModel.Class => new ArrayClassReturnType(returnValue), | ||
GirModel.PrimitiveValueType => new ArrayPrimitiveValueReturnType(returnValue), | ||
_ => new StandardReturnType(returnValue) | ||
}, | ||
_ => new StandardReturnType(returnValue) | ||
) | ||
); | ||
} | ||
} |
9 changes: 6 additions & 3 deletions
9
src/Generation/Generator3/Model/Internal/ReturnType/RecordReturnType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Generation/Generator3/Model/Internal/ReturnType/RecordReturnTypeForCallback.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Generator3.Converter; | ||
using GirModel; | ||
|
||
namespace Generator3.Model.Internal | ||
{ | ||
public class RecordReturnTypeForCallback : ReturnType | ||
{ | ||
private GirModel.Record Type => (GirModel.Record) Model.AnyType.AsT0; | ||
|
||
public override string NullableTypeName => !IsPointer | ||
? Type.GetFullyQualifiedInternalStructName() | ||
: Type.GetFullyQualifiedInternalHandle(); | ||
|
||
protected internal RecordReturnTypeForCallback(GirModel.ReturnType returnValue) : base(returnValue) | ||
{ | ||
returnValue.AnyType.VerifyType<GirModel.Record>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.