Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: third_party/harfbuzz-ng/src/hb-blob.cc

Issue 1408003004: Roll harfbuzz-ng to 1.0.5 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2526
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/harfbuzz-ng/README.chromium ('k') | third_party/harfbuzz-ng/src/hb-buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright © 2009 Red Hat, Inc. 2 * Copyright © 2009 Red Hat, 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 * @mode: Memory mode for @data. 84 * @mode: Memory mode for @data.
85 * @user_data: Data parameter to pass to @destroy. 85 * @user_data: Data parameter to pass to @destroy.
86 * @destroy: Callback to call when @data is not needed anymore. 86 * @destroy: Callback to call when @data is not needed anymore.
87 * 87 *
88 * Creates a new "blob" object wrapping @data. The @mode parameter is used 88 * Creates a new "blob" object wrapping @data. The @mode parameter is used
89 * to negotiate ownership and lifecycle of @data. 89 * to negotiate ownership and lifecycle of @data.
90 * 90 *
91 * Return value: New blob, or the empty blob if something failed or if @length i s 91 * Return value: New blob, or the empty blob if something failed or if @length i s
92 * zero. Destroy with hb_blob_destroy(). 92 * zero. Destroy with hb_blob_destroy().
93 * 93 *
94 * Since: 1.0 94 * Since: 0.9.2
95 **/ 95 **/
96 hb_blob_t * 96 hb_blob_t *
97 hb_blob_create (const char *data, 97 hb_blob_create (const char *data,
98 unsigned int length, 98 unsigned int length,
99 hb_memory_mode_t mode, 99 hb_memory_mode_t mode,
100 void *user_data, 100 void *user_data,
101 hb_destroy_func_t destroy) 101 hb_destroy_func_t destroy)
102 { 102 {
103 hb_blob_t *blob; 103 hb_blob_t *blob;
104 104
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 * will never modify data in the parent blob. The parent data is not 140 * will never modify data in the parent blob. The parent data is not
141 * expected to be modified, and will result in undefined behavior if it 141 * expected to be modified, and will result in undefined behavior if it
142 * is. 142 * is.
143 * 143 *
144 * Makes @parent immutable. 144 * Makes @parent immutable.
145 * 145 *
146 * Return value: New blob, or the empty blob if something failed or if 146 * Return value: New blob, or the empty blob if something failed or if
147 * @length is zero or @offset is beyond the end of @parent's data. Destroy 147 * @length is zero or @offset is beyond the end of @parent's data. Destroy
148 * with hb_blob_destroy(). 148 * with hb_blob_destroy().
149 * 149 *
150 * Since: 1.0 150 * Since: 0.9.2
151 **/ 151 **/
152 hb_blob_t * 152 hb_blob_t *
153 hb_blob_create_sub_blob (hb_blob_t *parent, 153 hb_blob_create_sub_blob (hb_blob_t *parent,
154 unsigned int offset, 154 unsigned int offset,
155 unsigned int length) 155 unsigned int length)
156 { 156 {
157 hb_blob_t *blob; 157 hb_blob_t *blob;
158 158
159 if (!length || offset >= parent->length) 159 if (!length || offset >= parent->length)
160 return hb_blob_get_empty (); 160 return hb_blob_get_empty ();
(...skipping 11 matching lines...) Expand all
172 172
173 /** 173 /**
174 * hb_blob_get_empty: 174 * hb_blob_get_empty:
175 * 175 *
176 * Returns the singleton empty blob. 176 * Returns the singleton empty blob.
177 * 177 *
178 * See TODO:link object types for more information. 178 * See TODO:link object types for more information.
179 * 179 *
180 * Return value: (transfer full): the empty blob. 180 * Return value: (transfer full): the empty blob.
181 * 181 *
182 * Since: 1.0 182 * Since: 0.9.2
183 **/ 183 **/
184 hb_blob_t * 184 hb_blob_t *
185 hb_blob_get_empty (void) 185 hb_blob_get_empty (void)
186 { 186 {
187 static const hb_blob_t _hb_blob_nil = { 187 static const hb_blob_t _hb_blob_nil = {
188 HB_OBJECT_HEADER_STATIC, 188 HB_OBJECT_HEADER_STATIC,
189 189
190 true, /* immutable */ 190 true, /* immutable */
191 191
192 NULL, /* data */ 192 NULL, /* data */
(...skipping 10 matching lines...) Expand all
203 /** 203 /**
204 * hb_blob_reference: (skip) 204 * hb_blob_reference: (skip)
205 * @blob: a blob. 205 * @blob: a blob.
206 * 206 *
207 * Increases the reference count on @blob. 207 * Increases the reference count on @blob.
208 * 208 *
209 * See TODO:link object types for more information. 209 * See TODO:link object types for more information.
210 * 210 *
211 * Return value: @blob. 211 * Return value: @blob.
212 * 212 *
213 * Since: 1.0 213 * Since: 0.9.2
214 **/ 214 **/
215 hb_blob_t * 215 hb_blob_t *
216 hb_blob_reference (hb_blob_t *blob) 216 hb_blob_reference (hb_blob_t *blob)
217 { 217 {
218 return hb_object_reference (blob); 218 return hb_object_reference (blob);
219 } 219 }
220 220
221 /** 221 /**
222 * hb_blob_destroy: (skip) 222 * hb_blob_destroy: (skip)
223 * @blob: a blob. 223 * @blob: a blob.
224 * 224 *
225 * Descreases the reference count on @blob, and if it reaches zero, destroys 225 * Descreases the reference count on @blob, and if it reaches zero, destroys
226 * @blob, freeing all memory, possibly calling the destroy-callback the blob 226 * @blob, freeing all memory, possibly calling the destroy-callback the blob
227 * was created for if it has not been called already. 227 * was created for if it has not been called already.
228 * 228 *
229 * See TODO:link object types for more information. 229 * See TODO:link object types for more information.
230 * 230 *
231 * Since: 1.0 231 * Since: 0.9.2
232 **/ 232 **/
233 void 233 void
234 hb_blob_destroy (hb_blob_t *blob) 234 hb_blob_destroy (hb_blob_t *blob)
235 { 235 {
236 if (!hb_object_destroy (blob)) return; 236 if (!hb_object_destroy (blob)) return;
237 237
238 _hb_blob_destroy_user_data (blob); 238 _hb_blob_destroy_user_data (blob);
239 239
240 free (blob); 240 free (blob);
241 } 241 }
242 242
243 /** 243 /**
244 * hb_blob_set_user_data: (skip) 244 * hb_blob_set_user_data: (skip)
245 * @blob: a blob. 245 * @blob: a blob.
246 * @key: key for data to set. 246 * @key: key for data to set.
247 * @data: data to set. 247 * @data: data to set.
248 * @destroy: callback to call when @data is not needed anymore. 248 * @destroy: callback to call when @data is not needed anymore.
249 * @replace: whether to replace an existing data with the same key. 249 * @replace: whether to replace an existing data with the same key.
250 * 250 *
251 * Return value: 251 * Return value:
252 * 252 *
253 * Since: 1.0 253 * Since: 0.9.2
254 **/ 254 **/
255 hb_bool_t 255 hb_bool_t
256 hb_blob_set_user_data (hb_blob_t *blob, 256 hb_blob_set_user_data (hb_blob_t *blob,
257 hb_user_data_key_t *key, 257 hb_user_data_key_t *key,
258 void * data, 258 void * data,
259 hb_destroy_func_t destroy, 259 hb_destroy_func_t destroy,
260 hb_bool_t replace) 260 hb_bool_t replace)
261 { 261 {
262 return hb_object_set_user_data (blob, key, data, destroy, replace); 262 return hb_object_set_user_data (blob, key, data, destroy, replace);
263 } 263 }
264 264
265 /** 265 /**
266 * hb_blob_get_user_data: (skip) 266 * hb_blob_get_user_data: (skip)
267 * @blob: a blob. 267 * @blob: a blob.
268 * @key: key for data to get. 268 * @key: key for data to get.
269 * 269 *
270 * 270 *
271 * 271 *
272 * Return value: (transfer none): 272 * Return value: (transfer none):
273 * 273 *
274 * Since: 1.0 274 * Since: 0.9.2
275 **/ 275 **/
276 void * 276 void *
277 hb_blob_get_user_data (hb_blob_t *blob, 277 hb_blob_get_user_data (hb_blob_t *blob,
278 hb_user_data_key_t *key) 278 hb_user_data_key_t *key)
279 { 279 {
280 return hb_object_get_user_data (blob, key); 280 return hb_object_get_user_data (blob, key);
281 } 281 }
282 282
283 283
284 /** 284 /**
285 * hb_blob_make_immutable: 285 * hb_blob_make_immutable:
286 * @blob: a blob. 286 * @blob: a blob.
287 * 287 *
288 * 288 *
289 * 289 *
290 * Since: 1.0 290 * Since: 0.9.2
291 **/ 291 **/
292 void 292 void
293 hb_blob_make_immutable (hb_blob_t *blob) 293 hb_blob_make_immutable (hb_blob_t *blob)
294 { 294 {
295 if (hb_object_is_inert (blob)) 295 if (hb_object_is_inert (blob))
296 return; 296 return;
297 297
298 blob->immutable = true; 298 blob->immutable = true;
299 } 299 }
300 300
301 /** 301 /**
302 * hb_blob_is_immutable: 302 * hb_blob_is_immutable:
303 * @blob: a blob. 303 * @blob: a blob.
304 * 304 *
305 * 305 *
306 * 306 *
307 * Return value: TODO 307 * Return value: TODO
308 * 308 *
309 * Since: 1.0 309 * Since: 0.9.2
310 **/ 310 **/
311 hb_bool_t 311 hb_bool_t
312 hb_blob_is_immutable (hb_blob_t *blob) 312 hb_blob_is_immutable (hb_blob_t *blob)
313 { 313 {
314 return blob->immutable; 314 return blob->immutable;
315 } 315 }
316 316
317 317
318 /** 318 /**
319 * hb_blob_get_length: 319 * hb_blob_get_length:
320 * @blob: a blob. 320 * @blob: a blob.
321 * 321 *
322 * 322 *
323 * 323 *
324 * Return value: the length of blob data in bytes. 324 * Return value: the length of blob data in bytes.
325 * 325 *
326 * Since: 1.0 326 * Since: 0.9.2
327 **/ 327 **/
328 unsigned int 328 unsigned int
329 hb_blob_get_length (hb_blob_t *blob) 329 hb_blob_get_length (hb_blob_t *blob)
330 { 330 {
331 return blob->length; 331 return blob->length;
332 } 332 }
333 333
334 /** 334 /**
335 * hb_blob_get_data: 335 * hb_blob_get_data:
336 * @blob: a blob. 336 * @blob: a blob.
337 * @length: (out): 337 * @length: (out):
338 * 338 *
339 * 339 *
340 * 340 *
341 * Returns: (transfer none) (array length=length): 341 * Returns: (transfer none) (array length=length):
342 * 342 *
343 * Since: 1.0 343 * Since: 0.9.2
344 **/ 344 **/
345 const char * 345 const char *
346 hb_blob_get_data (hb_blob_t *blob, unsigned int *length) 346 hb_blob_get_data (hb_blob_t *blob, unsigned int *length)
347 { 347 {
348 if (length) 348 if (length)
349 *length = blob->length; 349 *length = blob->length;
350 350
351 return blob->data; 351 return blob->data;
352 } 352 }
353 353
354 /** 354 /**
355 * hb_blob_get_data_writable: 355 * hb_blob_get_data_writable:
356 * @blob: a blob. 356 * @blob: a blob.
357 * @length: (out): output length of the writable data. 357 * @length: (out): output length of the writable data.
358 * 358 *
359 * Tries to make blob data writable (possibly copying it) and 359 * Tries to make blob data writable (possibly copying it) and
360 * return pointer to data. 360 * return pointer to data.
361 * 361 *
362 * Fails if blob has been made immutable, or if memory allocation 362 * Fails if blob has been made immutable, or if memory allocation
363 * fails. 363 * fails.
364 * 364 *
365 * Returns: (transfer none) (array length=length): Writable blob data, 365 * Returns: (transfer none) (array length=length): Writable blob data,
366 * or %NULL if failed. 366 * or %NULL if failed.
367 * 367 *
368 * Since: 1.0 368 * Since: 0.9.2
369 **/ 369 **/
370 char * 370 char *
371 hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length) 371 hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length)
372 { 372 {
373 if (!_try_writable (blob)) { 373 if (!_try_writable (blob)) {
374 if (length) 374 if (length)
375 *length = 0; 375 *length = 0;
376 376
377 return NULL; 377 return NULL;
378 } 378 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 470
471 memcpy (new_data, blob->data, blob->length); 471 memcpy (new_data, blob->data, blob->length);
472 _hb_blob_destroy_user_data (blob); 472 _hb_blob_destroy_user_data (blob);
473 blob->mode = HB_MEMORY_MODE_WRITABLE; 473 blob->mode = HB_MEMORY_MODE_WRITABLE;
474 blob->data = new_data; 474 blob->data = new_data;
475 blob->user_data = new_data; 475 blob->user_data = new_data;
476 blob->destroy = free; 476 blob->destroy = free;
477 477
478 return true; 478 return true;
479 } 479 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/README.chromium ('k') | third_party/harfbuzz-ng/src/hb-buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698