FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Struct vs. Class

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> DWT
View previous topic :: View next topic  
Author Message
brad
Site Admin


Joined: 22 Feb 2004
Posts: 490
Location: Atlanta, GA USA

PostPosted: Sun Mar 28, 2004 2:34 pm    Post subject: Struct vs. Class Reply with quote

Steve Roy and I have been talking about what to do about some of the SWT classes for Unicode and such. I'll give an example:

For LogFonts, there are three files in org.eclipse.swt.internal.win32:
LOGFONT.java
LOGFONTA.java
LOGFONTW.java

Each of them are basically acting like structs, but are separate classes (A and W inherit from the top one and add size to the struct).

Andy Friesen did some work and made:

dwt.internal.win32.logfont.d - with 3 structs inside.

Our question is, to keep up with what will inevitably be updates to SWT, should we have three different files, all classes, that inherit? Just to remain somewhat in sync with Java, even though D has the struct capability?

Thoughts?
_________________
I really like the vest!
Back to top
View user's profile Send private message
Guest






PostPosted: Sun Mar 28, 2004 2:59 pm    Post subject: Re: Struct vs. Class Reply with quote

brad wrote:
<snip>

Our question is, to keep up with what will inevitably be updates to SWT, should we have three different files, all classes, that inherit? Just to remain somewhat in sync with Java, even though D has the struct capability?

Thoughts?


Clearly there's some major benefits to tracking the original SWT code closely. While that may not be possible in many circumstances, I don't think it's in one's best interests to fork implementation purely for a syntactic preference.

OTOH, I haven't looked at the code so my opinion may be thoroughly groundless ...

- Kris
Back to top
BenHinkle



Joined: 27 Mar 2004
Posts: 76

PostPosted: Sun Mar 28, 2004 3:31 pm    Post subject: Re: Struct vs. Class Reply with quote

brad wrote:


For LogFonts, there are three files in org.eclipse.swt.internal.win32:
LOGFONT.java
LOGFONTA.java
LOGFONTW.java

Each of them are basically acting like structs, but are separate classes (A and W inherit from the top one and add size to the struct).


I was just poking around this site so I hope people don't mind if I stick my nose in here.
Can these files just import the windows declarations? Is LOGFONT even part included in the windows.d wrapper? Java needed explicit wrappers since it can't deal with native data structures and I think D should take advantage of the native interface whenver possible.

I don't know SWT all that well, but my impression is that it was unique for the Java world since it let you get right down to the native interface with minimal cross-platform overhead. I thought the point was to sacrifice cross-platform wrappers for speed. People who were sick of poor Swing performance started using SWT. Given that D can directly talk to the native API just by writing an import file, what is the advantage of SWT?
Back to top
View user's profile Send private message
brad
Site Admin


Joined: 22 Feb 2004
Posts: 490
Location: Atlanta, GA USA

PostPosted: Sun Mar 28, 2004 3:47 pm    Post subject: Reply with quote

Both SWT and DWT talk natively. I think this specific example of LOGFONT is a higher-level abstraction because another platform needed it. These are just structs that we're discussing, and the native calls are elsewhere. (maybe I mis-interpreted you Ben)

The dwt.internal.xxx modules (xxx= win32 or gtk) are where the native calls are found. org.eclipse.swt.internal.xxx is also where the JNI calls are found, so you can tell that Java was going native as well, wherever possible. That is the main reason I want to see a port of SWT. Ben just recapped them nicely.

Subversion has a web interface, albeit limited. See the code I'm talking about in a browser here:
http://svn.dsource.org/svn/projects/dwt/src/dwt/internal/win32/os.d

Look towards the bottom and I think you'll see your native interface calls.
_________________
I really like the vest!
Back to top
View user's profile Send private message
evetsyor



Joined: 27 Mar 2004
Posts: 12

PostPosted: Sun Mar 28, 2004 3:53 pm    Post subject: Reply with quote

SWT is a combination of classes and a native API wrapper written in C. for the D port we dont need the wrapper, we can call the native one directly.

So the port itself is more a port of the classes. which is what the SWT is really a classes framework.


- Steve
Back to top
View user's profile Send private message
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Sun Mar 28, 2004 8:11 pm    Post subject: An Independant DWT Reply with quote

Steve has the idea.

The purpose of porting SWT to D was to take advantage of a class design. It saves a lot of work. Also most of the native interface to separate OSes are already developed and easily translated to D calls. This simplifies the work of porting it to multiple platforms.

Unfortunately there are some issues. After examining the java code and doing some conversion, I have to disagree with the "Guest" above. Tracking the SWT closely may be very hard to do. I predict that DWT will have to become it's own library separate from SWT once it reaches satisfactory functionality. There is too much unnecessary baggage from Java SWT that would be best dropped from the D port. That and the fact that we may augment the event system to support D delegates too. You just have to look at the code to see that their are a lot of things that we shouldn't need in D. SWT, therefore, lends mostly to a structural base on which to improve an independent D GUI interface.

Thus, my opinion is that we should NOT track SWT too closely. It may make for an even more complicated project.

Opinions? I may be the only one that believes this way....shoot me down if I'm out of order. I just think heavy modifications will be necessary to make things smooth and palatable to D programmers and trying to integrate SWT updates concurrently will be messy.

Later,

John


Last edited by JJR on Sun Mar 28, 2004 8:47 pm; edited 1 time in total
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Sun Mar 28, 2004 8:28 pm    Post subject: Re: An Independant DWT Reply with quote

JJR wrote:
<snip>
Unfortunately there are some issues. After examining the java code and doing some conversion, I have to disagree with the "Guest" above. Tracking the SWT closely may be very hard to do. I predict that DWT will have to become it's own library separate from SWT once it reaches satisfactory functionality. There is too much unnecessary baggage from Java SWT that would be best dropped from the D port. That and the fact that we may augment the event system to support D delegates too.


I agree with you John; there will most certainly be some major differentiation in implementation, particularly when it comes to delegation. But my earlier post was just suggesting to avoid adding to that as a result of personal stylistic slants (preferring struct over class, in this case) ... something that I'm guilty of, and often wish I wasn't Smile

- Kris
Back to top
View user's profile Send private message
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Sun Mar 28, 2004 8:45 pm    Post subject: Reply with quote

Oops... (Guest == Kris)

I see your perspective. I mistakenly got the context wrong.
Back to top
View user's profile Send private message
Ant



Joined: 06 Mar 2004
Posts: 306
Location: Canada

PostPosted: Sun Mar 28, 2004 11:39 pm    Post subject: Re: An Independant DWT Reply with quote

kris wrote:
there will most certainly be some major differentiation in implementation, particularly when it comes to delegation.
- Kris


let me add the DUI lives perfectly happy with both listener interfaces
and delegates.

To listen to event through delegates it's not expensive (on coding
efford) and can be added at any moment to the event provider
classes with no other impact. That code should be stored some
here else on any format we find fit and added to the converted code
after each "synchronization" with SWT.

Ant
Back to top
View user's profile Send private message
evetsyor



Joined: 27 Mar 2004
Posts: 12

PostPosted: Mon Mar 29, 2004 7:55 am    Post subject: Reply with quote

I personaly prefer the use of struct. but in the current state of the project, i think its better idea to leave thing that can work as is. and change only thing that cant.

Traceability is very important unless we plan to have a team of 40 man to keep the code up-to-date and working, when it stop working everytime a os change (aka Redhat habit). when IBM have a huge team already fixing it in the java SWT. that we just have to port the fix after. imho

- Steve
Back to top
View user's profile Send private message
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Mon Mar 29, 2004 10:00 am    Post subject: Keep Reply with quote

After looking at the logfont code, I guess I have to agree with Steve and Kris. Better to leave it as is for now for consistancy. We can "pretty" things up (or fowl it up) later once things are actually working properly. This is much the same as we've been doing with most of the other SWT features anyway. We've basically been adopting what works in D whether it's preferable or not (String, SWT_error, etc.).

It's kind of ugly to have to "inherit" things like logfont(a,w) from the SWT code but... oh well.
Back to top
View user's profile Send private message
andy



Joined: 15 Mar 2004
Posts: 71

PostPosted: Wed Mar 31, 2004 2:18 pm    Post subject: Re: Struct vs. Class Reply with quote

brad wrote:
Steve Roy and I have been talking about what to do about some of the SWT classes for Unicode and such. I'll give an example:

For LogFonts, there are three files in org.eclipse.swt.internal.win32:
LOGFONT.java
LOGFONTA.java
LOGFONTW.java

Each of them are basically acting like structs, but are separate classes (A and W inherit from the top one and add size to the struct).

Andy Friesen did some work and made:

dwt.internal.win32.logfont.d - with 3 structs inside.

Our question is, to keep up with what will inevitably be updates to SWT, should we have three different files, all classes, that inherit? Just to remain somewhat in sync with Java, even though D has the struct capability?

Thoughts?


I don't think that keeping stuff this closely matched would really affect porting any improvements from SWT to DWT later on. What you'd typically do is do a mass-diff against the version of SWT we're porting from, and the new version. Then it's simple to copy/translate changes over.

With this in mind, I thought I'd do things the D Way.
_________________
"Complacency is a far more dangerous attitude than outrage." - Naomi Littlebear
Back to top
View user's profile Send private message
evetsyor



Joined: 27 Mar 2004
Posts: 12

PostPosted: Thu Apr 01, 2004 5:40 am    Post subject: Reply with quote

In those case:

LOGFONT.java
LOGFONTA.java
LOGFONTW.java

We should use struct, cuz those struct are passed to Win32 API, java version use class then thru the wrapper .c files are sorta converted. in D we will use the API directly.

Actuly those struct should come from std.c.windows.* and not supply them in dwt.

- Steve
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> DWT All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group