writing PMCs (documentation)

2004-05-07 Thread Nicholas Clark
I'm trying to find documentation on how to write PMCs. I can find lots of
PMCs in the source tree, but I can't seem to find documentation on how to
go about writing them, or what the various fields and flags do.

For example, the string PMC_data occurs in many source files, but as far
as I can tell nowhere in any documentation files, and there aren't many
comments about it in include/parrot/pobj.h

I don't find any documentation saying "if you do this you'll need to do that
in a destructor else you'll leak".

Am I missing something obvious?

Nicholas Clark


Re: writing PMCs (documentation)

2004-05-09 Thread Michael Scott
I just moved from Berlin to London and started a new job, so haven't 
had time recently for Parrot documentation. Indeed there is plenty to 
be done. I should be back on the case in a week or two.

Mike

On 7 May 2004, at 17:13, Simon Glover wrote:

 No. The closest we have to something like this is probably the stuff
 written by Mike Scott for the Wiki:
  
http://www.vendian.org/parrot/wiki/bin/view.cgi/Main/ParrotDiagramsPMC



Re: writing PMCs (documentation)

2004-05-07 Thread Simon Glover

On Fri, 7 May 2004, Nicholas Clark wrote:

> I'm trying to find documentation on how to write PMCs. I can find lots of
> PMCs in the source tree, but I can't seem to find documentation on how to
> go about writing them, or what the various fields and flags do.
>
> For example, the string PMC_data occurs in many source files, but as far
> as I can tell nowhere in any documentation files, and there aren't many
> comments about it in include/parrot/pobj.h
>
> I don't find any documentation saying "if you do this you'll need to do that
> in a destructor else you'll leak".
>
> Am I missing something obvious?

 No. The closest we have to something like this is probably the stuff
 written by Mike Scott for the Wiki:

  http://www.vendian.org/parrot/wiki/bin/view.cgi/Main/ParrotDiagramsPMC

 (Well, that plus the comments in pobj.h, which are somewhat opaque.)
 If no-one else volunteers, I'll try to put together something like this,
 as we do need it, but I'm unlikely to have sufficient tuits until the
 end of May :-(

 Simon




Re: writing PMCs (documentation)

2004-05-07 Thread Simon Glover

On Fri, 7 May 2004, Simon Glover wrote:
> On Fri, 7 May 2004, Nicholas Clark wrote:
>
> > I'm trying to find documentation on how to write PMCs. I can find lots of
> > PMCs in the source tree, but I can't seem to find documentation on how to
> > go about writing them, or what the various fields and flags do.
> >
> > For example, the string PMC_data occurs in many source files, but as far
> > as I can tell nowhere in any documentation files, and there aren't many
> > comments about it in include/parrot/pobj.h
> >
> > I don't find any documentation saying "if you do this you'll need to do that
> > in a destructor else you'll leak".
> >
> > Am I missing something obvious?
>
>  No. The closest we have to something like this is probably the stuff
>  written by Mike Scott for the Wiki:
>
>   http://www.vendian.org/parrot/wiki/bin/view.cgi/Main/ParrotDiagramsPMC
>
>  (Well, that plus the comments in pobj.h, which are somewhat opaque.)
>  If no-one else volunteers, I'll try to put together something like this,
>  as we do need it, but I'm unlikely to have sufficient tuits until the
>  end of May :-(

 Sorry to follow-up to myself, but I've thought of a few other things
 that are probably worth loooking at. First, PDD04 (datatypes) has
 some info on PMC internals, although this is incomplete, and possibly
 out of date...

 Second, when you come to implement the various vtable methods, you should
 probably look at PDD02, which is the closest thing to a comprehensive
 overview that we have, although I don't think it includes anything about
 the recent MMD-related changes that Dan has announced.

 Simon



Re: writing PMCs (documentation)

2004-05-07 Thread Leopold Toetsch
Nicholas Clark <[EMAIL PROTECTED]> wrote:
> I'm trying to find documentation on how to write PMCs. I can find lots of
> PMCs in the source tree, but I can't seem to find documentation on how to
> go about writing them, or what the various fields and flags do.

Well, there isn't too much documentation around. The flags are
documented in pobj.h. Existing PMCs should give you some hints.

WRT the fields: there are 2 rules of thumb:

- if the data fit into the UnionVal put it there
  (use appropriate members of the union)
  else you need the PMC_data allocated anyway.
- but if a PMC may point to other PMCs so that possibly deeply nested
  structures may result, it needs the C structure (denoted by
  need_ext) in the pmc file.

> I don't find any documentation saying "if you do this you'll need to do that
> in a destructor else you'll leak".

If your PMCs contains other managed objects like Buffers or PMCs, you
have to make sure, that they get marked properly. If you
mem_sys_allocate something during object creation, you need to set the
active_destroy flag and fill the destroy vtable.

> Am I missing something obvious?

No, not AFAIK. I always start writing a new PMC by copying a similar
one.

> Nicholas Clark

leo