-
Notifications
You must be signed in to change notification settings - Fork 774
Expand file tree
/
Copy pathPyIdentifier_.tt
More file actions
62 lines (56 loc) · 1.17 KB
/
PyIdentifier_.tt
File metadata and controls
62 lines (56 loc) · 1.17 KB
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
<#@ template debug="true" hostSpecific="true" #>
<#@ output extension=".cs" #>
<#
string[] internNames = new string[]
{
"__name__",
"__dict__",
"__doc__",
"__class__",
"__module__",
"__file__",
"__slots__",
"__self__",
"__annotations__",
"__dictoffset__",
"__init__",
"__repr__",
"__import__",
"__builtins__",
"builtins",
"__overloads__",
"Overloads",
};
#>
using System;
namespace Python.Runtime
{
static class PyIdentifier
{
#pragma warning disable CS0649 // indentifier is never assigned to (assigned with reflection)
<#
foreach (var name in internNames)
{
#>
static IntPtr f<#= name #>;
public static BorrowedReference <#= name #> => new(f<#= name #>);
<#
}
#>
#pragma warning restore CS0649 // indentifier is never assigned to (assigned with reflection)
}
static partial class InternString
{
private static readonly string[] _builtinNames = new string[]
{
<#
foreach (var name in internNames)
{
#>
"<#= name #>",
<#
}
#>
};
}
}