Permalink
Browse files

modified: CMakeLists.txt

	modified:   commands.gs
	new file:   test.vala
  • Loading branch information...
iloveaok
iloveaok committed Apr 27, 2012
1 parent 95f9d64 commit f7011bcc6b2aec4cb9b633a0a66d686a169c4da5
Showing with 42 additions and 3 deletions.
  1. +1 −1 CMakeLists.txt
  2. +4 −2 commands.gs
  3. +37 −0 test.vala
View
@@ -37,7 +37,7 @@ set(LIB_PATHS
link_directories(${LIB_PATHS})
set(VALA_SRC
- commands.gs
+ test.vala#commands.gs
)
vala_precompile(VALA_C
View
@@ -34,11 +34,13 @@ class Command : Object
columnname // requires "from" clause
customexpr?? */
//construct from_strings(columns : list of string)
- // pass
+ // init//code that pertains to the initlization of the class
construct(columns : list of Column)
var y = new dict of string,Column
+ relevant_columns = new dict of string,Column
for c in columns
- y["as"] = c
+ y[c.name] = c // works
+ relevant_columns[c.name] = c // works not
init
/* test dicts */
View
@@ -0,0 +1,37 @@
+using Gee;
+
+class Test : Object {
+ public HashMap<string, string> d;
+ public ArrayList<string> l;
+ construct {
+ l = new ArrayList<string> ();
+ d = new HashMap<string, string> ();
+ }
+ public Test(ArrayList<string> list) {
+ foreach (string s in list)
+ l.add(s);
+ }
+ public Test.from_dict(HashMap<string, string> dict) {
+ foreach (var entry in dict.entries)
+ d[entry.key] = entry.value;
+ }
+}
+
+void main () {
+ // ARRAY
+ var list = new ArrayList<string> ();
+ list.add("one");
+ var t = new Test(list);
+ foreach (string s in t.l)
+ stdout.printf ("%s\n", s);
+ // DICT
+ var map = new HashMap<string, string> ();
+ map["four"] = "4"; // same as map.set ("four", 4)
+ map["five"] = "5";
+ string a = map.get ("four");
+ string b = map["four"]; // same as map.get ("four")
+ assert (a == b);
+ var tt = new Test.from_dict(map);
+ foreach (var entry in tt.d.entries)
+ stdout.printf ("%s => %s\n", entry.key, entry.value);
+}

0 comments on commit f7011bc

Please sign in to comment.