Re: preprocessor

new topic     » goto parent     » topic index » view thread      » older message » newer message

Bernard Ryan wrote:

> include mixedlib.e
> --
>   record("RECT", ---------- if using mixedlib.e then define RECT
>     "left   : int : 1 "& -- RECT is already predefined in w32engin.ew
>     "top    : int : 1 "&
>     "right  : int : 1 "&
>     "bottom : int : 1 ")
> 
> -- RECT rect
> -- rect = new (RECT)
> -- rect.left = 66
> atom rect
>   rect = struc("RECT") -- creates new RECT initialized to zeros.
>   put(rect,"left",66)


Your definition of structure is simpler than what I do.
But using put(rect,"left",66) instead of rect[RECT_LEFT]=66? I still like the
latter more. And put(rect,"left",66) must be slower. I need all the speed I can
get. :)

I've come up with this to define "structure", it's a little prettier:

    constant RECT_LEFT = 1
    constant RECT_TOP = 2
    constant RECT_RIGHT = 3
    constant RECT_BOTTOM = 4
    type RECT (object rect)
        if not check_struct ({
            rect, "sequence",
            {RECT_LEFT, "integer"},
            {RECT_TOP, "integer"},
            {RECT_RIGHT, "integer"},
            {RECT_BOTTOM, "integer"}
            }) then
            return false
        end if
        return true
    end type

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu