On 26 April 2014 09:44, Markus Fritsche <mfritsche@reauktion.de> wrote:
Hello,

tl;dr: what's the reason to get aNBExternalHandle even if you expect a MySuperHandle object from an nbCall?

I am trying to build my first DLL wrapper with NativeBoost. I am having a problem that instead of returning a handle object (as I thought), my "primitive" throws NBExternalHandles at me.

The API I am trying to wrap tries to be somewhat object oriented by (mostly) having a handle of some sort.

My thinking was to attach all DLL primitives to the respective Handle Objects they take as a first parameter and go from there.

Some workspace code:

"Supplementary DLLs"
Tm1ULibDllLibraryLoader loadLibrary.
LibIbmCogEayLibraryLoader loadLibrary.
SslIbmCogEayLibraryLoader loadLibrary.
Log4CxxLibraryLoader loadLibrary.
"DLL to wrap"
TM1LibraryLoader loadTM1Library.

t := TM1Api new.
t tm1APIInitialize.
hUser := t tm1SystemOpen. "Returns a proper 'TM1UHandle' object'"
hUser tm1SystemAdminHostSet: 'localhost'.
hPool1 := hUser tm1ValPoolCreate. "Returns NBExternalHandle"
hPool1 inspect.
hUser tm1SystemClose.
t tm1APIFinalize.

TM1Api>>#tm1SystemOpen
�� �� <primitive: #primitiveNativeCall
�� �� ��module: #NativeBoostPlugin>
�� �� ^ self nbCall: #(TM1UHandle TM1SystemOpen(void))

TM1UHandle>>#tm1ValPoolCreate
�� �� <primitive: #primitiveNativeCall
�� �� ��module: #NativeBoostPlugin>
�� �� ^ self nbCall: #(#TM1PHandle TM1ValPoolCreate ( TM1UHandle self ) )

sidenote: when using 'self', you can use it without type. just say 'self', since it refers to
the instance of method's class, which is enough to determine the type to use for marshalling.
��
Both, TM1UHandle class and TM1PHandle class have the method
asNBExternalType: gen
�� �� "use handle ivar to hold my instance (TM1x)"
�� �� ^ NBExternalObjectType objectClass: self

and are subclasses of object. What's my mistake? Can you tell with the information I provided?


This is strange.. should work fine.
There's no way how NBExternalObjectType could return an instance of NBExternalHandle.
Please check your code again.

Best regards,
�� Markus




--
Best regards,
Igor Stasenko.