Re: [Vala] "as" word

2011-03-18 Thread Anatol Pomozov
Hi

2011/3/18 Pavol Klačanský :
> var window = builder.get_object("window") as Gtk.Window;

Dynamic type casting

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


Re: [Vala] Vala broken on non-gnu systems

2011-03-16 Thread Anatol Pomozov
Hi

On Wed, Mar 16, 2011 at 1:37 AM, Alexander Kojevnikov
 wrote:
> On 16 March 2011 16:33, Anatol Pomozov  wrote:
>> But now tests are broken because of other error:
>>
>> make  check-TESTS
>> TEST: Building...                                                      FAIL
>> cc1: error: -Wuninitialized is not supported without -O
>> error: cc exited with status 256
>> Compilation failed: 1 error(s), 0 warning(s)
>> make[4]: *** [check-TESTS] Error 1
>> make[3]: *** [check-am] Error 2
>> make[2]: *** [check] Error 2
>> make[1]: *** [check-recursive] Error 1
>> make: *** [check] Error 2
>>
>
> This should be fixed by the patch in the other bug I mentioned, please
> give it a try:
>
> https://bugzilla.gnome.org/show_bug.cgi?id=644876

Thanks for your patches. It is much better now.

Now only dbus tests fail with

  /dbus/basic-types/server:FAIL
Failed to start message bus: launchd's environment variable
DBUS_LAUNCHD_SESSION_BUS_SOCKET is empty, but should contain a socket
path.

EOF in dbus-launch reading address from bus daemon

** CRITICAL **: file /Users/anatol/sources/vala/tests/_test/main.c:
line 19824: uncaught error: Error connecting: No such file or
directory (g-io-error-quark, 1)
aborting...
dbus.basic_types.server.check: line 4: 74545 Abort trap
./test /dbus/basic-types/server
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec
... or kill -l [sigspec]



It looks similar to this issue https://trac.macports.org/ticket/26712
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Vala broken on non-gnu systems

2011-03-16 Thread Anatol Pomozov
Hi

On Tue, Mar 15, 2011 at 11:43 PM, Alexander Kojevnikov
 wrote:
> On 16 March 2011 13:49, Anatol Pomozov  wrote:
>> On Tue, Mar 15, 2011 at 10:46 PM, Alexander Kojevnikov
>>  wrote:
>>> On 16 March 2011 12:07, Anatol Pomozov  wrote:
>>>> While you are here you might want to fix tests/testrunner.sh that also
>>>> uses GNU extension (xargs -r). See line 167.
>>>
>>> Which Unix are you using?
>>
>> macosx 10.6.4
>
> I filed this as bgo#644884 [0], please test the attached patch and
> comment in the bug.
>
> [0] https://bugzilla.gnome.org/show_bug.cgi?id=644884

Current HEAD is broken on macosx so I checked out revision before the
Jurg's change
$ git checkout a2d2120b~
applied your patch and it fixes the issue with "xargs -r".

But now tests are broken because of other error:

make  check-TESTS
TEST: Building...  FAIL
cc1: error: -Wuninitialized is not supported without -O
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
make[4]: *** [check-TESTS] Error 1
make[3]: *** [check-am] Error 2
make[2]: *** [check] Error 2
make[1]: *** [check-recursive] Error 1
make: *** [check] Error 2
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Vala broken on non-gnu systems

2011-03-15 Thread Anatol Pomozov
Hi

On Tue, Mar 15, 2011 at 10:46 PM, Alexander Kojevnikov
 wrote:
> On 16 March 2011 12:07, Anatol Pomozov  wrote:
>> While you are here you might want to fix tests/testrunner.sh that also
>> uses GNU extension (xargs -r). See line 167.
>
> Which Unix are you using?
macosx 10.6.4

> FreeBSD's xarg works fine with or without
> the -r option:
>
>     -r      Compatibility with GNU xargs.  The GNU version of xargs runs the
>             utility argument at least once, even if xargs input is empty, and
>             it supports a -r option to inhibit this behavior.  The FreeBSD
>             version of xargs does not run the utility argument on empty
>             input, but it supports the -r option for command-line compatibil-
>             ity with GNU xargs, but the -r option does nothing in the FreeBSD
>             version of xargs.
>
> On a side note, there are other issues with the test runner under
> FreeBSD, they should be fixed by the patch attached to bgo#644876 [0]
>
> [0] https://bugzilla.gnome.org/show_bug.cgi?id=644876
>
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Vala broken on non-gnu systems

2011-03-15 Thread Anatol Pomozov
Hi

On Tue, Mar 15, 2011 at 12:05 PM, pancake  wrote:
> The commit a2s2120.. dated at 2011-02-10 adds the use of strnlen function in 
> glib-2.0.vapi.
>
> This function is a gnu extension on libc. This is not glib and this function 
> is only available in GNU LibC. Do the build breaks on OSX, Windows and 
> probably all BSD systems.
>
> It would be great if someone with commit access (Jurg?) fixes that.

While you are here you might want to fix tests/testrunner.sh that also
uses GNU extension (xargs -r). See line 167.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Vala HEAD is broken on MacOSX

2011-03-15 Thread Anatol Pomozov
On Tue, Mar 15, 2011 at 2:58 PM, pancake  wrote:
> Just fyi.. It was originally a gnu extension ( as reported in my archlinux 
> manpage) but its defined as posix now. Netbsd, openbsd and freebsd have this 
> (only recent versions).

If this is added to POSIX then some of the future macosx version will
have it. But my current version (10.6.4) still does not have it.

> The place for this should be glib. But looks like glibc have some sse 
> optimizations for this function.. And that would make run vala programs 
> slower on linux86.. (theorically... I would be happy to see some benchmarks)

Some projects have "compat" directory that include missing
implementations, something like

#ifdef __APPLE__
   implement strnlen here ..
#endif

I am not sure how to add this kind of code to *.vapi file.

>> I just reported this in the irc few hours ago. The commit was in 10th of 
>> february. And jurg ha no plans to remove that claiming for optimization 
>> issues.
>>
>> So the idea would be to fix this on the affected platforms:
>>
>> Osx, iphone and windows.
>>
>> I have just appended the inline definition of strnlen into the system's 
>> string.h include file. This is just a hack..
>>
>> Any idea? Any program compiled against glib-2.0.vapi will suffer the same 
>> issue.
>>
>> On 15/03/2011, at 20:57, Anatol Pomozov  wrote:
>>
>>> Hi,
>>>
>>> I just tried to compile HEAD from git and it is broken on MacOSX.
>>>
>>> Here is the error:
>>>
>>> CCLD   libvala-0.12.la
>>> Undefined symbols:
>>> "_strnlen", referenced from:
>>>     _string_substring in valaccodebasemodule.o
>>>     _string_substring in valaccodemethodmodule.o
>>>     _string_substring in valadovabasemodule.o
>>>     _string_substring in valagirwriter.o
>>>     _vala_attribute_get_string in libvalacore.a(valaattribute.o)
>>>     _string_substring in libvalacore.a(valaclass.o)
>>>     _string_substring in libvalacore.a(valacodecontext.o)
>>>     _string_substring in libvalacore.a(valagirparser.o)
>>>     _string_substring in libvalacore.a(valagenieparser.o)
>>>     _string_substring in libvalacore.a(valageniescanner.o)
>>>     _string_substring in libvalacore.a(valaintegerliteral.o)
>>>     _string_substring in libvalacore.a(valainterface.o)
>>>     _string_substring in libvalacore.a(valamarkupreader.o)
>>>     _string_substring in libvalacore.a(valamethod.o)
>>>     _string_substring in libvalacore.a(valaparser.o)
>>>     _string_substring in libvalacore.a(valascanner.o)
>>>     _string_substring in libvalacore.a(valasourcefile.o)
>>>     _vala_string_literal_eval in libvalacore.a(valastringliteral.o)
>>> ld: symbol(s) not found
>>> collect2: ld returned 1 exit status
>>>
>>>
>>> The reason is that strnlen is not defined on macosx (at least on
>>> 10.6.4 + xcode 3). The easiest way is to implement it on this platform
>>> as
>>>
>>> size_t strnlen(const char *s, size_t n)
>>> {
>>> const char *p = (const char *)memchr(s, 0, n);
>>> return(p ? p-s : n);
>>> }
>>> ___
>>> 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] Vala HEAD is broken on MacOSX

2011-03-15 Thread Anatol Pomozov
Hi,

I just tried to compile HEAD from git and it is broken on MacOSX.

Here is the error:

  CCLD   libvala-0.12.la
Undefined symbols:
  "_strnlen", referenced from:
  _string_substring in valaccodebasemodule.o
  _string_substring in valaccodemethodmodule.o
  _string_substring in valadovabasemodule.o
  _string_substring in valagirwriter.o
  _vala_attribute_get_string in libvalacore.a(valaattribute.o)
  _string_substring in libvalacore.a(valaclass.o)
  _string_substring in libvalacore.a(valacodecontext.o)
  _string_substring in libvalacore.a(valagirparser.o)
  _string_substring in libvalacore.a(valagenieparser.o)
  _string_substring in libvalacore.a(valageniescanner.o)
  _string_substring in libvalacore.a(valaintegerliteral.o)
  _string_substring in libvalacore.a(valainterface.o)
  _string_substring in libvalacore.a(valamarkupreader.o)
  _string_substring in libvalacore.a(valamethod.o)
  _string_substring in libvalacore.a(valaparser.o)
  _string_substring in libvalacore.a(valascanner.o)
  _string_substring in libvalacore.a(valasourcefile.o)
  _vala_string_literal_eval in libvalacore.a(valastringliteral.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status


The reason is that strnlen is not defined on macosx (at least on
10.6.4 + xcode 3). The easiest way is to implement it on this platform
as

size_t strnlen(const char *s, size_t n)
{
  const char *p = (const char *)memchr(s, 0, n);
  return(p ? p-s : n);
}
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] functions and null

2011-01-19 Thread Anatol Pomozov
2011/1/19 Pavol Klačanský :
> Hi, why this code doesn't work
>
Here the item is null
> Item item = null;
>
> parse_content(item);
>
And in this function you declared parameter as non-null
> parse_content(Item item) {
>        stderr.printf("argh");
> }
>
> reports
> ** (process:674): CRITICAL **: xml_parser_parse_content: assertion
> `item != NULL' failed

Unlike Java and other languages Vala has idea of nullable references.

You should declare your function as

parse_content(Item? item) {

pay attention to the question mark after the parameter type.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] vala code generation too constrained?

2011-01-11 Thread Anatol Pomozov
On Tue, Jan 11, 2011 at 11:42 AM, Jim Nelson  wrote:
> I'll jump in here.
>
> The original poster is asking that Vala relax some of its restrictions that
> are in place due to its relationship with C.  The only restriction that's
> been named so far (unless I missed something) is overloaded method names.
>
> Although I used overloaded methods a lot in my past work with Java and C++,
> I don't miss them at all with Vala.  They worked fine with Java.  Name
> mangling in C++ is, in my mind, completely broken, particularly since each
> vendor uses a different mangling scheme.  Not only does this impeded with
> building libraries, but walking a debugger stack trace is like studying the
> garbage a modem terminal program spits out when mom picks up the phone.
>
> Personally, I like being able to peruse valac's C code and understand what
> it's doing.  There are certain situations where this is invaluable,
> sometimes more valuable than symbolic debugging.

Automatic name mangling is not the only way to resolve name
overloading. Another way is to handle C names manually i.e. using
CCode

So following example
https://github.com/anatol/thrift/blob/vala/lib/vala/src/Server/Server.vala
instead of

Server(Processor, ServerTransport);
Server.with_transport(Processor, ServerTransport, TransportFactory);
Server.with_transport_and_protocol(Processor, ServerTransport,
TransportFactory, ProtocolFactory);
# Next method should be called
with_input_output_transport_and_protocol but I am too lazy to type it
every time in my Vala code
Server.with_all(Processor, ServerTransport, TransportFactory,
TransportFactory, ProtocolFactory, ProtocolFactory);

Wouldn't it be better to have name overloading, something like this

# Default cname
Server(Processor, ServerTransport);
[CCode (cname_suffix = "_with_transport')]
Server(Processor, ServerTransport, TransportFactory);
[CCode (cname_suffix = "_with_transport_and_protocol')]
Server(Processor, ServerTransport, TransportFactory, ProtocolFactory);
[CCode (cname_suffix = "_with_input_output_transport_and_protocol')]
Server(Processor, ServerTransport, TransportFactory, TransportFactory,
ProtocolFactory, ProtocolFactory);

> I understand the original poster's concern.  If I'm building a stand-alone
> application, it seems restrictive to be constrained by requirements that
> only apply to libraries.
>
> But so far the only objection I've heard on this thread is about overloaded
> methods.  Can anyone name other constraints that are headaches?

1) Valac cannot compile class if its name is too short. Try to create
class called 'A'.
2) Name clashing
http://mail.gnome.org/archives/vala-list/2010-December/msg00129.html
Can valac resolve it automatically?

>
> And are overloaded methods really such a got-to-have feature?  Or are they a
> nice-to-have you can live without?
>
> -- Jim
>
> On Tue, Jan 11, 2011 at 7:57 AM, pancake  wrote:
>
>> its 111 time :D
>>
>> On 01/11/11 11:11, Xavier Bestel wrote:
>>
>>> Typical English expression, AFAIK.
>>>
>> 1st time I heard it..but teh internets has some references. nice to know :P
>>
>>  And what's he's talking about, is Vala's way of mangling names to be
> usable in C, which can make some names that are different in Vala
> conflict once translated to C. That behavior is useful when you're
> coding a library (you want your lin usable from C), but not when you're
> building an application.
>
 I didn't read any "mangling" word in his mail, and I don't think this is
 a feature for Vala.. but ok, maybe i'm an "old timer".

> So he's asking for a switch to change name mangling, so that "My.Class"
> and "My_class" have different names in the generated code. I tend to
> agree with him.
>
 I think that enforcing decent name constrains is good, not only for
 C compatiblity.. but also to force the developer to look for readable
 and coherent names for its code.

 This "feature" will help to new users or people who don't want to know
 what C is, or just see Vala as a completely unlinked language to C, which
 is not the case.

>>> Say what you want, I see it as a purely technical limitation, which does
>>> more harm than good. There can be much head-scratching, trying to
>>> understand why there's a bug in the program while it's just a
>>> non-obvious mangling problem.
>>>
>>>  for me it's a aestethic than technical. I never had big problems with
>> name
>> mangling issues, because when you understand how Vala works you use
>> to type decent and legal names for classes and variables.
>>
>> But if this problem is such a pain for many people.. we should look for a
>> solution.
>>
>>  The 'name mangling' magic you are asking for will force all name symbol
 generation to append a random number or prefix everything with the
 file name.. this will keep C compatiblity but making readability harder.

>>> That's an implementation detail. You could always use traditional name
>>> mang

[Vala] Different flags for vapi generation

2011-01-10 Thread Anatol Pomozov
Hi,

I see several different flags for 'valac' that look similar

--library
--fast-vapi
--vapi
--internal-vapi/internal-header

All of these flags generate *.vapi file for sources. Can anyone
explain what is difference between these flags?

PS Ideally this information should be added to the valac man page.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Are nested interfaces disallowed?

2011-01-07 Thread Anatol Pomozov
ping.

Are nested classes/interfaces officially supported in vala?

Classes seems work fine with vala 0.10 [1], but not interfaces.


1)

public class AClass {
public class BClass {
public void print() {
stdout.printf("Hello, world!\n");
}
}
}

void main() {
var cl = new AClass.BClass();
cl.print();
}


On Tue, Dec 28, 2010 at 4:42 PM, Anatol Pomozov
 wrote:
> Hi,
>
> I have a class and I want to add a nested interface into it.
>
> public class AClass : Object {
>  public interface BClass : Object { public void foo() { } }
> }
>
> Valac 0.10.0 fails with following error:
>
> a.vala:2.2-2.33: error: unexpected declaration in class
>        public interface BClass : Object {
>        
>
> This sounds weird. If I change 'interface' to 'class' valac is ok with
> it and compiles my program without any error.
>
> What is the reason of nested interfaces prohibition?
>
___
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-04 Thread Anatol Pomozov
> Correct, something like this. GroovyTestCase itself is based on jUnit
> (de-facto standard unit framework in java world).
>
> There is a test framework in Glib already
> http://library.gnome.org/devel/glib/unstable/glib-Testing.html and IMO
> the best of all is to adopt it for Vala. There are at least 2 thing
> have to be done:
>  - add vapi bindings for these methods
>  - add documentation/examples that shows how to use tests with
> make/autotools/cmake in your project

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
myself [1] with its description [2].

I would say tests in GLib are slightly different from tests in java.
In GLib/Vala unit tests are simple programs that you compile the same
way as any other binaries. 'make' runs those programs and check its
exit code.

1) https://github.com/anatol/vala-sample/
2) http://pomozok.wordpress.com/2011/01/02/vala-autotools-example/
___
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-04 Thread Anatol Pomozov
Oops, it seems that there are a few messages were out of the maillist.
Let me copy it here.

Hi

On Mon, Dec 27, 2010 at 7:58 PM, b4283  wrote:
> Doesn't Vala already has assertion clauses ?
Assertions (and contract programming) is not the same as unit testing,
although they both serve the same thing - find bugs and states that
should never happen.

You inject assertions into your code so you can check internal state
during running program. From other side unit testing assumes that you
write special small and fast programs called testcases. And then you
run these small programs automatically, ideally after any your change
so you can be sure that the code works as expected.

Unit testing is widely used technique and almost any language has some
kind of framework that helps to create testcases
http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks

> I am not exactly sure what you mean by framework but that should be
> sufficient.
>
> Or do you mean a test class, something like GroovyTestCase to inherit from ?

Correct, something like this. GroovyTestCase itself is based on jUnit
(de-facto standard unit framework in java world).

There is a test framework in Glib already
http://library.gnome.org/devel/glib/unstable/glib-Testing.html and IMO
the best of all is to adopt it for Vala. There are at least 2 thing
have to be done:
 - add vapi bindings for these methods
 - add documentation/examples that shows how to use tests with
make/autotools/cmake in your project
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] string <-> bytes conversion in Vala

2010-12-29 Thread Anatol Pomozov
On Wed, Dec 29, 2010 at 3:51 PM, Anatol Pomozov
 wrote:
> Hi
>
> On Thu, Dec 23, 2010 at 12:37 AM, Anatol Pomozov
>  wrote:
>> Hi,
>>
>> I manipulate with strings in my application such as storing/reading
>> to/from binary files. And I need to convert a string to/from array of
>> bytes. What is the best way of doing it in Vala?
>>
>> Looking into string class http://valadoc.org/glib-2.0/string.html I
>> see a method called string#to_utf8() that converts string to array of
>> chars. But I cannot find any other methods.
>>
>> So I have 2 questions:
>>  - How to convert a string to array of chars in encoding different
>> from UTF8. Something like this one
>> http://download.oracle.com/javase/6/docs/api/java/lang/String.html#getBytes(java.nio.charset.Charset)
>>  - How to convert array of chars/uint8 back to string? Like this one
>> http://download.oracle.com/javase/6/docs/api/java/lang/String.html#String(byte[],
>> java.nio.charset.Charset)
>
> I think I found a way to convert string to bytes in Vala. Actually it
> is as simple as casting string to char* and back. Under the hood
> strings in vala is just a pointer to char.
>
> Here is an example that shows it:
>
>  string hello = "abcd";
>  char* ch = (char*) hello;
>  stdout.printf("%c\n", ch[1]); // Second char, that is 'b'

It actually produces an interesting effect. You *can* change content
of a string (that are claimed as immutable)

  string hello = "abcd";
  char* ch = (char*) hello;
  ch[0] = 'z';
  stdout.printf(hello); // Prints 'zbcd'

PS Casting string to/from char* is an interesting technique and worth
mention about it in the tutorial.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] string <-> bytes conversion in Vala

2010-12-29 Thread Anatol Pomozov
Hi

On Thu, Dec 23, 2010 at 12:37 AM, Anatol Pomozov
 wrote:
> Hi,
>
> I manipulate with strings in my application such as storing/reading
> to/from binary files. And I need to convert a string to/from array of
> bytes. What is the best way of doing it in Vala?
>
> Looking into string class http://valadoc.org/glib-2.0/string.html I
> see a method called string#to_utf8() that converts string to array of
> chars. But I cannot find any other methods.
>
> So I have 2 questions:
>  - How to convert a string to array of chars in encoding different
> from UTF8. Something like this one
> http://download.oracle.com/javase/6/docs/api/java/lang/String.html#getBytes(java.nio.charset.Charset)
>  - How to convert array of chars/uint8 back to string? Like this one
> http://download.oracle.com/javase/6/docs/api/java/lang/String.html#String(byte[],
> java.nio.charset.Charset)

I think I found a way to convert string to bytes in Vala. Actually it
is as simple as casting string to char* and back. Under the hood
strings in vala is just a pointer to char.

Here is an example that shows it:

  string hello = "abcd";
  char* ch = (char*) hello;
  stdout.printf("%c\n", ch[1]); // Second char, that is 'b'

  char[] bytes = new char[4]; // 3 symbols and null-terminator
  bytes[0] = '1';
  bytes[1] = '2';
  bytes[2] = '3';
  bytes[3] = 0;
  string str = (string)bytes;
  stdout.printf(@"$str\n");
  stdout.printf("%d\n", (int)str.length); // Prints '3'

WRT question 'how to convert strings to different encodings' I think
this should help
http://library.gnome.org/devel/glib/unstable/glib-Character-Set-Conversion.html
I haven't it used though.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Are nested interfaces disallowed?

2010-12-28 Thread Anatol Pomozov
Hi,

I have a class and I want to add a nested interface into it.

public class AClass : Object {
  public interface BClass : Object { public void foo() { } }
}

Valac 0.10.0 fails with following error:

a.vala:2.2-2.33: error: unexpected declaration in class
public interface BClass : Object {


This sounds weird. If I change 'interface' to 'class' valac is ok with
it and compiles my program without any error.

What is the reason of nested interfaces prohibition?
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Name clashes in generated C code

2010-12-28 Thread Anatol Pomozov
On Tue, Dec 28, 2010 at 6:29 AM, Jan Hudec  wrote:
> On Mon, Dec 27, 2010 at 13:46:47 -0800, Anatol Pomozov wrote:
>> Hi,
>>
>> I have a simple Vala program
>>
>> public struct Struct { string name; }
>> public enum Type { STRUCT }
>>
>> [...]
>> The problem here a name clash in generated Vala code - TYPE_STRUCT
>> both generated as type of Struct
>>
>> #define TYPE_STRUCT (struct_get_type ())
>>
>> and as a enum value
>>
>> typedef enum  {
>>     TYPE_STRUCT
>> } Type;
>>
>> what is the best way to avoid such clashes?
>
> Well, it depends on whether you are writing a library or an application.
>
> For library the API should be usable from C, so best way is just to avoid
> calling the enum 'Type'. For an application the C names don't matter though,
> so you can just tell vala to use different one in C.
>
>> Is it possible to change enum names to something else.
>
> Try using the [CCode(cprefix=...)] annotation. You'll find examples in the
> .vapi files. It's normally used to tell vala how externally provided things
> are called, but it should work for renaming things generated by vala too.

Yeah, it is what i was looking for. Thanks for sharing this info.

It would be really great to have some information about attributes we
can use in vala code. There is almost nothing about it in the tutorial
http://live.gnome.org/Vala/Tutorial

>> I can change enum name from Type to something else e.g. RecordType, but
>> I would like to know if there is a better solution.
>
> As I say, it depends on whether somebody will be using the API from C or not.
> If they will, rename the type. If not, rename the members with cprefix.

I am sure using [CCode] is ok for libraries as well if cprefix value
does not change very often.

Another example of "C compatible names clashing" is method
overloading. I use it a lot in Java and miss it Vala. I would love
that vala compiler take care about it, something like:

If a developer compiles program without -H and -C then valac tries to
generate unique names for clashing names/overload methods &
constructors. It does not matter what names overloaded methods have
while it is consistent. If a user wants to have a library with C API
then valac fails with error saying "Names A.B_bar and A_B.bar are
clashing, please define external name for it using [CCode]". Does it
make sense?
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Any xUnit framework for Vala?

2010-12-27 Thread Anatol Pomozov
Hi,

I am trying to add some tests to my application and I am looking for
an example of Vala application with tests.

As an Java developer I would expect that Vala has some xUnit like
framework http://en.wikipedia.org/wiki/XUnit but seems there is
nothing like this. There is also Glib Testing framework, but I cannot
find any examples for Vala as well.

What is "State of the Art" Vala application with unittests? I see that
Vala project itself does some magic with testwrapper.sh, is it
preferred solution?
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Name clashes in generated C code

2010-12-27 Thread Anatol Pomozov
Hi,

I have a simple Vala program

public struct Struct { string name; }
public enum Type { STRUCT }


It looks fine, but if you try to compile it fails with following error:



$ CC=clang valac a.vala
/usr/local/google/home/anatol/sources/learning/vala/a.vala.c:22:2:
error: expected '}'
TYPE_STRUCT
^
/usr/local/google/home/anatol/sources/learning/vala/a.vala.c:11:21:
note: instantiated from:
#define TYPE_STRUCT (struct_get_type ())
^
/usr/local/google/home/anatol/sources/learning/vala/a.vala.c:21:15:
note: to match this '{'
typedef enum  {
  ^
/usr/local/google/home/anatol/sources/learning/vala/a.vala.c:75:38:
error: initializer element is not a compile-time
  constant
static const GEnumValue values[] = {{TYPE_STRUCT,
"TYPE_STRUCT", "struct"}, {0, NULL, NULL}};

^
3 diagnostics generated.
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
--


The problem here a name clash in generated Vala code - TYPE_STRUCT
both generated as type of Struct

#define TYPE_STRUCT (struct_get_type ())

and as a enum value

typedef enum  {
TYPE_STRUCT
} Type;


what is the best way to avoid such clashes? Is it possible to change
enum names to something else. I can change enum name from Type to
something else e.g. RecordType, but I would like to know if there is a
better solution.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] string <-> bytes conversion in Vala

2010-12-23 Thread Anatol Pomozov
Hi,

I manipulate with strings in my application such as storing/reading
to/from binary files. And I need to convert a string to/from array of
bytes. What is the best way of doing it in Vala?

Looking into string class http://valadoc.org/glib-2.0/string.html I
see a method called string#to_utf8() that converts string to array of
chars. But I cannot find any other methods.

So I have 2 questions:
 - How to convert a string to array of chars in encoding different
from UTF8. Something like this one
http://download.oracle.com/javase/6/docs/api/java/lang/String.html#getBytes(java.nio.charset.Charset)
 - How to convert array of chars/uint8 back to string? Like this one
http://download.oracle.com/javase/6/docs/api/java/lang/String.html#String(byte[],
java.nio.charset.Charset)
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Complex number support?

2010-12-13 Thread Anatol Pomozov
Hi

2010/12/13 pancake :
> On 12/13/10 19:30, Aleksander Wabik wrote:
>>>
>>> -1 portability is VERY important if we want to use vala outside
>>> gnu/linux.
>>
>> I understand your point of view (the whole idea of sticking to
>> glib as a layer between vala and everything else is good). I'd then
>> propose to create c99 bindings: c99.vapi or something. It would not be
>> portable, just as such apis like posix aren't. Complex numbers would
>> not be part of vala language. But you would not have to use mpfr to get
>> the functionality that is available at the language level for 10 years.
>>
>> On the other hand, again: I personally think that the whole idea of
>> sticking to glib as a layer between vala and everything else is good;
>> the idea of maintaining glib compatibility with 20-years old tools is
>> awful (well, that should go to the glib list). Compatibility?
>>
>> icc: supports c99
>> rvct: yes, but without complex numbers (in version 3, I don't know what
>> about 4, but I hope that this will be implemented)
>> openwatcom: work in progress
>>
>> I don't want to start a flamewar here, but if by "portability" you mean
>> "compiling with microsoft compiler", I can not agree with this. From my
>> point of view, you just can not create a good, modern product using
>> non-modern tools. Not to mention that microsoft support for C language
>> is... unclear. I did not touch visual studio for a year, but in the
>> last version that I've seen there were no C compiler at all, only C++.
>>
>> Well, these were my 2 pennies.
>>
>> best regards,
>>
> I don't like visual studio, but is what you get if you work for a company
> that wants their product on windows.

You can compile C99 code on windows, you just need to use compiler
that supports this language standard (e.g. gcc). It is what other
projects recommend http://www.ffmpeg.org/faq.html#SEC34

But even with MinGW/gcc there are some limitation http://www.mingw.org/wiki/C99

> Actually all vala code compiles
> in clang, gcc, msvc, tcc, icc and forte. which is pretty good.
>
> I know that VisualStudio C compiler is pretty broken, but I would like
> to have Vala fit with the same C standard as GLIB does. Just for
> coherence.
>
> The features c99 adds to the language are not really useful and most
> of them (apart complex numbers) can be handled by the vala compiler
> (defining vars in the middle of the code, switch cases with ranges, ..)
>
> I have never need to use complex numbers.. so i dont see it as an
> important feature.
>
> But I understand that if you do stuff with maths you need complex, rational
> and big numbers .. and having the language support this can hardly
> benefit the development of apps in Vala for such tasks.
>
> What i'm proposing is just simpler. It keeps compatiblity with compiler and
> allows to use different backends to implement such kind of types. But
> requires
> to add support for operator overloading in vapis, which requires some
> discussion (as I already talk about this a year ago with Jürg).
>
> The use of complex numbers can be defined in a vapi file which make it use
> the C99-gcc magic you like, but it will also support other kind of backends,
> like native one or based on OpenSSL, GMP or MPFR.
>
> --pancake
> ___
> vala-list mailing list
> vala-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/vala-list
>
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Array.length

2010-12-06 Thread Anatol Pomozov
Hi

2010/12/6 Aleksander Wabik :
> Seems like https://bugzilla.gnome.org/show_bug.cgi?id=585847 , but it
> is claimed to be fixed. Maybe some corner case?

Or regression. I see that commit 5226feafef5 that fixes the given
issue does not have any unit tests.

> best regards,
>
>>It seems you found an error in vala.
>>However, this code works as expected:
>>
>>{
>>    string cadena = "uno,dos,tres,cuatro";
>>    string[] cadenas = cadena.split(",");
>>    stdout.printf("Cantidad de elementos %i\n", cadenas.length);
>>}
>>
>>
>>
>>On Mon, Dec 6, 2010 at 4:20 PM, Arley Consuegra Rosello
>> wrote:
>>> I'm have de following code.
>>> public class HelloVala: GLib.Object {
>>> public static int main (string[] args) {
>>> string cadena = "uno,dos,tres,cuatro";
>>> stdout.printf("Cantidad de elementos %i\n",cadena.split(",").length);
>>> return 0;
>>> }
>>> }
>>>
>>>
>>> compiled with Vala 0.10.0 in ubuntu maverick no warnings, no errors but
>>> the output is not fine at less for me.
>>>
>>> Output >    Cantidad de elementos 55
>>>
>>>
>>>
>>>
>>>
>>> ___
>>> 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
>
>
> --
> Mój klucz publiczny o identyfikatorze 1024D/E12C5A4C znajduje się na
> serwerze hkp://keys.gnupg.net
>
> My public key with signature 1024D/E12C5A4C is on the server
> hkp://keys.gnupg.net
>
> ___
> 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] Cannot have field and method with the same name

2010-12-04 Thread Anatol Pomozov
On Fri, Dec 3, 2010 at 5:08 PM, Evan Nemerson  wrote:
> On Fri, 2010-12-03 at 15:38 -0800, Anatol Pomozov wrote:
>> Hi,
>>
>> I have a class that contains a field and method with the same name,
>> and Valac does not like it. What is the reason? Other languages
>> (C#/Java) allow it. You have to use () for method so you know whether
>> you access method or field.
>
> I'm not a C# or Java programmer, so feel free to correct me if I'm wrong
> but...
>
> Java doesn't have delegates. In this example, what is X?

Ah, delegates, functions that act as variables. Now it a little bit clearer.

>
> public class Foo {
>  public boolean stop = true;
>
>  public boolean stop () {
>    return true;
>  }
>
>  public Foo () {
>    var X = this.stop;
>  }
> }
This example does not work. valac 0.11 complains with quite weird message

a.vala:11.7-11.18: error: Assignment: Cannot convert from `Foo.stop'
to `Foo.stop'
var x = this.stop;

We cannot use var - we need to declare Delegate type here. Something like

MyDelegateType x = this.stop;

But in this case it is clear that we want function. We cannot assign
field/property to a delegate, isn't it?

Sorry for stubbornness - I learn Vala and trying to illuminate all
dark corners. I am looking for an example that clearly shows why we
cannot have field/method with the same name.

> Actually, now that I think about it, I don't think Java does type
> inferencing either.
It is planned for Java7.
>
> In addition to type inferencing issues, this could cause problems with
> generics, and would generally be a pain to read.
Not sure what do you mean here.

>
> C# doesn't allow this either. AFAIK, in C# you can overload methods so
> that the most appropriate method is called, but you can't have a method
> and a property with the same name. Example:
>
> class Foo {
>  bool stop () {
>    return true;
>  }
>
>  // No problem
>  bool stop (bool a) {
>    return false;
>  }
>
>  // Problem
>  bool stop = false;
>
>  public static void Main () {
>    var foo = new Foo ();
>  }
> }
>
> Overloading methods is a separate issue, which Aleksander Wabik already
> explained.
>
>> anatol:vala $ valac a.vala
>> a.vala:4.3-4.21: error: `Foo' already contains a definition for `stop'
>>   public boolean stop() {
>>   ^^^
>> a.vala:2.3-2.21: note: previous definition of `stop' was here
>>   public boolean stop = true;
>>   ^^^
>> Compilation failed: 1 error(s), 0 warning(s)
>
> Amusingly, this is basically the same error message as you get in C# (at
> least from mcs):
>
> test.cs(12,8): error CS0102: The type `Foo' already contains a
> definition for `stop'
> test.cs(2,8): (Location of the symbol related to previous error)
> Compilation failed: 1 error(s), 0 warnings

Oops, my statement that it works in C# is wrong. I was looking at
incorrect C# example.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Cannot have field and method with the same name

2010-12-04 Thread Anatol Pomozov
2010/12/3 Aleksander Wabik :
>>I have a class that contains a field and method with the same name,
>>and Valac does not like it.
>
> Generally Vala does not have any usable symbol mangling engine. It's
> good, because Vala generates a C api and you obviously don't want to
> have obfuscated symbols there (the way that C++ does it is just awful).
> The drawback is that you can't have symbols with the same name but
> different semantics (eg. no function overloading). It's possible that
> the problem you have is the same, but if not - well, maybe it could be
> improved (as Vala has no function overloading and similar things, the
> semantic analyzer may be - and probably is - much simpler than in other
> languages, and it does not allow symbol 'overloading' on any scope -
> Vala, or C api).

In this particular case we don't need any method name obfuscation. If
I understand GObject correctly then method names never clash with
field names, as (virtual) methods are defined on the Class structure,
so generated C can have fields & virtual functions with the same name.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Cannot have field and method with the same name

2010-12-03 Thread Anatol Pomozov
Hi,

I have a class that contains a field and method with the same name,
and Valac does not like it. What is the reason? Other languages
(C#/Java) allow it. You have to use () for method so you know whether
you access method or field.

public class Foo {
  public boolean stop = true;

  public boolean stop() {
return true;
  }
}

anatol:vala $ valac a.vala
a.vala:4.3-4.21: error: `Foo' already contains a definition for `stop'
  public boolean stop() {
  ^^^
a.vala:2.3-2.21: note: previous definition of `stop' was here
  public boolean stop = true;
  ^^^
Compilation failed: 1 error(s), 0 warning(s)
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] gobject-introspect vs gir

2010-11-16 Thread Anatol Pomozov
Hi,

I am trying to understand write-vala-bindings fu and I would like to
clarify a couple of questions related to gen-introspect tool. There is
almost no information in wiki about it.

http://live.gnome.org/Vala/Bindings page recommends 2-step vapi generation
  1) Generate *.gi file using gen-introspect tool. It works for glib-style code.
  2) Generate vapi file using vapigen tool

Both tools are located in Vala repository. Why there are 2 steps here?

I also see a gir branch in Vala repository and it makes me believe
that this is the next gen-introspect tool. Where I can find more info
about *.gir format? What is the plan, are you going to replace
gen-introspect with it? Is it vala-specific or it is comes from glib?

I am trying to process Apache Thrift source code with gen-introspect
and I think that there is a bug. Should I try to fix it (or/and report
to bugzilla) or it is better to wait for gir-... stuff?
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Define constant at compile time

2010-11-16 Thread Anatol Pomozov
On Tue, Nov 16, 2010 at 11:44 AM, Jan Hudec  wrote:
> On Tue, Nov 16, 2010 at 18:51:12 +0100, Günther Wutz wrote:
>> It is possible to use cpp as Preprocessor. I'm working on a
>> wrapper-program to combine cpp and give it valac to compile. The easiest
>> way i found actually.
>
> Sorry. That's an extremely bad idea for most cases.
>
> The easiest way is to tell vala to emit the symbols that will then be defined
> when compiling the generated C code. That way vala will guard you from name
> conflicts and the code will be more readable.

"preprocessor" is probably a bad word as it makes people think about
C-style preprocessor. If I understand the request correctly one wants
"compile-time type-safe constants substitution".

> In C, the preprocessor is generally used for two things:
>  - symbolic constants -- but real constants serve the purpose better and

But what if you want to change the real constant value at the
compile-time? A classical example is DEBUG vs OPTIMIZED mode. During
development I want to log of information to stdout, like this:

if (DEBUG) {
  stdout.printf("User ID is: $user");
}

and I don't want to have this code in the release version. To make it
happen one can use something like

bool DEBUG=false;

and compile the vala program with -DDEBUG (or its equivalent
-DDEBUG=true). This compiler flag changes the default value of the
const.

Type-safety means that vala compile knows that DEBUG is boolean and
complains if someone tries to use number/string here (-DDEBUG=foo) or
tries to set value for unexisting constant.

>  - generic constructs -- but vala does have generics, so you don't need
>   those.
> Even in C++ you usually avoid the preprocessor for most things, because
> preprocessor symbols cannot be scoped. Which is doubly so applicable to vala.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] vala-gen-introspect does not add my struct to *.gi file

2010-11-02 Thread Anatol Pomozov
On Tue, Nov 2, 2010 at 5:59 AM, Abderrahim Kitouni  wrote:
> Hello,
>                  في ن، 01-11-2010 عند 14:42 -0700 ، كتب Anatol Pomozov:
>> Hi,
>>
>> I have a smaller repo case. On my Ubuntu 10.04 I run
>>
>> /usr/local/lib/vala-0.10/gen-introspect-0.10 --namespace=Thrift
>> -I/usr/local/include/thrift -I/usr/include/glib-2.0
>> -I/usr/lib/glib-2.0/include
>> /usr/local/include/thrift/protocol/thrift_protocol.h
>> /usr/local/lib/libthrift_c_glib.so
>>
>> It generates metadata for only 2 structures ThriftProtocolError and
>> ThriftProtocol. Why the tool does not generate information for other
>> structures such as ThriftType, ThriftMessageType and
>> ThriftProtocolClass.
>>
>> http://github.com/anatol/thrift/blob/c_glib/lib/c_glib/src/protocol/thrift_protocol.h
>>
>> I am really new to gtk OO style so I don't understand what is going on here.
> I guess the problem with ThriftType and ThriftMessageType is that they
> aren't defined in the "standard" way "typedef enum {...} EnumName" as is
> the case with ThriftProtocolError. (even glib-mkenums wouldn't find
> them). As for ThriftProtocolClass, it seems really weird.

Thanks for the help. "Fixing" the enum helped. Now i see the enums in
the *.gi file.

ThriftProtocolClass still not extracted.


anatol:vala $ vapigen --library thrift thrift/thrift_c_glib.gi
error: The type name `Thrift.ProtocolClass' could not be found
error: The type name `Thrift.ProtocolFactoryClass' could not be found
error: The type name `Thrift.ServerClass' could not be found
Generation failed: 3 error(s), 0 warning(s)
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] vala-gen-introspect does not add my struct to *.gi file

2010-11-01 Thread Anatol Pomozov
Hi,

I have a smaller repo case. On my Ubuntu 10.04 I run

/usr/local/lib/vala-0.10/gen-introspect-0.10 --namespace=Thrift
-I/usr/local/include/thrift -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include
/usr/local/include/thrift/protocol/thrift_protocol.h
/usr/local/lib/libthrift_c_glib.so

It generates metadata for only 2 structures ThriftProtocolError and
ThriftProtocol. Why the tool does not generate information for other
structures such as ThriftType, ThriftMessageType and
ThriftProtocolClass.

http://github.com/anatol/thrift/blob/c_glib/lib/c_glib/src/protocol/thrift_protocol.h

I am really new to gtk OO style so I don't understand what is going on here.

On Fri, Oct 29, 2010 at 6:10 PM, Anatol Pomozov
 wrote:
> Hi, everyone. I have a question related to vala-gen-introspect tool.
>
> I am trying to add a Vala support for Apache Thrift
> http://incubator.apache.org/thrift/
> https://issues.apache.org/jira/browse/THRIFT-764
>
> Instead of writing a library I want to reuse glib based c based
> library for Thrift
> http://github.com/anatol/thrift/tree/c_glib/lib/c_glib/test/ and now I
> am working on Vala binding for this great library from Apache.
>
> I use http://live.gnome.org/Vala/Bindings page that shows how to
> create a .vapi file step-by-step. So I run
>
> $ vala-gen-introspect thrift_c_glib thrift
>
> It generates *.gi file http://pastie.org/1259281 which seems
> incorrect. What makes me think that it is incorrect is following
> command
>
> anatol:vala $ vapigen --library thrift thrift/thrift_c_glib.gi
> error: The type name `Thrift.ProtocolClass' could not be found
> error: The type name `Thrift.ProtocolFactoryClass' could not be found
> error: The type name `Thrift.ServerClass' could not be found
> error: The type name `Thrift.Type' could not be found
> .
> error: The type name `Thrift.Type' could not be found
> error: The type name `Thrift.MessageType' could not be found
> Generation failed: 16 error(s), 0 warning(s)
>
> So vapigen cannot find Thrift.ProtocolClass class. If we look into
> *.gi file (see the pastie link) gi mentions it only once
>
> 
>  
> 
>
> But if you look at its definition here
> http://github.com/anatol/thrift/blob/c_glib/lib/c_glib/src/protocol/thrift_protocol.h
> you'll see
>
> /*!
>  * Thrift Protocol object
>  */
> struct _ThriftProtocol
> {
>  GObject parent;
>
>  /* protected */
>  ThriftTransport *transport;
> };
> typedef struct _ThriftProtocol ThriftProtocol;
>
> Which seems fine to me (it looks the same as ThriftBinaryProtocol definition).
>
> Could you help me to understand why the tool does not add
> ThriftProtocolClass to the known structures?
>
>
>
>
> One more question here: why this process has 2 steps? Why it generates
> *.gi file. Is it used some where else (outside of Vala API
> generation)?
>
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] vala-gen-introspect does not add my struct to *.gi file

2010-10-29 Thread Anatol Pomozov
Hi, everyone. I have a question related to vala-gen-introspect tool.

I am trying to add a Vala support for Apache Thrift
http://incubator.apache.org/thrift/
https://issues.apache.org/jira/browse/THRIFT-764

Instead of writing a library I want to reuse glib based c based
library for Thrift
http://github.com/anatol/thrift/tree/c_glib/lib/c_glib/test/ and now I
am working on Vala binding for this great library from Apache.

I use http://live.gnome.org/Vala/Bindings page that shows how to
create a .vapi file step-by-step. So I run

$ vala-gen-introspect thrift_c_glib thrift

It generates *.gi file http://pastie.org/1259281 which seems
incorrect. What makes me think that it is incorrect is following
command

anatol:vala $ vapigen --library thrift thrift/thrift_c_glib.gi
error: The type name `Thrift.ProtocolClass' could not be found
error: The type name `Thrift.ProtocolFactoryClass' could not be found
error: The type name `Thrift.ServerClass' could not be found
error: The type name `Thrift.Type' could not be found
.
error: The type name `Thrift.Type' could not be found
error: The type name `Thrift.MessageType' could not be found
Generation failed: 16 error(s), 0 warning(s)

So vapigen cannot find Thrift.ProtocolClass class. If we look into
*.gi file (see the pastie link) gi mentions it only once


  


But if you look at its definition here
http://github.com/anatol/thrift/blob/c_glib/lib/c_glib/src/protocol/thrift_protocol.h
you'll see

/*!
 * Thrift Protocol object
 */
struct _ThriftProtocol
{
  GObject parent;

  /* protected */
  ThriftTransport *transport;
};
typedef struct _ThriftProtocol ThriftProtocol;

Which seems fine to me (it looks the same as ThriftBinaryProtocol definition).

Could you help me to understand why the tool does not add
ThriftProtocolClass to the known structures?




One more question here: why this process has 2 steps? Why it generates
*.gi file. Is it used some where else (outside of Vala API
generation)?
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] GNU extensions :P

2010-10-28 Thread Anatol Pomozov
Hi

On Thu, Oct 28, 2010 at 6:50 AM, CaStarCo  wrote:
> Hello , i have a question about Vala.. :p
>
> It's needed the gcc compiler?
No, gcc is not a requirement. Vala generates very accurate
standard-complaint C code. Any decent compiler is fine.

Actually I prefer to use clang (c frontend for llvm) because of better
error/warning reporting.

You can change C compiler by setting "CC" env var like this:

$ CC=clang vala myprog.vala

> or the C generated code can be compiled with
> other compilers such as Vala?
Vala is not C compiler.
>
> --
> - Per la llibertat del coneixement -
> - Per la llibertat de la ment...       -
>
> ___
> 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] [ANNOUNCE] Vala 0.10.1 - Compiler for the GObject type system

2010-10-26 Thread Anatol Pomozov
Hi, Jurg.

Thanks for the release.

One thing that confuses me is versioning policy for Vala. 0.11 version
has been release recently, now you release 0.10. Also git repository
as well as some developers mention 0.12 version. What is these
versions for, what are the difference between them? Is there any doc
that describes it? What is the recommended version?

On Tue, Oct 26, 2010 at 11:33 AM, Jürg Billeter  wrote:
> We are pleased to announce version 0.10.1 of Vala, a compiler for the
> GObject type system.
>
> Vala 0.10.1 is now available for download at:
>   http://download.gnome.org/sources/vala/0.10/
>
> Changes since 0.10.0
>  * Remove outdated GTK+ 3 bindings.
>  * Many bug fixes and binding updates.
>
> Vala is a new programming language that aims to bring modern programming
> language features to GNOME developers without imposing any additional
> runtime requirements and without using a different ABI compared to
> applications and libraries written in C.
>
> valac, the Vala compiler, is a self-hosting compiler that translates
> Vala source code into C source and header files. It uses the GObject
> type system to create classes and interfaces declared in the Vala source
> code.
>
> The syntax of Vala is similar to C#, modified to better fit the GObject
> type system. Vala supports modern language features as the following:
>
>        * Interfaces
>        * Properties
>        * Signals
>        * Foreach
>        * Lambda expressions
>        * Type inference for local variables
>        * Generics
>        * Non-null types
>        * Assisted memory management
>        * Exception handling
>
> Vala is designed to allow access to existing C libraries, especially
> GObject-based libraries, without the need for runtime bindings. All that
> is needed to use a library with Vala is an API file, containing the class
> and method declarations in Vala syntax. Vala currently comes with
> bindings for GLib and GTK+. It's planned to provide generated bindings for
> the full GNOME Platform at a later stage.
>
> Using classes and methods written in Vala from an application written in
> C is not difficult. The Vala library only has to install the generated
> header files and C applications may then access the GObject-based API of
> the Vala library as usual. It should also be easily possible to write a
> bindings generator for access to Vala libraries from applications
> written in e.g. C# as the Vala parser is written as a library, so that
> all compile-time information is available when generating a binding.
>
> More information about Vala is available at
>
>        http://www.vala-project.org/
>
>
> Jürg Billeter
>
> ___
> 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] Vala tutorial translation into Russian.

2010-10-05 Thread Anatol Pomozov
Hi, Bulat.

On Tue, Oct 5, 2010 at 9:17 AM, Bulat Shafigullin  wrote:
> Hello everybody!
>
> My name is bulat. I'm very proud to announce that small group of
> enthusiasts is just finishing translation of
> Vala tutorial into Russian. All work is held at
> http://translated.by/you/vala-tutorial/into-ru/trans/.
> Actually all translation is done and further text review is required.
> I hope it will be completely ready next week.
>
> Any kind of help and comments are very welcome.

The translation looks really great. Thanks for doing this.

I think this article worth mention on a Russian IT site (e.g. habr.ru)
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] "Asynchronous Stream Reading" example does not work

2010-09-19 Thread Anatol Pomozov
On Sun, Sep 19, 2010 at 7:43 AM, JM  wrote:
> It works for me on vala-0.10.0 . Did you try it with a textfile as arg?
> Jörn
>
>
>> Hi,
>> I have MacOSX 10.6, vala 0.10, libgee 0.5.3, glib 2.25.17. I run
>> examples from this page http://live.gnome.org/Vala/GIOSamples and all
>> of them work fine except "Asynchronous Stream Reading" one.
>>
>> I build it with "valac --pkg gio-2.0 example.vala" and then run as
>> ./example I have following failure. I don't know what does it mean,
>> probably the example should be updated.
>>
>>
>>
>> Error 01!
>> start...
>> (process:74938): GLib-GIO-CRITICAL **:
>> g_data_input_stream_read_line_async: assertion `G_IS_DATA_INPUT_STREAM
>> (stream)' failed

I was able to localize it. With following code I have "Operation not
supported" Error. I am not sure what exactly operation is not
supported


public class AsyncReadLineTest {
public static int main(string[] args) {
File f = File.new_for_uri("http://www.gnome.org";);
try {
DataInputStream di_stream = new DataInputStream(f.read(null));
} catch (GLib.Error e) {
print("%s\n", e.message);
}   
return 0;
}
}
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] "Asynchronous Stream Reading" example does not work

2010-09-19 Thread Anatol Pomozov
Hi,
I have MacOSX 10.6, vala 0.10, libgee 0.5.3, glib 2.25.17. I run
examples from this page http://live.gnome.org/Vala/GIOSamples and all
of them work fine except "Asynchronous Stream Reading" one.

I build it with "valac --pkg gio-2.0 example.vala" and then run as
./example I have following failure. I don't know what does it mean,
probably the example should be updated.



Error 01!
start...
(process:74938): GLib-GIO-CRITICAL **:
g_data_input_stream_read_line_async: assertion `G_IS_DATA_INPUT_STREAM
(stream)' failed
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Compiling vala 0.10 on macosx

2010-09-18 Thread Anatol Pomozov
Hi,

I am trying to compile vala-0.10 on mac 10.6 (snow leopard).

valac itself compiles and seems work fine, but 'make test' is failing:

1) One of the failures is "xargs no such argument -r" comes from
tests/testrunner.sh
line
if $VALAC $VALAFLAGS -o test$EXEEXT $(echo $PACKAGES | xargs -n 1 -r echo -n
" --pkg") main.vala &>log; then

Indeed, according to http://unixhelp.ed.ac.uk/CGI/man-cgi?xargs argument
"-r" is a GNU extension and FreeBSD/Mac does not have it. If we just remove
this option most of the tests are green, except...


2) Except 6 dbus tests that fail with following message:
** CRITICAL **: file /Users/anatol/sources/vala/tests/_test/main.c: line
20160: uncaught error: Cannot spawn a message bus without a machine-id:
Unable to load /var/lib/dbus/machine-id: Failed to open file
'/var/lib/dbus/machine-id': No such file or directory (g-file-error-quark,
4)
aborting...
dbus.async.server.check: line 4: 98103 Trace/BPT trap  ./test
/dbus/async/server
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or
kill -l [sigspec]
  /dbus/signals/server:FAIL
Failed to start message bus: launchd's environment variable
DBUS_LAUNCHD_SESSION_BUS_SOCKET is empty, but should contain a socket path.

EOF in dbus-launch reading address from bus daemon


I am not sure where it comes from, but there is no such
file /var/lib/dbus/machine-id on my computer, I
have /opt/local/var/lib/dbus/machine-id though.

$ sudo ls -l /opt/local/var/lib/dbus/machine-id
-rw-r--r--  2 root  admin  33 Sep 18 07:03
/opt/local/var/lib/dbus/machine-id
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Vala compilation fails

2010-09-18 Thread Anatol Pomozov
Hi

On Fri, Sep 17, 2010 at 11:37 PM, Luca Bruno  wrote:

> On Fri, Sep 17, 2010 at 06:39:05PM -0700, Anatol Pomozov wrote:
> > It seems that master is broken. I checked out 0.10 tag and now it
> compiles
> > fine, although it fails on "make check" http://pastie.org/1166017
>
> Expected if you don't have latest glib development installed. Tests target
> glib 2.26 (unreleased).
>

Ok, it explains it. Ubuntu Lucid has 2.24 version.

http://packages.ubuntu.com/lucid/libglib2.0-0
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] [PATCH] Use valac instead of vala as a compiler

2010-09-18 Thread Anatol Pomozov
If we leave vala it produces following error:

$ ./autogen.sh --prefix=/opt/vala
No source file specified.
**Error**: You must have valac >= 0.7.0 installed
  to build vala. Download the appropriate package
  from your distribution or get the source tarball at
  http://download.gnome.org/sources/vala/

The underlying problem is that 'vala --version' does not produce
version string.

$ /opt/vala/bin/vala --version
No source file specified.
$ /opt/vala/bin/valac --version
Vala 0.10.0
---
 doc/building.txt |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/building.txt b/doc/building.txt
index ad205eb..159ec48 100644
--- a/doc/building.txt
+++ b/doc/building.txt
@@ -32,7 +32,7 @@ Compiling the newest Vala from the repository:
 
 git clone git://git.gnome.org/vala
 cd vala
-export VALAC=/opt/vala-release/bin/vala
+export VALAC=/opt/vala-release/bin/valac
 ./autogen.sh --prefix=/opt/vala
 make && sudo make install
 
@@ -40,7 +40,7 @@ Maybe you want to compile the new Vala with itself. Then you 
simply go over
 it again:
 
 make distclean
-export VALAC=/opt/vala/bin/vala
+export VALAC=/opt/vala/bin/valac
 ./autogen.sh --prefix=/opt/vala
 make && sudo make install
 
-- 
1.7.2.3

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


Re: [Vala] Vala compilation fails

2010-09-17 Thread Anatol Pomozov
Hi

On Fri, Sep 17, 2010 at 6:01 PM, Anatol Pomozov wrote:

> Hi,
>
> I just started learning Vala. I cloned vala repo from git://
> git.gnome.org/vala and run ./autogem.sh  (See log here
> http://pastie.org/1165976).
>
> Everything looks fine, but when I run make - compilation fails
>
> anatol:vala $ make
> make  all-recursive
> make[1]: Entering directory
> `/usr/local/google/home/anatol/sources/opensource/vala/vala'
> Making all in gee
> make[2]: Entering directory
> `/usr/local/google/home/anatol/sources/opensource/vala/vala/gee'
>   VALAC  arraylist.vala collection.vala hashmap.vala hashset.vala
> iterable.vala iterator.vala list.vala map.vala set.vala
> **
> ERROR:valasemanticanalyzer.c:2886:vala_semantic_analyzer_get_actual_type:
> assertion failed: (instance_type != NULL)
> /bin/sh: line 1:   849 Aborted /usr/bin/valac
> --disable-version-header -C --vapidir ./../vapi --pkg gobject-2.0 -H
> valagee.h --library gee arraylist.vala collection.vala hashmap.vala
> hashset.vala iterable.vala iterator.vala list.vala map.vala set.vala
> make[2]: *** [gee.vala.stamp] Error 134
> make[2]: Leaving directory
> `/usr/local/google/home/anatol/sources/opensource/vala/vala/gee'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory
> `/usr/local/google/home/anatol/sources/opensource/vala/vala'
> make: *** [all] Error 2
>
>
> I really don't understand what does it mean. Can you help me to resolve it?
>

It seems that master is broken. I checked out 0.10 tag and now it compiles
fine, although it fails on "make check" http://pastie.org/1166017
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Vala compilation fails

2010-09-17 Thread Anatol Pomozov
Hi,

I just started learning Vala. I cloned vala repo from git://
git.gnome.org/vala and run ./autogem.sh  (See log here
http://pastie.org/1165976).

Everything looks fine, but when I run make - compilation fails

anatol:vala $ make
make  all-recursive
make[1]: Entering directory
`/usr/local/google/home/anatol/sources/opensource/vala/vala'
Making all in gee
make[2]: Entering directory
`/usr/local/google/home/anatol/sources/opensource/vala/vala/gee'
  VALAC  arraylist.vala collection.vala hashmap.vala hashset.vala
iterable.vala iterator.vala list.vala map.vala set.vala
**
ERROR:valasemanticanalyzer.c:2886:vala_semantic_analyzer_get_actual_type:
assertion failed: (instance_type != NULL)
/bin/sh: line 1:   849 Aborted /usr/bin/valac
--disable-version-header -C --vapidir ./../vapi --pkg gobject-2.0 -H
valagee.h --library gee arraylist.vala collection.vala hashmap.vala
hashset.vala iterable.vala iterator.vala list.vala map.vala set.vala
make[2]: *** [gee.vala.stamp] Error 134
make[2]: Leaving directory
`/usr/local/google/home/anatol/sources/opensource/vala/vala/gee'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory
`/usr/local/google/home/anatol/sources/opensource/vala/vala'
make: *** [all] Error 2


I really don't understand what does it mean. Can you help me to resolve it?
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list