Hildo Biersma <[EMAIL PROTECTED]> wrote:

> This thread got side-track with perl5 issues, so let me ask again:

> - Are there any examples of creating a PMC class that maps to a C
>   structure, with the PMC class (in C) setting defaults and adding
>   accessor methods?

The UnmanagedStruct PMC allows accessing of structure elements. Classes
provide namespace and methods. But it should be possible to provide both
functionality in one PMC if you really want a full (C++) class
emulation.

You could have a look at "ncurses.imc", which is used by my "slides"
presentation program. You can find it in the tarball at:
http://toetsch.at/parrot/
below "Parrot slides".
It wraps ncurses NCI functions and provides a class interface for PIR.

Youl'll find more complex structures in CVS in the SDL library:

runtime/parrot/library/SDL.imc
runtime/parrot/library/SDL/*
examples/sdl/*

> - How do I define a class with constant values that are accessible to
>   other classes?  E.g. I want to be able to use constants like this
>   pseudo-code:

>     OpenOptions.Flags = WMQ.MQC.MQOO_READ_ONLY

>   where MQOO_READ_ONLY is a typed constant that lives in the WMQ.MQC
>   class.

I'd just create an include file with the constants. The dot isn't
allowed in identifiers, so you would need a bit of name mangling.

 # your_lib.inc

 .const int WMQ::MQC::MQOD_READ_ONLY = 42

or

 # your_lib.pasm

 .constant WMQ::MQC::MQOD_READ_ONLY  42

That would get included and parsed during compilation of the module using
the include file. The former creates an identifier with that name, the
second is a macro definition and needs a dot in front during usage.

leo

Reply via email to