3 docCopyright("Daniel Rosengren", 2007)
4 docLicense("BSD revised")
5 docCategory("Graphics")
8 #include "IoCairoGlyph.h"
11 #define GLYPH(self) ((cairo_glyph_t *)IoObject_dataPointer(self))
14 static IoTag
*IoCairoGlyph_newTag(void *state
)
16 IoTag
*tag
= IoTag_newWithName_("CairoGlyph");
17 IoTag_state_(tag
, state
);
18 IoTag_cloneFunc_(tag
, (IoTagCloneFunc
*)IoCairoGlyph_rawClone
);
19 IoTag_freeFunc_(tag
, (IoTagFreeFunc
*)IoCairoGlyph_free
);
23 IoCairoGlyph
*IoCairoGlyph_proto(void *state
)
25 IoObject
*self
= IoObject_new(state
);
26 IoObject_tag_(self
, IoCairoGlyph_newTag(state
));
28 IoObject_setDataPointer_(self
, calloc(1, sizeof(cairo_glyph_t
)));
30 IoState_registerProtoWithFunc_(state
, self
, IoCairoGlyph_proto
);
33 IoMethodTable methodTable
[] = {
34 {"setIndex", IoCairoGlyph_setIndex
},
35 {"index", IoCairoGlyph_index
},
37 {"setX", IoCairoGlyph_setX
},
38 {"x", IoCairoGlyph_x
},
40 {"setY", IoCairoGlyph_setY
},
41 {"y", IoCairoGlyph_y
},
45 IoObject_addMethodTable_(self
, methodTable
);
50 IoCairoGlyph
*IoCairoGlyph_rawClone(IoCairoGlyph
*proto
)
52 IoObject
*self
= IoObject_rawClonePrimitive(proto
);
53 IoObject_setDataPointer_(self
, cpalloc(IoObject_dataPointer(proto
), sizeof(cairo_glyph_t
)));
57 IoCairoGlyph
*IoCairoGlyph_newWithRawGlyph_(void *state
, cairo_glyph_t
*glyph
)
59 IoCairoGlyph
*self
= IOCLONE(IoState_protoWithInitFunction_(state
, IoCairoGlyph_proto
));
60 memcpy(GLYPH(self
), glyph
, sizeof(cairo_glyph_t
));
64 void IoCairoGlyph_free(IoCairoGlyph
*self
)
66 free(IoObject_dataPointer(self
));
70 cairo_glyph_t
*IoCairoGlyph_rawGlyph(IoCairoGlyph
*self
)
76 /* ------------------------------------------------------------------------------------------------*/
78 IoObject
*IoCairoGlyph_setIndex(IoCairoGlyph
*self
, IoObject
*locals
, IoMessage
*m
)
80 GLYPH(self
)->index
= IoMessage_locals_intArgAt_(m
, locals
, 0);
84 IoObject
*IoCairoGlyph_index(IoCairoGlyph
*self
, IoObject
*locals
, IoMessage
*m
)
86 return IONUMBER(GLYPH(self
)->index
);
90 IoObject
*IoCairoGlyph_setX(IoCairoGlyph
*self
, IoObject
*locals
, IoMessage
*m
)
92 GLYPH(self
)->x
= IoMessage_locals_doubleArgAt_(m
, locals
, 1);
96 IoObject
*IoCairoGlyph_x(IoCairoGlyph
*self
, IoObject
*locals
, IoMessage
*m
)
98 return IONUMBER(GLYPH(self
)->x
);
102 IoObject
*IoCairoGlyph_setY(IoCairoGlyph
*self
, IoObject
*locals
, IoMessage
*m
)
104 GLYPH(self
)->y
= IoMessage_locals_doubleArgAt_(m
, locals
, 2);
108 IoObject
*IoCairoGlyph_y(IoCairoGlyph
*self
, IoObject
*locals
, IoMessage
*m
)
110 return IONUMBER(GLYPH(self
)->y
);
114 /* ------------------------------------------------------------------------------------------------*/
116 cairo_glyph_t
*rawGlyphsFromList_count_(IoList
*glyphList
, int *count
)
118 int glyphCount
= IoList_rawSize(glyphList
);
119 cairo_glyph_t
*glyphs
= 0;
128 glyphs
= malloc(sizeof(cairo_glyph_t
) * glyphCount
);
129 for (i
= 0; i
< glyphCount
; i
++)
131 cairo_glyph_t
*glyph
= IoCairoGlyph_rawGlyph(IoList_rawAt_(glyphList
, i
));
132 memcpy(glyphs
+ i
, glyph
, sizeof(cairo_glyph_t
));