[C++-sig] Boost.Python code generator

Nicodemus nicodemus at globalite.com.br
Fri Dec 6 15:47:06 CET 2002


Niki Spahiev wrote:

> Why not borrow syntax (and parser) from Pyrex?

I will probably use the Pyrex parser, Plex.

> Also maybe swig-xml to interface can work for generating initial 
> contents. 

Good idea. But I will probably worry about this only later. 8)

> Whatever it is i have plan how to use it.

Nice to know. 8)


I have some changes in the interface file, and would like to know your 
opinion...
I followed David's suggestion to make the syntax look a little more like 
C++:

class IRawImage : base IRasterImage, base IColorMatch
    IRawImage()
    IRawImage( const IRawImage& )
    IRawImage( const I2DISize &, unint, unint )
    IRawImage( const I2DISize &, unint, unint, const IColorMatch & )

    # constructors for this class. No secrets here.
    # If the user doesn't declare any constructors, the class will be
    # created with the "no_init" flag. If no copy constructor is defined,
    # it will be created with the "boost::noncopyable" flag.


    def void Reconstruct( const I2DISize &, unint, unint = )
    def void Reconstruct( const I2DISize &, unint, unint, const 
IColorMatch & )

    # since here we have overloads for this function, we have to declare 
the types
    # to be able to generate the correct code. Also, the "=" after a 
parameter
    # indicates a default parameter.


    def SetColorMatch : return internal_ref
    def IColorMatch & ColorMatch() : return internal_ref
        def operator= : rename Assign, return internal_ref

    # call policies in action. After a function declaration, options can 
be declared with
    # a ":" character. Options include call policies, rename options, etc.


    def Size
    def DataSize
    def Alignment
    def WidthInBytes
    def BytesUsed

    # simple functions that are not overloaded, and don't have default 
params


    operator + IRawImage
    operator & IRawImage
    operator ~
    # some operators


Regards,
Nicodemus.






More information about the Cplusplus-sig mailing list