A little COM Story, or Why I like Using Dolphin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

A little COM Story, or Why I like Using Dolphin

Jeffrey Odell-2
A little story on why I value my Dolphin Smalltalk license...

Many of you know I code on VisualAge in my business, more specifically the
IBM Smalltalk subset of it.  We moved a large application from Visual
Smalltalk a couple years ago and things are going well.  But sometimes, it
falls short in Windows integration ... not surprising since it is targeted
to be cross platform, but a problem none the less.

One area of IBM Smalltalk that has not been enhanced in quite a while is the
COM support.  It is adequate; it provides the ability to generate a wrapper
class from the COM object itself and, from there, I can rework the methods
generated to get what I need.  I created a framework to get over some of the
deficiencies - missing Variant type conversions, no automatic releasing of
COM objects on garbage collection, and the fact that the relationship
between COM objects is not taken in to account, so the wrapper generated
when another COM object is returned as the result of a method or property
does not know to use the wrapper for that object.  I have a pattern on how
to do it, it largely works, and things are OK.

However, I had taken to generating the COM wrappers with Dolphin when trying
to learn anything more about COM.  The wrapping is much more complete,
exposes the interfaces, which I like, and generally produces objects you can
use immediately without having to recode things.  This would allow, with
careful design, the regeneration of the objects as newer versions of COM
objects were supplied - something I think is vitally important.

Now the story - I was invited to try a beta version of a COM object from a
vender whose software I already use in another area of my system.  Among
other things, this object encrypts and decrypts data, something I've been
wanting to incorporate in my software.  I wrapped the COM object in my IBM
Smalltalk image, and things went well until I have to retrieve the encrypted
data.  The COM object answered a Variant type that IBM Smalltalk didn't know
about, so I was on my own to figure out how to get the result out of it.
Also, it turned out, I have to create this same type of Variant to pass to
the COM object to decrypt later on.

After a bit of head scratching and MSDN browsing, I figured out I was
getting a SAFEARRAY back.  IBM Smalltalk leaves me to fend for myself on
this.  Then it dawned on my to fire up Dolphin Smalltalk and see what it
came up with.

Pleasantly, I found out after wrapping the object with Dolphin's Active/X
Component Wizard, I found that I could write a script that exercised the
encrypt/decrypt functions I wanted to do within the hour.  The script looked
like this:

=========================================
encryption := ENCRYPTIONLibIXceedEncryption new.

encryptedSafeArray :=
 encryption
  encryptionMethod: eemRijndael;
  encryptionMode: emoFreeBlocks;
  setSecretKeyFromPassPhrase: 'I am testing this control and need a really
long passkey to make it work'
   nKeySize: 256
   eHashingMethod: ehmSHA;
  encrypt: 'This is the data I am encrypting'
   bEndOfData: true.

encryptedBytes :=
 ByteArray
  fromAddress: encryptedSafeArray data
  length: encryptedSafeArray length.

decryptedSafeArray :=
 encryption
  decrypt: encryptedBytes asSAFEARRAY
  bEndOfData: true.

UnicodeString
 fromAddress: decryptedSafeArray data
 length: (decryptedSafeArray length)/2
=========================================

It was pretty easy - Dolphin has a full fledged object that wraps a
SAFEARRAY, and handled the specialized case where the SAFEARRAY represents a
vector (the #data method).  It also had support for the Unicode string
returned.

I had none of this in my IBM Smalltalk image - I have an object that
represents a SAFEARRAY; I was left to my own devices to tease the data in
and out of memory.  The IBM Smalltalk SAFEARRAY object has the Windows calls
on it, and that's all.  Yuck.

However, by tracing how Dolphin Smalltalk uses these calls, I was able to
extend my IBM Smalltalk object enough to get the work done.  After a couple
hours of messing around, extending the SAFEARRAY object and enhancing the
Variant type conversion, I had it working correctly in IBM Smalltalk.

Even though I don't (yet) deliver any software on the Dolphin platform, it
has been worth the licensing cost based on what I've been able to learn from
various parts of the system.  This is just one example.

jlo


Reply | Threaded
Open this post in threaded view
|

Re: A little COM Story, or Why I like Using Dolphin

Blair McGlashan
Jeff

You wrote in message news:3b0921e0$[hidden email]...
> A little story on why I value my Dolphin Smalltalk license...
> ....

Thanks for your story. Would you consider putting it on the Wiki
(http://www.object-arts.com/wiki/html/Dolphin/SmalltalkStories.htm)?

Regards

Blair