[C++-sig] Pyste: support for user defined code.
Nicodemus
nicodemus at globalite.com.br
Sat Aug 16 21:51:50 CEST 2003
Hi Prabhu!
Prabhu Ramachandran wrote:
>>>>>>"N" == nicodemus <nicodemus at globalite.com.br> writes:
>>>>>>
>>>>>>
>
> N> Prabhu Ramachandran wrote:
> >> Hi,
> >>
> >> I was thinking of adding a new feature to Pyste so that a user
> >> could add arbitrary code to the code generated by Pyste.
> >> Something along these lines:
> >>
> >> ud = UserDefined() ud.addToHeader(['h1.hpp', 'h2.hpp'])
> >> ud.addToDeclaration("""// insert code in the declaration area
> >> """) ud.addToModule("""// insert code inside the module
> >> area""")
>
> N> Seems easy, but I think a more functional interface would fit
> N> with the rest better:
>
> N> add_include('h1.hpp', 'h2.hpp') add_code(MODULE, '''
> N> class_< std::vector<bool> > ("VectorBool")
> N> .def(vector_indexing_suite< std::vector<bool>,
> N> true> ());''')
>
>Thats fine too but will there be a problem with ordering of the code
>if the interface is functional? i.e. if I have a class('A', 'h.hpp')
>and then want to add the user defined code after this, is it possible
>to do with this approach? I also thought that the UserDefined
>approach would be easier to implement.
>
Yeah, no problem. The ordering is kept, since the exporters are kept in
a list.
So, how about this interface:
add_include('header1', 'header2', 'header3')
add_code(MODULE, <code>)
add_code(DECLARATION, <code>)
add_code(GLOBAL_DECLARATION, <code>) # outside the namespace generated
by pyste.
# Any suggestions for a better name?
Does it cover all the needs, or am I missing something? 8)
I plan to work on this tomorrow, or perhaps a little today. Any
suggestions are appreciated!!
Regards,
Nicodemus.
More information about the Cplusplus-sig
mailing list