Alexey-
Thanks. Good points.
(Mark sheepishly says)
No, I didn't test under VC++, I just trusted the code you posted
earlier and extrapolated from there. I'll look at changing the header
and repost it. This is the first time I've worked at including the
macro API and I have to say I find it pretty ugly.
One thing I'd like to see is a COM-type query function that would
enumerate the macro strings rather than making me catenate them at
design time. And Stefan's lack of comments makes TBP_ExecMacro a bit
of a joke as example code.
Also, tpxTotalPages and tpxTracking both evaluate to 248 and
tpxCurrentPage and tpxQuoteStyle both evaluate to 249. This can't
possibly be right, can it?
ANV This is main and critically serious error. Please, refer to
ANV other variants of API (which I
ANV referred on the top of the letter) and work more... I warn you about it because
ANV giving the wrong headers from the beginning can prefer many from writing such
ANV plugins.
Again, a very good point.
ANV 1. Strictly speaking, the interface is defined as struct. (there is line in the
ANV header: #define interface struct. So, I would change your code by using word
ANV struct if interface is undefined, and also public: is not necessary in
ANV this case. But, repeat, this is only cosmetic.
Well, I could have sworn that, strictly speaking, functions were
illegal as struct members. However, that syntax seems to pass my
compilers without problem, so I have now changed it. Yes, it *is* just
cosmetic, but I wouldn't have made it a class if I thought I could
have gotten away with a struct.
ANV 2. If you write on CPP, why are you using malloc and free? Let use new and
ANV delete instead! CPP is not C, and although malloc and free still works, they are
ANV deprecated in CPP. Of course, this is also just cosmetic, and somebody who will
ANV use it will change it, but anywhere...
The main reason that malloc and free are deprecated is that their
usage can result in sloppy code that causes memory leaks. I've tried
to be very careful to free anything that was allocated and the one
case in which a memory block is not explicitly freed is notated in the
source (as it is in your source as well). Note that new without a
corresponding delete will cause the same memory leak as malloc without
a corresponding free.
My intention here is 1) to cut down the size of the code and increase
execution speed by not instantiating new objects unless absolutely
necessary, and 2) to minimize the chances of creating a problem
interfacing with Delphi with name mangling and such, since this is a
shared library and not a standalone application. Obviously both
approaches will work.
My idea here was to write as much simple C, not C++, code as possible
to minimize the chances of having to modify the code for other
compilers (i.e. not using vcl or MFC objects). This is the same
reasoning as above in using a struct instead of a class.
--
-Mark Wieder
Using The Bat! v1.63 Beta/7 on Windows 2000 5.0 Build 2195 Service Pack 2
http://www.silverstones.com/thebat/TBUDLInfo.html