How to create the ITypeInfo interface in twinBASIC

126 Views Asked by At

I'm trying to write up ITypeInfo in tB.

Interface ITypeInfo Extends IUnknown
    
    'HRESULT  GetTypeAttr([out] TYPEATTR **ppTypeAttr )
    Sub GetTypeAttr(ByRef outpTypeAttr As LongPtr)
    Sub GetTypeComp()
    Sub GetFuncDesc()
    Sub GetVarDesc()
    Sub GetNames()
    Sub GetRefTypeOfImplType()
    Sub GetImplTypeFlags()
    Sub GetIDsOfNames()
    Sub Invoke()
    'HRESULT  GetDocumentation( [in] MEMBERID memid, [out] BSTR *pBstrName, [out] BSTR *pBstrDocString, [out] DWORD *pdwHelpContext, [out] BSTR *pBstrHelpFile)
    Sub GetDocumentation(ByVal memid As DISPID, ByRef outName As String, Optional ByVal pBstrDocString As LongPtr = NULL_PTR, Optional ByVal pdwHelpContext As LongPtr = NULL_PTR, Optional ByVal pBstrHelpFile As LongPtr = NULL_PTR)
    Sub GetDllEntry()
    Sub GetRefTypeInfo()
    Sub AddressOfMember()
    Sub CreateInstance()
    Sub GetMops()
    Sub GetContainingTypeLib()
    'void ITypeInfo::ReleaseTypeAttr( [in] TYPEATTR *pTypeAttr)
    Sub ReleaseTypeAttr(ByVal pTypeAttr As LongPtr)
    Sub ReleaseFuncDesc()
    Sub ReleaseVarDesc()
End Interface

I have some questions

  1. I only need a few members so I'm wondering; is it possible only to declare the members I want to use:
Interface ITypeInfo Extends IUnknown
    [VTableIndex(0)]
    Sub GetTypeAttr(ByRef outpTypeAttr As LongPtr)
    [VTableIndex(9)]
    Sub GetDocumentation(ByVal memid As DISPID, ByRef outName As String, Optional ByVal pBstrDocString As LongPtr = NULL_PTR, Optional ByVal pdwHelpContext As LongPtr = NULL_PTR, Optional ByVal pBstrHelpFile As LongPtr = NULL_PTR)
    [VTableIndex(16)]
    Sub ReleaseTypeAttr(ByVal pTypeAttr As LongPtr)
End Interface

Or mark the other members as stubs/not-invokable to the compiler.

  1. HRESULT subs are the default in VBA classes. So I assume they are declared as I have. However ITypeInfo has a void method:
void ITypeInfo::ReleaseTypeAttr( [in] TYPEATTR *pTypeAttr)

I just wrote Sub ReleaseTypeAttr(ByVal pTypeAttr As LongPtr) is this going to lead to a misaligned stack since there is no HRESULT to pop?

  1. We don't have a way to express an out-TYPEATTR (in GetTypeAttr) struct, I have to use copy memory and pointers IIUC
0

There are 0 best solutions below