Skip to content

Commit 7ff6ad3

Browse files
committed
Stop collecting TKIND_UNION (unsupported), initial eval binding support.
1 parent e14545b commit 7ff6ad3

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Rubberduck.Parsing/ComReflection/ComMember.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212

1313
namespace Rubberduck.Parsing.ComReflection
1414
{
15+
internal enum DispId
16+
{
17+
Collect = -8, //The method you are calling through Invoke is an accessor function.
18+
Destructor = -7, //The C++ destructor function for the object.
19+
Construtor = -6, //The C++ constructor function for the object.
20+
Evaluate = -5, //This method is implicitly invoked when the ActiveX client encloses the arguments in square brackets.
21+
NewEnum = -4, //It returns an enumerator object that supports IEnumVARIANT.
22+
PropertyPut = -3, //The parameter that receives the value of an assignment in a PROPERTYPUT.
23+
Unknown = -1, //The value returned by IDispatch::GetIDsOfNames to indicate that a member or parameter name was not found.
24+
Value = 0 //The default member for the object.
25+
}
26+
1527
[DebuggerDisplay("{MemberDeclaration}")]
1628
public class ComMember : ComBase
1729
{
@@ -20,6 +32,8 @@ public class ComMember : ComBase
2032
public bool ReturnsWithEventsObject { get; private set; }
2133
public bool IsDefault { get; private set; }
2234
public bool IsEnumerator { get; private set; }
35+
//This member is called on an interface when a bracketed expression is dereferenced.
36+
public bool IsEvaluateFunction { get; private set; }
2337
public ComParameter ReturnType { get; private set; }
2438
public List<ComParameter> Parameters { get; set; }
2539

@@ -30,8 +44,9 @@ public ComMember(ITypeInfo info, FUNCDESC funcDesc) : base(info, funcDesc)
3044
IsHidden = flags.HasFlag(FUNCFLAGS.FUNCFLAG_FHIDDEN);
3145
IsRestricted = flags.HasFlag(FUNCFLAGS.FUNCFLAG_FRESTRICTED);
3246
ReturnsWithEventsObject = flags.HasFlag(FUNCFLAGS.FUNCFLAG_FSOURCE);
33-
IsDefault = Index == 0;
34-
IsEnumerator = Index == -4;
47+
IsDefault = Index == (int)DispId.Value;
48+
IsEnumerator = Index == (int)DispId.NewEnum;
49+
IsEvaluateFunction = Index == (int)DispId.Evaluate;
3550
SetDeclarationType(funcDesc, info);
3651
}
3752

Rubberduck.Parsing/ComReflection/ComProject.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ private void LoadModules(ITypeLib typeLibrary)
120120
if (type != null) KnownTypes.TryAdd(typeAttributes.guid, coclass);
121121
break;
122122
case TYPEKIND.TKIND_ALIAS:
123-
case TYPEKIND.TKIND_UNION:
124-
125123
//The current handling of this is wrong - these don't have to be classes or interfaces. In the VBE module for example,
126124
//"LongPtr" is defined as an alias to "Long" (at least on a 32 bit system) - RD is currently treating is like a class.
127125
//Unclear if these can *also* define alternative names for interfaces as well, but all the ones I've seen have been basically
@@ -141,6 +139,9 @@ private void LoadModules(ITypeLib typeLibrary)
141139
_modules.Add(module as ComModule);
142140
if (type != null) KnownTypes.TryAdd(typeAttributes.guid, module);
143141
break;
142+
case TYPEKIND.TKIND_UNION:
143+
//TKIND_UNION is not a supported member type in VBA.
144+
break;
144145
default:
145146
throw new NotImplementedException(string.Format("Didn't expect a TYPEATTR with multiple typekind flags set in {0}.", Path));
146147
}

0 commit comments

Comments
 (0)