jasonroelofs/rbplusplus

Parsing error when namespaces found in headers

Closed this issue · 11 comments

We have header files that already belong to existing namespaces. As soon as the parser encounters anything that is namespaced it crashes with the following output.

(INFO) Parsing ["testing.h"]
/home/tmux/.rvm/gems/ruby-1.9.3-p545@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:220: warning: Insecure world writable dir /opt/tools in PATH, mode 040777
/home/tmux/.rvm/gems/ruby-1.9.3-p545@global/gems/bundler-1.5.3/lib/bundler.rb:295: warning: Insecure world writable dir /opt/tools in PATH, mode 040777
/home/tmux/.rvm/gems/ruby-1.9.3-p545/bundler/gems/rbgccxml-da76add8d536/lib/rbgccxml/sax_parser.rb:46:in `const_get': uninitialized constant RbGCCXML::NamespaceAlias (NameError)
    from /home/tmux/.rvm/gems/ruby-1.9.3-p545/bundler/gems/rbgccxml-da76add8d536/lib/rbgccxml/sax_parser.rb:46:in `start_element'
    from /home/tmux/.rvm/gems/ruby-1.9.3-p545/gems/nokogiri-1.5.9/lib/nokogiri/xml/sax/document.rb:116:in `start_element_namespace'
    from /home/tmux/.rvm/gems/ruby-1.9.3-p545/gems/nokogiri-1.5.9/lib/nokogiri/xml/sax/parser.rb:95:in `parse_with'
    from /home/tmux/.rvm/gems/ruby-1.9.3-p545/gems/nokogiri-1.5.9/lib/nokogiri/xml/sax/parser.rb:95:in `parse_io'
    from /home/tmux/.rvm/gems/ruby-1.9.3-p545/gems/nokogiri-1.5.9/lib/nokogiri/xml/sax/parser.rb:82:in `parse'
    from /home/tmux/.rvm/gems/ruby-1.9.3-p545/bundler/gems/rbgccxml-da76add8d536/lib/rbgccxml/sax_parser.rb:15:in `parse'
    from /home/tmux/.rvm/gems/ruby-1.9.3-p545/bundler/gems/rbgccxml-da76add8d536/lib/rbgccxml/parser.rb:67:in `parse'
    from /home/tmux/.rvm/gems/ruby-1.9.3-p545/bundler/gems/rbgccxml-da76add8d536/lib/rbgccxml/rbgccxml.rb:27:in `parse'
    from /home/tmux/.rvm/gems/ruby-1.9.3-p545/bundler/gems/rbplusplus-82d025aa0232/lib/rbplusplus/extension.rb:163:in `sources'
    from generate.rb:6:in `block in <main>'
    from /home/tmux/.rvm/gems/ruby-1.9.3-p545/bundler/gems/rbplusplus-82d025aa0232/lib/rbplusplus/extension.rb:82:in `call'
    from /home/tmux/.rvm/gems/ruby-1.9.3-p545/bundler/gems/rbplusplus-82d025aa0232/lib/rbplusplus/extension.rb:82:in `initialize'
    from generate.rb:5:in `new'
    from generate.rb:5:in `<main>'

It seems rbgccxml is missing some constants that are produced from nokogiri?

Must be, I've never seen the NamespaceAlias tag before. What version / build of gcc-xml are you using?

GCC-XML version 0.9.0

And could I see the header files in question, or an example that shows this failure?

Cool, thanks. I'll see what I can do about that.

I added the following to rbgccxml/nodes/namespace.rb and it at least compiles. I've yet to test the result though.

class NamespaceAlias < Node
end

Also is there a way to wrap something that is in a nested namespace such as...

namesapce foo {
  namespace bar {
    // stuff i want to wrap
  }
}

That should just work. Are you seeing otherwise?

It was not resolving the namespace. It might be because the foo:bar namespace was linking to a library we install. Not quite sure, ended up re-factoring to have everything use the test namespace.

The generated code is working now, just working on getting it to tie in properly with our tests.

rbgccxml 1.0.4 is out that supports NamespaceAlias nodes.

Yep. Tested it out and it is working great. If I have continued troubles
with nested name spacing I'll file a separate issue.

Thanks for the quick feedback and commit.
On May 5, 2014 12:35 PM, "Jason Roelofs" notifications@github.com wrote:

rbgccxml 1.0.4 is out that supports NamespaceAlias nodes.


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-42207707
.