+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace {Namespace.GetInternalName(functions.First().Namespace)};

// AUTOGENERATED FILE - DO NOT MODIFY

public partial class Functions
public static partial class Functions
{{
{Functions.Render(functions)}
}}";
Expand Down
10 changes: 10 additions & 0 deletions src/Libs/GObject-2.0/Internal/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@ public partial class Functions
// why it is defined manually here.
[DllImport(ImportResolver.Library, EntryPoint = "g_strv_get_type")]
internal static extern nuint StrvGetType();

/// <summary>
/// Returns whether the given type is a fundamental type.
/// </summary>
/// <returns>True if the type is fundamental otherwise false.</returns>
public static bool IsFundamental(nuint type)
{
//255 << 2 corresponds to G_TYPE_FUNDAMENTAL_MAX
return type <= (255 << 2);
}
}
13 changes: 13 additions & 0 deletions src/Tests/Libs/GObject-2.0.Tests/Records/TypeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,17 @@ public void SizeOfTypeIs8()
sizeof(Type).Should().Be(8);
}
}

[TestMethod]
public void FundamentalTypesCanBeDetected()
{
//(255 << 2) => G_TYPE_FUNDAMENTAL_MAX
Internal.Functions.IsFundamental(255 << 2).Should().BeTrue();

//Fundamental types
Internal.Functions.IsFundamental(Object.GetGType().Value).Should().BeTrue();

//Non fundamental types
Internal.Functions.IsFundamental(Binding.GetGType().Value).Should().BeFalse();
}
}
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载