Re: [Vala] Calling Vala functions from JavaScript
On 06/07/10 22:45, Frederik wrote: Hi Andrew, you were the person on IRC asking how to call Vala functions from WebKit's JavaScript, right? I have attached some files (demo.vala, jscore.vapi and demo.html) that demonstrate how to achieve this. You probably want to port the .vala file to Genie. If you put the jscore.vapi file in your working directory you can compile with $ valac demo.vala --pkg webkit-1.0 --pkg jscore --vapidir . (You can ignore the compiler warnings, I have not yet found a way to suppress them) Best regards, Frederik You are amazing!! Thankyou so much, this will (hopefully) allow me to continue my project. Thankyou! -- Andrew ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Calling Vala functions from JavaScript
On 07/07/10 08:01, CaStarCo wrote: I' curious ¿what's your project? :) Kind regards 2010/7/7 Andrew rugby...@gmail.com mailto:rugby...@gmail.com On 06/07/10 22:45, Frederik wrote: Hi Andrew, you were the person on IRC asking how to call Vala functions from WebKit's JavaScript, right? I have attached some files (demo.vala, jscore.vapi and demo.html) that demonstrate how to achieve this. You probably want to port the .vala file to Genie. If you put the jscore.vapi file in your working directory you can compile with $ valac demo.vala --pkg webkit-1.0 --pkg jscore --vapidir . (You can ignore the compiler warnings, I have not yet found a way to suppress them) Best regards, Frederik You are amazing!! Thankyou so much, this will (hopefully) allow me to continue my project. Thankyou! -- Andrew ___ vala-list mailing list vala-list@gnome.org mailto:vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list -- - Per la llibertat del coneixement - - Per la llibertat de la ment... - My project is http://whyareyoureadingthisurl.wordpress.com/2010/06/14/introducing-the-wasiliana-mail-client/ The other guy who was asking about graphics toolkits also has a project but I don't know what that is -- Andrew ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Global int variable.. Problems?
Probably 'index' is already defined as a function or variable in some header. In fact if you put all the code in a namespace, it compiles with no errors. Regards, Davide int index; public int main(string[] args) { stdout.printf(Ran program: %i,index); return 0; } I get the following errors: default/main.c:13: error: ‘index’ redeclared as different kind of symbol default/main.c:14: error: ‘index’ redeclared as different kind of symbol So I checked the C file, which contains the following: extern gint index; gint index = 0; This is what's throwing the C compiler off... Anybody have a suggestion? Thanks -Harry signature.asc Description: This is a digitally signed message part. ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Global int variable.. Problems?
Probably 'index' is already defined as a function or variable in some header. In fact if you put all the code in a namespace, it compiles with no errors. Wauw, that simple.. Nice one. :-) Happy coding for me now, -Harry ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
[Vala] dsync - simple rsync frontend
i have written a very stupid frontend for rsync. it's just a few hours work.. This is something I always wanted to have a program like this to sync a directory between different boxes. I'm actually using it in my n900 and laptop syncing info to an http directory on a server. If you wanna give a try: http://lolcathost.org/b/dsync.tar.gz And the n900 binary: http://lolcathost.org/b/dsync (wget + chmod+x) It's written in Genie, and the code could be better, but it's just a quick hack :P I have a list of ideas to do to support different profiles, sincronize configurations, select directories using FileChooser and others.. but my main idea is to keep it simple with as less buttons and configuration options as possible. PD: How lambdas works in Genie? i didnt managed to use them because of syntax errors. PD2: I'm gonna add this link to the Vala projects section --pancake ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
[Vala] array declaration
I have noticed that if you declare an array in a wrong way you get errors from the C compiler instead of handling it at vala level. should this syntax be supported? or we should just throw an error? Here's the test case: $ cat a.vala #!/usr/bin/vala void main () { // uint8[] foo = new uint8[16]; // OK uint8 foo[] = new uint8[16]; // FAIL print(%d\n, foo[0]); } $ vala a.vala /tmp/a.vala.LDAGFV.c: In function '_vala_main': /tmp/a.vala.LDAGFV.c:16:9: error: array size missing in '_tmp0_' /tmp/a.vala.LDAGFV.c:19:9: error: array size missing in 'foo' /tmp/a.vala.LDAGFV.c:20:16: error: incompatible types when assigning to type 'guint8[1]' from type 'guint8 *' /tmp/a.vala.LDAGFV.c:20:6: error: incompatible types when assigning to type 'guint8[1]' from type 'guint8 *' /tmp/a.vala.LDAGFV.c:22:6: error: incompatible types when assigning to type 'guint8[1]' from type 'void *' error: cc exited with status 256 Thanks --pancake ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] array declaration
Hey, Coming from a C++ background I first tried typeHere nameHere[]; too. I noticed that newer languages seemed to have type[] name; configuration (Java, C# etc). I'm not part of the Vala team though, so I dont know the official status! -Harry On Wed, Jul 7, 2010 at 5:15 PM, pancake panc...@youterm.com wrote: I have noticed that if you declare an array in a wrong way you get errors from the C compiler instead of handling it at vala level. should this syntax be supported? or we should just throw an error? Here's the test case: $ cat a.vala #!/usr/bin/vala void main () { // uint8[] foo = new uint8[16]; // OK uint8 foo[] = new uint8[16]; // FAIL print(%d\n, foo[0]); } $ vala a.vala /tmp/a.vala.LDAGFV.c: In function '_vala_main': /tmp/a.vala.LDAGFV.c:16:9: error: array size missing in '_tmp0_' /tmp/a.vala.LDAGFV.c:19:9: error: array size missing in 'foo' /tmp/a.vala.LDAGFV.c:20:16: error: incompatible types when assigning to type 'guint8[1]' from type 'guint8 *' /tmp/a.vala.LDAGFV.c:20:6: error: incompatible types when assigning to type 'guint8[1]' from type 'guint8 *' /tmp/a.vala.LDAGFV.c:22:6: error: incompatible types when assigning to type 'guint8[1]' from type 'void *' error: cc exited with status 256 Thanks --pancake ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] array declaration
Am 07.07.2010 18:33, Harry Van Haaren wrote: Hey, Coming from a C++ background I first tried typeHere nameHere[]; too. I noticed that newer languages seemed to have type[] name; configuration (Java, C# etc). Vala supports two types of arrays: 1) dynamically heap-allocated arrays: Vala, Java, C#: int[] a = new int[5]; C++: int* a = new int[5]; C: int* a = malloc (5 * sizeof (int)); 2) inline/stack-allocated fixed-size arrays: Vala: int a[5]; C++: int a[5]; C: int a[5]; Java: not supported C#: unsafe { int* a = stackalloc int[5]; } @pancake: 'new' combined with the latter type of array does not make sense, since the 'new' keyword stands for dynamic alloation on the heap. The Vala compiler should refuse to compile something like 'int a[] = new int[5]'. So it's obviously a bug. Best regards Frederik ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
[Vala] Delegate on struct
Hello, I don't understand why this code produce a warning (vala 0.9.2) : public delegate void myDelegateFunc(); struct MyStruct { public myDelegateFunc my_struct_func; } void main(){ string a = test; var t = MyStruct(); t.my_struct_func = () = { print(a); }; t.my_struct_func(); } .../test.vala.c: In function ‘_vala_main’: .../test.vala.c:113: warning: assignment from incompatible pointer type Thanks. ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Delegate on struct
Hey Nicolas, Any chance you'd compile with valac --save-temps your files etc here? And then maybe post line 113 from your test.c file so we can see what's really going on there? Cheers, -Harry On Thu, Jul 8, 2010 at 12:14 AM, Nicolas HENRY ice...@gmail.com wrote: Hello, I don't understand why this code produce a warning (vala 0.9.2) : public delegate void myDelegateFunc(); struct MyStruct { public myDelegateFunc my_struct_func; } void main(){ string a = test; var t = MyStruct(); t.my_struct_func = () = { print(a); }; t.my_struct_func(); } .../test.vala.c: In function ‘_vala_main’: .../test.vala.c:113: warning: assignment from incompatible pointer type Thanks. ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Delegate on struct
Line 113 : t.my_struct_func = (_tmp0_ = __lambda0__my_delegate_func, ((t.my_struct_func_target_destroy_notify == NULL) ? NULL : (t.my_struct_func_target_destroy_notify (t.my_struct_func_target), NULL), t.my_struct_func = NULL, t.my_struct_func_target = NULL, t.my_struct_func_target_destroy_notify = NULL), t.my_struct_func_target = block1_data_ref (_data1_), t.my_struct_func_target_destroy_notify = block1_data_unref, _tmp0_); test.c : /* test.c generated by valac, the Vala compiler * generated from test.vala, do not modify */ #include glib.h #include glib-object.h #include stdlib.h #include string.h #define TYPE_MY_STRUCT (my_struct_get_type ()) typedef struct _MyStruct MyStruct; #define _g_free0(var) (var = (g_free (var), NULL)) typedef struct _Block1Data Block1Data; typedef void (*myDelegateFunc) (void* user_data); struct _MyStruct { myDelegateFunc my_struct_func; gpointer my_struct_func_target; GDestroyNotify my_struct_func_target_destroy_notify; }; struct _Block1Data { int _ref_count_; char* a; }; GType my_struct_get_type (void); MyStruct* my_struct_dup (const MyStruct* self); void my_struct_free (MyStruct* self); void my_struct_copy (const MyStruct* self, MyStruct* dest); void my_struct_destroy (MyStruct* self); static void _lambda0_ (Block1Data* _data1_); static void __lambda0__my_delegate_func (gpointer self); static Block1Data* block1_data_ref (Block1Data* _data1_); static void block1_data_unref (Block1Data* _data1_); void _vala_main (void); void my_struct_copy (const MyStruct* self, MyStruct* dest) { dest-my_struct_func = self-my_struct_func; } void my_struct_destroy (MyStruct* self) { ((*self).my_struct_func_target_destroy_notify == NULL) ? NULL : ((*self).my_struct_func_target_destroy_notify ((*self).my_struct_func_target), NULL); self-my_struct_func = NULL; (*self).my_struct_func_target = NULL; (*self).my_struct_func_target_destroy_notify = NULL; } MyStruct* my_struct_dup (const MyStruct* self) { MyStruct* dup; dup = g_new0 (MyStruct, 1); my_struct_copy (self, dup); return dup; } void my_struct_free (MyStruct* self) { my_struct_destroy (self); g_free (self); } GType my_struct_get_type (void) { static volatile gsize my_struct_type_id__volatile = 0; if (g_once_init_enter (my_struct_type_id__volatile)) { GType my_struct_type_id; my_struct_type_id = g_boxed_type_register_static (MyStruct, (GBoxedCopyFunc) my_struct_dup, (GBoxedFreeFunc) my_struct_free); g_once_init_leave (my_struct_type_id__volatile, my_struct_type_id); } return my_struct_type_id__volatile; } static void _lambda0_ (Block1Data* _data1_) { g_print (%s, _data1_-a); } static void __lambda0__my_delegate_func (gpointer self) { _lambda0_ (self); } static Block1Data* block1_data_ref (Block1Data* _data1_) { ++_data1_-_ref_count_; return _data1_; } static void block1_data_unref (Block1Data* _data1_) { if ((--_data1_-_ref_count_) == 0) { _g_free0 (_data1_-a); g_slice_free (Block1Data, _data1_); } } void _vala_main (void) { Block1Data* _data1_; MyStruct t = {0}; myDelegateFunc _tmp0_; _data1_ = g_slice_new0 (Block1Data); _data1_-_ref_count_ = 1; _data1_-a = g_strdup (test); memset (t, 0, sizeof (MyStruct)); t.my_struct_func = (_tmp0_ = __lambda0__my_delegate_func, ((t.my_struct_func_target_destroy_notify == NULL) ? NULL : (t.my_struct_func_target_destroy_notify (t.my_struct_func_target), NULL), t.my_struct_func = NULL, t.my_struct_func_target = NULL, t.my_struct_func_target_destroy_notify = NULL), t.my_struct_func_target = block1_data_ref (_data1_), t.my_struct_func_target_destroy_notify = block1_data_unref, _tmp0_); t.my_struct_func (t.my_struct_func_target); my_struct_destroy (t); block1_data_unref (_data1_); } int main (int argc, char ** argv) { g_type_init (); _vala_main (); return 0; } Le jeudi 08 juillet 2010 à 00:29 +0100, Harry Van Haaren a écrit : Hey Nicolas, Any chance you'd compile with valac --save-temps your files etc here? And then maybe post line 113 from your test.c file so we can see what's really going on there? Cheers, -Harry On Thu, Jul 8, 2010 at 12:14 AM, Nicolas HENRY ice...@gmail.com wrote: Hello, I don't understand why this code produce a warning (vala 0.9.2) : public delegate void myDelegateFunc(); struct MyStruct { public myDelegateFunc my_struct_func; } void main(){ string a = test; var t = MyStruct(); t.my_struct_func = () = { print(a); };
[Vala] [PATCH] GLib vapi with non-null
Hey! I was having some trouble compiling with --enable-experimental-non-null and the glib vapi. Attached is a VERY small patch that fixes the problems I've run into. Sam diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index 596570a..ab680a9 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -1129,7 +1129,7 @@ public class string { if (str == null) { str_size = 0; } else { - str_size = str.size (); + str_size = ((string)str).size (); } string* result = GLib.malloc0 (this.size () - ((char*) end_string - (char*) start_string) + str_size + 1); @@ -2693,12 +2693,12 @@ namespace GLib { if (c == '\n') { break; } -ret.append_c ((char) c); +((StringBuilder)ret).append_c ((char) c); } if (ret == null) { return null; } else { -return ret.str; +return ((StringBuilder)ret).str; } } } ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
[Vala] Assertion Fails in valasemanticanalyzer.c
Hello again! When I compile my project with git head I get the following assertion: ERROR:valasemanticanalyzer.c:2939:vala_semantic_analyzer_get_actual_type: assertion failed: (instance_type != NULL) I tracked it with git bisect to commit ac780b92d6b561f422e7935a8a9735464dc1540a Author: Jürg Billeter j...@bitron.ch Date: Sat Jul 3 09:28:33 2010 +0200 Prepare support for generic delegates I have no idea why, I haven't taken a look at the changes it introduces. If I get some time tomorrow, I'll look into making a test case for it. Thanks, Sam ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list