Commits

Reid van Melle committed 266a2b5

Got the score working I think

Comments (0)

Files changed (4)

clutter/clutter.props

   method remove : "int -> unit"
   method remove_all
   method get_timeline : "int -> timeline obj"
-  method list_timelines : "timeline obj array"
+  method list_timelines : "timeline obj list"
   method start
   method pause
   method stop

clutter/clutterProps.ml

   external remove_all : [>`score] obj -> unit = "ml_clutter_score_remove_all"
   external get_timeline : [>`score] obj -> int -> timeline obj
     = "ml_clutter_score_get_timeline"
-  external list_timelines : [>`score] obj -> timeline obj array
+  external list_timelines : [>`score] obj -> timeline obj list
     = "ml_clutter_score_list_timelines"
   external start : [>`score] obj -> unit = "ml_clutter_score_start"
   external pause : [>`score] obj -> unit = "ml_clutter_score_pause"

clutter/ml_score.c

   return ret; 
 }
 
-CAMLprim value ml_clutter_score_append() {}
-CAMLprim value ml_clutter_score_list_timelines() {}
+CAMLprim value ml_clutter_score_append(value score, value parent, value t)
+{
+  CAMLparam3(score, parent, t);
+  ClutterTimeline* p = Option_val(parent, ClutterTimeline_val, NULL);
+  CAMLreturn(Val_int
+	     (clutter_score_append(ClutterScore_val(score), p,
+				   ClutterTimeline_val(t))));
+}
+
+// FIXME: ensure this use of Val_ClutterTimeline_ is OK
+CAMLprim value ml_clutter_score_list_timelines(value score)
+{
+  CAMLparam1(score);
+  GSList* ts = clutter_score_list_timelines(ClutterScore_val(score));
+  CAMLreturn(Val_GSList(ts, Val_ClutterTimeline_));
+}
 
 ML_4(clutter_score_append_at_marker, ClutterScore_val, ClutterTimeline_val,
      String_val, ClutterTimeline_val, Val_int)

tests/test-score.ml

     Array.init 5
       (fun i ->
 	 let t = Timeline.new_for_duration 1000 () in
-	 Gobject.Property.set_dyn t#obj "timeline-name"
-	   (`STRING (Some (sprintf "Timeline %d" i)));
+	 (*Gobject.Property.set_dyn t#obj "timeline-name"
+	   (`STRING (Some (sprintf "Timeline %d" i)));*)
 	 t) in
   
   timeline2#add_marker_at_time "foo" 500;
   let _ = score#connect#timeline_started
     (fun _ t ->
        for i=1 to !level do printf " " done;
-       printf "Started timeline: '%s'\n%!"
-	 (match Gobject.Property.get_dyn t "timeline-name" with
+       printf "Started timeline: '%d'\n%!" 0;
+       (* (match Gobject.Property.get_dyn t "timeline-name" with
 	      `STRING Some x -> x
-	    | _ -> "wft?");
+	    | _ -> "wft?");*)
        incr level;
     )
   and _ = score#connect#timeline_completed
     (fun _ t ->
        decr level;
        for i=1 to !level do printf " " done;
-       printf "Completed timeline: '%s'\n%!"
-	 (match Gobject.Property.get_dyn t "timeline-name" with
+       printf "Completed timeline: '%d'\n%!" 0;
+	(* (match Gobject.Property.get_dyn t "timeline-name" with
 	      `STRING Some x -> x
-	    | _ -> "wft?");
+	    | _ -> "wft?");*)
     )
   and _ = score#connect#completed
     (fun _ -> clutter_quit ())
   score#append_at_marker ~parent:timeline2 ~marker:"foo" timeline5;
 
   let timelines = score#list_timelines in
+  printf "timelines=%d\n%!" (List.length timelines);
   assert ((Array.length timelines) = 5);
 
   score#start;