Feature #6613

VT_RECORD, IRecordInfo Support in WIN32OLE

Added by Dominic Sisneros about 3 years ago. Updated about 1 year ago.

[ruby-core:45731]
Status:Assigned
Priority:Normal
Assignee:Masaki Suketa

Description

WIN32OLE has no support for VT_RECORD 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 *
get_ptr_of_variant(VARIANT *pvar)
{
switch(V_VT(pvar)) {
case VT_UI1:
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'], c_void_p, 'pvNew')),
COMMETHOD([], HRESULT, 'RecordClear',
(['in'], c_void_p, 'pvExisting')),
COMMETHOD([], HRESULT, 'RecordCopy',
(['in'], c_void_p, 'pvExisting'),
(['in'], c_void_p, 'pvNew')),
COMMETHOD([], HRESULT, 'GetGuid',
(['out'], POINTER(GUID), 'pguid')),
COMMETHOD([], HRESULT, 'GetName',
(['out'], POINTER(BSTR), 'pbstrName')),
COMMETHOD([], HRESULT, 'GetSize',
(['out'], POINTER(c_ulong), 'pcbSize')),
COMMETHOD([], HRESULT, 'GetTypeInfo',
(['out'], POINTER(POINTER(ITypeInfo)), 'ppTypeInfo')),
COMMETHOD([], HRESULT, 'GetField',
(['in'], c_void_p, 'pvData'),
(['in'], c_wchar_p, 'szFieldName'),
(['out'], POINTER(VARIANT), 'pvarField')),
COMMETHOD([], HRESULT, 'GetFieldNoCopy',
(['in'], c_void_p, 'pvData'),
(['in'], c_wchar_p, 'szFieldName'),
(['out'], POINTER(VARIANT), 'pvarField'),
(['out'], POINTER(c_void_p), 'ppvDataCArray')),
COMMETHOD([], HRESULT, 'PutField',
(['in'], c_ulong, 'wFlags'),
(['in'], c_void_p, 'pvData'),
(['in'], c_wchar_p, 'szFieldName'),
(['in'], POINTER(VARIANT), 'pvarField')),
COMMETHOD([], HRESULT, 'PutFieldNoCopy',
(['in'], c_ulong, 'wFlags'),
(['in'], c_void_p, 'pvData'),
(['in'], c_wchar_p, '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'], c_void_p, 'pvSource'),
(['out'], POINTER(c_void_p), 'ppvDest')),
COMMETHOD([], HRESULT, 'RecordDestroy',
(['in'], c_void_p, '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 about 3 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 almost 3 years ago

  • Target version set to next minor

#3 Updated by Dominic Sisneros over 1 year ago

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

#4 Updated by Masaki Suketa about 1 year ago

Sorry for waiting too long. I had implemented VT_RECORD / IRecordInterface features.
Try WIN32OLE_RECORD class in ruby-trunk (2.2.0dev revision 47020 or later).

Also available in: Atom PDF