### ----------------------------------------------------
### -- LibXML
### -- Licenses: Artistic-2.0
### -- Authors: David Warring
### -- File: lib/LibXML/Raw.rakumod
### ----------------------------------------------------
### -- Chunk 4 of 4
),
        &close (Pointer --> int32)
         --> int32) is native($XML2) is symbol('xmlRegisterInputCallbacks') {*}
}

sub xmlLoadCatalog(Str --> int32) is native($XML2) is export {*}

## xmlInitParser() should be called once at start-up
sub xmlInitParser is native($XML2) is export {*}

## Globals aren't yet writable in Rakudo

method KeepBlanksDefault is rw {
    sub FETCH($) { ? xml6_gbl::get-keep-blanks() }
    sub STORE($, Bool() $_) {
        xml6_gbl::set-keep-blanks($_);
    }
    Proxy.new: :&FETCH, :&STORE;
}

method TagExpansion is rw {
    sub FETCH($) { ? xml6_gbl::get-tag-expansion() }
    sub STORE($, Bool() $_) {
        xml6_gbl::set-tag-expansion($_);
    }
    Proxy.new: :&FETCH, :&STORE;
}

module xmlExternalEntityLoader is export {
    our sub NoNet(xmlCharP, xmlCharP, xmlParserCtxt --> xmlParserInput) is native($XML2) is symbol('xmlNoNetExternalEntityLoader') {*}
    our sub Set( &loader (xmlCharP, xmlCharP, xmlParserCtxt --> xmlParserInput) ) is native($BIND-XML2) is symbol('xml6_gbl_set_external_entity_loader') {*}
    our sub set-networked(int32 $ --> int32) is native($BIND-XML2) is symbol('xml6_gbl_set_external_entity_loader_net') {*}
}

method ExternalEntityLoader is rw {
    sub FETCH($) {
        nativecast( :(xmlCharP, xmlCharP, xmlParserCtxt --> xmlParserInput), xmlEntityLoader::Get())
    }
    sub STORE($, &loader) {
        xmlExternalEntityLoader::Set(&loader)
    }
    Proxy.new: :&FETCH, :&STORE;
}

INIT {
    xmlInitParser();
    xml6_gbl::init();
}

=begin pod

=head2 License

This program is free software; you can redistribute it and/or modify it under
the terms of the Artistic License 2.0 L<http://www.perlfoundation.org/artistic_license_2_0>.

=end pod


