Re: [Vala] Newbie need help

2018-10-23 Thread Tal Hadad via vala-list
valac - The standard Vala compiler
Vala - A programming language. (Description, Specification,...)

It's as same as this relationship:
GCC - A free compiler for C
C - A programming language. (Description, Specification,...)

מאת: wolfgang.ma...@kabelmail.de
נשלח: יום שלישי, 23 באוקטובר, 10:51
נושא: [Vala] Newbie need help
אל: vala-list@gnome.org


Hi all, what is the difference between valac and vala? (Compiler / Interpreter) 
valac -> compiler(ok) vala -> interpreter  what/how/usage 
___ 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] [ANNOUNCE] Vala 0.25.1 - Compiler for the GObject type system

2014-07-27 Thread Tal Hadad
>> * Support explicit interface method implementation.I asked about this 
>> feature when Vala version was about 0.10.
I'm glad Vala team haven't forgotten this feature!

Tal

> Date: Wed, 23 Jul 2014 16:57:33 +0200
> From: lethalma...@gmail.com
> To: vala-list@gnome.org
> Subject: Re: [Vala] [ANNOUNCE] Vala 0.25.1 - Compiler for the GObject type 
> system
> 
> On 23/07/2014 12:03, Jürg Billeter wrote:
> > Changes since 0.24.0
> >  * Support explicit interface method implementation.
> >  * Support (unowned type)[] syntax.
> >  * Support non-literal length in fixed-size arrays.
> >  * Mark regular expression literals as stable.
> >  * GIR parser updates.
> >  * Add webkit2gtk-3.0 bindings.
> >  * Add gstreamer-allocators-1.0 and gstreamer-riff-1.0 bindings.
> >  * Bug fixes and binding updates.
> About the new features I suggest  reading
> http://valajournal.blogspot.it/2014/07/vala-0251-released.html .
> We explain how to use the new explicit interface method implementation
> and give some good advice.
> 
> Best regards,
> ___
> 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] New tiny helper for unit testing

2014-06-25 Thread Tal Hadad
Looks very good!
Keep going

> Date: Fri, 13 Jun 2014 15:58:02 +0900
> From: yusuke.ishida@gmail.com
> To: vala-list@gnome.org
> Subject: [Vala] New tiny helper for unit testing
> 
> Hi all,
> I've create a new tiny helper 'vtth' for unit testing.
> Please try it.
> 
> https://github.com/y-ishida/vtth
> 
> Features of vtth are as follows:
>   - Only requires a file 'vtth.vala'.
>   - Colored OK or NG are output at each assertion.
>   - You can select actions at the assertion failed, wheter to abort or
> continue the program.
>   - The simple (one line) report which contained counts of OK, NG and
> total of these is output.
>   - Methods and parameters related the test case can be grouped into a class.
> 
> Regards,
> Y.Ishida
> ___
> 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] array memory leak?

2014-03-07 Thread Tal Hadad
I know it's little desperate but could you:
1. Post the generated C code?
2. Try to replace string array with int array.

Tal

> Date: Fri, 7 Mar 2014 11:38:50 +0100
> From: ul...@gmx.at
> To: vala-list@gnome.org
> Subject: Re: [Vala] array memory leak?
> 
> > Are you sure it's not because optimizations?
> 
> No I'm not sure :-)
> I simply don't understand the behaviour differences between test 1 and
> test 2. But I'm curious to understand what's the reason for this.
> 
> > Try to put Dummy1 method in external compile unit(i.e. different .vala and 
> > .c file) and you should
> > get better results.
> 
> Tried, no changes :-(
> 
> Maybe I should simply trust Vala/GLib and consider my test code as an
> artificial provocation of an error that do not exist in practice.
> 
> 
> -- 
> Bernhard
> ___
> 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] array memory leak?

2014-03-07 Thread Tal Hadad
Are you sure it's not because optimizations?

Try to put Dummy1 method in external compile unit(i.e. different .vala and .c 
file) and you should
get better results.

Tal

> Date: Thu, 6 Mar 2014 11:00:05 +0100
> From: ul...@gmx.at
> To: vala-list@gnome.org
> Subject: Re: [Vala] array memory leak?
> 
> Hi Juerg,
> 
> > According to valgrind 3.9.0, there are no leaks with this test code on
> > my system (up-to-date Linux on x86-64). I've tested with valac 0.20.1
> > and valac 0.22.1.
> 
> Confirmed, valgrind shows no memory leak. I'm puzzled.
> 
> void Dummy1(int len)
> {
>   const int LOOPS=100;
>   string[] dummy = new string[LOOPS];
>   for(var xx=0; xx dummy[xx]=string.nfill(len, 'x');
> }
> 
> //test 1: memory used by Dummy1 still used after return from Dummy1
> int main(string[] args)
> {
>   Dummy1(100);
>   for(;;);
>   return 0;
> }
> 
> //test 2: memory used by Dummy1 FREED after return from Dummy1. WTF?
> int main(string[] args)
> {
>   Dummy1(100);
>   MainLoop loop = new MainLoop ();
>   loop.run();
>   return 0;
> }
> 
> WTF? Is there a hidden garbage collector within the main loop or what?
> 
> Im TOTALLY puzzled now. Seems I have much to learn left, someone
> illuminate me PLEASE ;-)
> 
> -- 
> Bernhard
> ___
> 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] Change in 0.23.1 for array ownership and .length parameter

2014-01-09 Thread Tal Hadad
> That would be a memory leak.
No it wouldn't:
If the "if" statement is false, then it should delete it in the end of the 
block.

You might afraid the complicity of valac calculation.
That could be resolved - using two C variables - one for owned and one for 
unowned.
The owned always deleted at the end of the block, the trick is that this C 
variable is
set to null when transferring ownership.

If an owned "bar" was defined outside the block, I already said you're right 
and it
should be null in when outside the block(e.g. class field), since there's no 
way to
automate this safely.

I know it may add a minor complicity, but it just seems rational to use an 
object with
"unowned" access after transferring it to something else, since passing 
ownership
privilege doesn't means forgetting a reference.

I suppose that most Vala programmer solve this(including me) problem by saving
this variable in different unowned variable, but this is not 
intuitive(especially for a
new language) and may raise many bugs.

Tal

Date: Thu, 9 Jan 2014 21:04:16 +0100
Subject: Re: [Vala] Change in 0.23.1 for array ownership and .length parameter
From: lethalma...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

That would be a memory leak.

On Thu, Jan 9, 2014 at 7:01 PM, Tal Hadad  wrote:

> What about:

>

> if (foo) {

>bar = (owned) ar;

> }

> // what now

>

> This behavior is confusing.

It would be unowned, even if in "if" statement, just like I suggest.



Tal



> Date: Tue, 7 Jan 2014 09:24:40 +0100

> From: lethalma...@gmail.com

> To: vala-list@gnome.org

> Subject: Re: [Vala] Change in 0.23.1 for array ownership and .length  
> parameter

>

> On 07/01/2014 06:46, Tal Hadad wrote:

> > This case trigger me a question I wanted to ask before.

> > Why transforming ownership is nulling the original variable?

> >

> > Instead of nulling, maybe just change variable to behave as unowned.

> >

> > You might say that there is a problem in my solution, like this code:

> >

> > uint8[] ar = new uint8[10];

> > if (some_method() != NULL)

> >  another_method((owned)ar);

> > ...

> >

> > Since after the "if" case, valac can't determinate if ownership was 
> > given(at compile time).

> >

> > Despite of this, nulling "ar" variable is even worse in my opinion and it's 
> > error prone.

> >

> > The user might use "ar" varible later and it will crush he's application.

> > If he was lucky enough, he would realize that ar is null.

> > It's not easy to find that this line causing it.

> >

> > I suggest solution for the last problem from valac side - treat ar as 
> > unowned after the

> > (owned) operator, even if this operator was in "if" block!

> >

> > That way, "ar" won't be null, and the user could use it later only as 
> > unowned.

> >

> > And for class/struct fields - I do accept that they must be nulled when 
> > transferring ownership.

>

> What about:

>

> if (foo) {

>bar = (owned) ar;

> }

> // what now

>

> This behavior is confusing.

> ___

> 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



-- 
www.debian.org - The Universal Operating System
  
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Change in 0.23.1 for array ownership and .length parameter

2014-01-09 Thread Tal Hadad
> What about:
> 
> if (foo) {
>bar = (owned) ar;
> }
> // what now
> 
> This behavior is confusing.
It would be unowned, even if in "if" statement, just like I suggest.

Tal

> Date: Tue, 7 Jan 2014 09:24:40 +0100
> From: lethalma...@gmail.com
> To: vala-list@gnome.org
> Subject: Re: [Vala] Change in 0.23.1 for array ownership and .length  
> parameter
> 
> On 07/01/2014 06:46, Tal Hadad wrote:
> > This case trigger me a question I wanted to ask before.
> > Why transforming ownership is nulling the original variable?
> >
> > Instead of nulling, maybe just change variable to behave as unowned.
> >
> > You might say that there is a problem in my solution, like this code:
> >
> > uint8[] ar = new uint8[10];
> > if (some_method() != NULL)
> >  another_method((owned)ar);
> > ...
> >
> > Since after the "if" case, valac can't determinate if ownership was 
> > given(at compile time).
> >
> > Despite of this, nulling "ar" variable is even worse in my opinion and it's 
> > error prone.
> >
> > The user might use "ar" varible later and it will crush he's application.
> > If he was lucky enough, he would realize that ar is null.
> > It's not easy to find that this line causing it.
> >
> > I suggest solution for the last problem from valac side - treat ar as 
> > unowned after the
> > (owned) operator, even if this operator was in "if" block!
> >
> > That way, "ar" won't be null, and the user could use it later only as 
> > unowned.
> >
> > And for class/struct fields - I do accept that they must be nulled when 
> > transferring ownership.
> 
> What about:
> 
> if (foo) {
>bar = (owned) ar;
> }
> // what now
> 
> This behavior is confusing.
> ___
> 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] Change in 0.23.1 for array ownership and .length parameter

2014-01-06 Thread Tal Hadad
This case trigger me a question I wanted to ask before.
Why transforming ownership is nulling the original variable?

Instead of nulling, maybe just change variable to behave as unowned.

You might say that there is a problem in my solution, like this code:

uint8[] ar = new uint8[10];
if (some_method() != NULL)
another_method((owned)ar);
...

Since after the "if" case, valac can't determinate if ownership was given(at 
compile time).

Despite of this, nulling "ar" variable is even worse in my opinion and it's 
error prone.

The user might use "ar" varible later and it will crush he's application.
If he was lucky enough, he would realize that ar is null.
It's not easy to find that this line causing it.

I suggest solution for the last problem from valac side - treat ar as unowned 
after the
(owned) operator, even if this operator was in "if" block!

That way, "ar" won't be null, and the user could use it later only as unowned.

And for class/struct fields - I do accept that they must be nulled when 
transferring ownership.

Waiting for your reply,
Tal

> Date: Tue, 7 Jan 2014 02:20:49 -0008
> From: j...@yorba.org
> To: vala-list@gnome.org
> Subject: [Vala] Change in 0.23.1 for array ownership and .length parameter
> 
> Just wanted to give everyone a head's-up about a change that appeared 
> in Vala 0.23.  Previously you could do this in Vala:
> 
> uint8[] ar = new uint8[10];
> // ... fill ar with interesting bytes ...
> process((owned) ar, ar.length);
> 
> ... where process() takes an array and a length field (sometimes 
> because an array might have a "filled" count versus it's allocated 
> length).  Before 0.23 the above worked, but now ar.length will be 
> zeroed out before it's passed to process():
> 
> https://bugzilla.gnome.org/show_bug.cgi?id=721001
> 
> I found a few instances of this pattern in our code and thought others 
> might want to be alerted about it as well.
> 
> -- Jim
> ___
> 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] "vala friendly" atomic pointer

2013-12-21 Thread Tal Hadad
There is another alternative I used for my project.

I had needed to use a REAL GObject singleton in my code, so
I write some code in C that do this perfectly.
Now this singleton could be "non-leaked", which means that
when there's no refs to it, it destroy itself.

The tricky thing was to do this thread-safety, i.e. beware from
situation when user request a new instance exactly while other
thread release the last reference to the previous instance.

I have come up with solution using the method:
g_object_add_toggle_ref
which is thread safe.

When the callback is invoked, I use my "locks" to transmit that
the object is not longer vialed to be used anymore, and need to
create a new one.

Here is singleton.c:
http://sourceforge.net/p/maxdream/maxdream/ci/efa2d719f2066970d0336969e0b8469488e1feb4/tree/src/maxdream-kernel/utils/singleton.c

I sent you this alternative since I think you might afraid of
thread local list performance :-)

Not the simplest solution, but works well.

Tal


> From: norjaidi.t...@ubd.edu.bn
> To: vala-list@gnome.org
> Date: Sat, 21 Dec 2013 14:45:54 +0800
> Subject: Re: [Vala] "vala friendly" atomic pointer
> 
> Thank you for the clarification and the link
> on HazardPointer.
> 
> 
> Nice day
> Nor Jaidi Tuah
> 
> 
> 
> 
> 
> 
> PRIVILEGED/CONFIDENTIAL information may be contained in this message. If you 
> are neither the addressee (intended recipient) nor an authorised recipient of 
> the addressee, and have received this message in error, please destroy this 
> message (including attachments) and notify the sender immediately. STRICT 
> PROHIBITION: This message, whether in part or in whole, should not be 
> reviewed, retained, copied, reused, disclosed, distributed or used for any 
> purpose whatsoever. Such unauthorised use may be unlawful and may contain 
> material protected by the Official Secrets Act (Cap 153) of the Laws of 
> Brunei Darussalam. DISCLAIMER: We/This Department/The Government of Brunei 
> Darussalam, accept[s] no responsibility for loss or damage arising from the 
> use of this message in any manner whatsoever. Our messages are checked for 
> viruses but we do not accept liability for any viruses which may be 
> transmitted in or with this message.
> ___
> 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] "vala friendly" atomic pointer

2013-12-19 Thread Tal Hadad
http://www.valadoc.org/#!api=gobject-2.0/GLib.WeakRef

This is a simple solution thanks to the good design of GObject.

Tal

> From: norjaidi.t...@ubd.edu.bn
> To: vala-list@gnome.org
> Date: Thu, 19 Dec 2013 08:59:44 +0800
> Subject: [Vala] "vala friendly" atomic pointer
> 
> Dear all,
> 
> I want to implement something like these:
>*  x = AtomicPointer.@get (ref atomicRef)   // reader
> 
>*  AtomicPointer.@set (ref atomicRef, newref)  // writer
> 
>*  return AtomicPointer.@get (ref atomicRef)  // reader
> 
> but have the benefit of vala ref counting.
> 
> The best I can think of is:
> 
>*  lock (atomicRef) { x = atomicRef; }
> 
>*  lock (atomicRef) { atomicRef = newref; }
> 
>*  lock (atomicRef) { return atomicRef; }
> 
> But lock is too course.
> e.g., lock (atomicRef) {x = atomicRef;} will also lock
> out other readers, whereas AtomicPointer.get won't.
> 
> I realise that the exclusive region is small.
> But if you have a lot of readers, the effect
> may be significant.
> 
> Any suggestions?
> 
> 
> Nice day
> Nor Jaidi Tuah
> 
> 
> 
> 
> 
> 
> PRIVILEGED/CONFIDENTIAL information may be contained in this message. If you 
> are neither the addressee (intended recipient) nor an authorised recipient of 
> the addressee, and have received this message in error, please destroy this 
> message (including attachments) and notify the sender immediately. STRICT 
> PROHIBITION: This message, whether in part or in whole, should not be 
> reviewed, retained, copied, reused, disclosed, distributed or used for any 
> purpose whatsoever. Such unauthorised use may be unlawful and may contain 
> material protected by the Official Secrets Act (Cap 153) of the Laws of 
> Brunei Darussalam. DISCLAIMER: We/This Department/The Government of Brunei 
> Darussalam, accept[s] no responsibility for loss or damage arising from the 
> use of this message in any manner whatsoever. Our messages are checked for 
> viruses but we do not accept liability for any viruses which may be 
> transmitted in or with this message.
> ___
> 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] getting the valadoc.org documentation on a local server

2013-12-16 Thread Tal Hadad
You need the -p switch. From wget --help:

-p,  --page-requisitesget all images, etc. needed to display HTML page.

Tal

> Date: Mon, 16 Dec 2013 04:40:58 +0100
> From: flo.bro...@gmail.com
> To: je...@jezra.net
> CC: vala-list@gnome.org
> Subject: Re: [Vala] getting the valadoc.org documentation on a local server
> 
> Hey Jezra,
> 
> Please do not use wget. You wouldn't like the result.
> 
> 
> On Mon, Dec 16, 2013 at 3:46 AM, jezra  wrote:
> > I have searched on valadoc.org and https://wiki.gnome.org/Projects/Vala
> > but can not find 'devhelp-package'. Can you please provide the URL for
> > the main page?
> 
> http://api.valadoc.org/download.png
> 
> valadoc.org might look different in your browser.
> 
> 
> With best regards
>  Flo
> 
> On Mon, Dec 16, 2013 at 3:50 AM, jezra  wrote:
> > My previous attempt to harvest the documentation included using wget.
> > Unfortunately I don't recall why it didn't work for me, nor do I
> > remember which flags I used with wget. I am currently trying again with
> > 'wget -rk http://valadoc.org'
> >
> > jezra
> >
> > On Sat, 14 Dec 2013 21:39:39 +0200
> > Tal Hadad  wrote:
> >
> >> Wget can clone an entire HTTP website(even convert links and images
> >> to off-line addresses). Read:
> >> http://www.linuxjournal.com/content/downloading-entire-web-site-wget
> >>
> >> The alternative is to build all packages with vapi-gen, doesn't
> >> really recommended for you :-)
> >>
> >> Tal
> >>
> >> > Date: Sat, 14 Dec 2013 10:52:05 -0800
> >> > From: je...@jezra.net
> >> > To: vala-list@gnome.org
> >> > Subject: [Vala] getting the valadoc.org documentation on a local
> >> > server
> >> >
> >> > Hello,
> >> > Quite often, I travel to an area with no internet and do a bit of
> >> > code hacking and I would really like to be able to have the
> >> > valadoc.org documentation available on my development machine. Is
> >> > there an easy way to get the documentation?
> >> >
> >> > Jezra
> >> >
> >> > Web: http://www.jezra.net
> >> > Status: http://status.jezra.net
> >> > Coffee: http://coffee.jezra.net
> >> > ___
> >> > 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-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-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] getting the valadoc.org documentation on a local server

2013-12-14 Thread Tal Hadad
Wget can clone an entire HTTP website(even convert links and images to off-line 
addresses).
Read:
http://www.linuxjournal.com/content/downloading-entire-web-site-wget

The alternative is to build all packages with vapi-gen, doesn't really 
recommended for you :-)

Tal

> Date: Sat, 14 Dec 2013 10:52:05 -0800
> From: je...@jezra.net
> To: vala-list@gnome.org
> Subject: [Vala] getting the valadoc.org documentation on a local server
> 
> Hello,
> Quite often, I travel to an area with no internet and do a bit of code
> hacking and I would really like to be able to have the valadoc.org
> documentation available on my development machine. Is there an easy way
> to get the documentation?
> 
> Jezra
> 
> Web: http://www.jezra.net
> Status: http://status.jezra.net
> Coffee: http://coffee.jezra.net
> ___
> 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] Properties == GObject properties?

2013-10-11 Thread Tal Hadad
> Of course you would have to _declare_ the 'notify' signal.
I suppose that by "declare" you mean invoking notify("property")
inside the setter.

Thank everyone for the full answer.
Tal

Date: Fri, 11 Oct 2013 16:25:27 +0200
Subject: Re: [Vala] Properties == GObject properties?
From: nyocu...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

2013/10/11 Tal Hadad 

>  Hi,

>

> On Fri, Oct 11, 2013 at 9:34 AM, Tal Hadad  wrote:

> > First time I hear not all properties are GObject.

> >

> > Suppose I have this property:

> >

> > ...

> > public int 1numbered { get; set; }

> > ...

> >

> > This is not a GObject property, since it's started with a number.

>

> You can't have that at all, see

> https://wiki.gnome.org/Vala/Tutorial#Syntax_Overview :

>

> "For identifier names the same rules apply as for C identifiers: the

> first character must be one of [a-z], [A-Z] or an underscore,

> subsequent characters may additionally be digits [0-9]."

>

> Signal names also must start with a letter:

>

> https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-new

>

> Regards, Simon



But suppose there's a property which is valid for Vala, but can't be GObject 
property,

what then would be the answer for my questions?

Hi,
the answer would be: yes, you would _not_ be able to connect to a 
'notify'signal for a property that's not backed by GObject managed properties
(such as would happen for Compact classes), and yes, you should still beable to 
emit a custom signal from withing any getter/setter, as those arejust 
syntactical sugar that turn

obj.a = 14;
into
myobj_set_a(obj, 14);
Of course you would have to declare the 'notify' signal.
Jonas
  
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Properties == GObject properties?

2013-10-11 Thread Tal Hadad
>  Hi,
> 
> On Fri, Oct 11, 2013 at 9:34 AM, Tal Hadad  wrote:
> > First time I hear not all properties are GObject.
> >
> > Suppose I have this property:
> >
> > ...
> > public int 1numbered { get; set; }
> > ...
> >
> > This is not a GObject property, since it's started with a number.
> 
> You can't have that at all, see
> https://wiki.gnome.org/Vala/Tutorial#Syntax_Overview :
> 
> "For identifier names the same rules apply as for C identifiers: the
> first character must be one of [a-z], [A-Z] or an underscore,
> subsequent characters may additionally be digits [0-9]."
> 
> Signal names also must start with a letter:
> 
> https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-new
> 
> Regards, Simon

But suppose there's a property which is valid for Vala, but can't be GObject 
property,
what then would be the answer for my questions?

> Date: Fri, 11 Oct 2013 10:46:18 +0200
> Subject: Re: [Vala] Properties == GObject properties?
> From: skage...@gmail.com
> To: tal...@hotmail.com
> CC: vala-list@gnome.org
> 
> 
>  Hi,
> 
> On Fri, Oct 11, 2013 at 9:34 AM, Tal Hadad  wrote:
> > First time I hear not all properties are GObject.
> >
> > Suppose I have this property:
> >
> > ...
> > public int 1numbered { get; set; }
> > ...
> >
> > This is not a GObject property, since it's started with a number.
> 
> You can't have that at all, see
> https://wiki.gnome.org/Vala/Tutorial#Syntax_Overview :
> 
> "For identifier names the same rules apply as for C identifiers: the
> first character must be one of [a-z], [A-Z] or an underscore,
> subsequent characters may additionally be digits [0-9]."
> 
> Signal names also must start with a letter:
> 
> https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-new
> 
> Regards, Simon
  
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Properties == GObject properties?

2013-10-11 Thread Tal Hadad
First time I hear not all properties are GObject.

Suppose I have this property:

...
public int 1numbered { get; set; }
...

This is not a GObject property, since it's started with a number.
Does it mean that I couldn't connect to notify["1numbered"] signal?

In case that I can't connect to notify signal, and I have this code instead:
...
int _1numbered = 0;
public int 1numbered {
get { return _1numbered };
set {
if (_1numbered == value)
return;
// otherwise
_1numbered = value;
notify("1numbered");
};}
...

Would this notification is valid and would work?

Tal

> Date: Fri, 11 Oct 2013 03:21:24 +0200
> From: flo.bro...@gmail.com
> To: e...@coeus-group.com
> CC: kno...@gmail.com; vala-list@gnome.org
> Subject: Re: [Vala] Properties == GObject properties?
> 
> > it depends on the type, but usually yes.
> 
> It depends on the type, accessibility, member-binding, "virtual",
> attributes and name[1].
> 
> [1]https://git.gnome.org/browse/vala/tree/codegen/valagobjectmodule.vala#n695
> 
> On 10 October 2013 21:36, Evan Nemerson  wrote:
> > On Thu, 2013-10-10 at 21:18 +0200, "Andrés G. Aragoneses" wrote:
> >> Quick question, are properties of objects in vala bound to gobject
> >> properties? That is, properties that can be found via
> >> g_object_class_find_property()?
> >
> > Assuming you're talking about a class which inherits from GLib.Object,
> > it depends on the type, but usually yes.  Arrays (other than arrays of
> > strings) and delegates aren't.
> >
> > Also, keep in mind that fields != properties.  For example,
> >
> > public class Foo : GLib.Object {
> >   public int bar { get; set; }
> >   public int baz;
> > }
> >
> > In this case, "bar" is a GObject property, but "baz" isn't.
> >
> >
> > -Evan
> >
> > ___
> > 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-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Vala 0.22.0 - requiring instance of Class to access Class class-members.

2013-09-29 Thread Tal Hadad
> Hello,
> 
> This is the second time I've tried to post to the list, but I haven't 
> seen my first attempt show up in the vala-list archive yet, so I thought 
> I would resend, just in case.
> 
> I'm still learning my way around vala so I may be doing something wrong, 
> but according to the docs at https://wiki.gnome.org/Vala/Manual/Classes:
> 
>   * Class members are shared between all instances of a class. They can
> be accessed without an instance of the class, and class methods will
> execute in the scope of the class.

I'll mark some points:

Class members are sharing ACCESS between all instances of a class.
They
 can be accessed without an instance of the class(BUT HAVE TO 
SPECIFY ANOTHER INSTANCE TO GET TO), and class methods will execute 
in the scope of the class(WITH A GIVEN INSTANCE).

There's an only one exception to my marking - static members.
Static
 members belong to the class, not to the instance, and therefore its 
value is "shared" between all instances and the class.

More about static vs non-static members(in OOP):
http://www.daniweb.com/software-development/csharp/threads/96978/static-vs-non-static-methods

> 
> This does not appear to be the case.  In the following example I cannot 
> access the prop method of the Parent or Child classes without 
> instantiating an instance of those classes.
> 
> public class Parent : Object {
>  protected class int _prop;
>  public class int prop() { return _prop; }
>  class construct {
>  _prop = 0;
>  }
> }
> 
> public class Child : Parent {
>  class construct {
>  _prop = 1;
>  }
> }
> 
> Parent p = new Parent();
> print ("Parent.prop: %d\n", p.prop()); // Works as expected
> print ("Parent.prop: %d\n", Parent.prop());// error: Access to 
> instance member `Parent.prop' denied
> 
> Child c = new Child();
> print ("Child.prop: %d\n", c.prop());// Works as expected
> print ("Child.prop: %d\n", Child.prop());// error: The name `prop' 
> does not exist in the context of `Child'
> 
> Is this the desired behavior or are class methods, suppose to only be 
> accessible from class instances?
> 
> Kind Regards,
> 
> Tom
> 

This is desirable behavior.
Notice that it works fine when calling method "prop" by instance.
When you call this method by a class name, it fails, since ONLY static method 
are allowed to be called by a class name.
Child.prop() would fail even if prop() is static, since the method belongs to 
Parent, and not to Child.

> I believe it's a bug in the compiler. It's non-sense to require an instance
> when those are class-level instances.

Sorry, but I don't understand you. Why it's a bug in compiler?

> However as a workaround you can use static fields. You can still initialize
> them with class construct { } or static construct { }.

So why don't just do this?

> Also if you were thinking of overriding a protected class field, I hardly
> believe that's implemented (there's a bug somewhere about that)

No I checked this in the past, Vala doesn't support this.
It could theoretically can be possible by register this with GObject class 
struct, but it's a source for ABI breaks.
Better to implicate this with a virtual static get method.

I do accept that this could be a nice feature.

Tal
  
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] A struct in a vapi file with undefined contents?

2013-07-30 Thread Tal Hadad
It's sounds like what you want is a compact class:
[CCode (cname = "FIT_CONVERT_STATE")]
[Compact]
public class a {
}

Compact class is better, since it's always treated like pointer.
In struct you may accidentally copy memory(zero in your case) if you do
a value assignment.

Tal

> From: dylanmcc...@gmail.com
> Date: Mon, 29 Jul 2013 23:37:03 -0700
> To: vala-list@gnome.org
> Subject: Re: [Vala] A struct in a vapi file with undefined contents?
> 
> And, naturally, if I'd just not made a silly typo when I had tried
> this, I would have seen valac doesn't complain at all and it works the
> way I want, allocating the correct space in memory. Hooray!
> 
> So, I have the following in my vapi file now…
> 
> [CCode (cname = "FIT_CONVERT_STATE")]
> public struct State {
> // Private
> }
> 
> Sorry about the noise. Of course, please do point out if this is going
> to end poorly :)
> 
> --
> Dylan
> 
> On 28 July 2013 22:28, Dylan McCall  wrote:
> > Sometimes, when I find myself working with a (plain) C library through
> > Vala, I end up using a pattern like this. I really don't like it:
> >
> > void * convert_state = Fit.create_convert_state();
> > Fit.Convert.init(convert_state, true);
> >
> > In this case, Fit.Convert.init is part of the original library, which
> > I made a vapi file for. It takes a reference to convert_state, which
> > it writes to. Fit.create_convert_state() is a function I created in a
> > small C wrapper library. The entire point of it is to allocate space
> > for a struct on the heap (for Fit.Convert.init), and then return a
> > pointer to that struct. The struct isn't in the vapi file because it's
> > huge and complicated and it's really internal to that library. Its
> > contents aren't _interesting_ to the Vala program - just that it's of
> > a particular size.
> >
> > Is there a way to add a struct with undefined contents in a vapi file?
> > That way I can maybe do something like this with the example?
> >
> > ConvertState convert_state = ConvertState();
> > Fit.Convert.init(convert_state, true);
> >
> > We wouldn't be able to access any members in convert_state, but we'd
> > be spared ugly void pointers.
> >
> > …or am I looking at this the wrong way? I probably am. Any help is
> > appreciated :)
> >
> > --
> > Dylan
> ___
> 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] Deriving classes from GLib.Thread

2013-05-02 Thread Tal Hadad
Yes, it's invalid because you inherit from compact class.

However, you pointing up an issue!
Shell ValaC give a "normal" error on inheritance?
e.g.:
"MThread.vala:1.1-3.18: error: class `MThread' can't inherit from class 
`GLib.Thread',
since it's compact.
class MThread : GLib.Thread
^^^"
- Tal


> Date: Tue, 30 Apr 2013 10:44:49 -0400
> From: andrew.benton...@gmail.com
> To: richard.wiedenho...@gmail.com
> CC: vala-list@gnome.org
> Subject: Re: [Vala] Deriving classes from GLib.Thread
> 
> I believe that the problem that you are having is due to the fact that 
> GLib.Thread is a compact class.  When classes are compact, it means 
> that you cannot inherit from them.
> 
> For information on compact classes, look here: 
> https://live.gnome.org/Vala/ReferenceHandling#Memory_management_for_compact_classes_without_reference_counting
>  
> 
> 
> On 4/30/2013 6:43 AM, Richard Wiedenhöft wrote:
> > Hi,
> >
> > I am trying to add some functionality (e.g. an is_alive-method) to the
> > GLib.Thread class, but with the following code:
> >
> > class MThread : GLib.Thread {
> >  public MThread(string? name, ThreadFunc func) {
> >  base(name, func);
> >  }
> >
> >  public MThread.try(string? name, ThreadFunc func) throws Error {
> >  base.try(name, func);
> >  }
> > }
> >
> > I get the following error:
> >
> > MThread.vala:3.3-3.18: error: chain up to `GLib.Thread' not supported
> >  base(name, func);
> >  
> > MThread.vala:7.3-7.10: error: The name `try' does not exist in the
> > context of `GLib.Thread'
> >  base.try(name, func);
> >  
> > MThread.vala:6.2-6.19: error: unable to chain up to private base constructor
> >  public MThread.try(string? name, ThreadFunc func) throws Error {
> >  ^^
> > Compilation failed: 3 error(s), 0 warning(s)
> >
> > I found a similar issue in
> > https://mail.gnome.org/archives/vala-list/2009-October/msg0.html but
> > it is not helping me very much. It just gives me
> > the idea, that my problem is something that is not as easily solved as
> > it sounds...
> >
> > Thanks for any help in advance
> >
> >
> >
> >
> > ___
> > 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-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Vala should use g_slice for structures.

2013-04-15 Thread Tal Hadad
Hello all

I've seen in my generated code, that Vala use g_slice for alloc. classes.
But on structs, Vala use g_new0 and g_free.

I think it should be also in structures "dup" and "free" funcs, for faster 
performance,
even known struct duplicating isn't used a lot.

Hope to hear your opinion.

Tal
  
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Vala to Android - Cairo

2013-04-01 Thread Tal Hadad
Very good results.
But why the Android device is needed to be rooted?

And is it possible to use OpenGLES in Vala there?

Tal

> From: tarn...@tarnyko.net
> To: vala-list@gnome.org
> Date: Mon, 1 Apr 2013 06:10:40 +0200
> Subject: Re: [Vala] Vala to Android - Cairo
> 
> Hi people, 
> 
> Last message from myself on this thread, just to let you know that I made a 
> tutorial for using Cairo on Android - from Vala : 
> 
> http://www.tarnyko.net/en/?q=node/26 
> 
> So we can now draw shapes, text, images... and all sort of nice things on 
> Android's screen from Vala code. 
> 
> More interesting stuff in this style will come later, working on this. 
> 
> Regards,
> Tarnyko
> ___
> 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] Autovala: new program for developers

2013-03-30 Thread Tal Hadad
This is sound very attractive, even I don't like CMake.

I have a few question tough:
1. I've read autovala search autocratically for vala files.
Can I disable this feature?
Supposing I want to compile some file only on some condition, can it be 
possible?

2. Can a C files be used with Vala?
Like using --use-fast-vapi and adding a C file to complication.

Hope the best for your tool.
Tal

> From: tarn...@tarnyko.net
> To: vala-list@gnome.org
> Date: Sat, 30 Mar 2013 16:14:00 +0100
> Subject: Re: [Vala] Autovala: new program for developers
> 
> Nice ! Thanks for your work, will check that when I have time. 
> 
> Regards,
> Tarnyko 
> 
> rastersoft writes: 
> 
> > Hi all: 
> > 
> > Several days ago, another user commented in Elementary Dev list that
> > using CMake with Vala was quite hard and difficult. 
> > 
> > After thinking about it, I reached the conclusion that using CMake is
> > quite boring and repetitive, so I said to myself: why not creating a
> > tool that automatically generates the CMakeLists.txt files, based on
> > several rules and heuristics? 
> > 
> > The result is Autovala. It not only deduces where to put each file and
> > how to compile the binaries or libraries from the sources, but also
> > automagically finds the packages used in each project, and passes them
> > to the compiler. It also creates automatically the .gir and .vapi files
> > for libraries. 
> > 
> > You have a longer and more precise description in the README file, in
> > the github repository: 
> > 
> > https://github.com/rastersoft/autovala 
> > 
> > It is still an alpha version, but fully usable. It still lacks some
> > minor things, like generating the .pc file for pkg-config, and other
> > things. For those I will need some help. If someone volunteers... 
> > 
> > Enjoy it! 
> > 
> > -- 
> > Nos leemos
> >  RASTER(Linux user #228804)
> > ras...@rastersoft.com  http://www.rastersoft.com 
> > 
> > ___
> > 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-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Vala to Android

2013-03-20 Thread Tal Hadad
Very good!
someone had to break his mind until this would success, and you and many others 
volunteered...

The main problem was GObject and GLib, I think it would interest people in 
other GNOME mailing list.

I recently also tried myself to find ways to use Vala in Android, and you prove 
it works!

This also should be a great start for GTK in android, QT is ahead in this race.

Tal

> From: tarn...@tarnyko.net
> To: vala-list@gnome.org
> Date: Wed, 20 Mar 2013 00:05:47 +0100
> Subject: Re: [Vala] Vala to Android
> 
> Nice, thank you very much ! 
> 
> Regards,
> Tarnyko 
> 
> Luca Bruno writes:
> > 
> > Thanks for your contribution. I've reported it here fyi:
> > http://valajournal.blogspot.it/2013/03/vala-on-android.html 
> > 
> > Best regards, 
> > 
> > -- 
> > www.debian.org - The Universal Operating System
> ___
> 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] Using "is" keyword yeilds error in Valac 0.18.1

2013-03-11 Thread Tal Hadad

Using "is" keyword yeilds error in Valac 0.18.1.
For example,

if (e is Error)


Gives me this error:
error: macro "G_TYPE_CHECK_INSTANCE_TYPE" requires 2 arguments, but only 1 given

In 0.16, it works 100%

Can you fix this please?
Tal
  
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] regarding Gtk.Application managing a single instance app

2013-02-02 Thread Tal Hadad

First, note you can use GLib.Application in GLib, you don't have to use 
Gtk.Aplication(it's inherit from the first):
http://developer.gnome.org/gio/unstable/GApplication.html

There, you can see example 19A, where it shows you how to activate an Action, 
using Application class.
The action is performed in the primary instance, even if it was activated in 
other process.
You can pass a string parameter to the action.

Good luck
Tal

> From: db...@uci.cu
> To: vala-list@gnome.org
> Date: Fri, 1 Feb 2013 14:21:35 -0500
> Subject: [Vala] regarding Gtk.Application managing a single instance app
> 
> Hello,
> 
> a student of mine has been appointed to develop a copy manager. He
> decided to write the code in Vala and he's been consulting me since. The
> idea is to be able to manage several copy processes in a single window,
> so he's using Gtk.Application for that matter.
> 
> The logic behind the single instance is (as you may suppose) that the
> first time the application is invoked it launches a new window with the
> copy widgets on it. Any new attempt to invoke the application should add
> a new copy to the already existing window (a window exists solely while
> any of the copies it handles is alive, so: if the there is no copy in
> progress any invocation is considered as the first one).
> 
> All that being said what's happening is that the second time the app is
> invoked the "activate" method seems to be running on the first instance
> of the class, and since the new copy information is stored on the
> current instance, there is no new copy being created since the existing
> instance tries to create (again) it's own copy resulting on an logical
> error since the same copy cannot be run twice at the same time.
> 
> Issues related to good programming practices have been discussed with
> the student already, yet I fail to understand how could the new info be
> passed to the existing instance.
> 
> I'm hoping someone can shed some light on this.
> 
> Best regards,
> 
> D.H.Bahr.
> 
> PS: This is the code relevant to the problem:
> 
> /**/
> using GLib;
> using Gtk;
> 
> public class Main : Gtk.Application {
> 
>   private MainView main_view;
>   private string operation_type;
>   private List sources;
>   private string destination;
>   
>   public Main (string operation_type, List sources, string
> destination) {
> Object (application_id: "nova.ncopier", flags:
> ApplicationFlags.FLAGS_NONE);
>   
> this.operation_type = operation_type;
>   
> this.sources = new List ();   
> foreach (unowned string source in sources) {
>   this.sources.append (source);
> }
>   
> this.destination = destination;
>   }
> 
>   public override void activate () {
> if (this.get_windows ().length () == 0) {
>   main_view = new MainView (this.operation_type, this.sources,
> this.destination);
>   this.add_window(main_view);
> } else {
>   for (int i = 0; i < (int) this.sources.length (); i++) {
> stdout.printf ("%d:%s", i, this.sources.nth_data (i));
>   }
>   main_view.add_operation (new OperationView (this.operation_type,
> this.sources, this.destination));
>   main_view.present ();
> }
>   }
> 
>   static int main (string[] args) {
> Gtk.init (ref args);
>   
> if (args.length < 4) {
>   stdout.printf ("incomplete parameters\n");
>   return 1;
> } else {
>   string operation_type = "";
>   List sources = new List ();
>   string destination = "";
>   
>   if (args[1] == "copy") {
> operation_type = "COPYING";
>   }
>   sources.append ("file:" + args[2]);
>   destination = "file:" + args[3];
>   
>   return new Main (operation_type, sources, destination).run ();
> }
>   }
> }
> /***/
> 
> ___
> 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] Vala dynamic array with double []

2013-01-27 Thread Tal Hadad

This is kinda tricky.
First, take a look in Wikipedia:

http://en.wikipedia.org/wiki/Dynamic_array

The bad way, is to use "resize" method every time:

double[] a = new double[0];
for (int i=0;ihttp://developer.gnome.org/glib/2.31/glib-Arrays.html#GArray

Good luck!
Tal

> From: 2cyouag...@gmail.com
> To: vala-list@gnome.org
> Date: Sun, 27 Jan 2013 20:56:49 +0700
> Subject: [Vala] Vala dynamic array with double []
> 
> What alternative to define array like this:
> in PHP or C# we can do
> $arrOptions = array();
> $arrOptions[][] = 1;
> 
> any suggestion or what library that have class or other?
> thanks
> 
> ___
> 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] Few bugs in Xnoise

2013-01-22 Thread Tal Hadad

After testing the new version, I have few bugs to report(sorry for being late):
1. Adding a new source directory to library should be async.
It means that after adding music directory, the user could continue and add 
another directory, not waiting for finishing scanning.

2. When (de/)activating the equalizer, the current track gets restarted.

3. I have not set a GTK3 thee in my machine, so it uses the default one.
Therefore, I see the ugly relief on the 4 media buttons, please disable this 
using "relief" property.

4. This is a suggestion, but think that the Ascending/Descending buttons are 
ugly and not interactive.
You should have an arrow down or arrow up in the button which is selected.
You can pack a Box(which contain a label(icon?) and arrow) inside a Button by 
using add () method.

Sorry for not being here long time.

Tal
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Defining new virtual signal is possible, but overring it isn't.

2012-12-17 Thread Tal Hadad

I tried this too in my Windows machine(version 0.18) and it works like your 
machine.

I'll try to update my Vala at Debian machine and check this too.

Thanks,
Tal

Date: Mon, 17 Dec 2012 12:39:37 +0100
From: nyocu...@gmail.com
To: vala-list@gnome.org
Subject: Re: [Vala] Defining new virtual signal is possible,but overring it 
isn't.

2012/12/17 Tal Hadad 
 
> public class Foo : GLib.Object {
> public virtual void func() {
> }
>
> internal static void bug () {
> new Bar ();
> }
> }
> public class Bar : Foo {
> public override void func() {
> }
> }
>
 
I just tried compiling this with Vala 0.18 too
and it works for me. Maybe you should upgrade
your valac?
 
 - Jonas

___
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] Defining new virtual signal is possible, but overring it isn't.

2012-12-17 Thread Tal Hadad

Thanks you for your replies!
But the bug is still there.

I have given a wrong example for this bug(since it works).

The good example for this bug, is:

public class Foo : GLib.Object {
public virtual void func() {
}

internal static void bug () {
new Bar ();
}
}
public class Bar : Foo {
public override void func() {
}
}

Valac(0.16.1) gives:

$ valac main.vala
main.vala:11.2-11.26: error: Bar.func: no suitable method found to override
public override void func() {
^
Compilation failed: 1 error(s), 0 warning(s)

When there's some method inside classes(e.g. "bug"), no matter if it's static 
or not,
that calls Bar contractor, valac gives this error.

However, if "bug" method is outside of Foo class blocks, valac compiles fine.

I have report this bug in GNOME Bugzilla:
https://bugzilla.gnome.org/show_bug.cgi?id=690335

Hope you'll fix this bug in next releases.

Yours
Tal

From: daide...@gmail.com
Date: Sun, 16 Dec 2012 21:47:32 +0800
To: vala-list@gnome.org
Subject: Re: [Vala] Defining new virtual signal is possible,but overring it 
isn't.

You can try code below as solution/workaround.
 
class Foo : GLib.Object
{
public virtual signal void func()
 {
message("Foo");
}
}
 
class Bar : Foo
{
public override void func()
{
 message("Bar");
}
}
 
int main()
{
Foo foo = new Bar();
foo.func.connect(() => { message("Main"); });
 foo.func();
 return 0;
}
 
Derek Dai
 
 
 
On Sun, Dec 16, 2012 at 8:00 PM,  wrote:
 
> Send vala-list mailing list submissions to
> vala-list@gnome.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://mail.gnome.org/mailman/listinfo/vala-list
> or, via email, send a message with subject or body 'help' to
> vala-list-requ...@gnome.org
>
> You can reach the person managing the list at
> vala-list-ow...@gnome.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of vala-list digest..."
>
>
> Today's Topics:
>
>1. Defining new virtual signal is possible,  but overring it
>   isn't. (Tal Hadad)
>
>
> --
>
> Message: 1
> Date: Sat, 15 Dec 2012 21:00:24 +0200
> From: Tal Hadad 
> To: Vala Mail List 
> Subject: [Vala] Defining new virtual signal is possible,but
> overring
> it isn't.
> Message-ID: 
> Content-Type: text/plain; charset="windows-1255"
>
>
> When I try to:
> public class A : GLib.Object {
>   public virtual signal void func () {}
> }
>
>
> public class B : A {
>
>   public override void func () {}
>
> }
>
> I get an error from Valac:
> error: B.func: no suitable method found to override
>
> I'm using Vala 0.16.1
>
> I think that this is a critical bug in Vala, or my code is wrong?
>
> Thanks,
> Tal
>
>
> --
>
> ___
> vala-list mailing list
> vala-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/vala-list
>
>
> End of vala-list Digest, Vol 61, Issue 7
> 
>

___
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] Defining new virtual signal is possible, but overring it isn't.

2012-12-15 Thread Tal Hadad

When I try to:
public class A : GLib.Object {
  public virtual signal void func () {}
}


public class B : A {

  public override void func () {}

}

I get an error from Valac:
error: B.func: no suitable method found to override

I'm using Vala 0.16.1

I think that this is a critical bug in Vala, or my code is wrong?

Thanks,
Tal
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] [Bug?] Lambda user data inside compact classes method cause error.

2012-11-18 Thread Tal Hadad

The bug is like this:
Look on my code:

[Compact]
public class DsRoot {

private void initialize_unit (DsUnit unit) {// line 137
// "managers" is a field (GLib.SList).
managers.foreach ((manager) => {
unit.foreach_object ((object) => {
manager.initialize_object (object);
});
});
}
// line 144

}

This code perform nested "foreach" action.
It looks fine on first look, but Vala compiler run into error:
graphics/drawing/nodes/ds_root.vala:137.59-144.9: error: duplicating DsRoot 
instance, use unowned variable or explicitly invoke copy method

At first, I didn't understand the error, so I started testing with (/* */).
I've discovered that if I remove the second foreach like that:

[Compact]

public class DsRoot {



private void initialize_unit (DsUnit unit) {// line 137

// "managers" is a field (GLib.SList).

managers.foreach ((manager) => {

/*unit.foreach_object ((object) => {

manager.initialize_object (object);

});*/

});

}

// line 144



}

The error is gone.
The reason for this happan only in the second foreach, is that it requires user 
data("manager" variable), while the first one doesn't.

So when Vala create the user data, it threat "self"/"this" as owned, while it 
should be unowned, since the delegate parameter is unowned too.
I think Vala always threat this as owned since Vala used to deal with 
GObjects(or ref-counted-classes), and always ref&unref them.

So I suggest that for fixing this bug, Vala should threat "self" as unowned for 
targets of unowned delegates, no matter if they are ref-counted-classes nor 
Compact.

What do you think? Am I right with my assumption?

Tal
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Should be warning(maybe error) when method with [ReturnsModifiedPointer] is called from unowned variable

2012-11-08 Thread Tal Hadad

> Yes, now I see it. I guess that it might be error specific to implementation 
> of GLib.SList.No it's not. GLib implicated it as the way they see this, and 
> Vala coordinate it with [ReturnsModifiedPointer].
> I won't be able to help you :( (btw, I use Gee for lists/arrays etc).It's not 
> a matter of help. I just wish that there will be error when developer call a 
> method with [ReturnsModifiedPointer] (i.e. SList.remove ()) from unowned 
> variable, or at least a warning. That will fix the whole this.Also, I admire 
> Gee work, but in term of performance for internal lists, I guess most devs 
> will chose SList
Would you chose to warn/err the developer when this situation invoked?Should I 
open a bug report?
Tal
Date: Thu, 8 Nov 2012 01:12:10 +0100
Subject: Re: [Vala] Should be warning(maybe error) when method with 
[ReturnsModifiedPointer] is called from unowned variable
From: kotow...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

Yes, now I see it. I guess that it might be error specific to implementation of 
GLib.SList.
In example that you gave, same behaviour can be seen when removing first item 
from other list (given_list). If it is first item, list you were modifying 
works fine, but other seems to be broken (it is the same in both cases, 
modifying given_list or list).

I won't be able to help you :( (btw, I use Gee for lists/arrays etc).
Jarek
2012/11/6 Tal Hadad 



I'm sorry, the example I gave is bad. Forgot the "unowned" word.

Example:



unowned GLib.SList list = given_list;



list.remove(data);



Do you see the problem here?

If "data" is on the FIRST item on the list, it only removes it from

"list", not from the owned variable "given_list".



I run into bug likes that im my program and just wanted to warn

Vala devs.



Do you see the problem now?



Tal



Date: Mon, 5 Nov 2012 17:01:14 +0100

Subject: Re: [Vala] Should be warning(maybe error) when method with 
[ReturnsModifiedPointer] is called from unowned variable

From: kotow...@gmail.com

To: tal...@hotmail.com

CC: vala-list@gnome.org



I am confused here. What [ReturnsModifiedPointer] has to do with 
copying/referencing an object?

With GLib.SList list = given_list; you do not create a copy of an object but 
owned reference/pointer. And if you do anything to that reference, you will 
modify given_list too.



And in most cases not copying object, but referencing it is desired behaviour, 
so I don't see problem here. I would also not desire assuming that copy should 
be created whenever I assign object from unowned reference to owned reference.




I think that everything is ok here, unless I am missing something.

Could you describe the result you expect from the code you provided?

Jarek



2012/11/4 Tal Hadad 







There should be warning(maybe error) when method with



[ReturnsModifiedPointer] is called from unowned variable.







Take a look on GLib.SList. The beginner programer(me too) can be



assign an unowned variable to the list, and remove items, but he



don't know it shell update the owned pointer.







Example:







GLib.SList list = given_list;



list.remove(data);







Naive programers can be fooled(like me) that this code are valid,



since Vala print no errors neither warning.







I think we all agree it's NOT ok, but do you see this as error or warning?







Yours



Tal





___



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-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Should be warning(maybe error) when method with [ReturnsModifiedPointer] is called from unowned variable

2012-11-06 Thread Tal Hadad

I'm sorry, the example I gave is bad. Forgot the "unowned" word.
Example:

unowned GLib.SList list = given_list;

list.remove(data);

Do you see the problem here?
If "data" is on the FIRST item on the list, it only removes it from
"list", not from the owned variable "given_list".

I run into bug likes that im my program and just wanted to warn
Vala devs.

Do you see the problem now?

Tal

Date: Mon, 5 Nov 2012 17:01:14 +0100
Subject: Re: [Vala] Should be warning(maybe error) when method with 
[ReturnsModifiedPointer] is called from unowned variable
From: kotow...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

I am confused here. What [ReturnsModifiedPointer] has to do with 
copying/referencing an object?
With GLib.SList list = given_list; you do not create a copy of an object but 
owned reference/pointer. And if you do anything to that reference, you will 
modify given_list too.

And in most cases not copying object, but referencing it is desired behaviour, 
so I don't see problem here. I would also not desire assuming that copy should 
be created whenever I assign object from unowned reference to owned reference.

I think that everything is ok here, unless I am missing something.
Could you describe the result you expect from the code you provided?
Jarek

2012/11/4 Tal Hadad 



There should be warning(maybe error) when method with

[ReturnsModifiedPointer] is called from unowned variable.



Take a look on GLib.SList. The beginner programer(me too) can be

assign an unowned variable to the list, and remove items, but he

don't know it shell update the owned pointer.



Example:



GLib.SList list = given_list;

list.remove(data);



Naive programers can be fooled(like me) that this code are valid,

since Vala print no errors neither warning.



I think we all agree it's NOT ok, but do you see this as error or warning?



Yours

Tal

  
___

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] Should be warning(maybe error) when method with [ReturnsModifiedPointer] is called from unowned variable

2012-11-04 Thread Tal Hadad

There should be warning(maybe error) when method with
[ReturnsModifiedPointer] is called from unowned variable.

Take a look on GLib.SList. The beginner programer(me too) can be
assign an unowned variable to the list, and remove items, but he
don't know it shell update the owned pointer.

Example:

GLib.SList list = given_list;
list.remove(data);

Naive programers can be fooled(like me) that this code are valid,
since Vala print no errors neither warning.

I think we all agree it's NOT ok, but do you see this as error or warning?

Yours
Tal
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Binding Bug in Atk.Util.add_global_event_listener

2012-10-04 Thread Tal Hadad

There is a bug in atk.vapi, in method:
Atk.Util.add_global_event_listener
The line is:

public static uint add_global_event_listener (GLib.SignalEmissionHook 
listener, string event_type);

But there should be a CCode attribute in first parameter(listener) saying 
"has_target=false" .
There is no user_data aurgument. See:
http://developer.gnome.org/atk/stable/AtkUtil.html#atk-add-global-event-listener

Tal
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Fisrt start in ATK(bad)

2012-10-03 Thread Tal Hadad

I'm trying to get into the ATK API for reading GTK widgets text, but I my first 
try is not great.
I've read this document:
http://developer.gnome.org/accessibility-devel-guide/3.0/id232879.html.en
Sadly, it is the most useful document for ATK client.

I tried the first one, but with no luck.
Here is source:

using GLib;
using Atk;
using Gtk;

void _my_focus_tracker (Atk.Object object) {
stdout.printf ("Tracked!\n");
}

int main (string[] args) {
Gtk.init (ref args);
Util.add_focus_tracker (_my_focus_tracker);

Gtk.Window window1 = new Gtk.Window ();
window1.show ();

Gtk.Window window2 = new Gtk.Window ();
window2.show ();

Gtk.main ();

return 0;
}

But no matter how many times I change the focus from window1 to window2, no 
output.
Does someone here knows why?

Tal
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] GLib binding missing: GLib.Once and bit locking are missing

2012-09-30 Thread Tal Hadad

> I imagine that there are implemented, but hidden behind Vala's locking
> syntax. See https://live.gnome.org/Vala/Tutorial#Resource_Control
They're not. I've read this page.
Locking uses G_LOCK_DEFINE, G_LOCK and G_UNLOCK, which are completely different.

> Bug reports belong on the bug tracker. They are easily forgotten when
> posted here.
I did:
https://bugzilla.gnome.org/show_bug.cgi?id=685139

Thanks!
Tal

Date: Sun, 30 Sep 2012 11:33:46 +0100
From: t...@jollybox.de
To: vala-list@gnome.org
Subject: Re: [Vala] GLib binding missing: GLib.Once and bit locking are missing

On 09/26/2012 09:44 PM, Tal Hadad wrote:
> After looking on this page:
> http://developer.gnome.org/glib/2.31/glib-Threads.html
> I see that those useful thread-safe binding are missing:
> * GLib.Once namespace and its methods.
> * g_bit_lock, g_bit_try_lock and g_bit_unlock in GLib.AtomicInt
> * g_pointer_lock, g_pointer_try_lock and g_pointer_unlock in 
> GLib.AtomicPointer
 
I imagine that there are implemented, but hidden behind Vala's locking
syntax. See https://live.gnome.org/Vala/Tutorial#Resource_Control
 
>
> Please fix them on the next release.
 
Bug reports belong on the bug tracker. They are easily forgotten when
posted here.
 
>
> Yours
> Tal
> 
>
>
> ___
> 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-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] GLib binding missing: GLib.Once and bit locking are missing

2012-09-26 Thread Tal Hadad

After looking on this page:
http://developer.gnome.org/glib/2.31/glib-Threads.html
I see that those useful thread-safe binding are missing:
* GLib.Once namespace and its methods.
* g_bit_lock, g_bit_try_lock and g_bit_unlock in GLib.AtomicInt
* g_pointer_lock, g_pointer_try_lock and g_pointer_unlock in GLib.AtomicPointer

Please fix them on the next release.

Yours
Tal
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Volatile keyword in Vala(please answer)

2012-09-06 Thread Tal Hadad




Sorry for late reply.

Volatile vars also needed for:
* atomic thread locking(atomic-int and atomic-pointer)
* static memory buffers
* static id by pointer

As I said earlier, even .Net support it, and it hates low level support.
Therefore Vala should support it.

I would like to hear if you think this feature is necessary in Vala.

Thanks
Tal

> Date: Tue, 28 Aug 2012 10:23:17 +0200
> From: ras...@rastersoft.com
> To: vala-list@gnome.org
> Subject: Re: [Vala] Volatile keyword in Vala(please answer)
> 
> 
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> It's supposed that a volatile variable can change "magically" (this is,
> being modified by another thread, a device driver...), so the compiler
> has to take that into account when doing optimizations.
> 
> A crude example in C:
> 
> volatile int v=1;
> while(v==1) {
> sleep(1);
> }
> 
> (Let's assume that another thread will change the 'v' variable when
> whatever-has-to-occur happens). In this example, the "volatile" is
> mandatory because, without it, the C compiler probably will transform
> that in something like:
> 
> if (v==1) {
> loop:
> sleep(1);
> goto loop
> }
> 
> optimizing the loop and doing the comparison one time, only at the
> start, because it sees that the variable isn't being modified inside.
> But when you add the "volatile", the C compiler will know that the
> variable can be changed from other parts of the code, avoiding that
> optimization and comparing the value in each loop.
> 
> "volatile" is a reserver keyword in C, so implementing it in Vala would
> mean little more than adding it directly in the C source when found in
> Vala source.
> 
> El 28/08/12 09:14, Mikkel Kamstrup Erlandsen escribió:
> > On 24 August 2012 17:31, Tal Hadad  wrote:
> >>
> >> Is volatile keyword supported in Vala? Is it planned?
> >> Few sources say it does, but testing showing it's not.
> >>
> >> I asked this question a month ago and no one replay.
> >> Does Jörg Biller include this in Vala?
> >
> > This question is a bit scarce on detail. What do you expect volatile
> > to do, and why do you need it?
> >
> > Cheers,
> > Mikkel
> > ___
> > vala-list mailing list
> > vala-list@gnome.org
> > https://mail.gnome.org/mailman/listinfo/vala-list
> >
> 
> - -- 
> Nos leemos
>  RASTER(Linux user #228804)
> ras...@rastersoft.com  http://www.rastersoft.com
> 
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAlA8f/QACgkQXEZvyfy1ha/zvgCgloBpJR6MxRMINNMXaL9cgYVM
> mU8AoIV3hGkdvSybTEXiLRKVR3MsBIco
> =spbp
> -END PGP SIGNATURE-
> 
> ___
> 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] ANNOUNCE: ValaWinPKG for win32

2012-08-25 Thread Tal Hadad

It looks very good!
Most .Net devs find Vala libraries installation difficult with windows(such as 
me).
This software solve the problems(give Windows users the installation style they 
used to!).
I have questions though:
If I have mingw and install Vala and other libraries using MinGW(msys),
can I install a specific library(such as gobject-introspection) which I can't 
build?
Can I create a custom package for other libraries(which out of repo)?

Good work! I'll test it when I boot back to Windows.

Tal

> From: tarn...@tarnyko.net
> To: vala-list@gnome.org
> Date: Fri, 24 Aug 2012 20:33:57 +0200
> Subject: [Vala] ANNOUNCE: ValaWinPKG for win32
> 
> Hi folks, 
> 
> Since this a dev list, I'll just post a little dev-oriented annnounce... 
> 
> I just released the first version of ValaWinPKG. It's a kind of package 
> manager, which downloads Win32 libraries having Vala bindings : Soup, Gee, 
> MySQL, SQLite, GLUT, GtkGLExt, SDL... 
> 
> It permits usage of the Win32 Vala compiler with additional libraries 
> easily. 
> 
> The packages themselves contains DLLs, import libraries (dll.a), locales and 
> eventuelly .vapi files when they are not included with Vala itself. 
> 
> Download link : http://www.tarnyko.net/en/?q=node/5
> Tutorial link : http://www.tarnyko.net/en/?q=node/6 
> 
> It's GPL of course.
> I also posted it on the wiki. 
> 
> Regards, Tarnyko
> ___
> 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] Volatile keyword in Vala(please answer)

2012-08-24 Thread Tal Hadad

Is volatile keyword supported in Vala? Is it planned?
Few sources say it does, but testing showing it's not.

I asked this question a month ago and no one replay.
Does Jörg Biller include this in Vala?

Tal
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Help! The method named 'XGetImage' is missing.

2012-08-15 Thread Tal Hadad

Until this binding will be fixed, you can use the extern word in your program:
extern X.Image X.GetImage(params)
extern int X.PutImage(params)

If my definitions were wrong, write your own using the "extern" keyword.

> Date: Wed, 15 Aug 2012 22:41:17 +0800
> From: ad...@heiher.info
> To: vala-list@gnome.org
> Subject: [Vala] Help! The method named 'XGetImage' is missing.
> 
> Hello!
> 
> The method named 'XGetImage' and 'XPutImage' is missing in x11.vapi.
> 
> Help!
> 
> -- 
> Best regards!
> Heiher
> https://heiher.info
> ___
> 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] [xnoise] [Bug] Crash when attempt to play tracks

2012-08-15 Thread Tal Hadad

I've found the problem on the second bug.
After testing it both with Xfwm4&Compiz, I' don't think it's a composer bug. It 
maybe a GTK bug or X11 bug.
The method is:
public void toggle_window_visbility() {
if(active_notifier != 0) {
this.disconnect(active_notifier);
active_notifier = 0;
}
if(this.has_toplevel_focus) {
this.get_position(out _posX, out _posY);
this.hide();
}
else if(this.get_window().is_visible() == true) {
this.move(_posX, _posY);
this.present();
active_notifier = this.notify["is-active"].connect(buffer_position);
}
else {
this.move(_posX, _posY);
this.present();
active_notifier = this.notify["is-active"].connect(buffer_position);
}
}

For some reason(tested it using GLib.message() method), this.has_toplevel_focus 
is always true in the program.
It maybe a gtk bug(3.4.2-2) or xserver bug.
There is a solution to make it works, by checking if the window is visible.
I've tested it, it works again by this method:
Just change this line in the method:
if(this.has_toplevel_focus) {
To this:
if(this.has_toplevel_focus && this.visible) {

This way we can escape the GTK/X11 bug.

BTW: Why do you use buffer_position() and move()?
It just seems useless(correct me if I'm wrong)

Yours
Tal

> Subject: RE: [xnoise] [Bug] Crash when attempt to play tracks
> From: shuerhaa...@googlemail.com
> To: xno...@googlegroups.com
> Date: Tue, 14 Aug 2012 16:17:57 +0200
> 
> I do.
> 
> The code you copied to your mail is used after clicking on tray icon
> only.
> 
> for other code touching window visibility please see
> the signal handler attached to the delete_event of the main_window and
> the handler of window_state_event of the main_window.
> window_state_event is for tracking some window state changes
> internally. 
> 
> I recommend using a tool called regexxer. It will help you understand
> and find out where functions are called from and where signals are
> connected to.
> 
> Best Regards
> 
> 
> 
> 
> Am Dienstag, den 14.08.2012, 15:30 +0300 schrieb Tal Hadad:
> > 
> > Thanks for fixing the first one.
> > And about the second bug, I don't really understand the
> > main_window.toggle_window_visbility method:
> > public void toggle_window_visbility() {
> > if(active_notifier != 0) {
> > this.disconnect(active_notifier);
> > active_notifier = 0;
> > }
> > if(this.is_active) { 
> 
> //is_active is a property of the Gtk.Window base class of main_window
> 
> > this.get_position(out _posX, out _posY);
> > this.hide();
> > }
> > else if(this.get_window().is_visible() == true) {
> > this.move(_posX, _posY);
> > this.present();
> > active_notifier =
> > this.notify["is-active"].connect(buffer_position);
> > }
> > else {
> > this.move(_posX, _posY);
> > this.present();
> > active_notifier =
> > this.notify["is-active"].connect(buffer_position);
> > }
> > }
> > 
> > Shouldn't you use only the present () and hide () methods?
> > 
> > Tal 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "xnoise" group.
> To post to this group, send email to xno...@googlegroups.com.
> To unsubscribe from this group, send email to 
> xnoise+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/xnoise?hl=en.
> 
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] How can I get information about vala & gtk?

2012-08-14 Thread Tal Hadad

1. How to make a connection between signal_handler_event() and my
check_button1?
The same way you do:
check_button1.toggled.connect(() => { check_button1.label = "I'm toggled!" });
You can write:
check_button1.button_press_event.connect(signal_handler_event);
Please see this example in the Vala tutorial.
An alternative is:
check_button1.button_press_event.connect(
(chk, e) {
 
if (e.type == EventButton.2BUTTON_PRESS) {
label.label = "Ouch!";
}
 
return false;
});
Do you see the imagination? I truly just copy&paste.
Actually, I just removed the parameter types.

> 2. How to solve an error: "The name `EventButton' does not exist in
> the context of `signal_handler_event'"
Add "using Gdk;" line in the first lines of your code.
When ever you see this error, suspect if you use all the needed
namespaces.
You see? This is what I meant experience is the best teacher.
Tal


> A while back I started working on a Vala GTK+ tutorial in the vein of the
> classic GTK+ tutorial for C.
> 
> You can find it on
> 
> https://github.com/abenga/valagtktutorial
>  
> I managed to work on the first 7 chapters, you can find them in the */content/
> folder.*
> 
> I've held off on posting here about the effort untilI had a reasonable
> amount of content, but I'm thinking I'll probably ask for help as I've been
> really busy recently. I recently started working on porting it to Docbook
> XML, and I hope to be done in a couple of months or so.

Very good. I think it should be added into Vala wiki.

 
On 14 August 2012 14:37, Tal Hadad  wrote:
 
>
> > Thanks, it's really nice, but I have a few tasks already and can't
> > find, how to solve it.
> > For eample: I need to make some control invisible,
> Not quit sure what do you mean by control. Is it SpinButton? Entry? Menu?
> and so on... Please give us the Widget type or at least screen shot.
> But "control" is a Widget, you can use the "hide()" method, or set the
> visible property into false.
>
> > I need to catch
> > double-mouse-click event and change one control to another and so one.
> > Can somebody help me?
>
> button_press_event in Widget is what you need.
> There is an Gdk.EventButton parameter, usually called "e" in Vala:
> http://valadoc.org/#!api=gdk-3.0/Gdk.EventButton
> It contains all information you need, including what type of click it was.
> This is an example method for this event:
> bool signal_handler_event(Widget widget, Gdk.EventButton e)
> {
> if (e.type==EventButton.2BUTTON_PRESS) {
> // Something
> }
>
>   return FALSE;
> }Yours
> Tal
>
> > Date: Tue, 14 Aug 2012 16:59:19 +0600
> > Subject: Re: [Vala] How can I get information about vala & gtk?
> > From: shoot...@gmail.com
> > To: tal...@hotmail.com
> >
> > Thanks, it's really nice, but I have a few tasks already and can't
> > find, how to solve it.
> > For eample: I need to make some control invisible, I need to catch
> > double-mouse-click event and change one control to another and so one.
> > Can somebody help me?
> >
> > 2012/8/14 Tal Hadad :
> > >
> > > I'll give you the magic trick:
> > > Look at the examples and when you find some example interesting,
> > > start to twick the code.
> > > Only experience can truly teach you.
> > > It works for me, hope it will work for you.
> > >
> > > See for example, the GTK example:
> > > https://live.gnome.org/Vala/GTKSample
> > > I'll give you homework if you want with this examples:
> > > * Basic Sample: After the first click, when the text is changed into
> > > "Thank you", the next click will make the window to exit.
> > > * Synchronizing Widgets: Add a nice restore default button with blue
> background.
> > > * Creating a Dialog: Add a button with clear the text in the entry.
> > >
> > > I don't tell you how to do it, you'll have to search the web.
> > > Do what ever you want to do with them. Pick an interesting task
> > > and perform it by your need.
> > >
> > > Hope you found my response useful.
> > > Tal
> > >
> > >> Date: Tue, 14 Aug 2012 16:25:12 +0600
> > >> From: shoot...@gmail.com
> > >> To: vala-list@gnome.org
> > >> Subject: [Vala] How can I get information about vala & gtk?
> > >>
> > >> Hi all,
> > >> I'm extremely new in vala, I've wrote almost all documentation about
> > >> vala, sqlite and gtk etc, but still have many questions how gt

Re: [Vala] How can I get information about vala & gtk?

2012-08-14 Thread Tal Hadad

> Thanks, it's really nice, but I have a few tasks already and can't
> find, how to solve it.
> For eample: I need to make some control invisible,
Not quit sure what do you mean by control. Is it SpinButton? Entry? Menu?
and so on... Please give us the Widget type or at least screen shot.
But "control" is a Widget, you can use the "hide()" method, or set the
visible property into false.

> I need to catch
> double-mouse-click event and change one control to another and so one.
> Can somebody help me?

button_press_event in Widget is what you need.
There is an Gdk.EventButton parameter, usually called "e" in Vala:
http://valadoc.org/#!api=gdk-3.0/Gdk.EventButton
It contains all information you need, including what type of click it was.
This is an example method for this event:
bool signal_handler_event(Widget widget, Gdk.EventButton e)
{
if (e.type==EventButton.2BUTTON_PRESS) {
// Something
}

  return FALSE;
}Yours
Tal

> Date: Tue, 14 Aug 2012 16:59:19 +0600
> Subject: Re: [Vala] How can I get information about vala & gtk?
> From: shoot...@gmail.com
> To: tal...@hotmail.com
> 
> Thanks, it's really nice, but I have a few tasks already and can't
> find, how to solve it.
> For eample: I need to make some control invisible, I need to catch
> double-mouse-click event and change one control to another and so one.
> Can somebody help me?
> 
> 2012/8/14 Tal Hadad :
> >
> > I'll give you the magic trick:
> > Look at the examples and when you find some example interesting,
> > start to twick the code.
> > Only experience can truly teach you.
> > It works for me, hope it will work for you.
> >
> > See for example, the GTK example:
> > https://live.gnome.org/Vala/GTKSample
> > I'll give you homework if you want with this examples:
> > * Basic Sample: After the first click, when the text is changed into
> > "Thank you", the next click will make the window to exit.
> > * Synchronizing Widgets: Add a nice restore default button with blue 
> > background.
> > * Creating a Dialog: Add a button with clear the text in the entry.
> >
> > I don't tell you how to do it, you'll have to search the web.
> > Do what ever you want to do with them. Pick an interesting task
> > and perform it by your need.
> >
> > Hope you found my response useful.
> > Tal
> >
> >> Date: Tue, 14 Aug 2012 16:25:12 +0600
> >> From: shoot...@gmail.com
> >> To: vala-list@gnome.org
> >> Subject: [Vala] How can I get information about vala & gtk?
> >>
> >> Hi all,
> >> I'm extremely new in vala, I've wrote almost all documentation about
> >> vala, sqlite and gtk etc, but still have many questions how gtk+ and
> >> vala works. It's a newbie questions but I need to ask it somebody who
> >> cant me  help. How can I get it?
> >> ___
> >> 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-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Interfaces and asynchronous methods

2012-08-14 Thread Tal Hadad

"out" keyword in async method has a different approach.
See the tutorial about async method:
https://live.gnome.org/Vala/Tutorial#Asynchronous_Methods

They is there an example that look similar to yours:
  async int fetch_webpage(string url, out string text) throws IOError {
 // Fetch a webpage asynchronously and when ready return the 
 // HTTP status code and put the page contents in 'text'
 [...]
 text = result;
 return status;
  }And how to use it, and handle the output:
  fetch_webpage.begin("http://www.example.com/";, (obj, res) => {
  try {
  string text;
  var status = fetch_webpage.end(res, out text);
  // Result of call is in 'text' and 'status' ...
  } catch (IOError e) {
  // Problem ...
  }
  });I think this example answers your question.
Tal

> Date: Tue, 14 Aug 2012 11:49:15 +0200
> From: ras...@rastersoft.com
> To: e...@yorba.org
> CC: vala-list@gnome.org
> Subject: Re: [Vala] Interfaces and asynchronous methods
> 
> 
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> Ok, here are the interesting pieces of the code:
> 
> interface backends : GLib.Object {
> [...]
> public abstract async BACKUP_RETVAL start_backup(out int64
> last_backup_time);
> [...]
> }
> 
> private backends backend;
> var rv=this.backend.start_backup(out this.last_backup_time);
> 
> 
> BTW, Jim Nelson answered that I have to do something like this:
> 
> run_async.begin(on_run_async_completed);
> 
> /* ... */
> 
> void on_run_async(AsyncResult result, Object? source) {
> int result = run_async.end(result);
> }
> 
> 
> Is this correct?
> 
> Thanks.
> 
> 
> El 14/08/12 01:10, Eric Gregory escribió:
> > On Mon, Aug 13, 2012 at 4:03 PM, rastersoft  wrote:
> >
> >>
> >> -BEGIN PGP SIGNED MESSAGE-
> >> Hash: SHA1
> >>
> >> Hi all:
> >>
> >> I tried to define an interface with an async method, but I receive this
> >> error in the line where I try to invoke it in an object that
> implements it:
> >>
> >> backup.vala:246.14-246.43: error: invocation of void method not allowed
> >> as expression
> >>
> >> Are async methods not allowed in interfaces?
> >>
> >> Thanks.
> >>
> >
> >
> > Could you paste the code that invokes the async method in this thread?
> >
> > - Eric
> >
> 
> - -- 
> Nos leemos
>  RASTER(Linux user #228804)
> ras...@rastersoft.com  http://www.rastersoft.com
> 
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAlAqHxsACgkQXEZvyfy1ha+sKgCgxRoFUf2QmxrUQVH5B4n+z21y
> 6UIAnA4xXKunyl1qz/GajMhKNu4kGj9w
> =yxwF
> -END PGP SIGNATURE-
> 
> ___
> 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] How can I get information about vala & gtk?

2012-08-14 Thread Tal Hadad

I'll give you the magic trick:
Look at the examples and when you find some example interesting,
start to twick the code.
Only experience can truly teach you.
It works for me, hope it will work for you.

See for example, the GTK example:
https://live.gnome.org/Vala/GTKSample
I'll give you homework if you want with this examples:
* Basic Sample: After the first click, when the text is changed into
"Thank you", the next click will make the window to exit.
* Synchronizing Widgets: Add a nice restore default button with blue background.
* Creating a Dialog: Add a button with clear the text in the entry.

I don't tell you how to do it, you'll have to search the web.
Do what ever you want to do with them. Pick an interesting task
and perform it by your need.

Hope you found my response useful.
Tal

> Date: Tue, 14 Aug 2012 16:25:12 +0600
> From: shoot...@gmail.com
> To: vala-list@gnome.org
> Subject: [Vala] How can I get information about vala & gtk?
> 
> Hi all,
> I'm extremely new in vala, I've wrote almost all documentation about
> vala, sqlite and gtk etc, but still have many questions how gtk+ and
> vala works. It's a newbie questions but I need to ask it somebody who
> cant me  help. How can I get it?
> ___
> 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] Declare array of enumerated(enum) value size

2012-08-12 Thread Tal Hadad

Try this code:
enum stats_parameters {
#ifdef EMBEDED
MAX_EVENTS=2
#else
MAX_EVENTS=20
#endif
}
 
 
int statistics[stats_parameters.MAX_EVENTS];
int foo[stats_parameters.MAX_EVENTS];
 
 
int bar[stats_parameters.MAX_EVENTS];Vala enums must be used with the enum name.

Yours,
Tal

Date: Sun, 12 Aug 2012 18:10:00 +0600
From: kamanashis...@gmail.com
To: vala-list@gnome.org
Subject: [Vala] Declare array of enumerated(enum) value size

Hi,
 
  I was rewriting some of my (C)code in vala. I used to do the following in
my C code,
 

 
enum {
#ifdef EMBEDED
MAX_EVENTS=2
#else
MAX_EVENTS=20
#endif
};
 
 
int statistics[MAX_EVENTS];
int foo[MAX_EVENTS];
 
 
int bar[MAX_EVENTS];
 

 
   Unfortunately I am not allowed to use enum identifier inside array
declaration. Is there any problem in this idea ? I mean this feature is
very useful.
I wanted to write code something like this,
 

 
 
enum stats_parameters {
#ifdef EMBEDED
MAX_EVENTS=2
#else
MAX_EVENTS=20
#endif
}
 
 
int statistics[MAX_EVENTS];
int foo[MAX_EVENTS];
 
 
int bar[MAX_EVENTS];
 

 
 
   And if this feature is not feasible then do you know any work around ?
 
   And if you think you like this idea, then can you please suggest me the
place to edit ? Because I have little experience working on your compiler
code..
 
 
-- 
-- Thanks
 
Kamanashis Roy

___
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] Volatile is supported or not?

2012-08-09 Thread Tal Hadad

I have to use volatile variables in my project. The alternative is to
allocate a new memory slice and use this pointer, or disable
optimizations.
Currently, when I define a field, variable or parameter with "volatile"
keyword, i get error, so I guess it's not supported yet.
However, here[0] it's mentioned it was suspended since it has
some bug. I don't know what is the current status of this.

Please support this keyword, or at least in CCode attribute.
Volatile has few advantage since the pointer to itself is constant:
1. It can safely be written or read into even after the call to the
method which take its pointer to it. e.g.:
volatile int some;
int* saved_pointer;
void save_ponter (volatile int* pointer) {
saved_pointer = pointer;
}

int read_ponter () {

return saved_pointer;

}

It can be safely done only with volatile keyword.
2. I'm not sure weather GLib.AtomicInt is safe without the
volatile keyword. I know that all this method defined in the C
header with a volatile parameters, but is CC makes a global
volatile variable, or it can makes a different volatile variable each
innovation?

Is volatile supported in Vala? If not, it realy should.
Most modern languages have this "feature", so I see no reason why
it shouldn't be in Vala.

Does Jürg Billeter include this in the language?

Tal

[0] http://web.archiveorange.com/archive/v/vLjdS6l4XaRgyE44fRQu
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] [Suggestion] New class attribute - Singleton

2012-07-21 Thread Tal Hadad

Currently, it is hard to create pure singleton in Vala. Sure, I can implicate 
myself
get_instance() method and make all constructors private, but outside usage of
the type could call g_object_new(type) and ruin it all.
An example for this would be the libpeas plugin extensions registration(by
type).

There is a solution for that, introduced here:
http://blogs.gnome.org/xclaesse/2010/02/11/how-to-make-a-gobject-singleton/

This attribute[Singleton], shell is relevant for all class types:
* GObject derived
* Non GObject classes
* Compact classes
No classes constructor are allowed(even private).
Only "construct {}" block is allowed.
Of course finalizers would act normal(both for ref_counted and not, see next).

this attribute shell have this properties:
1. "thread_safe"-bool: Whether construction should be thread safe or not.
Default: false.
Exported to Vapi binding.
2. "mutual_lock"-bool: Whether the lock for thread safety is mutual, or 
int-lock.
Most constructors shell have int-lock(inter lock) since it's non block
operation, but some constructor have blocking operations, so it is better to
have mutual lock for them.
Default: false.

Doesn't exported to Vapi binding.
Ignored if thread_safe=false.
3. "ref_counted"-bool: Whether the instance is ref counted or not(live for 
ever).
If true, get_instance() shell return owned instance, otherwise, an owned
instance.
Default: false.

Exported to Vapi binding.
Ignored(live forever) if the class is compact and doesn't have ref_function and
unref_function in CCode attribute.
4. "get_instance_func"-string: Name of the generated func for getting the
instance, or null to default method("get_instance")

Default: null.

Exported to Vapi binding.

I think it will be great if Vala would support this. It will makes Singleton 
more
pure and easier.
I know some of you may think Singletons are bad, but it has good usage(at
least for me).
What do you think?

Tal
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Seg fault when trying to pass args to gtk_init_check.

2012-07-18 Thread Tal Hadad

Thanks about the solution.
I thought about this solution earlier as fail safe, but it just didn't seen 
right to
force the user to use my way all along main(and not natural).
However, I've ended up using another way to make this easy in Vala:
namespace Max {
[CCode (has_target="false")]
public delegate bool ArgsBoolFunc ([CCode (array_length_pos = 0.9)] ref 
unowned string[] args);
private delegate bool ArgsBoolFuncC (int* argsc, char*** argsv);
public bool pass_args_bool (ArgsBoolFunc func) {
ArgsBoolFuncC func_c = (ArgsBoolFuncC)func;
return func_c (argsc, argsv); 
}
}

I've also copy the code for the void and int types.
This hide complexity from the user which I see as the best solution so far.

I've just hoped that there could be some pointer to "ref" conversion in Vala,
like:
void* pointer
func ((ref)pointer)

Thanks again,
Tal

> Subject: Re: [Vala] Seg fault when trying to pass args to gtk_init_check.
> From: j...@bitron.ch
> To: tal...@hotmail.com
> CC: vala-list@gnome.org
> Date: Wed, 18 Jul 2012 16:38:08 +0200
> 
> Hi Tal,
> 
> On Mon, 2012-07-16 at 20:27 +0300, Tal Hadad wrote:
> > Ok I've explained my self wrong.
> > The reason I use a pointer to string[] instead of just storing it, is that 
> > I want
> > the plugins init calls, Gtk.init_check for example, is that I want Gtk to
> > remove arguments which Gtk familiar with.
> > Then, when other init () invoked, they remove the familiar args.
> > In the end, the user returns to the main, and if unrecognized arguments
> > had left, the main shows error "Unrecognized argument".
> > 
> > Now this all thing can be done only if I use a pointer which points it to 
> > the
> > args variable in the main function:
> > main (string[] args)
> 
> I'd replace the function Max.get_args() with a variable:
> 
> namespace Max {
>   unowned string[] args;
> }
> 
> int main (string[] args) {
>   Max.args = args;
>   ... initialize plugins
>   ... use Max.args instead of args
> }
> 
> public void peas_register_types (ObjectModule module) {
>   if (!Gtk.init_check (ref Max.args)) {
>   stderr.printf ("Error: Failed to initialize Gtk.\n");
>   return;
>   }
>   stdout.printf ("Pass first\n");
> }
> 
> Regards,
> Jürg
> 
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Seg fault when trying to pass args to gtk_init_check.

2012-07-16 Thread Tal Hadad

> If argsv is supposed to represent a string array, Max.get_args() has
> been bound incorrectly. Use string[] if you mean string array - or
> char** if you have to use raw pointers but char*** is most likely wrong
> here. The correct binding is probably something like:

Ok I've explained my self wrong.
The reason I use a pointer to string[] instead of just storing it, is that I 
want
the plugins init calls, Gtk.init_check for example, is that I want Gtk to
remove arguments which Gtk familiar with.
Then, when other init () invoked, they remove the familiar args.
In the end, the user returns to the main, and if unrecognized arguments
had left, the main shows error "Unrecognized argument".

Now this all thing can be done only if I use a pointer which points it to the
args variable in the main function:
main (string[] args)

> This binding is not ideal. I recommend you to use Gtk.init_check() from
> the GTK+ bindings shipped with Vala.

I splited up the length pointer and the argsv pointer since I don't know how
to manage this all thing in one pointer in Vala, but I do take it as an 
disadvantage if I must to.

Thanks
Tal

> Subject: Re: [Vala] Seg fault when trying to pass args to gtk_init_check.
> From: j...@bitron.ch
> To: tal...@hotmail.com
> CC: vala-list@gnome.org
> Date: Mon, 16 Jul 2012 18:23:29 +0200
> 
> Hi Tal,
> 
> On Mon, 2012-07-16 at 18:02 +0300, Tal Hadad wrote:
> > int* argsc;
> > char*** argsv;
> > argsv = Max.get_args (out argsc);
> 
> If argsv is supposed to represent a string array, Max.get_args() has
> been bound incorrectly. Use string[] if you mean string array - or
> char** if you have to use raw pointers but char*** is most likely wrong
> here. The correct binding is probably something like:
> 
>   public static string[] get_args ();
> 
> > extern bool gtk_init_check (int *argc, char ***argv);
> 
> This binding is not ideal. I recommend you to use Gtk.init_check() from
> the GTK+ bindings shipped with Vala.
> 
>   Gtk.init_check (ref args);
> 
> Regards,
> Jürg
> 
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Seg fault when trying to pass args to gtk_init_check.

2012-07-16 Thread Tal Hadad

I use the libpeas plugin engine, and want to init gtk from the plugin registar 
method.
I saved the main() args in static field in my library, and the plugin registar 
method looks like this:
public void peas_register_types (ObjectModule module) {
int* argsc;
char*** argsv;
argsv = Max.get_args (out argsc);

stdout.printf ("Args count : " + (*argsc).to_string () + "\n");
stdout.printf ("First arg : " + (string)argsv[0] + "\n");

if (!gtk_init_check (argsc, argsv)) {
stderr.printf ("Error: Failed to initialize Gtk.\n");
return;
}
stdout.printf ("Pass first\n");
...
}
...
extern bool gtk_init_check (int *argc, char ***argv);

I get this output:

$$ LD_LIBRARY_PATH=. ./simple_triangle
Start to setup plugins.
Loading plugin module: backend-gtkglext1
Args count : 1
First arg : ./simple_triangle
Segmentation fault

The question is why it's make seg fault?
I tested the input, and it looks fine!
If I don't pass args to gtk_init_check, i.e.:
gtk_init_check (null, null)

It works! So what is the problem?

Thanks
Tal
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] array_length_type in CCode attribute should be applied to everything.

2012-06-16 Thread Tal Hadad


> If it _actually_ applies to something else, feel free to change the wiki.

I do believe to what said in the wiki, so I'm not gonna change it and you
must get me wrong.

I ask not why wiki said so, I ask why Vala do so?
Why Vala doesn't apply it for parameters, properties and delegates?

Tal

Date: Fri, 15 Jun 2012 18:39:18 +0200
Subject: Re: [Vala] array_length_type in CCode attribute should be applied to 
everything.
From: lethalma...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

On Fri, Jun 15, 2012 at 5:27 PM, Tal Hadad  wrote:



According to Manual/Attributes[1], the array_length_type in the CCode attribute

applies only to fields and methods.

It should be applies also for parameters, properties and delegates so why not?

If it _actually_ applies to something else, feel free to change the wiki.
-- 
www.debian.org - The Universal Operating System
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] array_length_type in CCode attribute should be applied to everything.

2012-06-15 Thread Tal Hadad

According to Manual/Attributes[1], the array_length_type in the CCode attribute
applies only to fields and methods.
It should be applies also for parameters, properties and delegates so why not?

Tal

[1] https://live.gnome.org/Vala/Manual/Attributes
  ___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] After transfering ownership of compact class, Vala still call free method

2012-05-22 Thread Tal Hadad

I'm trying to write a nodes system which is tree based. Not matter how it
works, this is part of the code:

NodesRoot root = new NodesRoot ();
stdout.printf ("Root created\n");
unowned NodesUnit unit = root.prepend_unit ();
if (unit == null)
stderr.printf ("Not working!");
stdout.printf ("Unit created\n");
Node node = new Node ();
stdout.printf ("Node created\n");
unit.prepend_node ((owned)node);
stdout.printf ("Node prepended\n");

node = null;// Ensure that node will be free before root if it will.
stdout.printf ("Node is null\n");

this is the runtime:
Root created
Unit created
Node created
Node prepended
Node is null
*** glibc detected *** ./simple_triangle: free(): invalid pointer: 
0x0190cc40 ***
=== Backtrace: =
(big memory trace)

I've noticed that in the generated C code, node get freed by Vala.
Why is it happening if I transferred ownership for the method?
Doesn't the ownership transferring make the original unowned?

Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] [Bug] Compact class as user data need to be passed as unowned

2012-04-27 Thread Tal Hadad

When I pass lambda method in non-static compact class method
block, I get this error:
error: duplicating SerializedVbo instance, use unowned variable or explicitly 
invoke copy method

The reason is that the compact class instance is in the user data,
but it's not marked as unowned.

Vala shell threat it as unowned.

Yours,
Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Allow passing ref/out as a pointer.

2012-04-15 Thread Tal Hadad

This is exactly what I meant when I post this thread.
I use your advice and use pointers for binding, so it's alternative to must 
have arrays.
Even though Luca binding(array_length_pos=-1) is great for modern language 
syntax,
it is less powerful than the old C fashion way.

Tal

Date: Sun, 15 Apr 2012 20:38:23 +0200
From: j...@vdnberg.net
To: tal...@hotmail.com
Subject: Re: [Vala] Allow passing ref/out as a pointer.


  



  
  
On 04/15/2012 12:57 PM, Tal Hadad wrote:

  You're right!
The problem is that I forgot to gl_begin () also in initialization(i.e. before 
game loop).
Thanks all!
Tal

Date: Sun, 15 Apr 2012 12:48:58 +0200
Subject: Re: [Vala] Allow passing ref/out as a pointer.
From: lethalma...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

2012/4/15 Tal Hadad 



Thanks, but this code doesn't work either:

GLuint[2] a = {2,5};

glGenBuffers (2, &a[0]);

stdout.printf ("Buffers: " + ((uint)a[0]).to_string () + ", "+ 
((uint)a[1]).to_string () + "\n");

...

public extern void glGenBuffers (GLsizei n, GLuint * ids);



Output(same):

Buffers: 2, 5



Someone knows why?

The generated C call is correct with glGenBuffers (a), with the vapi I 
mentioned earlier. Maybe it doesn't work because you are missing some GL 
context? Also, try with zeros instead of those numbers?



  

  

I had problems with the use of arrays of structs, similar to those
that one would use with Open GL, as well.



Things were even quite different after the introduction of
vala-0.14.



The main observation I made is that vala is using intermediate
variables when an array element is referenced.



The compiler generated the following eror message at some point:



'ref and out method arguments can only be used with fields,
parameters, local variables and array element access'



I had considerable problems understanding the semantics of arrays of
structs, that I did not want to copy around.



Since I did not want my arrays elements being copied, I used
pointers to the array elements, like var ai = &a [i];



where ai is a pointer-variable with the type of the structs used as
array elements. When writing var bi = b [i], you get something quite
different, bi is represented by an intermediate variable allocated
on the stack, filled with &temp, where temp is a copy of the
struct b [i]; somewhere on the stack.



This latter bi-variable has semantics that are quite different from
the pointer semantics of the ai-variable.



It is possible to pass the bi variable as an argument, without
copying the struct b [i], but the intermediate variable bi cannot be
the return value of a function.



You may be tempted to write &a [i]->fun (foo, bar) to assign
foo and bar to fields of the struct, but this does not work. The
problem is that vala creates since 0.14 as well an intermediate
struct on the stack, that receives the modifications. The target
struct that one expects to get modified is hence kept unchanged.



Instead it is needed to have a static function fun, and to call this
static function with &a[i] as additional first argument to get
the desired effect.



There are good reasons to copy structs from arrays, since it is
problematic to resize an array, as long as there are pointers to
elements of the array that are still significant.



It is however also important to understand the implications of the
copy operation. A struct element with an embedded  array instance
will copy the whole array when the struct is to be copied. This may
be what one expects when a copy of a value is made, since the value
will be copied in full detail, even if you thought that array
instances might be excluded from the copy-rule.



There are hence also good reasons to have pointers to array
elements. The problem is however that the language behaves quite
differently for similar syntactic constructs, like pointers to
structs, struct references and class references.



One solution could be to use compact class instances as a
replacement of structs in arrays. The 'only' problem is that the
sizeof a compact class instance is the size of a pointer, this is
not the same as the size of the struct that implements the compact
class. These compact class instances will live as long as the array
in which they are embedded, so there is no need to do reference
counting on individual instances. The idea would hence be to
introduce say a 'compact_struct', that behaves in all aspects of
allocation like a struct, but in all aspects of usage and access
like a class that is accessed with a pointer. This may help to keep
the semanti

Re: [Vala] Allow passing ref/out as a pointer.

2012-04-15 Thread Tal Hadad

You're right!
The problem is that I forgot to gl_begin () also in initialization(i.e. before 
game loop).
Thanks all!
Tal

Date: Sun, 15 Apr 2012 12:48:58 +0200
Subject: Re: [Vala] Allow passing ref/out as a pointer.
From: lethalma...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

2012/4/15 Tal Hadad 



Thanks, but this code doesn't work either:

GLuint[2] a = {2,5};

glGenBuffers (2, &a[0]);

stdout.printf ("Buffers: " + ((uint)a[0]).to_string () + ", "+ 
((uint)a[1]).to_string () + "\n");

...

public extern void glGenBuffers (GLsizei n, GLuint * ids);



Output(same):

Buffers: 2, 5



Someone knows why?

The generated C call is correct with glGenBuffers (a), with the vapi I 
mentioned earlier. Maybe it doesn't work because you are missing some GL 
context? Also, try with zeros instead of those numbers?


-- 
www.debian.org - The Universal Operating System
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Allow passing ref/out as a pointer.

2012-04-15 Thread Tal Hadad

Thanks, but this code doesn't work either:
GLuint[2] a = {2,5};
glGenBuffers (2, &a[0]);
stdout.printf ("Buffers: " + ((uint)a[0]).to_string () + ", "+ 
((uint)a[1]).to_string () + "\n");
...
public extern void glGenBuffers (GLsizei n, GLuint * ids);

Output(same):
Buffers: 2, 5

Someone knows why?

Thanks
Tal

> Subject: Re: [Vala] Allow passing ref/out as a pointer.
> From: sergej.re...@googlemail.com
> To: tal...@hotmail.com
> CC: vala-list@gnome.org
> Date: Sun, 15 Apr 2012 12:17:15 +0200
> 
> I've written a vapi for GLEW that addresses most of the issues the GL
> vapi has. In the end I ended up using pointers everywhere since it's
> much simpler.
> I've used it in my projects for a while now, if you want I can put it up
> somewhere.
> 
> Am Sonntag, den 15.04.2012, 12:53 +0300 schrieb Tal Hadad:
> > Luca, when I test it now I get that the method don't do anything (and
> > it should).
> > Test code:
> > GLuint[2] a = {2,5};
> > glGenBuffers (a);
> > stdout.printf ("Buffers: " + ((uint)a[0]).to_string () + ", "+ 
> > ((uint)a[1]).to_string () + "\n");
> > 
> > public extern void glGenBuffers ([CCode (array_length_pos = 0.1)] 
> > GL.GLuint[] buffers);
> > 
> > And output:
> > Buffers: 2, 5
> > 
> > So it seems that it don't do anything, when it should change values.
> > My OpenGL hardware&drivers are fine.
> > The other GL code in my program display a simple triangle that
> > works 100%, and so is Compiz Fusion.
> > 
> > Do you know what is the problem?
> > 
> > Tal
> > 
> > Date: Sun, 15 Apr 2012 11:26:41 +0200
> > Subject: Re: [Vala] Allow passing ref/out as a pointer.
> > From: lethalma...@gmail.com
> > To: tal...@hotmail.com
> > CC: vala-list@gnome.org
> > 
> > 2012/4/15 Tal Hadad 
> > 
> > 
> > 
> >  There's two GL vapis in ExternalBinding page. I'm talking about
> > 
> > the one inside the brackets[0]. This is part of the vapi:
> > 
> > public static void glGenBuffers (GL.GLsizei n, [CCode (array_length = 
> > false, array_null_terminated = true)] out unowned GL.GLuint[] buffers);
> > 
> > public static void glDeleteBuffers (GL.GLsizei n, [CCode (array_length = 
> > false, array_null_terminated = true)] GL.GLuint[]? buffers);
> > 
> > 
> > 
> > The GL C API is:
> > 
> > void glGenBuffers (GLsize n, GLuint *buffers)
> > 
> > void glDeleteBuffers (GLsize n, GLuint *buffers)
> > 
> > 
> > 
> > Which n is the count of buffers, and buffers represent a pointer
> > 
> > to the first element.
> > 
> > 
> > 
> > The generation of method glGenBuffers is completely buggy (i.e.
> > 
> > failed even if I pass an GL.GLuint[] array).
> > 
> > However, the generation of the second method is OK.
> > 
> > 
> > 
> > Take a look at the first method. What the parameter should be?
> > 
> > Is it should be "out GL.GLuint first_element"?
> > 
> > public static void glGenBuffers ([CCode (array_length_pos = 0.1)] 
> > GL.GLuint[] buffers);
> > public static void glDeleteBuffers ([CCode (array_length_pos = 0.1)] 
> > GL.GLuint[] buffers);
> > 
> > ___
> > 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] Allow passing ref/out as a pointer.

2012-04-15 Thread Tal Hadad

Luca, when I test it now I get that the method don't do anything (and
it should).
Test code:
GLuint[2] a = {2,5};
glGenBuffers (a);
stdout.printf ("Buffers: " + ((uint)a[0]).to_string () + ", "+ 
((uint)a[1]).to_string () + "\n");

public extern void glGenBuffers ([CCode (array_length_pos = 0.1)] GL.GLuint[] 
buffers);

And output:
Buffers: 2, 5

So it seems that it don't do anything, when it should change values.
My OpenGL hardware&drivers are fine.
The other GL code in my program display a simple triangle that
works 100%, and so is Compiz Fusion.

Do you know what is the problem?

Tal

Date: Sun, 15 Apr 2012 11:26:41 +0200
Subject: Re: [Vala] Allow passing ref/out as a pointer.
From: lethalma...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

2012/4/15 Tal Hadad 



 There's two GL vapis in ExternalBinding page. I'm talking about

the one inside the brackets[0]. This is part of the vapi:

public static void glGenBuffers (GL.GLsizei n, [CCode (array_length = false, 
array_null_terminated = true)] out unowned GL.GLuint[] buffers);

public static void glDeleteBuffers (GL.GLsizei n, [CCode (array_length = false, 
array_null_terminated = true)] GL.GLuint[]? buffers);



The GL C API is:

void glGenBuffers (GLsize n, GLuint *buffers)

void glDeleteBuffers (GLsize n, GLuint *buffers)



Which n is the count of buffers, and buffers represent a pointer

to the first element.



The generation of method glGenBuffers is completely buggy (i.e.

failed even if I pass an GL.GLuint[] array).

However, the generation of the second method is OK.



Take a look at the first method. What the parameter should be?

Is it should be "out GL.GLuint first_element"?

public static void glGenBuffers ([CCode (array_length_pos = 0.1)] GL.GLuint[] 
buffers);
public static void glDeleteBuffers ([CCode (array_length_pos = 0.1)] 
GL.GLuint[] buffers);

-- 
www.debian.org - The Universal Operating System
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Allow passing ref/out as a pointer.

2012-04-15 Thread Tal Hadad

 There's two GL vapis in ExternalBinding page. I'm talking about
the one inside the brackets[0]. This is part of the vapi:
public static void glGenBuffers (GL.GLsizei n, [CCode (array_length = false, 
array_null_terminated = true)] out unowned GL.GLuint[] buffers);
public static void glDeleteBuffers (GL.GLsizei n, [CCode (array_length = false, 
array_null_terminated = true)] GL.GLuint[]? buffers);

The GL C API is:
void glGenBuffers (GLsize n, GLuint *buffers)
void glDeleteBuffers (GLsize n, GLuint *buffers)

Which n is the count of buffers, and buffers represent a pointer
to the first element.

The generation of method glGenBuffers is completely buggy (i.e.
failed even if I pass an GL.GLuint[] array).
However, the generation of the second method is OK.

Take a look at the first method. What the parameter should be?
Is it should be "out GL.GLuint first_element"?

Tal

[0] http://blazt.sablun.org/tmp/gl.vapi

Date: Sun, 15 Apr 2012 10:47:17 +0200
Subject: Re: [Vala] Allow passing ref/out as a pointer.
From: lethalma...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

2012/4/15 Tal Hadad 


Hello Luca

Even thought there are replacement for that, don't you think that this option 
is good?

Vala has full support of pointers except this.

I don't know unless you paste some code of what you're doing and of the vapi.
-- 
www.debian.org - The Universal Operating System
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Vala for physics simulations?

2012-04-15 Thread Tal Hadad

Can't you use Bullet C API?
http://code.google.com/p/bullet/issues/detail?id=43

> Date: Thu, 12 Apr 2012 22:51:11 +0200
> From: dura...@gmail.com
> To: lethalma...@gmail.com
> CC: vala-list@gnome.org
> Subject: Re: [Vala] Vala for physics simulations?
> 
> Luca, I'm not using any physics engine. I have to start from scratch
> because I need something very specific anyway. At the moment, I've
> been using code written in fortran and have used another written in C
> so I'm pretty sure Vala would be fine. I just wanted to see if someone
> else has add any experience with this kind of stuff.
> 
> Cheers!
> 
> On 12 April 2012 19:28, Luca Bruno  wrote:
> > On Thu, Apr 12, 2012 at 6:16 PM, Durand  wrote:
> >>
> >> Hey,
> >>
> >> I'm considering using Vala to write a stellar evolution code which
> >> needs to be pretty efficient in utilizing memory and cpu cycles. Is
> >> there anything I'd need to be concerned about before using Vala for
> >> this purpose? I guess the main features of the code will be the use of
> >> large arrays. I'm also quite new to writing efficient code so I'm
> >> wondering whether it is sensible to use libgee arrays and maps or to
> >> stick to the basic arrays. As Vala is basically just C, I'm assuming
> >> that efficiency is comparable to native C code but that might be a
> >> little naive.
> >>
> >> Any advice is much appreciated!
> >
> >
> > Most physics engines out there are C++, and Vala can't handle C++ (not yet).
> >
> > --
> > www.debian.org - The Universal Operating System
> ___
> 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] Allow passing ref/out as a pointer.

2012-04-15 Thread Tal Hadad




Hello Luca
Even thought there are replacement for that, don't you think that this option 
is good?
Vala has full support of pointers except this.

Tal

Date: Thu, 12 Apr 2012 19:32:46 +0200
Subject: Re: [Vala] Allow passing ref/out as a pointer.
From: lethalma...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

2012/4/12 Tal Hadad 



Can you please allow to cast a pointer type into ref/out?

I mean to allow this:

method ((ref) pointer,...)

Same for the out keyword.

Because sometimes there are binding issue.

For example, glGenBuffers in gl.vapi(external) cause errors.

If it causes errors then the vapi has to be fixed.

-- 
www.debian.org - The Universal Operating System

  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Allow passing ref/out as a pointer.

2012-04-12 Thread Tal Hadad

Can you please allow to cast a pointer type into ref/out?
I mean to allow this:
method ((ref) pointer,...)
Same for the out keyword.
Because sometimes there are binding issue.
For example, glGenBuffers in gl.vapi(external) cause errors.

Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Too many arguments in generated code

2012-04-11 Thread Tal Hadad

Compact classes are 100% C structs(no GObject at all).
The difference is that compact class are threaded as a ref types, while structs
are threaded as a value types.
If the struct is used most of the time by ref type, it logically makes sense to
define it as compact class.
Compact class is logically the same as C++(with ownership transfer)

Tal

> From: t...@ubilix.com
> To: simon.werb...@googlemail.com
> Date: Wed, 11 Apr 2012 08:28:38 +0200
> CC: vala-list@gnome.org
> Subject: Re: [Vala] Too many arguments in generated code
> 
> 
> > So in your case I would bind Joint as
> > [Compact]
> > [CCode (copy_function="...", free_function="...")]
> > class Skeltrack.Joint {...}
> 
> thanks, following your suggestion works. What I don't get however is why
> Vala requires a class to get it right where the in the original C code
> Skeltrack.Joint is a struct.
> 
> --tomw
> 
>   
> 
> ___
> 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] Posix Bindings

2012-04-04 Thread Tal Hadad

It comes with Vala installation.
It shell be the location $(prefix}/share/vala-0.xx/vapi/posix.vapi.
For example, in my Debian machine, it's is /usr/share/vala-0.16/vapi/posix.vapi

If for some reason you still can't find them installed, you can dig in Vala 
tarballs.

Yours,
Tal

Date: Wed, 4 Apr 2012 22:05:49 +0100
From: davidrafago...@gmail.com
To: vala-list@gnome.org
Subject: [Vala] Posix Bindings

Hello everyone,
 
Where can I find Posix bindings for Vala? I found
https://github.com/ony/heatoff/blob/master/posix-regex.vapi, but that is
posix-regex.
 
My application uses the Posix namespace, and I can't find .vapi's for it,
or the source code so that I can build it and install it.
 
Any idea?
 
Thank you.
 
-- 
David Gomes

___
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


[Vala] Calling to a non-static member of a null object

2012-04-02 Thread Tal Hadad

Just wanted to share with you some weird thing in Vala.
I'll give an example to what I said in the title:
This code return access to method denied:
MainContext.iteration (null, false)
See GLib docs[1]. You can pass null and it means the default main loop context.
But how can we perform method for null?
So, you need to cast null to (MainContext?). It looks like that:
((MainContext?)null).iteration (false)

Don't know if you threat this as an bug in architecture or not, just want to 
share it.

[1] 
http://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html#g-main-context-iteration
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Boxed type generics

2012-03-20 Thread Tal Hadad

Even known it's doesn't sound like that, and it's work in .Net, double? is 
always
a pointer type. It's the same as double*. This explains the first example error.
In the second one, you convert some type to double* and then to double(in the
deceleration "double tmp"). The compiler seems to ignore the first conversion,
and skip to the second.

In conclusion, use (double) instead of (double?). If you want to achieve a null
passing in by value(i.e. not pointer), pass another Boolean which tells if it's
empty.

Yours,
Tal

> Date: Mon, 19 Mar 2012 13:59:33 +0100
> From: step...@ecshi.net
> To: vala-list@gnome.org
> Subject: [Vala] Boxed type generics
> 
> Hello,
> 
> I'd like to do something like the following (somewhat oversimplified):
> 
> public T increment (T number) {
> return (double?) number + 1;
> }
> public static void main () {
> stdout.printf("%f\n", increment (4.7));
> }
> 
> Unfortunately the C-compiler complains about not being able to convert
> the double to a pointer type in the return statement.
> I have found out this works as expected:
> 
> public T increment (T number) {
> double tmp = (double?) number;
> tmp += 1;
> return &tmp;
> }
> 
> This, however, seems not to be the right thing to do. Could someone
> explain how to handle those boxed types correctly without resorting to
> the address-of-operator?
> 
> Thanks,
> 
> Stephan
> 
> ___
> 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] c#/mono to vala converter

2012-03-19 Thread Tal Hadad

In Google search, I get only 4 irrelevant results.
Don't waste your time for searching that kind of thing.
Vala logic is far different from .Net logic, so even if there were such thing,
it was better to convert it manually.
As far as I can see that, only class methods(head only), structures,
properties and emuns can be converted.
Interfaces and the inside/actual method code can't be logically converted
automatically.
I didn't mention fields because I'm doubt in it.

Don't get me wrong. Converting your code to Vala is a smart decision.

(I also emigrated from C#.)
You shell read this first:
https://live.gnome.org/Vala/ValaForCSharpProgrammers

Good luck!
Tal

Date: Mon, 19 Mar 2012 14:44:47 +1000
From: micta...@gmail.com
To: vala-list@gnome.org
Subject: [Vala] c#/mono to vala converter

Hello,
is there a converter to get Vala from c#/mono code?
 
Thank you in advance.

___
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] Purple.CoreUiOps

2012-02-24 Thread Tal Hadad

> Shouldn't compact class install a default constructor when no 
> constructor was provided by user?

I don't think so, because it's only a VAPI wrapper.
But if it so bugging you, you can decelerate new methods(and I think that also
constructs) in the binding.

> Besides, what's the difference between compact class and struct when 
> wrapping non-gobject C lib? Should we always use public struct when 
> wrapping C structs?

The different is from Vala side- structs are threaded(unless using
pointers-struct*) as by value variables, and compact(and non-compact)
classes threaded as by reference(pointers in C) variables.

Yours,
Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Sample app built with ninja+vala

2012-02-19 Thread Tal Hadad

You mention Tup, which I see this as a great tool.
But have anyone found an autoconf alternative for Tup?

Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Create an instance of a derived class, from a base class method

2012-02-19 Thread Tal Hadad

It's not for you at all(and won't solve anything), but take a look at this 
example:
https://live.gnome.org/Vala/GStreamerSample

> Date: Sun, 19 Feb 2012 13:24:31 +
> Subject: Re: [Vala] Create an instance of a derived class, from a base class 
> method
> From: blowb...@gmail.com
> To: tal...@hotmail.com
> CC: vala-list@gnome.org
> 
> 2012/2/19 Tal Hadad :
> >
> > I don't understand what is your purpose:
> > I don't understand why you don't use constructors, or static methods.
> 
> I'd got myself in a bit of a mess inheriting singleton factory classes
> and static properties/methodscoming from a C background, I get a
> bit over-exciteable around OO. I've since refactored with templates
> and accepted the 'singletons are evil' lore, which has made everything
> a lot simpler.
> 
> > See, the type deceleration must be explicit at complication time.
> > However, if you don't want it, you can always use generics and the 
> > "dynamic" word.
> 
> Meh, I very much like the concept of 'complication time'. What is this
> 'dynamic' keyword of which you speak?
> 
> cheers
> ant
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Create an instance of a derived class, from a base class method

2012-02-19 Thread Tal Hadad

I don't understand what is your purpose:
I don't understand why you don't use constructors, or static methods.

See, the type deceleration must be explicit at complication time.
However, if you don't want it, you can always use generics and the "dynamic" 
word.

In simple words, as far as I know, what you want to achieve isn't possible(but 
could be manually implicated).

Yours,
Tal

> Date: Sat, 18 Feb 2012 15:51:55 +
> From: blowb...@gmail.com
> To: vala-list@gnome.org
> Subject: [Vala] Create an instance of a derived class,from a base 
> class method
> 
> Hi,
> 
> I am trying to craft a base class method, that is able to create an
> object of the same class as whatever derived-class object it was
> called on.
> 
> For example, if classes Bar and Baz both derive from Foo, and Foo has
> a create() method, then bar.create() should give me an instance of
> Bar, and Baz.create() should give me an instance of Baz.
> 
> I've spent so long happily experimenting with this that I forgot the
> original requirement. but I have come up with two approaches that
> almost work (below).
> 
> Everything is fine at run-time, but I have to resort to ugly casts
> like "Derived obj = derived.foo() as Derived" to get valac to accept
> it.
> 
> I think the return type ('Base') of foo() is my problem, but I'm at a
> loss as to what to replace it with to make this work.
> 
> Is there a better way to achieve this sort of thing?
> 
> 
> 
> 
> public class Base : GLib.Object {
> public Base foo() {
> Type t = this.get_type();
> return Object.new(t) as Base;
> }
> }
> 
> public class Derived : Base {
> public void test() {
> stdout.printf("I am an instance of Derived!\n");
> }
> }
> 
> //
> 
> /* second attempt with abstract methods */
> public abstract class Base2 : GLib.Object {
> public Base2 foo() {
> return new_instance();
> }
> protected abstract Base2 new_instance();
> 
> }
> 
> public class Derived2 : Base2 {
> 
> /* return type has to be Base2 or vala won't allow the override */
> public override Base2 new_instance() {
> return new Derived2();
> }
> 
> public void test() {
> stdout.printf("Derived2: I am an instance of Derived2!\n");
> }
> }
> 
> 
> //
> 
> 
> public static int main(string[] args) {
> 
> #if false
> Derived derived = new Derived();
> Derived obj = derived.foo(); // 'cannot convert from Base to Derived?'
> #else
> Derived derived = new Derived();
> Derived obj = derived.foo() as Derived; // ugly!
> #endif
> 
> Type t = obj.get_type();
> stdout.printf("Type of obj is %s\n", t.name());
> obj.test();
> 
> 
> /* second attempt with abstract methods */
> #if false
> Derived2 derived2 = new Derived2();
> Derived2 obj2 = derived2.foo(); // 'cannot convert from Base to Derived?'
> #else
> Derived2 derived2 = new Derived2();
> Derived2 obj2 = derived2.foo() as Derived2; // ugly!
> #endif
> 
> Type t2 = obj2.get_type();
> stdout.printf("Type of obj2 is %s\n", t2.name());
> obj2.test();
> 
> 
> return 0;
> }
> 
> 
> cheers
> ant
> ___
> 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


[Vala] Type initialization error in gnome3(fallback) applet experiment.

2012-01-05 Thread Tal Hadad

I try to support my project(MPRIS Applet) into GNOME3 fallback mode, as an in 
process applet.

But I run into a trouble- I got an error while loading this applet.
For debug it I typed in one terminal:
startx gnome-session-fallback -- :1

Inside the gnome session I restarted gnome-panel(when my applet is in the panel 
with failure), by:
gnome-panel --replace

Then, I get this error log:

...
...

(gnome-panel:24097):
 Gtk-WARNING **: Theme parsing error: gtk-widgets.css:858:36: Failed to 
import: Error opening file: No such file or directory

(gnome-panel:24097):
 GLib-GObject-WARNING **: 
/tmp/buildd/glib2.0-2.30.2/./gobject/gsignal.c:2295: signal 
`size_request' is invalid for instance `0x2046da0'

** (gnome-panel:24097): WARNING **: Failed to get pixmap 14680140, 923, 0

** (gnome-panel:24097): WARNING **: Failed to get pixmap 14680140, 78, 0

** (gnome-panel:24097): WARNING **: Failed to get pixmap 14680140, 0, 0

(gnome-panel:24097): Gtk-CRITICAL **: gtk_drag_set_icon_gicon: assertion `icon 
!= NULL' failed

(gnome-panel:24097): GLib-GObject-CRITICAL **: g_object_unref: assertion 
`G_IS_OBJECT (object)' failed

(gnome-panel:24097):
 GLib-GObject-WARNING **: specified class size for type `MainApplet' is 
smaller than the parent type's `PanelApplet' class size

(gnome-panel:24097): GLib-CRITICAL **: g_once_init_leave: assertion 
`initialization_value != 0' failed
**
ERROR:panel-applet.c:2535:_panel_applet_factory_main_internal: assertion 
failed: (g_type_is_a (applet_type, PANEL_TYPE_APPLET))
Aborted
$ 

The "..." is GTK warning about the theme, very long and isn't related.
It is happening because of invalid type initialization, somehow class is 
smaller then parent.
At
 first, I thought it is invaild/outdated headers problem. But in my 
Debian machine, the -dev package is in the same version of the library 
package
of libpanel-applet-4.0(3.2.1-2+b1).
I even tried to add fields and virtual methods as a desperate solution, but 
still haven't helped.

Therefore I made&uploaded a little example of this problem packed into a 
autoconf tarball so you can test it by yourself:

http://www.mediafire.com/?g9xsaaybpn386ej

About the source files:
src/register.c: A convenient GMoudle register file into in process applet, 
since Vala doesn't support this kind of macros.
src/main_applet.vala: The applet it self.

Here is a nice example how it shell look in C, the Fish applet example:
http://gnome-panel.sourcearchive.com/documentation/3.0.2-1/fish_8c_source.html

Can you please see why the type fail to be initialized?

Thanks
Tal

  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] vapigen ignores .metadata

2012-01-04 Thread Tal Hadad

> 1) Please _always_ write down any warning or error
> 2) Use skip instead of hidden=true 
Result:
PanelApplet-4.0.metadata:2.13-2.27: warning: metadata never used
PanelApplet.add_preferences skip=true
^^^
Generation succeeded - 1 warning(s)


Date: Wed, 4 Jan 2012 12:51:06 +0100
Subject: Re: [Vala] vapigen ignores .metadata
From: lethalma...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

2012/1/4 Tal Hadad 



Thanks, but I have a new problem:

How can I access to class methods? This line doesn't work and raise warning:

PanelApplet.add_preferences hidden=true

1) Please _always_ write down any warning or error
2) Use skip instead of hidden=true 

-- 
www.debian.org - The Universal Operating System
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] vapigen ignores .metadata

2012-01-04 Thread Tal Hadad

Thanks, but I have a new problem:
How can I access to class methods? This line doesn't work and raise warning:
PanelApplet.add_preferences hidden=true

Tal

Date: Wed, 4 Jan 2012 12:03:58 +0100
Subject: Re: [Vala] vapigen ignores .metadata
From: lethalma...@gmail.com
To: tal...@hotmail.com

2012/1/4 Tal Hadad 





Thanks, it works as expected.
But I were reading other manual:
http://live.gnome.org/Vala/Manual/GIDL%20metadata%20format

Since it was mention in:
http://live.gnome.org/Vala/Bindings
What is the different between this two "metadata" formats?


GIDL is the old introspection that is inside Vala only. GIR is the new format 
adopted by gnome.
-- 
www.debian.org - The Universal Operating System
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] vapigen ignores .metadata

2012-01-04 Thread Tal Hadad




Thanks, it works as expected.
But I were reading other manual:
http://live.gnome.org/Vala/Manual/GIDL%20metadata%20format
Since it was mention in:
http://live.gnome.org/Vala/Bindings
What is the different between this two "metadata" formats?

Thanks
Tal

Date: Wed, 4 Jan 2012 11:40:08 +0100
Subject: Re: [Vala] vapigen ignores .metadata
From: lethalma...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

2012/1/4 Tal Hadad 



I try to create a binding from GNOME official PanelApplet-4.0.gir to 
libpanelapplet-4.0.vapi.

Vapi generation success, but the header file name is wrong(always 
"PanelApplet-4.0.h"). I tried to change it by adding a new file named 
"libpanelapplet-4.0.metadata" in the same directory:



PanelApplet cheader_filename="libpanel-applet/panel-applet.h"



But it didn't change anything in the vapi file.

This is my command(based on what you gave me in this mailing list):



vapigen --metadatadir . --pkg gtk+-3.0 --library libpanelapplet-4.0 
PanelApplet-4.0.gir



What am I doing wrong?

As per http://live.gnome.org/Vala/Manual/GIR%20metadata%20format :
"The filename of a metadata for a SomeLib.gir must be SomeLib.metadata."


Therefore, it must be PanelApplet-4.0.metadata . 
-- 
www.debian.org - The Universal Operating System

  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] vapigen ignores .metadata

2012-01-04 Thread Tal Hadad

I try to create a binding from GNOME official PanelApplet-4.0.gir to 
libpanelapplet-4.0.vapi.
Vapi generation success, but the header file name is wrong(always 
"PanelApplet-4.0.h"). I tried to change it by adding a new file named 
"libpanelapplet-4.0.metadata" in the same directory:

PanelApplet cheader_filename="libpanel-applet/panel-applet.h"

But it didn't change anything in the vapi file.
This is my command(based on what you gave me in this mailing list):

vapigen --metadatadir . --pkg gtk+-3.0 --library libpanelapplet-4.0 
PanelApplet-4.0.gir

What am I doing wrong?

Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Vapigen failure for PanelApplet-4.0.gir

2011-12-26 Thread Tal Hadad

Thanks didn't thought --pkg is needed.
Thanks
Tal

> Subject: Re: [Vala] Vapigen failure for PanelApplet-4.0.gir
> From: a.kito...@gmail.com
> To: tal...@hotmail.com
> CC: vala-list@gnome.org
> Date: Mon, 26 Dec 2011 17:49:43 +0100
> 
> Hello,
> 
>في ن، 26-12-2011 عند 17:07 +0200 ، كتب Tal Hadad:
> > I try to generate vapi for PanelApplet-4.0(since vala don't include version 
> > 4.0), but
> > vapigen fails:
> > $ vapigen --library libpanel-applet-4.0 PanelApplet-4.0.gir
> 
> Generally, a good idea is to use the vapis wherever possible, adding
> --pkg gtk+-3.0 should get you closer (if not fix your problem).
> 
> HTH,
> Abderrahim
> 
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] create a tar ball

2011-12-26 Thread Tal Hadad

As a first step,try vala-project-generator:
http://blogs.gnome.org/juergbi/2007/11/25/vala-project-generator/
Also, see this example(Sampala):
http://github.com/tadeboro/Sampala
Good luck!
Tal

> Date: Mon, 26 Dec 2011 17:36:06 +0200
> From: dr3...@gmail.com
> To: vala-list@gnome.org
> Subject: [Vala] create a tar ball
> 
> hello I am new to programming in  linux and i find my self lost
> i have written a small app in vala glade gtk3 and i want to create a
> tarball for testers so others
> can
> ./configure
> make
> make install
> 
> and i read about autotools / automake /cmake
> but i can;t find easy tutorial step by step that help me
> please if any one can reply with help i will appreciate it
> 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


[Vala] Vapigen failure for PanelApplet-4.0.gir

2011-12-26 Thread Tal Hadad

I try to generate vapi for PanelApplet-4.0(since vala don't include version 
4.0), but
vapigen fails:
$ vapigen --library libpanel-applet-4.0 PanelApplet-4.0.gir

(vapigen:29191): GLib-CRITICAL **: g_str_has_suffix: assertion `str != NULL' 
failed

** (vapigen:29191): CRITICAL **: vala_gir_parser_node_lookup: assertion `name 
!= NULL' failed
Gio-2.0.gir:44595.7-44599.24: error: `UnixSocketAddress' already contains a 
definition for `abstract'
Gio-2.0.gir:44475.7-44477.103: note: previous definition of `abstract' was here
Generation failed: 1 error(s), 0 warning(s)
$ 

Why it fails?
My valac is 0.14.0-1, in Debian wheezy.
Link to download gir: http://www.mediafire.com/?niqun6wbobpg6r9
Can someone please test it in his machine?

Thanks
Tal

  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Can adding new virtual method break ABI?

2011-12-23 Thread Tal Hadad

>If you need to do these things manually, then what's the point in using
>vala? It's the job of compilers.I got a proposed solution, please say if you 
>agree.

First, make a new attribute called "ClassStruct" with the field 
virtual_methods_total, which is the total virtual methods(used + unused).
This can't be decided automatically, since it doesn't know how many virtual 
methods the developer think of.

Secondly, use a half human half machine file called by default vala_abi_doc, 
which keeps the position of any generated virtual method.
The developer can do this manually before the compiler choose position, or let 
the compiler do this autocratically. The next compiler will
respect the offsets that has been chose. This file of course must be shipped 
with the library.

The first one solve the padding issue, the second solve the ordering issue.

Please share your opinion,
Tal

Date: Sat, 17 Dec 2011 12:01:45 +0800
From: pcman...@gmail.com
To: mikkel.kamst...@gmail.com
CC: vala-list@gnome.org
Subject: Re: [Vala] Can adding new virtual method break ABI?

If you need to do these things manually, then what's the point in using
vala? It's the job of compilers.
People who like to do the job of compilers manually should use GObject/C
instead.
Manually filling a virtual function table and calculate offset of
pointers are really of fun. lol
Creating some empty functions for padding is even easier and more readable
IMO.
 
On Wed, Dec 14, 2011 at 6:15 PM, Mikkel Kamstrup Erlandsen <
mikkel.kamst...@gmail.com> wrote:
 
> On 12 December 2011 12:15, Jürg Billeter  wrote:
> > On Mon, 2011-12-12 at 12:12 +0100, Luca Bruno wrote:
> >>
> >> On Mon, Dec 12, 2011 at 12:01 PM, Jürg Billeter  wrote:
> >>     On Sun, 2011-12-11 at 11:34 +0100, Luca Bruno wrote:
> >> > 2011/12/11 Tal Hadad 
> >> >
> >> > > This idea is based on the assumption that the size of
> >> XClass struct
> >> > > doesn't matter and can be changed(Am I right?).
> >> > > Also, how does the virtual method order is currently done
> >> by Vala? Is it
> >> > > alphabetic or by the order of the decelerations?
> >> > >
> >> >
> >> > The ordering does not matter, the padding does.
> >>
> >> Ordering matters as well. Vala uses declaration order.
> >>
> >> We're talking about virtual methods, aren't we? There's no ABI break
> >> if the order of N pointers is exchanged.
> >
> > When a subclass overrides a virtual method, the class_init function uses
> > the offset of the virtual function pointer. If that offset changes, the
> > subclass will need to be recompiled to work again.
>
> Indeed.
>
> Would it make sense to a [CCode (vfunc_padding = "8")] to class
> declarations? This could then be decremented when new virtual
> functions are added (to the end of the class!).
>
> Cheers,
> Mikkel
> ___
> 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
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Can adding new virtual method break ABI?

2011-12-11 Thread Tal Hadad

> Yes it does. What C programmers often do is adding unused vfuncs as 
padding for future extension of the class. From this perspective Vala 
could theoretically add some kind of padding to avoid abi breakage.
So what about this idea for fix it:
Create a new attribute property in [CCode], named binary_position, that is used 
for virtual methods, but can be used for another things(such as fields, etc.).
It can be used by the developer to avoid this risk, by doing so:
Every time the developer create a new virtual method, he shell pick the 
smallest number available for virtual method position, and put it in 
binary_position in [CCode].
On every planned ABI(&API) break, he can minimize those binary_position(s) for 
virtual methods.

This idea is based on the assumption that the size of XClass struct doesn't 
matter and can be changed(Am I right?).
Also, how does the virtual method order is currently done by Vala? Is it 
alphabetic or by the order of the decelerations?

Thanks
Tal

Date: Sun, 11 Dec 2011 10:48:21 +0100
Subject: Re: [Vala] Can adding new virtual method break ABI?
From: lethalma...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

2011/12/11 Tal Hadad 



I've read how GObject define virtual methods, in the XClass struct, and

I'm afraid defining new virtual method can break ABI. Am I right?

Before:

struct _XClass

{

GObjectClass parent_class;



/* stuff */

void (*do_action) (X *self, /* parameters */);

};



After:

struct _XClass

{



GObjectClass parent_class;





/* stuff */





void (*another_action) (X *self, /* parameters */);



void (*do_action) (X *self, /* parameters */);



};



Can this case break ABI?


 Yes it does. What C programmers often do is adding unused vfuncs as padding 
for future extension of the class. From this perspective Vala could 
theoretically add some kind of padding to avoid abi breakage.

-- 
www.debian.org - The Universal Operating System
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Can adding new virtual method break ABI?

2011-12-11 Thread Tal Hadad

I've read how GObject define virtual methods, in the XClass struct, and
I'm afraid defining new virtual method can break ABI. Am I right?
Before:
struct _XClass
{
GObjectClass parent_class;

/* stuff */
void (*do_action) (X *self, /* parameters */);
};

After:
struct _XClass
{

GObjectClass parent_class;


/* stuff */


void (*another_action) (X *self, /* parameters */);

void (*do_action) (X *self, /* parameters */);

};

Can this case break ABI?

Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] [Bug?] Access to non-static field are permitted inside static methods

2011-11-26 Thread Tal Hadad

I've noticed now after finding a bug in my program, that access to
non-static field are permitted inside static methods!
I didn't believed no one was noticed this until now...
Here is a code shows the behavior:
class A {
  int num = 0;
  static void foo () {
if (num == 0)
  num++;
  }
}

Vala compiles "num" in "foo" into an unsigned _tmp*_.
Hope it was helpful.

Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] How to cast Gdk.EventKey to Gdk.Event ?

2011-11-26 Thread Tal Hadad

Gdk.Event* real_e = (Gdk.Event*)(&e);
It's tested.

Gdk.Event* is an unowned Gdk.Event, only different is syntax:
(Gdk.Event)instance = (Gdk.Event*)->instance

Tal

Date: Fri, 25 Nov 2011 23:48:59 -0500
From: shawn.p.hu...@gmail.com
To: vala-list@gnome.org
Subject: [Vala] How to cast Gdk.EventKey to Gdk.Event ?
How to cast Gdk.EventKey to Gdk.Event in vala?
 
some code like, but it does not compile.
 
100 public override bool key_release_event(Gdk.EventKey e) {
101 if (m_primary_modifier !=
KeybindingManager.keyval_to_modifier(e.keyval))
102 return true;
103
104 if
(KeybindingManager.primary_modifier_still_pressed((Gdk.Event)e))
105 return true;
106
107 hide();
108 return true;
109 }
 
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


[Vala] How to cancel async GIO DBus method?

2011-11-24 Thread Tal Hadad

Async GIO method can be canceled by Cancelable.
Is there any way to cancel async DBus method by GIO?

This is the method I may need to cancel:
[DBus (name = "org.freedesktop.DBus")]
internal interface MasterDBus : GLib.Object {
public abstract async string[] list_names () throws IOError;
}

Thanks,
Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] play mp3 file

2011-11-11 Thread Tal Hadad

It's not a single row, but it easy than it looks like:
http://live.gnome.org/Vala/GStreamerSample

Tal

Date: Fri, 11 Nov 2011 12:06:06 -0200
From: rodrigo.heref...@gmail.com
To: vala-list@gnome.org
Subject: [Vala] play mp3 file

Hi all, i need to play a mp3 file on a vala program, is there any easy way
doing that?
 
-- 
Rodrigo Cesar Herefeld

___
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] How to generate "inline" C functions?

2011-11-07 Thread Tal Hadad

> Is there any CCode attribute to make the generated C function "inline"?
> Or, is it possible to generate C macros instead of functions with vala?
>
> For example:
> class Test {
>   inline public void func1() {
>   }Vala tutorial sadly doesn't say a word about it, but it shell look 
> like:public inline void func1() {}This onw works currently in vala.>   [Macro]
>   public void func2() {
>   }
> }
 
This is sound a great feature request.But I would like that the macro could 
also not be function-like, butalso be able to define functon,  varibles, 
...(i.e. full featured CMacro).
 
> Another question is, is it possible to use bit-field in vala classes?
> Like this:
> class Test {
>   private bool b1 : 1;
>   private bool b2 : 1;
>   private bool b3 : 1;
>   private uint i1 : 4;
> }
Good feature request.Tal  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] How to get the result of signal when emitting it?

2011-10-18 Thread Tal Hadad

Is this possible to get the result(return) of signals handlers?
Take for example some of Gtk signals. Sometimes the docs say something like 
that:
...
return : FALSE for continue event further, TRUE otherwise.

I wonder, is it possible in Vala? If not, I'll have to use a delegate property.

Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] The right way to compare file timestamp?

2011-10-18 Thread Tal Hadad

OK, I got this fixed.
Just switch
FileInfo info = file.query_filesystem_info ("*");
with
FileInfo info = file.query_info ("standard::content-type,time::modified", 0, 
null);
Thanks to cheese source code.
Tal

From: tal...@hotmail.com
To: vala-list@gnome.org
Date: Sun, 16 Oct 2011 16:22:42 +0200
Subject: [Vala] The right way to compare file timestamp?

 
I want to compare the timestamp of a given file, to see whether
a modification warning shell be given.
I try to use this code as a start(with GIO package):
if (file.query_exists ()) {
FileInfo info = file.query_filesystem_info ("*");
TimeVal temp_time;
info.get_modification_time (out temp_time);
stdout.printf ("Current timestamp: " + temp_time.to_iso8601 () + "\n");
}
 
On the console, I get:
Current timestamp: 1970-01-01T00:00:00Z
 
It always stay the same no matter what I do to the file.
What is wrong with my code?
 
And another question- Can I convert this TimeVal into int64?
It will be easier to compare this way. It also said that GLib will
drop TimeVal for int64 in future on docs.
  

___
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


[Vala] The right way to compare file timestamp?

2011-10-16 Thread Tal Hadad

I want to compare the timestamp of a given file, to see whether
a modification warning shell be given.
I try to use this code as a start(with GIO package):
if (file.query_exists ()) {
FileInfo info = file.query_filesystem_info ("*");
TimeVal temp_time;
info.get_modification_time (out temp_time);
stdout.printf ("Current timestamp: " + temp_time.to_iso8601 () + "\n");
}

On the console, I get:
Current timestamp: 1970-01-01T00:00:00Z

It always stay the same no matter what I do to the file.
What is wrong with my code?

And another question- Can I convert this TimeVal into int64?
It will be easier to compare this way. It also said that GLib will
drop TimeVal for int64 in future on docs.
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] [suggestion] Make lambda generated func inline(performance)

2011-10-16 Thread Tal Hadad

I thought on this simple suggestion:
Whenever lambda expression exist, Vala translate it to func:
static (type) __lambda4_ ([args]) {
...
}

Lambda expression is used for callback, but Vala always produce
another func which is the real callback, which call lambda func
(maybe for allowing user data).
So why don't generate lambda func as inline?
It can never be recurs, so it's safe.

BTW: I recommend you to give a tip in Vala/Tutorial that if anyone
prefer to use a method instead of lambda for signal, make this
method inline for the same reason, unless this method has also a
different purpose, which inline is a bad idea.

Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] namespaces bug

2011-10-15 Thread Tal Hadad

Yes it's a disadvantage(if you look this way) of Vala, but don't think it's a 
bug.
You see, Vala is based on GObject in pure C, and the "cname" of NameSpaceName
is name_space_name...
But I your post make me wonder, shell Vala convert name_space_name to "cname"
name__space__name for compatibility, or leave it this way and do not confuse
programmers?
Lets see what the dev team have to say about it.

> Date: Sat, 15 Oct 2011 18:53:53 +0400
> From: i.nix...@gmail.com
> To: vala-list@gnome.org
> Subject: [Vala] namespaces bug
> 
> Hello list!
> 
> This simple vala-code:
> namespace NameSpaceName {int myval = 2;}
> namespace name_space_name {int myval = 3;}
> 
> void main() {
>NameSpaceName.myval = 3;
>name_space_name.myval = 4;
> }
> 
> 
> produce this C-code:
> ...
> extern gint name_space_name_myval;
> gint name_space_name_myval = 2;
> gint name_space_name_myval = 3;
> ...
> 
> 
> Thanks.
>niXman.
> ___
> 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] Passing user_data in signals is supported, but could be better.

2011-10-10 Thread Tal Hadad

I know this method, and I'm happy it's possible.
And no, I don't have problem at all while coding, I just think that Vala
shell support also other syntax.
I just wish Vala could use some thing like this:
another_object.my_signal.connect(user_data:my_method);
I wasn't a real C developer in my past, but I think they would agree that
Vala code generator shell call callbacks directly when possible, not via
the generated lambda function.
I know that there won't be an extra call at run time, if my_method be an
internal method.
I just think that if it possible to do it in other language, C practically, and 
it's not
such a bad idea, doesn't conflict with Vala mechanics, so why not?
Again, it's just a feature request, and I ask from developers and users to tell
me if it would be great to have it in Vala.
So what do you think?

From: alexandre.rosenf...@gmail.com
Date: Mon, 10 Oct 2011 14:32:15 -0300
Subject: Re: [Vala] Passing user_data in signals is supported, but could be 
better.
To: tal...@hotmail.com
CC: vala-list@gnome.org

I understand your problem, but you can still use lambdas. If you try to fool 
the compiler into taking a pointer as a user data, you end up with reference 
issues (what happens if no one uses the object but the signal handler?). The 
easiest solution is to use lambdas, so that Vala manages the references to 
objects for you automatically. And from the lambda you can call another method.


For instance, check this non-working, out-of-my-head code:

class A : Object {
void my_method(int b) {
printf("Got %d\n", b);
}
}

int main(string[] args) {
a = new A();


int i = 5;
another_object.my_signal.connect(() => {
a.my_method(i);
});
}

If you check the generated C code, you´ll see Vala created a reference-counted 
struct to hold a and i. This struct is automatically freed for you and it holds 
the a reference, so that when you free a in the main, the signal will keep 
working since it holds a reference to the data struct, which holds a reference 
to a.


If you just use pointers to try and fool the compiler into accepting an object 
as user_data, you end up having to do this management yourself and many times 
it´s actually impossible to do it right.
Alexandre Rosenfeld



2011/10/10 Tal Hadad 




Thanks for your answer Alexandre Rosenfeld, but you get me wrong.



> Why not just use lambda? From the Gtk+ example:

Yes I know I can do this. I point this out in my post:

> 2. Variables outside the lambda expression.



Some prefer using lambda, some prefer using traditional methods.

Another quote I said:

> Method 2 is done perfectly by Vala, when we talk about lambda expression.



Some(I'm included) prefer to use traditional methods than lambda.

It is easier to read, document, etc.

Don't you think it's a good idea to allow passing user_data directly

using traditional methods?

The last sentence is the whole point of my post.



From: alexandre.rosenf...@gmail.com

Date: Mon, 10 Oct 2011 12:16:13 -0300

Subject: Re: [Vala] Passing user_data in signals is supported, but could be 
better.

To: tal...@hotmail.com

CC: vala-list@gnome.org



Why not just use lambda? From the Gtk+ example:

var button = new Button.with_label ("Click me!");





button.clicked.connect (() => {





button.label = "Thank you";





this.my_data = 3;

});

And you can have that my_data be anything you want, an instance member or a 
property in any other instance (doesnt have to be from this).





Alexandre Rosenfeld



2011/10/10 Tal Hadad 









Vala does support passing a "context" argument, calling user_data to callbacks,



by this two methods(source: FAQ and Tutorial):



1. Passing "this"/self as user_data, for instance method.



2. Variables outside the lambda expression.



Method 2 is done perfectly by Vala, when we talk about lambda expression.



But method 1 is not enough... Not always it's "this"/self what that needed to be



passed.



By now, two ways to overcome this, without using lambda:



* The dirty trick:



instance.event_name.connect (((instance_type*)user_data)->method);



...



private void method ([args]) {



user_data_type* user_data = this;



// Perform action with user_data.



}







* Back to basic(using GLib.Signal namespace):



Signal.connect (instance, "event_name", (GLib.Callback)method, user_data);



...







private static void static_on_stop_clicked ([args], user_data_type user_data) {







// Perform action with user_data.







}







Both works, but I think a proper syntax should be.



I really like the instance.method way for passing callbacks, but it's valid 
only for



"this"/self. So, perhaps, instance:method for static methods?



What do you think? Shell Vala support this featur

Re: [Vala] Passing user_data in signals is supported, but could be better.

2011-10-10 Thread Tal Hadad

Thanks for your answer Alexandre Rosenfeld, but you get me wrong.

> Why not just use lambda? From the Gtk+ example:
Yes I know I can do this. I point this out in my post:
> 2. Variables outside the lambda expression.

Some prefer using lambda, some prefer using traditional methods.
Another quote I said:
> Method 2 is done perfectly by Vala, when we talk about lambda expression.

Some(I'm included) prefer to use traditional methods than lambda.
It is easier to read, document, etc.
Don't you think it's a good idea to allow passing user_data directly
using traditional methods?
The last sentence is the whole point of my post.

From: alexandre.rosenf...@gmail.com
Date: Mon, 10 Oct 2011 12:16:13 -0300
Subject: Re: [Vala] Passing user_data in signals is supported, but could be 
better.
To: tal...@hotmail.com
CC: vala-list@gnome.org

Why not just use lambda? From the Gtk+ example:
var button = new Button.with_label ("Click me!");


button.clicked.connect (() => {


button.label = "Thank you";


this.my_data = 3;
});
And you can have that my_data be anything you want, an instance member or a 
property in any other instance (doesnt have to be from this).


Alexandre Rosenfeld

2011/10/10 Tal Hadad 




Vala does support passing a "context" argument, calling user_data to callbacks,

by this two methods(source: FAQ and Tutorial):

1. Passing "this"/self as user_data, for instance method.

2. Variables outside the lambda expression.

Method 2 is done perfectly by Vala, when we talk about lambda expression.

But method 1 is not enough... Not always it's "this"/self what that needed to be

passed.

By now, two ways to overcome this, without using lambda:

* The dirty trick:

instance.event_name.connect (((instance_type*)user_data)->method);

...

private void method ([args]) {

user_data_type* user_data = this;

// Perform action with user_data.

}



* Back to basic(using GLib.Signal namespace):

Signal.connect (instance, "event_name", (GLib.Callback)method, user_data);

...



private static void static_on_stop_clicked ([args], user_data_type user_data) {



// Perform action with user_data.



}



Both works, but I think a proper syntax should be.

I really like the instance.method way for passing callbacks, but it's valid 
only for

"this"/self. So, perhaps, instance:method for static methods?

What do you think? Shell Vala support this feature?

Tal

  
___

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] Passing user_data in signals is supported, but could be better.

2011-10-10 Thread Tal Hadad

> private static void static_on_stop_clicked ([args], user_data_type user_data) 
> {

A copy&paste mistake in method name. Please threat this as:
private static void method ([args], user_data_type user_data) {

From: tal...@hotmail.com
To: vala-list@gnome.org
Date: Mon, 10 Oct 2011 15:48:45 +0200
Subject: [Vala] Passing user_data in signals is supported,  but could be 
better.

 
Vala does support passing a "context" argument, calling user_data to callbacks,
by this two methods(source: FAQ and Tutorial):
1. Passing "this"/self as user_data, for instance method.
2. Variables outside the lambda expression.
Method 2 is done perfectly by Vala, when we talk about lambda expression.
But method 1 is not enough... Not always it's "this"/self what that needed to be
passed.
By now, two ways to overcome this, without using lambda:
* The dirty trick:
instance.event_name.connect (((instance_type*)user_data)->method);
...
private void method ([args]) {
user_data_type* user_data = this;
// Perform action with user_data.
}
 
* Back to basic(using GLib.Signal namespace):
Signal.connect (instance, "event_name", (GLib.Callback)method, user_data);
...
 
private static void static_on_stop_clicked ([args], user_data_type user_data) {
 
// Perform action with user_data.
 
}
 
Both works, but I think a proper syntax should be.
I really like the instance.method way for passing callbacks, but it's valid 
only for
"this"/self. So, perhaps, instance:method for static methods?
What do you think? Shell Vala support this feature?
Tal
  

___
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


[Vala] Passing user_data in signals is supported, but could be better.

2011-10-10 Thread Tal Hadad

Vala does support passing a "context" argument, calling user_data to callbacks,
by this two methods(source: FAQ and Tutorial):
1. Passing "this"/self as user_data, for instance method.
2. Variables outside the lambda expression.
Method 2 is done perfectly by Vala, when we talk about lambda expression.
But method 1 is not enough... Not always it's "this"/self what that needed to be
passed.
By now, two ways to overcome this, without using lambda:
* The dirty trick:
instance.event_name.connect (((instance_type*)user_data)->method);
...
private void method ([args]) {
user_data_type* user_data = this;
// Perform action with user_data.
}

* Back to basic(using GLib.Signal namespace):
Signal.connect (instance, "event_name", (GLib.Callback)method, user_data);
...

private static void static_on_stop_clicked ([args], user_data_type user_data) {

// Perform action with user_data.

}

Both works, but I think a proper syntax should be.
I really like the instance.method way for passing callbacks, but it's valid 
only for
"this"/self. So, perhaps, instance:method for static methods?
What do you think? Shell Vala support this feature?
Tal
  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] How to make shared library in win32?

2011-09-01 Thread Tal Hadad

valac --pkg config --pkg gtk+-2.0 --pkg gee-1.0 --pkg libxml-2.0
 --vapidir=../vapi/ *.vala --disable-warnings --library dvw-0.1 -X
 -fPIC -X -shared -o test_shared.dll
All this in one line. You must pass this two arguments to CC(C
Compiler), which
each one comes after the "-X". See the first link you gave here for
them.
It ends with "-o test_shared.dll" which tell the output name.
As far as I know, this is the only argument in Vala which
passed to the CC without the "-X". Same relationship between
CC and linker.

> Date: Thu, 1 Sep 2011 12:16:09 +0900
> From: hoisa...@gmail.com
> To: vala-list@gnome.org
> Subject: [Vala] How to make shared library in win32?
> 
> I try to build libdvw shared library. But following error occur.
> 
> https://live.gnome.org/Vala/SharedLibSample
> http://gitorious.org/libdvw/libdvw
> 
> toddw@TODDW-PC /C/msys/home/toddw/libdvw/dvw (master)
> $ 
> 
> c:/msys/home/toddw/libdvw/dvw/util.vala.c: In function
> `_vala_dvw_point_get_property':
> c:/msys/home/toddw/libdvw/dvw/util.vala.c:586: warning: passing arg 2 of 
> `g_valu
> e_set_pointer' discards qualifiers from pointer target type
> c:/msys/home/toddw/libdvw/dvw/util.vala.c:589: warning: passing arg 2 of 
> `g_valu
> e_set_pointer' discards qualifiers from pointer target type
> c:/vala-0.12.0/lib/libmingw32.a(main.o):main.c:(.text+0xbd): undefined 
> reference
>  to `WinMain@16'
> collect2: ld returned 1 exit status
> error: cc exited with status 1
> Compilation failed: 1 error(s), 0 warning(s)
> 
> I try to use Carl's 13.1 valac environment too. But it's a same result.
> Thanks in advance for any suggetions.
> ___
> 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] Is a Direct GCallback to signals possible in vala?

2011-08-31 Thread Tal Hadad

Sorry about my mistake, I should wrote at the end:
widget.hide_on_delete()

Tal

From: tal...@hotmail.com
To: vala-list@gnome.org
Date: Wed, 31 Aug 2011 17:23:30 +0300
Subject: [Vala] Is a Direct GCallback to signals possible in vala?

 
I take a look in the generated C code, and I thought, does signal handling
have to be two stages? It possible to do it on 1 stage, right?
I'll give an example that shows this behavior:
Take a look on gtk_widget_hide_on_delete method in GTK. This method
were ment to be used as direct callback to delete-event, for popup hiding
popup windows when user click something outside of this window.
I thought I'll embrace it in my Vala code, but I run into a little mess- access
to this method denied. This is because of vala behavior a.foo (...) instead
of ..._foo (a, ...) .
I "fixed" this by adding Gtk.widget_hide_on_delete to my low_binding.vapi
file. So this is how it looked:
[CCode (cheader_filename = "gtk/gtk.h", cname_prefix = 
"gtk_widget_hide_on_delete")]
public static bool widget_hide_on_delete (Widget widget);
 
But then I get:
error: Argument 1: Cannot convert from`Gtk.widget_hide_on_delete' to 
`Gtk.Widget.delete_event'
I tried to add a parameter named "Gdk.Event event" to the method above.
I get error from CC that too many arguments in this method, which were only
logical to me after I looked on the generated code. So far, the only way to use
this method is by writing another method or lambda that calls to:
Widget.hide_on_delete (widget)
Is it possible to do it by a single GCallback? I'm talking only about static
methods, because that for the others have the "self" order problem.
  

___
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


  1   2   >