diff options
author | Nick Wellnhofer <[email protected]> | 2014-11-16 21:56:49 +0100 |
---|---|---|
committer | Nick Wellnhofer <[email protected]> | 2014-11-16 22:43:04 +0100 |
commit | 675b92aa6b6c8124c8ccf9535e338fd37b8b9977 (patch) | |
tree | f3201e9ceb6fab30db8c97bcc01812ef341f97b9 /src/ast.h | |
parent | 52045957a87f2c86f61f2054cafbebe050a1299b (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.h | 55 |
1 files changed, 50 insertions, 5 deletions
@@ -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) |