OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2012 Google, Inc. | 2 * Copyright © 2012 Google, Inc. |
3 * | 3 * |
4 * This is part of HarfBuzz, a text shaping library. | 4 * This is part of HarfBuzz, a text shaping library. |
5 * | 5 * |
6 * Permission is hereby granted, without written agreement and without | 6 * Permission is hereby granted, without written agreement and without |
7 * license or royalty fees, to use, copy, modify, and distribute this | 7 * license or royalty fees, to use, copy, modify, and distribute this |
8 * software and its documentation for any purpose, provided that the | 8 * software and its documentation for any purpose, provided that the |
9 * above copyright notice and the following two paragraphs appear in | 9 * above copyright notice and the following two paragraphs appear in |
10 * all copies of this software. | 10 * all copies of this software. |
(...skipping 12 matching lines...) Expand all Loading... |
23 * | 23 * |
24 * Google Author(s): Behdad Esfahbod | 24 * Google Author(s): Behdad Esfahbod |
25 */ | 25 */ |
26 | 26 |
27 #include "hb-set-private.hh" | 27 #include "hb-set-private.hh" |
28 | 28 |
29 | 29 |
30 /* Public API */ | 30 /* Public API */ |
31 | 31 |
32 | 32 |
| 33 /** |
| 34 * hb_set_create: (Xconstructor) |
| 35 * |
| 36 * Return value: (transfer full): |
| 37 * |
| 38 * Since: 1.0 |
| 39 **/ |
33 hb_set_t * | 40 hb_set_t * |
34 hb_set_create (void) | 41 hb_set_create (void) |
35 { | 42 { |
36 hb_set_t *set; | 43 hb_set_t *set; |
37 | 44 |
38 if (!(set = hb_object_create<hb_set_t> ())) | 45 if (!(set = hb_object_create<hb_set_t> ())) |
39 return hb_set_get_empty (); | 46 return hb_set_get_empty (); |
40 | 47 |
41 set->clear (); | 48 set->clear (); |
42 | 49 |
43 return set; | 50 return set; |
44 } | 51 } |
45 | 52 |
| 53 /** |
| 54 * hb_set_get_empty: |
| 55 * |
| 56 * Return value: (transfer full): |
| 57 * |
| 58 * Since: 1.0 |
| 59 **/ |
46 hb_set_t * | 60 hb_set_t * |
47 hb_set_get_empty (void) | 61 hb_set_get_empty (void) |
48 { | 62 { |
49 static const hb_set_t _hb_set_nil = { | 63 static const hb_set_t _hb_set_nil = { |
50 HB_OBJECT_HEADER_STATIC, | 64 HB_OBJECT_HEADER_STATIC, |
51 true, /* in_error */ | 65 true, /* in_error */ |
52 | 66 |
53 {0} /* elts */ | 67 {0} /* elts */ |
54 }; | 68 }; |
55 | 69 |
56 return const_cast<hb_set_t *> (&_hb_set_nil); | 70 return const_cast<hb_set_t *> (&_hb_set_nil); |
57 } | 71 } |
58 | 72 |
| 73 /** |
| 74 * hb_set_reference: (skip) |
| 75 * @set: a set. |
| 76 * |
| 77 * Return value: (transfer full): |
| 78 * |
| 79 * Since: 1.0 |
| 80 **/ |
59 hb_set_t * | 81 hb_set_t * |
60 hb_set_reference (hb_set_t *set) | 82 hb_set_reference (hb_set_t *set) |
61 { | 83 { |
62 return hb_object_reference (set); | 84 return hb_object_reference (set); |
63 } | 85 } |
64 | 86 |
| 87 /** |
| 88 * hb_set_destroy: (skip) |
| 89 * @set: a set. |
| 90 * |
| 91 * Since: 1.0 |
| 92 **/ |
65 void | 93 void |
66 hb_set_destroy (hb_set_t *set) | 94 hb_set_destroy (hb_set_t *set) |
67 { | 95 { |
68 if (!hb_object_destroy (set)) return; | 96 if (!hb_object_destroy (set)) return; |
69 | 97 |
70 set->fini (); | 98 set->fini (); |
71 | 99 |
72 free (set); | 100 free (set); |
73 } | 101 } |
74 | 102 |
| 103 /** |
| 104 * hb_set_set_user_data: (skip) |
| 105 * @set: a set. |
| 106 * @key: |
| 107 * @data: |
| 108 * @destroy (closure data): |
| 109 * @replace: |
| 110 * |
| 111 * Return value: |
| 112 * |
| 113 * Since: 1.0 |
| 114 **/ |
75 hb_bool_t | 115 hb_bool_t |
76 hb_set_set_user_data (hb_set_t *set, | 116 hb_set_set_user_data (hb_set_t *set, |
77 hb_user_data_key_t *key, | 117 hb_user_data_key_t *key, |
78 void * data, | 118 void * data, |
79 hb_destroy_func_t destroy, | 119 hb_destroy_func_t destroy, |
80 hb_bool_t replace) | 120 hb_bool_t replace) |
81 { | 121 { |
82 return hb_object_set_user_data (set, key, data, destroy, replace); | 122 return hb_object_set_user_data (set, key, data, destroy, replace); |
83 } | 123 } |
84 | 124 |
| 125 /** |
| 126 * hb_set_get_user_data: (skip) |
| 127 * @set: a set. |
| 128 * @key: |
| 129 * |
| 130 * Return value: (transfer none): |
| 131 * |
| 132 * Since: 1.0 |
| 133 **/ |
85 void * | 134 void * |
86 hb_set_get_user_data (hb_set_t *set, | 135 hb_set_get_user_data (hb_set_t *set, |
87 hb_user_data_key_t *key) | 136 hb_user_data_key_t *key) |
88 { | 137 { |
89 return hb_object_get_user_data (set, key); | 138 return hb_object_get_user_data (set, key); |
90 } | 139 } |
91 | 140 |
92 | 141 |
| 142 /** |
| 143 * hb_set_allocation_successful: |
| 144 * @set: a set. |
| 145 * |
| 146 * |
| 147 * |
| 148 * Return value: |
| 149 * |
| 150 * Since: 1.0 |
| 151 **/ |
93 hb_bool_t | 152 hb_bool_t |
94 hb_set_allocation_successful (const hb_set_t *set HB_UNUSED) | 153 hb_set_allocation_successful (const hb_set_t *set HB_UNUSED) |
95 { | 154 { |
96 return !set->in_error; | 155 return !set->in_error; |
97 } | 156 } |
98 | 157 |
| 158 /** |
| 159 * hb_set_clear: |
| 160 * @set: a set. |
| 161 * |
| 162 * |
| 163 * |
| 164 * Since: 1.0 |
| 165 **/ |
99 void | 166 void |
100 hb_set_clear (hb_set_t *set) | 167 hb_set_clear (hb_set_t *set) |
101 { | 168 { |
102 set->clear (); | 169 set->clear (); |
103 } | 170 } |
104 | 171 |
| 172 /** |
| 173 * hb_set_is_empty: |
| 174 * @set: a set. |
| 175 * |
| 176 * |
| 177 * |
| 178 * Return value: |
| 179 * |
| 180 * Since: 1.0 |
| 181 **/ |
105 hb_bool_t | 182 hb_bool_t |
106 hb_set_is_empty (const hb_set_t *set) | 183 hb_set_is_empty (const hb_set_t *set) |
107 { | 184 { |
108 return set->is_empty (); | 185 return set->is_empty (); |
109 } | 186 } |
110 | 187 |
| 188 /** |
| 189 * hb_set_has: |
| 190 * @set: a set. |
| 191 * @codepoint: |
| 192 * |
| 193 * |
| 194 * |
| 195 * Return value: |
| 196 * |
| 197 * Since: 1.0 |
| 198 **/ |
111 hb_bool_t | 199 hb_bool_t |
112 hb_set_has (const hb_set_t *set, | 200 hb_set_has (const hb_set_t *set, |
113 hb_codepoint_t codepoint) | 201 hb_codepoint_t codepoint) |
114 { | 202 { |
115 return set->has (codepoint); | 203 return set->has (codepoint); |
116 } | 204 } |
117 | 205 |
| 206 /** |
| 207 * hb_set_add: |
| 208 * @set: a set. |
| 209 * @codepoint: |
| 210 * |
| 211 * |
| 212 * |
| 213 * Since: 1.0 |
| 214 **/ |
118 void | 215 void |
119 hb_set_add (hb_set_t *set, | 216 hb_set_add (hb_set_t *set, |
120 hb_codepoint_t codepoint) | 217 hb_codepoint_t codepoint) |
121 { | 218 { |
122 set->add (codepoint); | 219 set->add (codepoint); |
123 } | 220 } |
124 | 221 |
| 222 /** |
| 223 * hb_set_add_range: |
| 224 * @set: a set. |
| 225 * @first: |
| 226 * @last: |
| 227 * |
| 228 * |
| 229 * |
| 230 * Since: 1.0 |
| 231 **/ |
125 void | 232 void |
126 hb_set_add_range (hb_set_t *set, | 233 hb_set_add_range (hb_set_t *set, |
127 hb_codepoint_t first, | 234 hb_codepoint_t first, |
128 hb_codepoint_t last) | 235 hb_codepoint_t last) |
129 { | 236 { |
130 set->add_range (first, last); | 237 set->add_range (first, last); |
131 } | 238 } |
132 | 239 |
| 240 /** |
| 241 * hb_set_del: |
| 242 * @set: a set. |
| 243 * @codepoint: |
| 244 * |
| 245 * |
| 246 * |
| 247 * Since: 1.0 |
| 248 **/ |
133 void | 249 void |
134 hb_set_del (hb_set_t *set, | 250 hb_set_del (hb_set_t *set, |
135 hb_codepoint_t codepoint) | 251 hb_codepoint_t codepoint) |
136 { | 252 { |
137 set->del (codepoint); | 253 set->del (codepoint); |
138 } | 254 } |
139 | 255 |
| 256 /** |
| 257 * hb_set_del_range: |
| 258 * @set: a set. |
| 259 * @first: |
| 260 * @last: |
| 261 * |
| 262 * |
| 263 * |
| 264 * Since: 1.0 |
| 265 **/ |
140 void | 266 void |
141 hb_set_del_range (hb_set_t *set, | 267 hb_set_del_range (hb_set_t *set, |
142 hb_codepoint_t first, | 268 hb_codepoint_t first, |
143 hb_codepoint_t last) | 269 hb_codepoint_t last) |
144 { | 270 { |
145 set->del_range (first, last); | 271 set->del_range (first, last); |
146 } | 272 } |
147 | 273 |
| 274 /** |
| 275 * hb_set_is_equal: |
| 276 * @set: a set. |
| 277 * @other: |
| 278 * |
| 279 * |
| 280 * |
| 281 * Return value: |
| 282 * |
| 283 * Since: 1.0 |
| 284 **/ |
148 hb_bool_t | 285 hb_bool_t |
149 hb_set_is_equal (const hb_set_t *set, | 286 hb_set_is_equal (const hb_set_t *set, |
150 const hb_set_t *other) | 287 const hb_set_t *other) |
151 { | 288 { |
152 return set->is_equal (other); | 289 return set->is_equal (other); |
153 } | 290 } |
154 | 291 |
| 292 /** |
| 293 * hb_set_set: |
| 294 * @set: a set. |
| 295 * @other: |
| 296 * |
| 297 * |
| 298 * |
| 299 * Since: 1.0 |
| 300 **/ |
155 void | 301 void |
156 hb_set_set (hb_set_t *set, | 302 hb_set_set (hb_set_t *set, |
157 const hb_set_t *other) | 303 const hb_set_t *other) |
158 { | 304 { |
159 set->set (other); | 305 set->set (other); |
160 } | 306 } |
161 | 307 |
| 308 /** |
| 309 * hb_set_union: |
| 310 * @set: a set. |
| 311 * @other: |
| 312 * |
| 313 * |
| 314 * |
| 315 * Since: 1.0 |
| 316 **/ |
162 void | 317 void |
163 hb_set_union (hb_set_t *set, | 318 hb_set_union (hb_set_t *set, |
164 const hb_set_t *other) | 319 const hb_set_t *other) |
165 { | 320 { |
166 set->union_ (other); | 321 set->union_ (other); |
167 } | 322 } |
168 | 323 |
| 324 /** |
| 325 * hb_set_intersect: |
| 326 * @set: a set. |
| 327 * @other: |
| 328 * |
| 329 * |
| 330 * |
| 331 * Since: 1.0 |
| 332 **/ |
169 void | 333 void |
170 hb_set_intersect (hb_set_t *set, | 334 hb_set_intersect (hb_set_t *set, |
171 const hb_set_t *other) | 335 const hb_set_t *other) |
172 { | 336 { |
173 set->intersect (other); | 337 set->intersect (other); |
174 } | 338 } |
175 | 339 |
| 340 /** |
| 341 * hb_set_subtract: |
| 342 * @set: a set. |
| 343 * @other: |
| 344 * |
| 345 * |
| 346 * |
| 347 * Since: 1.0 |
| 348 **/ |
176 void | 349 void |
177 hb_set_subtract (hb_set_t *set, | 350 hb_set_subtract (hb_set_t *set, |
178 const hb_set_t *other) | 351 const hb_set_t *other) |
179 { | 352 { |
180 set->subtract (other); | 353 set->subtract (other); |
181 } | 354 } |
182 | 355 |
| 356 /** |
| 357 * hb_set_symmetric_difference: |
| 358 * @set: a set. |
| 359 * @other: |
| 360 * |
| 361 * |
| 362 * |
| 363 * Since: 1.0 |
| 364 **/ |
183 void | 365 void |
184 hb_set_symmetric_difference (hb_set_t *set, | 366 hb_set_symmetric_difference (hb_set_t *set, |
185 const hb_set_t *other) | 367 const hb_set_t *other) |
186 { | 368 { |
187 set->symmetric_difference (other); | 369 set->symmetric_difference (other); |
188 } | 370 } |
189 | 371 |
| 372 /** |
| 373 * hb_set_invert: |
| 374 * @set: a set. |
| 375 * |
| 376 * |
| 377 * |
| 378 * Since: 1.0 |
| 379 **/ |
190 void | 380 void |
191 hb_set_invert (hb_set_t *set) | 381 hb_set_invert (hb_set_t *set) |
192 { | 382 { |
193 set->invert (); | 383 set->invert (); |
194 } | 384 } |
195 | 385 |
| 386 /** |
| 387 * hb_set_get_population: |
| 388 * @set: a set. |
| 389 * |
| 390 * Returns the number of numbers in the set. |
| 391 * |
| 392 * Return value: set population. |
| 393 * |
| 394 * Since: 1.0 |
| 395 **/ |
196 unsigned int | 396 unsigned int |
197 hb_set_get_population (const hb_set_t *set) | 397 hb_set_get_population (const hb_set_t *set) |
198 { | 398 { |
199 return set->get_population (); | 399 return set->get_population (); |
200 } | 400 } |
201 | 401 |
| 402 /** |
| 403 * hb_set_get_min: |
| 404 * @set: a set. |
| 405 * |
| 406 * Finds the minimum number in the set. |
| 407 * |
| 408 * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty. |
| 409 * |
| 410 * Since: 1.0 |
| 411 **/ |
202 hb_codepoint_t | 412 hb_codepoint_t |
203 hb_set_get_min (const hb_set_t *set) | 413 hb_set_get_min (const hb_set_t *set) |
204 { | 414 { |
205 return set->get_min (); | 415 return set->get_min (); |
206 } | 416 } |
207 | 417 |
| 418 /** |
| 419 * hb_set_get_max: |
| 420 * @set: a set. |
| 421 * |
| 422 * Finds the maximum number in the set. |
| 423 * |
| 424 * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty. |
| 425 * |
| 426 * Since: 1.0 |
| 427 **/ |
208 hb_codepoint_t | 428 hb_codepoint_t |
209 hb_set_get_max (const hb_set_t *set) | 429 hb_set_get_max (const hb_set_t *set) |
210 { | 430 { |
211 return set->get_max (); | 431 return set->get_max (); |
212 } | 432 } |
213 | 433 |
| 434 /** |
| 435 * hb_set_next: |
| 436 * @set: a set. |
| 437 * @codepoint: (inout): |
| 438 * |
| 439 * |
| 440 * |
| 441 * Return value: whether there was a next value. |
| 442 * |
| 443 * Since: 1.0 |
| 444 **/ |
214 hb_bool_t | 445 hb_bool_t |
215 hb_set_next (const hb_set_t *set, | 446 hb_set_next (const hb_set_t *set, |
216 hb_codepoint_t *codepoint) | 447 hb_codepoint_t *codepoint) |
217 { | 448 { |
218 return set->next (codepoint); | 449 return set->next (codepoint); |
219 } | 450 } |
220 | 451 |
| 452 /** |
| 453 * hb_set_next_range: |
| 454 * @set: a set. |
| 455 * @first: (out): output first codepoint in the range. |
| 456 * @last: (inout): input current last and output last codepoint in the range. |
| 457 * |
| 458 * Gets the next consecutive range of numbers in @set that |
| 459 * are greater than current value of @last. |
| 460 * |
| 461 * Return value: whether there was a next range. |
| 462 * |
| 463 * Since: 1.0 |
| 464 **/ |
221 hb_bool_t | 465 hb_bool_t |
222 hb_set_next_range (const hb_set_t *set, | 466 hb_set_next_range (const hb_set_t *set, |
223 hb_codepoint_t *first, | 467 hb_codepoint_t *first, |
224 hb_codepoint_t *last) | 468 hb_codepoint_t *last) |
225 { | 469 { |
226 return set->next_range (first, last); | 470 return set->next_range (first, last); |
227 } | 471 } |
OLD | NEW |