forked from sq/JSIL.Meta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProxies.cs
116 lines (104 loc) · 5.51 KB
/
Proxies.cs
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#pragma warning disable 1591
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace JSIL.Proxy {
public enum JSProxyMemberPolicy {
ReplaceDeclared,
ReplaceNone,
ReplaceAll
}
public enum JSProxyAttributePolicy {
ReplaceDeclared,
ReplaceAll
}
public enum JSProxyInterfacePolicy {
ReplaceDeclared,
ReplaceNone,
ReplaceAll
}
/// <summary>
/// Specifies that a type should be treated as a proxy for another type, replacing the target type's members and/or attributes.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
public class JSProxy : Attribute {
/// <param name="type">The type to proxy.</param>
/// <param name="memberPolicy">Determines how members defined in the proxied type should be replaced with members defined by the proxy type.</param>
/// <param name="attributePolicy">Determines how how attributes defined in the proxied type should be replaced with attributes attached to the proxy type.</param>
/// <param name="interfacePolicy">Determines how how interfaces defined in the proxied type should be replaced with interfaces attached to the proxy type.</param>
public JSProxy (
Type type,
JSProxyMemberPolicy memberPolicy = JSProxyMemberPolicy.ReplaceDeclared,
JSProxyAttributePolicy attributePolicy = JSProxyAttributePolicy.ReplaceDeclared,
JSProxyInterfacePolicy interfacePolicy = JSProxyInterfacePolicy.ReplaceDeclared,
bool inheritable = true
) {
}
/// <param name="types">The types to proxy.</param>
/// <param name="memberPolicy">Determines how members defined in the proxied type should be replaced with members defined by the proxy type.</param>
/// <param name="attributePolicy">Determines how how attributes defined in the proxied type should be replaced with attributes attached to the proxy type.</param>
/// <param name="interfacePolicy">Determines how how interfaces defined in the proxied type should be replaced with interfaces attached to the proxy type.</param>
public JSProxy (
Type[] types,
JSProxyMemberPolicy memberPolicy = JSProxyMemberPolicy.ReplaceDeclared,
JSProxyAttributePolicy attributePolicy = JSProxyAttributePolicy.ReplaceDeclared,
JSProxyInterfacePolicy interfacePolicy = JSProxyInterfacePolicy.ReplaceDeclared,
bool inheritable = true
) {
}
/// <param name="typeName">The type to proxy.</param>
/// <param name="memberPolicy">Determines how members defined in the proxied type should be replaced with members defined by the proxy type.</param>
/// <param name="attributePolicy">Determines how how attributes defined in the proxied type should be replaced with attributes attached to the proxy type.</param>
/// <param name="interfacePolicy">Determines how how interfaces defined in the proxied type should be replaced with interfaces attached to the proxy type.</param>
public JSProxy (
string typeName,
JSProxyMemberPolicy memberPolicy = JSProxyMemberPolicy.ReplaceDeclared,
JSProxyAttributePolicy attributePolicy = JSProxyAttributePolicy.ReplaceDeclared,
JSProxyInterfacePolicy interfacePolicy = JSProxyInterfacePolicy.ReplaceDeclared,
bool inheritable = true
) {
}
/// <param name="typeNames">The types to proxy.</param>
/// <param name="memberPolicy">Determines how members defined in the proxied type should be replaced with members defined by the proxy type.</param>
/// <param name="attributePolicy">Determines how how attributes defined in the proxied type should be replaced with attributes attached to the proxy type.</param>
/// <param name="interfacePolicy">Determines how how interfaces defined in the proxied type should be replaced with interfaces attached to the proxy type.</param>
public JSProxy (
string[] typeNames,
JSProxyMemberPolicy memberPolicy = JSProxyMemberPolicy.ReplaceDeclared,
JSProxyAttributePolicy attributePolicy = JSProxyAttributePolicy.ReplaceDeclared,
JSProxyInterfacePolicy interfacePolicy = JSProxyInterfacePolicy.ReplaceDeclared,
bool inheritable = true
) {
}
}
[AttributeUsage(
AttributeTargets.Event | AttributeTargets.Property |
AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field
)]
public class JSNeverReplace : Attribute {
}
[AttributeUsage(
AttributeTargets.Event | AttributeTargets.Property |
AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field
)]
public class JSNeverInherit : Attribute {
}
/// <summary>
/// Specifies that you wish to replace an existing constructor with one from your proxy. This is necessary because
/// the compiler automatically generates hidden constructors for your proxy classes.
/// </summary>
[AttributeUsage(
AttributeTargets.Constructor
)]
public class JSReplaceConstructor : Attribute {
}
/// <summary>
/// Use this as a stand-in type when defining a proxy to specify that any type is valid for the given parameter/return type.
/// </summary>
public abstract class AnyType {
private AnyType () {
throw new InvalidOperationException();
}
}
}