Re: [Vala] Generics and Contract Programming

2011-06-24 Thread Nicolas

Hi Chris,

1) For assertations, try this:

[indent=4]

def static foo (ref args : array of string, opts : T, ...) of T
requires (args.length  1)
// do something

init
print hello world

2) For generics, try this:

[indent=4]

class Wrapper of G : GLib.Object

data : private G

def set_data(data : G)
this.data = data

def get_data() : G
return this.data

init
var wrapper = new Wrapper of string
wrapper.set_data(test)
var data = wrapper.get_data()

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


Re: [Vala] Generics and Contract Programming

2011-06-24 Thread Chris Molozian

Ah ok, it was the of T that I wasn't sure how to do.

Thank you,

Chris


On 06/24/11 13:48, Nicolas wrote:

Hi Chris,

1) For assertations, try this:

[indent=4]

def static foo (ref args : array of string, opts : T, ...) of T
requires (args.length  1)
// do something

init
print hello world

2) For generics, try this:

[indent=4]

class Wrapper of G : GLib.Object

data : private G

def set_data(data : G)
this.data = data

def get_data() : G
return this.data

init
var wrapper = new Wrapper of string
wrapper.set_data(test)
var data = wrapper.get_data()

Regards,
Nicolas.

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


Re: [Vala] [Genie] OptionContext not setting reference

2011-06-24 Thread Nicolas

Hello again !

The problem in your program is: args = args[1:args.length]
The first arg is not taken by the program, so just delete this 
unecessary line, and it works !


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


Re: [Vala] [Genie] OptionContext not setting reference

2011-06-24 Thread Chris Molozian

Thanks,

I had hoped that args = args[1:args.length] was an elegant way to 
remove an argument from the array that is of no use to my program. It 
seems that line didn't do what I expected.


Cheers,

Chris


On 06/24/11 15:58, Nicolas wrote:

Hello again !

The problem in your program is: args = args[1:args.length]
The first arg is not taken by the program, so just delete this 
unecessary line, and it works !


Regards,
Nicolas.

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


Re: [Vala] opengl and gtk+-3.0

2011-06-24 Thread august

Is there any way right now to open a GL context up inside of a GTK+3
window using vala?


 I've been trying to automatically parse the headers glext.h and glxext.h so I 
 could use OpenGL functions that aren't available in the current gl.vapi 
 (anything beyond OpenGL 1.3). So far, I've managed to produce bindings for 
 the 
 functions and the constants defined in both headers. I'm not sure what to do 
 with the types, though.
 
 Is there anywhere I can go to find out what all the [IntegerType (rank=9)] 
 stuff 
 means, and how I decide to use rank=9 versus rank=7 or 6, or whatever number 
 strikes my fancy?
 
 I've attached my progress so far. There are two python  files; each of them 
 parse the header they are named after. Two directories need to be present
 before either script runs: intermediates and xintermediates.
 
 To run the script, type:
 
 python vala_glext_header_parser.py debug
 
 The scripts produces 4 things:
 1. and 2.) A constants.vapi and functions.vapi file either in 
 intermediates 
 or xintermediates, depending on whether the parser is for GL or GLX.
 
 3.) A debug log
 
 4.) A list of the types used in each function printed to the command line. 
 This 
 is so I have an easy-to-reference list of the types used in the .vapi that 
 need 
 binding.
 
 
 On Mon Jun 5 2011, august wrote:
 Are there .vapi's that work with openGL and GTK+-3.0?
 
 any examples?
 
 thanks -august.





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


-- 
---
http://aug.ment.org



signature.asc
Description: Digital signature
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] [Genie] Anonymous functions

2011-06-24 Thread Chris Molozian

Hey,

I'm starting to get the hang of Genie programming, there's still a few 
things I can't see how to do. How would I create an anonymous function? 
e.g. What's the Genie equivalent to:


delegate int Comparator(int a, int b);

void my_sorting_algorithm(int[] data, Comparator compare) {
// ... 'compare' is called somewhere in here ...
}

void main() {
int[] data = { 3, 9, 2, 7, 5 };
// An anonymous method is passed as the second argument:
my_sorting_algorithm(data, (a, b) = {
if (a  b) return -1;
if (a  b) return 1;
return 0;
});
}

Regards,

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


[Vala] [Genie] Anonymous functions

2011-06-24 Thread Nicolas

Chris,

I'm not sure genie support closure, if someone can confirm...
For the delegate, try something like this:

[indent=4]

delegate DelegateType (a : int) : bool

def f1 (a:int) : bool
print testing delegate value %d, a
return true

def f2 (d:DelegateType, a:int)
var c = d (a)

init
f2 (f1, 5)

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