[gnome-builder/wip/slaf/xml-pack: 569/572] xml-pack: IdeXmlSchema object
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/slaf/xml-pack: 569/572] xml-pack: IdeXmlSchema object
- Date: Sun, 14 May 2017 21:23:11 +0000 (UTC)
commit b8d606c4c4282997c49eca462e20f646f2d756ee
Author: Sebastien Lafargue <slafargue gnome org>
Date: Sun May 14 23:10:16 2017 +0200
xml-pack: IdeXmlSchema object
Used to store rng parser result
plugins/xml-pack/Makefile.am | 2 +
plugins/xml-pack/ide-xml-schema.c | 78 +++++++++++++++++++++++++++++++++++++
plugins/xml-pack/ide-xml-schema.h | 49 +++++++++++++++++++++++
3 files changed, 129 insertions(+), 0 deletions(-)
---
diff --git a/plugins/xml-pack/Makefile.am b/plugins/xml-pack/Makefile.am
index e305666..c1fa2b9 100644
--- a/plugins/xml-pack/Makefile.am
+++ b/plugins/xml-pack/Makefile.am
@@ -36,6 +36,8 @@ libxml_pack_plugin_la_SOURCES = \
ide-xml-sax.h \
ide-xml-service.c \
ide-xml-service.h \
+ ide-xml-schema.c \
+ ide-xml-schema.h \
ide-xml-schema-cache-entry.c \
ide-xml-schema-cache-entry.h \
ide-xml-stack.c \
diff --git a/plugins/xml-pack/ide-xml-schema.c b/plugins/xml-pack/ide-xml-schema.c
new file mode 100644
index 0000000..cf42bd3
--- /dev/null
+++ b/plugins/xml-pack/ide-xml-schema.c
@@ -0,0 +1,78 @@
+/* ide-xml-schema.c
+ *
+ * Copyright (C) 2017 Sebastien Lafargue <slafargue gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ide-xml-schema.h"
+
+G_DEFINE_BOXED_TYPE (IdeXmlSchema, ide_xml_schema, ide_xml_schema_ref, ide_xml_schema_unref)
+
+IdeXmlSchema *
+ide_xml_schema_new (void)
+{
+ IdeXmlSchema *self;
+
+ self = g_slice_new0 (IdeXmlSchema);
+ self->ref_count = 1;
+
+ return self;
+}
+
+IdeXmlSchema *
+ide_xml_schema_copy (IdeXmlSchema *self)
+{
+ IdeXmlSchema *copy;
+
+ g_return_val_if_fail (self, NULL);
+ g_return_val_if_fail (self->ref_count, NULL);
+
+ copy = ide_xml_schema_new ();
+
+ return copy;
+}
+
+static void
+ide_xml_schema_free (IdeXmlSchema *self)
+{
+ g_assert (self);
+ g_assert_cmpint (self->ref_count, ==, 0);
+
+ if (self->top_grammar != NULL)
+ ide_xml_rng_grammar_unref (self->top_grammar);
+
+ g_slice_free (IdeXmlSchema, self);
+}
+
+IdeXmlSchema *
+ide_xml_schema_ref (IdeXmlSchema *self)
+{
+ g_return_val_if_fail (self, NULL);
+ g_return_val_if_fail (self->ref_count, NULL);
+
+ g_atomic_int_inc (&self->ref_count);
+
+ return self;
+}
+
+void
+ide_xml_schema_unref (IdeXmlSchema *self)
+{
+ g_return_if_fail (self);
+ g_return_if_fail (self->ref_count);
+
+ if (g_atomic_int_dec_and_test (&self->ref_count))
+ ide_xml_schema_free (self);
+}
diff --git a/plugins/xml-pack/ide-xml-schema.h b/plugins/xml-pack/ide-xml-schema.h
new file mode 100644
index 0000000..afc3f83
--- /dev/null
+++ b/plugins/xml-pack/ide-xml-schema.h
@@ -0,0 +1,49 @@
+/* ide-xml-schema.h
+ *
+ * Copyright (C) 2017 Sebastien Lafargue <slafargue gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_XML_SCHEMA_H
+#define IDE_XML_SCHEMA_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "ide-xml-rng-grammar.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_XML_SCHEMA (ide_xml_schema_get_type())
+
+typedef struct _IdeXmlSchema IdeXmlSchema;
+
+struct _IdeXmlSchema
+{
+ guint ref_count;
+
+ IdeXmlRngGrammar *top_grammar;
+};
+
+IdeXmlSchema *ide_xml_schema_new (void);
+IdeXmlSchema *ide_xml_schema_copy (IdeXmlSchema *self);
+IdeXmlSchema *ide_xml_schema_ref (IdeXmlSchema *self);
+void ide_xml_schema_unref (IdeXmlSchema *self);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (IdeXmlSchema, ide_xml_schema_unref)
+
+G_END_DECLS
+
+#endif /* IDE_XML_SCHEMA_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]