summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2023-01-11 21:18:36 -0500
committerMatthias Clasen <mclasen@redhat.com>2023-01-12 00:11:10 -0500
commit0f7d8e04d82d8c7ab31d9261ef856cfc07b8cfec (patch)
tree27beb247130182f8639d4965b6961c9c7ecea1b8
parentc9fca559dc01cc47e4194c6cdd291517979141d1 (diff)
downloadgtk+-0f7d8e04d82d8c7ab31d9261ef856cfc07b8cfec.tar.gz
css: Some inlining
-rw-r--r--gtk/css/gtkcsslocation.c72
-rw-r--r--gtk/css/gtkcsslocationprivate.h34
-rw-r--r--gtk/css/gtkcsstokenizer.c16
-rw-r--r--gtk/css/meson.build1
4 files changed, 35 insertions, 88 deletions
diff --git a/gtk/css/gtkcsslocation.c b/gtk/css/gtkcsslocation.c
deleted file mode 100644
index 41725ad2fe..0000000000
--- a/gtk/css/gtkcsslocation.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* GSK - The GIMP Toolkit
- * Copyright (C) 2019 Benjamin Otte <otte@gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gtkcsslocationprivate.h"
-
-/**
- * GtkCssLocation:
- * @bytes: number of bytes parsed since the beginning
- * @chars: number of characters parsed since the beginning
- * @lines: number of full lines that have been parsed. If you want to
- * display this as a line number, you need to add 1 to this.
- * @line_bytes: Number of bytes parsed since the last line break
- * @line_chars: Number of characters parsed since the last line break
- *
- * Represents a location in a file or other source of data parsed
- * by the CSS engine.
- *
- * The @bytes and @line_bytes offsets are meant to be used to
- * programmatically match data. The @lines and @line_chars offsets
- * can be used for printing the location in a file.
- *
- * Note that the @lines parameter starts from 0 and is increased
- * whenever a CSS line break is encountered. (CSS defines the C character
- * sequences "\r\n", "\r", "\n" and "\f" as newlines.)
- * If your document uses different rules for line breaking, you might want
- * run into problems here.
- */
-
-void
-gtk_css_location_init (GtkCssLocation *location)
-{
- memset (location, 0, sizeof (GtkCssLocation));
-}
-
-void
-gtk_css_location_advance (GtkCssLocation *location,
- gsize bytes,
- gsize chars)
-{
- location->bytes += bytes;
- location->chars += chars;
- location->line_bytes += bytes;
- location->line_chars += chars;
-}
-
-void
-gtk_css_location_advance_newline (GtkCssLocation *location,
- gboolean is_windows)
-{
- gtk_css_location_advance (location, is_windows ? 2 : 1, is_windows ? 2 : 1);
-
- location->lines++;
- location->line_bytes = 0;
- location->line_chars = 0;
-}
-
diff --git a/gtk/css/gtkcsslocationprivate.h b/gtk/css/gtkcsslocationprivate.h
index 46ed3c8056..89ff0e979e 100644
--- a/gtk/css/gtkcsslocationprivate.h
+++ b/gtk/css/gtkcsslocationprivate.h
@@ -25,13 +25,33 @@
G_BEGIN_DECLS
-void gtk_css_location_init (GtkCssLocation *location);
-
-void gtk_css_location_advance (GtkCssLocation *location,
- gsize bytes,
- gsize chars);
-void gtk_css_location_advance_newline (GtkCssLocation *location,
- gboolean is_windows);
+static inline void
+gtk_css_location_init (GtkCssLocation *location)
+{
+ memset (location, 0, sizeof (GtkCssLocation));
+}
+
+static inline void
+gtk_css_location_advance (GtkCssLocation *location,
+ gsize bytes,
+ gsize chars)
+{
+ location->bytes += bytes;
+ location->chars += chars;
+ location->line_bytes += bytes;
+ location->line_chars += chars;
+}
+
+static inline void
+gtk_css_location_advance_newline (GtkCssLocation *location,
+ gboolean is_windows)
+{
+ location->bytes += is_windows ? 2 : 1;
+ location->chars += is_windows ? 2 : 1;
+ location->line_bytes = 0;
+ location->line_chars = 0;
+ location->lines++;
+}
G_END_DECLS
diff --git a/gtk/css/gtkcsstokenizer.c b/gtk/css/gtkcsstokenizer.c
index 4d405539e6..262f52a3cd 100644
--- a/gtk/css/gtkcsstokenizer.c
+++ b/gtk/css/gtkcsstokenizer.c
@@ -630,7 +630,7 @@ gtk_css_tokenizer_parse_error (GError **error,
va_end (args);
}
-static gboolean
+static inline gboolean
is_newline (char c)
{
return c == '\n'
@@ -638,7 +638,7 @@ is_newline (char c)
|| c == '\f';
}
-static gboolean
+static inline gboolean
is_whitespace (char c)
{
return is_newline (c)
@@ -646,13 +646,13 @@ is_whitespace (char c)
|| c == ' ';
}
-static gboolean
+static inline gboolean
is_multibyte (char c)
{
return c & 0x80;
}
-static gboolean
+static inline gboolean
is_name_start (char c)
{
return is_multibyte (c)
@@ -660,7 +660,7 @@ is_name_start (char c)
|| c == '_';
}
-static gboolean
+static inline gboolean
is_name (char c)
{
return is_name_start (c)
@@ -668,7 +668,7 @@ is_name (char c)
|| c == '-';
}
-static gboolean
+static inline gboolean
is_non_printable (char c)
{
return (c >= 0 && c <= 0x08)
@@ -678,7 +678,7 @@ is_non_printable (char c)
|| c == 0x7F;
}
-static gboolean
+static inline gboolean
is_valid_escape (const char *data,
const char *end)
{
@@ -703,7 +703,7 @@ gtk_css_tokenizer_remaining (GtkCssTokenizer *tokenizer)
return tokenizer->end - tokenizer->data;
}
-static gboolean
+static inline gboolean
gtk_css_tokenizer_has_valid_escape (GtkCssTokenizer *tokenizer)
{
return is_valid_escape (tokenizer->data, tokenizer->end);
diff --git a/gtk/css/meson.build b/gtk/css/meson.build
index 2785f41374..bf083f693e 100644
--- a/gtk/css/meson.build
+++ b/gtk/css/meson.build
@@ -1,5 +1,4 @@
gtk_css_public_sources = files([
- 'gtkcsslocation.c',
'gtkcsserror.c',
'gtkcsssection.c',
])