[Bps-public-commit] r14024 - in Data-Plist: .

alexmv at bestpractical.com alexmv at bestpractical.com
Fri Jul 11 15:51:12 EDT 2008


Author: alexmv
Date: Fri Jul 11 15:51:11 2008
New Revision: 14024

Modified:
   Data-Plist/   (props changed)
   Data-Plist/lib/Data/Plist.pm

Log:
 r34075 at kohr-ah:  chmrr | 2008-07-11 15:49:42 -0400
  * Clean out leftocre "use" statements
  * ->object takes a prefix to bless under


Modified: Data-Plist/lib/Data/Plist.pm
==============================================================================
--- Data-Plist/lib/Data/Plist.pm	(original)
+++ Data-Plist/lib/Data/Plist.pm	Fri Jul 11 15:51:11 2008
@@ -3,20 +3,12 @@
 use strict;
 use warnings;
 
-use Encode qw(decode encode);
-use Fcntl qw(:seek);
 use DateTime;
-use POSIX ();
-use Math::BigInt;
-use MIME::Base64;
 use UNIVERSAL::require;
 
-use vars qw/$VERSION/;
-$VERSION = "1.5";
-
 sub new {
     my $class = shift;
-    return bless { uids => undef, data => undef, @_ } => $class;
+    return bless { data => undef, @_ } => $class;
 }
 
 sub collapse {
@@ -98,19 +90,19 @@
 
 sub reify {
     my $self = shift;
-    my $data = shift;
+    my($data, $prefix) = @_;
 
     return $data unless ref $data;
     if (ref $data eq "HASH") {
         my $hash = { %{$data} };
         my $class = delete $hash->{'$class'};
-        $hash->{$_} = $self->reify($hash->{$_}) for keys %{$hash};
+        $hash->{$_} = $self->reify($hash->{$_}, $prefix) for keys %{$hash};
         if ($class and ref $class and ref $class eq "HASH" and $class->{'$classname'}) {
             my $classname = "Foundation::" . $class->{'$classname'};
             if (not $classname->require) {
                 warn "Can't require $classname: $@\n";
-            } elsif (not $classname->isa("Foundation::NSObject")) {
-                warn "$classname isn't a Foundation::NSObject\n";
+            } elsif (not $classname->isa($prefix . "::NSObject")) {
+                warn "$classname isn't a @{[$prefix]}::NSObject\n";
             } else {
                 bless($hash, $classname);
                 $hash = $hash->replacement;
@@ -118,7 +110,7 @@
         }
         return $hash;
     } elsif (ref $data eq "ARRAY") {
-        return [map $self->reify($_), @{$data}];
+        return [map $self->reify($_, $prefix), @{$data}];
     } else {
         return $data;
     }
@@ -132,8 +124,20 @@
 
 sub object {
     my $self = shift;
+    my $prefix = shift;
+
+    my $base = $prefix . "::NSObject";
+    unless ($base->require) {
+        warn "Can't require base class $base: $@\n";
+        return;
+    }
+    
     return unless $self->is_archive;
-    return $self->reify($self->collapse($self->raw_object));
+    return $self->reify($self->collapse($self->raw_object), $prefix);
+}
+
+sub serialize {
+    my $self = shift;
 }
 
 1;



More information about the Bps-public-commit mailing list