From eb6c2a63469997d549ca0e41574922d5f71c53ae Mon Sep 17 00:00:00 2001 From: euzuro Date: Fri, 14 Jul 2006 12:59:08 +0000 Subject: [PATCH] first step of deprecating copyOf() functions, to be replaced with clone() git-svn-id: http://svn.openlayers.org/trunk/openlayers@943 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Util.js | 79 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 15 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 41edef870c..b60173f01c 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -41,9 +41,18 @@ OpenLayers.Pixel.prototype = { }, /** - * @type OpenLayers.Pixel - */ + * @deprecated + * + * @type OpenLayers.Pixel + */ copyOf:function() { + return this.clone(); + }, + + /** + * @type OpenLayers.Pixel + */ + clone:function() { return new OpenLayers.Pixel(this.x, this.y); }, @@ -124,10 +133,20 @@ OpenLayers.Size.prototype = { }, /** - * @return New OpenLayers.Size object with the same w and h values - * @type OpenLayers.Size - */ + * @deprecated + * + * @return New OpenLayers.Size object with the same w and h values + * @type OpenLayers.Size + */ copyOf:function() { + return this.clone(); + }, + + /** + * @return New OpenLayers.Size object with the same w and h values + * @type OpenLayers.Size + */ + clone:function() { return new OpenLayers.Size(this.w, this.h); }, @@ -193,10 +212,20 @@ OpenLayers.LonLat.prototype = { }, /** - * @return New OpenLayers.LonLat object with the same lon and lat values - * @type OpenLayers.LonLat - */ + * @deprecated + * + * @return New OpenLayers.LonLat object with the same lon and lat values + * @type OpenLayers.LonLat + */ copyOf:function() { + return this.clone(); + }, + + /** + * @return New OpenLayers.LonLat object with the same lon and lat values + * @type OpenLayers.LonLat + */ + clone:function() { return new OpenLayers.LonLat(this.lon, this.lat); }, @@ -288,10 +317,20 @@ OpenLayers.Bounds.prototype = { }, /** - * @returns A fresh copy of the bounds - * @type OpenLayers.Bounds - */ + * @deprecated + * + * @returns A fresh copy of the bounds + * @type OpenLayers.Bounds + */ copyOf:function() { + return this.clone(); + }, + + /** + * @returns A fresh copy of the bounds + * @type OpenLayers.Bounds + */ + clone:function() { return new OpenLayers.Bounds(this.left, this.bottom, this.right, this.top); }, @@ -609,16 +648,26 @@ Array.prototype.remove = function(item) { return this; } +/** + * @deprecated + * + * @returns A fresh copy of the array + * @type Array + */ +Array.prototype.copyOf = function() { + return this.clone(); +}; + /** * @returns A fresh copy of the array * @type Array */ -Array.prototype.copyOf = function() { - var copy = new Array(); +Array.prototype.clone = function() { + var clone = new Array(); for (var i = 0; i < this.length; i++) { - copy[i] = this[i]; + clone[i] = this[i]; } - return copy; + return clone; }; /**