Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 8c2764a9b8572d5b6ce5997fa74bf65334713030 @postmodern committed May 11, 2011
@@ -0,0 +1,3 @@
+-
+ChangeLog.*
+LICENSE.txt
@@ -0,0 +1,2 @@
+doc/
+pkg/
1 .rspec
@@ -0,0 +1 @@
+--colour --format documentation
@@ -0,0 +1 @@
+--markup markdown --title "ffi-upskirt Documentation" --protected
@@ -0,0 +1,4 @@
+### 0.1.0 / 2011-05-10
+
+* Initial release:
+
@@ -0,0 +1,20 @@
+Copyright (c) 2011 Hal Brodigan
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,26 @@
+# ffi-upskirt
+
+* [Source](http://github.com/postmodern/ffi-upskirt)
+* [Issues](http://github.com/postmodern/ffi-upskirt/issues)
+* [Documentation](http://rubydoc.info/gems/ffi-upskirt/frames)
+* [Email](mailto:postmodern.mod3 at gmail.com)
+
+## Description
+
+Ruby FFI bindings for the libupskirt markdown library.
+
+## Examples
+
+ require 'ffi/upskirt'
+
+## Requirements
+
+## Install
+
+ $ gem install ffi-upskirt
+
+## Copyright
+
+Copyright (c) 2011 Hal Brodigan
+
+See {file:LICENSE.txt} for details.
@@ -0,0 +1,38 @@
+require 'rubygems'
+require 'rake'
+
+begin
+ gem 'ore-tasks', '~> 0.4'
+ require 'ore/tasks'
+
+ Ore::Tasks.new
+rescue LoadError => e
+ STDERR.puts e.message
+ STDERR.puts "Run `gem install ore-tasks` to install 'ore/tasks'."
+end
+
+begin
+ gem 'rspec', '~> 2.4'
+ require 'rspec/core/rake_task'
+
+ RSpec::Core::RakeTask.new
+rescue LoadError => e
+ task :spec do
+ abort "Please run `gem install rspec` to install RSpec."
+ end
+end
+
+task :test => :spec
+task :default => :spec
+
+begin
+ gem 'yard', '~> 0.6.0'
+ require 'yard'
+
+ YARD::Rake::YardocTask.new
+rescue LoadError => e
+ task :yard do
+ abort "Please run `gem install yard` to install YARD."
+ end
+end
+task :doc => :yard
@@ -0,0 +1,15 @@
+# -*- encoding: utf-8 -*-
+
+begin
+ Ore::Specification.new do |gemspec|
+ # custom logic here
+ end
+rescue NameError
+ begin
+ require 'ore/specification'
+ retry
+ rescue LoadError
+ STDERR.puts "The '#{__FILE__}' file requires Ore."
+ STDERR.puts "Run `gem install ore-core` to install Ore."
+ end
+end
@@ -0,0 +1,15 @@
+name: ffi-upskirt
+summary: FFI bindings for libupskirt
+description:
+ Ruby FFI bindings for the libupskirt markdown library.
+
+license: MIT
+authors: Postmodern
+email: postmodern.mod3@gmail.com
+homepage: http://github.com/postmodern/ffi-upskirt
+has_yard: true
+
+development_dependencies:
+ ore-tasks: ~> 0.4
+ rspec: ~> 2.4
+ yard: ~> 0.6.0
@@ -0,0 +1,2 @@
+require 'ffi/upskirt/upskirt'
+require 'ffi/upskirt/version'
@@ -0,0 +1,15 @@
+require 'ffi'
+
+module FFI
+ module Upskirt
+ class Buf < FFI::Struct
+
+ layout :data, :pointer,
+ :size, :size_t,
+ :asize, :size_t,
+ :unit, :size_t,
+ :ref, :int
+
+ end
+ end
+end
@@ -0,0 +1,34 @@
+module FFI
+ module Upskirt
+ class Renderer < FFI::Struct
+
+ layout :blockcode, :blockcode_callback,
+ :blockquote, :blockquote_callback,
+ :blockhtml, :blockhtml_callback,
+ :header, :header_callback,
+ :hrule, :hrule_callback,
+ :list, :list_callback,
+ :listitem, :listitem_callback,
+ :paragraph, :paragraph_callback,
+ :table, :table_callback,
+ :table_row, :table_row_callback,
+ :table_cell, :table_cell_callback,
+ :autolink, :autolink_callback,
+ :codespan, :codespan_callback,
+ :double_emphasis, :double_emphasis_callback,
+ :emphasis, :emphasis_callback,
+ :image, :image_callback,
+ :linebreak, :linebreak_callback,
+ :link, :link_callback,
+ :raw_html_tag, :raw_html_tag_callback,
+ :triple_emphasis, :triple_emphasis_callback,
+ :strikethrough, :strikethrough_callback,
+ :entity, :entity_callback,
+ :normal_text, :normal_text_callback,
+ :doc_header, :doc_header_callback,
+ :doc_footerm, :doc_footer_callback,
+ :opaque, :pointer
+
+ end
+ end
+end
@@ -0,0 +1,56 @@
+require 'ffi'
+
+module FFI
+ module Upskirt
+ extend FFI::Library
+
+ enum :markdown_autolink, [
+ :not_autolink,
+ :normal,
+ :email
+ ]
+
+ enum :markdown_extensions, [
+ :no_intra_emphasis, (1 << 0),
+ :tables, (1 << 1),
+ :fenced_code, (1 << 2),
+ :autolink, (1 << 3),
+ :strikethrough, (1 << 4),
+ :lax_html_blocks, (1 << 5),
+ :space_headers, (1 << 6)
+ ]
+
+ # block level callbacks - NULL skips the block
+ callback :blockcode_callback, [:pointer, :pointer, :pointer, :pointer], :void
+ callback :blockquote_callback, [:pointer, :pointer, :pointer], :void
+ callback :blockhtml_callback, [:pointer, :pointer, :pointer], :void
+ callback :header_callback, [:pointer, :pointer, :int, :pointer], :void
+ callback :hrule_callback, [:pointer, :pointer], :void
+ callback :list_callback, [:pointer, :pointer, :int, :pointer], :void
+ callback :listitem_callback, [:pointer, :pointer, :int, :pointer], :void
+ callback :paragraph_callback, [:pointer, :pointer, :pointer], :void
+ callback :table_callback, [:pointer, :pointer, :pointer, :pointer], :void
+ callback :table_row_callback, [:pointer, :pointer, :pointer], :void
+ callback :table_cell_callback, [:pointer, :pointer, :int, :pointer], :void
+
+ # span level callbacks - NULL or return 0 prints the span verbatim
+ callback :autolink_callback, [:pointer, :pointer, :markdown_autolink, :pointer], :int
+ callback :codespan_callback, [:pointer, :pointer, :pointer], :int
+ callback :double_emphasis_callback, [:pointer, :pointer, :pointer], :int
+ callback :emphasis_callback, [:pointer, :pointer, :pointer], :int
+ callback :image_callback, [:pointer, :pointer, :pointer, :pointer, :pointer], :int
+ callback :linebreak_callback, [:pointer, :pointer], :int
+ callback :link_callback, [:pointer, :pointer, :pointer, :pointer, :pointer], :int
+ callback :raw_html_tag_callback, [:pointer, :pointer, :pointer], :int
+ callback :triple_emphasis_callback, [:pointer, :pointer, :pointer], :int
+ callback :strikethrough_callback, [:pointer, :pointer, :pointer], :int
+
+ # low level callbacks - NULL copies input directly into the output
+ callback :entity, [:pointer, :pointer, :pointer], :void
+ callback :normal_text, [:pointer, :pointer, :pointer], :void
+
+ # header and footer
+ callback :doc_header, [:pointer, :pointer], :void
+ callback :doc_footer, [:pointer, :pointer], :void
+ end
+end
@@ -0,0 +1,40 @@
+require 'ffi/upskirt/types'
+
+require 'ffi'
+
+module FFI
+ module Upskirt
+ extend FFI::Library
+
+ ffi_lib 'upskirt'
+
+ attach_function :bufcasecmp, [:pointer, :pointer], :int
+ attach_function :bufcmp, [:pointer, :pointer], :int
+ attach_function :bufcmps, [:pointer, :pointer], :int
+ attach_function :bufprefix, [:pointer, :pointer], :int
+ attach_function :bufdup, [:pointer, :size_t], :pointer
+ attach_function :bufgrow, [:pointer, :size_t], :int
+ attach_function :bufnew, [:size_t], :pointer
+ attach_function :bufnullterm, [:pointer], :void
+ attach_function :bufprintf, [:pointer, :pointer, :varargs], :void
+ attach_function :bufput, [:pointer, :pointer, :size_t], :void
+ attach_function :bufputs, [:pointer, :pointer], :void
+ attach_function :bufputc, [:pointer, :char], :void
+ attach_function :bufrelease, [:pointer], :void
+ attach_function :bufreset, [:pointer], :void
+ attach_function :bufset, [:pointer, :pointer], :void
+ attach_function :bufslurp, [:pointer, :size_t], :void
+ attach_function :buftoi, [:pointer, :size_t, :pointer], :int
+
+ MARKDOWN_LIST_ORDERED = 1
+ MARKDOWN_LI_BLOCK = 2
+ MARKDOWN_TABLE_ALIGN_L = (1 << 0)
+ MARKDOWN_TABLE_ALIGN_R = (1 << 1)
+ MARKDOWN_TABLE_ALIGN_CENTER = (
+ MARKDOWN_TABLE_ALIGN_L | MARKDOWN_TABLE_ALIGN_R
+ )
+
+ attach_function :is_safe_link, [:pointer, :size_t], :int
+ attach_function :ups_markdown, [:pointer, :pointer, :pointer, :uint], :void
+ end
+end
@@ -0,0 +1,6 @@
+module FFI
+ module Upskirt
+ # ffi-upskirt version
+ VERSION = "0.1.0"
+ end
+end
@@ -0,0 +1,5 @@
+gem 'rspec', '~> 2.4'
+require 'rspec'
+require 'ffi/upskirt/version'
+
+include FFI::Upskirt
@@ -0,0 +1,8 @@
+require 'spec_helper'
+require 'ffi/upskirt'
+
+describe FFI::Upskirt do
+ it "should have a VERSION constant" do
+ subject.const_get('VERSION').should_not be_empty
+ end
+end

0 comments on commit 8c2764a

Please sign in to comment.