Re: [Vala] Rv: C to Vala
If I understand correctly, that approach requires an intermediate bytecode either from Java or from .NET to finally create sourcecode. Alas, in the OP's case the best we can get would be native machine code (being different for x64, i386, arm, etc) so the parser wouldn't be able to stick to one static 'syntax', even if it would support Vala as an output. I'm guessing here, but: If it's possible to automatically generate vapi's out of g-object-based libraries, then a similar tool might be able to create vala-code out of g-object-based sourcecode. But I'm really just guessing here, not knowing anything about the effort behind it. At least the need for such a tool (that turns C-code into Vala just before C-code is generated again) proves that vala is a favourable language :) Interesting though that XMLVM can create Objective-C-code. Gilzad Original-Nachricht Datum: Thu, 20 Sep 2012 12:09:39 -0700 Von: Eric Gregory e...@yorba.org An: Mario Daniel Ruiz Saavedra desideran...@rocketmail.com CC: Vala List vala-list@gnome.org Betreff: Re: [Vala] Rv: C to Vala On Thu, Sep 20, 2012 at 12:01 PM, Mario Daniel Ruiz Saavedra desideran...@rocketmail.com wrote: Unlikely. You are confusing translate with transform. Please argue properly. He's right though -- the relationship between C and Vala is not 1:1 unless the C code was generated by valac. Converting arbitrary C code into Vala is possible, but unwieldy. A professor from my college days did a project that converts between various languages. It's quite complex, but amazingly all the conversion is done in XSLT. I'd recommend checking it out to see what kind of territory you're wading into here: http://xmlvm.org - Eric ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Rv: C to Vala
Doing some research, i found something relevant: http://razum.si/automagical/ It's not the same, but uses the same principle i've thought, declaring some rules about when finding a class declaration, translate; etc. Shouldn't be that hard, for a good declarative programmer (i'm not one, not even a coder). No bytecode needed, for i wasn't talking about decompiling. The idea is, given a C code with total use of GLib, can that be translated to Vala code? I wonder if there is some real problem holding back that possibility. De: Gilzad Hamuni gil...@gmx.net Para: vala-list@gnome.org Enviado: Viernes, 21 de septiembre, 2012 10:33:38 Asunto: Re: [Vala] Rv: C to Vala If I understand correctly, that approach requires an intermediate bytecode either from Java or from .NET to finally create sourcecode. Alas, in the OP's case the best we can get would be native machine code (being different for x64, i386, arm, etc) so the parser wouldn't be able to stick to one static 'syntax', even if it would support Vala as an output. I'm guessing here, but: If it's possible to automatically generate vapi's out of g-object-based libraries, then a similar tool might be able to create vala-code out of g-object-based sourcecode. But I'm really just guessing here, not knowing anything about the effort behind it. At least the need for such a tool (that turns C-code into Vala just before C-code is generated again) proves that vala is a favourable language :) Interesting though that XMLVM can create Objective-C-code. Gilzad Original-Nachricht Datum: Thu, 20 Sep 2012 12:09:39 -0700 Von: Eric Gregory e...@yorba.org An: Mario Daniel Ruiz Saavedra desideran...@rocketmail.com CC: Vala List vala-list@gnome.org Betreff: Re: [Vala] Rv: C to Vala On Thu, Sep 20, 2012 at 12:01 PM, Mario Daniel Ruiz Saavedra desideran...@rocketmail.com wrote: Unlikely. You are confusing translate with transform. Please argue properly. He's right though -- the relationship between C and Vala is not 1:1 unless the C code was generated by valac. Converting arbitrary C code into Vala is possible, but unwieldy. A professor from my college days did a project that converts between various languages. It's quite complex, but amazingly all the conversion is done in XSLT. I'd recommend checking it out to see what kind of territory you're wading into here: http://xmlvm.org - Eric ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] deleting folders
Hello everyone! GLib.File provides a 'delete' method to delete files and empty folders. I need to delete a non empty folder so I thought of a recursive method like this: bool remove_directory (string path) { bool flag = false; var directory = File.new_for_path (path); var enumerator = directory.enumerate_children ( FileAttribute.STANDARD_NAME, 0 ); FileInfo file_info; while ((file_info = enumerator.next_file ()) != null) { if ((file_info.get_file_type ()) == FileType.DIRECTORY) { /* What should I do here? How can I get a File from a FileInfo so I can use the 'delete' method on it? */ } } return flag; } Best regards, D.H. Bahr 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] deleting folders
You obviously can't, but you can do the following: string file_name = file_info.get_name (); var file = directory.get_child (file_name); And after that, you can call file.delete(). Regards, Victor. On vie, sep 21, 2012 at 1:07 , D.H. Bahr db...@uci.cu wrote: Hello everyone! GLib.File provides a 'delete' method to delete files and empty folders. I need to delete a non empty folder so I thought of a recursive method like this: bool remove_directory (string path) { bool flag = false; var directory = File.new_for_path (path); var enumerator = directory.enumerate_children ( FileAttribute.STANDARD_NAME, 0 ); FileInfo file_info; while ((file_info = enumerator.next_file ()) != null) { if ((file_info.get_file_type ()) == FileType.DIRECTORY) { /* What should I do here? How can I get a File from a FileInfo so I can use the 'delete' method on it? */ } } return flag; } Best regards, D.H. Bahr 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] deleting folders
My last message was incomplete. I meant that you can't get a GLib.File directly from a GLib.FileInfo object, but you can do it using the way I suggested. Hope this helps. On vie, sep 21, 2012 at 1:07 , D.H. Bahr db...@uci.cu wrote: Hello everyone! GLib.File provides a 'delete' method to delete files and empty folders. I need to delete a non empty folder so I thought of a recursive method like this: bool remove_directory (string path) { bool flag = false; var directory = File.new_for_path (path); var enumerator = directory.enumerate_children ( FileAttribute.STANDARD_NAME, 0 ); FileInfo file_info; while ((file_info = enumerator.next_file ()) != null) { if ((file_info.get_file_type ()) == FileType.DIRECTORY) { /* What should I do here? How can I get a File from a FileInfo so I can use the 'delete' method on it? */ } } return flag; } Best regards, D.H. Bahr 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] deleting folders
On 09/21/2012 09:07 PM, D.H. Bahr wrote: Hello everyone! GLib.File provides a 'delete' method to delete files and empty folders. I need to delete a non empty folder so I thought of a recursive method like this: bool remove_directory (string path) { bool flag = false; var directory = File.new_for_path (path); var enumerator = directory.enumerate_children ( FileAttribute.STANDARD_NAME, 0 ); FileInfo file_info; while ((file_info = enumerator.next_file ()) != null) { if ((file_info.get_file_type ()) == FileType.DIRECTORY) { /* What should I do here? How can I get a File from a FileInfo so I can use the 'delete' method on it? */ } } return flag; } Hi, Victor has already given you the answer - you have to use the parent directory's get_child method. If you want, you can consult my Emperor file manager's deletion code at https://github.com/tjol/emperor/blob/master/src/modules/basic_actions/basic_actions.vala#L256 As this is a GUI file manager, the code is more complex - it uses asynchronous methods, asks the user for confirmation, and does error handling. The core loop, equivalent to what you've been writing, is here: https://github.com/tjol/emperor/blob/master/src/modules/basic_actions/basic_actions.vala#L348 Code license: GPLv3+ -- Thomas Best regards, D.H. Bahr 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list