Monday, December 13, 2004

Some of my C++ to VB conversions

So, I have C++ function declarations, and their VB wrappers. Anybody see anything wrong with them?

TypeDefs in demo C++ code:
typedef void* KPDCOpaqueRef;
typedef KPDCOpaqueRef KPDCLibMgrRef;
typedef KPDCOpaqueRef KPDCIteratorRef;
typedef KPDCIteratorRef KPDCCameraIterRef;
typedef KPDCOpaqueRef KPDCCameraRef;
typedef KPDCIteratorRef KPDCPropertyIterRef;
typedef KPDCOpaqueRef KPDCPropertyRef;
typedef KPDCIteratorRef KPDCDirectoryIterRef;
typedef KPDCOpaqueRef KPDCDirItemRef;
typedef KPDCOpaqueRef KPDCIORef;
typedef KPDCOpaqueRef KPDCImageRef;


Native Def:
//Get the size and type for the specified attribute ID.//
KPDCStatus KPDCGetAttributeInfo(KPDCOpaqueRef inRef, KPDCAttributeID inAttrID, KPDCDataTypes *outAttrType, KPDCUInt32 *outAttrSize);


My wrap:
Declare Auto Function KGetAttributeInfo Lib "DCSPro4SLR.dll" Alias "KPDCGetAttributeInfo" (ByVal inRef As IntPtr, ByVal inAttrID As Integer, ByRef outAttrType As KPDCDataTypes, ByRef outAttrSize As Integer) As Integer

Native Def:
//Get the value of the specified attribute ID. If the attribute is the KPDCPropValueID of a property, then the value of the property will be retrieved from the camera.//
KPDCStatus KPDCGetAttributeValue(KPDCOpaqueRef inRef, KPDCAttributeID inAttrID, KPDCUInt32 *inOutAttrSize,


My wrap:
Declare Auto Function KGetAttributeValue Lib "DCSPro4SLR.dll" Alias "KPDCGetAttributeValue" (ByVal inRef As IntPtr, ByVal inAttrID As Integer, ByRef inOutAttrSize As Integer, ByVal outAttrValue As IntPtr) As Integer

Native Def:
//Allocate a property iterator for camera properties.//
KPDCStatus KPDCAllocPropertyIterator ( KPDCCameraRef inCameraRef, KPDCPropertyIterRef *outRef);


My Wrap:
Declare Auto Function KAllocPropertyIterator Lib "DCSPro4SLR.dll" Alias "KPDCAllocPropertyIterator" (ByVal inCameraRef As IntPtr, ByRef outRef As IntPtr) As Integer

Native Code:
//Return a reference to the first item that has the string specified by inName and the value of its name attribute. The iterator points to the found item. A subsequent call to KPDCIteratorNext returns the item following the found item in the list.//
KPDCStatus KPDCIteratorFind(KPDCIteratorRef inIteratorRef, const char *inName, KPDCOpaqueRef *outFoundItemRef);


My Wrap:
Declare Auto Function KIteratorFind Lib "DCSPro4SLR.dll" Alias "KPDCIteratorFind" (ByVal inIteratorRef As IntPtr, ByVal inName As System.Text.StringBuilder, ByRef outFoundItemRef As IntPtr) As Integer

Native Code:
//Return a reference to the next enumerated item. After creating a new iterator or calling KPDCIteratorReset, this function returns the first item. If there are no more items, outNextItemRef will not be valid.//
KPDCStatus KPDCIteratorNext(KPDCIteratorRef inIteratorRef, KPDCOpaqueRef *outNextItemRef);


My Wrap:
Declare Auto Function KIteratorNext Lib "DCSPro4SLR.dll" Alias "KPDCIteratorNext" (ByVal inIteratorRef As IntPtr, ByRef outNextItemRef As IntPtr) As Integer

Native Code:
//Reset the iterator to point to the beginning of the list.//
KPDCStatus KPDCIteratorReset(KPDCIteratorRef inIteratorRef);


My Wrap:
Declare Auto Function KIteratorReset Lib "DCSPro4SLR.dll" Alias "KPDCIteratorReset" (ByVal inIteratorRef As IntPtr) As Integer

1 comment:

Osvaldo Mafra Lopes JĂșnior said...

I´d like to know what it is KPDCOpaqueRef? How is its structure.

Thank you.