Fieldmapper.prototype.clone = function() {
var obj = new this.constructor();
- for( var i in this.array ) {
- var thing = this.array[i];
+ for( var i in this.a ) {
+ var thing = this.a[i];
if(thing == null) continue;
if( thing._isfieldmapper ) {
- obj.array[i] = thing.clone();
+ obj.a[i] = thing.clone();
} else {
if(instanceOf(thing, Array)) {
- obj.array[i] = new Array();
+ obj.a[i] = new Array();
for( var j in thing ) {
if( thing[j]._isfieldmapper )
- obj.array[i][j] = thing[j].clone();
+ obj.a[i][j] = thing[j].clone();
else
- obj.array[i][j] = thing[j];
+ obj.a[i][j] = thing[j];
}
} else {
- obj.array[i] = thing;
+ obj.a[i] = thing;
}
}
}
my $short_name = $map->{$object}->{hint};
-print <<JS;
-
-// ----------------------------------------------------------------
-// Class: $short_name
-// ----------------------------------------------------------------
-
-JS
-
print <<JS;
-
$short_name.prototype = new Fieldmapper();
$short_name.prototype.constructor = $short_name;
$short_name.baseClass = Fieldmapper.constructor;
-function $short_name(array) {
-
+function $short_name(a) {
this.classname = "$short_name";
this._isfieldmapper = true;
-
- if(array) {
- if( array.constructor == Array)
- this.array = array;
-
+ if(a) {
+ if( a.constructor == Array)
+ this.a = a;
else
throw new FieldmapperException(
"Attempt to build fieldmapper object with non-array");
-
- } else { this.array = []; }
-
+ } else this.a = [];
}
$short_name._isfieldmapper = true;
-
-
JS
for my $field (keys %{$map->{$object}->{fields}}) {
my $position = $map->{$object}->{fields}->{$field}->{position};
print <<JS;
-$short_name.prototype.$field = function(new_value) {
- if(arguments.length == 1) { this.array[$position] = new_value; }
- return this.array[$position];
-}
+$short_name.prototype.$field = function(n) {if(arguments.length == 1) this.a[$position] = n; return this.a[$position]; }
JS
}