Re: [pygccxml-development] How to do error checking?
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2006-09-12 11:29:04
|
On 9/12/06, Matthias Baas <ba...@ir...> wrote:
> Hi,
>
> I'm still at adding function transformer support to non-virtual
> functions. When transformers are applied to a set of methods, it can
> happen that several (overloaded) methods end up with an identical
> signature. Currently, this would result in an error during compilation
> because a function is redefined.
>
> So I'd like to check this and issue a warning in such cases. The check
> itself is no problem, but it requires sort of "global" data (namely a
> dictionary with the signatures that have been created so far) on a
> per-class basis.
>
> So there are two questions now:
>
> 1. Where should I store that data? (should I just add it to the class_t
> code creator instance?)
>
> 2. Does the Py++ design already specify where such a check should be
> done? (currently, I would probably do it in
> mem_fun_transformed_wrapper_t when the actual code gets generated)
I suspect that you still don't understand the design.
You need function signatures for 2 cases:
1. to register it ( def )
2. to check uniqueness
So, why don't you add to the "function ( final ) transformation_t"
class new method:
"signature". This method will return [member|free] function type. This
will solve you both
problems:
1. You will be able to generate code, that will include function
signature( type ) in it.
Take a look on generated code for overloaded functions.
2. In decl_wrappers.class_t you "override" _readme_impl method that
will check for
the "problems". This method will be called from
creator_t.prepare_decls method
Answer to the first question: you don't have to store "the data".
( Performance is not an issue ).
Answer to the second question: mem_fun_transformed_wrapper_t should concern on
code generation and nothing else. So, it is a wrong place to put this
functionality to it.
Does it sound reasonable to you?
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|