Sha256: 3c90c22627f404595cf181fcaf0f2f625cdc8238f861e4c5b5bdb3a383eb0b46

Contents?: true

Size: 1.8 KB

Versions: 3

Compression:

Stored size: 1.8 KB

Contents

###
# wxRuby3 wxWidgets interface director
# Copyright (c) M.J.N. Corino, The Netherlands
###

module WXRuby3

  class Director

    class XmlNode < Director

      def setup
        super
        spec.disable_proxies
        spec.gc_as_untracked
        spec.disown 'wxXmlNode *child'
        # ignore this; only allow adding child node by explicitly calling Add/Insert-child methods (easier on the GC handling and avoids wxXmlAttribute)
        spec.ignore 'wxXmlNode::wxXmlNode(wxXmlNode *, wxXmlNodeType, const wxString &, const wxString &, wxXmlAttribute *, wxXmlNode *, int)'
        # avoid wxXmlAttribute
        spec.ignore 'wxXmlNode::GetAttributes() const' # add alternative returning list of names
        spec.ignore 'wxXmlNode::AddAttribute(wxXmlAttribute *)'
        spec.ignore 'wxXmlNode::SetAttributes(wxXmlAttribute *)'
        spec.ignore 'wxXmlNode::GetAttribute(const wxString &, wxString *) const' # implement pure Ruby alternative
        # ignore these, we want wxXmlNode mostly (only?) to be able to inspect custom nodes from an XmlResource
        # NOT to manipulate any nodes
        spec.ignore('wxXmlNode::SetChildren(wxXmlNode *)')
        spec.ignore('wxXmlNode::SetParent(wxXmlNode *)')
        spec.ignore('wxXmlNode::SetNext(wxXmlNode *)')
        spec.ignore('wxXmlNode::RemoveChild(wxXmlNode *)')
        spec.add_extend_code 'wxXmlNode', <<~__HEREDOC
          VALUE GetAttributes()
          {
            VALUE result = rb_ary_new();
            wxXmlAttribute* attptr = self->GetAttributes();
            while (attptr)
            {
              rb_ary_push(result, WXSTR_TO_RSTR(attptr->GetName()));
              attptr = attptr->GetNext();
            }
            return result;
          }
          __HEREDOC
      end
    end # class XmlNode

  end # class Director

end # module WXRuby3

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wxruby3-0.9.0.pre.rc.3 rakelib/lib/director/xml_node.rb
wxruby3-0.9.0.pre.rc.2 rakelib/lib/director/xml_node.rb
wxruby3-0.9.0.pre.rc.1 rakelib/lib/director/xml_node.rb