Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Added JSProxyMemberPolicy.ReplaceAll. Reordered enum so that it match…
Browse files Browse the repository at this point in the history
…es default values (when querying attribute through Mono.Cecil).
  • Loading branch information
xen2 committed Aug 15, 2012
1 parent 2d9ff21 commit ef8b1b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 12 additions & 1 deletion JSIL/TypeInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,15 @@ public TypeInfo (ITypeInfoSource source, ModuleInfo module, TypeDefinition type,
escInfo.ForcedNewName = name;
ExtraStaticConstructors.Add(escInfo);
}

if (proxy.MemberPolicy == JSProxyMemberPolicy.ReplaceAll) {
var previousMembers = Members.ToArray();
Members.Clear();
foreach (var member in previousMembers) {
if (member.Value.IsFromProxy)
Members.TryAdd(member.Key, member.Value);
}
}
}
}

Expand Down Expand Up @@ -761,7 +770,9 @@ protected bool BeforeAddProxyMember<T> (ProxyInfo proxy, T member, out IMemberIn
((owningMember != null) && (owningMember.CustomAttributes.Any(ShouldNeverReplace)))
) {
return true;
} else if (proxy.MemberPolicy == JSProxyMemberPolicy.ReplaceDeclared) {
} else if (
proxy.MemberPolicy == JSProxyMemberPolicy.ReplaceDeclared ||
proxy.MemberPolicy == JSProxyMemberPolicy.ReplaceAll) {
if (result.IsFromProxy)
Debug.WriteLine(String.Format("Warning: Proxy member '{0}' replacing proxy member '{1}'.", member, result));

Expand Down
5 changes: 3 additions & 2 deletions Meta/Proxies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
namespace JSIL.Proxy {
public enum JSProxyMemberPolicy {
ReplaceDeclared,
ReplaceNone
ReplaceNone,
ReplaceAll
}

public enum JSProxyAttributePolicy {
Expand All @@ -15,8 +16,8 @@ public enum JSProxyAttributePolicy {
}

public enum JSProxyInterfacePolicy {
ReplaceNone,
ReplaceDeclared,
ReplaceNone,
ReplaceAll
}

Expand Down

0 comments on commit ef8b1b6

Please sign in to comment.