Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Keyed Access to UnManagedStruct?

6 views
Skip to first unread message

Chromatic

unread,
Feb 8, 2004, 3:55:58 PM2/8/04
to perl6-i...@perl.org
Hi there,

What's the best way to access fields within an UnManagedStruct, one
returned from an NCI call? For example, if I call _new_SDL_Screen, how
can I access the w and h fields of the SDL_Surface it returns?

I've tried creating an OrderedHash called layout and then doing:

set screen, layout

Is there a better way? I can provide more code if necessary.

-- c

Leopold Toetsch

unread,
Feb 8, 2004, 6:06:34 PM2/8/04
to Chromatic, perl6-i...@perl.org
Chromatic <chro...@wgz.org> wrote:
> Hi there,

> What's the best way to access fields within an UnManagedStruct, one
> returned from an NCI call? For example, if I call _new_SDL_Screen, how
> can I access the w and h fields of the SDL_Surface it returns?

> I've tried creating an OrderedHash called layout and then doing:

> set screen, layout

Above statement just aliases both P-registers to point to the same thing,

_new_SDL_screen has a return type of 'p' - that is an UnManagedStruct
pointing to that. You know, that the return type is a struct screen *.

So you create an initializer for that struct (above layout? - a bad name
BTW) and *assign* it to the screen:

assign screen, screen_struct_layout
w = screen["w"] # presumed your struct initializer defines that

s. docs/pmcs/struct.pod

> ... I can provide more code if necessary.

If its still not clear, yes please.

> -- c

leo

Chromatic

unread,
Feb 9, 2004, 4:07:52 PM2/9/04
to l...@toetsch.at, perl6-i...@perl.org
On Sun, 2004-02-08 at 15:06, Leopold Toetsch wrote:

> So you create an initializer for that struct (above layout? - a bad name
> BTW) and *assign* it to the screen:
>
> assign screen, screen_struct_layout
> w = screen["w"] # presumed your struct initializer defines that
>
> s. docs/pmcs/struct.pod

Hmm, I wasn't adding the _struct property for struct pointers, but it
looks like I should do that. That's workable.

Now, I'm seeing an odd error whenever I use the 'loadlib' op, though:

set_pmc_keyed_str() not implemented in class 'PerlInt'

The backtrace oddness starts in imcc/parser.c 352, when it calls
Parrot_load_lib().

-- c

Leopold Toetsch

unread,
Feb 9, 2004, 4:34:16 PM2/9/04
to Chromatic, perl6-i...@perl.org
Chromatic <chro...@wgz.org> wrote:
> Now, I'm seeing an odd error whenever I use the 'loadlib' op, though:

> set_pmc_keyed_str() not implemented in class 'PerlInt'

Time for an example ;)

leo

Chromatic

unread,
Feb 9, 2004, 4:40:08 PM2/9/04
to l...@toetsch.at, perl6-i...@perl.org
On Mon, 2004-02-09 at 13:34, Leopold Toetsch wrote:

I see it on examples/sdl/anim_parrot_logo.imc with a fresh build.

-- c

Chromatic

unread,
Feb 9, 2004, 8:56:16 PM2/9/04
to l...@toetsch.at, perl6-i...@perl.org
On Mon, 2004-02-09 at 13:40, chromatic wrote:

> I see it on examples/sdl/anim_parrot_logo.imc with a fresh build.

Oops, now I don't. Ignore that; I'll have a better example of weirdness
shortly.

-- c

0 new messages