]> mj.ucw.cz Git - libucw.git/commitdiff
XML: Uninlined
authorMartin Mares <mj@ucw.cz>
Fri, 13 Feb 2015 14:54:39 +0000 (15:54 +0100)
committerMartin Mares <mj@ucw.cz>
Fri, 13 Feb 2015 14:54:39 +0000 (15:54 +0100)
maint/libucw.abi
ucw-xml/dtd.c
ucw-xml/internals.h
ucw-xml/parse.c

index ca9287ebf11ad2a3a2d10d078698232ddf922dea..299c06d49ae7cc8a845c6039bae0e8369f86e6e1 100644 (file)
@@ -813,6 +813,10 @@ xml_dtd_finish
 xml_dtd_find_attr
 # ucw-xml/internals.h
 xml_throw
+xml_do_push
+xml_do_pop
+xml_push_dom
+xml_pop_dom
 xml_hash_new
 xml_spout_chars
 xml_fatal_nested
@@ -823,6 +827,7 @@ xml_sources_cleanup
 xml_fatal_expected
 xml_fatal_expected_white
 xml_fatal_expected_quot
+xml_parse_white
 xml_parse_eq
 xml_parse_name
 xml_skip_name
index 7c06af84446dc35d11c39da005c89f7e1796135b..62badba2bc2b8999d492d4755fa4adb1149cbed8 100644 (file)
@@ -218,7 +218,7 @@ xml_dtd_attrs_eq(struct xml_dtd_attrs_table *tab UNUSED, struct xml_dtd_elem *el
   return (elem1 == elem2) && !strcmp(name1, name2);
 }
 
-static inline void
+static void
 xml_dtd_attrs_init_key(struct xml_dtd_attrs_table *tab UNUSED, struct xml_dtd_attr *attr, struct xml_dtd_elem *elem, char *name)
 {
   attr->elem = elem;
@@ -302,7 +302,7 @@ xml_dtd_enotns_eq(struct xml_dtd_enotns_table *tab UNUSED, struct xml_dtd_attr *
   return (attr1 == attr2) && (notn1 == notn2);
 }
 
-static inline void
+static void
 xml_dtd_enotns_init_key(struct xml_dtd_enotns_table *tab UNUSED, struct xml_dtd_enotn *enotn, struct xml_dtd_attr *attr, struct xml_dtd_notn *notn)
 {
   enotn->attr = attr;
@@ -411,7 +411,7 @@ xml_parse_dtd_pe(struct xml_context *ctx, uint entity_decl)
   return 1;
 }
 
-static inline uint
+static uint
 xml_parse_dtd_white(struct xml_context *ctx, uint mandatory)
 {
   /* Whitespace or parameter entity,
index 8752cc2d973c4bb56a498fb39565777474a66c35..0e9dc2de94fc8739f07183275b731ca26bc7995b 100644 (file)
@@ -14,6 +14,8 @@
 #include <ucw-xml/dtd.h>
 
 #ifdef CONFIG_UCW_CLEAN_ABI
+#define xml_do_pop ucw_xml_do_pop
+#define xml_do_push ucw_xml_do_push
 #define xml_fatal_expected ucw_xml_fatal_expected
 #define xml_fatal_expected_quot ucw_xml_fatal_expected_quot
 #define xml_fatal_expected_white ucw_xml_fatal_expected_white
 #define xml_parse_pe_ref ucw_xml_parse_pe_ref
 #define xml_parse_pubid_literal ucw_xml_parse_pubid_literal
 #define xml_parse_system_literal ucw_xml_parse_system_literal
+#define xml_parse_white ucw_xml_parse_white
 #define xml_pop_comment ucw_xml_pop_comment
+#define xml_pop_dom ucw_xml_pop_dom
 #define xml_pop_pi ucw_xml_pop_pi
 #define xml_push_comment ucw_xml_push_comment
+#define xml_push_dom ucw_xml_push_dom
 #define xml_push_entity ucw_xml_push_entity
 #define xml_push_pi ucw_xml_push_pi
 #define xml_push_source ucw_xml_push_source
@@ -72,26 +77,8 @@ struct xml_stack {
   uint flags;
 };
 
-static inline void *xml_do_push(struct xml_context *ctx, uint size)
-{
-  /* Saves ctx->stack and ctx->flags state */
-  struct mempool_state state;
-  mp_save(ctx->stack, &state);
-  struct xml_stack *s = mp_alloc(ctx->stack, size);
-  s->state = state;
-  s->flags = ctx->flags;
-  s->next = ctx->stack_list;
-  ctx->stack_list = s;
-  return s;
-}
-
-static inline void xml_do_pop(struct xml_context *ctx, struct xml_stack *s)
-{
-  /* Restore ctx->stack and ctx->flags state */
-  ctx->stack_list = s->next;
-  ctx->flags = s->flags;
-  mp_restore(ctx->stack, &s->state);
-}
+void *xml_do_push(struct xml_context *ctx, uint size);
+void xml_do_pop(struct xml_context *ctx, struct xml_stack *s);
 
 static inline void xml_push(struct xml_context *ctx)
 {
@@ -111,39 +98,8 @@ struct xml_dom_stack {
   struct mempool_state state;
 };
 
-static inline struct xml_node *xml_push_dom(struct xml_context *ctx, struct mempool_state *state)
-{
-  /* Create a new DOM node */
-  TRACE(ctx, "push_dom");
-  struct xml_dom_stack *s = xml_do_push(ctx, sizeof(*s));
-  if (state)
-    s->state = *state;
-  else
-    mp_save(ctx->pool, &s->state);
-  struct xml_node *n = mp_alloc(ctx->pool, sizeof(*n));
-  n->user = NULL;
-  if (n->parent = ctx->node)
-    clist_add_tail(&n->parent->sons, &n->n);
-  return ctx->node = n;
-}
-
-static inline void xml_pop_dom(struct xml_context *ctx, uint free)
-{
-  /* Leave DOM subtree */
-  TRACE(ctx, "pop_dom");
-  ASSERT(ctx->node);
-  struct xml_node *p = ctx->node->parent;
-  struct xml_dom_stack *s = (void *)ctx->stack_list;
-  if (free)
-    {
-      /* See xml_pop_element() for cleanup of attribute hash table */
-      if (p)
-        clist_remove(&ctx->node->n);
-      mp_restore(ctx->pool, &s->state);
-    }
-  ctx->node = p;
-  xml_do_pop(ctx, &s->stack);
-}
+struct xml_node *xml_push_dom(struct xml_context *ctx, struct mempool_state *state);
+void xml_pop_dom(struct xml_context *ctx, uint free);
 
 #define XML_HASH_HDR_SIZE ALIGN_TO(sizeof(void *), CPU_STRUCT_ALIGN)
 #define XML_HASH_GIVE_ALLOC struct HASH_PREFIX(table); \
@@ -254,20 +210,7 @@ void NONRET xml_fatal_expected(struct xml_context *ctx, uint c);
 void NONRET xml_fatal_expected_white(struct xml_context *ctx);
 void NONRET xml_fatal_expected_quot(struct xml_context *ctx);
 
-static inline uint xml_parse_white(struct xml_context *ctx, uint mandatory)
-{
-  /* mandatory=1 -> S ::= (#x20 | #x9 | #xD | #xA)+
-   * mandatory=0 -> S? */
-  uint cnt = 0;
-  while (xml_peek_cat(ctx) & XML_CHAR_WHITE)
-    {
-      xml_skip_char(ctx);
-      cnt++;
-    }
-  if (unlikely(mandatory && !cnt))
-    xml_fatal_expected_white(ctx);
-  return cnt;
-}
+uint xml_parse_white(struct xml_context *ctx, uint mandatory);
 
 static inline void xml_parse_char(struct xml_context *ctx, uint c)
 {
index b1790d0b7081303954b0455c57123c611a44551c..65e556b602a0d5ae7c666ab743f31ed012694ddc 100644 (file)
@@ -54,6 +54,80 @@ xml_parse_eq(struct xml_context *ctx)
   xml_parse_white(ctx, 0);
 }
 
+/*** Memory management ***/
+
+void *xml_do_push(struct xml_context *ctx, uint size)
+{
+  /* Saves ctx->stack and ctx->flags state */
+  struct mempool_state state;
+  mp_save(ctx->stack, &state);
+  struct xml_stack *s = mp_alloc(ctx->stack, size);
+  s->state = state;
+  s->flags = ctx->flags;
+  s->next = ctx->stack_list;
+  ctx->stack_list = s;
+  return s;
+}
+
+void xml_do_pop(struct xml_context *ctx, struct xml_stack *s)
+{
+  /* Restore ctx->stack and ctx->flags state */
+  ctx->stack_list = s->next;
+  ctx->flags = s->flags;
+  mp_restore(ctx->stack, &s->state);
+}
+
+struct xml_node *xml_push_dom(struct xml_context *ctx, struct mempool_state *state)
+{
+  /* Create a new DOM node */
+  TRACE(ctx, "push_dom");
+  struct xml_dom_stack *s = xml_do_push(ctx, sizeof(*s));
+  if (state)
+    s->state = *state;
+  else
+    mp_save(ctx->pool, &s->state);
+  struct xml_node *n = mp_alloc(ctx->pool, sizeof(*n));
+  n->user = NULL;
+  if (n->parent = ctx->node)
+    clist_add_tail(&n->parent->sons, &n->n);
+  return ctx->node = n;
+}
+
+void xml_pop_dom(struct xml_context *ctx, uint free)
+{
+  /* Leave DOM subtree */
+  TRACE(ctx, "pop_dom");
+  ASSERT(ctx->node);
+  struct xml_node *p = ctx->node->parent;
+  struct xml_dom_stack *s = (void *)ctx->stack_list;
+  if (free)
+    {
+      /* See xml_pop_element() for cleanup of attribute hash table */
+      if (p)
+        clist_remove(&ctx->node->n);
+      mp_restore(ctx->pool, &s->state);
+    }
+  ctx->node = p;
+  xml_do_pop(ctx, &s->stack);
+}
+
+/*** Basics ***/
+
+uint xml_parse_white(struct xml_context *ctx, uint mandatory)
+{
+  /* mandatory=1 -> S ::= (#x20 | #x9 | #xD | #xA)+
+   * mandatory=0 -> S? */
+  uint cnt = 0;
+  while (xml_peek_cat(ctx) & XML_CHAR_WHITE)
+    {
+      xml_skip_char(ctx);
+      cnt++;
+    }
+  if (unlikely(mandatory && !cnt))
+    xml_fatal_expected_white(ctx);
+  return cnt;
+}
+
 /*** Names and nmtokens ***/
 
 static char *
@@ -387,7 +461,7 @@ xml_spout_chars(struct fastbuf *fb)
     }
 }
 
-static inline uint
+static uint
 xml_end_chars(struct xml_context *ctx, char **out)
 {
   struct fastbuf *fb = &ctx->chars;
@@ -402,7 +476,7 @@ xml_end_chars(struct xml_context *ctx, char **out)
   return len;
 }
 
-static inline uint
+static uint
 xml_report_chars(struct xml_context *ctx, char **out)
 {
   struct fastbuf *fb = &ctx->chars;
@@ -416,7 +490,7 @@ xml_report_chars(struct xml_context *ctx, char **out)
   return len;
 }
 
-static inline uint
+static uint
 xml_flush_chars(struct xml_context *ctx)
 {
   char *text, *rtext;
@@ -447,14 +521,14 @@ xml_flush_chars(struct xml_context *ctx)
   return len;
 }
 
-static inline void
+static void
 xml_pop_chars(struct xml_context *ctx)
 {
   xml_pop_dom(ctx, !(ctx->flags & XML_ALLOC_CHARS));
   TRACE(ctx, "pop_chars");
 }
 
-static inline void
+static void
 xml_append_chars(struct xml_context *ctx)
 {
   TRACE(ctx, "append_chars");