Re: [Vala] Abstract class constructors and ABI compatibility

2019-09-27 Thread Jens Georg
Hi.
> 
> I noticed public constructors of abstract classes are no longer
> allowed since Vala 0.45.1.
> 
> Does changing the public constructors to protected break ABI
> compatibility?

No. The C code is identical.


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


Re: [Vala] ValaForCSharpProgrammers "No partial classes"

2019-02-09 Thread Jens Georg


> 
> If here some dev's just let me say that "partial classes" are
> elementary 
> for C# developers.
> 
> The reason is, to split functionality in smaller source-files.

That is kind of a two-edged sort. Personally, I think if your class
gets so big that you feel the need to distribute your class into
several files, you might need to have a round of design review. 


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


Re: [Vala] Newbie need help

2018-10-23 Thread Jens Georg




valac - The standard Vala compiler
Vala - A programming language. (Description, Specification,...)


That isn't the complete truth, there is also vala, the "interpreter" 
that on-the-fly compiles the vala code and runs it - which works ok for 
simple files e.g. if you need to check something quickly

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


Re: [Vala] Using databases with Vala

2018-05-07 Thread Jens Georg
On Thu, 2018-03-08 at 21:03 -0500, Steven Oliver wrote:
> I want to begin working an application that would have a database,
> specifically SQLite, as a back-end. I know that at some point
> sqlheavy
> (https://github.com/nemequ/sqlheavy) was an option for using
> databases
> with Vala. It doesn't appear to be maintained anymore though. Are
> there other options out there? What do most people use? Are there any
> good open source vala projects using SQLite I could look to as an
> example? The only one I'm aware of is Geary, but ripping the database
> layer out of Geary would be quite the task and probably more than I
> would need.

You can check Rygel's db layer: https://git.gnome.org/browse/rygel/tree
/src/librygel-db
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] cannot locate ITS rules for org.gnome.Publisher.appdata.xml.in

2017-06-13 Thread Jens Georg


sascha@linux-ktr9:~/Projects/gnome-publisher1/data> make
  GEN  org.gnome.Publisher.appdata.xml
/usr/bin/msgfmt: cannot locate ITS rules for
org.gnome.Publisher.appdata.xml.in


Usually you forgot to specify the format when doing this, but your code 
looks good.

check if you have appdata.its in your gettext package.
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] How to check if string is empty

2017-01-17 Thread Jens Georg


In Vala you can simply just check for str != "", this is enough.


No, if str is nullable it's semantically different, because str != "" 
will be generated as


if (g_strcmp0 (_tmp1_, "") != 0) {
  ..
}

This will be TRUE for _tmp1_ being NULL because NULL isn't "" ( and 
g_strcmp0 will return -1 because NULL is < everything)

so if str is nullable, str != "" means NULL or not empty.
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] The future of Vala

2016-09-16 Thread Jens Georg

> It's just very tiring when one's efforts are ignored for weeks and
> the general impression is that new
> developers are something the project doesn't give a tuppeny-cuss
> about…

You know, it's still volunteer work. The time has to come from
somewhere.

> In addition to that, I also believe that Jürg's decision not to merge
> the patch is misguided. If clear and

That's probably driven by the history of people yelling at him for
breaking vala-based projects again.

> obvious bugs like that (short summary: the compiler accepts code such
> as List l = new ArrayList())
> are retained because of broken third-party projects (shotwell was
> mentioned), then it's impossible to move
> things forward. And guess what: open source developers do what they
> do because they do want to move things 
> forward. And if they can't do it in vala, they'll soon find some
> other, more welcoming project. And while
> I understand the importance of backwards compatibility, I don't think
> it's as important for vala as it is for,
> say, the kernel. Unlike the kernel, one machine can easily run two
> different versions of the compiler 
> simultaneously, and if the shotwell people want to compile old,
> broken code, I think it's entirely reasonable
> to expect them to keep an old, broken compiler version around to do
> so. Of course, the far more likely case is
> that they, like basically anyone else, actually *want* the compiler
> to tell them about their broken code so they
> can fix it! Not to mention all the other user who'd like to have this
> fix…

Or, you know, maybe you could just talk to "the shotwell people"
instead of making assumptions - I had no idea about this until
accidentally reading this thread.

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


Re: [Vala] Vala and GLib license

2016-07-11 Thread Jens Georg
Yes. Obviously the two licenses are not compatible then. The only way 
out there
would be a compatibility layer that translates those runtimes into 
something

GLib can live with.


Even if that would violate licence from Sony and Microsoft? Obviously,
sharing that code with someone who already has license from them to
use their API is not a problem at all. But sharing that code with
those who don't have such license will put me into trouble with that
companies, but even if people will have those sources - they are
useless without previous agreement with Sony/Microsoft and their SDK.
That's the one of the moments that kind of preventing me to look into
Vala more seriously in view of professional game development. I never
know where it will end. The thing is - I have bunch of old code that I
may to do some refactoring - go from old C code into C++ with bunch of
own new and old bicycles or just went with Vala step by step, maybe
even ending with helping community in places where I may be useful.
But even how much I don't like C++ as the language, at least I know I
won't have any license headache later. Vala looks way better in
comparison, but the license of it's core runtime... That was the whole
point of the subject.

On Jul 11, 2016 5:25 PM, "Jens Georg"  wrote:


But If I would need to patch GLib to work on PS4 or XBONE? I doubt
that
those platforms will allow me to share usage of their internal
API. Can I
keep those patch closed and share them only with people who has
licenses
for PS4 and XONE (you aren't able to put that patch in anyway if
you are
just standard customer and user of the console and not the
developer) so
they would able to use that new code as well, but not with others,
because
that may violate license of console platforms.


No. Because you're patching (L)GPL code you would have to grant
access to the modified sources
___
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 and GLib license

2016-07-11 Thread Jens Georg



But If I would need to patch GLib to work on PS4 or XBONE? I doubt that
those platforms will allow me to share usage of their internal API. Can 
I
keep those patch closed and share them only with people who has 
licenses
for PS4 and XONE (you aren't able to put that patch in anyway if you 
are
just standard customer and user of the console and not the developer) 
so
they would able to use that new code as well, but not with others, 
because

that may violate license of console platforms.


No. Because you're patching (L)GPL code you would have to grant access 
to the modified sources

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


Re: [Vala] Interface static method

2015-07-07 Thread Jens Georg

my question is simple : How implement static method c interface ?


Yet I have no idea what you are trying to do. Are you trying to 
implement URIHandler interface in Vala?



An exemple with GStreamer URIHandler :
http://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gsturi.h

get_protocols member has "2 types" : 1 in interface structure and the 
other

as method.


the get_protocols method is a convenience function that "just" calls the 
function pointer in the structure. For GObject interfaces, you don't 
have to do anything about that.


If you want to implement this interface in vala, you just "override" the 
method because it is abstract and Vala does the rest of the magic.



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


Re: [Vala] Using a C library

2015-04-20 Thread Jens Georg

Hi,



I'm trying to wrap the proprietary libspotify C library. I've found 
this


Someone already did that:

https://gitorious.org/spotifyd/spotifyd/source/a3487ee9c56b816c120ad41855c02ad3471d1021:libspotify.vapi

I don't know how up-to-date this is, though.

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


Re: [Vala] [ANNOUNCE] Vala 0.22.1 - Compiler for the GObject type system

2013-11-19 Thread Jens Georg

Am 2013-11-19 18:12, schrieb Jürg Billeter:

We are pleased to announce version 0.22.1 of Vala, a compiler for the
GObject type system.


Hm, I'd suggest to either give reasons for the reversions or just 
"squash" them in the changelog, it looks a bit weird :)


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


Re: [Vala] How to get date/time infos from a file ?

2013-08-21 Thread Jens Georg
On Mi, 2013-08-21 at 15:39 +0200, r...@no-log.org wrote:
> Well, Im' trying something like :
>   var file = File.new_for_path ("some_file.txt");
>   var file_info = file.query_info ("*::*", 0);

Should be file.query_info ("*", 0) for everything

> int64 file_stamp =
>  file_info.get_attribute_int64(FileAttribute.TIME_ACCESS);
> 
> stdout.printf ("%" + int64.FORMAT + "\n", file_stamp);
> 
> But result is "0" :-?
> 
> where am I wrong ?
> 
> 
> > On Mi, 2013-08-21 at 14:41 +0200, r...@no-log.org wrote:
> >> Hello,
> >>
> >> I'm trying to get informations like TIME_ACCESS, TIME_CREATED, ... from
> >> a
> >> file but I don't know how.
> >>
> >> For example :
> >>var file = File.new_for_path ("some_file.txt");
> >
> > You have to add things you want to extract from the FileInfo on the line
> > below also in the line here (or use "*" to get everything).
> >
> >>var file_info = file.query_info (FILE_ATTRIBUTE_STANDARD_NAME + "," +
> >> FILE_ATTRIBUTE_STANDARD_TYPE, 0);
> >>int64 file_stamp =
> >> file_info.get_attribute_int64(FileAttribute.TIME_ACCESS);
> >>
> >>stdout.printf ("%" + int64.FORMAT + "\n", file_stamp);
> >
> >
> > ___
> > 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 to get date/time infos from a file ?

2013-08-21 Thread Jens Georg
On Mi, 2013-08-21 at 14:41 +0200, r...@no-log.org wrote:
> Hello,
> 
> I'm trying to get informations like TIME_ACCESS, TIME_CREATED, ... from a
> file but I don't know how.
> 
> For example :
>var file = File.new_for_path ("some_file.txt");

You have to add things you want to extract from the FileInfo on the line
below also in the line here (or use "*" to get everything).

>var file_info = file.query_info (FILE_ATTRIBUTE_STANDARD_NAME + "," +
> FILE_ATTRIBUTE_STANDARD_TYPE, 0);
>int64 file_stamp =
> file_info.get_attribute_int64(FileAttribute.TIME_ACCESS);
> 
>stdout.printf ("%" + int64.FORMAT + "\n", file_stamp);


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


Re: [Vala] How track memory leaks ?

2013-03-18 Thread Jens Georg
On Mo, 2013-03-18 at 22:44 -0007, Jim Nelson wrote:
> This is a problem we faced in Geary.  We went several directions 
> before adding this, which helped immensely:
> 
> http://redmine.yorba.org/projects/geary/repository/revisions/master/entry/src/engine/api/geary-base-object.vala
> 
> Note that this approach is of limited utility, as it requires *all* 
> your project's classes to inherit from it in order to get reference 
> tracking.  However, it did help us track down a couple of memory leaks 
> that would've been a bear to find otherwise.
> 
> May not be right for you, but perhaps it gives you ideas as well.

You can also use https://github.com/danni/gobject-list for reference
debugging.


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


Re: [Vala] suppressing the "never used" warning on a method-by-method basis, at least for libraries

2013-01-15 Thread Jens Georg
On Mo, 2013-01-14 at 20:57 -0800, Dan Hitt wrote:

> I would really like to disable only the never used warnings
> (and i'd like to do it on a method-by-method basis, because,
> after all, the "never used" warning is very useful).
> 
> Here's a sort of minimal example, to be put in a file called NotUsed.vala:
> 
>// Compile with:
>// valac --library=lib NotUsed.vala -X -fPIC -X -shared -o lib.so
> 
>class NotUsed {
>  public uint method() {return 0;}
>}
> 

Declare the class "public".


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


Re: [Vala] How can I disable the gdb integration?

2012-09-06 Thread Jens Georg
On Fr, 2012-09-07 at 09:11 +0300, Alberto Mardegan wrote:
> Hi all,
>when running my application under gdb I get the following:
> 
> =
> > Program received signal SIGSEGV, Segmentation fault.
> > publishing_ui_publishing_dialog_account_service_copy (self=self@entry=0x0, 
> > dest=dest@entry=0x7fffcae0)
> > at 
> > /media/mardy/Data/src/bzr/shotwell/build-area/shotwell-0.12.90/src/publishing/PublishingUI.vala:133
> > 133 private struct AccountService {
> > (gdb) bt
> > #0  publishing_ui_publishing_dialog_account_service_copy 
> > (self=self@entry=0x0, dest=dest@entry=0x7fffcae0)
> > at 
> > /media/mardy/Data/src/bzr/shotwell/build-area/shotwell-0.12.90/src/publishing/PublishingUI.vala:133
> > #1  0x004e1f25 in 
> > publishing_ui_publishing_dialog_on_service_changed 
> > (self=self@entry=0xa5e2a0)
> > at 
> > /media/mardy/Data/src/bzr/shotwell/build-area/shotwell-0.12.90/src/publishing/PublishingUI.vala:415
> [...]
> =
> 
> "publishing_ui_publishing_dialog_account_service_copy" is a C function 
> generated by Vala. However, if I type "list" in gdb all I see is the 
> definition of my "struct AccountService".
> I would like to be able to see a backtrace with the C functions, and be 
> able to navigate through them.
> Any hints?

Don't pass -g to valac. The yorba guys might know how to do that nicely
in shotwell without disabling C debug.


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


Re: [Vala] Asynchronous construction

2012-03-27 Thread Jens Georg
On Di, 2012-03-27 at 12:24 +0200, tomw wrote:
> On Di, 2012-03-27 at 11:59 +0200, Jens Georg wrote:
> 
> > >   try {   
> > >   debug ("Trying to run init_async");
> > >   bool re = yield device.init_async (Priority.DEFAULT, 
> > > cancellable);
> > 
> > ^^ this yield returns to main loop and once init_async calls its
> > call-back will call init_finish for you. So after this line the device
> > is initialized.
> 
> Thanks, 
> 
> I'm afraid that the statement above is just initializing a new device
> instance, which (according to gfreenect) can only be used after
> gfreenect_device_new_finish () is called like in the C example. This is
> why I was trying to create a finished instance in the callback. As the
> code is still crashing in libusb - Is there a way to get the callback
> called rather than the implicit init_finish being called from
> init_async? 

gfreenect_device_new_finished is just calling _async_initable_new_finish
which calls async_initable_finish, same for _device_new. Removing the
subdevices property stops the crashing here. looking at the gfreenect
code that isn't used at all:
https://github.com/elima/GFreenect/blob/master/gfreenect/gfreenect-device.c#L1150


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


Re: [Vala] Asynchronous construction

2012-03-27 Thread Jens Georg

> Hi,

[Freenect C init sample ]

> Trying to implement that in Vala, I took the approach below.
> It seems however, that the init_async does not work. Looking at the
> generated C-Code it looks like the g_async_initable_init_finish method 
> is called right after init_async an not with in the callback as expected.
> As a result the code is crashing in the underlying libusb due to 
> incorrect initialization.
> 
> What am I missing here? Any idea how to solve the issue.
> 
> thanks and sorry for the lengthy post,
> 
> --tomw
> 
> -
> 
> using GLib;
> using GFreenect;
> 
> public class Main : Object 
> {
> 
> public GFreenect.Device device;
> public Cancellable cancellable;   
>   
> public Main () {
>   Cancellable cancellable  = new Cancellable ();
>   
> }
>   
> public async void run (out Device dev) {
> debug ("Starting");
> Device device = (Device) GLib.Object.@new (
>   typeof (Device),
>   "index", 0,
>   "subdevices", Subdevice.CAMERA
>   );
>   debug ("Device created");   
>   Idle.add (run.callback);

^^ No need for this since you're using yield in the function. Might
actually be harmful, causing a race between the init_async you call and
the one Vala calls implicitly.

>   try {   
>   debug ("Trying to run init_async");
>   bool re = yield device.init_async (Priority.DEFAULT, 
> cancellable);

^^ this yield returns to main loop and once init_async calls its
call-back will call init_finish for you. So after this line the device
is initialized.

>   if (re) {
>   debug ("Result = OK");
>   } else {
>   debug ("Result = FAILED");
>   }
>   } catch (Error e) {
>   debug ("Error initalizing device : %s", e.message);
>   } 
>   }
>   
>public void callback (Main? source, GLib.AsyncResult? res, void* 
> user_data) {
>   debug ("Entering Callback");
>   Device dev;
>   if (res != null) {
>   source.run.end (res, out dev);
>   debug ("Callback called - Device created");
>   try {
>   Device kinect = new dev.finish(res);

^^ And here you're basically trying to create another device.

>   } catch (Error e) {
>   debug ("Error finalizing device : %s", e.message);
>   }
>   } else {
>   debug ("No result delivered");
>   }
>}   

I would do it like this:
using GLib;
using GFreenect;

public class Main : Object 
{

public GFreenect.Device device;
public Cancellable cancellable;   

public Main () {
Cancellable cancellable  = new Cancellable ();

}

public async void run () {
debug ("Starting");
Device device = (Device) GLib.Object.@new (
typeof (Device),
"index", 0,
"subdevices", Subdevice.CAMERA
);
debug ("Device created");   
try {   
debug ("Trying to run init_async");
bool re = yield device.init_async (Priority.DEFAULT, 
cancellable);
// start using the device
} catch (Error e) {
// re will always be true in the try block if you always get an 
error
// when it's false, because you end up here anyway.
debug ("Error initalizing device : %s", e.message);
} 
  }

   static int main (string[] args) {
var loop = new MainLoop ();
var app = new Main ();
app.run.begin ();
loop.run ();

return 0;
   }


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


Re: [Vala] regarding GLib.Process.spawn_async_with_pipes

2012-03-13 Thread Jens Georg
Hi,

> I'm trying to write a simple GTK3 front-end for smbpasswd and I'm trying
> to use «GLib.Process.spawn_async_with_pipes» based on the «-s» option of
> smbpasswd which allows it to use stdin for password prompt. 
> How can I send the data to «GLib.Process.spawn_async_with_pipes»' stdin?

You need to set up an IOWatch on the resulting standard_input fd and
check if the app is ready for receiving input; you'll probably also
connect to stdout and stderr to properly interact with the command-line
app.


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


Re: [Vala] DBus server-side codegen

2012-03-08 Thread Jens Georg
On Do, 2012-03-08 at 12:29 +0100, Luca Bruno wrote:
> On Tue, Mar 6, 2012 at 9:48 PM, Eric Gregory  wrote:

> > Is there a codegen tool out there that can generate a Vala DBus adapter
> > from the XML?  Or is this something where I'd have to hand-roll (and
> > hand-maintain) the adapter interface?
> >
> 
> Why do you need xml for the server?
> http://live.gnome.org/Vala/DBusServerSample

Well it makes sense when you want to implement server interface specs
like e.g. MPRIS2 to save you from the dull task to write the interface
in vala by hand.


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


Re: [Vala] Thread error 'assignment makes pointer from integer without a cast'

2012-02-29 Thread Jens Georg
On Di, 2012-02-28 at 21:52 +, David M wrote:
> Following upgrading to Vala verion 0.15.2, I get the warning 
> 'GLib.Thread.create 
> has been deprecated since 2.32. Use new Thread ()'. So I did as it 
> suggested, 
> but then I get the errors as follows:
> 
> In function ?thread_demo_main?:
> warning: assignment makes pointer from integer without a cast [enabled by 
> default]
> undefined reference to `g_thread_new'
> undefined reference to `g_thread_free'

Only do as suggested if you really have glib 2.32 (2.31.x) available.
Otherwise you need to live with that vala warning.


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


Re: [Vala] Safe call operator

2012-02-20 Thread Jens Georg
On Mo, 2012-02-20 at 07:28 +0100, pancake wrote:
> i really like the idea of having the elvis operator and the safe navigation 
> operator in Vala.

Elvis is already supported, just with different syntax: ?? (same as in
C#)

> 
> fmi : http://groovy.codehaus.org/Operators
> 
> is this going to be added at some point into the compiler?
> 
> On Feb 1, 2012, at 21:08, Jim Nelson  wrote:
> 
> > I was going to mention that as well.  Null handling in Java is not
> > analogous to Vala's strategy, if for no other reason than there's no NPE.
> > 
> > It looks to me the idea of a future Vala that emphasizes code correctness
> > is that it will catch things like this:
> > 
> > Xyxxy? x = get_xyzzy();
> > int result = x.foo();
> > 
> > The compiler will flag that last line as problematic.  I think it will, at
> > least.  I don't really know.  But it seems to me that if null-checking is
> > going to be enforced by the compiler, it's not too much to ask the language
> > to supply good tools for doing that checking.  The nullable operator is one
> > step in that direction, but I've coded many lines where I needed something
> > like the Elvis operator (and the associated operators suggested by Project
> > Coin).
> > 
> > I'll also point out that (according to the Project Coin page) the reason
> > the null-safety operators were turned down by the Java committee was that
> > the Checker framework was added to Java and that Groovy, the inspiration
> > for the proposed syntax, uses dynamic typing, which makes the operators
> > more flexible.  But the first is not going to happen for Vala (I've not
> > heard of any such framework) and the second could be made to argue against
> > the nullable operator, which was, in fact, added to Vala.
> > 
> > I think the Elvis operator (and its cousins) should get real consideration
> > and not be dismissed merely because Java didn't take them.
> > 
> > -- Jim
> > 
> > 
> > 
> > On Tue, Jan 31, 2012 at 7:27 AM, Artem Tarasov 
> > wrote:
> > 
> >>> As a starter, Java rejected that syntax.
> >> 
> >> Yeah, but in Java at least a NullPointerException is thrown when null
> >> dereferencing occurs. In Vala the only option to provide null-safety
> >> is explicit checking for null after each method call in a chain.
> >> ___
> >> 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
> 


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


Re: [Vala] Problems with HashMap/Dictionary

2011-10-14 Thread Jens Georg
On Fr, 2011-10-14 at 10:09 +0200, Kris Thomsen wrote:
> Hi Jens,
> 
> Thanks - but would you show me an example on what you mean?

Instead of
private var map;

you need to use
private HashMap map;

> 
> // Kris
> 
> 2011/10/14 Jens Georg 
> On Fr, 2011-10-14 at 09:52 +0200, Kris Thomsen wrote:
> > Hi!
> >
> > I'm new to Vala and therefore I try to translate a
> Java-example to Vala. I
> > have translated the same Java-example to C# before with
> success. In this
> > example they use af HashMap (C#: Dictionary) and I know
> HashMap is a part of
> > LibGee. BUT, I cant make it work, the compiler keep on
> telling me an error:
> >
> > My example:
> >
> > public class ProductCatalog : GLib.Object {
> > private var map;
> 
> [...]
> > }
> >
> > The compiler gives me this error:
> >
> > [kris@odin Udvikling]$ valac --pkg gee-1.0 NextGen.vala
> > NextGen.vala:59.17-59.19: error: syntax error, statements
> outside blocks
> > allowed only in root namespace
> > private var map;
> 
> 
> You can't use var there, you need the full type.
> 
> 
> ___
> 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] Problems with HashMap/Dictionary

2011-10-14 Thread Jens Georg
On Fr, 2011-10-14 at 09:52 +0200, Kris Thomsen wrote:
> Hi!
> 
> I'm new to Vala and therefore I try to translate a Java-example to Vala. I
> have translated the same Java-example to C# before with success. In this
> example they use af HashMap (C#: Dictionary) and I know HashMap is a part of
> LibGee. BUT, I cant make it work, the compiler keep on telling me an error:
> 
> My example:
> 
> public class ProductCatalog : GLib.Object {
> private var map;
[...]
> }
> 
> The compiler gives me this error:
> 
> [kris@odin Udvikling]$ valac --pkg gee-1.0 NextGen.vala
> NextGen.vala:59.17-59.19: error: syntax error, statements outside blocks
> allowed only in root namespace
> private var map;

You can't use var there, you need the full type.


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


Re: [Vala] http server help

2011-10-03 Thread Jens Georg
On Sa, 2011-10-01 at 15:18 +0200, andrea zambon wrote:
> Hi,
> I'm writing a little http server to send some binary data.

I wonder if it wouldn't be easier to use the one from libsoup.


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


Re: [Vala] "this" in objects

2011-08-03 Thread Jens Georg
On Mi, 2011-08-03 at 20:39 +0200, Pavol Klačanský wrote:
> Hi,
> 
> why somebody uses this. prefix and somebody doesn't, I have tried and it 
> worked with or without it

It's a matter of taste and or coding guidelines or explicitly avoid
shadowing of object members by local variables.

"this" can be used as an equivalent to the hungarian notation of m_foo
for members. 

You're completely free to use the style that suits you for your project.



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


Re: [Vala] Problems retrieving binary data from a sqlite3 database BLOB column

2011-07-09 Thread Jens Georg
On So, 2011-06-26 at 00:24 +0200, Iñigo Serna wrote:
> Hi,
> 
> I have problems retrieving binary data from a sqlite3 DB.
> 
> One of the columns of the database (f.e., number 3) is a BLOB with png images.
> 
> Using FileUtils.set_data("test.png", (uint8[]) smtm.column_blob(3));
> writes a 8-bytes file with the first bytes of the image ("PNG" header
> and some other numbers)
> 
> I'm sure the query is ok as I also retrieve other fields in the same
> query and even stmt.column_bytes(3) returns the correct size of the
> image.
> 
> Documentation explains "smtm.column_blob()" returns a void * so I
> guess I have to cast to uint8[] to use FileUtils.set_data.
> 
> 
> What am I doing wrong?

Try 
var data = (uint8[]) smtm.column_blob(3);
data.length = smtm.column_bytes(3);


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


Re: [Vala] [vala][newbie] file_info.get_file_type

2011-05-08 Thread Jens Georg
On Mo, 2011-04-11 at 22:53 -0700, Charles Hixson wrote:
> I   can't   figure   out   what   I'm   doing   wrong,   but  
> file_info.get_file_type   always   returns   a   value   of   0   
> (i.e.,   UNKNOWN):

Yes, and it rightfully does. Because you don't query for it.

You want to query for either "*" - everything, more specifically
"standard::*" for standard properties like size, type etc. or even more
specifically for FILE_ATTRIBUTE_STANDARD_NAME + "," +
FILE_ATTRIBUTE_STANDART_TYPE. For possible constants see:

http://developer.gnome.org/gio/2.28/GFile.html#g-file-enumerate-children
and http://developer.gnome.org/gio/2.28/GFileInfo.html


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


Re: [Vala] [vala][newbie] file_info.get_file_type

2011-04-11 Thread Jens Georg
On Mon, 2011-04-11 at 22:49 -0700, Charles Hixson wrote:
> I   can't   figure   out   what   I'm   doing   wrong,   but  
> file_info.get_file_type   always   returns   a   value   of   0   
> (i.e.,   UNKNOWN):

That's correct, because…

> 
> 
> // valac --pkg gio-2.0 walker.vala
> // ./walker
> 
> void  walk (File directory)
> {
> try
> {  var enumerator = directory.enumerate_children 
> (FILE_ATTRIBUTE_STANDARD_NAME, 0);

… you don't query for it. Change to FILE_ATTRIBUTE_STANDARD_NAME + "," +
FILE_ATTRIBUTE_STANDARD_TYPE to also get the type.

See http://developer.gnome.org/gio/stable/GFileInfo.html#GFileInfo for
all flags (just remove the G_ prefix) for the vala version.

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


Re: [Vala] [newbie] Creating a VAPI for a raw C library

2011-02-28 Thread Jens Georg
On Mon, 2011-02-28 at 09:09 +0100, Guilhem Bonnefille wrote:
> Hi all,
> 
> It's my first post on this list, as I've just decided to experiment vala.
> 
> My idea is to build a software around a C library. But, this library
> is in the pure C spirit:
> - opaque public types
> - return values via parameters
> - huge mix with value and references
> I tried to initiate a .vapi, but it is quite complex for a newbie like
> me. So, I'm looking for some help, and post here.
> 
> I think I have two dificulties that I can summarize with the following code:
> 
> /* API */
> typedef void*lib_type_t;
> void init(lib_type_t *p);
> void get(lib_type_t p, char **val);
> 
> /* USE */
> ...
> lib_type_t myType;
> char *val;
> lib_init(&myType);
> lib_get(myType, &val);

(take with a grain of salt, typed from memory)

[CCode (c_prefix="lib_")]
namespace MyLib {
[Compact]
[CCode (c_prefix="lib_")]
class MyType {
static void init (out MyType instance);
int @get(out string val);
}
}

MyType foo;
string val;
MyType.init(out foo);
foo.get(out val);

You should have a look at the SQLite vapi.


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


Re: [Vala] Vala for everyone

2011-01-31 Thread Jens Georg
On Mon, 2011-01-31 at 14:27 +, Denis Reichelt wrote:
> Hi all,  
>   
> I'm not a GNOME developer but I'm interrested in Vala because for me it would 
>  
> be a perfect C frontend. C is virtually platform independent because C  
> compilers exist for nearly every processor / controller.  
> So my question is:  
> Why is Vala that hardly bound to the Gnome world and the gcc compiler?  
> Why simply transform Vala code to C and let the platform dependent C compiler 
>  
> do all the machine code things?  
> I would like to use Vala with embedded devices, not using any linux OS or 
> such.  
> Would that be possible, maybe with a reduced library set?  

There is the POSIX profile, but you lose those features provided through
GObject. The generated C should conform to C89.



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


Re: [Vala] Any xUnit framework for Vala?

2011-01-06 Thread Jens Georg

> Let me answer to my question: binding for GLib testing framework
> actually exist in Vala. They are just hidden. I did not find any
> examples of unit tests for a Vala app, so I created such example by

http://git.gnome.org/browse/rygel/tree/tests



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


Re: [Vala] uuid binding

2011-01-04 Thread Jens Georg
On Tue, 04 Jan 2011 13:49:52 +0100, Pavol Klačanský 
wrote:
> Hi, is there working uuid bindings?
> 
> thanks

http://git.gnome.org/browse/rygel/tree/src/rygel/rygel-root-device-factory.vala#n28
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] FileInfo.get_file_type()

2010-06-23 Thread Jens Georg

> Can anyone tell me why the following program always returns UNKNOWN for 
> the file type?

Because you do not include the query for the filetype in the enumerate call.

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


Re: [Vala] Mysql binding

2010-01-18 Thread Jens Georg

> Hi,
> i'm trying mysql bindings now, and it doesn't work for me,
> 
> r...@centos-54-64-minimal ~/develop/vala # valac --pkg mysql mysql2.vala && 
> ./mysql2
> mysql2.vala:10.19-10.33: error: `Mysql.Database' does not have a default 
> constructor
> Database mysql = new Database ();
>  ^^^
> Compilation failed: 1 error(s), 0 warning(s)
> 
> 
> i've read maillist and it seem like a common error on later versons of
> vala? :(

I'm not so sure why this worked in the first place. You could try the
attached patch which makes init a static factory method:

var mysql = Database.init();


--- /home/jens/checkout/gnome2/vala/vapi/mysql.vapi	2009-04-08 22:20:46.0 +0200
+++ /opt/gnome2/share/vala/vapi/mysql.vapi	2010-01-13 18:18:32.0 +0100
@@ -26,8 +26,7 @@
 	[Compact]
 	[CCode (free_function = "mysql_close", cname = "MYSQL", cprefix = "mysql_")]
 	public class Database {
-		[CCode (argument0 = "NULL", cname = "mysql_init")]
-		public void init ();
+		public static Database? init (Database? db=null);
 
 		public ulong affected_rows ();
 		public bool autocommit (bool mode);
___
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] SDL error: SDL_gfxPrimitive.h not found

2009-10-22 Thread Jens Georg
> > It's because SDL, unlike a lot of libraries bound for Vala, doesn't
> > have a pkg-config file defining include paths and the like.
> > 
> 
> That depends. It seems to have on debian-based systems and on openSUSE.

and in libsdl's svn:
http://www.libsdl.org/cgi/viewvc.cgi/trunk/SDL/sdl.pc.in?view=log


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


Re: [Vala] SDL error: SDL_gfxPrimitive.h not found

2009-10-22 Thread Jens Georg
Am Donnerstag, den 22.10.2009, 10:45 -0400 schrieb Levi Bard:
> >> Did you have  "--Xcc=-I/usr/include/SDL" as part of your compile line?
> >
> > Just out of curiosity...  Why is that necessary?
> 
> It's because SDL, unlike a lot of libraries bound for Vala, doesn't
> have a pkg-config file defining include paths and the like.
> 

That depends. It seems to have on debian-based systems and on openSUSE.

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


Re: [Vala] Bitwise and (c &) in Vala

2009-09-17 Thread Jens Georg
 
> >  if (condition & MyClass.ENUM_VALUE_1)
> 
> if ((condition & MyClass.ENUM_VALUE_1) != 0)
> 
> Elementary, dear Watson ;-)

... in every other language than C ;)

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


Re: [Vala] libgee on Windows

2009-09-11 Thread Jens Georg

> The mailing list keeps destroying my pretty formating! Delete all the hyphens 
> following the urls.

aw. sh*t. Due to the limited smartness of older versions of libtool, you
need to install g++, although you don't need it to compile.


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


Re: [Vala] libgee on Windows

2009-09-11 Thread Jens Georg
> The mailing list keeps destroying my pretty formating! Delete all the hyphens 
> following the urls.

That looks weird. Are you - by any chance - compiling in a directory
that contains spaces?


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


Re: [Vala] libgee on Windows

2009-09-10 Thread Jens Georg

> I tried running configure, make, make install from cygwin but it failed at 
> configure. :( Appending --no-undefined on the gcc compile command also failed.
> output.txt http://www.flyupload.com/?fid=155588output.png 
> http://www.flyupload.com/?fid=7060892
> config.log http://www.flyupload.com/?fid=8200585

I cannot open those files. Could you use pastebin.com or a similar
service? Forget about the -no-undefined for a now please.


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


Re: [Vala] libgee on Windows

2009-09-08 Thread Jens Georg
Am Montag, den 07.09.2009, 13:30 -0500 schrieb Mr. Maxwell .:

> pkg-config --libs glib-2.0 produces -LD:/vala-0.7.4/lib -lglib-2.0 -lintl
> When I used that as the link option the linking still failed with the same 
> errors. I tried to create a batch file with this as the contents and it also 
> failed with the same errors. (it's all one line)gcc -shared -o libgee.dll 
> D:\libgee-0.3.0\gee\abstractcollection.o D:\libgee-0.3.0\gee\abstractlist.o 
> D:\libgee-0.3.0\gee\abstractmap.o D:\libgee-0.3.0\gee\arraylist.o 
> D:\libgee-0.3.0\gee\collection.o D:\libgee-0.3.0\gee\functions.o 
> D:\libgee-0.3.0\gee\hashmap.o D:\libgee-0.3.0\gee\hashset.o 
> D:\libgee-0.3.0\gee\iterable.o D:\libgee-0.3.0\gee\iterator.o 
> D:\libgee-0.3.0\gee\linkedlist.o D:\libgee-0.3.0\gee\list.o 
> D:\libgee-0.3.0\gee\map.o D:\libgee-0.3.0\gee\readonlycollection.o 
> D:\libgee-0.3.0\gee\readonlylist.o D:\libgee-0.3.0\gee\readonlymap.o 
> D:\libgee-0.3.0\gee\readonlyset.o D:\libgee-0.3.0\gee\set.o 
> D:\libgee-0.3.0\gee\treemap.o D:\libgee-0.3.0\gee\treeset.o 
> -LD:\vala-0.7.4\lib -lglib-2.0 -lintlAny ideas?
> 
Sorry, but I think libgee compiles on mingw by using the normal
"configure, make & make install" triumvirate. (apart from not building a
shared library due to missing -no-undefined on win32 which is easily
fixable, patch follows)



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


Re: [Vala] I'm not a Genie !

2009-05-14 Thread Jens Georg

> $ valac --save-temps --pkg gtk+-2.0 test.gs
> /usr/home/niko/Desktop/test/Genie/test.c: In function '_lambda0_':
> /usr/home/niko/Desktop/test/Genie/test.c:84: error: 'slider' undeclared 
> (first use in this function)
> /usr/home/niko/Desktop/test/Genie/test.c:84: error: (Each undeclared 
> identifier is reported only once
> /usr/home/niko/Desktop/test/Genie/test.c:84: error: for each function it 
> appears in.)
> error: cc exited with status 256
> Compilation failed: 1 error(s), 0 warning(s)
> 
> Any idea ?
> 

Since I hit that one myself yesterday ;) You're using a local variable
in a lambda expression. This is not yet supported.


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


Re: [Vala] [Bindings] Few quick questions about glib

2008-09-08 Thread Jens Georg
> but
> "%s: %d".printf ("Hello", 5)
> is some weird, weird stuff !

Looks like consequent OOP, bit like smalltalk

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