Re: [pygccxml-development] mdecl and methods that return values
Brought to you by:
mbaas,
roman_yakovenko
|
From: Allen B. <al...@vr...> - 2006-05-31 14:11:21
|
Roman Yakovenko wrote:
> On 5/30/06, Roman Yakovenko <rom...@gm...> wrote:
>
>> Allen, I tried the patch and there are some errors in unit tests.
>> I will try to fix it tommorrow and commit. I will let you know.
>
>
> 1. __getitem__ has been changed a little:
>
> def __getitem__( self, index ):
> """provides access to declaration.
> If passed a standard index, then return contained decl.
> Else call the getitem method of contained decls.
> """
> if isinstance(index, ( int, slice ) ):
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> return self.decls[index]
> else:
> return call_redirector_t( '__getitem__', self.decls)(index)
>
> slice has been added.
>
> But still patch does not work:
>
> class X{ X(){} };
>
> global_ns['X'].meber_functions()
>
> Will raise an error: AttributeError: 'constructor_t' object has no
> attribute '__getitem__'
I would have to look into this further, but what is calling __getitem__
on a constructor_t object?
It looks like __getitem__ is being called on a namespace, but that
should be allowed since a namespace is a scopedef_t.
> The query breaks precondition of
> call_redirector_t.__call__ : I assume that all functions will return
> same type
> We don't have list of same objects. So mdecl_wrapper_t.__getitem__ can
> not
> return call_redirector_t( '__getitem__', self.decls)(index) :-(.
>
Maybe the precondition should be modified slightly. Maybe the
precondition should be that all objects returned can be wrapped with in
a mdecl. So the preconditions would be the same as those for creating
an mdecl. And unless I am missing something, an mdecl can wrap objects
of different types.
For example a call like:
mfs = my_class.member_functions()
Will return an mdecl that wraps constructors, calldefs, and any other
types of members.
-Allen
> Without good definition I don't know how to fix this. So, if you don't
> mind I will not apply
> the patch.
>
|