Skip to content

Commit

Permalink
Fix repository.generated.cs (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Jun 16, 2019
1 parent 053414a commit 6da77e5
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/LibGit2.CodeGen/LibGit2.CodeGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CppAst.CodeGen" Version="0.2.0" />
<PackageReference Include="CppAst.CodeGen" Version="0.2.2" />
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions src/LibGit2.CodeGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ public void Run()
// Remove this function as it is not supported (varargs)
e => e.Map<CppFunction>("git_libgit2_opts").Discard(),

// Mappings for repository.h
e => e.MapMacroToConst("GIT_REPOSITORY_INIT_OPTIONS_VERSION", "unsigned int"),
e => e.Map<CppParameter>("git_repository_open_ext::flags").Type("git_repository_open_flag_t"),
e => e.Map<CppParameter>("git_repository_init::is_bare").Type("bool").MarshalAs(CSharpUnmanagedKind.I4),
e => e.Map<CppParameter>("git_repository_discover::across_fs").Type("bool").MarshalAs(CSharpUnmanagedKind.I4),
e => e.Map<CppParameter>("git_repository_init_init_options::version").InitValue("GIT_REPOSITORY_INIT_OPTIONS_VERSION"),
e => e.Map<CppParameter>("git_repository_set_workdir::update_gitlink").Type("bool").MarshalAs(CSharpUnmanagedKind.I4),
e => e.Map<CppField>("git_repository_init_options::flags").Type("git_repository_init_flag_t"),
e => e.Map<CppField>("git_repository_init_options::mode").Type("git_repository_init_mode_t"),
e => e.Map<CppFunction>("git_repository_state").Type("git_repository_state_t"),
e => e.Map<CppFunction>("git_repository_is_shallow").Type("bool").MarshalAs(CSharpUnmanagedKind.I4),
e => e.Map<CppFunction>("git_repository_ident").Type("git_result"),
e => e.Map<CppFunction>("git_repository_set_ident").Type("git_result"),

e => e.Map<CppField>("git_strarray::strings").Private(),
e => e.Map<CppField>("git_strarray::count").Private(),
e => e.MapAll<CppParameter>().CSharpAction(ProcessCSharpParameter),
Expand Down Expand Up @@ -131,6 +145,7 @@ private void ProcessCppFunctions(CSharpConverter converter, CppElement cppFuncti
(returnText.Contains("0 on success") && returnText.Contains("0 on failure")) ||
(returnText.StartsWith("0") && (
returnText.Contains("or an error") ||
returnText.Contains("-1 on error") ||
returnText.Contains("or error") ||
returnText.Contains("error code otherwise") ||
returnText.Contains("other errors") ||
Expand Down
2 changes: 2 additions & 0 deletions src/LibGit2/generated/cppast.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ public static partial class libgit2

public static bool operator !=(git_result left, git_result right) => !left.Equals(right);
}

public const uint GIT_REPOSITORY_INIT_OPTIONS_VERSION = 1;
}
}
40 changes: 32 additions & 8 deletions src/LibGit2/generated/pathspec.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,14 @@ public static git_result git_pathspec_new(out git_pathspec @out, string[] pathsp
/// pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES`
/// flag). You must call `git_pathspec_match_list_free()` on this object.
/// </remarks>
[DllImport(LibGit2Name, CallingConvention = CallingConvention.Cdecl)]
public static extern int git_pathspec_match_workdir(out git_pathspec_match_list @out, git_repository repo, uint flags, git_pathspec ps);
public static git_result git_pathspec_match_workdir(out git_pathspec_match_list @out, git_repository repo, uint flags, git_pathspec ps)
{
var __result__ = git_pathspec_match_workdir__(out @out, repo, flags, ps).Check();
return __result__;
}

[DllImport(LibGit2Name, EntryPoint = "git_pathspec_match_workdir", CallingConvention = CallingConvention.Cdecl)]
private static extern git_result git_pathspec_match_workdir__(out git_pathspec_match_list @out, git_repository repo, uint flags, git_pathspec ps);

/// <summary>
/// Match a pathspec against entries in an index.
Expand All @@ -242,8 +248,14 @@ public static git_result git_pathspec_new(out git_pathspec @out, string[] pathsp
/// pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES`
/// flag). You must call `git_pathspec_match_list_free()` on this object.
/// </remarks>
[DllImport(LibGit2Name, CallingConvention = CallingConvention.Cdecl)]
public static extern int git_pathspec_match_index(out git_pathspec_match_list @out, git_index index, uint flags, git_pathspec ps);
public static git_result git_pathspec_match_index(out git_pathspec_match_list @out, git_index index, uint flags, git_pathspec ps)
{
var __result__ = git_pathspec_match_index__(out @out, index, flags, ps).Check();
return __result__;
}

[DllImport(LibGit2Name, EntryPoint = "git_pathspec_match_index", CallingConvention = CallingConvention.Cdecl)]
private static extern git_result git_pathspec_match_index__(out git_pathspec_match_list @out, git_index index, uint flags, git_pathspec ps);

/// <summary>
/// Match a pathspec against files in a tree.
Expand All @@ -261,8 +273,14 @@ public static git_result git_pathspec_new(out git_pathspec @out, string[] pathsp
/// pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES`
/// flag). You must call `git_pathspec_match_list_free()` on this object.
/// </remarks>
[DllImport(LibGit2Name, CallingConvention = CallingConvention.Cdecl)]
public static extern int git_pathspec_match_tree(out git_pathspec_match_list @out, git_tree tree, uint flags, git_pathspec ps);
public static git_result git_pathspec_match_tree(out git_pathspec_match_list @out, git_tree tree, uint flags, git_pathspec ps)
{
var __result__ = git_pathspec_match_tree__(out @out, tree, flags, ps).Check();
return __result__;
}

[DllImport(LibGit2Name, EntryPoint = "git_pathspec_match_tree", CallingConvention = CallingConvention.Cdecl)]
private static extern git_result git_pathspec_match_tree__(out git_pathspec_match_list @out, git_tree tree, uint flags, git_pathspec ps);

/// <summary>
/// Match a pathspec against files in a diff list.
Expand All @@ -280,8 +298,14 @@ public static git_result git_pathspec_new(out git_pathspec @out, string[] pathsp
/// pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES`
/// flag). You must call `git_pathspec_match_list_free()` on this object.
/// </remarks>
[DllImport(LibGit2Name, CallingConvention = CallingConvention.Cdecl)]
public static extern int git_pathspec_match_diff(out git_pathspec_match_list @out, git_diff diff, uint flags, git_pathspec ps);
public static git_result git_pathspec_match_diff(out git_pathspec_match_list @out, git_diff diff, uint flags, git_pathspec ps)
{
var __result__ = git_pathspec_match_diff__(out @out, diff, flags, ps).Check();
return __result__;
}

[DllImport(LibGit2Name, EntryPoint = "git_pathspec_match_diff", CallingConvention = CallingConvention.Cdecl)]
private static extern git_result git_pathspec_match_diff__(out git_pathspec_match_list @out, git_diff diff, uint flags, git_pathspec ps);

/// <summary>
/// Free memory associates with a git_pathspec_match_list
Expand Down
57 changes: 38 additions & 19 deletions src/LibGit2/generated/repository.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ public partial struct git_repository_init_options
{
public uint version;

public uint flags;
public git_repository_init_flag_t flags;

public uint mode;
public git_repository_init_mode_t mode;

[MarshalAs(UnmanagedType.LPUTF8Str)]
public string workdir_path;
Expand Down Expand Up @@ -460,14 +460,14 @@ public static git_result git_repository_wrap_odb(out git_repository @out, git_od
/// The method will automatically detect if the repository is bare
/// (if there is a repository).
/// </remarks>
public static git_result git_repository_discover(out git_buf @out, [MarshalAs(UnmanagedType.LPUTF8Str)] string start_path, int across_fs, [MarshalAs(UnmanagedType.LPUTF8Str)] string ceiling_dirs)
public static git_result git_repository_discover(out git_buf @out, [MarshalAs(UnmanagedType.LPUTF8Str)] string start_path, [MarshalAs(UnmanagedType.I4)] bool across_fs, [MarshalAs(UnmanagedType.LPUTF8Str)] string ceiling_dirs)
{
var __result__ = git_repository_discover__(out @out, start_path, across_fs, ceiling_dirs).Check();
return __result__;
}

[DllImport(LibGit2Name, EntryPoint = "git_repository_discover", CallingConvention = CallingConvention.Cdecl)]
private static extern git_result git_repository_discover__(out git_buf @out, [MarshalAs(UnmanagedType.LPUTF8Str)] string start_path, int across_fs, [MarshalAs(UnmanagedType.LPUTF8Str)] string ceiling_dirs);
private static extern git_result git_repository_discover__(out git_buf @out, [MarshalAs(UnmanagedType.LPUTF8Str)] string start_path, [MarshalAs(UnmanagedType.I4)] bool across_fs, [MarshalAs(UnmanagedType.LPUTF8Str)] string ceiling_dirs);

/// <summary>
/// Find and open a repository with extended controls.
Expand All @@ -487,7 +487,7 @@ public static git_result git_repository_discover(out git_buf @out, [MarshalAs(Un
/// or -1 if there was a repository but open failed for some reason
/// (such as repo corruption or system errors).</returns>
[DllImport(LibGit2Name, CallingConvention = CallingConvention.Cdecl)]
public static extern int git_repository_open_ext(out git_repository @out, [MarshalAs(UnmanagedType.LPUTF8Str)] string path, uint flags, [MarshalAs(UnmanagedType.LPUTF8Str)] string ceiling_dirs);
public static extern int git_repository_open_ext(out git_repository @out, [MarshalAs(UnmanagedType.LPUTF8Str)] string path, git_repository_open_flag_t flags, [MarshalAs(UnmanagedType.LPUTF8Str)] string ceiling_dirs);

/// <summary>
/// Open a bare repository on the serverside.
Expand Down Expand Up @@ -537,14 +537,14 @@ public static git_result git_repository_open_bare(out git_repository @out, [Mars
/// TODO:
/// - Reinit the repository
/// </remarks>
public static git_result git_repository_init(out git_repository @out, [MarshalAs(UnmanagedType.LPUTF8Str)] string path, uint is_bare)
public static git_result git_repository_init(out git_repository @out, [MarshalAs(UnmanagedType.LPUTF8Str)] string path, [MarshalAs(UnmanagedType.I4)] bool is_bare)
{
var __result__ = git_repository_init__(out @out, path, is_bare).Check();
return __result__;
}

[DllImport(LibGit2Name, EntryPoint = "git_repository_init", CallingConvention = CallingConvention.Cdecl)]
private static extern git_result git_repository_init__(out git_repository @out, [MarshalAs(UnmanagedType.LPUTF8Str)] string path, uint is_bare);
private static extern git_result git_repository_init__(out git_repository @out, [MarshalAs(UnmanagedType.LPUTF8Str)] string path, [MarshalAs(UnmanagedType.I4)] bool is_bare);

/// <summary>
/// Initialize git_repository_init_options structure
Expand All @@ -556,14 +556,14 @@ public static git_result git_repository_init(out git_repository @out, [MarshalAs
/// Initializes a `git_repository_init_options` with default values. Equivalent to
/// creating an instance with `GIT_REPOSITORY_INIT_OPTIONS_INIT`.
/// </remarks>
public static git_result git_repository_init_init_options(ref git_repository_init_options opts, uint version)
public static git_result git_repository_init_init_options(ref git_repository_init_options opts, uint version = GIT_REPOSITORY_INIT_OPTIONS_VERSION)
{
var __result__ = git_repository_init_init_options__(ref opts, version).Check();
return __result__;
}

[DllImport(LibGit2Name, EntryPoint = "git_repository_init_init_options", CallingConvention = CallingConvention.Cdecl)]
private static extern git_result git_repository_init_init_options__(ref git_repository_init_options opts, uint version);
private static extern git_result git_repository_init_init_options__(ref git_repository_init_options opts, uint version = GIT_REPOSITORY_INIT_OPTIONS_VERSION);

/// <summary>
/// Create a new Git repository in the given folder with extended controls.
Expand Down Expand Up @@ -748,14 +748,14 @@ public static git_result git_repository_item_path(out git_buf @out, git_reposito
/// all the common workdir operations (checkout, status, index
/// manipulation, etc).
/// </remarks>
public static git_result git_repository_set_workdir(git_repository repo, [MarshalAs(UnmanagedType.LPUTF8Str)] string workdir, int update_gitlink)
public static git_result git_repository_set_workdir(git_repository repo, [MarshalAs(UnmanagedType.LPUTF8Str)] string workdir, [MarshalAs(UnmanagedType.I4)] bool update_gitlink)
{
var __result__ = git_repository_set_workdir__(repo, workdir, update_gitlink).Check();
return __result__;
}

[DllImport(LibGit2Name, EntryPoint = "git_repository_set_workdir", CallingConvention = CallingConvention.Cdecl)]
private static extern git_result git_repository_set_workdir__(git_repository repo, [MarshalAs(UnmanagedType.LPUTF8Str)] string workdir, int update_gitlink);
private static extern git_result git_repository_set_workdir__(git_repository repo, [MarshalAs(UnmanagedType.LPUTF8Str)] string workdir, [MarshalAs(UnmanagedType.I4)] bool update_gitlink);

/// <summary>
/// Check if a repository is bare
Expand Down Expand Up @@ -1069,7 +1069,7 @@ public static git_result git_repository_detach_head(git_repository repo)
/// <param name="repo">Repository pointer</param>
/// <returns>The state of the repository</returns>
[DllImport(LibGit2Name, CallingConvention = CallingConvention.Cdecl)]
public static extern int git_repository_state(git_repository repo);
public static extern git_repository_state_t git_repository_state(git_repository repo);

/// <summary>
/// Sets the active namespace for this Git Repository
Expand All @@ -1083,8 +1083,14 @@ public static git_result git_repository_detach_head(git_repository repo)
/// This namespace affects all reference operations for the repo.
/// See `man gitnamespaces`
/// </remarks>
[DllImport(LibGit2Name, CallingConvention = CallingConvention.Cdecl)]
public static extern int git_repository_set_namespace(git_repository repo, [MarshalAs(UnmanagedType.LPUTF8Str)] string nmspace);
public static git_result git_repository_set_namespace(git_repository repo, [MarshalAs(UnmanagedType.LPUTF8Str)] string nmspace)
{
var __result__ = git_repository_set_namespace__(repo, nmspace).Check();
return __result__;
}

[DllImport(LibGit2Name, EntryPoint = "git_repository_set_namespace", CallingConvention = CallingConvention.Cdecl)]
private static extern git_result git_repository_set_namespace__(git_repository repo, [MarshalAs(UnmanagedType.LPUTF8Str)] string nmspace);

/// <summary>
/// Get the currently active namespace for this repository
Expand All @@ -1101,7 +1107,8 @@ public static git_result git_repository_detach_head(git_repository repo)
/// <param name="repo">The repository</param>
/// <returns>1 if shallow, zero if not</returns>
[DllImport(LibGit2Name, CallingConvention = CallingConvention.Cdecl)]
public static extern int git_repository_is_shallow(git_repository repo);
[return:MarshalAs(UnmanagedType.I4)]
public static extern bool git_repository_is_shallow(git_repository repo);

/// <summary>
/// Retrieve the configured identity to use for reflogs
Expand All @@ -1113,8 +1120,14 @@ public static git_result git_repository_detach_head(git_repository repo)
/// The memory is owned by the repository and must not be freed by the
/// user.
/// </remarks>
[DllImport(LibGit2Name, CallingConvention = CallingConvention.Cdecl)]
public static extern int git_repository_ident(out string name, out string email, git_repository repo);
public static git_result git_repository_ident(out string name, out string email, git_repository repo)
{
var __result__ = git_repository_ident__(out name, out email, repo).Check();
return __result__;
}

[DllImport(LibGit2Name, EntryPoint = "git_repository_ident", CallingConvention = CallingConvention.Cdecl)]
private static extern git_result git_repository_ident__(out string name, out string email, git_repository repo);

/// <summary>
/// Set the identity to be used for writing reflogs
Expand All @@ -1127,7 +1140,13 @@ public static git_result git_repository_detach_head(git_repository repo)
/// reflog. Pass NULL to unset. When unset, the identity will be taken
/// from the repository's configuration.
/// </remarks>
[DllImport(LibGit2Name, CallingConvention = CallingConvention.Cdecl)]
public static extern int git_repository_set_ident(git_repository repo, [MarshalAs(UnmanagedType.LPUTF8Str)] string name, [MarshalAs(UnmanagedType.LPUTF8Str)] string email);
public static git_result git_repository_set_ident(git_repository repo, [MarshalAs(UnmanagedType.LPUTF8Str)] string name, [MarshalAs(UnmanagedType.LPUTF8Str)] string email)
{
var __result__ = git_repository_set_ident__(repo, name, email).Check();
return __result__;
}

[DllImport(LibGit2Name, EntryPoint = "git_repository_set_ident", CallingConvention = CallingConvention.Cdecl)]
private static extern git_result git_repository_set_ident__(git_repository repo, [MarshalAs(UnmanagedType.LPUTF8Str)] string name, [MarshalAs(UnmanagedType.LPUTF8Str)] string email);
}
}

0 comments on commit 6da77e5

Please sign in to comment.