[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [MacPerl] Resource file hacking with MacPerl



At 11.31 -0400 1999.07.27, Creede Lambard (Volt Computer) wrote:
>I've wondered about creating a TieResources module that would do all this
>behind the scenes for you. There's a similar routine in ActivePerl for Win32
>called Win32::TieRegistry that automates a bunch of the dirty work of
>playing with the you-know-what on that platform, so it certainly seems like
>TieResources should be possible. I've brought my copy of Advanced Perl
>Programming in to work today just in case I run out of things to do and can
>play with Tie a little (not that that's very likely, mind you).

I don't think tie() would be needed here.  I envision a simple OOP interface.

  package Mac::Resources::Simple;  # original name, huh?
  use Mac::Resources;
  require Exporter;
  @ISA = 'Exporter';

  use constant RES => 0;
  use constant FILE => 1;

  sub new {
    my $pkg = shift;
    my $file = shift;
    my $res = FSpOpenResFile($file) or die $^E;
    return [$file, $res], $pkg;
  }

  sub DESTROY {
    my $self = shift;
    CloseResFile($self->[RES]);
  }

Then you can just add in all the other methods you want.  I suppose you
could do a scalar tie, and then use it with the actual Mac::Resources
functions, but I might do it this way.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org