cairo-api-update 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh
  2. set -e
  3. if [ $# -lt 1 ]; then
  4. argv0=`basename $0`
  5. echo "$argv0: Update source code to the lastest Cairo API" >&2
  6. echo "" >&2
  7. echo "Usage: $argv0 file [...]" >&2
  8. exit 1
  9. fi
  10. cairo_api_update() {
  11. file=$1
  12. backup=$file.bak
  13. cp $file $backup
  14. sed -e '/\(DEPRECATED\|REPLACED\)_BY/! {
  15. s/cairo_current_font_extents/cairo_font_extents/g
  16. s/cairo_get_font_extents/cairo_font_extents/g
  17. s/cairo_current_operator/cairo_get_operator/g
  18. s/cairo_current_tolerance/cairo_get_tolerance/g
  19. s/cairo_current_point/cairo_get_current_point/g
  20. s/cairo_current_fill_rule/cairo_get_fill_rule/g
  21. s/cairo_current_line_width/cairo_get_line_width/g
  22. s/cairo_current_line_cap/cairo_get_line_cap/g
  23. s/cairo_current_line_join/cairo_get_line_join/g
  24. s/cairo_current_miter_limit/cairo_get_miter_limit/g
  25. s/cairo_current_matrix/cairo_get_matrix/g
  26. s/cairo_current_pattern/cairo_get_source/g
  27. s/cairo_current_target_surface/cairo_get_target/g
  28. s/cairo_get_status/cairo_status/g
  29. s/cairo_get_status_string/cairo_status_string/g
  30. s/cairo_concat_matrix/cairo_transform/g
  31. s/cairo_scale_font/cairo_set_font_size/g
  32. s/cairo_select_font\([^_]\)/cairo_select_font_face\1/g
  33. s/cairo_transform_font/cairo_set_font_matrix/g
  34. s/cairo_transform_point/cairo_user_to_device/g
  35. s/cairo_transform_distance/cairo_user_to_device_distance/g
  36. s/cairo_inverse_transform_point/cairo_device_to_user/g
  37. s/cairo_inverse_transform_distance/cairo_device_to_user_distance/g
  38. s/cairo_init_clip/cairo_reset_clip/g
  39. s/cairo_surface_create_for_image/cairo_image_surface_create_for_data/g
  40. s/cairo_default_matrix/cairo_identity_matrix/g
  41. s/cairo_matrix_set_affine/cairo_matrix_init/g
  42. s/cairo_matrix_set_identity/cairo_matrix_init_identity/g
  43. s/\([^_]\)cairo_pattern_add_color_stop\([^_]\)/\1cairo_pattern_add_color_stop_rgba\2/g
  44. s/cairo_set_rgb_color/cairo_set_source_rgb/g
  45. s/cairo_set_pattern/cairo_set_source/g
  46. s/CAIRO_OPERATOR_SRC/CAIRO_OPERATOR_SOURCE/g
  47. s/CAIRO_OPERATOR_DST/CAIRO_OPERATOR_DEST/g
  48. s/CAIRO_OPERATOR_OVER_REVERSE/CAIRO_OPERATOR_DEST_OVER/g
  49. s/CAIRO_OPERATOR_IN_REVERSE/CAIRO_OPERATOR_DEST_IN/g
  50. s/CAIRO_OPERATOR_OUT_REVERSE/CAIRO_OPERATOR_DEST_OUT/g
  51. s/CAIRO_OPERATOR_ATOP_REVERSE/CAIRO_OPERATOR_DEST_ATOP/g
  52. }
  53. ' $backup > $file
  54. grep -n 'cairo_create[ ]*([ ]*)' $file /dev/null | sed 's/^\(.*:[0-9]\+:\).*/\1 cairo_create must now accept a target surface/'
  55. grep -n 'cairo_set_target_image' $file /dev/null | sed 's/^\(.*:[0-9]\+:\).*/\1 cairo_set_target_image should be reworked to use cairo_image_surface_create_for_data, likely before cairo_create/'
  56. grep -n 'cairo_set_target_surface' $file /dev/null | sed 's/^\(.*:[0-9]\+:\).*/\1 cairo_set_target_surface for temporarily changing the target should now be rworked to create a temporary context with cairo_create/'
  57. grep -n 'cairo_set_target_png' $file /dev/null | sed 's/^\(.*:[0-9]\+:\).*/\1 cairo_set_target_png should be reworked to use cairo_image_surface_create followed by cairo_surface_write_to_png/'
  58. grep -n 'cairo_set_target_drawable' $file /dev/null | sed 's/^\(.*:[0-9]\+:\).*/\1 cairo_set_target_drawable should be reworked to use cairo_xlib_surface_create, likely before cairo_create/'
  59. grep -n 'cairo_set_target_[^dis][^n]' $file /dev/null | sed 's/^\(.*:[0-9]\+:\).*cairo_set_target_\([a-z]*\).*/\1 cairo_set_target_\2 should be reworked to use cairo_\2_surface_create, likely before cairo_create/'
  60. grep -n 'cairo_set_alpha' $file /dev/null | sed 's/\(.*:[0-9]\+:\).*/\1 cairo_set_alpha should be replaced by turning a nearby cairo_set_source_rgb into cairo_set_source_rgba or turning a nearby cairo_paint into cairo_paint_with_alpha/'
  61. }
  62. while [ $# -gt 0 ]; do
  63. file=$1
  64. shift
  65. cairo_api_update $file
  66. done