Hi,

On Tuesday 30 March 2004 09:33, chromatic wrote:
> Hi all,
>
> With the improved object system in place, I've been porting the existing
> SDL Parrot bindings.  Here's a sample program that draws the friendly
> blue rectangle again:
>
> .pcc_sub _main non_prototyped, @MAIN
>       load_bytecode "library/sdl_app.imc"
>       load_bytecode "library/sdl_rect.imc"
>       load_bytecode "library/sdl_color.imc"
>
>       .sym pmc app
>       .sym int app_type
>
>       find_type app_type, 'SDL::App'
>       new app, app_type
>
>       .sym pmc args
>       new args, .PerlHash
>       set args['height'], 480
>       set args['width'],  640
>       set args['bpp'],      0
>       set args['flags'],    1
>
>       app.'_new'( args )
>
>       .sym pmc rect
>       .sym int rect_type
>
>       find_type rect_type, 'SDL::Rect'
>       new rect, rect_type
>
>       new args, .PerlHash
>       set args['height'], 100
>       set args['width'],  100
>       set args['x'],      270
>       set args['y'],      190
>
>       rect.'_new'( args )
>
>       .sym pmc color
>       .sym int color_type
>
>       find_type color_type, 'SDL::Color'
>       new color, color_type
>
>       new args, .PerlHash
>       set args['r'],  0
>       set args['g'],  0
>       set args['b'], 255
>
>       color.'_new'( args )
>
>       app.'_fill_rect'( rect, color )
>       app.'_update_rect'( rect )
>
>       sleep 2
>
>       app.'_quit'()
>       end
> .end
>
> As you can see, this is a lot simpler and quite a bit cleaner.  I'll add
> some documentation, port the existing examples to the new code, and
> check it in.
Why are you using an underscore in front of all method and label names? They 
are indicating global labels; it is not necessary to use them for method 
names.

> Any preferences whether these files are 'library/sdl_rect.imc' or
> 'library/sdl/rect.imc', by the way?
I vote for library/SDL/*.imc, because this is consistent with the original
C API file naming scheme.

> -- c
jens

Reply via email to