Commits

Reid van Melle  committed aa6f8b5

More type cleanups for the object hierarchy

  • Participants
  • Parent commits 5bb9664

Comments (0)

Files changed (2)

 - convert to object-oriented interface
 - add phantom types to container actors vs normal actors
 - figure out why my variant hashing is not working as-in GTK
+- add phantom type to stage (container)
+- figure out how to do #define functions properly

File clutter/clutter.ml

 
 external boom : unit -> 'a = "ml_abort"
 
-type actor =     [`actor] Gobject.obj
 type alpha =     [`alpha] Gobject.obj
+type stage =     [`container|`stage|`actor] Gobject.obj
     
 type ellipse =   [`behaviour|`ellipse] Gobject.obj
 type opacity =   [`behaviour|`opacity] Gobject.obj
 type path =      [`behaviour|`path] Gobject.obj
 type scale =     [`behaviour|`scale] Gobject.obj
 	
-type container = [`container] Gobject.obj
 type timeline =  [`timeline] Gobject.obj
 type pixbuf =    GdkPixbuf.pixbuf
 
     
 module Actor = struct
   module E = ClutterEnums
-  external set_position : actor -> int -> int -> unit
+  external set_position : [> `actor] Gobject.obj -> int -> int -> unit
     = "ml_clutter_actor_set_position"
-  external set_rotation : actor -> int -> float -> int ->
+  external set_rotation : [> `actor] Gobject.obj -> int -> float -> int ->
     int -> int -> unit = "ml_clutter_actor_set_rotation_bc"
     "ml_clutter_actor_set_rotation"
-  external show_all : actor -> unit = "ml_clutter_actor_show_all"
-  external get_width : actor -> int = "ml_clutter_actor_get_width"
-  external get_height : actor -> int = "ml_clutter_actor_get_height"    
+  external show_all : [> `actor] Gobject.obj -> unit = "ml_clutter_actor_show_all"
+  external get_width : [> `actor] Gobject.obj -> int = "ml_clutter_actor_get_width"
+  external get_height : [> `actor] Gobject.obj -> int = "ml_clutter_actor_get_height"    
 end;;
 
 module Group = struct
-  external create : unit -> actor = "ml_clutter_group_new"
+  external create : unit -> [> `actor] Gobject.obj = "ml_clutter_group_new"
 end;;
 
 module Alpha = struct
 
 
 module Texture = struct
-  external from_pixbuf : pixbuf -> actor
+  external from_pixbuf : pixbuf -> [> `actor] Gobject.obj
     = "ml_clutter_texture_new_from_pixbuf"    
 end;;
 
   external opacity : alpha -> start:int -> finish:int -> opacity = "ml_clutter_behaviour_opacity_new"
 
   (* general behaviour operations *)
-  external apply : [> `behaviour] Gobject.obj -> actor -> unit = "ml_clutter_behaviour_apply"
+  external apply : [> `behaviour] Gobject.obj -> [> `actor] Gobject.obj -> unit = "ml_clutter_behaviour_apply"
 
   module P = struct
     let opacity_end : ([>`opacity],_) Gobject.property =
 end;;
 
 module Container = struct
-  external add_actor : actor -> actor -> unit
+  external add_actor : [> `container] Gobject.obj -> [> `actor] Gobject.obj -> unit
     = "ml_clutter_container_add_actor"
   let add c actors =
     List.iter (add_actor c) actors
 end;;
 
 module Stage = struct
-  external get_default : unit -> actor = "ml_clutter_stage_get_default"
+  external get_default : unit -> stage = "ml_clutter_stage_get_default"
 end;;