changeset 266:b302f82224e1

Fix: bitfield access for PangoLayoutLine
author Frank Benoit <benoit@tionex.de>
date Sun, 06 Jul 2008 15:34:54 +0200
parents 07d9ed8927b6
children 6383fb4cdfc3
files dwt/internal/c/pango.d dwt/internal/gtk/OS.d
diffstat 2 files changed, 53 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/internal/c/pango.d	Sun Jul 06 15:34:21 2008 +0200
+++ b/dwt/internal/c/pango.d	Sun Jul 06 15:34:54 2008 +0200
@@ -6,8 +6,50 @@
 
 import dwt.dwthelper.utils;
 
+//version=DYNLINK;
+
 public import dwt.internal.c.glib_object;
 
+version(DYNLINK){
+    import tango.sys.SharedLib : SharedLib;
+    import tango.util.log.Trace;
+    struct Symbol{
+        String name;
+        void** symbol;
+    }
+}
+
+void loadLib(){
+    version(DYNLINK){
+        String libname = "libpango-1.0.so";
+
+        SharedLib lib = SharedLib.load( libname );
+        if( lib is null ){
+            lib = SharedLib.load( libname ~ ".0" );
+        }
+        int loaded;
+        if ( lib !is null ) {
+            foreach( s; symbols ){
+                try{
+                    *s.symbol = lib.getSymbol( s.name.ptr );
+                }
+                catch(Exception e){}
+                if( *s.symbol is null ){
+                    Trace.formatln( "{}: Symbol '{}' not found", libname, s.name );
+                }
+                else{
+                    loaded++;
+                }
+            }
+        } else {
+            Trace.formatln( "Could not load the library {}", libname );
+        }
+    }
+}
+
+
+
+
 extern(C):
 align(4):
 
@@ -371,6 +413,12 @@
 uint bitfield0;
 // uint is_paragraph_start // bits 0 .. 1
 // uint resolved_dir // bits 1 .. 4
+uint is_paragraph_start(){ return ( bitfield0 >> 0 ) & 0x01; }
+uint resolved_dir      (){ return ( bitfield0 >> 1 ) & 0x07; }
+
+uint is_paragraph_start( uint v ){ bitfield0 &= ~( 0x01 << 0 ); bitfield0 |= ( v & 0x01 ) << 0; return is_paragraph_start(); }
+uint resolved_dir      ( uint v ){ bitfield0 &= ~( 0x07 << 1 ); bitfield0 |= ( v & 0x07 ) << 1; return resolved_dir      (); }
+
 }
 struct _PangoGlyphItem {
 _PangoItem * item;
@@ -497,7 +545,6 @@
 // uint is_expandable_space // bits 11 .. 12
 }
 version(DYNLINK){
-extern (C) int function(_PangoLayoutLine*) pango_layout_line_get_resolved_dir; // manually added
 extern (C) char * function(int, int, int)pango_version_check;
 extern (C) char * function()pango_version_string;
 extern (C) int function()pango_version;
@@ -849,7 +896,6 @@
 
 
 Symbol[] symbols = [
-    { "pango_layout_line_get_resolved_dir",  cast(void**)& pango_layout_line_get_resolved_dir}, // manually added
     { "pango_version_check",  cast(void**)& pango_version_check},
     { "pango_version_string",  cast(void**)& pango_version_string},
     { "pango_version",  cast(void**)& pango_version},
@@ -1201,7 +1247,6 @@
 ];
 
 } else { // version(DYNLINK)
-extern (C) int pango_layout_line_get_resolved_dir(_PangoLayoutLine*); // manually added
 extern (C) char * pango_version_check(int, int, int);
 extern (C) char * pango_version_string();
 extern (C) int pango_version();
--- a/dwt/internal/gtk/OS.d	Sun Jul 06 15:34:21 2008 +0200
+++ b/dwt/internal/gtk/OS.d	Sun Jul 06 15:34:54 2008 +0200
@@ -654,6 +654,7 @@
 
     static this(){
         dwt.internal.c.gtk.loadLib();
+        dwt.internal.c.pango.loadLib();
         if (OS.GTK_VERSION >= OS.buildVERSION (2, 10, 0)){
 //            dwt.internal.c.gtk_unix_print_2_0.loadLib();
         }
@@ -2240,7 +2241,6 @@
     mixin ForwardGtkOsCFunc!(.pango_layout_iter_next_run);
     mixin ForwardGtkOsCFunc!(.pango_layout_line_get_extents);
     mixin ForwardGtkOsCFunc!(.pango_layout_line_x_to_index);
-    mixin ForwardGtkOsCFunc!(.pango_layout_line_get_resolved_dir);
     mixin ForwardGtkOsCFunc!(.pango_layout_new);
     mixin ForwardGtkOsCFunc!(.pango_layout_set_alignment );
     mixin ForwardGtkOsCFunc!(.pango_layout_set_attributes);
@@ -2264,6 +2264,10 @@
 
     /* Field accessors */
 
+    public static uint pango_layout_line_get_resolved_dir( PangoLayoutLine* line ){
+        return line.resolved_dir();
+    }
+
     static void    GTK_ACCEL_LABEL_SET_ACCEL_STRING( void *arg0, gchar * arg1 )
             { (cast(GtkAccelLabel*)arg0).accel_string = arg1; }
     static gchar*  GTK_ACCEL_LABEL_GET_ACCEL_STRING( void* arg0)