Changeset 2792 in project


Ignore:
Timestamp:
01/05/07 06:45:44 (14 years ago)
Author:
felix winkelmann
Message:

fixed syntax errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/An extended FFI example

    r1626 r2792  
    4343 ;; Define a few callback function:
    4444
    45  (define-external (hello ((c-pointer GtkWidget) widget)
     45 (define-external (hello ((pointer "GtkWidget") widget)
    4646                         (c-pointer data))
    4747   void
    48    (print Hello, world) )
     48   (print "Hello, world") )
    4949
    50  (define-external (delete_event ((c-pointer GtkWidget) widget)
    51                                 ((c-pointer GdkEvent) event)
     50 (define-external (delete_event ((pointer "GtkWidget") widget)
     51                                ((pointer "GdkEvent") event)
    5252                                (c-pointer data) )
    5353   bool
     
    5555   #t)
    5656
    57  (define-external (destroy ((c-pointer GtkWidget) widget)
     57 (define-external (destroy ((pointer "GtkWidget") widget)
    5858                           (c-pointer data) )
    5959   void
     
    6464 ;; to foreign code:
    6565
    66  (foreign-code gtk_init(&C_main_argc, &C_main_argv);)
     66 (foreign-code "gtk_init(&C_main_argc, &C_main_argv);")
    6767
    6868 (define window (gtk_window_new GTK_WINDOW_TOPLEVEL))
     
    7070 ;; $#... with a callback-name returns the function pointer:
    7171
    72  (g_signal_connect window delete_event #$delete_event #f)
    73  (g_signal_connect window destroy #$destroy #f)
     72 (g_signal_connect window "delete_event" #$delete_event #f)
     73 (g_signal_connect window "destroy" #$destroy #f)
    7474
    7575 (gtk_container_set_border_width window 10)
     
    7777 (define button (gtk_button_new_with_label "Hello World"))
    7878
    79  (g_signal_connect button clicked #$hello #f)
     79 (g_signal_connect button "clicked" #$hello #f)
    8080
    8181 ;; Here we use foreign-value to get the function pointer.
     
    8383 ;; a callback:
    8484
    85  (g_signal_connect_swapped button clicked
     85 (g_signal_connect_swapped button "clicked"
    8686   (foreign-value gtk_widget_destroy c-pointer) window)
    8787
Note: See TracChangeset for help on using the changeset viewer.