Change ImageLoader importing#105
Conversation
This change is required to allow a call to Object.factory to work as intended. For such calls to work, D needs to know about the module (i.e. the symbol needs to be resolvable). This specific change is in relation to a change that will happen in the FileFormat class which will create a child of FileFormat dynamically.
Thinking out loud: would it be better to add a
Cyclic dependencies are caused by module constructors. I had a quick glance at the module constructor in |
I'd be happy with that. I only chose
Sorry, not entirely sure what you mean by this. What counts as part of the module constructor? |
A module constructor is declared using |
Ah, okay. I didn't realise a While I'd be (mostly) fine moving the code out, I thought the general idea was to keep the code as close to Java as possible? The local fix I have does this — the main part being that |
There's no semantic difference of placing a
Yes, but correctness first. I was thinking this issue was in the correctness category. But, of course, it can be solved in different ways. |
This will add a
.allfororg.eclipse.swt.internal.image, which is then imported by theImageLoaderclass.As I've mentioned in #103 and #104, when attempting to add a new constructor to the
Imageclass (specificallyImage(Device, ImageDataProvider), I encountered a cyclic dependency betweenDPIUtilandJPEGFileFormat.The main cause was in the
FileFormatclass which, in DWT, imports theJPEGFileFormatclass, whereas SWT doesn't.SWT uses
Class.forNameto dynamically create an instance of the file format. I changed DWT to use the same (after implementing theforNamemethod), but -- sinceFileFormatcouldn't importJPEGFileFormat-- DWT couldn't resolve the symbol.ImageLoaderis the only place where SWT imports all from theorg.eclipse.swt.internal.imagepackage, so I changed the import here to be the same. This then made everything work (locally).Edit: (corrected cyclic dependency)
Here is the error that would occur: