Skip to content

Bug in ITypeLib 64 bit + Discussion on style of declarations  #11

@Greedquest

Description

@Greedquest

https://github.com/fafalone/tbShellLib/blob/93346dece996ba12da8526ad21a923bdb95cc00f/Export/Sources/slTypelib.twin#L33

This should return LongPtr I believe (it is PVOID)


Also I wonder how you would feel about 2 (or 3) improvements to make this more idiomatic:

https://github.com/fafalone/tbShellLib/blob/93346dece996ba12da8526ad21a923bdb95cc00f/Export/Sources/slTypelib.twin#L30

In my code, I have declared this as

Sub GetDocumentation(ByVal memid As MEMID, Optional ByRef pBstrName As String, Optional ByRef pBstrDocString As String = vbNullString, Optional ByRef pdwHelpContext As Long, Optional ByRef pBstrHelpFile As String)

with 2 changes: The Optional arguments, since these are optional from the API point of view. You can specify default of =vbNullString and =NULL_PTR or =0 if needed

Second change is I do

Public Enum MEMID
	[_]
End Enum

This does a sort of typedef for DWORD types which improves readability IMO

3rd change is I rename parameters to for example

Sub GetDocumentation(ByVal memid As MEMID, Optional ByRef outName As String, ...)

Since ByRef pBstrName to me is

  • Too much information; I don't need to know about Bstr as a VBA developer, just String
  • ByRef and p both mean kinda the same thing, doubling up makes me expect to get a pointer to a string out, not just a string
  • I think the outParam prefix is good from a VBA consumer point of view to make it clear. Attributes may be better in future tB.

I think this may be a harder sell as it is backwards incompatible for your library interface. However in my experience when I declare the APIs this way it makes me much less likely to need to look at the MSDN documentation. But it's still easy to look up online even if I've renamed the params, the function name is the same and the order of params is the same. Maybe for version 3.x of your package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions