--- nfo/php/libs/org.netfrag.glib/Data/Lift.php 2003/02/22 16:20:04 1.1
+++ nfo/php/libs/org.netfrag.glib/Data/Lift.php 2003/02/27 16:30:17 1.2
@@ -1,8 +1,13 @@
// -------------------------------------------------------------------------
-// $Id: Lift.php,v 1.1 2003/02/22 16:20:04 joko Exp $
+// $Id: Lift.php,v 1.2 2003/02/27 16:30:17 joko Exp $
// -------------------------------------------------------------------------
// $Log: Lift.php,v $
+// Revision 1.2 2003/02/27 16:30:17 joko
+// + enhanced '_autodetect'
+// + added '_check'
+// + now throughout returning lifted values by reference
+//
// Revision 1.1 2003/02/22 16:20:04 joko
// + initial commit
//
@@ -38,23 +43,51 @@
function set(&$payload, $metatype = '') {
$this->payload = &$payload;
+
if ($metatype) { $this->metatype = $metatype; }
$this->_autodetect();
+ $this->_check();
}
function _autodetect() {
+
// FIXME: distinguish between is_array and is_hash here!
- if (is_array($this->payload)) {
+ if (is_object($this->payload)) {
+ $this->vartype = 'object';
+ $this->metatype = get_class($this->payload);
+ if ($parent_class = get_parent_class($this->payload)) {
+ $this->metatype = $parent_class;
+ }
+
+ } elseif (is_array($this->payload)) {
$this->vartype = 'hash';
+
+ } else {
+ $this->vartype = 'scalar';
+
}
}
- function to($level) {
+ function _check() {
+
+ $good = $this->vartype && $this->metatype;
+
+ //print "metatype: " . $this->metatype . "
";
+
+ if (!$good) {
+ print "Data::Lift cannot handle this payload: ";
+ print "(vartype=" . $this->vartype . ", metatype=" . $this->metatype . ")
";
+ print Dumper($this->payload);
+ }
+
+ }
+
+ function &to($level) {
$this->_resolve_location($level);
//print Dumper($this->actor);
//exit;
//$result = array( name => 'abc', description => 'def' );
- $result = $this->_perform_actor();
+ $result = &$this->_perform_actor();
return $result;
}
@@ -74,7 +107,7 @@
}
- function _perform_actor() {
+ function &_perform_actor() {
//$actor_file = join('/', $this->actor) . '.php';
//include($actor_file);
$actor_name = 'Data/Lift/' . join('/', $this->actor);