1. RE: Win4Eu update

Tommy Carlier wrote:

<SNIP> 

> Although Win4Eu hides the low-level stuff for regular users, you can
> still access all the low-level features. An example: structures. You
> can create structures, like you create regular objects, with the 
> create-verb. Here's a simple definition of a structure, and how you
> create an instance:
> }}}
<eucode>
> constant POINT = defineStructure("POINT", {
>    {"x", Int},
>    {"y", Int}
> })
> 
> integer pt, size
> atom address
> pt = create(POINT, "pt", {})
> pokeField(pt, "x", 0, 100)
> pokeField(pt, "y", 0, 100)
> size = getStructureSize(pt) -- get the size in bytes
> address = getStructureAddress(pt) -- get the physical address
> 
> destroy(pt) -- release the memory
> </eucode>
{{{

>
> I will try to make it as easy as possible for people to create
> Windows applications. And another advantage of the object-oriented
> architecture is extensibility: it will be easy to create new controls
> and treat them exactly the same as regular controls (what I earlier
> tried to do with EuControls). 
> 
> --
> tommy online: http://users.telenet.be/tommycarlier
> tommy.blog: http://tommycarlier.blogspot.com
> Euphoria Message Board: http://uboard.proboards32.com
> Empire for Euphoria: http://empire.iwireweb.com

Have you seen structs.e? The version in the RDS contribs is fairly old, 
but still it works well. It's very much like what you have there.

I've got an updated version, that I built for the empire set.
It goes like this..

constant RECT = define_struct({
  {"left",  LONG}
 ,{"top",   LONG}
 ,{"right", LONG}
 ,{"bottom",LONG}
})

atom lprect
lprect = alloc_struct(RECT)

pokes(lprect,{0,0,100,100})
? peeks(lprect) -- print all members
? peeks({lprect,"right"}) -- print the "right" member
? sizeOf(lprect) -- print the size of the struct
? sizeOf({lprect,"left"}) -- print the size of the left member
dealloc_struct(lprect)


There is also addressOf() and offsetOf(), etc..
It also supports arrays, unions, externally allocated structs, and other 
stuff.


Chris Bensler
Code is Alchemy

new topic     » topic index » view message » categorize

2. RE: Win4Eu update

Chris Bensler wrote:
> Tommy Carlier wrote:
> <SNIP> 
> Have you seen structs.e? The version in the RDS contribs is fairly old, 
> but still it works well. It's very much like what you have there.

Yes, I have. I've looked at different libraries that do what I want, and
I actually considered using existing libraries, but my idea of Win4Eu is
a solid uniform core, and components built on that core.
I think structs.e is one of the best structure-libraries i found, and it
has a really easy interface. As you can see, it actually inspired me.
But I wanted structures to be objects like the other objects. Actually,
the Structure-class is not a base-class, but inherits from the Allocator-
class: an Allocator allows you to allocate memory-blocks, and a Structure
is just an allocator that is structured (it has named fields).

> I've got an updated version, that I built for the empire set.
> It goes like this..
> 
> }}}
<eucode>
> constant RECT = define_struct({
>   {"left",  LONG}
>  ,{"top",   LONG}
>  ,{"right", LONG}
>  ,{"bottom",LONG}
> })
> 
> atom lprect
> lprect = alloc_struct(RECT)
> 
> pokes(lprect,{0,0,100,100})
> ? peeks(lprect) -- print all members
> ? peeks({lprect,"right"}) -- print the "right" member
> ? sizeOf(lprect) -- print the size of the struct
> ? sizeOf({lprect,"left"}) -- print the size of the left member
> dealloc_struct(lprect)
> </eucode>
{{{

> 
> There is also addressOf() and offsetOf(), etc..
> It also supports arrays, unions, externally allocated structs, and other 
> stuff.

Win4Eu structures behave like this:
constant myStructure = defineStructure("myStructure", {
   {"Name", String},
   {"Age", Int},
   {"Address", String}
})

integer x
x = create(myStructure, "x", {})

atom address
integer size, age
address = getStructureAddress(x)
size = getStructureSize(x)
pokeField(x, "Name", 0, "Chris")
age = peekField(x, "Age", 0)

destroy(x)


--
tommy online: http://users.telenet.be/tommycarlier
tommy.blog: http://tommycarlier.blogspot.com
Euphoria Message Board: http://uboard.proboards32.com
Empire for Euphoria: http://empire.iwireweb.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu