I'm currently converting htmlhelp.h to masm format. there's this last bit which I'm unsure how to handle



typedef enum tagHH_GPROPID
{
HH_GPROPID_SINGLETHREAD=1, ; VARIANT_BOOL: True for single thread
HH_GPROPID_TOOLBAR_MARGIN=2, ; long: Provides a left/right margin around the toolbar.
HH_GPROPID_UI_LANGUAGE=3, ; long: LangId of the UI.
HH_GPROPID_CURRENT_SUBSET=4, ; BSTR: Current subset.
HH_GPROPID_CONTENT_LANGUAGE=5 ; long: LandId for desired content.
} HH_GPROPID;

typedef struct tagHH_GLOBAL_PROPERTY
{
HH_GPROPID id;
VARIANT var;
} HH_GLOBAL_PROPERTY ;


The problem is the id member of the structure. It's defined as an enumerated type...Enumerated types are just a list of constants so I'm stumped how to translate the structure to masm format...any ideas?
Posted on 2002-06-03 18:54:50 by MArtial_Code
MArtial_Code,

You can do the most basic stuff just on its size, LONG = DWORD in asm.

I think BSTR is just a DWORD handle.

What I would be inclined to do is look up the header files to see where the data type definitions are and see what they are constructed from. Most of this stuff are just equates to known sizes but where you are playing with stuff like variants, it may involve structures and unions.

Regards,

hutch@movsd.com
Posted on 2002-06-03 22:57:21 by hutch--
Language ID's are defined in an include file Microsoft named (in a rare moment of outstanding clarity) language.h

I havn't used it much, but here's my whack at a translation.

Hope it helps



PS: Since the board only allows pictures and .asm files, you need to delete the .asm to make this a .inc file.
Posted on 2002-06-03 23:15:01 by Ernie
Hi the problem is not in converting the data sizes...here's how I think the translation should go:



--------------------------------------------------------------------------------
typedef enum tagHH_GPROPID
{
HH_GPROPID_SINGLETHREAD=1, ; VARIANT_BOOL: True for single thread
HH_GPROPID_TOOLBAR_MARGIN=2, ; long: Provides a left/right margin around the toolbar.
HH_GPROPID_UI_LANGUAGE=3, ; long: LangId of the UI.
HH_GPROPID_CURRENT_SUBSET=4, ; BSTR: Current subset.
HH_GPROPID_CONTENT_LANGUAGE=5 ; long: LandId for desired content.
} HH_GPROPID;

[B]Becomes[/B]
HH_GPROPID_SINGLETHREAD equ 1
HH_GPROPID_TOOLBAR_MARGIN equ 2
HH_GPROPID_UI_LANGUAGE equ 3
HH_GPROPID_CURRENT_SUBSET equ 4
HH_GPROPID_CONTENT_LANGUAGE equ 5

the problem now is I can't equate HH_GPROPID to anything
and in the following structure one member is defined as HH_GPROPID id so how do I translate the structure member id ?


typedef struct tagHH_GLOBAL_PROPERTY
{
HH_GPROPID id;
VARIANT var;
} HH_GLOBAL_PROPERTY ;

cheers
Posted on 2002-06-04 04:36:45 by MArtial_Code
OK I've had a test in VC and here's what I found...



typedef enum workdays {MON=2,TUE,WED,THU,FRI} workweek;

struct teststruct
{
workweek id;
DWORD var;
} test;
#define SUN 1
#define SAT 7


by defining the structure member id as type workweek you can assign any member of workweek to it without error. Any other values will require a cast to type workweek to compile...
eg.


test.id=WED ;compiles and runs fine
test.id=SUN ;compilation error
test.id=(workweek)SUN ;compiles and runs fine
Posted on 2002-06-04 05:52:00 by MArtial_Code
By default, VC++ allocates one DWORD for each enum variable.
Posted on 2002-06-04 16:17:04 by tenkey
MArtial_Code, your translation is fine, add the following for the rest of it:
HH_GPROPID typedef DWORD


HH_GLOBAL_PROPERTY struct
id HH_GPROPID ?
var VARIANT <>
HH_GLOBAL_PROPERTY ends
MASM doesn't support enums - wish it did - all you can do is tell MASM it is a DWORD and then use it in the STRUCT so the programmer knows what it's suppose to be if they trace it back. Or, if you use RadASM, I'd rather see HH_GPROPID in the struct list then DWORD. :)
Posted on 2002-06-04 17:54:22 by bitRAKE
I've got everything else sorted except for that last structure...
I've defined the members as DWORDS
I couldn't find the declaration for type VARIANT anywhere?
Posted on 2002-06-04 18:40:35 by MArtial_Code
Are you SURE you want to know what a Variant is? ;-)

Variants come from VB, where it is the type you use when you don't know the type. Not that a variant is typeless, it supports all other types. It is one of the basic Automation (OLE/COM) types.




VARIANT STRUCT ;DWORD
vt WORD VT_EMPTY
wReserved1 WORD 0
wReserved2 WORD 0
wReserved3 WORD 0
Union
lVal SDWORD ? ; VT_I4
bVal WORD ? ; VT_UI1
iVal SWORD ? ; VT_I2
fltVal REAL4 ? ; VT_R4
dblVal REAL8 ? ; VT_R8
boolVal VARIANT_BOOL ? ; VT_BOOL
scode SCODE ? ; VT_ERROR
cyVal QWORD ? ; VT_CY
date QWORD ? ; VT_DATE
bstrVal BSTR ? ; VT_BSTR
punkVal PVOID ? ; VT_UNKNOWN
pdispVal PVOID ? ; VT_DISPATCH
parray PVOID ? ; VT_ARRAY
pbVal PVOID ? ; VT_BYREF|VT_UI1
piVal PVOID ? ; VT_BYREF|VT_I2
plVal PVOID ? ; VT_BYREF|VT_I4
pfltVal PVOID ? ; VT_BYREF|VT_R4
pdblVal PVOID ? ; VT_BYREF|VT_R8
pboolVal PVOID ? ; VT_BYREF|VT_BOOL
pscode PVOID ? ; VT_BYREF|VT_ERROR
pcyVal PVOID ? ; VT_BYREF|VT_CY
pdate PVOID ? ; VT_BYREF|VT_DATE
pbstrVal PVOID ? ; VT_BYREF|VT_BSTR
ppunkVal PVOID ? ; VT_BYREF|VT_UNKNOWN
ppdispVal PVOID ? ; VT_BYREF|VT_DISPATCH
pparray PVOID ? ; VT_BYREF|VT_ARRAY
pvarVal PVOID ? ; VT_BYREF|VT_VARIANT
byref PVOID ? ; Generic ByRef
cVal SBYTE ? ; VT_I1
uiVal WORD ? ; VT_UI2
ulVal DWORD ? ; VT_UI4
intVal SWORD ? ; VT_int
uintVal WORD ? ; VT_uint
pdecVal PVOID ? ; VT_BYREF|VT_DECIMAL
pcVal PVOID ? ; VT_BYREF|VT_I1
puiVal PVOID ? ; VT_BYREF|VT_UI2
pulVal PVOID ? ; VT_BYREF|VT_UI4
pintVal PVOID ? ; VT_BYREF|VT_int
puintVal PVOID ? ; VT_BYREF|VT_uint
ENDS
VARIANT ENDS



You can define a Variant like so:





LOCAL variantNewItem:VARIANT

mov variantNewItem.vt, VT_DISPATCH
mov eax, pNewDoc ; pointer to a IDispatch object
mov variantNewItem.pdispVal, eax


Basically, the .vt WORD holds the type enclosed, and you pick something from the union for the data part. Leave the reserved parts NULL.

There are quite a few APIs for manipulaing Variants, mostly defining, and converting from one type to another (ie, from a string to a long).

You might find my oaild.inc file usefull, its where I define this type. It should be in the COM part of MASM32 (masm32\COM\include).
Posted on 2002-06-04 19:15:44 by Ernie

I couldn't find the declaration for type VARIANT anywhere?
Search the board. ;)
You'll find this: http://www.asmcommunity.net/board/index.php?topic=2127&highlight=VARIANT

Ernie, beat my reply - good, someone that
really knows what he's talking about in this area. :alright:
Posted on 2002-06-04 19:20:01 by bitRAKE