Skip to content

Commit

Permalink
Improve managed method naming by using the standard function name
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed May 19, 2024
1 parent c5e943c commit 686ceb2
Show file tree
Hide file tree
Showing 26 changed files with 148 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ private void ProcessCSharpMethods(CSharpConverter converter, CSharpElement eleme
if (returnElementType is CppPrimitiveType { Kind: CppPrimitiveKind.Char })
{
newManagedMethod ??= csMethod.Clone();
newManagedMethod.Name = $"{newManagedMethod.Name}_string";
csMethod.Name = $"{csMethod.Name}_";
newManagedMethod.ReturnType = new CSharpTypeWithAttributes(CSharpPrimitiveType.String())
{
Attributes = { new CSharpMarshalUsingAttribute("typeof(Utf8CustomMarshaller)") { Scope = CSharpAttributeScope.Return } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void ProcessStringArgs(CSharpMethod csMethod)
if (returnElementType is CppPrimitiveType { Kind: CppPrimitiveKind.Char })
{
newManagedMethod ??= csMethod.Clone();
newManagedMethod.Name = $"{newManagedMethod.Name}_string";
csMethod.Name = $"{csMethod.Name}_";
newManagedMethod.ReturnType = new CSharpTypeWithAttributes(CSharpPrimitiveType.String())
{
Attributes = { new CSharpMarshalUsingAttribute("typeof(Utf8CustomMarshaller)") { Scope = CSharpAttributeScope.Return } }
Expand All @@ -191,7 +191,7 @@ private void ProcessStringArgs(CSharpMethod csMethod)
else if (csMethod.Name.Contains("16") && returnElementType is CppPrimitiveType { Kind: CppPrimitiveKind.Void })
{
newManagedMethod ??= csMethod.Clone();
newManagedMethod.Name = $"{newManagedMethod.Name}_string";
csMethod.Name = $"{csMethod.Name}_";
newManagedMethod.ReturnType = new CSharpTypeWithAttributes(CSharpPrimitiveType.String())
{
Attributes = { new CSharpMarshalAsAttribute(UnmanagedType.LPWStr)
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/XenoAtom.Interop.CodeGen/zlib/ZlibGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private void ProcessStringArgs(CSharpMethod csMethod)
if (returnElementType is CppPrimitiveType { Kind: CppPrimitiveKind.Char })
{
newManagedMethod ??= csMethod.Clone();
newManagedMethod.Name = $"{newManagedMethod.Name}_string";
csMethod.Name = $"{csMethod.Name}_";
newManagedMethod.ReturnType = new CSharpTypeWithAttributes(CSharpPrimitiveType.String())
{
Attributes = { new CSharpMarshalUsingAttribute("typeof(Utf8CustomMarshaller)") { Scope = CSharpAttributeScope.Return } }
Expand Down
4 changes: 2 additions & 2 deletions src/libgit2/XenoAtom.Interop.libgit2.Tests/BasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void TestSimple()
// Alternatively git_repository_open(out var repo, repoPath);
result = git_repository_open_ext(out var repo, AppContext.BaseDirectory, 0, default);
Assert.IsTrue(result.Success);
var repoPath2 = git_repository_path_string(repo);
var repoPath2 = git_repository_path(repo);
Assert.AreEqual(repoPath, repoPath2);

// Iterate over the commits
Expand All @@ -38,7 +38,7 @@ public void TestSimple()
result = git_commit_lookup(out var commit, repo, oid);
Assert.IsTrue(result.Success);

var message = git_commit_message_string(commit);
var message = git_commit_message(commit);
hashCode += message.GetHashCode();
git_commit_free(commit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static unsafe partial class libgit2
/// <returns>@return ref name.</returns>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_annotated_commit_ref")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_annotated_commit_ref(libgit2.git_annotated_commit commit);
public static partial byte* git_annotated_commit_ref_(libgit2.git_annotated_commit commit);

/// <summary>
/// Get the refname that the given `git_annotated_commit` refers to.
Expand All @@ -140,7 +140,7 @@ public static unsafe partial class libgit2
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_annotated_commit_ref")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_annotated_commit_ref_string(libgit2.git_annotated_commit commit);
public static partial string git_annotated_commit_ref(libgit2.git_annotated_commit commit);

/// <summary>
/// Frees a `git_annotated_commit`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static unsafe partial class libgit2
/// </remarks>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_message_encoding")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_commit_message_encoding(libgit2.git_commit commit);
public static partial byte* git_commit_message_encoding_(libgit2.git_commit commit);

/// <summary>
/// Get the encoding for the message of a commit,
Expand All @@ -158,7 +158,7 @@ public static unsafe partial class libgit2
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_message_encoding")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_commit_message_encoding_string(libgit2.git_commit commit);
public static partial string git_commit_message_encoding(libgit2.git_commit commit);

/// <summary>
/// Get the full message of a commit.
Expand All @@ -171,7 +171,7 @@ public static unsafe partial class libgit2
/// </remarks>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_message")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_commit_message(libgit2.git_commit commit);
public static partial byte* git_commit_message_(libgit2.git_commit commit);

/// <summary>
/// Get the full message of a commit.
Expand All @@ -185,7 +185,7 @@ public static unsafe partial class libgit2
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_message")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_commit_message_string(libgit2.git_commit commit);
public static partial string git_commit_message(libgit2.git_commit commit);

/// <summary>
/// Get the full raw message of a commit.
Expand All @@ -194,7 +194,7 @@ public static unsafe partial class libgit2
/// <returns>@return the raw message of a commit</returns>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_message_raw")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_commit_message_raw(libgit2.git_commit commit);
public static partial byte* git_commit_message_raw_(libgit2.git_commit commit);

/// <summary>
/// Get the full raw message of a commit.
Expand All @@ -204,7 +204,7 @@ public static unsafe partial class libgit2
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_message_raw")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_commit_message_raw_string(libgit2.git_commit commit);
public static partial string git_commit_message_raw(libgit2.git_commit commit);

/// <summary>
/// Get the short "summary" of the git commit message.
Expand All @@ -217,7 +217,7 @@ public static unsafe partial class libgit2
/// </remarks>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_summary")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_commit_summary(libgit2.git_commit commit);
public static partial byte* git_commit_summary_(libgit2.git_commit commit);

/// <summary>
/// Get the short "summary" of the git commit message.
Expand All @@ -231,7 +231,7 @@ public static unsafe partial class libgit2
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_summary")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_commit_summary_string(libgit2.git_commit commit);
public static partial string git_commit_summary(libgit2.git_commit commit);

/// <summary>
/// Get the long "body" of the git commit message.
Expand All @@ -246,7 +246,7 @@ public static unsafe partial class libgit2
/// </remarks>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_body")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_commit_body(libgit2.git_commit commit);
public static partial byte* git_commit_body_(libgit2.git_commit commit);

/// <summary>
/// Get the long "body" of the git commit message.
Expand All @@ -262,7 +262,7 @@ public static unsafe partial class libgit2
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_body")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_commit_body_string(libgit2.git_commit commit);
public static partial string git_commit_body(libgit2.git_commit commit);

/// <summary>
/// Get the commit time (i.e. committer time) of a commit.
Expand Down Expand Up @@ -337,7 +337,7 @@ public static unsafe partial class libgit2
/// <returns>@return the header text of the commit</returns>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_raw_header")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_commit_raw_header(libgit2.git_commit commit);
public static partial byte* git_commit_raw_header_(libgit2.git_commit commit);

/// <summary>
/// Get the full raw text of the commit header.
Expand All @@ -347,7 +347,7 @@ public static unsafe partial class libgit2
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_commit_raw_header")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_commit_raw_header_string(libgit2.git_commit commit);
public static partial string git_commit_raw_header(libgit2.git_commit commit);

/// <summary>
/// Get the tree pointed to by a commit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public enum git_libgit2_opt_t : uint
/// <returns>@return the name of the prerelease state or NULL</returns>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_libgit2_prerelease")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_libgit2_prerelease();
public static partial byte* git_libgit2_prerelease_();

/// <summary>
/// Return the prerelease state of the libgit2 library currently being
Expand All @@ -294,7 +294,7 @@ public enum git_libgit2_opt_t : uint
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_libgit2_prerelease")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_libgit2_prerelease_string();
public static partial string git_libgit2_prerelease();

/// <summary>
/// Query compile time options for libgit2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public enum git_credential_t : uint
/// <returns>@return the credential username, or NULL if not applicable</returns>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_credential_get_username")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_credential_get_username(libgit2.git_credential cred);
public static partial byte* git_credential_get_username_(libgit2.git_credential cred);

/// <summary>
/// Return the username associated with a credential object.
Expand All @@ -390,7 +390,7 @@ public enum git_credential_t : uint
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_credential_get_username")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_credential_get_username_string(libgit2.git_credential cred);
public static partial string git_credential_get_username(libgit2.git_credential cred);

/// <summary>
/// Create a new plain-text username and password credential object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public partial struct git_index_entry
/// <returns>@return path to index file or NULL for in-memory index</returns>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_index_path")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_index_path(libgit2.git_index index);
public static partial byte* git_index_path_(libgit2.git_index index);

/// <summary>
/// Get the full path to the index file on disk.
Expand All @@ -383,7 +383,7 @@ public partial struct git_index_entry
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_index_path")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_index_path_string(libgit2.git_index index);
public static partial string git_index_path(libgit2.git_index index);

/// <summary>
/// Read a tree into the index file with stats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public partial struct git_indexer_options
/// </remarks>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_indexer_name")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_indexer_name(libgit2.git_indexer idx);
public static partial byte* git_indexer_name_(libgit2.git_indexer idx);

/// <summary>
/// Get the unique name for the resulting packfile.
Expand All @@ -230,7 +230,7 @@ public partial struct git_indexer_options
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_indexer_name")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_indexer_name_string(libgit2.git_indexer idx);
public static partial string git_indexer_name(libgit2.git_indexer idx);

/// <summary>
/// Free the indexer and its resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static unsafe partial class libgit2
/// <returns>@return the note message</returns>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_note_message")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_note_message(libgit2.git_note note);
public static partial byte* git_note_message_(libgit2.git_note note);

/// <summary>
/// Get the note message
Expand All @@ -195,7 +195,7 @@ public static unsafe partial class libgit2
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_note_message")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_note_message_string(libgit2.git_note note);
public static partial string git_note_message(libgit2.git_note note);

/// <summary>
/// Get the note object's id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public static unsafe partial class libgit2
/// </remarks>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_object_type2string")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_object_type2string(libgit2.git_object_t type);
public static partial byte* git_object_type2string_(libgit2.git_object_t type);

/// <summary>
/// Convert an object type to its string representation.
Expand All @@ -182,7 +182,7 @@ public static unsafe partial class libgit2
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_object_type2string")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_object_type2string_string(libgit2.git_object_t type);
public static partial string git_object_type2string(libgit2.git_object_t type);

/// <summary>
/// Convert a string object type representation to it's git_object_t.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public enum git_packbuilder_stage_t : uint
/// </remarks>
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_packbuilder_name")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static partial byte* git_packbuilder_name(libgit2.git_packbuilder pb);
public static partial byte* git_packbuilder_name_(libgit2.git_packbuilder pb);

/// <summary>
/// Get the unique name for the resulting packfile.
Expand All @@ -276,7 +276,7 @@ public enum git_packbuilder_stage_t : uint
[global::System.Runtime.InteropServices.LibraryImport(LibraryName, EntryPoint = "git_packbuilder_name")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[return:global::System.Runtime.InteropServices.Marshalling.MarshalUsing(typeof(Utf8CustomMarshaller))]
public static partial string git_packbuilder_name_string(libgit2.git_packbuilder pb);
public static partial string git_packbuilder_name(libgit2.git_packbuilder pb);

/// <summary>
/// Create the new pack and pass each object to the callback
Expand Down
Loading

0 comments on commit 686ceb2

Please sign in to comment.