]> git.eshelyaron.com Git - emacs.git/commitdiff
Prefer INLINE functions in font.h to match style used in lisp.h
authorDmitry Antipov <dmantipov@yandex.ru>
Fri, 16 Jan 2015 12:15:32 +0000 (15:15 +0300)
committerDmitry Antipov <dmantipov@yandex.ru>
Fri, 16 Jan 2015 12:15:32 +0000 (15:15 +0300)
* 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
src/font.c
src/font.h
src/ftfont.c
src/macfont.m
src/w32uniscribe.c
src/xftfont.c

index 0601e5a5aeda6c13c10d62da3e105e7f7c60bed0..16e2fa196266ba12fc039f8ae9b07b2452d09563 100644 (file)
        * 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  <eggert@cs.ucla.edu>
 
        Give up on -Wsuggest-attribute=const
index 074e86687a11d12fb78dbdd0f08ef3336a3d6800..56a27821718c3e7820ef339ded38cd3f4d694e67 100644 (file)
@@ -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;
index 5a3e38a2a6e3ec6c8558934c592035865087cd9d..efc184eef77bcb8e1f0afdf4aa595ecbac2ccb54 100644 (file)
@@ -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
 
index 9707b6c1b71214f9c63c2aff4a9a3f8bd287c0fe..053b95fc69f9375b6cdca5ef9092f5f6f23fad06 100644 (file)
@@ -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,
index f569934128f3e76b2660fcf65c3d75f38a1de2c0..cbf1b07bc94370c8db11b9b40f0487f430a3ca9e 100644 (file)
@@ -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++)
index 2a7fe2e6f91618ee8d687116d02f5dd89908d299..9cd97e28616c0fab21e1399f07ab39febd682568 100644 (file)
@@ -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;
index c587d814efa103bd8cfbecac090b19f8197dae98..054b38e120fb18131242b386a721354861e42843 100644 (file)
@@ -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);