Source

clutter-ocaml / clutter / ml_score.c

Full commit
#include "wrappers.h"
#include "ml_score.h"
#include "ml_timeline.h"

#define gobject_list_of_GSList_free(l)  Val_GSList_free (l, (value_in) Val_GObject)

static struct custom_operations ml_clutter_score_ops = {
  "ClutterScore",
  custom_finalize_default,
  custom_compare_default,
  custom_hash_default,
  custom_serialize_default,
  custom_deserialize_default
};

value Val_ClutterScore_ (ClutterScore *t, gboolean ref)
{ 
  ClutterScore **p;
  value ret; 
  //if (t == NULL) ml_raise_null_pointer(); 
  ret = alloc_custom (&ml_clutter_score_ops, sizeof t, 
		      100, 1000);
  p = Data_custom_val (ret);
  *p = ref ? g_object_ref (t) : t;
  return ret; 
}

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))));
}

#define Val_GtkTextTag_new(val) (Val_GObject_new((GObject*)val))
// 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(gobject_list_of_GSList_free(ts));
  /// of should I use Val_GSList_free ? I assume this is a memory leak
  //CAMLreturn(Val_GSList_free(ts, (value_in)Val_ClutterTimeline));
}

ML_4(clutter_score_append_at_marker, ClutterScore_val, ClutterTimeline_val,
     String_val, ClutterTimeline_val, Val_int)
ML_2(clutter_score_remove, ClutterScore_val, Int_val, Unit)
ML_2(clutter_score_get_timeline, ClutterScore_val, Int_val, Val_ClutterTimeline)
ML_1(clutter_score_start, ClutterScore_val, Unit)
ML_1(clutter_score_pause, ClutterScore_val, Unit)
ML_1(clutter_score_stop, ClutterScore_val, Unit)
ML_1(clutter_score_rewind, ClutterScore_val, Unit)
ML_1(clutter_score_remove_all, ClutterScore_val, Unit)
ML_1(clutter_score_is_playing, ClutterScore_val, Val_bool)