2009-12-07 Rolf Bjarne Kvinge <RKvinge@novell.com>
[moon.git] / cairo / util / cairo-api-update
blobe16df43fd14a3268b89818d7b8211e03f79a7a27
1 #!/bin/sh
2 set -e
4 if [ $# -lt 1 ]; then
5 argv0=`basename $0`
6 echo "$argv0: Update source code to the lastest Cairo API" >&2
7 echo "" >&2
8 echo "Usage: $argv0 file [...]" >&2
9 exit 1
12 cairo_api_update() {
13 file=$1
14 backup=$file.bak
16 cp $file $backup
17 sed -e '/\(DEPRECATED\|REPLACED\)_BY/! {
18 s/cairo_current_font_extents/cairo_font_extents/g
19 s/cairo_get_font_extents/cairo_font_extents/g
20 s/cairo_current_operator/cairo_get_operator/g
21 s/cairo_current_tolerance/cairo_get_tolerance/g
22 s/cairo_current_point/cairo_get_current_point/g
23 s/cairo_current_fill_rule/cairo_get_fill_rule/g
24 s/cairo_current_line_width/cairo_get_line_width/g
25 s/cairo_current_line_cap/cairo_get_line_cap/g
26 s/cairo_current_line_join/cairo_get_line_join/g
27 s/cairo_current_miter_limit/cairo_get_miter_limit/g
28 s/cairo_current_matrix/cairo_get_matrix/g
29 s/cairo_current_pattern/cairo_get_source/g
30 s/cairo_current_target_surface/cairo_get_target/g
31 s/cairo_get_status/cairo_status/g
32 s/cairo_get_status_string/cairo_status_string/g
33 s/cairo_concat_matrix/cairo_transform/g
34 s/cairo_scale_font/cairo_set_font_size/g
35 s/cairo_select_font\([^_]\)/cairo_select_font_face\1/g
36 s/cairo_transform_font/cairo_set_font_matrix/g
37 s/cairo_transform_point/cairo_user_to_device/g
38 s/cairo_transform_distance/cairo_user_to_device_distance/g
39 s/cairo_inverse_transform_point/cairo_device_to_user/g
40 s/cairo_inverse_transform_distance/cairo_device_to_user_distance/g
41 s/cairo_init_clip/cairo_reset_clip/g
42 s/cairo_surface_create_for_image/cairo_image_surface_create_for_data/g
43 s/cairo_default_matrix/cairo_identity_matrix/g
44 s/cairo_matrix_set_affine/cairo_matrix_init/g
45 s/cairo_matrix_set_identity/cairo_matrix_init_identity/g
46 s/\([^_]\)cairo_pattern_add_color_stop\([^_]\)/\1cairo_pattern_add_color_stop_rgba\2/g
47 s/cairo_set_rgb_color/cairo_set_source_rgb/g
48 s/cairo_set_pattern/cairo_set_source/g
49 s/CAIRO_OPERATOR_SRC/CAIRO_OPERATOR_SOURCE/g
50 s/CAIRO_OPERATOR_DST/CAIRO_OPERATOR_DEST/g
51 s/CAIRO_OPERATOR_OVER_REVERSE/CAIRO_OPERATOR_DEST_OVER/g
52 s/CAIRO_OPERATOR_IN_REVERSE/CAIRO_OPERATOR_DEST_IN/g
53 s/CAIRO_OPERATOR_OUT_REVERSE/CAIRO_OPERATOR_DEST_OUT/g
54 s/CAIRO_OPERATOR_ATOP_REVERSE/CAIRO_OPERATOR_DEST_ATOP/g
56 ' $backup > $file
58 grep -n 'cairo_create[ ]*([ ]*)' $file /dev/null | sed 's/^\(.*:[0-9]\+:\).*/\1 cairo_create must now accept a target surface/'
59 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/'
60 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/'
61 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/'
62 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/'
63 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/'
64 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/'
67 while [ $# -gt 0 ]; do
68 file=$1
69 shift
70 cairo_api_update $file
71 done