Hello,NAN and everyone else:

1.how to convert a static member function in c++ to Masm Class member?

2.and how to convert this to asm:

CQueue::ELEMENT e = { nThreadNum, nRequestNum };

Thanks all.
and have a good new year!
Posted on 2002-01-02 00:41:43 by smallwaves
Well it seems your coming along fast :), but unfortunately i may not be of much help for you at this moment.

Static Members: This is something that we are still trying to implement "cleanly" (remember the OOP stuff released is only a Pre-release) so there is still some issues to be delt with (( This is one, sorry ))

The best solution so far is to place the variable to be static in the ".data" portion of the class. The downside is this just a public variable in essence (not hidden by ClassName.Variable, just Variable!! :( ) Likewise you can simply add functions within your class file and you in effect have the same thing as a static function (dont forget PROTO's) and once again the same problem occours of keeping this "static" function encapsulated withing the class name :( )

I hope this helps your problem in this area...

As for you second question, I can barely read that :grin: . Me and C++ have been growing very far apart these days (mainly because it looks like jibberish). If im reading this right, it declairs a variable within the CQueue class called 'e' and is of the type "ELEMENT" and is also pre-initialized to hold nThreadNum, nRequestNum in that order....

So with our model my guess is:

; need to know how ELEMENT is structured and predifined
ELEMENT struct

; In the class definition add the variable 'e'

; if nThread and nRequest are static values at compile time
; then initialize them here!
d? nThreadNum, nRequestNum ; as per ELEMENT IFF n's are static!


; if they are not static, then have them initialized in the
; constructor by passing to the constructor these variables
; Dont forget to modify the PROTO as well
CQueue_Init PROC uses edi esi lpTHIS:DWORD, nThreadNum:DWROD, nRequestNum:DWORD
SetObject edi, CQueue

m2m [edi].e.ThreadNum, nThreadNum
m2m [edi].e.RequestNum, nRequestNum

ReleaseObject edi
CQueue_Init ENDP

NOTE: m2m is a common macro used (m2m mem1, mem2 == push mem2, pop mem1)

The latter way will *always* work for static or dynamic variables of nThreadNum and nRequestNum, but requires this info passed when an instance of CQueue is create:

NEWOBJECT CQueue, nThreadNum, nRequestNum

Not a real biggy, but thought i should point it out! ;)

Is any of this any help to you??
Posted on 2002-01-02 02:53:33 by NaN
I don't know much about C++ either, but I found the source from the book on the internet (here).
I don't know if I got it right here but as the ELEMENT structure is defined *inside* the class definition (look at the C code), you'll have to write:

CQueue::ELEMENT e = { nThreadNum, nRequestNum };

instead of:

ELEMENT e = { nThreadNum, nRequestNum };

I think 'CCQueue::ELEMENT' is just a type identifier. However in masm you don't have these things so just declare the ELEMENT structure somewhere (or call it CQUEUE_ELEMENT or something), and just use it like NaN says. However, I don't think 'e' is a class member, it's just an ELEMENT structure outside the class.
But I may be wrong as I have not much C++ experience.

Posted on 2002-01-02 15:34:27 by Thomas
Thanks first.

It helps me a little and now I can solve What I have meet but a little not perfect beautiful because I could't use them as a class number. (:-

and yes,I am converting all source codes of Jeffrey Richter's "Programming Applications for Microsoft Windows,Fourth Edition." to Masm32 and have implemented 12 samples.a little difficult but also very interesting.

Hope NAN's Masm32 OOP 's release published quickly,It's indeed a great work I think!

Have a good day!


Posted on 2002-01-03 05:04:18 by smallwaves
Glad We Can help your work... and thanx for your suprort!

Posted on 2002-01-03 11:18:03 by NaN