Re: [pygccxml-development] array_t vs pointer_t
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2006-04-11 17:52:10
|
On 4/11/06, Matthias Baas <ba...@ir...> wrote:
> Roman Yakovenko wrote:
> >> I'm wrapping a method that takes one single argument of type "double
> >> scale[3]". In the argument list of the corresponding declaration objec=
t
> >> this appears as a pointer_t object with a double_t object as base. Wha=
t
> >> I'm missing is the '3'.
> >> I noticed that pyplusplus defines a type array_t. Shouldn't the above
> >> argument be an array_t instead of a pointer_t to a double? Is this a b=
ug
> >> in pyplusplus, in gccxml or something else?
> >
> > I could be wrong, but this is how C/C++ works. Array is passed by point=
ers.
> > Am I wrong? Even if I wrong, GCC-XML reports this.
>
> That's too bad. :( The array size would have been a valuable piece of
> information for creating the wrappers. Without them I have to wade
> through ~250 methods manually to check if the arguments are really plain
> pointers or fixed size arrays as above (which seems to be the majority
> of cases in the Maya SDK)...
:-(.
First of all I will ask on GCC-XML list what could be done.
Second it is possible to implement solution using pygccxml only.
We can implement it and see how well it will work.
Description:
1. Please take a look on declarations/call_invocation.py module.
( There is some doc strings within it )
2. Please take a look on parser/patcher.py module.
Basically GCC-XML has few bugs/features that pygccxml corrects.
patch_it function is invoked from
source_reader_t.__parse_gccxml_created_file method for every parsed
file.
The idea is next: you can create your own patcher and rewrite/replace patch=
_it
with an other one. Every calldef declaration has location property initiali=
zed.
Thus you can get file path and line of declaration. Using type_traits
you can find
whether function has relevant type of arguments or not. After this you can =
go to
file, read original declaration, using call_invocation parser to split
it's arguments
and then find out whether it is array or not. After this you can replace ty=
pe of
argument to be an array of relevant type.
I don't say that this is a perfect method. But I think it will work in
most cases.
An other way to solve this issue is to create small parser, that will parse=
all
header files and will create table with relevant information. Then you
can just use
that information from your script. I use this trick with tnfox. Take a look=
on
examples/tnfox/declarations_to_exclude.py/find_deprecated function.
> In which case does pygccxml create an array_t object then?
When you have member/free variable declared as array:
const int items[23];
> - Matthias -
Hope this will help you.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|