-
Notifications
You must be signed in to change notification settings - Fork 897
/
Copy pathObjects.tt
101 lines (91 loc) · 2.07 KB
/
Objects.tt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<#@ template language="C#" #>
<#@ output extention=".cs" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
using System;
namespace LibGit2Sharp.Core.Handles
{
<#
var cNames = new[] {
"git_tree_entry",
"git_reference",
"git_repository",
"git_signature",
"git_status_list",
"git_blame",
"git_diff",
"git_patch",
"git_config",
"git_index_conflict_iterator",
"git_index",
"git_reflog",
"git_treebuilder",
"git_packbuilder",
"git_note",
"git_describe_result",
"git_submodule",
"git_annotated_commit",
"git_odb",
"git_revwalk",
"git_remote",
"git_object",
"git_rebase",
"git_odb_stream",
"git_worktree",
};
var csNames = new[] {
"TreeEntryHandle",
"ReferenceHandle",
"RepositoryHandle",
"SignatureHandle",
"StatusListHandle",
"BlameHandle",
"DiffHandle",
"PatchHandle",
"ConfigurationHandle",
"ConflictIteratorHandle",
"IndexHandle",
"ReflogHandle",
"TreeBuilderHandle",
"PackBuilderHandle",
"NoteHandle",
"DescribeResultHandle",
"SubmoduleHandle",
"AnnotatedCommitHandle",
"ObjectDatabaseHandle",
"RevWalkerHandle",
"RemoteHandle",
"ObjectHandle",
"RebaseHandle",
"OdbStreamHandle",
"WorktreeHandle"
};
for (var i = 0; i < cNames.Length; i++)
{
#>
internal unsafe class <#= csNames[i] #> : Libgit2Object
{
internal <#= csNames[i] #>(<#= cNames[i] #> *ptr, bool owned)
: base(ptr, owned)
{
}
internal <#= csNames[i] #>(IntPtr ptr, bool owned)
: base(ptr, owned)
{
}
protected override bool ReleaseHandle()
{
NativeMethods.<#= cNames[i] #>_free((<#= cNames[i] #>*)AsIntPtr());
return true;
}
public static implicit operator <#= cNames[i] #>*(<#= csNames[i] #> handle)
{
return (<#= cNames[i] #>*)handle.AsIntPtr();
}
}
<#
}
#>
}