emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 4303d11: Prefer INLINE functions in font.h to match


From: Dmitry Antipov
Subject: [Emacs-diffs] master 4303d11: Prefer INLINE functions in font.h to match style used in lisp.h
Date: Fri, 16 Jan 2015 12:16:40 +0000

branch: master
commit 4303d11029cf204cbf4ddf917ee0d37b08130570
Author: Dmitry Antipov <address@hidden>
Commit: Dmitry Antipov <address@hidden>

    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.
---
 src/ChangeLog      |   11 +++++
 src/font.c         |   13 ++----
 src/font.h         |  115 ++++++++++++++++++++++++++++++++++++----------------
 src/ftfont.c       |    9 +---
 src/macfont.m      |   10 +---
 src/w32uniscribe.c |    8 +--
 src/xftfont.c      |    6 +--
 7 files changed, 106 insertions(+), 66 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 0601e5a..16e2fa1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -18,6 +18,17 @@
        * lisp.h (XTERMINAL): Add eassert.
        * process.c (make_lisp_proc): Now static here.
 
+       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.
+
 2015-01-16  Paul Eggert  <address@hidden>
 
        Give up on -Wsuggest-attribute=const
diff --git a/src/font.c b/src/font.c
index 074e866..56a2782 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
 corresponding character.  */)
   (Lisp_Object font_object, Lisp_Object character, Lisp_Object otf_features)
 {
-  struct font *font;
+  struct font *font = CHECK_FONT_GET_OBJECT (font_object);
   Lisp_Object gstring_in, gstring_out, g;
   Lisp_Object alternates;
   int i, num;
 
-  CHECK_FONT_GET_OBJECT (font_object, font);
   if (! font->driver->otf_drive)
     error ("Font backend %s can't drive OpenType GSUB table",
           SDATA (SYMBOL_NAME (font->driver->type)));
@@ -4648,12 +4647,9 @@ FEATURE is a symbol representing OpenType feature tag.
 If the font is not OpenType font, CAPABILITY is nil.  */)
   (Lisp_Object font_object)
 {
-  struct font *font;
-  Lisp_Object val;
+  struct font *font = CHECK_FONT_GET_OBJECT (font_object);
+  Lisp_Object val = make_uninit_vector (9);
 
-  CHECK_FONT_GET_OBJECT (font_object, font);
-
-  val = make_uninit_vector (9);
   ASET (val, 0, AREF (font_object, FONT_NAME_INDEX));
   ASET (val, 1, AREF (font_object, FONT_FILE_INDEX));
   ASET (val, 2, make_number (font->pixel_size));
@@ -4692,12 +4688,11 @@ the corresponding element is nil.  */)
   (Lisp_Object font_object, Lisp_Object from, Lisp_Object to,
    Lisp_Object object)
 {
-  struct font *font;
+  struct font *font = CHECK_FONT_GET_OBJECT (font_object);
   ptrdiff_t i, len;
   Lisp_Object *chars, vec;
   USE_SAFE_ALLOCA;
 
-  CHECK_FONT_GET_OBJECT (font_object, font);
   if (NILP (object))
     {
       ptrdiff_t charpos, bytepos;
diff --git a/src/font.h b/src/font.h
index 5a3e38a..efc184e 100644
--- a/src/font.h
+++ b/src/font.h
@@ -413,46 +413,91 @@ struct font_bitmap
 /* Predicates to check various font-related objects.  */
 
 /* True iff X is one of font-spec, font-entity, and font-object.  */
-#define FONTP(x) PSEUDOVECTORP (x, PVEC_FONT)
+INLINE bool
+FONTP (Lisp_Object x)
+{
+  return PSEUDOVECTORP (x, PVEC_FONT);
+}
+
 /* True iff X is font-spec.  */
-#define FONT_SPEC_P(x) \
-  (FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_SPEC_MAX)
+INLINE bool
+FONT_SPEC_P (Lisp_Object x)
+{
+  return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_SPEC_MAX;
+}
+
 /* True iff X is font-entity.  */
-#define FONT_ENTITY_P(x)       \
-  (FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_ENTITY_MAX)
+INLINE bool
+FONT_ENTITY_P (Lisp_Object x)
+{
+  return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_ENTITY_MAX;
+}
+
 /* True iff X is font-object.  */
-#define FONT_OBJECT_P(x)       \
-  (FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_OBJECT_MAX)
-
-/* Check macros for various font-related objects.  */
-
-#define CHECK_FONT(x)  \
-  do { if (! FONTP (x)) wrong_type_argument (Qfont, x); } while (false)
-#define CHECK_FONT_SPEC(x)     \
-  do { if (! FONT_SPEC_P (x)) wrong_type_argument (Qfont_spec, x); } \
-  while (false)
-#define CHECK_FONT_ENTITY(x)   \
-  do { if (! FONT_ENTITY_P (x)) wrong_type_argument (Qfont_entity, x); } \
-  while (false)
-#define CHECK_FONT_OBJECT(x)   \
-  do { if (! FONT_OBJECT_P (x)) wrong_type_argument (Qfont_object, x); } \
-  while (false)
-
-#define CHECK_FONT_GET_OBJECT(x, font) \
-  do {                                 \
-    CHECK_FONT_OBJECT (x);             \
-    font = XFONT_OBJECT (x);           \
-  } while (false)
+INLINE bool
+FONT_OBJECT_P (Lisp_Object x)
+{
+  return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_OBJECT_MAX;
+}
+
+/* Type checking functions for various font-related objects.  */
+
+INLINE void
+CHECK_FONT (Lisp_Object x)
+{
+  CHECK_TYPE (FONTP (x), Qfont, x);
+}
+
+INLINE void
+CHECK_FONT_SPEC (Lisp_Object x)
+{
+  CHECK_TYPE (FONT_SPEC_P (x), Qfont_spec, x);
+}
+
+INLINE void
+CHECK_FONT_ENTITY (Lisp_Object x)
+{
+  CHECK_TYPE (FONT_ENTITY_P (x), Qfont_entity, x);
+}
+
+INLINE void
+CHECK_FONT_OBJECT (Lisp_Object x)
+{
+  CHECK_TYPE (FONT_OBJECT_P (x), Qfont_object, x);
+}
+
+/* C pointer extraction functions for various font-related objects.  */
+
+INLINE struct font_spec *
+XFONT_SPEC (Lisp_Object p)
+{
+  eassert (FONT_SPEC_P (p));
+  return XUNTAG (p, Lisp_Vectorlike);
+}
+
+INLINE struct font_entity *
+XFONT_ENTITY (Lisp_Object p)
+{
+  eassert (FONT_ENTITY_P (p));
+  return XUNTAG (p, Lisp_Vectorlike);
+}
+
+INLINE struct font *
+XFONT_OBJECT (Lisp_Object p)
+{
+  eassert (FONT_OBJECT_P (p));
+  return XUNTAG (p, Lisp_Vectorlike);
+}
 
-#define XFONT_SPEC(p)  \
-  (eassert (FONT_SPEC_P (p)), (struct font_spec *) XUNTAG (p, Lisp_Vectorlike))
-#define XFONT_ENTITY(p)        \
-  (eassert (FONT_ENTITY_P (p)), \
-   (struct font_entity *) XUNTAG (p, Lisp_Vectorlike))
-#define XFONT_OBJECT(p)        \
-  (eassert (FONT_OBJECT_P (p)), (struct font *) XUNTAG (p, Lisp_Vectorlike))
 #define XSETFONT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FONT))
 
+INLINE struct font *
+CHECK_FONT_GET_OBJECT (Lisp_Object x)
+{
+  CHECK_FONT_OBJECT (x);
+  return XFONT_OBJECT (x);
+}
+
 /* Number of pt per inch (from the TeXbook).  */
 #define PT_PER_INCH 72.27
 
diff --git a/src/ftfont.c b/src/ftfont.c
index 9707b6c..053b95f 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -2576,13 +2576,10 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font 
*font,
 Lisp_Object
 ftfont_shape (Lisp_Object lgstring)
 {
-  struct font *font;
-  struct ftfont_info *ftfont_info;
-  OTF *otf;
+  struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring));
+  struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
+  OTF *otf = ftfont_get_otf (ftfont_info);
 
-  CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font);
-  ftfont_info = (struct ftfont_info *) font;
-  otf = ftfont_get_otf (ftfont_info);
   if (! otf)
     return make_number (0);
   return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf,
diff --git a/src/macfont.m b/src/macfont.m
index f569934..cbf1b07 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,
 static Lisp_Object
 macfont_shape (Lisp_Object lgstring)
 {
-  struct font *font;
-  struct macfont_info *macfont_info;
-  FontRef macfont;
+  struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring));
+  struct macfont_info *macfont_info = (struct macfont_info *) font;
+  FontRef macfont = macfont_info->macfont;
   ptrdiff_t glyph_len, len, i, j;
   CFIndex nonbmp_len;
   UniChar *unichars;
@@ -2799,10 +2799,6 @@ macfont_shape (Lisp_Object lgstring)
   CFIndex used = 0;
   struct mac_glyph_layout *glyph_layouts;
 
-  CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font);
-  macfont_info = (struct macfont_info *) font;
-  macfont = macfont_info->macfont;
-
   glyph_len = LGSTRING_GLYPH_LEN (lgstring);
   nonbmp_len = 0;
   for (i = 0; i < glyph_len; i++)
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c
index 2a7fe2e..9cd97e2 100644
--- a/src/w32uniscribe.c
+++ b/src/w32uniscribe.c
@@ -183,8 +183,9 @@ uniscribe_otf_capability (struct font *font)
 static Lisp_Object
 uniscribe_shape (Lisp_Object lgstring)
 {
-  struct font * font;
-  struct uniscribe_font_info * uniscribe_font;
+  struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring));
+  struct uniscribe_font_info *uniscribe_font
+    = (struct uniscribe_font_info *) font;
   EMACS_UINT nchars;
   int nitems, max_items, i, max_glyphs, done_glyphs;
   wchar_t *chars;
@@ -199,9 +200,6 @@ uniscribe_shape (Lisp_Object lgstring)
   HDC context = NULL;
   HFONT old_font = NULL;
 
-  CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font);
-  uniscribe_font = (struct uniscribe_font_info *) font;
-
   /* Get the chars from lgstring in a form we can use with uniscribe.  */
   max_glyphs = nchars = LGSTRING_GLYPH_LEN (lgstring);
   done_glyphs = 0;
diff --git a/src/xftfont.c b/src/xftfont.c
index c587d81..054b38e 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,
 static Lisp_Object
 xftfont_shape (Lisp_Object lgstring)
 {
-  struct font *font;
-  struct xftfont_info *xftfont_info;
+  struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring));
+  struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
   FT_Face ft_face;
   Lisp_Object val;
 
-  CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font);
-  xftfont_info = (struct xftfont_info *) font;
   ft_face = XftLockFace (xftfont_info->xftfont);
   xftfont_info->ft_size = ft_face->size;
   val = ftfont_driver.shape (lgstring);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]