From 170ec08234e29050c5d78d52e4100207625897d2 Mon Sep 17 00:00:00 2001 From: Israel Madueme Date: Fri, 15 Jun 2018 14:42:19 -0700 Subject: Bug 1456877 - Add a wrapper around libcmark_gfm to Bugzilla --- Bugzilla/Markdown/GFM/Node.pm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Bugzilla/Markdown/GFM/Node.pm (limited to 'Bugzilla/Markdown/GFM/Node.pm') diff --git a/Bugzilla/Markdown/GFM/Node.pm b/Bugzilla/Markdown/GFM/Node.pm new file mode 100644 index 000000000..da5af1a68 --- /dev/null +++ b/Bugzilla/Markdown/GFM/Node.pm @@ -0,0 +1,33 @@ +package Bugzilla::Markdown::GFM::Node; + +use 5.10.1; +use strict; +use warnings; + +sub SETUP { + my ($class, $FFI) = @_; + + $FFI->custom_type( + markdown_node_t => { + native_type => 'opaque', + native_to_perl => sub { + bless \$_[0], $class if $_[0]; + }, + perl_to_native => sub { ${ $_[0] } }, + } + ); + + $FFI->attach( + [ cmark_node_free => 'DESTROY' ], + [ 'markdown_node_t' ] => 'void' + ); + + $FFI->attach( + [ cmark_render_html => 'render_html' ], + [ 'markdown_node_t', 'markdown_options_t', 'markdown_syntax_extension_list_t'] => 'string', + ); +} + +1; + +__END__ -- cgit v1.2.3-24-g4f1b