From d6ef9ac526f417b9f6f0b60756bf8c19cc7a68c2 Mon Sep 17 00:00:00 2001
From: "Sven M. Hallberg" <pesco@khjk.org>
Date: Fri, 25 Jan 2013 18:32:01 +0100
Subject: [PATCH] add definitions for h_cast family of functions

---
 examples/glue.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/examples/glue.c b/examples/glue.c
index 6fe3392d..52ffd89b 100644
--- a/examples/glue.c
+++ b/examples/glue.c
@@ -119,6 +119,36 @@ HParsedToken *h_make_uint(HArena *arena, uint64_t val)
   return ret;
 }
 
+void * h_cast(HTokenType type, const HParsedToken *p)
+{
+  assert(p->token_type == type);
+  return p->user;
+}
+
+HCountedArray *h_cast_seq (const HParsedToken *p)
+{
+  assert(p->token_type == TT_SEQUENCE);
+  return p->seq;
+}
+
+HBytes h_cast_bytes(const HParsedToken *p)
+{
+  assert(p->token_type == TT_BYTES);
+  return p->bytes;
+}
+
+int64_t h_cast_sint (const HParsedToken *p)
+{
+  assert(p->token_type == TT_SINT);
+  return p->sint;
+}
+
+uint64_t h_cast_uint (const HParsedToken *p)
+{
+  assert(p->token_type == TT_UINT);
+  return p->uint;
+}
+
 // XXX -> internal
 HParsedToken *h_carray_index(const HCountedArray *a, size_t i)
 {
-- 
GitLab