Feature #6613

VT_RECORD, IRecordInfo Support in WIN32OLE

Added by Dominic Sisneros almost 2 years ago. Updated 3 months ago.

[ruby-core:45731]
Status:Assigned
Priority:Normal
Assignee:Masaki Suketa
Category:ext
Target version:next minor

Description

WIN32OLE has no support for VTRECORD VARIANTS. Python and Perl use the
functions GetRecordInfoFromTypeInfo and GetRecordInfoFromGuids to add
support for VT
RECORD and the IRecordInfo interface.

suggest having a class IRecordInfo and support for generating a Class
for the UDT to use this Record/Struct in ruby

The method starting on 1395 needs a case statement for VT_RECORD and a way to turn that into a IRECORD class

static void *
getptrofvariant(VARIANT *pvar)
{
switch(V
VT(pvar)) {
case VTUI1:
return &V
UI1(pvar);
break;

The IDL definitions for the methods are as follows

HRESULT GetRecordInfoFromTypeInfo(
_in ITypeInfo *pTypeInfo,
_
out IRecordInfo **ppRecInfo
);

HRESULT GetRecordInfoFromGuids(
_in REFGUID rGuidTypeLib,
_
in ULONG uVerMajor,
_in ULONG uVerMinor,
_
in LCID lcid,
_in REFGUID rGuidTypeInfo,
_
out IRecordInfo **ppRecInfo
);

here is the CTYPES definition for python that adds this support

class IRecordInfo(IUnknown):
# C:/vc98/include/OAIDL.H 5974
iid = GUID("{0000002F-0000-0000-C000-000000000046}")

def GetFieldNames(self, *args):
    count = c_ulong()
    self.__com_GetFieldNames(count, None)
    array = (BSTR * count.value)()
    self.__com_GetFieldNames(count, array)
    result = array[:]
    # XXX Should SysFreeString the array contents. How to?
    return result

IRecordInfo. methods = [
COMMETHOD([], HRESULT, 'RecordInit',
(['in'], cvoidp, 'pvNew')),
COMMETHOD([], HRESULT, 'RecordClear',
(['in'], cvoidp, 'pvExisting')),
COMMETHOD([], HRESULT, 'RecordCopy',
(['in'], cvoidp, 'pvExisting'),
(['in'], cvoidp, 'pvNew')),
COMMETHOD([], HRESULT, 'GetGuid',
(['out'], POINTER(GUID), 'pguid')),
COMMETHOD([], HRESULT, 'GetName',
(['out'], POINTER(BSTR), 'pbstrName')),
COMMETHOD([], HRESULT, 'GetSize',
(['out'], POINTER(culong), 'pcbSize')),
COMMETHOD([], HRESULT, 'GetTypeInfo',
(['out'], POINTER(POINTER(ITypeInfo)), 'ppTypeInfo')),
COMMETHOD([], HRESULT, 'GetField',
(['in'], c
voidp, 'pvData'),
(['in'], c
wcharp, 'szFieldName'),
(['out'], POINTER(VARIANT), 'pvarField')),
COMMETHOD([], HRESULT, 'GetFieldNoCopy',
(['in'], c
voidp, 'pvData'),
(['in'], c
wcharp, 'szFieldName'),
(['out'], POINTER(VARIANT), 'pvarField'),
(['out'], POINTER(c
voidp), 'ppvDataCArray')),
COMMETHOD([], HRESULT, 'PutField',
(['in'], c
ulong, 'wFlags'),
(['in'], cvoidp, 'pvData'),
(['in'], cwcharp, 'szFieldName'),
(['in'], POINTER(VARIANT), 'pvarField')),
COMMETHOD([], HRESULT, 'PutFieldNoCopy',
(['in'], culong, 'wFlags'),
(['in'], c
voidp, 'pvData'),
(['in'], c
wcharp, 'szFieldName'),
(['in'], POINTER(VARIANT), 'pvarField')),
COMMETHOD([], HRESULT, 'GetFieldNames',
(['in', 'out'], POINTER(c
ulong), 'pcNames'),
(['in'], POINTER(BSTR), 'rgBstrNames')),
COMMETHOD([], BOOL, 'IsMatchingType',
(['in'], POINTER(IRecordInfo))),
COMMETHOD([], HRESULT, 'RecordCreate'),
COMMETHOD([], HRESULT, 'RecordCreateCopy',
(['in'], cvoidp, 'pvSource'),
(['out'], POINTER(cvoidp), 'ppvDest')),
COMMETHOD([], HRESULT, 'RecordDestroy',
(['in'], cvoidp, 'pvRecord'))]

################################################################

functions

_oleaut32 = oledll.oleaut32

def GetRecordInfoFromTypeInfo(tinfo):
"Return an IRecordInfo pointer to the UDT described in tinfo"
ri = POINTER(IRecordInfo)()
_oleaut32.GetRecordInfoFromTypeInfo(tinfo, byref(ri))
return ri

def GetRecordInfoFromGuids(rGuidTypeLib, verMajor, verMinor, lcid,
rGuidTypeInfo):
ri = POINTER(IRecordInfo)()
_oleaut32.GetRecordInfoFromGuids(byref(GUID(rGuidTypeLib)),
verMajor, verMinor, lcid,
byref(GUID(rGuidTypeInfo)),
byref(ri))
return ri

History

#1 Updated by Hiroshi Nakamura almost 2 years ago

  • Category set to ext
  • Status changed from Open to Assigned
  • Assignee set to Masaki Suketa

Suketa-san, would you please comment to it?

#2 Updated by Yusuke Endoh over 1 year ago

  • Target version set to next minor

#3 Updated by Dominic Sisneros 3 months ago

Still no progress on this?? I wish I knew C better

Also available in: Atom PDF