Changeset 25812 in project for release


Ignore:
Timestamp:
01/15/12 14:59:29 (10 years ago)
Author:
Christian Kellermann
Message:

Fix bug #762

Due to a missing conversion procedure in the define-foreign-type
definitions of cairo-font-extents-type and cairo-text-extents-type the
wrapping record has been handed to the C part and not the blob itself
causing stack corruption and segfaults on several systems.

This commit also fixes the record printers for these types.

Uses now C_return instead of a plain return call (just in case).

Thanks to Felix and Peter for teaching about the FFI and support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/cairo/trunk/cairo.scm

    r25654 r25812  
    309309
    310310(define-record-printer (cairo-text-extents-type te out)
    311   (for-each (lambda (x) (display x out)
     311  (for-each (lambda (x) (display x out))
    312312                    (list "#<cairo-text-extents "
    313313                          (cairo-text-extents-x-bearing te)" "
     
    316316                          (cairo-text-extents-height te)" "
    317317                          (cairo-text-extents-x-advance te)" "
    318                           (cairo-text-extents-y-advance te)">"))))
    319 
    320 (define-foreign-type cairo_text_extents_t scheme-pointer)
    321 
    322 (define cairo-text-extents-x-bearing (foreign-lambda* double ((cairo_text_extents_t te)) "return(((cairo_text_extents_t*)te)->x_bearing);"))
    323 (define cairo-text-extents-y-bearing (foreign-lambda* double ((cairo_text_extents_t te)) "return(((cairo_text_extents_t*)te)->y_bearing);"))
    324 (define cairo-text-extents-width (foreign-lambda* double ((cairo_text_extents_t te)) "return(((cairo_text_extents_t*)te)->width);"))
    325 (define cairo-text-extents-height (foreign-lambda* double ((cairo_text_extents_t te)) "return(((cairo_text_extents_t*)te)->height);"))
    326 (define cairo-text-extents-x-advance (foreign-lambda* double ((cairo_text_extents_t te)) "return(((cairo_text_extents_t*)te)->x_advance);"))
    327 (define cairo-text-extents-y-advance (foreign-lambda* double ((cairo_text_extents_t te)) "return(((cairo_text_extents_t*)te)->y_advance);"))
     318                          (cairo-text-extents-y-advance te)">")))
     319
     320(define-foreign-type cairo_text_extents_t scheme-pointer cairo-text-extents-type-buffer)
     321
     322(define cairo-text-extents-x-bearing (foreign-lambda* double ((cairo_text_extents_t te)) "C_return(((cairo_text_extents_t*)te)->x_bearing);"))
     323(define cairo-text-extents-y-bearing (foreign-lambda* double ((cairo_text_extents_t te)) "C_return(((cairo_text_extents_t*)te)->y_bearing);"))
     324(define cairo-text-extents-width (foreign-lambda* double ((cairo_text_extents_t te)) "C_return(((cairo_text_extents_t*)te)->width);"))
     325(define cairo-text-extents-height (foreign-lambda* double ((cairo_text_extents_t te)) "C_return(((cairo_text_extents_t*)te)->height);"))
     326(define cairo-text-extents-x-advance (foreign-lambda* double ((cairo_text_extents_t te)) "C_return(((cairo_text_extents_t*)te)->x_advance);"))
     327(define cairo-text-extents-y-advance (foreign-lambda* double ((cairo_text_extents_t te)) "C_return(((cairo_text_extents_t*)te)->y_advance);"))
    328328
    329329(define cairo-text-extents-x-bearing-set! (foreign-lambda* double ((cairo_text_extents_t te) (double v)) "((cairo_text_extents_t*)te)->x_bearing = v;"))
     
    342342
    343343(define-record-printer (cairo-font-extents-type e out)
    344   (for-each (lambda (x) (display x out)
     344  (for-each (lambda (x) (display x out))
    345345                    (list "#<cairo-font-extents "
    346346                          (cairo-font-extents-ascent e)" "
     
    348348                          (cairo-font-extents-height e)" "
    349349                          (cairo-font-extents-max-x-advance e)" "
    350                           (cairo-font-extents-max-y-advance e)">"))))
    351 
    352 (define-foreign-type cairo_font_extents_t scheme-pointer)
    353 
    354 (define cairo-font-extents-ascent (foreign-lambda* double ((cairo_font_extents_t e)) "return(((cairo_font_extents_t*)e)->ascent);"))
    355 (define cairo-font-extents-descent (foreign-lambda* double ((cairo_font_extents_t e)) "return(((cairo_font_extents_t*)e)->descent);"))
    356 (define cairo-font-extents-height (foreign-lambda* double ((cairo_font_extents_t e)) "return(((cairo_font_extents_t*)e)->height);"))
    357 (define cairo-font-extents-max-x-advance (foreign-lambda* double ((cairo_font_extents_t e)) "return(((cairo_font_extents_t*)e)->max_x_advance);"))
    358 (define cairo-font-extents-max-y-advance (foreign-lambda* double ((cairo_font_extents_t e)) "return(((cairo_font_extents_t*)e)->max_y_advance);"))
     350                          (cairo-font-extents-max-y-advance e)">")))
     351
     352(define-foreign-type cairo_font_extents_t scheme-pointer cairo-font-extents-type-buffer)
     353
     354(define cairo-font-extents-ascent (foreign-lambda* double ((cairo_font_extents_t e)) "C_return(((cairo_font_extents_t*)e)->ascent);"))
     355(define cairo-font-extents-descent (foreign-lambda* double ((cairo_font_extents_t e)) "C_return(((cairo_font_extents_t*)e)->descent);"))
     356(define cairo-font-extents-height (foreign-lambda* double ((cairo_font_extents_t e)) "C_return(((cairo_font_extents_t*)e)->height);"))
     357(define cairo-font-extents-max-x-advance (foreign-lambda* double ((cairo_font_extents_t e)) "C_return(((cairo_font_extents_t*)e)->max_x_advance);"))
     358(define cairo-font-extents-max-y-advance (foreign-lambda* double ((cairo_font_extents_t e)) "C_return(((cairo_font_extents_t*)e)->max_y_advance);"))
    359359
    360360(define cairo-font-extents-ascent-set! (foreign-lambda* double ((cairo_font_extents_t e) (double v)) "((cairo_font_extents_t*)e)->ascent = v;"))
Note: See TracChangeset for help on using the changeset viewer.