summaryrefslogtreecommitdiff
path: root/src/ast.h
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2014-11-16 21:56:49 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2014-11-16 22:43:04 +0100
commit675b92aa6b6c8124c8ccf9535e338fd37b8b9977 (patch)
treef3201e9ceb6fab30db8c97bcc01812ef341f97b9 /src/ast.h
parent52045957a87f2c86f61f2054cafbebe050a1299b (diff)
Move inline function definitions to header files
Inline functions must be defined in header files in order to be inlined in other compilation units. This also fixes the MSVC build where out-of-line versions weren't created and allows to remove the -fgnu89-inline flag.
Diffstat (limited to 'src/ast.h')
-rw-r--r--src/ast.h55
1 files changed, 50 insertions, 5 deletions
diff --git a/src/ast.h b/src/ast.h
index dc8df41..0640f88 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -5,6 +5,7 @@
#include "config.h"
#include "buffer.h"
#include "chunk.h"
+#include "cmark.h"
#ifdef __cplusplus
extern "C" {
@@ -136,15 +137,59 @@ struct cmark_doc_parser {
cmark_strbuf *curline;
};
-struct cmark_node_inl *cmark_make_link(struct cmark_node_inl *label, unsigned char *url, unsigned char *title);
+unsigned char *cmark_clean_autolink(chunk *url, int is_email);
+
+static inline cmark_node_inl *cmark_make_link(cmark_node_inl *label, unsigned char *url, unsigned char *title)
+{
+ cmark_node_inl* e = (cmark_node_inl *)calloc(1, sizeof(*e));
+ if(e != NULL) {
+ e->tag = CMARK_INL_LINK;
+ e->content.linkable.label = label;
+ e->content.linkable.url = url;
+ e->content.linkable.title = title;
+ e->next = NULL;
+ }
+ return e;
+}
-struct cmark_node_inl* cmark_make_autolink(struct cmark_node_inl* label, cmark_chunk url, int is_email);
+static inline cmark_node_inl* cmark_make_autolink(cmark_node_inl* label, cmark_chunk url, int is_email)
+{
+ return cmark_make_link(label, cmark_clean_autolink(&url, is_email), NULL);
+}
-struct cmark_node_inl* cmark_make_inlines(cmark_inl_tag t, struct cmark_node_inl* contents);
+static inline cmark_node_inl* cmark_make_inlines(cmark_inl_tag t, cmark_node_inl* contents)
+{
+ cmark_node_inl * e = (cmark_node_inl *)calloc(1, sizeof(*e));
+ if(e != NULL) {
+ e->tag = t;
+ e->content.inlines = contents;
+ e->next = NULL;
+ }
+ return e;
+}
-struct cmark_node_inl* cmark_make_literal(cmark_inl_tag t, cmark_chunk s);
+// Create an inline with a literal string value.
+static inline cmark_node_inl* cmark_make_literal(cmark_inl_tag t, cmark_chunk s)
+{
+ cmark_node_inl * e = (cmark_node_inl *)calloc(1, sizeof(*e));
+ if(e != NULL) {
+ e->tag = t;
+ e->content.literal = s;
+ e->next = NULL;
+ }
+ return e;
+}
-struct cmark_node_inl* cmark_make_simple(cmark_inl_tag t);
+// Create an inline with no value.
+static inline cmark_node_inl* cmark_make_simple(cmark_inl_tag t)
+{
+ cmark_node_inl* e = (cmark_node_inl *)calloc(1, sizeof(*e));
+ if(e != NULL) {
+ e->tag = t;
+ e->next = NULL;
+ }
+ return e;
+}
// Macros for creating various kinds of simple.
#define cmark_make_str(s) cmark_make_literal(INL_STRING, s)