Re: [pygccxml-development] Additional attribute functionality
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2007-12-04 20:28:41
|
On Dec 4, 2007 9:58 PM, Ben Schleimer <bsc...@lu...> wrote:
> Hi Roman,
> Another thing to keep in mind for after 1.0 is that the scopedef is
> very difficult to work with.
> When I write class_.member_function("foobar"), I expect either a value or
> None to be returned. I don't expect an exception to be thrown
> likewise, I'd like to see class_.member_functions("foobar") to return a
> list of declarations, zero if no declaration matches. Again, no exception
> should be through.
> Then I can take the list and manipulate it like a normal python list.
>
Did you read this
http://language-binding.net/pygccxml/query_interface.htmldocument? The
behavior you are talking about was implemented intentionally.
I prefer to think about "mem_fun" as "get" function, which should raise in
error if there is 0 or 2+ member functions with the same name. The behavior
you propose doesn't distinct between these cases. On the other side raised
exception contains enough information to explain what went wrong.
I think about "mem_fun*s*" as a query function, it can return zero or more
items that match search criteria. You can customize the behavior of this
function. By default it raises an exception if no match was found. Pass
"allow_empty=True" as function argument to disable exception if no match was
found. I understand that not everyone agrees with such behavior, so
scopedef_t.ALLOW_EMPTY_MDECL_WRAPPER variable was introduced. You can set it
to False, after this "mem_fun*s*" method will not raise exception on "no
match".
Now, the return value of the "mem_fun*s*" method is very carefully
constructed class that allows the user to avoid writing of loops.
Link to the class
http://language-binding.net/pygccxml/apidocs/pygccxml.declarations.mdecl_wrapper.mdecl_wrapper_t-class.html
The class implements "container" interface and in general you should not
notice the difference between it and the list class.
I am using pygccxml for code generation projects. May be you are right and
the interface is really "less than intuitive", but it is very valuable for
code generation projects maintenance. If the underlying code change, class
was removed, renamed or moved, you get immediately very helpful error
message.
Does it make sense now?
P.S. Of course "mem_fun*s*" is just an example and every "query/select"
function has same behavior.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|