The time now is Sat 25 May 2013, 21:10
All times are UTC - 4 |
| Author |
Message |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Fri 03 Apr 2009, 19:09 Post subject:
|
|
today we discussed, what kind of final project we might do in the end of the C# course (last week of mai).
One idea I have, is the following. But I am not certain, how far it is doable.
A program, that reads in C# files, and converts them to vala.
So you afterwards could compile native binaries, and would not need .net or mono, to run them.
Limitations:
As I have just 1 week, it is impossible, to convert additional libs.
So WindowsForms or such would be ignored.
It just would convert simple things. Example:
| Code: | | Console.WriteLine("test"); |
This would become:
| Code: | | stdout.printf ("test\n") |
So the task would be, to replace several calls to "System" with calls to "GLib".
Usually, such a program will not work immedeatly, you had to convert other things by hand.
But it could simplify the process of porting from C# to vala.
If someone knows, if comparable utilities exist, please let me know.
In the next weeks, I will investigate, if it makes sense for only 1 week or not.
Mark
_________________ my recommended links
|
|
Back to top
|
|
 |
wow
Joined: 29 Jun 2006 Posts: 950
|
Posted: Sat 04 Apr 2009, 04:21 Post subject:
|
|
Download gnome-2.20.3-test02_400.sfs from:
http://puppyisos.org/wow/puppy4sfs/
user: puppy
passw: linux
I need more time to relink all my stuff to puppyisos.org
(Thanks MU)
_________________

|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Tue 07 Apr 2009, 18:26 Post subject:
|
|
Thanks for the Link, wow
------------------------------------------------------------
I tried to install .NET 3.5 SP in Wine again.
This takes really long in virtalbox.
It crashes, if the Wine version is set to XP.
Set to 2003, it works, but after one hour or so, after all the content was extracted by the installer, it stopped with the message, that I had to install .NET 3.0 SP1 first.
As that is a 2.4 MB zip only, I think it will download files.
Due to security and proxy settings, I cannot access the web from Virtualbox, so my experiments in this diretion will stop now.
------------------------------------------------------------
I also looked again at my project idea csharp2vala.
One bad issue might discourage me, from doing it.
In C#, you can overload methods, in Vala not. This could make it impossible, to wrap functions.
Example:
C#:
you can use:
| Code: | | Console.WriteLine(string_value); |
or
| Code: | | Console.WriteLine(int_value); |
This is called "overloading",
The Console class has 2 methods (18 to be exact) of the same name, but they are different, because they take different types of parameters.
If you try that in Vala, you will get an error, that the method was already defined.
Vala just has:
| Code: | | print(formatstring , value); |
So a converter would need a "scanner", that tries to find out, what type the value has.
Then it had to generate code like
| Code: | | print("%s" , string_value); |
or
| Code: | | print("%d" , int_value); |
So it explicitly must define, what type is printed, so this type had to be found out by the scanner.
As this is not only used by the inbuilt classes, but also by the selfwritten ones, it would be pretty difficult.
I must look a bit deeper into this, before I can make a decision.
Maybe I could use "placeholders", so that the converted code has to be corrected by hand afterwards by the programmer.
Then I would not need the scanner.
Mark
_________________ my recommended links
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Thu 09 Apr 2009, 11:31 Post subject:
|
|
I attach a prototype of csharp2vala.
Screenshot see at bottom.
This is far from creating usable code, but my small included example testproject works.
Extract csharp2vala somewhere, then open it in Visual Studio or Monodevelop.
Extract the "testprojects.tgz" in /root/ (or C:\).
In Windows, you must uncomment the path setting in convertprojects.cs at line 28, and comment the Linux path there.
Then run the project.
It creates /root/testprojects/WindowsFormsApplication1/valaout/.
This is a project, that can be loaded in the ValaIDE.
When you compile it, you get 1 error:
"cannot convert from int to string".
So set line 23 in main.vala to:
This error demontrates well the "overload" problem I described in my last message.
Currently, the WindowsForms are not converted to Gtk, just an empty Gladefile is created.
This is also not included yet in the code.
I also am not certain yet, if it will be possible, to import some elements like buttons. The layout certainly will break completely, but that could be "rearranged" by hand in Glade.
The eventhandlers in Form1.vala are converted already though.
It currently just prints "Hello World!".
So you see: still a lot to be done... well after some free easter days
Mark
| Description |
|

Download |
| Filename |
csharp2vala.jpg |
| Filesize |
189.9 KB |
| Downloaded |
375 Time(s) |
| Description |
|

Download |
| Filename |
csharp2vala.tar.gz |
| Filesize |
53.26 KB |
| Downloaded |
362 Time(s) |
| Description |
|

Download |
| Filename |
testprojects.tar.gz |
| Filesize |
66.32 KB |
| Downloaded |
355 Time(s) |
_________________ my recommended links
|
|
Back to top
|
|
 |
MUguest
Joined: 09 Dec 2006 Posts: 73
|
Posted: Wed 15 Apr 2009, 04:59 Post subject:
|
|
Uploaded a bugfix to the download folder of Monodevelpup.
The "Mac" Gtk theme has some entries, that can cause error dialogs.
This effects the filechooser in Valaide.
Monodevelop even crashes because of this.
The bugfix corrects this.
I also fixed the Glade icon, and the gedit starters.
And included a fix, when the desktop options did not save settings.
Mark
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Wed 15 Apr 2009, 11:36 Post subject:
|
|
I added some basic "Winforms to Glade" support to csharp2vala.
It supports buttons and textboxes.
The generated vala project contains the code to load the generated gladefile, and the eventhandlers work.
This has just started, so it will not be usable yet in practice, but the concept works now.
The rest is "just" adding more elements and eventhandlers.
This seems better doable than converting code itself (overloaded classes, polymorphism and other nasty stuff), so for my project in the end of the course, I might focus on the Winforms converter classes.
The screenshot shows the original (C#) on the left, and Vala on the right.
On the right, you see two small application windows.
The left is, what you see right after conversion. The right one was quickly "re-layouted" by hand in Glade afterwards, as layout containers are not converted.
The program now automatically detects, if it runs in Windows or Linux.
Mark
 |
| Description |
extract in /root/ or c:\
|

Download |
| Filename |
testprojects.tar.gz |
| Filesize |
66.32 KB |
| Downloaded |
363 Time(s) |
| Description |
Open and run in Monodevelop or Visual Studio.
|

Download |
| Filename |
csharp2vala05.tar.gz |
| Filesize |
66.67 KB |
| Downloaded |
353 Time(s) |
| Description |
|

Download |
| Filename |
csharp2vala05.jpg |
| Filesize |
241.57 KB |
| Downloaded |
354 Time(s) |
_________________ my recommended links
|
|
Back to top
|
|
 |
MUguest
Joined: 09 Dec 2006 Posts: 73
|
Posted: Thu 16 Apr 2009, 09:44 Post subject:
|
|
New csharp2vala06c:
- cleaned up interface for the converter.
- choice, if original code is added as comments or not.
- inlayed vala code.
You can include converterdirectives like
//PCB start
...
//PCB end
means: Preferred Code Block
If this is found, this code is used.
Like this you also can "ignore code":
//ICB start
...
//ICB end
Code surrounded by this directive, will not be converted.
For one-liners, use:
//PC ... yourcode ...
If this directive is found, yourcode will be used instead of the following line.
The screenshot shows Visual Studio with such directives, and ValaIDE with the resulting Vala program.
Mark
| Description |
|

Download |
| Filename |
csharp2vala06c.jpg |
| Filesize |
241.34 KB |
| Downloaded |
382 Time(s) |
| Description |
|

Download |
| Filename |
testprojects.zip |
| Filesize |
76.11 KB |
| Downloaded |
360 Time(s) |
| Description |
|

Download |
| Filename |
csharp2vala06c.zip |
| Filesize |
72.72 KB |
| Downloaded |
370 Time(s) |
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Fri 17 Apr 2009, 12:04 Post subject:
|
|
today only a minor update.
You now have a fileselection dialog, to select another project than the one in /root/testprojects.
This is not well tested yet, but seems to work in Visual Studio (Win) and Monodevelop (Linux).
I had to rewrite several variables, they now are public in the class Form1, not in Convertproject. There was a design error before, that made it not possible to modify them afterwards.
The location of the last project is not "remembered" yet, although it already creates a configfile in ~/.csharp2vala.
Mark
| Description |
|

Download |
| Filename |
csharp2vala07.tar.gz |
| Filesize |
79.74 KB |
| Downloaded |
344 Time(s) |
_________________ my recommended links
|
|
Back to top
|
|
 |
MUguest
Joined: 09 Dec 2006 Posts: 73
|
Posted: Thu 23 Apr 2009, 09:45 Post subject:
|
|
09, restructured, each glade element now has an own class.
Added some more elements, and a selected projectfolder now is stored.
Mark
| Description |
|
| Filesize |
53.79 KB |
| Viewed |
1537 Time(s) |

|
| Description |
|

Download |
| Filename |
WindowsFormsTest.zip |
| Filesize |
58.47 KB |
| Downloaded |
444 Time(s) |
| Description |
|

Download |
| Filename |
csharp2vala09.zip |
| Filesize |
95.49 KB |
| Downloaded |
456 Time(s) |
|
|
Back to top
|
|
 |
MUguest
Joined: 09 Dec 2006 Posts: 73
|
Posted: Fri 24 Apr 2009, 09:48 Post subject:
|
|
v10
notes:
notebook pages (Win: tabcontrol) are invisible, if they contain nothing.
So you must put elements in the pages using Glade.
Text boxes need a textbuffer so that you can "do" something with the text.
Same with treeviews, they need a listmodel.
I'd like to add such requirements later automatically generated.
Next week I first will add some more elements, and try to layout them (place the tabcontrol contents inside the notebook pages, and maybe use a "fixed" panel to arrange elements).
Mark
| Description |
|

Download |
| Filename |
WindowsFormsTest.zip |
| Filesize |
68.35 KB |
| Downloaded |
439 Time(s) |
| Description |
|

Download |
| Filename |
csharp2vala10b.zip |
| Filesize |
105.5 KB |
| Downloaded |
449 Time(s) |
| Description |
|

Download |
| Filename |
csharp2vala10.jpg |
| Filesize |
89.33 KB |
| Downloaded |
447 Time(s) |
|
|
Back to top
|
|
 |
MUguest
Joined: 09 Dec 2006 Posts: 73
|
Posted: Mon 27 Apr 2009, 09:42 Post subject:
|
|
added more elements:
-menubar (currently empty)
-statusbar
-progressbar
-hbox (flowlayout)
-vbox (flowlayout)
-picturebox
- calendar
-spinbutton
- notebook tabs now use assigned text
Mark
| Description |
|

Download |
| Filename |
csharp2vala11.zip |
| Filesize |
126.18 KB |
| Downloaded |
454 Time(s) |
| Description |
|

Download |
| Filename |
WindowsFormsTest.zip |
| Filesize |
93.41 KB |
| Downloaded |
452 Time(s) |
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Thu 30 Apr 2009, 11:40 Post subject:
|
|
here is version 12.
It has no "visible" advantages, so no need to download it.
I just upload it in order to document, how the project evolves.
I started to add a logic to layout the elements of a winform (but it does not save anything yet!).
The code now gets somewhat complex
The XML representation of each widget is added to an own arraylist.
These arraylists are managed by two other arraylists.
So they can be "resorted" lateron.
Then a "layout()" method begins to sort out (using the xml lists and the original winforms file), what widget is a child of another widget.
In this step, also positioning informations are added.
This part is not finished yet, as visible on the screenshot.
Once the whole "chains" of inheritance are created, the previously generated xml lists can be re-combined on base of this structure.
A special case are elements, that are placed directly on the "rootwindow".
They may be placed absolutely (like on a GtkFixed), or using a table layout like in the Java Swing BorderLayout.
Each tablecell itself can be separated again, so you can put a menubar and a toolbar on top of the window, and they scale to the wiindowsize.
I included a "rootwindow.glade", that simulates this with hboxes/vboxes.
I later must integrate such a layout for the rootwindow.
Another issue:
a SplitContainer has 2 panels in Winforms.
In Gtk, it has none, these must e defined in addition.
So I had to hack in somewhere the generation of these panels.
It is solved a bit ugly, but well...
I will continue on monday.
Mark
 |
| Description |
|

Download |
| Filename |
csharp2vala12upload.tar.gz |
| Filesize |
215.4 KB |
| Downloaded |
341 Time(s) |
| Description |
|
| Filesize |
92.96 KB |
| Viewed |
1289 Time(s) |

|
_________________ my recommended links
|
|
Back to top
|
|
 |
mymas
Joined: 29 Mar 2009 Posts: 3 Location: japan
|
Posted: Fri 01 May 2009, 09:20 Post subject:
|
|
hi, I try to use csharp2vala.
http://live.gnome.org/Vala/GladeSample
I look at this glade sample code. and then add --pkg option
but, receive fellowing error...
C:\testprojects\WindowsFormsTest\valaout>valac main.vala Form1.vala Class1.vala
--pkg gtk+-2.0 --pkg libglade-2.0 --pkg gmodule-2.0
main.vala:14.17-14.36: warning: local variable `form1' declared but never used
var form1 = new Form1 ();
^^^^^^^^^^^^^^^^^^^^
Form1.c: In function `windows_forms_test_form1_construct':
Form1.c:31: error: `GladeXML' undeclared (first use in this function)
Form1.c:31: error: (Each undeclared identifier is reported only once
Form1.c:31: error: for each function it appears in.)
Form1.c:31: error: `xml' undeclared (first use in this function)
error: cc exited with status 1
Compilation failed: 1 error(s), 1 warning(s)
my develop environment:
Windows XP Home sp3
vala 0.61 http://code.google.com/p/valide/downloads/list
download glade source
glade sourve http://ftp.gnome.org/pub/GNOME/sources/glade/2.12/glade-2.12.2.tar.gz
copy to
C:\vala-0.6.1\include\glade
My --pkg option is wrong? I don't know correct --pkg option.
thanks. regard.
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Fri 01 May 2009, 10:45 Post subject:
|
|
| Quote: | download glade source
glade sourve http://ftp.gnome.org/pub/GNOME/sources/glade/2.12/glade-2.12.2.tar.gz
copy to
C:\vala-0.6.1\include\glade |
No, this is not sufficient.
You need the libglade dlls.
http://dotpups.de/puppy4/dotpups/Programming/Vala/Vala-for-Windows/libglade-libxml-comdialog32.zip
Extract it to C:\vala-0.6.1\
It includes libglade compiled for Windows.
I uploaded the vala packages I use in Windows here:
http://dotpups.de/puppy4/dotpups/Programming/Vala/Vala-for-Windows/
The readme.txt explains how I use them.
If it does not work, I can test it again in a fresh setup.
Mark
_________________ my recommended links
|
|
Back to top
|
|
 |
mymas
Joined: 29 Mar 2009 Posts: 3 Location: japan
|
Posted: Sat 02 May 2009, 03:01 Post subject:
|
|
Mu, Thanks very much. It's works.
No problem =)
|
|
Back to top
|
|
 |
|
|
|
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 You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|