From 4c8b0086d7771616f02e39cc1c512ea6b165a5e5 Mon Sep 17 00:00:00 2001
From: "Sven M. Hallberg" <pesco@khjk.org>
Date: Wed, 23 Jan 2013 18:28:50 +0100
Subject: [PATCH] rename H_MAKE_TOKEN to H_MAKE and remove 'token' from other
 function names

---
 examples/dns.c        | 10 +++++-----
 examples/dns_common.c |  2 +-
 examples/glue.c       | 20 ++++++++++----------
 examples/glue.h       | 10 +++++-----
 examples/rr.c         | 16 ++++++++--------
 5 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/examples/dns.c b/examples/dns.c
index e3f36a6a..c8e3fafe 100644
--- a/examples/dns.c
+++ b/examples/dns.c
@@ -105,7 +105,7 @@ const HParsedToken* act_header(const HParseResult *p) {
   dns_header_t *header = H_ALLOC(dns_header_t);
   *header = header_;
 
-  return H_MAKE_TOKEN(dns_header_t, header);
+  return H_MAKE(dns_header_t, header);
 }
 
 const HParsedToken* act_label(const HParseResult *p) {
@@ -117,7 +117,7 @@ const HParsedToken* act_label(const HParseResult *p) {
     r->label[i] = p->ast->seq->elements[i]->uint;
   r->label[r->len] = 0;
 
-  return H_MAKE_TOKEN(dns_label_t, r);
+  return H_MAKE(dns_label_t, r);
 }
 
 const HParsedToken* act_rr(const HParseResult *p) {
@@ -132,7 +132,7 @@ const HParsedToken* act_rr(const HParseResult *p) {
   // Parse and pack RDATA.
   set_rdata(*rr, p->ast->seq->elements[4]->seq);	   
 
-  return H_MAKE_TOKEN(dns_rr_t, rr);
+  return H_MAKE(dns_rr_t, rr);
 }
 
 const HParsedToken* act_question(const HParseResult *p) {
@@ -149,7 +149,7 @@ const HParsedToken* act_question(const HParseResult *p) {
   q->qtype  = fields[1]->uint;
   q->qclass = fields[2]->uint;
 
-  return H_MAKE_TOKEN(dns_question_t, q);
+  return H_MAKE(dns_question_t, q);
 }
 
 const HParsedToken* act_message(const HParseResult *p) {
@@ -194,7 +194,7 @@ const HParsedToken* act_message(const HParseResult *p) {
   }
   msg->additional = additional;
 
-  return H_MAKE_TOKEN(dns_message_t, msg);
+  return H_MAKE(dns_message_t, msg);
 }
 
 #define act_hdzero h_act_ignore
diff --git a/examples/dns_common.c b/examples/dns_common.c
index 0171a592..76915b66 100644
--- a/examples/dns_common.c
+++ b/examples/dns_common.c
@@ -50,7 +50,7 @@ const HParsedToken* act_domain(const HParseResult *p) {
   if(arr) {
     dns_domain_t *val = H_ALLOC(dns_domain_t);  // dns_domain_t is char*
     *val = arr;
-    ret = H_MAKE_TOKEN(dns_domain_t, val);
+    ret = H_MAKE(dns_domain_t, val);
   }
 
   return ret;
diff --git a/examples/glue.c b/examples/glue.c
index 80864fce..1c86b15d 100644
--- a/examples/glue.c
+++ b/examples/glue.c
@@ -48,16 +48,16 @@ void h_seq_append(HParsedToken *xs, const HParsedToken *ys)
 
 // Flatten nested sequences. Always returns a sequence.
 // If input element is not a sequence, returns it as a singleton sequence.
-const HParsedToken *h_token_flatten(HArena *arena, const HParsedToken *p)
+const HParsedToken *h_seq_flatten(HArena *arena, const HParsedToken *p)
 {
   assert(p != NULL);
 
-  HParsedToken *ret = h_make_token_seq(arena);
+  HParsedToken *ret = h_make_seq(arena);
   switch(p->token_type) {
   case TT_SEQUENCE:
     // Flatten and append all.
     for(size_t i; i<p->seq->used; i++) {
-	  h_seq_append(ret, h_token_flatten(arena, h_seq_index(p, i)));
+	  h_seq_append(ret, h_seq_flatten(arena, h_seq_index(p, i)));
 	}
 	break;
   default:
@@ -69,26 +69,26 @@ const HParsedToken *h_token_flatten(HArena *arena, const HParsedToken *p)
   return ret;
 }
 
-// Action version of h_token_flatten.
+// Action version of h_seq_flatten.
 const HParsedToken *h_act_flatten(const HParseResult *p) {
-  return h_token_flatten(p->arena, p->ast);
+  return h_seq_flatten(p->arena, p->ast);
 }
 
-HParsedToken *h_make_token_(HArena *arena, HTokenType type)
+HParsedToken *h_make_(HArena *arena, HTokenType type)
 {
   HParsedToken *ret = h_arena_malloc(arena, sizeof(HParsedToken));
   ret->token_type = type;
   return ret;
 }
 
-HParsedToken *h_make_token_seq(HArena *arena)
+HParsedToken *h_make_seq(HArena *arena)
 {
-  return h_make_token_(arena, TT_SEQUENCE);
+  return h_make_(arena, TT_SEQUENCE);
 }
 
-HParsedToken *h_make_token(HArena *arena, HTokenType type, void *value)
+HParsedToken *h_make(HArena *arena, HTokenType type, void *value)
 {
-  HParsedToken *ret = h_make_token_(arena, type);
+  HParsedToken *ret = h_make_(arena, type);
   ret->user = value;
   return ret;
 }
diff --git a/examples/glue.h b/examples/glue.h
index 67f69071..dac8fbbf 100644
--- a/examples/glue.h
+++ b/examples/glue.h
@@ -45,19 +45,19 @@ const HParsedToken *h_act_flatten(const HParseResult *p);
 
 // Token constructors...
 
-HParsedToken *h_make_token(HArena *arena, HTokenType type, void *value);
-HParsedToken *h_make_token_seq(HArena *arena);
+HParsedToken *h_make(HArena *arena, HTokenType type, void *value);
+HParsedToken *h_make_seq(HArena *arena);
 
 #define H_ALLOC(TYP) \
   ((TYP *) h_arena_malloc(p->arena, sizeof(TYP)))
 
-#define H_MAKE_TOKEN(TYP, VAL) \
-  h_make_token(p->arena, TT_ ## TYP, VAL)
+#define H_MAKE(TYP, VAL) \
+  h_make(p->arena, TT_ ## TYP, VAL)
 
 // Sequences...
 
 // Flatten nested sequences into one.
-const HParsedToken *h_token_flatten(HArena *arena, const HParsedToken *p);
+const HParsedToken *h_seq_flatten(HArena *arena, const HParsedToken *p);
 
 void h_seq_snoc(HParsedToken *xs, const HParsedToken *x);
 void h_seq_append(HParsedToken *xs, const HParsedToken *ys);
diff --git a/examples/rr.c b/examples/rr.c
index bd4c1256..94c4b7cc 100644
--- a/examples/rr.c
+++ b/examples/rr.c
@@ -25,7 +25,7 @@ const HParsedToken *act_null(const HParseResult *p) {
   for (size_t i=0; i<len; ++i)
     buf[i] = p->ast->seq->elements[i]->uint;
 
-  return H_MAKE_TOKEN(dns_rr_null_t, null);
+  return H_MAKE(dns_rr_null_t, null);
 }
 
 const HParsedToken *act_txt(const HParseResult *p) {
@@ -43,7 +43,7 @@ const HParsedToken *act_txt(const HParseResult *p) {
   txt->count = p->ast->seq->elements[0]->seq->used;
   txt->txt_data = ret;
 
-  return H_MAKE_TOKEN(dns_rr_txt_t, txt);
+  return H_MAKE(dns_rr_txt_t, txt);
 }
 
 const HParsedToken* act_cstr(const HParseResult *p) {
@@ -56,7 +56,7 @@ const HParsedToken* act_cstr(const HParseResult *p) {
   assert(ret[arr->used-1] == '\0'); // XXX Is this right?! If so, shouldn't it be a validation?
   *cs = ret;
 
-  return H_MAKE_TOKEN(dns_cstr_t, cs);
+  return H_MAKE(dns_cstr_t, cs);
 }
 
 const HParsedToken* act_soa(const HParseResult *p) {
@@ -70,7 +70,7 @@ const HParsedToken* act_soa(const HParseResult *p) {
   soa->expire  = p->ast->seq->elements[5]->uint;
   soa->minimum = p->ast->seq->elements[6]->uint;
 
-  return H_MAKE_TOKEN(dns_rr_soa_t, soa);
+  return H_MAKE(dns_rr_soa_t, soa);
 }
 
 const HParsedToken* act_wks(const HParseResult *p) {
@@ -83,7 +83,7 @@ const HParsedToken* act_wks(const HParseResult *p) {
   for (size_t i=0; i<wks->len; ++i)
     wks->bit_map[i] = p->ast->seq->elements[2]->seq->elements[i]->uint;
 
-  return H_MAKE_TOKEN(dns_rr_wks_t, wks);
+  return H_MAKE(dns_rr_wks_t, wks);
 }
 
 const HParsedToken* act_hinfo(const HParseResult *p) {
@@ -92,7 +92,7 @@ const HParsedToken* act_hinfo(const HParseResult *p) {
   hinfo->cpu = *H_FIELD(dns_cstr_t, 0);
   hinfo->os  = *H_FIELD(dns_cstr_t, 1);
 
-  return H_MAKE_TOKEN(dns_rr_hinfo_t, hinfo);
+  return H_MAKE(dns_rr_hinfo_t, hinfo);
 }
 
 const HParsedToken* act_minfo(const HParseResult *p) {
@@ -101,7 +101,7 @@ const HParsedToken* act_minfo(const HParseResult *p) {
   minfo->rmailbx = *H_FIELD(dns_domain_t, 0);
   minfo->emailbx = *H_FIELD(dns_domain_t, 1);
 
-  return H_MAKE_TOKEN(dns_rr_minfo_t, minfo);
+  return H_MAKE(dns_rr_minfo_t, minfo);
 }
 
 const HParsedToken* act_mx(const HParseResult *p) {
@@ -110,7 +110,7 @@ const HParsedToken* act_mx(const HParseResult *p) {
   mx->preference = p->ast->seq->elements[0]->uint;
   mx->exchange   = *H_FIELD(dns_domain_t, 1);
 
-  return H_MAKE_TOKEN(dns_rr_mx_t, mx);
+  return H_MAKE(dns_rr_mx_t, mx);
 }
 
 
-- 
GitLab