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

How to solve a forward reference headache ?

 
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
Blandger



Joined: 21 May 2004
Posts: 50
Location: Ukraine, Kharkov

PostPosted: Tue Jun 29, 2004 3:27 am    Post subject: How to solve a forward reference headache ? Reply with quote

Guys we need your help in the subject. I think DWT came to the stage when we can't go further without it. Any ideas, help and suggestions are welcome. I'll try to be as short as possible.

Preamble for those who read about problem for the first time.
DWT has widgets classes hierarchy inherited from a SWT which is written on java. DMD doesn't resolve that hierarchy as java compiler does and we have f.ref. error in the DWT.

We stuck with f.ref. error for the first time (may be my case wasn't first ) when I've made DWT conversion from java to D using 'limited quantity' of source classes from Brad. I made conversion in the 'wrong way' leaving 'java style calling conventions' in the source. My approach was wrong but I could run up to the end of DWT conversion very quickly. My goal was to check possibility of compiling the DWT. So I got f.ref. which I couldn't resolve at the end. Now we came almost to the end of first compiled DWT version using 'right conversion approach' but we have the same error.

I made a 'simplified DWT' widget hierarchy trying to find a way to work around f.ref. but I still don't know what's the clue. Of cource this code is far from the 'real' DWT's twisted hierarchy. I'll give this sources and will comment them.

There are code which is 'compiled'. Now it doesn't have f.ref. error. I made it using 'stripped' DWT widgets classes and tweaking the placement of 'private import' directives.

Scons script is used for compiling. Scons is very convinient tool and saves a lot of time. You can get it from here http://scons.sourceforge.net/download.html. Also it needs Python23 to be installed on the PC.

src\SConstruct script file

Code:

from glob import glob
import os
import sys
env = Environment(ENV=os.environ)
SRC = (
    glob('dwt/widgets/*.d')
)
env.Program(SRC)


Here are sources. Private import commented with number like: //1.1... can be tweaked. We move private import statements to 'inside' or 'outside' class body.

src\dwt\widgets\display.d
Code:

module dwt.widgets.display;
public class Display {
private import dwt.widgets.control;
    Control lastHittestControl;
    public this() {
    }
}


src\dwt\widgets\composite.d

Code:

module dwt.widgets.composite;

private import dwt.widgets.scrollable;
private import dwt.widgets.control;

public class Composite : Scrollable {

//private import dwt.widgets.control;

   Control [] tabList;
   this() {}
   public this(Composite parent, int style) {
   //   super (parent, style);
   }
}


src\dwt\widgets\scrollable.d
Code:

module dwt.widgets.scrollable;

private import dwt.widgets.control;
//private import dwt.widgets.composite;

public abstract class Scrollable : Control {

private import dwt.widgets.composite;

   this() {}
   public this(Composite parent, int style) {
   //super (parent, style);
   }



src\dwt\widgets\control.d
Code:

module dwt.widgets.control;

private import dwt.widgets.widget;
//private import dwt.widgets.composite; // 1.1

public class Control : Widget {

private import dwt.widgets.composite; // 1.2

    Composite parent;
    this() {}
}


src\dwt\widgets\widget.d
Code:

module dwt.widgets.widget;

//private import dwt.widgets.display; //2.1
   
public abstract class Widget {

private import dwt.widgets.display; //2.2

   Display display;
   int style;
   this() {}
  public this(Widget parent, int style) {
   this.style = style;
   display = parent.display;
  }
}


1. If we change placement of 'private import' in the 'control.d' commenting line 1.2 and uncommenting 1.1 we'll get 'Forward Reference' error.

dwt\widgets\scrollable.d(7): class Scrollable is forward referenced

2. If we change placement of 'private import' in the 'widget.d' commenting line 2.2 and umcommenting 2.1 (leaving Control as it was for the first time) we'll get DMD crash on the widget.d.

The private imports tweaking in the other classes doesn't help in both cases.

I want to say what this example is far from the real DWT classes. They have more 'widget variables' in them and more imports. It's just a simplest hierarchy I could get compiled.
_________________
Regards, Yuriy
Back to top
View user's profile Send private message
kris



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

PostPosted: Tue Jun 29, 2004 11:23 am    Post subject: Reply with quote

If this is representative of the primary issues you're having, I suggest it would be worth sending a buildable example to Walter and plead with him to resolve the issue. I can't imagine Walter does not wish to see an SWT port ...

There's no harm in trying, and I imagine the f.ref problems are more a case of priority rather than some fundamental technical hurdle. DWT really could use some more "visibility".

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



Joined: 21 May 2004
Posts: 50
Location: Ukraine, Kharkov

PostPosted: Tue Jun 29, 2004 12:39 pm    Post subject: Reply with quote

kris wrote:
If this is representative of the primary issues you're having,

I'm not absolutely sure if it's primary issue or not but I think it shows some problems in the DMD which can be solved by Java compiler easily.

Quote:
I suggest it would be worth sending a buildable example to Walter and plead with him to resolve the issue. I can't imagine Walter does not wish to see an SWT port ...

This is exactly I offered to Brad long time ago.
What do you think Brad? Do you need an archive for this three cases or should I apply to Walter by myself? Actually all necessary source code is posted here.

Quote:
There's no harm in trying, and I imagine the f.ref problems are more a case of priority rather than some fundamental technical hurdle. DWT really could use some more "visibility".

Agree.

Thank you Kris.
_________________
Regards, Yuriy
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Tue Jun 29, 2004 5:16 pm    Post subject: Reply with quote

The "forward reference" problem has already been mentioned on the old official newsgroup, but maybe Walter needs some prodding. The posting of a concise (yet complete) set of code that causes the error could promote the issue in the Bugs newsgroup. Walter is already on the record as being in favor of fixing it, but there might not be an easy solution.

From http://www.digitalmars.com/drn-bin/wwwnews?D/21203
Walter wrote:
I agree it's a problem. I'm not sure what to do about it, but I'll keep it in the bug list until it is properly resolved.


(By the way, there was already a DWT topic with this subject, but I guess you can never have too much of a good thing.)
Back to top
View user's profile Send private message AIM Address
kris



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

PostPosted: Tue Jun 29, 2004 5:52 pm    Post subject: Reply with quote

I'd suggest foregoing the NG; send it to Walter directly (do a reply to one of his posts).
Back to top
View user's profile Send private message
brad
Site Admin


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

PostPosted: Fri Jul 02, 2004 2:02 am    Post subject: Reply with quote

As the newsgroup discussion suggested, once we go back to Make instead of scons (hopefully temporarily), the forward reference errors go away. At least for now. SCons approach of one file at a time may need some revision. There is an updated makefile in /src.

What does happen is that the compiler begins to give you real, solvable errors from the widgets subdirectory. I made progress on this with the first 5-6 widgets in the directory, and feel like we can make some more progress now.

Here's my SVN Commit message:
Code:
Reverted back to makefile in /src instead of scons.  This got rid of the forward references messages from DMD.
Then, began to fix compiler errors in button, canvas, composite, display, event, layout, shell, widget.
Left off at control (line 480).


BA
_________________
I really like the vest!
Back to top
View user's profile Send private message
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Fri Jul 02, 2004 3:07 am    Post subject: Reply with quote

Note that A-A-P support compiling all files at once using

:lib foo {onestep} : foo1.d foo2.d foo3.d
Back to top
View user's profile Send private message
Blandger



Joined: 21 May 2004
Posts: 50
Location: Ukraine, Kharkov

PostPosted: Fri Jul 02, 2004 8:41 am    Post subject: Reply with quote

brad wrote:
As the newsgroup discussion suggested, once we go back to Make instead of scons (hopefully temporarily),

It's a pity.
Is there any way to force it take all source as one line? I think it must be.

Quote:
What does happen is that the compiler begins to give you real, solvable errors from the widgets subdirectory. I made progress on this with the first 5-6 widgets in the directory, and feel like we can make some more progress now.

Excellent!

Quote:
Then, began to fix compiler errors in button, canvas, composite, display, event, layout, shell, widget.
Left off at control (line 480).

My hands are itching. I'll try it in the evening.
_________________
Regards, Yuriy
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