-
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.
- Loading branch information
Showing
42 changed files
with
618 additions
and
761 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
32 changes: 32 additions & 0 deletions
32
src/Generation/Generator/Generator/Internal/ClassHandle.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,32 @@ | ||
using Generator.Model; | ||
|
||
namespace Generator.Generator.Internal; | ||
|
||
internal class ClassHandle : Generator<GirModel.Class> | ||
{ | ||
private readonly Publisher _publisher; | ||
|
||
public ClassHandle(Publisher publisher) | ||
{ | ||
_publisher = publisher; | ||
} | ||
|
||
public void Generate(GirModel.Class obj) | ||
{ | ||
if (obj.Fundamental) | ||
return; | ||
|
||
if (obj.Parent is null) | ||
return; //Do not generate a handle for GObject.Object itself | ||
|
||
var source = Renderer.Internal.ClassHandle.Render(obj); | ||
var codeUnit = new CodeUnit( | ||
Project: Namespace.GetCanonicalName(obj.Namespace), | ||
Name: Class.GetInternalHandleName(obj), | ||
Source: source, | ||
IsInternal: true | ||
); | ||
|
||
_publisher.Publish(codeUnit); | ||
} | ||
} |
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
26 changes: 0 additions & 26 deletions
26
src/Generation/Generator/Generator/Public/Interface/InterfaceFramework.cs
This file was deleted.
Oops, something went wrong.
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
48 changes: 48 additions & 0 deletions
48
src/Generation/Generator/Renderer/Internal/Class/ClassHandle.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,48 @@ | ||
using Generator.Model; | ||
|
||
namespace Generator.Renderer.Internal; | ||
|
||
internal static class ClassHandle | ||
{ | ||
public static string Render(GirModel.Class cls) | ||
{ | ||
var handleName = Class.GetInternalHandleName(cls); | ||
|
||
return $$""" | ||
using System; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Versioning; | ||
|
||
#nullable enable | ||
|
||
namespace {{Namespace.GetInternalName(cls.Namespace)}}; | ||
|
||
public partial class {{handleName}} : GObject.Internal.ObjectHandle | ||
{ | ||
public {{handleName}}(IntPtr handle, bool ownsHandle) : base(handle, ownsHandle){ } | ||
|
||
public static {{handleName}} For<T>(bool owned, GObject.ConstructArgument[] constructArguments) where T : {{Class.GetFullyQualifiedPublicName(cls)}}, GObject.GTypeProvider | ||
{ | ||
// We can't check if a reference is floating via "g_object_is_floating" here | ||
// as the function could be "lying" depending on the intent of framework writers. | ||
// E.g. A Gtk.Window created via "g_object_new_with_properties" returns an unowned | ||
// reference which is not marked as floating as the gtk toolkit "owns" it. | ||
// For this reason we just delegate the problem to the caller and require a | ||
// definition whether the ownership of the new object will be transferred to us or not. | ||
|
||
var ptr = GObject.Internal.Object.NewWithProperties( | ||
objectType: T.GetGType(), | ||
nProperties: (uint) constructArguments.Length, | ||
names: constructArguments.Select(x => x.Name).ToArray(), | ||
values: GObject.Internal.ValueArray2OwnedHandle.Create(constructArguments.Select(x => x.Value).ToArray()) | ||
); | ||
|
||
return new {{handleName}}(ptr, owned); | ||
} | ||
} | ||
"""; | ||
} | ||
|
||
|
||
} |
File renamed without changes.
File renamed without changes.
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.