forked from gtkforphp/cairo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp_cairo.h
680 lines (603 loc) · 22.5 KB
/
php_cairo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2011 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Elizabeth Smith <[email protected]> |
| Michael Maclean <[email protected]> |
| Akshat Gupta <[email protected]> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_CAIRO_H
#define PHP_CAIRO_H
#define PHP_CAIRO_VERSION "0.3.2-beta"
extern zend_module_entry cairo_module_entry;
#define phpext_cairo_ptr &cairo_module_entry
#ifdef PHP_WIN32
# define PHP_CAIRO_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_CAIRO_API __attribute__ ((visibility("default")))
#else
# define PHP_CAIRO_API
#endif
/* Silly compilers */
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* 5.2 is stupid and needs some additional stuff */
#ifndef zend_parse_parameters_none
#define zend_parse_parameters_none() \
zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "")
#endif
/* refcount macros */
#ifndef Z_ADDREF_P
#define Z_ADDREF_P(pz) (pz)->refcount++
#endif
#ifndef Z_DELREF_P
#define Z_DELREF_P(pz) (pz)->refcount--
#endif
#ifndef Z_SET_REFCOUNT_P
#define Z_SET_REFCOUNT_P(pz, rc) (pz)->refcount = rc
#endif
#include <cairo.h>
#if defined(CAIRO_HAS_FT_FONT) && defined(HAVE_FREETYPE)
#include <ft2build.h>
#include FT_FREETYPE_H
#endif
/* Cairo object stuff */
typedef struct _stream_closure {
php_stream *stream;
zend_bool owned_stream;
#ifdef ZTS
TSRMLS_D;
#endif
} stream_closure;
typedef struct _cairo_glyph_object {
zend_object std;
cairo_glyph_t *glyph;
} cairo_glyph_object;
typedef struct _cairo_context_object {
zend_object std;
zval *surface;
zval *matrix;
zval *pattern;
zval *font_face;
zval *font_matrix;
zval *font_options;
zval *scaled_font;
cairo_t *context;
} cairo_context_object;
typedef struct _cairo_pattern_object {
zend_object std;
zval *matrix;
zval *surface;
cairo_pattern_t *pattern;
} cairo_pattern_object;
typedef struct _cairo_surface_object {
zend_object std;
cairo_surface_t *surface;
char * buffer;
stream_closure *closure;
zval *parent_zval;
} cairo_surface_object;
typedef struct _cairo_matrix_object {
zend_object std;
cairo_matrix_t *matrix;
} cairo_matrix_object;
typedef struct _cairo_path_object {
zend_object std;
cairo_path_t *path;
} cairo_path_object;
typedef struct _cairo_scaled_font_object {
zend_object std;
zval *font_face;
zval *font_options;
zval *matrix;
zval *ctm;
cairo_scaled_font_t *scaled_font;
} cairo_scaled_font_object;
typedef struct _cairo_font_face_object {
zend_object std;
cairo_font_face_t *font_face;
} cairo_font_face_object;
#if defined(CAIRO_HAS_FT_FONT) && defined(HAVE_FREETYPE)
typedef struct _cairo_ft_font_face_object {
zend_object std;
cairo_font_face_t *font_face;
FT_Stream ft_stream;
FT_Face ft_face;
cairo_user_data_key_t key;
} cairo_ft_font_face_object;
#endif
#if defined(CAIRO_HAS_WIN32_FONT) && defined(HAVE_WIN32_FONT)
typedef struct _cairo_win32_font_face_object {
zend_object std;
cairo_font_face_t *font_face;
} cairo_win32_font_face_object;
#endif
typedef struct _cairo_font_options_object {
zend_object std;
cairo_font_options_t *font_options;
} cairo_font_options_object;
/* Lifecycle functions */
PHP_MINIT_FUNCTION(cairo);
PHP_MINFO_FUNCTION(cairo);
PHP_MSHUTDOWN_FUNCTION(cairo);
/* Globals */
#if defined(CAIRO_HAS_FT_FONT) && defined(HAVE_FREETYPE)
ZEND_BEGIN_MODULE_GLOBALS(cairo)
/* Freetype library */
FT_Library ft_lib;
ZEND_END_MODULE_GLOBALS(cairo)
#ifdef ZTS
# define CAIROG(v) TSRMG(cairo_globals_id, zend_cairo_globals *, v)
#else
# define CAIROG(v) (cairo_globals.v)
#endif
ZEND_EXTERN_MODULE_GLOBALS(cairo)
typedef struct _php_cairo_ft_error {
int err_code;
const char *err_msg;
} php_cairo_ft_error;
extern const php_cairo_ft_error php_cairo_ft_errors[];
/* Helper for getting FreeType error strings */
const char* php_cairo_get_ft_error(int error TSRMLS_DC);
#undef __FTERRORS_H__
#define FT_ERRORDEF( e, v, s ) { e, s },
#define FT_ERROR_START_LIST {
#define FT_ERROR_END_LIST { 0, 0 } };
#endif
PHP_MINIT_FUNCTION(cairo_matrix);
PHP_MINIT_FUNCTION(cairo_error);
PHP_MINIT_FUNCTION(cairo_context);
PHP_MINIT_FUNCTION(cairo_path);
PHP_MINIT_FUNCTION(cairo_font_options);
PHP_MINIT_FUNCTION(cairo_font_face);
PHP_MINIT_FUNCTION(cairo_scaled_font);
PHP_MINIT_FUNCTION(cairo_font);
PHP_MINIT_FUNCTION(cairo_pattern);
PHP_MINIT_FUNCTION(cairo_surface);
PHP_MINIT_FUNCTION(cairo_image_surface);
PHP_MINIT_FUNCTION(cairo_svg_surface);
PHP_MINIT_FUNCTION(cairo_pdf_surface);
PHP_MINIT_FUNCTION(cairo_ps_surface);
PHP_MINIT_FUNCTION(cairo_recording_surface);
PHP_MINIT_FUNCTION(cairo_sub_surface);
PHP_MINIT_FUNCTION(cairo_ft_font);
PHP_MINIT_FUNCTION(cairo_win32_font);
/* cairo functions */
PHP_FUNCTION(cairo_version);
PHP_FUNCTION(cairo_version_string);
PHP_FUNCTION(cairo_available_surfaces);
PHP_FUNCTION(cairo_available_fonts);
PHP_FUNCTION(cairo_status_to_string);
/* Context Functions */
PHP_FUNCTION(cairo_create);
PHP_FUNCTION(cairo_status);
PHP_FUNCTION(cairo_save);
PHP_FUNCTION(cairo_restore);
PHP_FUNCTION(cairo_get_target);
PHP_FUNCTION(cairo_push_group);
PHP_FUNCTION(cairo_push_group_with_content);
PHP_FUNCTION(cairo_pop_group);
PHP_FUNCTION(cairo_pop_group_to_source);
PHP_FUNCTION(cairo_get_group_target);
PHP_FUNCTION(cairo_set_source_rgb);
PHP_FUNCTION(cairo_set_source_rgba);
PHP_FUNCTION(cairo_set_source);
PHP_FUNCTION(cairo_set_source_surface);
PHP_FUNCTION(cairo_get_source);
PHP_FUNCTION(cairo_set_antialias);
PHP_FUNCTION(cairo_get_antialias);
PHP_FUNCTION(cairo_set_dash);
PHP_FUNCTION(cairo_get_dash_count);
PHP_FUNCTION(cairo_get_dash);
PHP_FUNCTION(cairo_set_fill_rule);
PHP_FUNCTION(cairo_get_fill_rule);
PHP_FUNCTION(cairo_set_line_cap);
PHP_FUNCTION(cairo_get_line_cap);
PHP_FUNCTION(cairo_set_line_cap);
PHP_FUNCTION(cairo_set_line_join);
PHP_FUNCTION(cairo_get_line_join);
PHP_FUNCTION(cairo_set_line_width);
PHP_FUNCTION(cairo_get_line_width);
PHP_FUNCTION(cairo_set_miter_limit);
PHP_FUNCTION(cairo_get_miter_limit);
PHP_FUNCTION(cairo_set_operator);
PHP_FUNCTION(cairo_get_operator);
PHP_FUNCTION(cairo_set_tolerance);
PHP_FUNCTION(cairo_get_tolerance);
PHP_FUNCTION(cairo_clip);
PHP_FUNCTION(cairo_clip_preserve);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
PHP_FUNCTION(cairo_in_clip);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
PHP_FUNCTION(cairo_clip_extents);
PHP_FUNCTION(cairo_clip_rectangle_list);
#endif
PHP_FUNCTION(cairo_reset_clip);
PHP_FUNCTION(cairo_fill);
PHP_FUNCTION(cairo_fill_preserve);
PHP_FUNCTION(cairo_fill_extents);
PHP_FUNCTION(cairo_in_fill);
PHP_FUNCTION(cairo_mask);
PHP_FUNCTION(cairo_mask_surface);
PHP_FUNCTION(cairo_paint);
PHP_FUNCTION(cairo_paint_with_alpha);
PHP_FUNCTION(cairo_stroke);
PHP_FUNCTION(cairo_stroke_preserve);
PHP_FUNCTION(cairo_stroke_extents);
PHP_FUNCTION(cairo_in_stroke);
PHP_FUNCTION(cairo_copy_page);
PHP_FUNCTION(cairo_show_page);
/* Context Transformations */
PHP_FUNCTION(cairo_translate);
PHP_FUNCTION(cairo_scale);
PHP_FUNCTION(cairo_rotate);
PHP_FUNCTION(cairo_transform);
PHP_FUNCTION(cairo_set_matrix);
PHP_FUNCTION(cairo_get_matrix);
PHP_FUNCTION(cairo_identity_matrix);
PHP_FUNCTION(cairo_user_to_device);
PHP_FUNCTION(cairo_user_to_device_distance);
PHP_FUNCTION(cairo_device_to_user);
PHP_FUNCTION(cairo_device_to_user_distance);
/* Context and Paths */
PHP_FUNCTION(cairo_copy_path);
PHP_FUNCTION(cairo_copy_path_flat);
PHP_FUNCTION(cairo_append_path);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
PHP_FUNCTION(cairo_has_current_point);
#endif
PHP_FUNCTION(cairo_get_current_point);
PHP_FUNCTION(cairo_new_path);
PHP_FUNCTION(cairo_new_sub_path);
PHP_FUNCTION(cairo_close_path);
PHP_FUNCTION(cairo_arc);
PHP_FUNCTION(cairo_arc_negative);
PHP_FUNCTION(cairo_curve_to);
PHP_FUNCTION(cairo_line_to);
PHP_FUNCTION(cairo_move_to);
PHP_FUNCTION(cairo_rectangle);
PHP_FUNCTION(cairo_glyph_path);
PHP_FUNCTION(cairo_text_path);
PHP_FUNCTION(cairo_rel_curve_to);
PHP_FUNCTION(cairo_rel_line_to);
PHP_FUNCTION(cairo_rel_move_to);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
PHP_FUNCTION(cairo_path_extents);
#endif
/* Text Functions */
PHP_FUNCTION(cairo_select_font_face);
PHP_FUNCTION(cairo_set_font_size);
PHP_FUNCTION(cairo_set_font_matrix);
PHP_FUNCTION(cairo_get_font_matrix);
PHP_FUNCTION(cairo_set_font_options);
PHP_FUNCTION(cairo_get_font_options);
PHP_FUNCTION(cairo_set_font_face);
PHP_FUNCTION(cairo_get_font_face);
PHP_FUNCTION(cairo_set_scaled_font);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
PHP_FUNCTION(cairo_get_scaled_font);
#endif
PHP_FUNCTION(cairo_show_text);
PHP_FUNCTION(cairo_text_extents);
PHP_FUNCTION(cairo_font_extents);
/* Pattern Functions */
PHP_FUNCTION(cairo_pattern_get_type);
PHP_FUNCTION(cairo_pattern_status);
PHP_FUNCTION(cairo_pattern_get_matrix);
PHP_FUNCTION(cairo_pattern_set_matrix);
PHP_FUNCTION(cairo_pattern_create_rgb);
PHP_FUNCTION(cairo_pattern_create_rgba);
PHP_FUNCTION(cairo_pattern_create_for_surface);
PHP_FUNCTION(cairo_pattern_set_filter);
PHP_FUNCTION(cairo_pattern_get_filter);
PHP_FUNCTION(cairo_pattern_set_extend);
PHP_FUNCTION(cairo_pattern_get_extend);
PHP_FUNCTION(cairo_pattern_add_color_stop_rgb);
PHP_FUNCTION(cairo_pattern_add_color_stop_rgba);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
PHP_FUNCTION(cairo_pattern_get_color_stop_count);
PHP_FUNCTION(cairo_pattern_get_surface);
PHP_FUNCTION(cairo_pattern_get_linear_points);
PHP_FUNCTION(cairo_pattern_get_radial_circles);
PHP_FUNCTION(cairo_pattern_get_rgba);
PHP_FUNCTION(cairo_pattern_get_color_stop_rgba);
#endif
PHP_FUNCTION(cairo_pattern_create_linear);
PHP_FUNCTION(cairo_pattern_create_radial);
/* Matrix Functions */
PHP_FUNCTION(cairo_matrix_init);
PHP_FUNCTION(cairo_matrix_init_identity);
PHP_FUNCTION(cairo_matrix_init_translate);
PHP_FUNCTION(cairo_matrix_init_scale);
PHP_FUNCTION(cairo_matrix_init_rotate);
PHP_FUNCTION(cairo_matrix_translate);
PHP_FUNCTION(cairo_matrix_scale);
PHP_FUNCTION(cairo_matrix_rotate);
PHP_FUNCTION(cairo_matrix_invert);
PHP_FUNCTION(cairo_matrix_multiply);
PHP_FUNCTION(cairo_matrix_transform_distance);
PHP_FUNCTION(cairo_matrix_transform_point);
/* Font Options Functions */
PHP_FUNCTION(cairo_font_options_create);
PHP_FUNCTION(cairo_font_options_status);
PHP_FUNCTION(cairo_font_options_merge);
PHP_FUNCTION(cairo_font_options_hash);
PHP_FUNCTION(cairo_font_options_equal);
PHP_FUNCTION(cairo_font_options_set_antialias);
PHP_FUNCTION(cairo_font_options_get_antialias);
PHP_FUNCTION(cairo_font_options_set_subpixel_order);
PHP_FUNCTION(cairo_font_options_get_subpixel_order);
PHP_FUNCTION(cairo_font_options_set_hint_style);
PHP_FUNCTION(cairo_font_options_get_hint_style);
PHP_FUNCTION(cairo_font_options_set_hint_metrics);
PHP_FUNCTION(cairo_font_options_get_hint_metrics);
/* Font Face Functions */
PHP_FUNCTION(cairo_font_face_status);
PHP_FUNCTION(cairo_font_face_get_type);
/* Toy Font Face Functions */
PHP_FUNCTION(cairo_toy_font_face_create);
PHP_FUNCTION(cairo_toy_font_face_get_family);
PHP_FUNCTION(cairo_toy_font_face_get_weight);
PHP_FUNCTION(cairo_toy_font_face_get_slant);
/* Scaled Font Functiosn */
PHP_FUNCTION(cairo_scaled_font_create);
PHP_FUNCTION(cairo_scaled_font_status);
PHP_FUNCTION(cairo_scaled_font_extents);
PHP_FUNCTION(cairo_scaled_font_text_extents);
PHP_FUNCTION(cairo_scaled_font_glyph_extents);
PHP_FUNCTION(cairo_scaled_font_get_font_face);
PHP_FUNCTION(cairo_scaled_font_get_font_options);
PHP_FUNCTION(cairo_scaled_font_get_font_matrix);
PHP_FUNCTION(cairo_scaled_font_get_ctm);
PHP_FUNCTION(cairo_scaled_font_get_scale_matrix);
PHP_FUNCTION(cairo_scaled_font_get_type);
/* Generic Surface Functions */
PHP_FUNCTION(cairo_surface_create_similar);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
PHP_FUNCTION(cairo_surface_create_for_rectangle);
#endif
PHP_FUNCTION(cairo_surface_status);
PHP_FUNCTION(cairo_surface_finish);
PHP_FUNCTION(cairo_surface_flush);
PHP_FUNCTION(cairo_surface_get_font_options);
PHP_FUNCTION(cairo_surface_get_content);
PHP_FUNCTION(cairo_surface_mark_dirty);
PHP_FUNCTION(cairo_surface_mark_dirty_rectangle);
PHP_FUNCTION(cairo_surface_set_device_offset);
PHP_FUNCTION(cairo_surface_get_device_offset);
PHP_FUNCTION(cairo_surface_set_fallback_resolution);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
PHP_FUNCTION(cairo_surface_get_fallback_resolution);
#endif
PHP_FUNCTION(cairo_surface_get_type);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
PHP_FUNCTION(cairo_surface_copy_page);
PHP_FUNCTION(cairo_surface_show_page);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
PHP_FUNCTION(cairo_surface_has_show_text_glyphs);
#endif
/* Image Surface Functions */
PHP_FUNCTION(cairo_image_surface_create);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
PHP_FUNCTION(cairo_format_stride_for_width);
#endif
PHP_FUNCTION(cairo_image_surface_create_for_data);
PHP_FUNCTION(cairo_image_surface_get_data);
PHP_FUNCTION(cairo_image_surface_get_format);
PHP_FUNCTION(cairo_image_surface_get_width);
PHP_FUNCTION(cairo_image_surface_get_height);
PHP_FUNCTION(cairo_image_surface_get_stride);
/* PNG support Functions */
#ifdef CAIRO_HAS_PNG_FUNCTIONS
PHP_FUNCTION(cairo_image_surface_create_from_png);
PHP_FUNCTION(cairo_surface_write_to_png);
#endif
/* Font Face Functions */
PHP_FUNCTION(cairo_font_face_status);
PHP_FUNCTION(cairo_font_face_get_type);
#ifdef CAIRO_HAS_QUARTZ_FONT
PHP_FUNCTION(cairo_quartz_font_face_create_for_atsu_font_id);
PHP_FUNCTION(cairo_quartz_font_face_create_for_cgfont);
#endif
#if defined(CAIRO_HAS_FT_FONT) && defined(HAVE_FREETYPE)
PHP_FUNCTION(cairo_ft_font_face_create);
#endif
#if defined(CAIRO_HAS_WIN32_FONT) && defined(HAVE_WIN32_FONT)
PHP_FUNCTION(cairo_win32_font_face_create);
#endif
/* SVG Surface Functiosn */
#ifdef CAIRO_HAS_SVG_SURFACE
PHP_FUNCTION(cairo_svg_surface_create);
PHP_FUNCTION(cairo_svg_surface_restrict_to_version);
PHP_FUNCTION(cairo_svg_get_versions);
PHP_FUNCTION(cairo_svg_version_to_string);
#endif
/* PDF Surface Functions */
#ifdef CAIRO_HAS_PDF_SURFACE
PHP_FUNCTION(cairo_pdf_surface_create);
PHP_FUNCTION(cairo_pdf_surface_set_size);
#endif
/* PS Surface Functions */
#ifdef CAIRO_HAS_PS_SURFACE
PHP_FUNCTION(cairo_ps_surface_create);
PHP_FUNCTION(cairo_ps_surface_set_size);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
PHP_FUNCTION(cairo_ps_surface_restrict_to_level);
PHP_FUNCTION(cairo_ps_surface_set_eps);
PHP_FUNCTION(cairo_ps_surface_get_eps);
PHP_FUNCTION(cairo_ps_get_levels);
PHP_FUNCTION(cairo_ps_level_to_string);
#endif
PHP_FUNCTION(cairo_ps_surface_dsc_begin_setup);
PHP_FUNCTION(cairo_ps_surface_dsc_begin_page_setup);
PHP_FUNCTION(cairo_ps_surface_dsc_comment);
#endif
/* Recording surface functions */
#ifdef CAIRO_HAS_RECORDING_SURFACE
PHP_FUNCTION(cairo_recording_surface_create);
#endif
extern zend_object_handlers cairo_std_object_handlers;
extern zend_class_entry *cairo_ce_cairoexception;
extern zend_class_entry *cairo_ce_cairocontext;
extern zend_class_entry *cairo_ce_cairosurface;
extern zend_class_entry *cairo_ce_cairopattern;
extern zend_class_entry *cairo_ce_cairomatrix;
extern zend_class_entry *cairo_ce_cairopath;
extern zend_class_entry *cairo_ce_cairoimagesurface;
extern zend_class_entry *cairo_ce_cairosvgsurface;
extern zend_class_entry *cairo_ce_cairopdfsurface;
extern zend_class_entry *cairo_ce_cairopssurface;
extern zend_class_entry *cairo_ce_cairorecordingsurface;
extern zend_class_entry *cairo_ce_cairosubsurface;
extern zend_class_entry *cairo_ce_cairocontent;
extern zend_class_entry *cairo_ce_cairofontoptions;
extern zend_class_entry *cairo_ce_cairofontface;
extern zend_class_entry *cairo_ce_cairofonttype;
extern zend_class_entry *cairo_ce_cairofontslant;
extern zend_class_entry *cairo_ce_cairofontweight;
extern zend_class_entry *cairo_ce_cairotoyfontface;
extern zend_class_entry *cairo_ce_cairoscaledfont;
extern zend_class_entry *cairo_ce_cairoftfontface;
extern zend_object_value cairo_surface_object_new(zend_class_entry *ce TSRMLS_DC);
extern cairo_status_t php_cairo_read_func(void *closure, const unsigned char *data, unsigned int length);
extern cairo_status_t php_cairo_write_func(void *closure, const unsigned char *data, unsigned int length);
#if defined(CAIRO_HAS_FT_FONT) && defined(HAVE_FREETYPE)
static unsigned long php_cairo_ft_read_func(FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count);
extern void php_cairo_ft_close_stream(FT_Stream stream);
#endif
extern zend_object_value cairo_font_face_object_new(zend_class_entry *ce TSRMLS_DC);
/* Exported functions for PHP Cairo API */
PHP_CAIRO_API extern void php_cairo_throw_exception(cairo_status_t status TSRMLS_DC);
PHP_CAIRO_API extern void php_cairo_trigger_error(cairo_status_t status TSRMLS_DC);
PHP_CAIRO_API extern zend_class_entry* php_cairo_get_surface_ce(cairo_surface_t *surface TSRMLS_DC);
PHP_CAIRO_API extern zend_class_entry* php_cairo_get_pattern_ce(cairo_pattern_t *pattern TSRMLS_DC);
PHP_CAIRO_API extern zend_class_entry* php_cairo_get_context_ce();
PHP_CAIRO_API extern zend_class_entry* php_cairo_get_fontface_ce();
PHP_CAIRO_API extern zend_class_entry* php_cairo_get_fontoptions_ce();
PHP_CAIRO_API extern zend_class_entry* php_cairo_get_path_ce();
/* Wrapped internal cairo functionality to avoid having to link against cairo lib as well as this extension */
PHP_CAIRO_API extern cairo_font_options_t* php_cairo_font_options_copy(const cairo_font_options_t *);
PHP_CAIRO_API extern cairo_t * php_cairo_context_reference(cairo_t *context);
#define ALLOCATE_MATRIX(matrix_value) if (!matrix_value) { matrix_value = ecalloc(sizeof(cairo_matrix_t), 1); }
/* turn error handling to exception mode and restore */
#if PHP_VERSION_ID >= 50300
/* 5.3 version of the macros */
#define PHP_CAIRO_ERROR_HANDLING(force_exceptions) \
zend_error_handling error_handling; \
if(force_exceptions || getThis()) { \
zend_replace_error_handling(EH_THROW, cairo_ce_cairoexception, &error_handling TSRMLS_CC); \
}
#define PHP_CAIRO_RESTORE_ERRORS(force_exceptions) \
if(force_exceptions || getThis()) { \
zend_restore_error_handling(&error_handling TSRMLS_CC); \
}
#else
/* 5.2 versions of the macros */
#define PHP_CAIRO_ERROR_HANDLING(force_exceptions) \
if(force_exceptions || getThis()) { \
php_set_error_handling(EH_THROW, cairo_ce_cairoexception TSRMLS_CC); \
}
#define PHP_CAIRO_RESTORE_ERRORS(force_exceptions) \
if(force_exceptions || getThis()) { \
php_std_error_handling(); \
}
#endif
/* do error or exception based on "are we in method or in function" */
#define PHP_CAIRO_ERROR(status) \
if(!getThis()) { \
php_cairo_trigger_error(status TSRMLS_CC); \
} else { \
php_cairo_throw_exception(status TSRMLS_CC); \
}
/* a bunch of inline functions to deal with checking for the proper internal object, makes extending classes work */
static inline cairo_context_object* cairo_context_object_get(zval *zobj TSRMLS_DC)
{
cairo_context_object *pobj = zend_object_store_get_object(zobj TSRMLS_CC);
if (pobj->context == NULL) {
php_error(E_ERROR, "Internal context object missing in %s wrapper, you must call parent::__construct in extended classes", Z_OBJCE_P(zobj)->name);
}
return pobj;
}
static inline cairo_path_object* cairo_path_object_get(zval *zobj TSRMLS_DC)
{
cairo_path_object *pobj = zend_object_store_get_object(zobj TSRMLS_CC);
if (pobj->path == NULL) {
php_error(E_ERROR, "Internal path object missing in %s wrapper, you must call parent::__construct in extended classes", Z_OBJCE_P(zobj)->name);
}
return pobj;
}
static inline cairo_pattern_object* cairo_pattern_object_get(zval *zobj TSRMLS_DC)
{
cairo_pattern_object *pobj = zend_object_store_get_object(zobj TSRMLS_CC);
if (pobj->pattern == NULL) {
php_error(E_ERROR, "Internal pattern object missing in %s wrapper, you must call parent::__construct in extended classes", Z_OBJCE_P(zobj)->name);
}
return pobj;
}
static inline cairo_matrix_object* cairo_matrix_object_get(zval *zobj TSRMLS_DC)
{
cairo_matrix_object *mobj = zend_object_store_get_object(zobj TSRMLS_CC);
if (mobj->matrix == NULL) {
php_error(E_ERROR, "Internal matrix object missing in %s wrapper, you must call parent::__construct in extended classes", Z_OBJCE_P(zobj)->name);
}
return mobj;
}
static inline cairo_surface_object* cairo_surface_object_get(zval *zobj TSRMLS_DC)
{
cairo_surface_object *pobj = zend_object_store_get_object(zobj TSRMLS_CC);
if (pobj->surface == NULL) {
php_error(E_ERROR, "Internal surface object missing in %s wrapper, you must call parent::__construct in extended classes", Z_OBJCE_P(zobj)->name);
}
return pobj;
}
static inline cairo_font_face_object* cairo_font_face_object_get(zval *zobj TSRMLS_DC)
{
cairo_font_face_object *pobj = zend_object_store_get_object(zobj TSRMLS_CC);
if (pobj->font_face == NULL) {
php_error(E_ERROR, "Internal font face object missing in %s wrapper, you must call parent::__construct in extended classes", Z_OBJCE_P(zobj)->name);
}
return pobj;
}
static inline cairo_scaled_font_object* cairo_scaled_font_object_get(zval *zobj TSRMLS_DC)
{
cairo_scaled_font_object *pobj = zend_object_store_get_object(zobj TSRMLS_CC);
if (pobj->scaled_font == NULL) {
php_error(E_ERROR, "Internal scaled font object missing in %s wrapper, you must call parent::__construct in extended classes", Z_OBJCE_P(zobj)->name);
}
return pobj;
}
static inline cairo_font_options_object* cairo_font_options_object_get(zval *zobj TSRMLS_DC)
{
cairo_font_options_object *pobj = zend_object_store_get_object(zobj TSRMLS_CC);
if (pobj->font_options == NULL) {
php_error(E_ERROR, "Internal font options object missing in %s wrapper, you must call parent::__construct in extended classes", Z_OBJCE_P(zobj)->name);
}
return pobj;
}
#endif /* PHP_CAIRO_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/