I want to define my own flavor of IEnumXXXX. Why do I really need to
define two versions of Next() ? Wouldn't the fully remotable version work
just as well when called in the same apartment?
Thanks.
Udi Pladott
NetinTouch.com
--------------------------
u...@netintouch.com
--
===============================
Alexander Nickolov
Panasonic Technologies Inc.
Speech Technology Laboratory
email: agnic...@geocities.com
===============================
Udi Pladott wrote in message ...
So should I just add another file to the dependency list in my
MYPROJps.mk makefile and put that code in the new file? How shoud I handle
this NULL pointer?
Thanks.
Udi.
As for the code you should write - see the help on 'call_as' in the
MIDL documentation. If it isn't clear - MIDL just relies that you'll
provide those two functions so the link step will fail without them.
You simply add another .c file to the proxy/stub project.
This will not work.
The failure will occur in the interface proxy. The proxy (generated by MIDL)
will check for NULL for toplevel outbound pointers and throw an exception
(caught by the proxy witch will return a failure HRESULT). You server will
never get the Next call.
You add local/call_as pair to your interface declaration of Next in IDL.
This will require you to add proxy and stub method "hooks" where you can fix
up the NULL as the client makes the inbound call. Here is some source for
these hooks:
Given a custom enumerator called IEnumShopItems and the Next (in IDL)
declared as:
[local]
HRESULT Next(
[in] ULONG celt,
[out, size_is(celt), length_is(*pCeltFetched)] SHOPITEM*
rgelt,
[out] ULONG * pCeltFetched
);
[call_as(Next)]
HRESULT RemoteNext(
[in] ULONG celt,
[out, size_is(celt), length_is(*pCeltFetched)] SHOPITEM*
rgelt,
[out] ULONG * pCeltFetched
);
Then the hooks that need to be added to the proxy/stub are as follows:
/* [local] */ HRESULT STDMETHODCALLTYPE
umShopItems_Next_Proxy(
IEnumShopItems __RPC_FAR * This,
/* [in] */ ULONG celt,
/* [length_is][size_is][out] */ SHOPITEM __RPC_FAR *rgelt,
/* [out] */ ULONG __RPC_FAR *pCeltFetched)
{
if (!pCeltFetched)
if (celt != 1)
return E_INVALIDARG;
ULONG cnt = 0;
HRESULT hr = IEnumShopItems_RemoteNext_Proxy(This,celt,rgelt,&cnt);
if (pCeltFetched)
*pCeltFetched = cnt;
return hr;
}
/* [call_as] */ HRESULT STDMETHODCALLTYPE IEnumShopItems_Next_Stub(
IEnumShopItems __RPC_FAR * This,
/* [in] */ ULONG celt,
/* [length_is][size_is][out] */ SHOPITEM __RPC_FAR *rgelt,
/* [out] */ ULONG __RPC_FAR *pCeltFetched)
{
return This->Next(celt,rgelt,pCeltFetched);
}
Peter Partch
--
===============================
Alexander Nickolov
Panasonic Technologies Inc.
Speech Technology Laboratory
email: agnic...@geocities.com
===============================
Peter Partch wrote in message ...
without this local/call_as hook and when calling via a proxy the last
parameter will never be NULL therefore the check will do little good for
across apartment calls.
After re-reading your posting, maybe I think that my terse remark was not
warranted.
Peter
For anybody, if there is still confusion, all my posts regarded the
implementation of the local-to-call_as function on the proxy
(local) side of the conversion. All thanks go to Mr Partch who
provided actual working source code.
I implemented the proxy / stub code as both of you suggested, but now the
method I have in my type library is RemoteNext(). How can I have only Next()
in there instead, and still get the right version called depending on
whether I'm in the same apartment or not?
Udi.
Alexander Nickolov wrote in message <#XToVzss#GA.195@cppssbbsa03>...
But I need my clients to use it .....
My client is written in Delphi which does work with vtbl interfaces but
gets it all from the TLB.
Udi.
>--
>===============================
>Alexander Nickolov
>Panasonic Technologies Inc.
#ifndef _TYPELIB_BUILD
[local] Next();
[call_as(Next)]RemoteNext();
#else
Next();
#endif
Now, rebuild your idl twice once with _TYPELIB_BUILD and once without it. The
one without the _TYPELIB_BUILD will generate the _p.c and _i.c stuff which you
can build to get the proxy/stub. and the typelib generated when that is
defined can be distributed with the component. Now, you are happy and so are
your delphi customers <g>.
In article <eRnTad5s#GA....@cppssbbsa02.microsoft.com>, "Alexander Nickolov"
<agnic...@geocities.com> wrote:
>Hmm, that's a point. Can you create the Delphi definition by hand?
>The standard interfaces must have done their way into Delphi
>somehow... This is not a general recommendation - only for this
>case. Else, I'm not expert on type libraries - see if the 'hidden'
>attribute helps...
>
----
Girish Bharadwaj B.V [vc++/mvp]
Please post Questions in the newsgroups.
Do not mail them to me directly.
Thank you.
---