Announcement
Collapse
No announcement yet.
First Real Code Example??
Collapse
X
-
A good thing is that you can wrap up your dll into an easier to use (dispatch based) com server.
As long you are using automation, annoying declarations are bye bye.
The common API code Bob Zale showed us a week ago makes it also easy to load the ocx with the registering.
So far speculation, i don't have this compiler yet.
Comment
-
True it all depends how much you use classes and the dispatch interface. I have to deal with MS awarded programs where even the simplest function in the program is in a class and called via the dispatch interface. Could do some of the calculations quicker with pen and paper, though they don’t work too bad on dual quad core processors with 16 GB RAM.
Really a matter of common sense and a trade off in programming time versus uses speed.
Comment
-
Imo one of the biggest mistakes programmers make (assumption due the fact their software is slow) is they tend not to understand commands like for/each.
If you have an collection (~array) of objects often a simple for next loop is used.
I see my colleagues still do that.
On every loop it needs to create or obtain that object.
In practise by making use of the IEnumerator interface and write the correct code you'll create all objects at once.
The loop itself is then very fast.
This can be a 1000 times faster.. really!
So if i call a dispatch object and 'pop-eye' keeps creating objects on objects internally i am sure it get's slow.
Calling a dispatch once and do the heavy stuff inside a method is equally fast as an ordinary call.
If you call via a dispatch a 1000th times like in a loop.. yes, not recommended.
Only direct vtable access (direct interface) will help you here.
To be clear.. for/each suppose to call the IEnumerator interface.. if present.
Hopefully the PB interface stuff will let us do that.
Maybe not the for/each but at least this IEnumerator interface.
Oh well. if not you can still do that with an ordinary method.
But then compatibility is gone somewhat.
Comment
-
To be clear.. for/each suppose to call the IEnumerator interface.. if present.
Hopefully the PB interface stuff will let us do that.
Maybe not the for/each but at least this IEnumerator interface.
Code:DIM pEnum AS IEnumVARIANT DIM oItem AS DISPATCH ' or pItem AS <interface name> DIM vItem AS VARIANT ' Get a reference to the enumeator pEnum = <pCollection>.NewEnum_ ' Where <pCollection> will be an object variable holding a reference to the collection to enumerate DO ' Retrieve a reference to the next object in the collection hr = pEnum.Next(1, vItem, BYVAL %NULL) IF hr <> %S_OK THEN EXIT DO ' Assign the VT_DISPATCH variant to the object variable oItem = vItem ' or pItem = vItem ' Do some calls OBJECT CALL oItem.<wathever> ' or pItem.<whatever> LOOP
And instead of wrapper functions for the IEnumVARIANT interface, youn only need the following interface declaration:
Code:' ######################################################################################## ' IEnumVARIANT interface ' IID = 00000002-0000-0000-C000-000000000046 ' Inherited interface = IUnknown ' ######################################################################################## #IF NOT %DEF(%IEnumVARIANT_INTERFACE_DEFINED) %IEnumVARIANT_INTERFACE_DEFINED = 1 $IID_IEnumVARIANT = GUID$("{00020404-0000-0000-C000-000000000046}") INTERFACE IEnumVARIANT $IID_IEnumVARIANT INHERIT IUnknown ' ===================================================================================== METHOD Next ( _ ' VTable offset = 12 BYVAL DWORD _ ' /* [in] */ unsigned long celt , BYREF VARIANT _ ' /* [out] */ VARIANT FAR* rgVar , BYREF DWORD _ ' /* [out] */ unsigned long FAR* pCeltFetched ) AS LONG ' HRESULT ' ===================================================================================== METHOD Skip ( _ ' VTable offset = 16 BYVAL DWORD _ ' /* [in] */ unsigned long celt ) AS LONG ' HRESULT ' ===================================================================================== METHOD Reset ( _ ' VTable offset = 20 ) AS LONG ' HRESULT ' ===================================================================================== METHOD Clone ( _ ' VTable offset = 24 BYREF IEnumVARIANT _ ' /* [out] */ IEnumVARIANT** ppenum ) AS LONG ' HRESULT ' ===================================================================================== END INTERFACE #ENDIF ' /* __IEnumVARIANT_INTERFACE_DEFINED__ */
Last edited by José Roca; 13 Aug 2008, 11:03 PM.
Comment
Comment