Ahh; this was sent to my private address as well and so cython-dev in its wisdom decided not to send me a copy from the mailing list. Forwarding my response to the mailing list as well then.
-------- Original Message -------- Subject: Re: [Cython] Beginner-friendly tickets Date: Mon, 16 Mar 2009 08:23:26 +0100 From: Dag Sverre Seljebotn <[email protected]> To: Kurt Smith <[email protected]> References: <[email protected]> <[email protected]> <[email protected]> <[email protected]> <[email protected]> Kurt Smith wrote: > Thanks for the guidance -- I'm making progress but I can't figure out one > issue: > > when I add the following method to AnalyzeDeclarationsTransform > everything works as expected: > > def visit_NameNode(self, node): > print node.dump() > return node > > It is called for every name node in the parse tree. > > but this one is not called for every matching node: > > def visit_CNameDeclaratorNode(self, node): > print node.dump() > return node > > Specifically, it is only called when the CNameDeclaratorNode is part > of (a descendant of) a CArgDeclNode. When it's part of (a descendant > of) a CVarDefNode it is not called. Great that you're making progress. Yes, there is something I'd rather tell you about this :-) The transform works by recursive descent, and when a node type is intercepted, one needs to actively visit the children as well. This is done by self.visitchildren(node); see in visit_FuncDefNode for an example. Since visitchildren is never called in CVarDefNode, the children of CVarDefNode are never visited. Also, the node will be replaced with whatever it returns. visit_CVarDefNode returns None so that the entire declaration is removed from the tree, as it is no longer needed (which is why one isn't analysing the children as well). (Depending on what you need this for, you could be able to extract the information from the attributes of the enclosing FuncDefNode; I think there's a Scope there somewhere which you can inspect the entries of.) -- Dag Sverre -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
