From 0e42ea9159d3e93c1d59552ced2eea1a57f966d7 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Tue, 22 Sep 2015 13:30:57 -0700 Subject: [PATCH] Add garbage collection to native pointer values --- lime/_backend/native/NativeApplication.hx | 10 +- lime/_backend/native/NativeMouse.hx | 2 +- lime/_backend/native/NativeRenderer.hx | 14 +- lime/_backend/native/NativeWindow.hx | 34 +- lime/audio/openal/ALC.hx | 22 +- lime/audio/openal/ALContext.hx | 4 +- lime/audio/openal/ALDevice.hx | 4 +- lime/graphics/cairo/Cairo.hx | 166 ++--- lime/graphics/cairo/CairoFTFontFace.hx | 2 +- lime/graphics/cairo/CairoFontFace.hx | 12 +- lime/graphics/cairo/CairoFontOptions.hx | 6 +- lime/graphics/cairo/CairoImageSurface.hx | 14 +- lime/graphics/cairo/CairoPattern.hx | 30 +- lime/graphics/cairo/CairoSurface.hx | 16 +- lime/text/Font.hx | 30 +- lime/text/TextLayout.hx | 8 +- project/src/ExternalInterface.cpp | 291 +++++---- project/src/audio/openal/OpenALBindings.cpp | 52 +- project/src/graphics/cairo/CairoBindings.cpp | 627 +++++++++++-------- 19 files changed, 756 insertions(+), 588 deletions(-) diff --git a/lime/_backend/native/NativeApplication.hx b/lime/_backend/native/NativeApplication.hx index 8b33302da..4b3b63fc8 100644 --- a/lime/_backend/native/NativeApplication.hx +++ b/lime/_backend/native/NativeApplication.hx @@ -532,11 +532,11 @@ class NativeApplication { #if !macro @:cffi private static function lime_application_create (config:Dynamic):Float; @:cffi private static function lime_application_event_manager_register (callback:Dynamic, eventObject:Dynamic):Void; - @:cffi private static function lime_application_exec (handle:Float):Int; - @:cffi private static function lime_application_init (handle:Float):Void; - @:cffi private static function lime_application_quit (handle:Float):Int; - @:cffi private static function lime_application_set_frame_rate (handle:Float, value:Float):Void; - @:cffi private static function lime_application_update (handle:Float):Bool; + @:cffi private static function lime_application_exec (handle:Dynamic):Int; + @:cffi private static function lime_application_init (handle:Dynamic):Void; + @:cffi private static function lime_application_quit (handle:Dynamic):Int; + @:cffi private static function lime_application_set_frame_rate (handle:Dynamic, value:Float):Void; + @:cffi private static function lime_application_update (handle:Dynamic):Bool; @:cffi private static function lime_gamepad_event_manager_register (callback:Dynamic, eventObject:Dynamic):Void; @:cffi private static function lime_key_event_manager_register (callback:Dynamic, eventObject:Dynamic):Void; @:cffi private static function lime_mouse_event_manager_register (callback:Dynamic, eventObject:Dynamic):Void; diff --git a/lime/_backend/native/NativeMouse.hx b/lime/_backend/native/NativeMouse.hx index a7e102b7e..636e308ce 100644 --- a/lime/_backend/native/NativeMouse.hx +++ b/lime/_backend/native/NativeMouse.hx @@ -148,7 +148,7 @@ class NativeMouse { @:cffi private static function lime_mouse_set_cursor (cursor:Int):Void; @:cffi private static function lime_mouse_set_lock (lock:Bool):Void; @:cffi private static function lime_mouse_show ():Void; - @:cffi private static function lime_mouse_warp (x:Int, y:Int, window:Float):Void; + @:cffi private static function lime_mouse_warp (x:Int, y:Int, window:Dynamic):Void; #end diff --git a/lime/_backend/native/NativeRenderer.hx b/lime/_backend/native/NativeRenderer.hx index acefbe092..5fb465bed 100644 --- a/lime/_backend/native/NativeRenderer.hx +++ b/lime/_backend/native/NativeRenderer.hx @@ -159,13 +159,13 @@ class NativeRenderer { #if !macro - @:cffi private static function lime_renderer_create (window:Float):Float; - @:cffi private static function lime_renderer_flip (handle:Float):Void; - @:cffi private static function lime_renderer_get_context (handle:Float):Float; - @:cffi private static function lime_renderer_get_type (handle:Float):Dynamic; - @:cffi private static function lime_renderer_lock (handle:Float):Dynamic; - @:cffi private static function lime_renderer_make_current (handle:Float):Void; - @:cffi private static function lime_renderer_unlock (handle:Float):Void; + @:cffi private static function lime_renderer_create (window:Dynamic):Dynamic; + @:cffi private static function lime_renderer_flip (handle:Dynamic):Void; + @:cffi private static function lime_renderer_get_context (handle:Dynamic):Float; + @:cffi private static function lime_renderer_get_type (handle:Dynamic):Dynamic; + @:cffi private static function lime_renderer_lock (handle:Dynamic):Dynamic; + @:cffi private static function lime_renderer_make_current (handle:Dynamic):Void; + @:cffi private static function lime_renderer_unlock (handle:Dynamic):Void; #end diff --git a/lime/_backend/native/NativeWindow.hx b/lime/_backend/native/NativeWindow.hx index 7e31d06eb..5f7675a9e 100644 --- a/lime/_backend/native/NativeWindow.hx +++ b/lime/_backend/native/NativeWindow.hx @@ -270,23 +270,23 @@ class NativeWindow { #if !macro - @:cffi private static function lime_window_alert (handle:Float, message:String, title:String):Void; - @:cffi private static function lime_window_close (handle:Float):Void; - @:cffi private static function lime_window_create (application:Float, width:Int, height:Int, flags:Int, title:String):Float; - @:cffi private static function lime_window_focus (handle:Float):Void; - @:cffi private static function lime_window_get_enable_text_events (handle:Float):Bool; - @:cffi private static function lime_window_get_height (handle:Float):Int; - @:cffi private static function lime_window_get_id (handle:Float):Int; - @:cffi private static function lime_window_get_width (handle:Float):Int; - @:cffi private static function lime_window_get_x (handle:Float):Int; - @:cffi private static function lime_window_get_y (handle:Float):Int; - @:cffi private static function lime_window_move (handle:Float, x:Int, y:Int):Void; - @:cffi private static function lime_window_resize (handle:Float, width:Int, height:Int):Void; - @:cffi private static function lime_window_set_enable_text_events (handle:Float, enabled:Bool):Void; - @:cffi private static function lime_window_set_fullscreen (handle:Float, fullscreen:Bool):Bool; - @:cffi private static function lime_window_set_icon (handle:Float, buffer:Dynamic):Void; - @:cffi private static function lime_window_set_minimized (handle:Float, minimized:Bool):Bool; - @:cffi private static function lime_window_set_title (handle:Float, title:String):Dynamic; + @:cffi private static function lime_window_alert (handle:Dynamic, message:String, title:String):Void; + @:cffi private static function lime_window_close (handle:Dynamic):Void; + @:cffi private static function lime_window_create (application:Dynamic, width:Int, height:Int, flags:Int, title:String):Dynamic; + @:cffi private static function lime_window_focus (handle:Dynamic):Void; + @:cffi private static function lime_window_get_enable_text_events (handle:Dynamic):Bool; + @:cffi private static function lime_window_get_height (handle:Dynamic):Int; + @:cffi private static function lime_window_get_id (handle:Dynamic):Int; + @:cffi private static function lime_window_get_width (handle:Dynamic):Int; + @:cffi private static function lime_window_get_x (handle:Dynamic):Int; + @:cffi private static function lime_window_get_y (handle:Dynamic):Int; + @:cffi private static function lime_window_move (handle:Dynamic, x:Int, y:Int):Void; + @:cffi private static function lime_window_resize (handle:Dynamic, width:Int, height:Int):Void; + @:cffi private static function lime_window_set_enable_text_events (handle:Dynamic, enabled:Bool):Void; + @:cffi private static function lime_window_set_fullscreen (handle:Dynamic, fullscreen:Bool):Bool; + @:cffi private static function lime_window_set_icon (handle:Dynamic, buffer:Dynamic):Void; + @:cffi private static function lime_window_set_minimized (handle:Dynamic, minimized:Bool):Bool; + @:cffi private static function lime_window_set_title (handle:Dynamic, title:String):Dynamic; #end diff --git a/lime/audio/openal/ALC.hx b/lime/audio/openal/ALC.hx index ec2f83b56..f65d4a44d 100644 --- a/lime/audio/openal/ALC.hx +++ b/lime/audio/openal/ALC.hx @@ -199,18 +199,18 @@ class ALC { #if ((cpp || neko || nodejs) && lime_openal && !macro) - @:cffi private static function lime_alc_close_device (device:Float):Bool; - @:cffi private static function lime_alc_create_context (device:Float, attrlist:Dynamic):Float; - @:cffi private static function lime_alc_destroy_context (context:Float):Void; - @:cffi private static function lime_alc_get_contexts_device (context:Float):Float; - @:cffi private static function lime_alc_get_current_context ():Float; - @:cffi private static function lime_alc_get_error (device:Float):Int; - @:cffi private static function lime_alc_get_integerv (device:Float, param:Int, size:Int):Dynamic; - @:cffi private static function lime_alc_get_string (device:Float, param:Int):Dynamic; - @:cffi private static function lime_alc_make_context_current (context:Float):Bool; + @:cffi private static function lime_alc_close_device (device:Dynamic):Bool; + @:cffi private static function lime_alc_create_context (device:Dynamic, attrlist:Dynamic):Dynamic; + @:cffi private static function lime_alc_destroy_context (context:Dynamic):Void; + @:cffi private static function lime_alc_get_contexts_device (context:Dynamic):Float; + @:cffi private static function lime_alc_get_current_context ():Dynamic; + @:cffi private static function lime_alc_get_error (device:Dynamic):Int; + @:cffi private static function lime_alc_get_integerv (device:Dynamic, param:Int, size:Int):Dynamic; + @:cffi private static function lime_alc_get_string (device:Dynamic, param:Int):Dynamic; + @:cffi private static function lime_alc_make_context_current (context:Dynamic):Bool; @:cffi private static function lime_alc_open_device (devicename:String):Float; - @:cffi private static function lime_alc_process_context (context:Float):Void; - @:cffi private static function lime_alc_suspend_context (context:Float):Void; + @:cffi private static function lime_alc_process_context (context:Dynamic):Void; + @:cffi private static function lime_alc_suspend_context (context:Dynamic):Void; #end diff --git a/lime/audio/openal/ALContext.hx b/lime/audio/openal/ALContext.hx index aa49f4162..2c227b270 100644 --- a/lime/audio/openal/ALContext.hx +++ b/lime/audio/openal/ALContext.hx @@ -5,10 +5,10 @@ package lime.audio.openal; @:allow(lime.audio.openal.ALC) -abstract ALContext(Null) from Null to Null { +abstract ALContext(Dynamic) { - private function new (handle:Float) { + private function new (handle:Dynamic) { this = handle; diff --git a/lime/audio/openal/ALDevice.hx b/lime/audio/openal/ALDevice.hx index 33001a38e..bb2b26605 100644 --- a/lime/audio/openal/ALDevice.hx +++ b/lime/audio/openal/ALDevice.hx @@ -5,10 +5,10 @@ package lime.audio.openal; @:allow(lime.audio.openal.ALC) -abstract ALDevice(Null) from Null to Null { +abstract ALDevice(Dynamic) { - private function new (handle:Float) { + private function new (handle:Dynamic) { this = handle; diff --git a/lime/graphics/cairo/Cairo.hx b/lime/graphics/cairo/Cairo.hx index c0976cca9..3738e8487 100644 --- a/lime/graphics/cairo/Cairo.hx +++ b/lime/graphics/cairo/Cairo.hx @@ -133,7 +133,7 @@ class Cairo { } - /*@:finalizer*/ public function destroy ():Void { + public function destroy ():Void { #if (lime_cairo && !macro) lime_cairo_destroy (handle); @@ -904,88 +904,88 @@ class Cairo { #if (lime_cairo && !macro) - @:cffi private static function lime_cairo_arc (handle:Float, xc:Float, yc:Float, radius:Float, angle1:Float, angle2:Float):Void; - @:cffi private static function lime_cairo_arc_negative (handle:Float, xc:Float, yc:Float, radius:Float, angle1:Float, angle2:Float):Void; - @:cffi private static function lime_cairo_clip (handle:Float):Void; - @:cffi private static function lime_cairo_clip_preserve (handle:Float):Void; - @:cffi private static function lime_cairo_clip_extents (handle:Float, x1:Float, y1:Float, x2:Float, y2:Float):Void; - @:cffi private static function lime_cairo_close_path (handle:Float):Void; - @:cffi private static function lime_cairo_copy_page (handle:Float):Void; - @:cffi private static function lime_cairo_create (handle:Float):Float; - @:cffi private static function lime_cairo_curve_to (handle:Float, x1:Float, y1:Float, x2:Float, y2:Float, x3:Float, y3:Float):Void; - @:cffi private static function lime_cairo_destroy (handle:Float):Void; - @:cffi private static function lime_cairo_fill (handle:Float):Void; - @:cffi private static function lime_cairo_fill_extents (handle:Float, x1:Float, y1:Float, x2:Float, y2:Float):Void; - @:cffi private static function lime_cairo_fill_preserve (handle:Float):Void; - @:cffi private static function lime_cairo_get_antialias (handle:Float):Int; - @:cffi private static function lime_cairo_get_current_point (handle:Float):Dynamic; - @:cffi private static function lime_cairo_get_dash (handle:Float):Dynamic; - @:cffi private static function lime_cairo_get_dash_count (handle:Float):Int; - @:cffi private static function lime_cairo_get_fill_rule (handle:Float):Int; - @:cffi private static function lime_cairo_get_font_face (handle:Float):Float; - @:cffi private static function lime_cairo_get_font_options (handle:Float):Float; - @:cffi private static function lime_cairo_get_group_target (handle:Float):Float; - @:cffi private static function lime_cairo_get_line_cap (handle:Float):Int; - @:cffi private static function lime_cairo_get_line_join (handle:Float):Int; - @:cffi private static function lime_cairo_get_line_width (handle:Float):Float; - @:cffi private static function lime_cairo_get_matrix (handle:Float):Dynamic; - @:cffi private static function lime_cairo_get_miter_limit (handle:Float):Float; - @:cffi private static function lime_cairo_get_operator (handle:Float):Int; - @:cffi private static function lime_cairo_get_reference_count (handle:Float):Int; - @:cffi private static function lime_cairo_get_source (handle:Float):Float; - @:cffi private static function lime_cairo_get_target (handle:Float):Float; - @:cffi private static function lime_cairo_get_tolerance (handle:Float):Float; - @:cffi private static function lime_cairo_has_current_point (handle:Float):Bool; - @:cffi private static function lime_cairo_identity_matrix (handle:Float):Void; - @:cffi private static function lime_cairo_in_clip (handle:Float, x:Float, y:Float):Bool; - @:cffi private static function lime_cairo_in_fill (handle:Float, x:Float, y:Float):Bool; - @:cffi private static function lime_cairo_in_stroke (handle:Float, x:Float, y:Float):Bool; - @:cffi private static function lime_cairo_line_to (handle:Float, x:Float, y:Float):Void; - @:cffi private static function lime_cairo_mask (handle:Float, pattern:Float):Void; - @:cffi private static function lime_cairo_mask_surface (handle:Float, surface:Float, x:Float, y:Float):Void; - @:cffi private static function lime_cairo_move_to (handle:Float, x:Float, y:Float):Void; - @:cffi private static function lime_cairo_new_path (handle:Float):Void; - @:cffi private static function lime_cairo_paint (handle:Float):Void; - @:cffi private static function lime_cairo_paint_with_alpha (handle:Float, alpha:Float):Void; - @:cffi private static function lime_cairo_pop_group (handle:Float):Float; - @:cffi private static function lime_cairo_pop_group_to_source (handle:Float):Void; - @:cffi private static function lime_cairo_push_group (handle:Float):Void; - @:cffi private static function lime_cairo_push_group_with_content (handle:Float, content:Int):Void; - @:cffi private static function lime_cairo_rectangle (handle:Float, x:Float, y:Float, width:Float, height:Float):Void; - @:cffi private static function lime_cairo_reference (handle:Float):Void; - @:cffi private static function lime_cairo_rel_curve_to (handle:Float, dx1:Float, dy1:Float, dx2:Float, dy2:Float, dx3:Float, dy3:Float):Void; - @:cffi private static function lime_cairo_rel_line_to (handle:Float, dx:Float, dy:Float):Void; - @:cffi private static function lime_cairo_rel_move_to (handle:Float, dx:Float, dy:Float):Void; - @:cffi private static function lime_cairo_reset_clip (handle:Float):Void; - @:cffi private static function lime_cairo_restore (handle:Float):Void; - @:cffi private static function lime_cairo_rotate (handle:Float, amount:Float):Void; - @:cffi private static function lime_cairo_save (handle:Float):Void; - @:cffi private static function lime_cairo_scale (handle:Float, x:Float, y:Float):Void; - @:cffi private static function lime_cairo_set_antialias (handle:Float, cap:Int):Void; - @:cffi private static function lime_cairo_set_dash (handle:Float, dash:Dynamic):Void; - @:cffi private static function lime_cairo_set_fill_rule (handle:Float, cap:Int):Void; - @:cffi private static function lime_cairo_set_font_face (handle:Float, face:Float):Void; - @:cffi private static function lime_cairo_set_font_options (handle:Float, options:Float):Void; - @:cffi private static function lime_cairo_set_font_size (handle:Float, size:Float):Void; - @:cffi private static function lime_cairo_set_line_cap (handle:Float, cap:Int):Void; - @:cffi private static function lime_cairo_set_line_join (handle:Float, join:Int):Void; - @:cffi private static function lime_cairo_set_line_width (handle:Float, width:Float):Void; - @:cffi private static function lime_cairo_set_matrix (handle:Float, matrix:Dynamic):Void; - @:cffi private static function lime_cairo_set_miter_limit (handle:Float, miterLimit:Float):Void; - @:cffi private static function lime_cairo_set_operator (handle:Float, op:Int):Void; - @:cffi private static function lime_cairo_set_source (handle:Float, pattern:Float):Void; - @:cffi private static function lime_cairo_set_source_rgb (handle:Float, r:Float, g:Float, b:Float):Void; - @:cffi private static function lime_cairo_set_source_rgba (handle:Float, r:Float, g:Float, b:Float, a:Float):Void; - @:cffi private static function lime_cairo_set_source_surface (handle:Float, surface:Float, x:Float, y:Float):Void; - @:cffi private static function lime_cairo_set_tolerance (handle:Float, tolerance:Float):Void; - @:cffi private static function lime_cairo_show_page (handle:Float):Void; - @:cffi private static function lime_cairo_show_text (handle:Float, text:String):Void; - @:cffi private static function lime_cairo_status (handle:Float):Int; - @:cffi private static function lime_cairo_stroke (handle:Float):Void; - @:cffi private static function lime_cairo_stroke_extents (handle:Float, x1:Float, y1:Float, x2:Float, y2:Float):Void; - @:cffi private static function lime_cairo_stroke_preserve (handle:Float):Void; - @:cffi private static function lime_cairo_transform (handle:Float, matrix:Dynamic):Void; - @:cffi private static function lime_cairo_translate (handle:Float, x:Float, y:Float):Void; + @:cffi private static function lime_cairo_arc (handle:Dynamic, xc:Float, yc:Float, radius:Float, angle1:Float, angle2:Float):Void; + @:cffi private static function lime_cairo_arc_negative (handle:Dynamic, xc:Float, yc:Float, radius:Float, angle1:Float, angle2:Float):Void; + @:cffi private static function lime_cairo_clip (handle:Dynamic):Void; + @:cffi private static function lime_cairo_clip_preserve (handle:Dynamic):Void; + @:cffi private static function lime_cairo_clip_extents (handle:Dynamic, x1:Float, y1:Float, x2:Float, y2:Float):Void; + @:cffi private static function lime_cairo_close_path (handle:Dynamic):Void; + @:cffi private static function lime_cairo_copy_page (handle:Dynamic):Void; + @:cffi private static function lime_cairo_create (handle:Dynamic):Dynamic; + @:cffi private static function lime_cairo_curve_to (handle:Dynamic, x1:Float, y1:Float, x2:Float, y2:Float, x3:Float, y3:Float):Void; + @:cffi private static function lime_cairo_destroy (handle:Dynamic):Void; + @:cffi private static function lime_cairo_fill (handle:Dynamic):Void; + @:cffi private static function lime_cairo_fill_extents (handle:Dynamic, x1:Float, y1:Float, x2:Float, y2:Float):Void; + @:cffi private static function lime_cairo_fill_preserve (handle:Dynamic):Void; + @:cffi private static function lime_cairo_get_antialias (handle:Dynamic):Int; + @:cffi private static function lime_cairo_get_current_point (handle:Dynamic):Dynamic; + @:cffi private static function lime_cairo_get_dash (handle:Dynamic):Dynamic; + @:cffi private static function lime_cairo_get_dash_count (handle:Dynamic):Int; + @:cffi private static function lime_cairo_get_fill_rule (handle:Dynamic):Int; + @:cffi private static function lime_cairo_get_font_face (handle:Dynamic):Dynamic; + @:cffi private static function lime_cairo_get_font_options (handle:Dynamic):Dynamic; + @:cffi private static function lime_cairo_get_group_target (handle:Dynamic):Dynamic; + @:cffi private static function lime_cairo_get_line_cap (handle:Dynamic):Int; + @:cffi private static function lime_cairo_get_line_join (handle:Dynamic):Int; + @:cffi private static function lime_cairo_get_line_width (handle:Dynamic):Float; + @:cffi private static function lime_cairo_get_matrix (handle:Dynamic):Dynamic; + @:cffi private static function lime_cairo_get_miter_limit (handle:Dynamic):Float; + @:cffi private static function lime_cairo_get_operator (handle:Dynamic):Int; + @:cffi private static function lime_cairo_get_reference_count (handle:Dynamic):Int; + @:cffi private static function lime_cairo_get_source (handle:Dynamic):Dynamic; + @:cffi private static function lime_cairo_get_target (handle:Dynamic):Dynamic; + @:cffi private static function lime_cairo_get_tolerance (handle:Dynamic):Float; + @:cffi private static function lime_cairo_has_current_point (handle:Dynamic):Bool; + @:cffi private static function lime_cairo_identity_matrix (handle:Dynamic):Void; + @:cffi private static function lime_cairo_in_clip (handle:Dynamic, x:Float, y:Float):Bool; + @:cffi private static function lime_cairo_in_fill (handle:Dynamic, x:Float, y:Float):Bool; + @:cffi private static function lime_cairo_in_stroke (handle:Dynamic, x:Float, y:Float):Bool; + @:cffi private static function lime_cairo_line_to (handle:Dynamic, x:Float, y:Float):Void; + @:cffi private static function lime_cairo_mask (handle:Dynamic, pattern:Dynamic):Void; + @:cffi private static function lime_cairo_mask_surface (handle:Dynamic, surface:Dynamic, x:Float, y:Float):Void; + @:cffi private static function lime_cairo_move_to (handle:Dynamic, x:Float, y:Float):Void; + @:cffi private static function lime_cairo_new_path (handle:Dynamic):Void; + @:cffi private static function lime_cairo_paint (handle:Dynamic):Void; + @:cffi private static function lime_cairo_paint_with_alpha (handle:Dynamic, alpha:Float):Void; + @:cffi private static function lime_cairo_pop_group (handle:Dynamic):Dynamic; + @:cffi private static function lime_cairo_pop_group_to_source (handle:Dynamic):Void; + @:cffi private static function lime_cairo_push_group (handle:Dynamic):Void; + @:cffi private static function lime_cairo_push_group_with_content (handle:Dynamic, content:Int):Void; + @:cffi private static function lime_cairo_rectangle (handle:Dynamic, x:Float, y:Float, width:Float, height:Float):Void; + @:cffi private static function lime_cairo_reference (handle:Dynamic):Void; + @:cffi private static function lime_cairo_rel_curve_to (handle:Dynamic, dx1:Float, dy1:Float, dx2:Float, dy2:Float, dx3:Float, dy3:Float):Void; + @:cffi private static function lime_cairo_rel_line_to (handle:Dynamic, dx:Float, dy:Float):Void; + @:cffi private static function lime_cairo_rel_move_to (handle:Dynamic, dx:Float, dy:Float):Void; + @:cffi private static function lime_cairo_reset_clip (handle:Dynamic):Void; + @:cffi private static function lime_cairo_restore (handle:Dynamic):Void; + @:cffi private static function lime_cairo_rotate (handle:Dynamic, amount:Float):Void; + @:cffi private static function lime_cairo_save (handle:Dynamic):Void; + @:cffi private static function lime_cairo_scale (handle:Dynamic, x:Float, y:Float):Void; + @:cffi private static function lime_cairo_set_antialias (handle:Dynamic, cap:Int):Void; + @:cffi private static function lime_cairo_set_dash (handle:Dynamic, dash:Dynamic):Void; + @:cffi private static function lime_cairo_set_fill_rule (handle:Dynamic, cap:Int):Void; + @:cffi private static function lime_cairo_set_font_face (handle:Dynamic, face:Dynamic):Void; + @:cffi private static function lime_cairo_set_font_options (handle:Dynamic, options:Dynamic):Void; + @:cffi private static function lime_cairo_set_font_size (handle:Dynamic, size:Float):Void; + @:cffi private static function lime_cairo_set_line_cap (handle:Dynamic, cap:Int):Void; + @:cffi private static function lime_cairo_set_line_join (handle:Dynamic, join:Int):Void; + @:cffi private static function lime_cairo_set_line_width (handle:Dynamic, width:Float):Void; + @:cffi private static function lime_cairo_set_matrix (handle:Dynamic, matrix:Dynamic):Void; + @:cffi private static function lime_cairo_set_miter_limit (handle:Dynamic, miterLimit:Float):Void; + @:cffi private static function lime_cairo_set_operator (handle:Dynamic, op:Int):Void; + @:cffi private static function lime_cairo_set_source (handle:Dynamic, pattern:Dynamic):Void; + @:cffi private static function lime_cairo_set_source_rgb (handle:Dynamic, r:Float, g:Float, b:Float):Void; + @:cffi private static function lime_cairo_set_source_rgba (handle:Dynamic, r:Float, g:Float, b:Float, a:Float):Void; + @:cffi private static function lime_cairo_set_source_surface (handle:Dynamic, surface:Dynamic, x:Float, y:Float):Void; + @:cffi private static function lime_cairo_set_tolerance (handle:Dynamic, tolerance:Float):Void; + @:cffi private static function lime_cairo_show_page (handle:Dynamic):Void; + @:cffi private static function lime_cairo_show_text (handle:Dynamic, text:String):Void; + @:cffi private static function lime_cairo_status (handle:Dynamic):Int; + @:cffi private static function lime_cairo_stroke (handle:Dynamic):Void; + @:cffi private static function lime_cairo_stroke_extents (handle:Dynamic, x1:Float, y1:Float, x2:Float, y2:Float):Void; + @:cffi private static function lime_cairo_stroke_preserve (handle:Dynamic):Void; + @:cffi private static function lime_cairo_transform (handle:Dynamic, matrix:Dynamic):Void; + @:cffi private static function lime_cairo_translate (handle:Dynamic, x:Float, y:Float):Void; @:cffi private static function lime_cairo_version ():Int; @:cffi private static function lime_cairo_version_string ():String; #end diff --git a/lime/graphics/cairo/CairoFTFontFace.hx b/lime/graphics/cairo/CairoFTFontFace.hx index 5a03b0f80..8d6eadc05 100644 --- a/lime/graphics/cairo/CairoFTFontFace.hx +++ b/lime/graphics/cairo/CairoFTFontFace.hx @@ -40,7 +40,7 @@ abstract CairoFTFontFace(CairoFontFace) from CairoFontFace to CairoFontFace { #if ((cpp || neko || nodejs) && !macro) - @:cffi private static function lime_cairo_ft_font_face_create (face:Float, flags:Int):Float; + @:cffi private static function lime_cairo_ft_font_face_create (face:Dynamic, flags:Int):Dynamic; #end diff --git a/lime/graphics/cairo/CairoFontFace.hx b/lime/graphics/cairo/CairoFontFace.hx index fb9229c30..cedff3e3c 100644 --- a/lime/graphics/cairo/CairoFontFace.hx +++ b/lime/graphics/cairo/CairoFontFace.hx @@ -6,7 +6,7 @@ package lime.graphics.cairo; #end -abstract CairoFontFace(Dynamic) from Float to Float { +abstract CairoFontFace(Dynamic) { public var referenceCount (get, never):Int; @@ -14,7 +14,7 @@ abstract CairoFontFace(Dynamic) from Float to Float { private function new () { - this = cast 0; + this = null; } @@ -76,10 +76,10 @@ abstract CairoFontFace(Dynamic) from Float to Float { #if ((cpp || neko || nodejs) && !macro) - @:cffi private static function lime_cairo_font_face_destroy (handle:Float):Void; - @:cffi private static function lime_cairo_font_face_get_reference_count (handle:Float):Int; - @:cffi private static function lime_cairo_font_face_reference (handle:Float):Void; - @:cffi private static function lime_cairo_font_face_status (handle:Float):Int; + @:cffi private static function lime_cairo_font_face_destroy (handle:Dynamic):Void; + @:cffi private static function lime_cairo_font_face_get_reference_count (handle:Dynamic):Int; + @:cffi private static function lime_cairo_font_face_reference (handle:Dynamic):Void; + @:cffi private static function lime_cairo_font_face_status (handle:Dynamic):Int; #end diff --git a/lime/graphics/cairo/CairoFontOptions.hx b/lime/graphics/cairo/CairoFontOptions.hx index 66a70df08..7772e2708 100644 --- a/lime/graphics/cairo/CairoFontOptions.hx +++ b/lime/graphics/cairo/CairoFontOptions.hx @@ -8,7 +8,7 @@ import lime.text.Font; #end -abstract CairoFontOptions(Dynamic) from Float to Float { +abstract CairoFontOptions(Dynamic) { public var antialias (get, set):CairoAntialias; @@ -22,7 +22,7 @@ abstract CairoFontOptions(Dynamic) from Float to Float { #if (lime_cairo && !macro) this = lime_cairo_font_options_create (); #else - this = cast 0; + this = null; #end } @@ -141,7 +141,7 @@ abstract CairoFontOptions(Dynamic) from Float to Float { #if ((cpp || neko || nodejs) && !macro) - @:cffi private static function lime_cairo_font_options_create ():Float; + @:cffi private static function lime_cairo_font_options_create ():Dynamic; @:cffi private static function lime_cairo_font_options_destroy (handle:Float):Void; @:cffi private static function lime_cairo_font_options_get_antialias (handle:Float):Int; @:cffi private static function lime_cairo_font_options_get_hint_metrics (handle:Float):Int; diff --git a/lime/graphics/cairo/CairoImageSurface.hx b/lime/graphics/cairo/CairoImageSurface.hx index c6bbbe452..d9fe39a79 100644 --- a/lime/graphics/cairo/CairoImageSurface.hx +++ b/lime/graphics/cairo/CairoImageSurface.hx @@ -120,13 +120,13 @@ package lime.graphics.cairo; #if (lime_cairo && !macro) @:cffi private static function lime_bytes_get_data_pointer (handle:Dynamic):Float; - @:cffi private static function lime_cairo_image_surface_create (format:Int, width:Int, height:Int):Float; - @:cffi private static function lime_cairo_image_surface_create_for_data (data:Float, format:Int, width:Int, height:Int, stride:Int):Float; - @:cffi private static function lime_cairo_image_surface_get_data (handle:Float):Float; - @:cffi private static function lime_cairo_image_surface_get_format (handle:Float):Int; - @:cffi private static function lime_cairo_image_surface_get_height (handle:Float):Int; - @:cffi private static function lime_cairo_image_surface_get_stride (handle:Float):Int; - @:cffi private static function lime_cairo_image_surface_get_width (handle:Float):Int; + @:cffi private static function lime_cairo_image_surface_create (format:Int, width:Int, height:Int):Dynamic; + @:cffi private static function lime_cairo_image_surface_create_for_data (data:Float, format:Int, width:Int, height:Int, stride:Int):Dynamic; + @:cffi private static function lime_cairo_image_surface_get_data (handle:Dynamic):Float; + @:cffi private static function lime_cairo_image_surface_get_format (handle:Dynamic):Int; + @:cffi private static function lime_cairo_image_surface_get_height (handle:Dynamic):Int; + @:cffi private static function lime_cairo_image_surface_get_stride (handle:Dynamic):Int; + @:cffi private static function lime_cairo_image_surface_get_width (handle:Dynamic):Int; #end diff --git a/lime/graphics/cairo/CairoPattern.hx b/lime/graphics/cairo/CairoPattern.hx index 8b7a44105..3a23c3646 100644 --- a/lime/graphics/cairo/CairoPattern.hx +++ b/lime/graphics/cairo/CairoPattern.hx @@ -8,7 +8,7 @@ import lime.math.Matrix3; #end -abstract CairoPattern(Dynamic) from Float to Float { +abstract CairoPattern(Dynamic) { public var colorStopCount (get, never):Int; @@ -199,21 +199,21 @@ abstract CairoPattern(Dynamic) from Float to Float { #if (lime_cairo && !macro) - @:cffi private static function lime_cairo_pattern_add_color_stop_rgb (handle:Float, offset:Float, red:Float, green:Float, blue:Float):Void; - @:cffi private static function lime_cairo_pattern_add_color_stop_rgba (handle:Float, offset:Float, red:Float, green:Float, blue:Float, alpha:Float):Void; - @:cffi private static function lime_cairo_pattern_create_for_surface (surface:Float):Float; - @:cffi private static function lime_cairo_pattern_create_linear (x0:Float, y0:Float, x1:Float, y1:Float):Float; - @:cffi private static function lime_cairo_pattern_create_radial (cx0:Float, cy0:Float, radius0:Float, cx1:Float, cy1:Float, radius1:Float):Float; - @:cffi private static function lime_cairo_pattern_create_rgb (r:Float, g:Float, b:Float):Float; - @:cffi private static function lime_cairo_pattern_create_rgba (r:Float, g:Float, b:Float, a:Float):Float; - @:cffi private static function lime_cairo_pattern_destroy (handle:Float):Void; + @:cffi private static function lime_cairo_pattern_add_color_stop_rgb (handle:Dynamic, offset:Float, red:Float, green:Float, blue:Float):Void; + @:cffi private static function lime_cairo_pattern_add_color_stop_rgba (handle:Dynamic, offset:Float, red:Float, green:Float, blue:Float, alpha:Float):Void; + @:cffi private static function lime_cairo_pattern_create_for_surface (surface:Dynamic):Dynamic; + @:cffi private static function lime_cairo_pattern_create_linear (x0:Float, y0:Float, x1:Float, y1:Float):Dynamic; + @:cffi private static function lime_cairo_pattern_create_radial (cx0:Float, cy0:Float, radius0:Float, cx1:Float, cy1:Float, radius1:Float):Dynamic; + @:cffi private static function lime_cairo_pattern_create_rgb (r:Float, g:Float, b:Float):Dynamic; + @:cffi private static function lime_cairo_pattern_create_rgba (r:Float, g:Float, b:Float, a:Float):Dynamic; + @:cffi private static function lime_cairo_pattern_destroy (handle:Dynamic):Void; @:cffi private static function lime_cairo_pattern_get_color_stop_count (handle:Float):Int; - @:cffi private static function lime_cairo_pattern_get_extend (handle:Float):Int; - @:cffi private static function lime_cairo_pattern_get_filter (handle:Float):Int; - @:cffi private static function lime_cairo_pattern_get_matrix (handle:Float):Dynamic; - @:cffi private static function lime_cairo_pattern_set_extend (handle:Float, extend:Int):Void; - @:cffi private static function lime_cairo_pattern_set_filter (handle:Float, filter:Int):Void; - @:cffi private static function lime_cairo_pattern_set_matrix (handle:Float, matrix:Dynamic):Void; + @:cffi private static function lime_cairo_pattern_get_extend (handle:Dynamic):Int; + @:cffi private static function lime_cairo_pattern_get_filter (handle:Dynamic):Int; + @:cffi private static function lime_cairo_pattern_get_matrix (handle:Dynamic):Dynamic; + @:cffi private static function lime_cairo_pattern_set_extend (handle:Dynamic, extend:Int):Void; + @:cffi private static function lime_cairo_pattern_set_filter (handle:Dynamic, filter:Int):Void; + @:cffi private static function lime_cairo_pattern_set_matrix (handle:Dynamic, matrix:Dynamic):Void; #end diff --git a/lime/graphics/cairo/CairoSurface.hx b/lime/graphics/cairo/CairoSurface.hx index d01393730..28fdf6e92 100644 --- a/lime/graphics/cairo/CairoSurface.hx +++ b/lime/graphics/cairo/CairoSurface.hx @@ -6,7 +6,7 @@ package lime.graphics.cairo; #end -abstract CairoSurface(Dynamic) from Float to Float { +abstract CairoSurface(Dynamic) { public function destroy ():Void { @@ -27,6 +27,15 @@ abstract CairoSurface(Dynamic) from Float to Float { } + public function reference ():Void { + + #if (lime_cairo && !macro) + lime_cairo_surface_reference (this); + #end + + } + + // Native Methods @@ -35,8 +44,9 @@ abstract CairoSurface(Dynamic) from Float to Float { #if (lime_cairo && !macro) - @:cffi private static function lime_cairo_surface_destroy (surface:Float):Void; - @:cffi private static function lime_cairo_surface_flush (surface:Float):Void; + @:cffi private static function lime_cairo_surface_destroy (surface:Dynamic):Void; + @:cffi private static function lime_cairo_surface_flush (surface:Dynamic):Void; + @:cffi private static function lime_cairo_surface_reference (surface:Dynamic):Void; #end diff --git a/lime/text/Font.hx b/lime/text/Font.hx index 4a25a8e32..4d4e50627 100644 --- a/lime/text/Font.hx +++ b/lime/text/Font.hx @@ -490,22 +490,22 @@ class Font { #if ((cpp || neko || nodejs) && !macro) - @:cffi private static function lime_font_get_ascender (handle:Float):Int; - @:cffi private static function lime_font_get_descender (handle:Float):Int; - @:cffi private static function lime_font_get_family_name (handle:Float):Dynamic; - @:cffi private static function lime_font_get_glyph_index (handle:Float, character:String):Int; - @:cffi private static function lime_font_get_glyph_indices (handle:Float, characters:String):Dynamic; - @:cffi private static function lime_font_get_glyph_metrics (handle:Float, index:Int):Dynamic; - @:cffi private static function lime_font_get_height (handle:Float):Int; - @:cffi private static function lime_font_get_num_glyphs (handle:Float):Int; - @:cffi private static function lime_font_get_underline_position (handle:Float):Int; - @:cffi private static function lime_font_get_underline_thickness (handle:Float):Int; - @:cffi private static function lime_font_get_units_per_em (handle:Float):Int; + @:cffi private static function lime_font_get_ascender (handle:Dynamic):Int; + @:cffi private static function lime_font_get_descender (handle:Dynamic):Int; + @:cffi private static function lime_font_get_family_name (handle:Dynamic):Dynamic; + @:cffi private static function lime_font_get_glyph_index (handle:Dynamic, character:String):Int; + @:cffi private static function lime_font_get_glyph_indices (handle:Dynamic, characters:String):Dynamic; + @:cffi private static function lime_font_get_glyph_metrics (handle:Dynamic, index:Int):Dynamic; + @:cffi private static function lime_font_get_height (handle:Dynamic):Int; + @:cffi private static function lime_font_get_num_glyphs (handle:Dynamic):Int; + @:cffi private static function lime_font_get_underline_position (handle:Dynamic):Int; + @:cffi private static function lime_font_get_underline_thickness (handle:Dynamic):Int; + @:cffi private static function lime_font_get_units_per_em (handle:Dynamic):Int; @:cffi private static function lime_font_load (data:Dynamic):Dynamic; - @:cffi private static function lime_font_outline_decompose (handle:Float, size:Int):Dynamic; - @:cffi private static function lime_font_render_glyph (handle:Float, index:Int, data:Dynamic):Bool; - @:cffi private static function lime_font_render_glyphs (handle:Float, indices:Dynamic, data:Dynamic):Bool; - @:cffi private static function lime_font_set_size (handle:Float, size:Int):Void; + @:cffi private static function lime_font_outline_decompose (handle:Dynamic, size:Int):Dynamic; + @:cffi private static function lime_font_render_glyph (handle:Dynamic, index:Int, data:Dynamic):Bool; + @:cffi private static function lime_font_render_glyphs (handle:Dynamic, indices:Dynamic, data:Dynamic):Bool; + @:cffi private static function lime_font_set_size (handle:Dynamic, size:Int):Void; #end diff --git a/lime/text/TextLayout.hx b/lime/text/TextLayout.hx index 09699c478..853746be1 100644 --- a/lime/text/TextLayout.hx +++ b/lime/text/TextLayout.hx @@ -245,10 +245,10 @@ class TextLayout { #if ((cpp || neko || nodejs) && !macro) @:cffi private static function lime_text_layout_create (direction:Int, script:String, language:String):Dynamic; - @:cffi private static function lime_text_layout_position (textHandle:Float, fontHandle:Float, size:Int, textString:String, data:Dynamic):Dynamic; - @:cffi private static function lime_text_layout_set_direction (textHandle:Float, direction:Int):Void; - @:cffi private static function lime_text_layout_set_language (textHandle:Float, language:String):Void; - @:cffi private static function lime_text_layout_set_script (textHandle:Float, script:String):Void; + @:cffi private static function lime_text_layout_position (textHandle:Dynamic, fontHandle:Dynamic, size:Int, textString:String, data:Dynamic):Dynamic; + @:cffi private static function lime_text_layout_set_direction (textHandle:Dynamic, direction:Int):Void; + @:cffi private static function lime_text_layout_set_language (textHandle:Dynamic, language:String):Void; + @:cffi private static function lime_text_layout_set_script (textHandle:Dynamic, script:String):Void; #end diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index b934dbd84..d36de5f37 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -46,11 +46,57 @@ DEFINE_KIND (k_finalizer); namespace lime { - double lime_application_create (value callback) { + void gc_application (value handle) { - Application* app = CreateApplication (); + Application* application = (Application*)val_data (handle); + delete application; + + } + + + void gc_font (value handle) { + + #ifdef LIME_FREETYPE + Font *font = (Font*)val_data (handle); + delete font; + #endif + + } + + + void gc_renderer (value handle) { + + Renderer* renderer = (Renderer*)val_data (handle); + delete renderer; + + } + + + void gc_text_layout (value handle) { + + #ifdef LIME_HARFBUZZ + TextLayout *text = (TextLayout*)val_data (handle); + delete text; + #endif + + } + + + void gc_window (value handle) { + + Window* window = (Window*)val_data (handle); + delete window; + + } + + + value lime_application_create (value callback) { + + Application* application = CreateApplication (); Application::callback = new AutoGCRoot (callback); - return (intptr_t)app; + value handle = cffi::alloc_pointer (application); + val_gc (handle, gc_application); + return handle; } @@ -63,41 +109,41 @@ namespace lime { } - int lime_application_exec (double application) { + int lime_application_exec (value application) { - Application* app = (Application*)(intptr_t)application; + Application* app = (Application*)val_data (application); return app->Exec (); } - void lime_application_init (double application) { + void lime_application_init (value application) { - Application* app = (Application*)(intptr_t)application; + Application* app = (Application*)val_data (application); app->Init (); } - int lime_application_quit (double application) { + int lime_application_quit (value application) { - Application* app = (Application*)(intptr_t)application; + Application* app = (Application*)val_data (application); return app->Quit (); } - void lime_application_set_frame_rate (double application, double frameRate) { + void lime_application_set_frame_rate (value application, double frameRate) { - Application* app = (Application*)(intptr_t)application; + Application* app = (Application*)val_data (application); app->SetFrameRate (frameRate); } - bool lime_application_update (double application) { + bool lime_application_update (value application) { - Application* app = (Application*)(intptr_t)application; + Application* app = (Application*)val_data (application); return app->Update (); } @@ -254,20 +300,10 @@ namespace lime { } - void lime_font_destroy (value handle) { + int lime_font_get_ascender (value fontHandle) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)val_float (handle); - delete font; - #endif - - } - - - int lime_font_get_ascender (double fontHandle) { - - #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); return font->GetAscender (); #else return 0; @@ -276,10 +312,10 @@ namespace lime { } - int lime_font_get_descender (double fontHandle) { + int lime_font_get_descender (value fontHandle) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); return font->GetDescender (); #else return 0; @@ -288,10 +324,10 @@ namespace lime { } - value lime_font_get_family_name (double fontHandle) { + value lime_font_get_family_name (value fontHandle) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); wchar_t *name = font->GetFamilyName (); value result = alloc_wstring (name); delete name; @@ -303,10 +339,10 @@ namespace lime { } - int lime_font_get_glyph_index (double fontHandle, HxString character) { + int lime_font_get_glyph_index (value fontHandle, HxString character) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); return font->GetGlyphIndex ((char*)character.__s); #else return -1; @@ -315,10 +351,10 @@ namespace lime { } - value lime_font_get_glyph_indices (double fontHandle, HxString characters) { + value lime_font_get_glyph_indices (value fontHandle, HxString characters) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); return font->GetGlyphIndices ((char*)characters.__s); #else return alloc_null (); @@ -327,10 +363,10 @@ namespace lime { } - value lime_font_get_glyph_metrics (double fontHandle, int index) { + value lime_font_get_glyph_metrics (value fontHandle, int index) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); return font->GetGlyphMetrics (index); #else return alloc_null (); @@ -339,10 +375,10 @@ namespace lime { } - int lime_font_get_height (double fontHandle) { + int lime_font_get_height (value fontHandle) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); return font->GetHeight (); #else return 0; @@ -351,10 +387,10 @@ namespace lime { } - int lime_font_get_num_glyphs (double fontHandle) { + int lime_font_get_num_glyphs (value fontHandle) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); return font->GetNumGlyphs (); #else return alloc_null (); @@ -363,10 +399,10 @@ namespace lime { } - int lime_font_get_underline_position (double fontHandle) { + int lime_font_get_underline_position (value fontHandle) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); return font->GetUnderlinePosition (); #else return 0; @@ -375,10 +411,10 @@ namespace lime { } - int lime_font_get_underline_thickness (double fontHandle) { + int lime_font_get_underline_thickness (value fontHandle) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); return font->GetUnderlineThickness (); #else return 0; @@ -387,10 +423,10 @@ namespace lime { } - int lime_font_get_units_per_em (double fontHandle) { + int lime_font_get_units_per_em (value fontHandle) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); return font->GetUnitsPerEM (); #else return 0; @@ -421,9 +457,9 @@ namespace lime { if (font->face) { - value v = alloc_float ((intptr_t)font); - val_gc (v, lime_font_destroy); - return v; + value handle = cffi::alloc_pointer (font); + val_gc (handle, gc_font); + return handle; } else { @@ -439,10 +475,10 @@ namespace lime { } - value lime_font_outline_decompose (double fontHandle, int size) { + value lime_font_outline_decompose (value fontHandle, int size) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); return font->Decompose (size); #else return alloc_null (); @@ -451,10 +487,10 @@ namespace lime { } - bool lime_font_render_glyph (double fontHandle, int index, value data) { + bool lime_font_render_glyph (value fontHandle, int index, value data) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); Bytes bytes = Bytes (data); return font->RenderGlyph (index, &bytes); #else @@ -464,10 +500,10 @@ namespace lime { } - bool lime_font_render_glyphs (double fontHandle, value indices, value data) { + bool lime_font_render_glyphs (value fontHandle, value indices, value data) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); Bytes bytes = Bytes (data); return font->RenderGlyphs (indices, &bytes); #else @@ -477,10 +513,10 @@ namespace lime { } - void lime_font_set_size (double fontHandle, int fontSize) { + void lime_font_set_size (value fontHandle, int fontSize) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)fontHandle; + Font *font = (Font*)val_data (fontHandle); font->SetSize (fontSize); #endif @@ -857,13 +893,13 @@ namespace lime { } - void lime_mouse_warp (int x, int y, double window) { + void lime_mouse_warp (int x, int y, value window) { Window* windowRef = 0; if (window) { - windowRef = (Window*)(intptr_t)window; + windowRef = (Window*)val_data (window); } @@ -927,55 +963,57 @@ namespace lime { } - double lime_renderer_create (double window) { + value lime_renderer_create (value window) { - Renderer* renderer = CreateRenderer ((Window*)(intptr_t)window); - return (intptr_t)renderer; + Renderer* renderer = CreateRenderer ((Window*)val_data (window)); + value handle = cffi::alloc_pointer (renderer); + val_gc (handle, gc_renderer); + return handle; } - void lime_renderer_flip (double renderer) { + void lime_renderer_flip (value renderer) { - ((Renderer*)(intptr_t)renderer)->Flip (); + ((Renderer*)val_data (renderer))->Flip (); } - double lime_renderer_get_context (double renderer) { + double lime_renderer_get_context (value renderer) { - Renderer* targetRenderer = (Renderer*)(intptr_t)renderer; + Renderer* targetRenderer = (Renderer*)val_data (renderer); return (intptr_t)targetRenderer->GetContext (); } - value lime_renderer_get_type (double renderer) { + value lime_renderer_get_type (value renderer) { - Renderer* targetRenderer = (Renderer*)(intptr_t)renderer; + Renderer* targetRenderer = (Renderer*)val_data (renderer); const char* type = targetRenderer->Type (); return type ? alloc_string (type) : alloc_null (); } - value lime_renderer_lock (double renderer) { + value lime_renderer_lock (value renderer) { - return ((Renderer*)(intptr_t)renderer)->Lock (); + return ((Renderer*)val_data (renderer))->Lock (); } - void lime_renderer_make_current (double renderer) { + void lime_renderer_make_current (value renderer) { - ((Renderer*)(intptr_t)renderer)->MakeCurrent (); + ((Renderer*)val_data (renderer))->MakeCurrent (); } - void lime_renderer_unlock (double renderer) { + void lime_renderer_unlock (value renderer) { - ((Renderer*)(intptr_t)renderer)->Unlock (); + ((Renderer*)val_data (renderer))->Unlock (); } @@ -1025,25 +1063,14 @@ namespace lime { } - void lime_text_layout_destroy (value textHandle) { - - #ifdef LIME_HARFBUZZ - TextLayout *text = (TextLayout*)(intptr_t)val_float (textHandle); - delete text; - text = 0; - #endif - - } - - value lime_text_layout_create (int direction, HxString script, HxString language) { #if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ) TextLayout *text = new TextLayout (direction, script.__s, language.__s); - value v = alloc_float ((intptr_t)text); - val_gc (v, lime_text_layout_destroy); - return v; + value handle = cffi::alloc_pointer (text); + val_gc (handle, gc_text_layout); + return handle; #else @@ -1054,12 +1081,12 @@ namespace lime { } - value lime_text_layout_position (double textHandle, double fontHandle, int size, HxString textString, value data) { + value lime_text_layout_position (value textHandle, value fontHandle, int size, HxString textString, value data) { #if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ) - TextLayout *text = (TextLayout*)(intptr_t)textHandle; - Font *font = (Font*)(intptr_t)fontHandle; + TextLayout *text = (TextLayout*)val_data (textHandle); + Font *font = (Font*)val_data (fontHandle); Bytes bytes = Bytes (data); text->Position (font, size, textString.__s, &bytes); return bytes.Value (); @@ -1071,30 +1098,30 @@ namespace lime { } - void lime_text_layout_set_direction (double textHandle, int direction) { + void lime_text_layout_set_direction (value textHandle, int direction) { #if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ) - TextLayout *text = (TextLayout*)(intptr_t)textHandle; + TextLayout *text = (TextLayout*)val_data (textHandle); text->SetDirection (direction); #endif } - void lime_text_layout_set_language (double textHandle, HxString language) { + void lime_text_layout_set_language (value textHandle, HxString language) { #if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ) - TextLayout *text = (TextLayout*)(intptr_t)textHandle; + TextLayout *text = (TextLayout*)val_data (textHandle); text->SetLanguage (language.__s); #endif } - void lime_text_layout_set_script (double textHandle, HxString script) { + void lime_text_layout_set_script (value textHandle, HxString script) { #if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ) - TextLayout *text = (TextLayout*)(intptr_t)textHandle; + TextLayout *text = (TextLayout*)val_data (textHandle); text->SetScript (script.__s); #endif @@ -1109,26 +1136,28 @@ namespace lime { } - void lime_window_alert (double window, HxString message, HxString title) { + void lime_window_alert (value window, HxString message, HxString title) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); targetWindow->Alert (message.__s, title.__s); } - void lime_window_close (double window) { + void lime_window_close (value window) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); targetWindow->Close (); } - double lime_window_create (double application, int width, int height, int flags, HxString title) { + value lime_window_create (value application, int width, int height, int flags, HxString title) { - Window* window = CreateWindow ((Application*)(intptr_t)application, width, height, flags, title.__s); - return (intptr_t)window; + Window* window = CreateWindow ((Application*)val_data (application), width, height, flags, title.__s); + value handle = cffi::alloc_pointer (window); + val_gc (handle, gc_window); + return handle; } @@ -1141,114 +1170,114 @@ namespace lime { } - void lime_window_focus (double window) { + void lime_window_focus (value window) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); targetWindow->Focus (); } - bool lime_window_get_enable_text_events (double window) { + bool lime_window_get_enable_text_events (value window) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); return targetWindow->GetEnableTextEvents (); } - int lime_window_get_height (double window) { + int lime_window_get_height (value window) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); return targetWindow->GetHeight (); } - int32_t lime_window_get_id (double window) { + int32_t lime_window_get_id (value window) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); return (int32_t)targetWindow->GetID (); } - int lime_window_get_width (double window) { + int lime_window_get_width (value window) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); return targetWindow->GetWidth (); } - int lime_window_get_x (double window) { + int lime_window_get_x (value window) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); return targetWindow->GetX (); } - int lime_window_get_y (double window) { + int lime_window_get_y (value window) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); return targetWindow->GetY (); } - void lime_window_move (double window, int x, int y) { + void lime_window_move (value window, int x, int y) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); targetWindow->Move (x, y); } - void lime_window_resize (double window, int width, int height) { + void lime_window_resize (value window, int width, int height) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); targetWindow->Resize (width, height); } - void lime_window_set_enable_text_events (double window, bool enabled) { + void lime_window_set_enable_text_events (value window, bool enabled) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); targetWindow->SetEnableTextEvents (enabled); } - bool lime_window_set_fullscreen (double window, bool fullscreen) { + bool lime_window_set_fullscreen (value window, bool fullscreen) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); return targetWindow->SetFullscreen (fullscreen); } - void lime_window_set_icon (double window, value buffer) { + void lime_window_set_icon (value window, value buffer) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); ImageBuffer imageBuffer = ImageBuffer (buffer); targetWindow->SetIcon (&imageBuffer); } - bool lime_window_set_minimized (double window, bool fullscreen) { + bool lime_window_set_minimized (value window, bool fullscreen) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); return targetWindow->SetMinimized (fullscreen); } - value lime_window_set_title (double window, HxString title) { + value lime_window_set_title (value window, HxString title) { - Window* targetWindow = (Window*)(intptr_t)window; + Window* targetWindow = (Window*)val_data (window); const char* result = targetWindow->SetTitle (title.__s); return result ? alloc_string (result) : alloc_null (); diff --git a/project/src/audio/openal/OpenALBindings.cpp b/project/src/audio/openal/OpenALBindings.cpp index f59419cde..c7cf5a0e0 100644 --- a/project/src/audio/openal/OpenALBindings.cpp +++ b/project/src/audio/openal/OpenALBindings.cpp @@ -876,62 +876,62 @@ namespace lime { } - bool lime_alc_close_device (double device) { + bool lime_alc_close_device (value device) { - ALCdevice* alcDevice = (ALCdevice*)(intptr_t)device; + ALCdevice* alcDevice = (ALCdevice*)val_data (device); return alcCloseDevice (alcDevice); } - double lime_alc_create_context (double device, value attrlist) { + value lime_alc_create_context (value device, value attrlist) { - ALCdevice* alcDevice = (ALCdevice*)(intptr_t)device; + ALCdevice* alcDevice = (ALCdevice*)val_data (device); int* list = val_array_int (attrlist); ALCcontext* alcContext = alcCreateContext (alcDevice, list); - return (intptr_t)alcContext; + return cffi::alloc_pointer (alcContext); } - void lime_alc_destroy_context (double context) { + void lime_alc_destroy_context (value context) { - ALCcontext* alcContext = (ALCcontext*)(intptr_t)context; + ALCcontext* alcContext = (ALCcontext*)val_data (context); alcDestroyContext (alcContext); } - double lime_alc_get_contexts_device (double context) { + value lime_alc_get_contexts_device (value context) { - ALCcontext* alcContext = (ALCcontext*)(intptr_t)context; + ALCcontext* alcContext = (ALCcontext*)val_data (context); ALCdevice* alcDevice = alcGetContextsDevice (alcContext); - return (intptr_t)alcDevice; + return cffi::alloc_pointer (alcDevice); } - double lime_alc_get_current_context () { + value lime_alc_get_current_context () { ALCcontext* alcContext = alcGetCurrentContext (); - return (intptr_t)alcContext; + return cffi::alloc_pointer (alcContext); } - int lime_alc_get_error (double device) { + int lime_alc_get_error (value device) { - ALCdevice* alcDevice = (ALCdevice*)(intptr_t)device; + ALCdevice* alcDevice = (ALCdevice*)val_data (device); return alcGetError (alcDevice); } - value lime_alc_get_integerv (double device, int param, int size) { + value lime_alc_get_integerv (value device, int param, int size) { - ALCdevice* alcDevice = (ALCdevice*)(intptr_t)device; + ALCdevice* alcDevice = (ALCdevice*)val_data (device); ALCint* values = new ALCint[size]; alcGetIntegerv (alcDevice, param, size, values); @@ -950,43 +950,43 @@ namespace lime { } - value lime_alc_get_string (double device, int param) { + value lime_alc_get_string (value device, int param) { - ALCdevice* alcDevice = (ALCdevice*)(intptr_t)device; + ALCdevice* alcDevice = (ALCdevice*)val_data (device); const char* result = alcGetString (alcDevice, param); return result ? alloc_string (result) : alloc_null (); } - bool lime_alc_make_context_current (double context) { + bool lime_alc_make_context_current (value context) { - ALCcontext* alcContext = (ALCcontext*)(intptr_t)context; + ALCcontext* alcContext = (ALCcontext*)val_data (context); return alcMakeContextCurrent (alcContext); } - double lime_alc_open_device (HxString devicename) { + value lime_alc_open_device (HxString devicename) { ALCdevice* alcDevice = alcOpenDevice (devicename.__s); atexit (lime_al_cleanup); - return (intptr_t)alcDevice; + return cffi::alloc_pointer (alcDevice); } - void lime_alc_process_context (double context) { + void lime_alc_process_context (value context) { - ALCcontext* alcContext = (ALCcontext*)(intptr_t)context; + ALCcontext* alcContext = (ALCcontext*)val_data (context); alcProcessContext (alcContext); } - void lime_alc_suspend_context (double context) { + void lime_alc_suspend_context (value context) { - ALCcontext* alcContext = (ALCcontext*)(intptr_t)context; + ALCcontext* alcContext = (ALCcontext*)val_data (context); alcSuspendContext (alcContext); } diff --git a/project/src/graphics/cairo/CairoBindings.cpp b/project/src/graphics/cairo/CairoBindings.cpp index 34dc27b9f..75a13de79 100644 --- a/project/src/graphics/cairo/CairoBindings.cpp +++ b/project/src/graphics/cairo/CairoBindings.cpp @@ -9,199 +9,270 @@ namespace lime { - void lime_cairo_arc (double handle, double xc, double yc, double radius, double angle1, double angle2) { + void gc_cairo (value handle) { - cairo_arc ((cairo_t*)(intptr_t)handle, xc, yc, radius, angle1, angle2); + if (!val_is_null (handle)) { + + cairo_t* cairo = (cairo_t*)val_data (handle); + cairo_destroy (cairo); + + } } - void lime_cairo_arc_negative (double handle, double xc, double yc, double radius, double angle1, double angle2) { + void gc_cairo_font_face (value handle) { - cairo_arc_negative ((cairo_t*)(intptr_t)handle, xc, yc, radius, angle1, angle2); + if (!val_is_null (handle)) { + + cairo_font_face_t* face = (cairo_font_face_t*)val_data (handle); + cairo_font_face_destroy (face); + + } } - void lime_cairo_clip (double handle) { + void gc_cairo_font_options (value handle) { - cairo_clip ((cairo_t*)(intptr_t)handle); + if (!val_is_null (handle)) { + + cairo_font_options_t* options = (cairo_font_options_t*)val_data (handle); + cairo_font_options_destroy (options); + + } } - void lime_cairo_clip_extents (double handle, double x1, double y1, double x2, double y2) { + void gc_cairo_pattern (value handle) { - cairo_clip_extents ((cairo_t*)(intptr_t)handle, &x1, &y1, &x2, &y2); + if (!val_is_null (handle)) { + + cairo_pattern_t* pattern = (cairo_pattern_t*)val_data (handle); + cairo_pattern_destroy (pattern); + + } } - void lime_cairo_clip_preserve (double handle) { + void gc_cairo_surface (value handle) { - cairo_clip_preserve ((cairo_t*)(intptr_t)handle); + if (!val_is_null (handle)) { + + cairo_surface_t* surface = (cairo_surface_t*)val_data (handle); + cairo_surface_destroy (surface); + + } } - void lime_cairo_close_path (double handle) { + void lime_cairo_arc (value handle, double xc, double yc, double radius, double angle1, double angle2) { - cairo_close_path ((cairo_t*)(intptr_t)handle); + cairo_arc ((cairo_t*)val_data (handle), xc, yc, radius, angle1, angle2); } - void lime_cairo_copy_page (double handle) { + void lime_cairo_arc_negative (value handle, double xc, double yc, double radius, double angle1, double angle2) { - cairo_copy_page ((cairo_t*)(intptr_t)handle); + cairo_arc_negative ((cairo_t*)val_data (handle), xc, yc, radius, angle1, angle2); } - double lime_cairo_create (double surface) { + void lime_cairo_clip (value handle) { - return (intptr_t)cairo_create ((cairo_surface_t*)(intptr_t)surface); + cairo_clip ((cairo_t*)val_data (handle)); } - void lime_cairo_curve_to (double handle, double x1, double y1, double x2, double y2, double x3, double y3) { + void lime_cairo_clip_extents (value handle, double x1, double y1, double x2, double y2) { - cairo_curve_to ((cairo_t*)(intptr_t)handle, x1, y1, x2, y2, x3, y3); + cairo_clip_extents ((cairo_t*)val_data (handle), &x1, &y1, &x2, &y2); } - void lime_cairo_destroy (double handle) { + void lime_cairo_clip_preserve (value handle) { - cairo_destroy ((cairo_t*)(intptr_t)handle); + cairo_clip_preserve ((cairo_t*)val_data (handle)); } - void lime_cairo_fill (double handle) { + void lime_cairo_close_path (value handle) { - cairo_fill ((cairo_t*)(intptr_t)handle); + cairo_close_path ((cairo_t*)val_data (handle)); } - void lime_cairo_fill_extents (double handle, double x1, double y1, double x2, double y2) { + void lime_cairo_copy_page (value handle) { - cairo_fill_extents ((cairo_t*)(intptr_t)handle, &x1, &y1, &x2, &y2); + cairo_copy_page ((cairo_t*)val_data (handle)); } - void lime_cairo_fill_preserve (double handle) { + value lime_cairo_create (value surface) { - cairo_fill_preserve ((cairo_t*)(intptr_t)handle); - - } - - void lime_cairo_font_face_destroy (double handle) { - - cairo_font_face_destroy ((cairo_font_face_t*)(intptr_t)handle); + cairo_t* cairo = cairo_create ((cairo_surface_t*)val_data (surface)); + cairo_reference (cairo); + value handle = cffi::alloc_pointer (cairo); + val_gc (handle, gc_cairo); + return handle; } - int lime_cairo_font_face_get_reference_count (double handle) { + void lime_cairo_curve_to (value handle, double x1, double y1, double x2, double y2, double x3, double y3) { - return cairo_font_face_get_reference_count ((cairo_font_face_t*)(intptr_t)handle); + cairo_curve_to ((cairo_t*)val_data (handle), x1, y1, x2, y2, x3, y3); } - void lime_cairo_font_face_reference (double handle) { + void lime_cairo_destroy (value handle) { - cairo_font_face_reference ((cairo_font_face_t*)(intptr_t)handle); + cairo_destroy ((cairo_t*)val_data (handle)); } - int lime_cairo_font_face_status (double handle) { + void lime_cairo_fill (value handle) { - return cairo_font_face_status ((cairo_font_face_t*)(intptr_t)handle); + cairo_fill ((cairo_t*)val_data (handle)); } - double lime_cairo_font_options_create () { + void lime_cairo_fill_extents (value handle, double x1, double y1, double x2, double y2) { - return (intptr_t)cairo_font_options_create (); + cairo_fill_extents ((cairo_t*)val_data (handle), &x1, &y1, &x2, &y2); } - void lime_cairo_font_options_destroy (double handle) { + void lime_cairo_fill_preserve (value handle) { - cairo_font_options_destroy ((cairo_font_options_t*)(intptr_t)handle); + cairo_fill_preserve ((cairo_t*)val_data (handle)); + + } + + void lime_cairo_font_face_destroy (value handle) { + + cairo_font_face_destroy ((cairo_font_face_t*)val_data (handle)); } - int lime_cairo_font_options_get_antialias (double handle) { + int lime_cairo_font_face_get_reference_count (value handle) { - return cairo_font_options_get_antialias ((cairo_font_options_t*)(intptr_t)handle); + return cairo_font_face_get_reference_count ((cairo_font_face_t*)val_data (handle)); } - int lime_cairo_font_options_get_hint_metrics (double handle) { + void lime_cairo_font_face_reference (value handle) { - return cairo_font_options_get_hint_metrics ((cairo_font_options_t*)(intptr_t)handle); + cairo_font_face_reference ((cairo_font_face_t*)val_data (handle)); } - int lime_cairo_font_options_get_hint_style (double handle) { + int lime_cairo_font_face_status (value handle) { - return cairo_font_options_get_hint_style ((cairo_font_options_t*)(intptr_t)handle); + return cairo_font_face_status ((cairo_font_face_t*)val_data (handle)); } - int lime_cairo_font_options_get_subpixel_order (double handle) { + value lime_cairo_font_options_create () { - return cairo_font_options_get_subpixel_order ((cairo_font_options_t*)(intptr_t)handle); + value handle = cffi::alloc_pointer (cairo_font_options_create ()); + val_gc (handle, gc_cairo_font_options); + return handle; } - void lime_cairo_font_options_set_antialias (double handle, int v) { + void lime_cairo_font_options_destroy (value handle) { - cairo_font_options_set_antialias ((cairo_font_options_t*)(intptr_t)handle, (cairo_antialias_t)v); + cairo_font_options_destroy ((cairo_font_options_t*)val_data (handle)); + free_abstract (handle); } - void lime_cairo_font_options_set_hint_metrics (double handle, int v) { + int lime_cairo_font_options_get_antialias (value handle) { - cairo_font_options_set_hint_metrics ((cairo_font_options_t*)(intptr_t)handle, (cairo_hint_metrics_t)v); + return cairo_font_options_get_antialias ((cairo_font_options_t*)val_data (handle)); } - void lime_cairo_font_options_set_hint_style (double handle, int v) { + int lime_cairo_font_options_get_hint_metrics (value handle) { - cairo_font_options_set_hint_style ((cairo_font_options_t*)(intptr_t)handle, (cairo_hint_style_t)v); + return cairo_font_options_get_hint_metrics ((cairo_font_options_t*)val_data (handle)); } - void lime_cairo_font_options_set_subpixel_order (double handle, int v) { + int lime_cairo_font_options_get_hint_style (value handle) { - cairo_font_options_set_subpixel_order ((cairo_font_options_t*)(intptr_t)handle, (cairo_subpixel_order_t)v); + return cairo_font_options_get_hint_style ((cairo_font_options_t*)val_data (handle)); } - double lime_cairo_ft_font_face_create (double face, int flags) { + int lime_cairo_font_options_get_subpixel_order (value handle) { + + return cairo_font_options_get_subpixel_order ((cairo_font_options_t*)val_data (handle)); + + } + + + void lime_cairo_font_options_set_antialias (value handle, int v) { + + cairo_font_options_set_antialias ((cairo_font_options_t*)val_data (handle), (cairo_antialias_t)v); + + } + + + void lime_cairo_font_options_set_hint_metrics (value handle, int v) { + + cairo_font_options_set_hint_metrics ((cairo_font_options_t*)val_data (handle), (cairo_hint_metrics_t)v); + + } + + + void lime_cairo_font_options_set_hint_style (value handle, int v) { + + cairo_font_options_set_hint_style ((cairo_font_options_t*)val_data (handle), (cairo_hint_style_t)v); + + } + + + void lime_cairo_font_options_set_subpixel_order (value handle, int v) { + + cairo_font_options_set_subpixel_order ((cairo_font_options_t*)val_data (handle), (cairo_subpixel_order_t)v); + + } + + + value lime_cairo_ft_font_face_create (value face, int flags) { #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)face; - return (intptr_t)cairo_ft_font_face_create_for_ft_face ((FT_Face)font->face, flags); + Font *font = (Font*)val_data (face); + cairo_font_face_t* cairoFont = cairo_ft_font_face_create_for_ft_face ((FT_Face)font->face, flags); + cairo_font_face_reference (cairoFont); + value handle = cffi::alloc_pointer (cairoFont); + val_gc (handle, gc_cairo_font_face); + return handle; #else return 0; #endif @@ -209,31 +280,31 @@ namespace lime { } - int lime_cairo_get_antialias (double handle) { + int lime_cairo_get_antialias (value handle) { - return cairo_get_antialias ((cairo_t*)(intptr_t)handle); + return cairo_get_antialias ((cairo_t*)val_data (handle)); } - value lime_cairo_get_current_point (double handle) { + value lime_cairo_get_current_point (value handle) { double x, y; - cairo_get_current_point ((cairo_t*)(intptr_t)handle, &x, &y); + cairo_get_current_point ((cairo_t*)val_data (handle), &x, &y); Vector2 vec2 = Vector2 (x, y); return vec2.Value (); } - value lime_cairo_get_dash (double handle) { + value lime_cairo_get_dash (value handle) { - int length = cairo_get_dash_count ((cairo_t*)(intptr_t)handle); + int length = cairo_get_dash_count ((cairo_t*)val_data (handle)); double* dashes = new double[length]; double offset; - cairo_get_dash ((cairo_t*)(intptr_t)handle, dashes, &offset); + cairo_get_dash ((cairo_t*)val_data (handle), dashes, &offset); value result = alloc_array (length); @@ -249,470 +320,520 @@ namespace lime { } - int lime_cairo_get_dash_count (double handle) { + int lime_cairo_get_dash_count (value handle) { - return cairo_get_dash_count ((cairo_t*)(intptr_t)handle); + return cairo_get_dash_count ((cairo_t*)val_data (handle)); } - int lime_cairo_get_fill_rule (double handle) { + int lime_cairo_get_fill_rule (value handle) { - return cairo_get_fill_rule ((cairo_t*)(intptr_t)handle); + return cairo_get_fill_rule ((cairo_t*)val_data (handle)); } - double lime_cairo_get_font_face (double handle) { + value lime_cairo_get_font_face (value handle) { - return (intptr_t)cairo_get_font_face ((cairo_t*)(intptr_t)handle); + cairo_font_face_t* face = cairo_get_font_face ((cairo_t*)val_data (handle)); + cairo_font_face_reference (face); + value v = cffi::alloc_pointer (face); + val_gc (v, gc_cairo_font_face); + return v; } - double lime_cairo_get_font_options (double handle) { + value lime_cairo_get_font_options (value handle) { cairo_font_options_t *options = 0; - cairo_get_font_options ((cairo_t*)(intptr_t)handle, options); - return (intptr_t)options; + cairo_get_font_options ((cairo_t*)val_data (handle), options); + value v = cffi::alloc_pointer (options); + val_gc (v, gc_cairo_font_options); + return v; } - double lime_cairo_get_group_target (double handle) { + value lime_cairo_get_group_target (value handle) { - return (intptr_t)cairo_get_group_target ((cairo_t*)(intptr_t)handle); + cairo_surface_t* surface = cairo_get_group_target ((cairo_t*)val_data (handle)); + cairo_surface_reference (surface); + value v = cffi::alloc_pointer (surface); + val_gc (v, gc_cairo_surface); + return v; } - int lime_cairo_get_line_cap (double handle) { + int lime_cairo_get_line_cap (value handle) { - return cairo_get_line_cap ((cairo_t*)(intptr_t)handle); + return cairo_get_line_cap ((cairo_t*)val_data (handle)); } - int lime_cairo_get_line_join (double handle) { + int lime_cairo_get_line_join (value handle) { - return cairo_get_line_join ((cairo_t*)(intptr_t)handle); + return cairo_get_line_join ((cairo_t*)val_data (handle)); } - double lime_cairo_get_line_width (double handle) { + double lime_cairo_get_line_width (value handle) { - return cairo_get_line_width ((cairo_t*)(intptr_t)handle); + return cairo_get_line_width ((cairo_t*)val_data (handle)); } - value lime_cairo_get_matrix (double handle) { + value lime_cairo_get_matrix (value handle) { cairo_matrix_t cm; - cairo_get_matrix ((cairo_t*)(intptr_t)handle, &cm); + cairo_get_matrix ((cairo_t*)val_data (handle), &cm); Matrix3 mat3 = Matrix3 (cm.xx, cm.yx, cm.xy, cm.yy, cm.x0, cm.y0); return mat3.Value (); } - double lime_cairo_get_miter_limit (double handle) { + double lime_cairo_get_miter_limit (value handle) { - return cairo_get_miter_limit ((cairo_t*)(intptr_t)handle); + return cairo_get_miter_limit ((cairo_t*)val_data (handle)); } - int lime_cairo_get_operator (double handle) { + int lime_cairo_get_operator (value handle) { - return cairo_get_operator ((cairo_t*)(intptr_t)handle); + return cairo_get_operator ((cairo_t*)val_data (handle)); } - int lime_cairo_get_reference_count (double handle) { + int lime_cairo_get_reference_count (value handle) { - return cairo_get_reference_count ((cairo_t*)(intptr_t)handle); + return cairo_get_reference_count ((cairo_t*)val_data (handle)); } - double lime_cairo_get_source (double handle) { + value lime_cairo_get_source (value handle) { - return (intptr_t)cairo_get_source ((cairo_t*)(intptr_t)handle); + cairo_pattern_t* pattern = cairo_get_source ((cairo_t*)val_data (handle)); + cairo_pattern_reference (pattern); + value v = cffi::alloc_pointer (pattern); + val_gc (v, gc_cairo_pattern); + return v; } - double lime_cairo_get_target (double handle) { + value lime_cairo_get_target (value handle) { - return (intptr_t)cairo_get_target ((cairo_t*)(intptr_t)handle); + cairo_surface_t* surface = cairo_get_target ((cairo_t*)val_data (handle)); + cairo_surface_reference (surface); + value v = cffi::alloc_pointer (surface); + val_gc (v, gc_cairo_surface); + return v; } - double lime_cairo_get_tolerance (double handle) { + double lime_cairo_get_tolerance (value handle) { - return cairo_get_tolerance ((cairo_t*)(intptr_t)handle); + return cairo_get_tolerance ((cairo_t*)val_data (handle)); } - bool lime_cairo_has_current_point (double handle) { + bool lime_cairo_has_current_point (value handle) { - return cairo_has_current_point ((cairo_t*)(intptr_t)handle); + return cairo_has_current_point ((cairo_t*)val_data (handle)); } - void lime_cairo_identity_matrix (double handle) { + void lime_cairo_identity_matrix (value handle) { - cairo_identity_matrix ((cairo_t*)(intptr_t)handle); + cairo_identity_matrix ((cairo_t*)val_data (handle)); } - double lime_cairo_image_surface_create (int format, int width, int height) { + value lime_cairo_image_surface_create (int format, int width, int height) { - return (intptr_t)cairo_image_surface_create ((cairo_format_t)format, width, height); + cairo_surface_t* surface = cairo_image_surface_create ((cairo_format_t)format, width, height); + cairo_surface_reference (surface); + value handle = cffi::alloc_pointer (surface); + val_gc (handle, gc_cairo_surface); + return handle; } - double lime_cairo_image_surface_create_for_data (double data, int format, int width, int height, int stride) { + value lime_cairo_image_surface_create_for_data (double data, int format, int width, int height, int stride) { - return (intptr_t)cairo_image_surface_create_for_data ((unsigned char*)(intptr_t)data, (cairo_format_t)format, width, height, stride); + cairo_surface_t* surface = cairo_image_surface_create_for_data ((unsigned char*)(intptr_t)data, (cairo_format_t)format, width, height, stride); + cairo_surface_reference (surface); + value handle = cffi::alloc_pointer (surface); + val_gc (handle, gc_cairo_surface); + return handle; } - double lime_cairo_image_surface_get_data (double handle) { + double lime_cairo_image_surface_get_data (value handle) { - return (intptr_t)cairo_image_surface_get_data ((cairo_surface_t*)(intptr_t)handle); + return (intptr_t)cairo_image_surface_get_data ((cairo_surface_t*)val_data (handle)); } - int lime_cairo_image_surface_get_format (double handle) { + int lime_cairo_image_surface_get_format (value handle) { - return (int)cairo_image_surface_get_format ((cairo_surface_t*)(intptr_t)handle); + return (int)cairo_image_surface_get_format ((cairo_surface_t*)val_data (handle)); } - int lime_cairo_image_surface_get_height (double handle) { + int lime_cairo_image_surface_get_height (value handle) { - return cairo_image_surface_get_height ((cairo_surface_t*)(intptr_t)handle); + return cairo_image_surface_get_height ((cairo_surface_t*)val_data (handle)); } - int lime_cairo_image_surface_get_stride (double handle) { + int lime_cairo_image_surface_get_stride (value handle) { - return cairo_image_surface_get_stride ((cairo_surface_t*)(intptr_t)handle); + return cairo_image_surface_get_stride ((cairo_surface_t*)val_data (handle)); } - int lime_cairo_image_surface_get_width (double handle) { + int lime_cairo_image_surface_get_width (value handle) { - return cairo_image_surface_get_width ((cairo_surface_t*)(intptr_t)handle); + return cairo_image_surface_get_width ((cairo_surface_t*)val_data (handle)); } - bool lime_cairo_in_clip (double handle, double x, double y) { + bool lime_cairo_in_clip (value handle, double x, double y) { - return cairo_in_clip ((cairo_t*)(intptr_t)handle, x, y); + return cairo_in_clip ((cairo_t*)val_data (handle), x, y); } - bool lime_cairo_in_fill (double handle, double x, double y) { + bool lime_cairo_in_fill (value handle, double x, double y) { - return cairo_in_fill ((cairo_t*)(intptr_t)handle, x, y); + return cairo_in_fill ((cairo_t*)val_data (handle), x, y); } - bool lime_cairo_in_stroke (double handle, double x, double y) { + bool lime_cairo_in_stroke (value handle, double x, double y) { - return cairo_in_stroke ((cairo_t*)(intptr_t)handle, x, y); + return cairo_in_stroke ((cairo_t*)val_data (handle), x, y); } - void lime_cairo_line_to (double handle, double x, double y) { + void lime_cairo_line_to (value handle, double x, double y) { - cairo_line_to ((cairo_t*)(intptr_t)handle, x, y); + cairo_line_to ((cairo_t*)val_data (handle), x, y); } - void lime_cairo_mask (double handle, double pattern) { + void lime_cairo_mask (value handle, value pattern) { - cairo_mask ((cairo_t*)(intptr_t)handle, (cairo_pattern_t*)(intptr_t)pattern); + cairo_mask ((cairo_t*)val_data (handle), (cairo_pattern_t*)val_data (pattern)); } - void lime_cairo_mask_surface (double handle, double surface, double x, double y) { + void lime_cairo_mask_surface (value handle, value surface, double x, double y) { - cairo_mask_surface ((cairo_t*)(intptr_t)handle, (cairo_surface_t*)(intptr_t)surface, x, y); + cairo_mask_surface ((cairo_t*)val_data (handle), (cairo_surface_t*)val_data (surface), x, y); } - void lime_cairo_move_to (double handle, double x, double y) { + void lime_cairo_move_to (value handle, double x, double y) { - cairo_move_to ((cairo_t*)(intptr_t)handle, x, y); + cairo_move_to ((cairo_t*)val_data (handle), x, y); } - void lime_cairo_new_path (double handle) { + void lime_cairo_new_path (value handle) { - cairo_new_path ((cairo_t*)(intptr_t)handle); + cairo_new_path ((cairo_t*)val_data (handle)); } - void lime_cairo_paint (double handle) { + void lime_cairo_paint (value handle) { - cairo_paint ((cairo_t*)(intptr_t)handle); + cairo_paint ((cairo_t*)val_data (handle)); } - void lime_cairo_paint_with_alpha (double handle, double alpha) { + void lime_cairo_paint_with_alpha (value handle, double alpha) { - cairo_paint_with_alpha ((cairo_t*)(intptr_t)handle, alpha); + cairo_paint_with_alpha ((cairo_t*)val_data (handle), alpha); } - void lime_cairo_pattern_add_color_stop_rgb (double handle, double offset, double red, double green, double blue) { + void lime_cairo_pattern_add_color_stop_rgb (value handle, double offset, double red, double green, double blue) { - cairo_pattern_add_color_stop_rgb ((cairo_pattern_t*)(intptr_t)handle, offset, red, green, blue); + cairo_pattern_add_color_stop_rgb ((cairo_pattern_t*)val_data (handle), offset, red, green, blue); } - void lime_cairo_pattern_add_color_stop_rgba (double handle, double offset, double red, double green, double blue, double alpha) { + void lime_cairo_pattern_add_color_stop_rgba (value handle, double offset, double red, double green, double blue, double alpha) { - cairo_pattern_add_color_stop_rgba ((cairo_pattern_t*)(intptr_t)handle, offset, red, green, blue, alpha); + cairo_pattern_add_color_stop_rgba ((cairo_pattern_t*)val_data (handle), offset, red, green, blue, alpha); } - double lime_cairo_pattern_create_for_surface (double surface) { + value lime_cairo_pattern_create_for_surface (value surface) { - return (intptr_t)cairo_pattern_create_for_surface ((cairo_surface_t*)(intptr_t)surface); + cairo_pattern_t* pattern = cairo_pattern_create_for_surface ((cairo_surface_t*)val_data (surface)); + cairo_pattern_reference (pattern); + value handle = cffi::alloc_pointer (pattern); + val_gc (handle, gc_cairo_pattern); + return handle; } - double lime_cairo_pattern_create_linear (double x0, double y0, double x1, double y1) { + value lime_cairo_pattern_create_linear (double x0, double y0, double x1, double y1) { - return (intptr_t)cairo_pattern_create_linear (x0, y0, x1, y1); + cairo_pattern_t* pattern = cairo_pattern_create_linear (x0, y0, x1, y1); + cairo_pattern_reference (pattern); + value handle = cffi::alloc_pointer (pattern); + val_gc (handle, gc_cairo_pattern); + return handle; } - double lime_cairo_pattern_create_radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1) { + value lime_cairo_pattern_create_radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1) { - return (intptr_t)cairo_pattern_create_radial (cx0, cy0, radius0, cx1, cy1, radius1); + cairo_pattern_t* pattern = cairo_pattern_create_radial (cx0, cy0, radius0, cx1, cy1, radius1); + cairo_pattern_reference (pattern); + value handle = cffi::alloc_pointer (pattern); + val_gc (handle, gc_cairo_pattern); + return handle; } - double lime_cairo_pattern_create_rgb (double r, double g, double b) { + value lime_cairo_pattern_create_rgb (double r, double g, double b) { - return (intptr_t)cairo_pattern_create_rgb (r, g, b); + cairo_pattern_t* pattern = cairo_pattern_create_rgb (r, g, b); + cairo_pattern_reference (pattern); + value handle = cffi::alloc_pointer (pattern); + val_gc (handle, gc_cairo_pattern); + return handle; } - double lime_cairo_pattern_create_rgba (double r, double g, double b, double a) { + value lime_cairo_pattern_create_rgba (double r, double g, double b, double a) { - return (intptr_t)cairo_pattern_create_rgba (r, g, b, a); + cairo_pattern_t* pattern = cairo_pattern_create_rgba (r, g, b, a); + cairo_pattern_reference (pattern); + value handle = cffi::alloc_pointer (pattern); + val_gc (handle, gc_cairo_pattern); + return handle; } - void lime_cairo_pattern_destroy (double handle) { + void lime_cairo_pattern_destroy (value handle) { - cairo_pattern_destroy ((cairo_pattern_t*)(intptr_t)handle); + cairo_pattern_destroy ((cairo_pattern_t*)val_data (handle)); } - int lime_cairo_pattern_get_color_stop_count (double handle) { + int lime_cairo_pattern_get_color_stop_count (value handle) { int count; - return cairo_pattern_get_color_stop_count ((cairo_pattern_t*)(intptr_t)handle, &count); + return cairo_pattern_get_color_stop_count ((cairo_pattern_t*)val_data (handle), &count); return count; } - int lime_cairo_pattern_get_extend (double handle) { + int lime_cairo_pattern_get_extend (value handle) { - return cairo_pattern_get_extend ((cairo_pattern_t*)(intptr_t)handle); + return cairo_pattern_get_extend ((cairo_pattern_t*)val_data (handle)); } - int lime_cairo_pattern_get_filter (double handle) { + int lime_cairo_pattern_get_filter (value handle) { - return cairo_pattern_get_filter ((cairo_pattern_t*)(intptr_t)handle); + return cairo_pattern_get_filter ((cairo_pattern_t*)val_data (handle)); } - value lime_cairo_pattern_get_matrix (double handle) { + value lime_cairo_pattern_get_matrix (value handle) { cairo_matrix_t cm; - cairo_pattern_get_matrix ((cairo_pattern_t*)(intptr_t)handle, &cm); + cairo_pattern_get_matrix ((cairo_pattern_t*)val_data (handle), &cm); Matrix3 mat3 = Matrix3 (cm.xx, cm.yx, cm.xy, cm.yy, cm.x0, cm.y0); return mat3.Value (); } - void lime_cairo_pattern_set_extend (double handle, int extend) { + void lime_cairo_pattern_set_extend (value handle, int extend) { - cairo_pattern_set_extend ((cairo_pattern_t*)(intptr_t)handle, (cairo_extend_t)extend); + cairo_pattern_set_extend ((cairo_pattern_t*)val_data (handle), (cairo_extend_t)extend); } - void lime_cairo_pattern_set_filter (double handle, int filter) { + void lime_cairo_pattern_set_filter (value handle, int filter) { - cairo_pattern_set_filter ((cairo_pattern_t*)(intptr_t)handle, (cairo_filter_t)filter); + cairo_pattern_set_filter ((cairo_pattern_t*)val_data (handle), (cairo_filter_t)filter); } - void lime_cairo_pattern_set_matrix (double handle, value matrix) { + void lime_cairo_pattern_set_matrix (value handle, value matrix) { Matrix3 mat3 = Matrix3 (matrix); cairo_matrix_t cm; cairo_matrix_init (&cm, mat3.a, mat3.b, mat3.c, mat3.d, mat3.tx, mat3.ty); - cairo_pattern_set_matrix ((cairo_pattern_t*)(intptr_t)handle, &cm); + cairo_pattern_set_matrix ((cairo_pattern_t*)val_data (handle), &cm); } - double lime_cairo_pop_group (double handle) { + value lime_cairo_pop_group (value handle) { - return (intptr_t)cairo_pop_group ((cairo_t*)(intptr_t)handle); + cairo_pattern_t* pattern = cairo_pop_group ((cairo_t*)val_data (handle)); + cairo_pattern_reference (pattern); + value v = cffi::alloc_pointer (pattern); + val_gc (v, gc_cairo_pattern); + return v; } - void lime_cairo_pop_group_to_source (double handle) { + void lime_cairo_pop_group_to_source (value handle) { - cairo_pop_group_to_source ((cairo_t*)(intptr_t)handle); + cairo_pop_group_to_source ((cairo_t*)val_data (handle)); } - void lime_cairo_push_group (double handle) { + void lime_cairo_push_group (value handle) { - cairo_push_group ((cairo_t*)(intptr_t)handle); + cairo_push_group ((cairo_t*)val_data (handle)); } - void lime_cairo_push_group_with_content (double handle, int content) { + void lime_cairo_push_group_with_content (value handle, int content) { - cairo_push_group_with_content ((cairo_t*)(intptr_t)handle, (cairo_content_t)content); + cairo_push_group_with_content ((cairo_t*)val_data (handle), (cairo_content_t)content); } - void lime_cairo_rectangle (double handle, double x, double y, double width, double height) { + void lime_cairo_rectangle (value handle, double x, double y, double width, double height) { - cairo_rectangle ((cairo_t*)(intptr_t)handle, x, y, width, height); + cairo_rectangle ((cairo_t*)val_data (handle), x, y, width, height); } - void lime_cairo_reference (double handle) { + void lime_cairo_reference (value handle) { - cairo_reference ((cairo_t*)(intptr_t)handle); + cairo_reference ((cairo_t*)val_data (handle)); } - void lime_cairo_rel_curve_to (double handle, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3) { + void lime_cairo_rel_curve_to (value handle, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3) { - cairo_rel_curve_to ((cairo_t*)(intptr_t)handle, dx1, dy1, dx2, dy2, dx3, dy3); + cairo_rel_curve_to ((cairo_t*)val_data (handle), dx1, dy1, dx2, dy2, dx3, dy3); } - void lime_cairo_rel_line_to (double handle, double dx, double dy) { + void lime_cairo_rel_line_to (value handle, double dx, double dy) { - cairo_rel_line_to ((cairo_t*)(intptr_t)handle, dx, dy); + cairo_rel_line_to ((cairo_t*)val_data (handle), dx, dy); } - void lime_cairo_rel_move_to (double handle, double dx, double dy) { + void lime_cairo_rel_move_to (value handle, double dx, double dy) { - cairo_rel_move_to ((cairo_t*)(intptr_t)handle, dx, dy); + cairo_rel_move_to ((cairo_t*)val_data (handle), dx, dy); } - void lime_cairo_reset_clip (double handle) { + void lime_cairo_reset_clip (value handle) { - cairo_reset_clip ((cairo_t*)(intptr_t)handle); + cairo_reset_clip ((cairo_t*)val_data (handle)); } - void lime_cairo_restore (double handle) { + void lime_cairo_restore (value handle) { - cairo_restore ((cairo_t*)(intptr_t)handle); + cairo_restore ((cairo_t*)val_data (handle)); } - void lime_cairo_rotate (double handle, double amount) { + void lime_cairo_rotate (value handle, double amount) { - cairo_rotate ((cairo_t*)(intptr_t)handle, amount); + cairo_rotate ((cairo_t*)val_data (handle), amount); } - void lime_cairo_save (double handle) { + void lime_cairo_save (value handle) { - cairo_save ((cairo_t*)(intptr_t)handle); + cairo_save ((cairo_t*)val_data (handle)); } - void lime_cairo_scale (double handle, double x, double y) { + void lime_cairo_scale (value handle, double x, double y) { - cairo_scale ((cairo_t*)(intptr_t)handle, x, y); + cairo_scale ((cairo_t*)val_data (handle), x, y); } - void lime_cairo_set_antialias (double handle, int cap) { + void lime_cairo_set_antialias (value handle, int cap) { - cairo_set_antialias ((cairo_t*)(intptr_t)handle, (cairo_antialias_t)cap); + cairo_set_antialias ((cairo_t*)val_data (handle), (cairo_antialias_t)cap); } - void lime_cairo_set_dash (double handle, value dash) { + void lime_cairo_set_dash (value handle, value dash) { int length = val_array_size (dash); @@ -724,193 +845,200 @@ namespace lime { } - cairo_set_dash ((cairo_t*)(intptr_t)handle, dashPattern, length, 0); + cairo_set_dash ((cairo_t*)val_data (handle), dashPattern, length, 0); delete dashPattern; } - void lime_cairo_set_fill_rule (double handle, int cap) { + void lime_cairo_set_fill_rule (value handle, int cap) { - cairo_set_fill_rule ((cairo_t*)(intptr_t)handle, (cairo_fill_rule_t)cap); + cairo_set_fill_rule ((cairo_t*)val_data (handle), (cairo_fill_rule_t)cap); } - void lime_cairo_set_font_face (double handle, double face) { + void lime_cairo_set_font_face (value handle, value face) { - cairo_set_font_face ((cairo_t*)(intptr_t)handle, (cairo_font_face_t*)(intptr_t)face); + cairo_set_font_face ((cairo_t*)val_data (handle), (cairo_font_face_t*)val_data (face)); } - void lime_cairo_set_font_options (double handle, double options) { + void lime_cairo_set_font_options (value handle, value options) { - cairo_set_font_options ((cairo_t*)(intptr_t)handle, (cairo_font_options_t*)(intptr_t)options); + cairo_set_font_options ((cairo_t*)val_data (handle), (cairo_font_options_t*)val_data (options)); } - void lime_cairo_set_font_size (double handle, double size) { + void lime_cairo_set_font_size (value handle, double size) { - cairo_set_font_size ((cairo_t*)(intptr_t)handle, size); + cairo_set_font_size ((cairo_t*)val_data (handle), size); } - void lime_cairo_set_line_cap (double handle, int cap) { + void lime_cairo_set_line_cap (value handle, int cap) { - cairo_set_line_cap ((cairo_t*)(intptr_t)handle, (cairo_line_cap_t)cap); + cairo_set_line_cap ((cairo_t*)val_data (handle), (cairo_line_cap_t)cap); } - void lime_cairo_set_line_join (double handle, int join) { + void lime_cairo_set_line_join (value handle, int join) { - cairo_set_line_join ((cairo_t*)(intptr_t)handle, (cairo_line_join_t)join); + cairo_set_line_join ((cairo_t*)val_data (handle), (cairo_line_join_t)join); } - void lime_cairo_set_line_width (double handle, double width) { + void lime_cairo_set_line_width (value handle, double width) { - cairo_set_line_width ((cairo_t*)(intptr_t)handle, width); + cairo_set_line_width ((cairo_t*)val_data (handle), width); } - void lime_cairo_set_matrix (double handle, value matrix) { + void lime_cairo_set_matrix (value handle, value matrix) { Matrix3 mat3 = Matrix3 (matrix); cairo_matrix_t cm; cairo_matrix_init (&cm, mat3.a, mat3.b, mat3.c, mat3.d, mat3.tx, mat3.ty); - cairo_set_matrix ((cairo_t*)(intptr_t)handle, &cm); + cairo_set_matrix ((cairo_t*)val_data (handle), &cm); } - void lime_cairo_set_miter_limit (double handle, double miterLimit) { + void lime_cairo_set_miter_limit (value handle, double miterLimit) { - cairo_set_miter_limit ((cairo_t*)(intptr_t)handle, miterLimit); + cairo_set_miter_limit ((cairo_t*)val_data (handle), miterLimit); } - void lime_cairo_set_operator (double handle, int op) { + void lime_cairo_set_operator (value handle, int op) { - cairo_set_operator ((cairo_t*)(intptr_t)handle, (cairo_operator_t)op); + cairo_set_operator ((cairo_t*)val_data (handle), (cairo_operator_t)op); } - void lime_cairo_set_source (double handle, double pattern) { + void lime_cairo_set_source (value handle, value pattern) { - cairo_set_source ((cairo_t*)(intptr_t)handle, (cairo_pattern_t*)(intptr_t)pattern); + cairo_set_source ((cairo_t*)val_data (handle), (cairo_pattern_t*)val_data (pattern)); } - void lime_cairo_set_source_rgb (double handle, double r, double g, double b) { + void lime_cairo_set_source_rgb (value handle, double r, double g, double b) { - cairo_set_source_rgb ((cairo_t*)(intptr_t)handle, r, g, b); + cairo_set_source_rgb ((cairo_t*)val_data (handle), r, g, b); } - void lime_cairo_set_source_rgba (double handle, double r, double g, double b, double a) { + void lime_cairo_set_source_rgba (value handle, double r, double g, double b, double a) { - cairo_set_source_rgba ((cairo_t*)(intptr_t)handle, r, g, b, a); + cairo_set_source_rgba ((cairo_t*)val_data (handle), r, g, b, a); } - void lime_cairo_set_source_surface (double handle, double surface, double x, double y) { + void lime_cairo_set_source_surface (value handle, value surface, double x, double y) { - cairo_set_source_surface ((cairo_t*)(intptr_t)handle, (cairo_surface_t*)(intptr_t)surface, x, y); + cairo_set_source_surface ((cairo_t*)val_data (handle), (cairo_surface_t*)val_data (surface), x, y); } - void lime_cairo_set_tolerance (double handle, double tolerance) { + void lime_cairo_set_tolerance (value handle, double tolerance) { - cairo_set_tolerance ((cairo_t*)(intptr_t)handle, tolerance); + cairo_set_tolerance ((cairo_t*)val_data (handle), tolerance); } - void lime_cairo_show_page (double handle) { + void lime_cairo_show_page (value handle) { - cairo_show_page ((cairo_t*)(intptr_t)handle); + cairo_show_page ((cairo_t*)val_data (handle)); } - void lime_cairo_show_text (double handle, HxString text) { + void lime_cairo_show_text (value handle, HxString text) { - cairo_show_text ((cairo_t*)(intptr_t)handle, (char*)text.__s); + cairo_show_text ((cairo_t*)val_data (handle), (char*)text.__s); } - int lime_cairo_status (double handle) { + int lime_cairo_status (value handle) { - return cairo_status ((cairo_t*)(intptr_t)handle); + return cairo_status ((cairo_t*)val_data (handle)); } - void lime_cairo_stroke (double handle) { + void lime_cairo_stroke (value handle) { - cairo_stroke ((cairo_t*)(intptr_t)handle); + cairo_stroke ((cairo_t*)val_data (handle)); } - void lime_cairo_stroke_extents (double handle, double x1, double y1, double x2, double y2) { + void lime_cairo_stroke_extents (value handle, double x1, double y1, double x2, double y2) { - cairo_stroke_extents ((cairo_t*)(intptr_t)handle, &x1, &y1, &x2, &y2); + cairo_stroke_extents ((cairo_t*)val_data (handle), &x1, &y1, &x2, &y2); } - void lime_cairo_stroke_preserve (double handle) { + void lime_cairo_stroke_preserve (value handle) { - cairo_stroke_preserve ((cairo_t*)(intptr_t)handle); + cairo_stroke_preserve ((cairo_t*)val_data (handle)); } - void lime_cairo_surface_destroy (double handle) { + void lime_cairo_surface_destroy (value handle) { - cairo_surface_destroy ((cairo_surface_t*)(intptr_t)handle); + cairo_surface_destroy ((cairo_surface_t*)val_data (handle)); } - void lime_cairo_surface_flush (double handle) { + void lime_cairo_surface_flush (value handle) { - cairo_surface_flush ((cairo_surface_t*)(intptr_t)handle); + cairo_surface_flush ((cairo_surface_t*)val_data (handle)); } - void lime_cairo_transform (double handle, value matrix) { + void lime_cairo_surface_reference (value handle) { + + cairo_surface_reference ((cairo_surface_t*)val_data (handle)); + + } + + + void lime_cairo_transform (value handle, value matrix) { Matrix3 mat3 = Matrix3 (matrix); cairo_matrix_t cm; cairo_matrix_init (&cm, mat3.a, mat3.b, mat3.c, mat3.d, mat3.tx, mat3.ty); - cairo_transform ((cairo_t*)(intptr_t)handle, &cm); + cairo_transform ((cairo_t*)val_data (handle), &cm); } - void lime_cairo_translate (double handle, double x, double y) { + void lime_cairo_translate (value handle, double x, double y) { - cairo_translate ((cairo_t*)(intptr_t)handle, x, y); + cairo_translate ((cairo_t*)val_data (handle), x, y); } @@ -1049,6 +1177,7 @@ namespace lime { DEFINE_PRIME1v (lime_cairo_stroke_preserve); DEFINE_PRIME1v (lime_cairo_surface_destroy); DEFINE_PRIME1v (lime_cairo_surface_flush); + DEFINE_PRIME1v (lime_cairo_surface_reference); DEFINE_PRIME2v (lime_cairo_transform); DEFINE_PRIME3v (lime_cairo_translate); DEFINE_PRIME0 (lime_cairo_version);