diff options
| author | Dmitry Antipov | 2015-01-16 15:15:32 +0300 |
|---|---|---|
| committer | Dmitry Antipov | 2015-01-16 15:15:32 +0300 |
| commit | 4303d11029cf204cbf4ddf917ee0d37b08130570 (patch) | |
| tree | 5781c5e151aed74b7757a475de32190fdb58afcf | |
| parent | 7ee2733f1ecd3d4f2bd782aa802b090c77fbb135 (diff) | |
| download | emacs-4303d11029cf204cbf4ddf917ee0d37b08130570.tar.gz emacs-4303d11029cf204cbf4ddf917ee0d37b08130570.zip | |
Prefer INLINE functions in font.h to match style used in lisp.h
* font.h (FONTP, FONT_SPEC_P, FONT_ENTITY_P, FONT_OBJECT_P)
(CHECK_FONT, CHECK_FONT_SPEC, CHECK_FONT_ENTITY, CHECK_FONT_OBJECT)
(XFONT_SPEC, XFONT_ENTITY, XFONT_OBJECT, CHECK_FONT_GET_OBJECT):
Now functions.
* font.c (Ffont_otf_alternates, Fquery_font, Ffont_get_glyphs):
* ftfont.c (ftfont_shape):
* macfont.m (macfont_shape):
* w32uniscribe.c (uniscribe_shape):
* xftfont.c (xftfont_shape): Adjust CHECK_FONT_GET_OBJECT users.
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/font.c | 13 | ||||
| -rw-r--r-- | src/font.h | 113 | ||||
| -rw-r--r-- | src/ftfont.c | 9 | ||||
| -rw-r--r-- | src/macfont.m | 10 | ||||
| -rw-r--r-- | src/w32uniscribe.c | 8 | ||||
| -rw-r--r-- | src/xftfont.c | 6 |
7 files changed, 105 insertions, 65 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0601e5a5aed..16e2fa19626 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -18,6 +18,17 @@ | |||
| 18 | * lisp.h (XTERMINAL): Add eassert. | 18 | * lisp.h (XTERMINAL): Add eassert. |
| 19 | * process.c (make_lisp_proc): Now static here. | 19 | * process.c (make_lisp_proc): Now static here. |
| 20 | 20 | ||
| 21 | Prefer INLINE functions in font.h to match style used in lisp.h. | ||
| 22 | * font.h (FONTP, FONT_SPEC_P, FONT_ENTITY_P, FONT_OBJECT_P) | ||
| 23 | (CHECK_FONT, CHECK_FONT_SPEC, CHECK_FONT_ENTITY, CHECK_FONT_OBJECT) | ||
| 24 | (XFONT_SPEC, XFONT_ENTITY, XFONT_OBJECT, CHECK_FONT_GET_OBJECT): | ||
| 25 | Now functions. | ||
| 26 | * font.c (Ffont_otf_alternates, Fquery_font, Ffont_get_glyphs): | ||
| 27 | * ftfont.c (ftfont_shape): | ||
| 28 | * macfont.m (macfont_shape): | ||
| 29 | * w32uniscribe.c (uniscribe_shape): | ||
| 30 | * xftfont.c (xftfont_shape): Adjust CHECK_FONT_GET_OBJECT users. | ||
| 31 | |||
| 21 | 2015-01-16 Paul Eggert <eggert@cs.ucla.edu> | 32 | 2015-01-16 Paul Eggert <eggert@cs.ucla.edu> |
| 22 | 33 | ||
| 23 | Give up on -Wsuggest-attribute=const | 34 | Give up on -Wsuggest-attribute=const |
diff --git a/src/font.c b/src/font.c index 074e86687a1..56a27821718 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -4533,12 +4533,11 @@ character code corresponding to the glyph or nil if there's no | |||
| 4533 | corresponding character. */) | 4533 | corresponding character. */) |
| 4534 | (Lisp_Object font_object, Lisp_Object character, Lisp_Object otf_features) | 4534 | (Lisp_Object font_object, Lisp_Object character, Lisp_Object otf_features) |
| 4535 | { | 4535 | { |
| 4536 | struct font *font; | 4536 | struct font *font = CHECK_FONT_GET_OBJECT (font_object); |
| 4537 | Lisp_Object gstring_in, gstring_out, g; | 4537 | Lisp_Object gstring_in, gstring_out, g; |
| 4538 | Lisp_Object alternates; | 4538 | Lisp_Object alternates; |
| 4539 | int i, num; | 4539 | int i, num; |
| 4540 | 4540 | ||
| 4541 | CHECK_FONT_GET_OBJECT (font_object, font); | ||
| 4542 | if (! font->driver->otf_drive) | 4541 | if (! font->driver->otf_drive) |
| 4543 | error ("Font backend %s can't drive OpenType GSUB table", | 4542 | error ("Font backend %s can't drive OpenType GSUB table", |
| 4544 | SDATA (SYMBOL_NAME (font->driver->type))); | 4543 | SDATA (SYMBOL_NAME (font->driver->type))); |
| @@ -4648,12 +4647,9 @@ FEATURE is a symbol representing OpenType feature tag. | |||
| 4648 | If the font is not OpenType font, CAPABILITY is nil. */) | 4647 | If the font is not OpenType font, CAPABILITY is nil. */) |
| 4649 | (Lisp_Object font_object) | 4648 | (Lisp_Object font_object) |
| 4650 | { | 4649 | { |
| 4651 | struct font *font; | 4650 | struct font *font = CHECK_FONT_GET_OBJECT (font_object); |
| 4652 | Lisp_Object val; | 4651 | Lisp_Object val = make_uninit_vector (9); |
| 4653 | 4652 | ||
| 4654 | CHECK_FONT_GET_OBJECT (font_object, font); | ||
| 4655 | |||
| 4656 | val = make_uninit_vector (9); | ||
| 4657 | ASET (val, 0, AREF (font_object, FONT_NAME_INDEX)); | 4653 | ASET (val, 0, AREF (font_object, FONT_NAME_INDEX)); |
| 4658 | ASET (val, 1, AREF (font_object, FONT_FILE_INDEX)); | 4654 | ASET (val, 1, AREF (font_object, FONT_FILE_INDEX)); |
| 4659 | ASET (val, 2, make_number (font->pixel_size)); | 4655 | ASET (val, 2, make_number (font->pixel_size)); |
| @@ -4692,12 +4688,11 @@ the corresponding element is nil. */) | |||
| 4692 | (Lisp_Object font_object, Lisp_Object from, Lisp_Object to, | 4688 | (Lisp_Object font_object, Lisp_Object from, Lisp_Object to, |
| 4693 | Lisp_Object object) | 4689 | Lisp_Object object) |
| 4694 | { | 4690 | { |
| 4695 | struct font *font; | 4691 | struct font *font = CHECK_FONT_GET_OBJECT (font_object); |
| 4696 | ptrdiff_t i, len; | 4692 | ptrdiff_t i, len; |
| 4697 | Lisp_Object *chars, vec; | 4693 | Lisp_Object *chars, vec; |
| 4698 | USE_SAFE_ALLOCA; | 4694 | USE_SAFE_ALLOCA; |
| 4699 | 4695 | ||
| 4700 | CHECK_FONT_GET_OBJECT (font_object, font); | ||
| 4701 | if (NILP (object)) | 4696 | if (NILP (object)) |
| 4702 | { | 4697 | { |
| 4703 | ptrdiff_t charpos, bytepos; | 4698 | ptrdiff_t charpos, bytepos; |
diff --git a/src/font.h b/src/font.h index 5a3e38a2a6e..efc184eef77 100644 --- a/src/font.h +++ b/src/font.h | |||
| @@ -413,46 +413,91 @@ struct font_bitmap | |||
| 413 | /* Predicates to check various font-related objects. */ | 413 | /* Predicates to check various font-related objects. */ |
| 414 | 414 | ||
| 415 | /* True iff X is one of font-spec, font-entity, and font-object. */ | 415 | /* True iff X is one of font-spec, font-entity, and font-object. */ |
| 416 | #define FONTP(x) PSEUDOVECTORP (x, PVEC_FONT) | 416 | INLINE bool |
| 417 | FONTP (Lisp_Object x) | ||
| 418 | { | ||
| 419 | return PSEUDOVECTORP (x, PVEC_FONT); | ||
| 420 | } | ||
| 421 | |||
| 417 | /* True iff X is font-spec. */ | 422 | /* True iff X is font-spec. */ |
| 418 | #define FONT_SPEC_P(x) \ | 423 | INLINE bool |
| 419 | (FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_SPEC_MAX) | 424 | FONT_SPEC_P (Lisp_Object x) |
| 425 | { | ||
| 426 | return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_SPEC_MAX; | ||
| 427 | } | ||
| 428 | |||
| 420 | /* True iff X is font-entity. */ | 429 | /* True iff X is font-entity. */ |
| 421 | #define FONT_ENTITY_P(x) \ | 430 | INLINE bool |
| 422 | (FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_ENTITY_MAX) | 431 | FONT_ENTITY_P (Lisp_Object x) |
| 432 | { | ||
| 433 | return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_ENTITY_MAX; | ||
| 434 | } | ||
| 435 | |||
| 423 | /* True iff X is font-object. */ | 436 | /* True iff X is font-object. */ |
| 424 | #define FONT_OBJECT_P(x) \ | 437 | INLINE bool |
| 425 | (FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_OBJECT_MAX) | 438 | FONT_OBJECT_P (Lisp_Object x) |
| 426 | 439 | { | |
| 427 | /* Check macros for various font-related objects. */ | 440 | return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_OBJECT_MAX; |
| 428 | 441 | } | |
| 429 | #define CHECK_FONT(x) \ | 442 | |
| 430 | do { if (! FONTP (x)) wrong_type_argument (Qfont, x); } while (false) | 443 | /* Type checking functions for various font-related objects. */ |
| 431 | #define CHECK_FONT_SPEC(x) \ | 444 | |
| 432 | do { if (! FONT_SPEC_P (x)) wrong_type_argument (Qfont_spec, x); } \ | 445 | INLINE void |
| 433 | while (false) | 446 | CHECK_FONT (Lisp_Object x) |
| 434 | #define CHECK_FONT_ENTITY(x) \ | 447 | { |
| 435 | do { if (! FONT_ENTITY_P (x)) wrong_type_argument (Qfont_entity, x); } \ | 448 | CHECK_TYPE (FONTP (x), Qfont, x); |
| 436 | while (false) | 449 | } |
| 437 | #define CHECK_FONT_OBJECT(x) \ | 450 | |
| 438 | do { if (! FONT_OBJECT_P (x)) wrong_type_argument (Qfont_object, x); } \ | 451 | INLINE void |
| 439 | while (false) | 452 | CHECK_FONT_SPEC (Lisp_Object x) |
| 440 | 453 | { | |
| 441 | #define CHECK_FONT_GET_OBJECT(x, font) \ | 454 | CHECK_TYPE (FONT_SPEC_P (x), Qfont_spec, x); |
| 442 | do { \ | 455 | } |
| 443 | CHECK_FONT_OBJECT (x); \ | 456 | |
| 444 | font = XFONT_OBJECT (x); \ | 457 | INLINE void |
| 445 | } while (false) | 458 | CHECK_FONT_ENTITY (Lisp_Object x) |
| 459 | { | ||
| 460 | CHECK_TYPE (FONT_ENTITY_P (x), Qfont_entity, x); | ||
| 461 | } | ||
| 462 | |||
| 463 | INLINE void | ||
| 464 | CHECK_FONT_OBJECT (Lisp_Object x) | ||
| 465 | { | ||
| 466 | CHECK_TYPE (FONT_OBJECT_P (x), Qfont_object, x); | ||
| 467 | } | ||
| 468 | |||
| 469 | /* C pointer extraction functions for various font-related objects. */ | ||
| 470 | |||
| 471 | INLINE struct font_spec * | ||
| 472 | XFONT_SPEC (Lisp_Object p) | ||
| 473 | { | ||
| 474 | eassert (FONT_SPEC_P (p)); | ||
| 475 | return XUNTAG (p, Lisp_Vectorlike); | ||
| 476 | } | ||
| 477 | |||
| 478 | INLINE struct font_entity * | ||
| 479 | XFONT_ENTITY (Lisp_Object p) | ||
| 480 | { | ||
| 481 | eassert (FONT_ENTITY_P (p)); | ||
| 482 | return XUNTAG (p, Lisp_Vectorlike); | ||
| 483 | } | ||
| 484 | |||
| 485 | INLINE struct font * | ||
| 486 | XFONT_OBJECT (Lisp_Object p) | ||
| 487 | { | ||
| 488 | eassert (FONT_OBJECT_P (p)); | ||
| 489 | return XUNTAG (p, Lisp_Vectorlike); | ||
| 490 | } | ||
| 446 | 491 | ||
| 447 | #define XFONT_SPEC(p) \ | ||
| 448 | (eassert (FONT_SPEC_P (p)), (struct font_spec *) XUNTAG (p, Lisp_Vectorlike)) | ||
| 449 | #define XFONT_ENTITY(p) \ | ||
| 450 | (eassert (FONT_ENTITY_P (p)), \ | ||
| 451 | (struct font_entity *) XUNTAG (p, Lisp_Vectorlike)) | ||
| 452 | #define XFONT_OBJECT(p) \ | ||
| 453 | (eassert (FONT_OBJECT_P (p)), (struct font *) XUNTAG (p, Lisp_Vectorlike)) | ||
| 454 | #define XSETFONT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FONT)) | 492 | #define XSETFONT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FONT)) |
| 455 | 493 | ||
| 494 | INLINE struct font * | ||
| 495 | CHECK_FONT_GET_OBJECT (Lisp_Object x) | ||
| 496 | { | ||
| 497 | CHECK_FONT_OBJECT (x); | ||
| 498 | return XFONT_OBJECT (x); | ||
| 499 | } | ||
| 500 | |||
| 456 | /* Number of pt per inch (from the TeXbook). */ | 501 | /* Number of pt per inch (from the TeXbook). */ |
| 457 | #define PT_PER_INCH 72.27 | 502 | #define PT_PER_INCH 72.27 |
| 458 | 503 | ||
diff --git a/src/ftfont.c b/src/ftfont.c index 9707b6c1b71..053b95fc69f 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -2576,13 +2576,10 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, | |||
| 2576 | Lisp_Object | 2576 | Lisp_Object |
| 2577 | ftfont_shape (Lisp_Object lgstring) | 2577 | ftfont_shape (Lisp_Object lgstring) |
| 2578 | { | 2578 | { |
| 2579 | struct font *font; | 2579 | struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring)); |
| 2580 | struct ftfont_info *ftfont_info; | 2580 | struct ftfont_info *ftfont_info = (struct ftfont_info *) font; |
| 2581 | OTF *otf; | 2581 | OTF *otf = ftfont_get_otf (ftfont_info); |
| 2582 | 2582 | ||
| 2583 | CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font); | ||
| 2584 | ftfont_info = (struct ftfont_info *) font; | ||
| 2585 | otf = ftfont_get_otf (ftfont_info); | ||
| 2586 | if (! otf) | 2583 | if (! otf) |
| 2587 | return make_number (0); | 2584 | return make_number (0); |
| 2588 | return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf, | 2585 | return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf, |
diff --git a/src/macfont.m b/src/macfont.m index f569934128f..cbf1b07bc94 100644 --- a/src/macfont.m +++ b/src/macfont.m | |||
| @@ -2788,9 +2788,9 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 2788 | static Lisp_Object | 2788 | static Lisp_Object |
| 2789 | macfont_shape (Lisp_Object lgstring) | 2789 | macfont_shape (Lisp_Object lgstring) |
| 2790 | { | 2790 | { |
| 2791 | struct font *font; | 2791 | struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring)); |
| 2792 | struct macfont_info *macfont_info; | 2792 | struct macfont_info *macfont_info = (struct macfont_info *) font; |
| 2793 | FontRef macfont; | 2793 | FontRef macfont = macfont_info->macfont; |
| 2794 | ptrdiff_t glyph_len, len, i, j; | 2794 | ptrdiff_t glyph_len, len, i, j; |
| 2795 | CFIndex nonbmp_len; | 2795 | CFIndex nonbmp_len; |
| 2796 | UniChar *unichars; | 2796 | UniChar *unichars; |
| @@ -2799,10 +2799,6 @@ macfont_shape (Lisp_Object lgstring) | |||
| 2799 | CFIndex used = 0; | 2799 | CFIndex used = 0; |
| 2800 | struct mac_glyph_layout *glyph_layouts; | 2800 | struct mac_glyph_layout *glyph_layouts; |
| 2801 | 2801 | ||
| 2802 | CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font); | ||
| 2803 | macfont_info = (struct macfont_info *) font; | ||
| 2804 | macfont = macfont_info->macfont; | ||
| 2805 | |||
| 2806 | glyph_len = LGSTRING_GLYPH_LEN (lgstring); | 2802 | glyph_len = LGSTRING_GLYPH_LEN (lgstring); |
| 2807 | nonbmp_len = 0; | 2803 | nonbmp_len = 0; |
| 2808 | for (i = 0; i < glyph_len; i++) | 2804 | for (i = 0; i < glyph_len; i++) |
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c index 2a7fe2e6f91..9cd97e28616 100644 --- a/src/w32uniscribe.c +++ b/src/w32uniscribe.c | |||
| @@ -183,8 +183,9 @@ uniscribe_otf_capability (struct font *font) | |||
| 183 | static Lisp_Object | 183 | static Lisp_Object |
| 184 | uniscribe_shape (Lisp_Object lgstring) | 184 | uniscribe_shape (Lisp_Object lgstring) |
| 185 | { | 185 | { |
| 186 | struct font * font; | 186 | struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring)); |
| 187 | struct uniscribe_font_info * uniscribe_font; | 187 | struct uniscribe_font_info *uniscribe_font |
| 188 | = (struct uniscribe_font_info *) font; | ||
| 188 | EMACS_UINT nchars; | 189 | EMACS_UINT nchars; |
| 189 | int nitems, max_items, i, max_glyphs, done_glyphs; | 190 | int nitems, max_items, i, max_glyphs, done_glyphs; |
| 190 | wchar_t *chars; | 191 | wchar_t *chars; |
| @@ -199,9 +200,6 @@ uniscribe_shape (Lisp_Object lgstring) | |||
| 199 | HDC context = NULL; | 200 | HDC context = NULL; |
| 200 | HFONT old_font = NULL; | 201 | HFONT old_font = NULL; |
| 201 | 202 | ||
| 202 | CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font); | ||
| 203 | uniscribe_font = (struct uniscribe_font_info *) font; | ||
| 204 | |||
| 205 | /* Get the chars from lgstring in a form we can use with uniscribe. */ | 203 | /* Get the chars from lgstring in a form we can use with uniscribe. */ |
| 206 | max_glyphs = nchars = LGSTRING_GLYPH_LEN (lgstring); | 204 | max_glyphs = nchars = LGSTRING_GLYPH_LEN (lgstring); |
| 207 | done_glyphs = 0; | 205 | done_glyphs = 0; |
diff --git a/src/xftfont.c b/src/xftfont.c index c587d814efa..054b38e120f 100644 --- a/src/xftfont.c +++ b/src/xftfont.c | |||
| @@ -640,13 +640,11 @@ xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 640 | static Lisp_Object | 640 | static Lisp_Object |
| 641 | xftfont_shape (Lisp_Object lgstring) | 641 | xftfont_shape (Lisp_Object lgstring) |
| 642 | { | 642 | { |
| 643 | struct font *font; | 643 | struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring)); |
| 644 | struct xftfont_info *xftfont_info; | 644 | struct xftfont_info *xftfont_info = (struct xftfont_info *) font; |
| 645 | FT_Face ft_face; | 645 | FT_Face ft_face; |
| 646 | Lisp_Object val; | 646 | Lisp_Object val; |
| 647 | 647 | ||
| 648 | CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font); | ||
| 649 | xftfont_info = (struct xftfont_info *) font; | ||
| 650 | ft_face = XftLockFace (xftfont_info->xftfont); | 648 | ft_face = XftLockFace (xftfont_info->xftfont); |
| 651 | xftfont_info->ft_size = ft_face->size; | 649 | xftfont_info->ft_size = ft_face->size; |
| 652 | val = ftfont_driver.shape (lgstring); | 650 | val = ftfont_driver.shape (lgstring); |