Cairo: changed build.io to make the addon compile on my machine
[io/quag.git] / addons / Cairo / source / IoCairoFontExtents.c
blob00fb436fd111079a6e19569c92d03cc8c315c7b6
1 /*#io
2 Cairo ioDoc(
3 docCopyright("Trevor Fancher", 2007)
4 docLicense("BSD revised")
5 docObject("Cairo")
6 docDescription("Cairo is a 2D graphics library. http://cairographics.org/")
7 docCategory("Graphics")
8 */
10 #include "IoCairoFontExtents.h"
11 #include "IoNumber.h"
13 #define DATA(self) ((IoCairoFontExtentsData *)IoObject_dataPointer(self))
14 #define FONTEXTENTS(ctx) (DATA(ctx))
16 IoTag *IoCairoFontExtents_newTag(void *state)
18 IoTag *tag = IoTag_newWithName_("CairoFontExtents");
19 IoTag_state_(tag, state);
20 IoTag_cloneFunc_(tag, (IoTagCloneFunc *)IoCairoFontExtents_rawClone);
21 IoTag_freeFunc_(tag, (IoTagFreeFunc *)IoCairoFontExtents_free);
22 IoTag_markFunc_(tag, (IoTagMarkFunc *)IoCairoFontExtents_mark);
23 return tag;
26 IoCairoFontExtents *IoCairoFontExtents_proto(void *state)
28 IoObject *self = IoObject_new(state);
29 IoObject_tag_(self, IoCairoFontExtents_newTag(state));
31 IoObject_setDataPointer_(self, calloc(1, sizeof(IoCairoFontExtentsData)));
33 IoState_registerProtoWithFunc_(state, self, IoCairoFontExtents_proto);
36 IoMethodTable methodTable[] = {
37 {"ascent", IoCairoFontExtents_ascent},
38 {"descent", IoCairoFontExtents_descent},
39 {"height", IoCairoFontExtents_height},
40 {"maxXAdvance", IoCairoFontExtents_maxXAdvance},
41 {"maxYAdvance", IoCairoFontExtents_maxYAdvance},
42 {NULL, NULL},
44 IoObject_addMethodTable_(self, methodTable);
46 return self;
49 IoCairoFontExtents *IoCairoFontExtents_rawClone(IoCairoFontExtents *proto)
51 IoObject *self = IoObject_rawClonePrimitive(proto);
52 IoObject_setDataPointer_(self, cpalloc(IoObject_dataPointer(proto), sizeof(IoCairoFontExtentsData)));
53 return self;
56 IoCairoFontExtents *IoCairoFontExtents_newWithRawFontExtents(void *state, cairo_font_extents_t *te)
58 IoObject *proto = IoState_protoWithInitFunction_(state, IoCairoFontExtents_proto);
59 IoObject *self = IoObject_rawClonePrimitive(proto);
60 IoObject_setDataPointer_(self, cpalloc(te, sizeof(IoCairoFontExtentsData)));
61 return self;
64 /* ----------------------------------------------------------- */
66 void IoCairoFontExtents_free(IoCairoFontExtents *self)
68 free(IoObject_dataPointer(self));
71 void IoCairoFontExtents_mark(IoCairoFontExtents *self)
75 cairo_font_extents_t *IoCairoFontExtents_getRawFontExtents(IoCairoFontExtents *self)
77 return FONTEXTENTS(self);
80 /* ----------------------------------------------------------- */
82 #define IoCairoFontExtents_make_get_func(funName, dataName) \
83 IoObject *IoCairoFontExtents_ ## funName (IoCairoFontExtents *self, IoObject *locals, IoMessage *m) \
84 { \
85 return IONUMBER(DATA(self)->dataName); \
88 IoCairoFontExtents_make_get_func(ascent, ascent)
89 IoCairoFontExtents_make_get_func(descent, descent)
90 IoCairoFontExtents_make_get_func(height, height)
91 IoCairoFontExtents_make_get_func(maxXAdvance, max_x_advance)
92 IoCairoFontExtents_make_get_func(maxYAdvance, max_y_advance)
94 #undef IoCairoFontExtents_make_get_func