Hello.
I use the Classes of NaN and works very good.
But I have two questions.
a).In C++,the definition of an object
may be done anywhere,for examble in section data and
the object destroyed when the program terminate.
In Classes of NaN,the "newobject" must insert in a
module,for examble in WM_CREATE and must I destroy it in a module,for examble in WM_DESTROY.

b).The size, in bytes,of an object of C++ is the size of data
only,as is with structures.

Can the objects of NaN be the same as the objects of C++ ?

Thanks,Manos.
Posted on 2002-06-01 09:36:47 by Anonymous
Im glad you like it, but unfortunately it has limited, if any, cross-support with C++.

Our model was an evolving thought experiment of ideas between Thomas and myself. It is purely our own ideas, and has no direct C++ infuence in its design.

Thomas, did manages to make it link to a C++ build, but there was considerable overhead involved in setting up the right conditions.

Our model makes use of the HEAP to instanciate new object using the "newobject" macro. It can not be, at this point, done in the data section, as you can not call the HeapAlloc API's from the data section. In the future I might find a revision for this case.. thanks for pointing it out ;)

As well, the size will be wrong, as it accounts for the size of the function pointers it points to as well. We dont use a virtual look up table for the method pointers. As im told C++ does this, we store the function pointers, just like member variables, with in the class structure. So this will infuence the size by NUM_OF_METHODS * 4. Again, this is a side affect of the way it was designed initially.

We have put some research into another way of setting correct function pointers, but where progress was made, sacrifice was also involved.. mainly we loose the ability to inherit (at the moment with my research)... so as it stands we havent changed the model, since this way still provides most flexibility.

Over this summer i will, at sometime, get back into researching better organizations... but i have a fair bit of stuff on my plate at the moment.... as does Thomas ;)

Glad you like it tho..
:alright:
NaN
Posted on 2002-06-01 14:11:15 by NaN
From my readings (mostly the appendix of "Effective COM' (I believe, have me check before you buy)) MSVC++ stores the whole vtable inside the object blob. There was a whole discussion of what the Excel design team did to keep things small and in control (each cell in a sheet needs an object).

You can do it either way. For my CoLib objects I kept the vtable out of the object blob. But my code completely ignores implimentation inheritance (ie, same code in derived classes), and just uses macros to keep track of the function list (which ultimately must be filled in by hand anyway).

But for compatability with C++, you need do it the same exact way. Sorry, I don't know what this is.
Posted on 2002-06-01 22:45:06 by Ernie
Here's what I know about visual C++ classes:

Basically, the class is just a structure with it's data members. The class methods are just normal functions that take one extra parameter (this pointer), mostly in ECX for methods with the C++ calling convention, or as an extra parameter (pushed on the stack) when using stdcall convention.

The vtable is not present unless you've defined virtual methods. As soon as you have one or more virtual methods, one extra pointer is added at the top of the class structure. This pointer points to an array of method pointers.

So virtual methods are the only methods that add a function pointer to the class structure.

The class model NaN and I worked on only uses virtual methods, not the normal methods. Maybe it will in later versions.. A big difference is that while C++ stores the functions in a seperate table and adds a pointer to this table, our model stores them directly into the class structure.

C++ classes can be used as COM objects directly, as long as you use the stdcall convention. The virtual function pointer serves as vtable pointer, the class data doesn't matter for COM.

Thomas
Posted on 2002-06-02 03:29:10 by Thomas
Hello NaN,Hello Ernie.

I would like to know if it is possible to create,for masm32 of course,a simple Class,with private and public members,without inheritance,without polymorphism.
Under C++,the definition of an object have as follow:
CMyClass sameName;
When the program starts,is called the constructor and when the program terminate is called the destructor.
I would like to know,how and from wheare the program call the constructor and destructor of C++ Class ?
I think that the creation of a simple Class for masm32,is important for programmers.

Thanks,Manos.
Posted on 2002-06-02 03:49:24 by Anonymous
mostly in ECX for methods with the C++ calling convention


Well, isn't that funny? I was just looking at a disassembly wondering what the deal was with all those mov ecx,*** before CALL's :) Thanks!
Posted on 2002-06-02 03:50:45 by Qweerdy
Originally posted by manos
Hello NaN,Hello Ernie.

I would like to know if it is possible to create,for masm32 of course,a simple Class,with private and public members,without inheritance,without polymorphism.
Under C++,the definition of an object have as follow:
CMyClass sameName;
When the program starts,is called the constructor and when the program terminate is called the destructor.
I would like to know,how and from wheare the program call the constructor and destructor of C++ Class ?


Our object model can create a simple class, but it isn't as easy as in C++, simply because MASM has no native class support. The C++ compiler does a lot of stuff with the classes and calculates the right offsets and stuff when you use a class. We can only do this through macros, and therefore we are limited to what we can do with macros.

Like NaN said, there's no support yet for direct declaration of classes in the data section, only a pointer to a class (CMyClass *pSameName; ).
The constructor is called in the NEWOBJECT macro, the destructor is called in the DESTROY macro.
C++ calls these depending on how you declare the class. If you declare it globally, it will call the constructor in one of it's internal startup procedure, before your own code even runs, the destructor on the program's exit.
When declared locally (or in a class, or anything else not global), the constructor is called when the object is in scope, the destructor when the object is leaving it's scope.
Finally when you declare the object as a pointer to this objcet (CMyClass *pSameName), the constructor is called on the 'new' operator, and the destructor on the 'delete' operator.

This last method is the only method that can be used in MASM with our object model.

I think that the creation of a simple Class for masm32,is important for programmers.


Classes are an advanced topic in win32asm. In C++ classes are used all the time because the language has been designed to use classes (just like Java). Assembly was never designed to let the programmer use classes. In fact it was just designed as a replacement for entering machine code directly. We made it possible to use classes, but it's not as easy as with C++. You'll have to know what goes around internally, something you do not necessarily need to know when programming in C++.
What I'm saying is that a C++ is generally based on classes, while asm programs are not. In asm, most of the time it's easier to use procedural programming instead of classes. It's better not to use classes unless there's a real advantage in using them.

Thomas
Posted on 2002-06-02 04:19:03 by Thomas
One thing I forgot:
I would like to know if it is possible to create,for masm32 of course,a simple Class,with private and public members,without inheritance,without polymorphism.


In C++ there's a big difference between private and public members, the compiler will not let you use private members externally etc. In asm, it's up to you. Nothing will prevent you from writing to a private member when you are not allowed to.
I believe NaN did some research to see if this would be possible, but right now it isn't.

Thomas
Posted on 2002-06-02 04:24:30 by Thomas
Hello Thomas.

I understand all.I use your Classes.
I will wait the completion of their.

Thanks very mutch,Manos.
Posted on 2002-06-02 04:53:48 by Anonymous
Hello NaN,Hello Ernie,Hello Thomas.

I am a Professor.
One year ago,I had make a program for my School,with Visual Basic,without any Data Base.I had use structures and arrays.
It works good,but Visual Basic has limitations and run slowly.
After,I had make the same program with Visual C++,with MFC.
But MFC has unnecessary difficultys and limitations.I do n't like MFC.
Recently,(March 2002),I visited Hutch's home page and i downloaded masm32,Iczelion tutorials,oop,ComInAsm and Radasm.
Since then I am enthusiast about its and I have choose to programming in masm32.It is the best choice.
Now,I am making the same program with masm32.Every student in my program is a two-dimensions array with rows and cols.
All students represent an array that is an object of a Class of NaN-Thomas.The memmory is allocated from heap.I add or delete students with methods of object.It works fine.
But,I have a problem.In Visual Basic and in Visual++(with MFC),I had use the MS FlexGrid Control,(ActiveX Control),for display and edit data.With masm32,I can not do the same.I can not use ActiveX Controls.The ListView control,(Common controls),it is not so optimal.I must make a control with grid,but it need mutch time.
Has someone of you a better idea ?

Thanks,Manos.
Posted on 2002-06-02 09:10:09 by Anonymous
Search the board, people have run into this before. You might get some ideas.

Search for "Listview"
Posted on 2002-06-02 09:28:23 by Qweerdy
Well, there are two ways to go. Make your own or re use something else.

You could reuse an activeX control in asm. Jaspeth has posted some code on reusing the web browser control, the same technique should work for any activeX control. Basically you need provide a client site set of interfaces for the visual control to run inside.

That may have a steep learning curve, meaning it may take as much time to get working as writing something yourself.

I'm kinda surprised there isn't a window control for a grid, typically the VB controls shadow the standard controls in OCX wrappers. I don't know of any, but I'm not the last answer on controls.

Just how much data will your grid display? I'm assuming you have an array of pointers to some strings (student names) and numbers (ID number, age, ect) to display. Knowing the grid window size, col width, row height, it is straightforward to LINETO the borders, then (a little more work, but straightforward again) TEXTOUT a string ( first converting numbers to strings of course).

If you limit cells to a single line of text the math shouldn't be TOO convoluted to get a display up. It actually seems like a nice project for someone to work with (hint around and someone might write it for you).
Posted on 2002-06-02 10:08:08 by Ernie
Its ironic, but i reciently wrote a plotting custom control. Its purpose is for raw display of data.. mainly it geared towards the 'y-data' and not the 'x-data' in display. The x-data is just increments in the data array.

There is an unfinished example of my control Here.

When its finished i might make is support two equal length arrays (x data, y data) if your still in a pinch...

BTW, im glad you like the model we designed so much. We are quite proud of it ourselves, but we also realize its far from finished... problem really is man-power to get it done, and we also have *other* personal projects on the go. But it will get done at some point ;)

PS: Just currious, but what school do you profess for?

:NaN:
Posted on 2002-06-02 14:22:06 by NaN
Thanks Ernie for your interest.

For only display the data in form grid is easy.I do it already in Printer.But in screen the data must scrolling.Also,the grid control must send messages to parent window,as the mouse move,as the mouse leave a cell,as the mouse enter in a cell,.....
Also,I want to select a range of cells.
I can make that control,but need very much time.Thear are two ways.The first is by using the classes of NaN-Thomas with methods and sending user defined messages to the parent window.But at that case the control may be use only in masm32.
The second way is to make a Dll,as Common controls.This way is better,because the control it could be use from Visual C and from Visual Basic too(by subclassing),but is more difficult.
I do n't have choose,yet.
Thanks,Manos.
Posted on 2002-06-02 15:06:51 by Anonymous
Hello NaN.
I am Professor for middle school and high school.
Manos.
Posted on 2002-06-02 15:35:39 by Anonymous