ffi-expat 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +21 -0
- data/README.md +54 -0
- data/lib/ffi/expat.rb +250 -0
- data/test/fixtures/sample.xml +120 -0
- metadata +83 -0
    
        data/LICENSE
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            The MIT License
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Copyright (c) 2010 Scott Chacon
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         | 
| 6 | 
            +
            of this software and associated documentation files (the "Software"), to deal
         | 
| 7 | 
            +
            in the Software without restriction, including without limitation the rights
         | 
| 8 | 
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 9 | 
            +
            copies of the Software, and to permit persons to whom the Software is
         | 
| 10 | 
            +
            furnished to do so, subject to the following conditions:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            The above copyright notice and this permission notice shall be included in
         | 
| 13 | 
            +
            all copies or substantial portions of the Software.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 16 | 
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 17 | 
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         | 
| 18 | 
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 19 | 
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         | 
| 20 | 
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         | 
| 21 | 
            +
            THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,54 @@ | |
| 1 | 
            +
            ffi-expat
         | 
| 2 | 
            +
            =========
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            ffi-expat is a Ruby FFI wrapper for the expat XML parsing library.
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Installation
         | 
| 7 | 
            +
            ============
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                [sudo] gem install ffi-zlib
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            SAMPLE USAGE
         | 
| 12 | 
            +
            ============
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            ffi-expat is a thin wrapper around the expat calls so using ffi-expat in Ruby is similar to the way you would use expat in C (modulo the obious language specifics).
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            Here's a simple example which counts the number of each start tags:
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            	require "rubygems"
         | 
| 19 | 
            +
            	require "ffi/expat"
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            	class Handler
         | 
| 22 | 
            +
            		attr_reader :starts
         | 
| 23 | 
            +
            	    def initialize
         | 
| 24 | 
            +
            	        @starts = Hash.new
         | 
| 25 | 
            +
            	    end
         | 
| 26 | 
            +
            	    def start_elem(parser, tag, attrs)
         | 
| 27 | 
            +
            	        if @starts.has_key?(tag)
         | 
| 28 | 
            +
            	            @starts[tag] += 1
         | 
| 29 | 
            +
            	        else
         | 
| 30 | 
            +
            	            @starts[tag] = 1
         | 
| 31 | 
            +
            	        end
         | 
| 32 | 
            +
            	    end
         | 
| 33 | 
            +
            	end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            	xml = File.read("test.xml")
         | 
| 36 | 
            +
            	handler = Handler.new
         | 
| 37 | 
            +
            	parser = FFI::Expat.XML_ParserCreate(nil)
         | 
| 38 | 
            +
            	FFI::Expat.XML_SetStartElementHandler(parser, handler.method(:start_elem))
         | 
| 39 | 
            +
            	FFI::Expat.XML_Parse(parser, xml, xml.length, true)
         | 
| 40 | 
            +
            	FFI::Expat.XML_ParserFree(parser)
         | 
| 41 | 
            +
            	
         | 
| 42 | 
            +
            	handler.starts.each do |tag, count|
         | 
| 43 | 
            +
            		puts "#{tag}: #{count}"
         | 
| 44 | 
            +
            	end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            AUTHORS 
         | 
| 47 | 
            +
            ==============
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            Luc Heinrich <luc@honk-honk.com>
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            LICENSE
         | 
| 52 | 
            +
            ==============
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            MIT.
         | 
    
        data/lib/ffi/expat.rb
    ADDED
    
    | @@ -0,0 +1,250 @@ | |
| 1 | 
            +
            require "ffi"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # =============================================================================
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module FFI::Expat
         | 
| 6 | 
            +
                extend FFI::Library
         | 
| 7 | 
            +
                ffi_lib "expat"
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                # -------------------------------------------------------------------------
         | 
| 10 | 
            +
                
         | 
| 11 | 
            +
                typedef :pointer, :XML_Parser
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                # -------------------------------------------------------------------------
         | 
| 14 | 
            +
                
         | 
| 15 | 
            +
                enum :XML_Status, [         :XML_STATUS_ERROR, 
         | 
| 16 | 
            +
                                            :XML_STATUS_OK,
         | 
| 17 | 
            +
                                            :XML_STATUS_SUSPENDED]
         | 
| 18 | 
            +
                
         | 
| 19 | 
            +
                enum :XML_Error, [          :XML_ERROR_NONE,
         | 
| 20 | 
            +
                                            :XML_ERROR_NO_MEMORY,
         | 
| 21 | 
            +
                                            :XML_ERROR_SYNTAX,
         | 
| 22 | 
            +
                                            :XML_ERROR_NO_ELEMENTS,
         | 
| 23 | 
            +
                                            :XML_ERROR_INVALID_TOKEN,
         | 
| 24 | 
            +
                                            :XML_ERROR_UNCLOSED_TOKEN,
         | 
| 25 | 
            +
                                            :XML_ERROR_PARTIAL_CHAR,
         | 
| 26 | 
            +
                                            :XML_ERROR_TAG_MISMATCH,
         | 
| 27 | 
            +
                                            :XML_ERROR_DUPLICATE_ATTRIBUTE,
         | 
| 28 | 
            +
                                            :XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
         | 
| 29 | 
            +
                                            :XML_ERROR_PARAM_ENTITY_REF,
         | 
| 30 | 
            +
                                            :XML_ERROR_UNDEFINED_ENTITY,
         | 
| 31 | 
            +
                                            :XML_ERROR_RECURSIVE_ENTITY_REF,
         | 
| 32 | 
            +
                                            :XML_ERROR_ASYNC_ENTITY,
         | 
| 33 | 
            +
                                            :XML_ERROR_BAD_CHAR_REF,
         | 
| 34 | 
            +
                                            :XML_ERROR_BINARY_ENTITY_REF,
         | 
| 35 | 
            +
                                            :XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
         | 
| 36 | 
            +
                                            :XML_ERROR_MISPLACED_XML_PI,
         | 
| 37 | 
            +
                                            :XML_ERROR_UNKNOWN_ENCODING,
         | 
| 38 | 
            +
                                            :XML_ERROR_INCORRECT_ENCODING,
         | 
| 39 | 
            +
                                            :XML_ERROR_UNCLOSED_CDATA_SECTION,
         | 
| 40 | 
            +
                                            :XML_ERROR_EXTERNAL_ENTITY_HANDLING,
         | 
| 41 | 
            +
                                            :XML_ERROR_NOT_STANDALONE,
         | 
| 42 | 
            +
                                            :XML_ERROR_UNEXPECTED_STATE,
         | 
| 43 | 
            +
                                            :XML_ERROR_ENTITY_DECLARED_IN_PE,
         | 
| 44 | 
            +
                                            :XML_ERROR_FEATURE_REQUIRES_XML_DTD,
         | 
| 45 | 
            +
                                            :XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
         | 
| 46 | 
            +
                                            # Added in 1.95.7
         | 
| 47 | 
            +
                                            :XML_ERROR_UNBOUND_PREFIX,
         | 
| 48 | 
            +
                                            # Added in 1.95.8.
         | 
| 49 | 
            +
                                            :XML_ERROR_UNDECLARING_PREFIX,
         | 
| 50 | 
            +
                                            :XML_ERROR_INCOMPLETE_PE,
         | 
| 51 | 
            +
                                            :XML_ERROR_XML_DECL,
         | 
| 52 | 
            +
                                            :XML_ERROR_TEXT_DECL,
         | 
| 53 | 
            +
                                            :XML_ERROR_PUBLICID,
         | 
| 54 | 
            +
                                            :XML_ERROR_SUSPENDED,
         | 
| 55 | 
            +
                                            :XML_ERROR_NOT_SUSPENDED,
         | 
| 56 | 
            +
                                            :XML_ERROR_ABORTED,
         | 
| 57 | 
            +
                                            :XML_ERROR_FINISHED,
         | 
| 58 | 
            +
                                            :XML_ERROR_SUSPEND_PE,
         | 
| 59 | 
            +
                                            # Added in 2.0
         | 
| 60 | 
            +
                                            :XML_ERROR_RESERVED_PREFIX_XML,
         | 
| 61 | 
            +
                                            :XML_ERROR_RESERVED_PREFIX_XMLNS,
         | 
| 62 | 
            +
                                            :XML_ERROR_RESERVED_NAMESPACE_URI ]
         | 
| 63 | 
            +
                
         | 
| 64 | 
            +
                # -------------------------------------------------------------------------
         | 
| 65 | 
            +
                
         | 
| 66 | 
            +
                enum :XML_Content_Type, [   :XML_CTYPE_EMPTY, 1,
         | 
| 67 | 
            +
                                            :XML_CTYPE_ANY,
         | 
| 68 | 
            +
                                            :XML_CTYPE_MIXED,
         | 
| 69 | 
            +
                                            :XML_CTYPE_NAME,
         | 
| 70 | 
            +
                                            :XML_CTYPE_CHOICE,
         | 
| 71 | 
            +
                                            :XML_CTYPE_SEQ ]
         | 
| 72 | 
            +
                
         | 
| 73 | 
            +
                enum :XML_Content_Quant, [  :XML_CQUANT_NONE,
         | 
| 74 | 
            +
                                            :XML_CQUANT_OPT,
         | 
| 75 | 
            +
                                            :XML_CQUANT_REP,
         | 
| 76 | 
            +
                                            :XML_CQUANT_PLUS ]
         | 
| 77 | 
            +
                
         | 
| 78 | 
            +
                class XML_Content < FFI::Struct
         | 
| 79 | 
            +
                    layout  :type,          :XML_Content_Type,
         | 
| 80 | 
            +
                            :quant,         :XML_Content_Quant,
         | 
| 81 | 
            +
                            :name,          :string,
         | 
| 82 | 
            +
                            :numchildren,   :int,
         | 
| 83 | 
            +
                            :children,      :pointer
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
                    
         | 
| 86 | 
            +
                attach_function :XML_ParserCreate, [:string], :XML_Parser
         | 
| 87 | 
            +
                attach_function :XML_ParserCreateNS, [:string, :char], :XML_Parser
         | 
| 88 | 
            +
                attach_function :XML_ParserReset, [:XML_Parser, :string], :bool
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                callback :XML_ElementDeclHandler, [:pointer, :string, XML_Content], :void
         | 
| 91 | 
            +
                attach_function :XML_SetElementDeclHandler, [:XML_Parser, :XML_ElementDeclHandler], :void
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                callback :XML_AttlistDeclHandler, [:pointer, :string, :string, :string, :string, :int], :void
         | 
| 94 | 
            +
                attach_function :XML_SetAttlistDeclHandler, [:XML_Parser, :XML_AttlistDeclHandler], :void
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                callback :XML_XmlDeclHandler, [:pointer, :string, :string, :int], :void
         | 
| 97 | 
            +
                attach_function :XML_SetXmlDeclHandler, [:XML_Parser, :XML_XmlDeclHandler], :void
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                callback :XML_Encoding_convert, [:pointer, :string], :int
         | 
| 100 | 
            +
                callback :XML_Encoding_release, [:pointer], :void
         | 
| 101 | 
            +
                class XML_Encoding < FFI::Struct
         | 
| 102 | 
            +
                    layout  :map,                   [:char, 256],
         | 
| 103 | 
            +
                            :data,                  :pointer,
         | 
| 104 | 
            +
                            :convert,               :XML_Encoding_convert,
         | 
| 105 | 
            +
                            :release,               :XML_Encoding_release
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                callback :XML_StartElementHandler, [:pointer, :string, :pointer], :void
         | 
| 109 | 
            +
                callback :XML_EndElementHandler, [:pointer, :string], :void
         | 
| 110 | 
            +
                attach_function :XML_SetElementHandler, [:XML_Parser, :XML_StartElementHandler, :XML_EndElementHandler], :void
         | 
| 111 | 
            +
                attach_function :XML_SetStartElementHandler, [:XML_Parser, :XML_StartElementHandler], :void
         | 
| 112 | 
            +
                attach_function :XML_SetEndElementHandler, [:XML_Parser, :XML_EndElementHandler], :void
         | 
| 113 | 
            +
                attach_function :XML_GetSpecifiedAttributeCount, [:XML_Parser], :int
         | 
| 114 | 
            +
                attach_function :XML_GetIdAttributeIndex, [:XML_Parser], :int
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                callback :XML_CharacterDataHandler, [:pointer, :pointer, :int], :void
         | 
| 117 | 
            +
                attach_function :XML_SetCharacterDataHandler, [:XML_Parser, :XML_CharacterDataHandler], :void
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                callback :XML_ProcessingInstructionHandler, [:pointer, :string, :string], :void
         | 
| 120 | 
            +
                attach_function :XML_SetProcessingInstructionHandler, [:XML_Parser, :XML_ProcessingInstructionHandler], :void
         | 
| 121 | 
            +
             | 
| 122 | 
            +
                callback :XML_CommentHandler, [:pointer, :string], :void
         | 
| 123 | 
            +
                attach_function :XML_SetCommentHandler, [:XML_Parser, :XML_CommentHandler], :void
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                callback :XML_StartCdataSectionHandler, [:pointer], :void
         | 
| 126 | 
            +
                callback :XML_EndCdataSectionHandler, [:pointer], :void
         | 
| 127 | 
            +
                attach_function :XML_SetCdataSectionHandler, [:XML_Parser, :XML_StartCdataSectionHandler, :XML_EndCdataSectionHandler], :void
         | 
| 128 | 
            +
                attach_function :XML_SetStartCdataSectionHandler, [:XML_Parser, :XML_StartCdataSectionHandler], :void
         | 
| 129 | 
            +
                attach_function :XML_SetEndCdataSectionHandler, [:XML_Parser, :XML_EndCdataSectionHandler], :void
         | 
| 130 | 
            +
                
         | 
| 131 | 
            +
                callback :XML_DefaultHandler, [:pointer, :pointer, :int], :void
         | 
| 132 | 
            +
                attach_function :XML_SetDefaultHandler, [:XML_Parser, :XML_DefaultHandler], :void
         | 
| 133 | 
            +
                attach_function :XML_SetDefaultHandlerExpand, [:XML_Parser, :XML_DefaultHandler], :void
         | 
| 134 | 
            +
                
         | 
| 135 | 
            +
                callback :XML_StartDoctypeDeclHandler, [:pointer, :string, :string, :string, :int], :void
         | 
| 136 | 
            +
                callback :XML_EndDoctypeDeclHandler, [:pointer, :pointer], :void
         | 
| 137 | 
            +
                attach_function :XML_SetDoctypeDeclHandler, [:XML_Parser, :XML_StartDoctypeDeclHandler, :XML_EndDoctypeDeclHandler], :void
         | 
| 138 | 
            +
                attach_function :XML_SetStartDoctypeDeclHandler, [:XML_Parser, :XML_StartDoctypeDeclHandler], :void
         | 
| 139 | 
            +
                attach_function :XML_SetEndDoctypeDeclHandler, [:XML_Parser, :XML_EndDoctypeDeclHandler], :void
         | 
| 140 | 
            +
                
         | 
| 141 | 
            +
                callback :XML_EntityDeclHandler, [:pointer, :string, :int, :pointer, :int, :string, :string, :string, :string], :void
         | 
| 142 | 
            +
                attach_function :XML_SetEntityDeclHandler, [:XML_Parser, :XML_EntityDeclHandler], :void
         | 
| 143 | 
            +
             | 
| 144 | 
            +
                callback :XML_NotationDeclHandler, [:pointer, :string, :string, :string, :string], :void
         | 
| 145 | 
            +
                attach_function :XML_SetNotationDeclHandler, [:XML_Parser, :XML_NotationDeclHandler], :void
         | 
| 146 | 
            +
                
         | 
| 147 | 
            +
                callback :XML_StartNamespaceDeclHandler, [:pointer, :string, :string], :void
         | 
| 148 | 
            +
                callback :XML_EndNamespaceDeclHandler, [:pointer, :string], :void
         | 
| 149 | 
            +
                attach_function :XML_SetNamespaceDeclHandler, [:XML_Parser, :XML_StartNamespaceDeclHandler, :XML_EndNamespaceDeclHandler], :void
         | 
| 150 | 
            +
                attach_function :XML_SetStartNamespaceDeclHandler, [:XML_Parser, :XML_StartNamespaceDeclHandler], :void
         | 
| 151 | 
            +
                attach_function :XML_SetEndNamespaceDeclHandler, [:XML_Parser, :XML_EndNamespaceDeclHandler], :void
         | 
| 152 | 
            +
                
         | 
| 153 | 
            +
                callback :XML_NotStandaloneHandler, [:pointer], :void
         | 
| 154 | 
            +
                attach_function :XML_SetNotStandaloneHandler, [:XML_Parser, :XML_NotStandaloneHandler], :void
         | 
| 155 | 
            +
                
         | 
| 156 | 
            +
                callback :XML_ExternalEntityRefHandler, [:pointer, :string, :string, :string, :string], :void
         | 
| 157 | 
            +
                attach_function :XML_SetExternalEntityRefHandler, [:XML_Parser, :XML_ExternalEntityRefHandler], :void
         | 
| 158 | 
            +
                
         | 
| 159 | 
            +
                callback :XML_SkippedEntityHandler, [:pointer, :string, :int], :void
         | 
| 160 | 
            +
                attach_function :XML_SetExternalEntityRefHandlerArg, [:XML_Parser, :pointer], :void
         | 
| 161 | 
            +
                attach_function :XML_SetSkippedEntityHandler, [:XML_Parser, :XML_SkippedEntityHandler], :void
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                callback :XML_UnknownEncodingHandler, [:pointer, :string, XML_Encoding], :int
         | 
| 164 | 
            +
                attach_function :XML_SetUnknownEncodingHandler, [:XML_Parser, :XML_UnknownEncodingHandler, :pointer], :void
         | 
| 165 | 
            +
             | 
| 166 | 
            +
                # -------------------------------------------------------------------------
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                attach_function :XML_DefaultCurrent, [:XML_Parser], :void
         | 
| 169 | 
            +
                attach_function :XML_SetReturnNSTriplet, [:XML_Parser, :int], :void
         | 
| 170 | 
            +
                attach_function :XML_SetUserData, [:XML_Parser, :pointer], :void
         | 
| 171 | 
            +
                attach_function :XML_SetEncoding, [:XML_Parser, :string], :XML_Status
         | 
| 172 | 
            +
                attach_function :XML_UseParserAsHandlerArg, [:XML_Parser], :void
         | 
| 173 | 
            +
                attach_function :XML_UseForeignDTD, [:XML_Parser, :bool], :XML_Error
         | 
| 174 | 
            +
                attach_function :XML_SetBase, [:XML_Parser, :string], :XML_Status
         | 
| 175 | 
            +
                attach_function :XML_GetBase, [:XML_Parser], :string
         | 
| 176 | 
            +
             | 
| 177 | 
            +
                # -------------------------------------------------------------------------
         | 
| 178 | 
            +
             | 
| 179 | 
            +
                attach_function :XML_Parse, [:XML_Parser, :pointer, :int, :bool], :XML_Status
         | 
| 180 | 
            +
                attach_function :XML_GetBuffer, [:XML_Parser, :int], :pointer
         | 
| 181 | 
            +
                attach_function :XML_ParseBuffer, [:XML_Parser, :int, :int], :XML_Status
         | 
| 182 | 
            +
                attach_function :XML_StopParser, [:XML_Parser, :bool], :XML_Status
         | 
| 183 | 
            +
                attach_function :XML_ResumeParser, [:XML_Parser], :XML_Status
         | 
| 184 | 
            +
             | 
| 185 | 
            +
                enum :XML_Parsing, [:XML_INITIALIZED, :XML_PARSING, :XML_FINISHED, :XML_SUSPENDED]
         | 
| 186 | 
            +
                class XML_ParsingStatus < FFI::Struct
         | 
| 187 | 
            +
                    layout  :parsing,       :XML_Parsing,
         | 
| 188 | 
            +
                            :finalBuffer,   :bool
         | 
| 189 | 
            +
                end
         | 
| 190 | 
            +
                attach_function :XML_GetParsingStatus, [:XML_Parser, :buffer_out], :void
         | 
| 191 | 
            +
             | 
| 192 | 
            +
                # -------------------------------------------------------------------------
         | 
| 193 | 
            +
             | 
| 194 | 
            +
                enum :XML_ParamEntityParsing, [:XML_PARAM_ENTITY_PARSING_NEVER, :XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE, :XML_PARAM_ENTITY_PARSING_ALWAYS]
         | 
| 195 | 
            +
             | 
| 196 | 
            +
                attach_function :XML_ExternalEntityParserCreate, [:XML_Parser, :string, :string], :XML_Parser
         | 
| 197 | 
            +
                attach_function :XML_SetParamEntityParsing, [:XML_Parser, :XML_ParamEntityParsing], :int
         | 
| 198 | 
            +
             | 
| 199 | 
            +
                # -------------------------------------------------------------------------
         | 
| 200 | 
            +
             | 
| 201 | 
            +
                attach_function :XML_GetErrorCode, [:XML_Parser], :XML_Error
         | 
| 202 | 
            +
                attach_function :XML_GetCurrentLineNumber, [:XML_Parser], :ulong
         | 
| 203 | 
            +
                attach_function :XML_GetCurrentColumnNumber, [:XML_Parser], :ulong
         | 
| 204 | 
            +
                attach_function :XML_GetCurrentByteIndex, [:XML_Parser], :ulong
         | 
| 205 | 
            +
                attach_function :XML_GetCurrentByteCount, [:XML_Parser], :int
         | 
| 206 | 
            +
                attach_function :XML_GetInputContext, [:XML_Parser, :buffer_out, :buffer_out], :pointer
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                # -------------------------------------------------------------------------
         | 
| 209 | 
            +
             | 
| 210 | 
            +
                attach_function :XML_FreeContentModel, [:XML_Parser, :pointer], :void
         | 
| 211 | 
            +
                attach_function :XML_ParserFree, [:XML_Parser], :void
         | 
| 212 | 
            +
                attach_function :XML_ErrorString, [:XML_Error], :string
         | 
| 213 | 
            +
             | 
| 214 | 
            +
                # -------------------------------------------------------------------------
         | 
| 215 | 
            +
                
         | 
| 216 | 
            +
                class XML_Expat_Version < FFI::Struct
         | 
| 217 | 
            +
                    layout  :major, :int, 
         | 
| 218 | 
            +
                            :minor, :int, 
         | 
| 219 | 
            +
                            :micro, :int
         | 
| 220 | 
            +
                end
         | 
| 221 | 
            +
             | 
| 222 | 
            +
                attach_function :XML_ExpatVersion, [ ], :string
         | 
| 223 | 
            +
                attach_function :XML_ExpatVersionInfo, [ ], XML_Expat_Version.by_value
         | 
| 224 | 
            +
             | 
| 225 | 
            +
                # -------------------------------------------------------------------------
         | 
| 226 | 
            +
                
         | 
| 227 | 
            +
                enum :XML_FeatureEnum, [:XML_FEATURE_END,
         | 
| 228 | 
            +
                                        :XML_FEATURE_UNICODE,
         | 
| 229 | 
            +
                                        :XML_FEATURE_UNICODE_WCHAR_T,
         | 
| 230 | 
            +
                                        :XML_FEATURE_DTD,
         | 
| 231 | 
            +
                                        :XML_FEATURE_CONTEXT_BYTES,
         | 
| 232 | 
            +
                                        :XML_FEATURE_MIN_SIZE,
         | 
| 233 | 
            +
                                        :XML_FEATURE_SIZEOF_XML_CHAR,
         | 
| 234 | 
            +
                                        :XML_FEATURE_SIZEOF_XML_LCHAR,
         | 
| 235 | 
            +
                                        :XML_FEATURE_NS,
         | 
| 236 | 
            +
                                        :XML_FEATURE_LARGE_SIZE ]
         | 
| 237 | 
            +
                
         | 
| 238 | 
            +
                class XML_Feature < FFI::Struct
         | 
| 239 | 
            +
                    layout :feature, :XML_FeatureEnum,
         | 
| 240 | 
            +
                           :name,    :string,
         | 
| 241 | 
            +
                           :value,   :long
         | 
| 242 | 
            +
                end
         | 
| 243 | 
            +
                
         | 
| 244 | 
            +
                attach_function :XML_GetFeatureList, [ ], :pointer
         | 
| 245 | 
            +
             | 
| 246 | 
            +
                # -------------------------------------------------------------------------
         | 
| 247 | 
            +
             | 
| 248 | 
            +
            end
         | 
| 249 | 
            +
             | 
| 250 | 
            +
            # =============================================================================
         | 
| @@ -0,0 +1,120 @@ | |
| 1 | 
            +
            <?xml version="1.0"?>
         | 
| 2 | 
            +
            <catalog>
         | 
| 3 | 
            +
               <book id="bk101">
         | 
| 4 | 
            +
                  <author>Gambardella, Matthew</author>
         | 
| 5 | 
            +
                  <title>XML Developer's Guide</title>
         | 
| 6 | 
            +
                  <genre>Computer</genre>
         | 
| 7 | 
            +
                  <price>44.95</price>
         | 
| 8 | 
            +
                  <publish_date>2000-10-01</publish_date>
         | 
| 9 | 
            +
                  <description>An in-depth look at creating applications 
         | 
| 10 | 
            +
                  with XML.</description>
         | 
| 11 | 
            +
               </book>
         | 
| 12 | 
            +
               <book id="bk102">
         | 
| 13 | 
            +
                  <author>Ralls, Kim</author>
         | 
| 14 | 
            +
                  <title>Midnight Rain</title>
         | 
| 15 | 
            +
                  <genre>Fantasy</genre>
         | 
| 16 | 
            +
                  <price>5.95</price>
         | 
| 17 | 
            +
                  <publish_date>2000-12-16</publish_date>
         | 
| 18 | 
            +
                  <description>A former architect battles corporate zombies, 
         | 
| 19 | 
            +
                  an evil sorceress, and her own childhood to become queen 
         | 
| 20 | 
            +
                  of the world.</description>
         | 
| 21 | 
            +
               </book>
         | 
| 22 | 
            +
               <book id="bk103">
         | 
| 23 | 
            +
                  <author>Corets, Eva</author>
         | 
| 24 | 
            +
                  <title>Maeve Ascendant</title>
         | 
| 25 | 
            +
                  <genre>Fantasy</genre>
         | 
| 26 | 
            +
                  <price>5.95</price>
         | 
| 27 | 
            +
                  <publish_date>2000-11-17</publish_date>
         | 
| 28 | 
            +
                  <description>After the collapse of a nanotechnology 
         | 
| 29 | 
            +
                  society in England, the young survivors lay the 
         | 
| 30 | 
            +
                  foundation for a new society.</description>
         | 
| 31 | 
            +
               </book>
         | 
| 32 | 
            +
               <book id="bk104">
         | 
| 33 | 
            +
                  <author>Corets, Eva</author>
         | 
| 34 | 
            +
                  <title>Oberon's Legacy</title>
         | 
| 35 | 
            +
                  <genre>Fantasy</genre>
         | 
| 36 | 
            +
                  <price>5.95</price>
         | 
| 37 | 
            +
                  <publish_date>2001-03-10</publish_date>
         | 
| 38 | 
            +
                  <description>In post-apocalypse England, the mysterious 
         | 
| 39 | 
            +
                  agent known only as Oberon helps to create a new life 
         | 
| 40 | 
            +
                  for the inhabitants of London. Sequel to Maeve 
         | 
| 41 | 
            +
                  Ascendant.</description>
         | 
| 42 | 
            +
               </book>
         | 
| 43 | 
            +
               <book id="bk105">
         | 
| 44 | 
            +
                  <author>Corets, Eva</author>
         | 
| 45 | 
            +
                  <title>The Sundered Grail</title>
         | 
| 46 | 
            +
                  <genre>Fantasy</genre>
         | 
| 47 | 
            +
                  <price>5.95</price>
         | 
| 48 | 
            +
                  <publish_date>2001-09-10</publish_date>
         | 
| 49 | 
            +
                  <description>The two daughters of Maeve, half-sisters, 
         | 
| 50 | 
            +
                  battle one another for control of England. Sequel to 
         | 
| 51 | 
            +
                  Oberon's Legacy.</description>
         | 
| 52 | 
            +
               </book>
         | 
| 53 | 
            +
               <book id="bk106">
         | 
| 54 | 
            +
                  <author>Randall, Cynthia</author>
         | 
| 55 | 
            +
                  <title>Lover Birds</title>
         | 
| 56 | 
            +
                  <genre>Romance</genre>
         | 
| 57 | 
            +
                  <price>4.95</price>
         | 
| 58 | 
            +
                  <publish_date>2000-09-02</publish_date>
         | 
| 59 | 
            +
                  <description>When Carla meets Paul at an ornithology 
         | 
| 60 | 
            +
                  conference, tempers fly as feathers get ruffled.</description>
         | 
| 61 | 
            +
               </book>
         | 
| 62 | 
            +
               <book id="bk107">
         | 
| 63 | 
            +
                  <author>Thurman, Paula</author>
         | 
| 64 | 
            +
                  <title>Splish Splash</title>
         | 
| 65 | 
            +
                  <genre>Romance</genre>
         | 
| 66 | 
            +
                  <price>4.95</price>
         | 
| 67 | 
            +
                  <publish_date>2000-11-02</publish_date>
         | 
| 68 | 
            +
                  <description>A deep sea diver finds true love twenty 
         | 
| 69 | 
            +
                  thousand leagues beneath the sea.</description>
         | 
| 70 | 
            +
               </book>
         | 
| 71 | 
            +
               <book id="bk108">
         | 
| 72 | 
            +
                  <author>Knorr, Stefan</author>
         | 
| 73 | 
            +
                  <title>Creepy Crawlies</title>
         | 
| 74 | 
            +
                  <genre>Horror</genre>
         | 
| 75 | 
            +
                  <price>4.95</price>
         | 
| 76 | 
            +
                  <publish_date>2000-12-06</publish_date>
         | 
| 77 | 
            +
                  <description>An anthology of horror stories about roaches,
         | 
| 78 | 
            +
                  centipedes, scorpions  and other insects.</description>
         | 
| 79 | 
            +
               </book>
         | 
| 80 | 
            +
               <book id="bk109">
         | 
| 81 | 
            +
                  <author>Kress, Peter</author>
         | 
| 82 | 
            +
                  <title>Paradox Lost</title>
         | 
| 83 | 
            +
                  <genre>Science Fiction</genre>
         | 
| 84 | 
            +
                  <price>6.95</price>
         | 
| 85 | 
            +
                  <publish_date>2000-11-02</publish_date>
         | 
| 86 | 
            +
                  <description>After an inadvertant trip through a Heisenberg
         | 
| 87 | 
            +
                  Uncertainty Device, James Salway discovers the problems 
         | 
| 88 | 
            +
                  of being quantum.</description>
         | 
| 89 | 
            +
               </book>
         | 
| 90 | 
            +
               <book id="bk110">
         | 
| 91 | 
            +
                  <author>O'Brien, Tim</author>
         | 
| 92 | 
            +
                  <title>Microsoft .NET: The Programming Bible</title>
         | 
| 93 | 
            +
                  <genre>Computer</genre>
         | 
| 94 | 
            +
                  <price>36.95</price>
         | 
| 95 | 
            +
                  <publish_date>2000-12-09</publish_date>
         | 
| 96 | 
            +
                  <description>Microsoft's .NET initiative is explored in 
         | 
| 97 | 
            +
                  detail in this deep programmer's reference.</description>
         | 
| 98 | 
            +
               </book>
         | 
| 99 | 
            +
               <book id="bk111">
         | 
| 100 | 
            +
                  <author>O'Brien, Tim</author>
         | 
| 101 | 
            +
                  <title>MSXML3: A Comprehensive Guide</title>
         | 
| 102 | 
            +
                  <genre>Computer</genre>
         | 
| 103 | 
            +
                  <price>36.95</price>
         | 
| 104 | 
            +
                  <publish_date>2000-12-01</publish_date>
         | 
| 105 | 
            +
                  <description>The Microsoft MSXML3 parser is covered in 
         | 
| 106 | 
            +
                  detail, with attention to XML DOM interfaces, XSLT processing, 
         | 
| 107 | 
            +
                  SAX and more.</description>
         | 
| 108 | 
            +
               </book>
         | 
| 109 | 
            +
               <book id="bk112">
         | 
| 110 | 
            +
                  <author>Galos, Mike</author>
         | 
| 111 | 
            +
                  <title>Visual Studio 7: A Comprehensive Guide</title>
         | 
| 112 | 
            +
                  <genre>Computer</genre>
         | 
| 113 | 
            +
                  <price>49.95</price>
         | 
| 114 | 
            +
                  <publish_date>2001-04-16</publish_date>
         | 
| 115 | 
            +
                  <description>Microsoft Visual Studio 7 is explored in depth,
         | 
| 116 | 
            +
                  looking at how Visual Basic, Visual C++, C#, and ASP+ are 
         | 
| 117 | 
            +
                  integrated into a comprehensive development 
         | 
| 118 | 
            +
                  environment.</description>
         | 
| 119 | 
            +
               </book>
         | 
| 120 | 
            +
            </catalog>
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,83 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: ffi-expat
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              hash: 27
         | 
| 5 | 
            +
              prerelease: false
         | 
| 6 | 
            +
              segments: 
         | 
| 7 | 
            +
              - 0
         | 
| 8 | 
            +
              - 1
         | 
| 9 | 
            +
              - 0
         | 
| 10 | 
            +
              version: 0.1.0
         | 
| 11 | 
            +
            platform: ruby
         | 
| 12 | 
            +
            authors: 
         | 
| 13 | 
            +
            - Luc Heinrich
         | 
| 14 | 
            +
            autorequire: 
         | 
| 15 | 
            +
            bindir: bin
         | 
| 16 | 
            +
            cert_chain: []
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            date: 2010-05-31 00:00:00 +02:00
         | 
| 19 | 
            +
            default_executable: 
         | 
| 20 | 
            +
            dependencies: 
         | 
| 21 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 22 | 
            +
              name: ffi
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements: 
         | 
| 27 | 
            +
                - - ">="
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 29 | 
            +
                    hash: 3
         | 
| 30 | 
            +
                    segments: 
         | 
| 31 | 
            +
                    - 0
         | 
| 32 | 
            +
                    version: "0"
         | 
| 33 | 
            +
              type: :runtime
         | 
| 34 | 
            +
              version_requirements: *id001
         | 
| 35 | 
            +
            description: ffi-expat provides a very thin wrapper around expat using the Ruby FFI library.
         | 
| 36 | 
            +
            email: luc@honk-honk.com
         | 
| 37 | 
            +
            executables: []
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            extensions: []
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            extra_rdoc_files: []
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            files: 
         | 
| 44 | 
            +
            - lib/ffi/expat.rb
         | 
| 45 | 
            +
            - test/fixtures/sample.xml
         | 
| 46 | 
            +
            - README.md
         | 
| 47 | 
            +
            - LICENSE
         | 
| 48 | 
            +
            has_rdoc: true
         | 
| 49 | 
            +
            homepage: http://github.com/lucsky/ffi-expat
         | 
| 50 | 
            +
            licenses: []
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            post_install_message: 
         | 
| 53 | 
            +
            rdoc_options: []
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            require_paths: 
         | 
| 56 | 
            +
            - lib
         | 
| 57 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 58 | 
            +
              none: false
         | 
| 59 | 
            +
              requirements: 
         | 
| 60 | 
            +
              - - ">="
         | 
| 61 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 62 | 
            +
                  hash: 3
         | 
| 63 | 
            +
                  segments: 
         | 
| 64 | 
            +
                  - 0
         | 
| 65 | 
            +
                  version: "0"
         | 
| 66 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 67 | 
            +
              none: false
         | 
| 68 | 
            +
              requirements: 
         | 
| 69 | 
            +
              - - ">="
         | 
| 70 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 71 | 
            +
                  hash: 3
         | 
| 72 | 
            +
                  segments: 
         | 
| 73 | 
            +
                  - 0
         | 
| 74 | 
            +
                  version: "0"
         | 
| 75 | 
            +
            requirements: []
         | 
| 76 | 
            +
             | 
| 77 | 
            +
            rubyforge_project: 
         | 
| 78 | 
            +
            rubygems_version: 1.3.7
         | 
| 79 | 
            +
            signing_key: 
         | 
| 80 | 
            +
            specification_version: 3
         | 
| 81 | 
            +
            summary: FFI based wrapper for expat.
         | 
| 82 | 
            +
            test_files: []
         | 
| 83 | 
            +
             |