Fix build problems.

Review URL: http://codereview.chromium.org/543087

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3622 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ccd760ae
......@@ -364,6 +364,11 @@ DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
FILE* fp = OS::FOpen(name.start(), "ra");
int new_size, pointer_size, data_size, code_size, map_size, cell_size;
int large_size;
#ifdef _MSC_VER
// Avoid warning about unsafe fscanf from MSVC.
// Please note that this is only fine if %c and %s are not being used.
#define fscanf fscanf_s
#endif
CHECK_EQ(1, fscanf(fp, "new %d\n", &new_size));
CHECK_EQ(1, fscanf(fp, "pointer %d\n", &pointer_size));
CHECK_EQ(1, fscanf(fp, "data %d\n", &data_size));
......@@ -371,6 +376,9 @@ DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
CHECK_EQ(1, fscanf(fp, "map %d\n", &map_size));
CHECK_EQ(1, fscanf(fp, "cell %d\n", &cell_size));
CHECK_EQ(1, fscanf(fp, "large %d\n", &large_size));
#ifdef _MSC_VER
#undef fscanf
#endif
fclose(fp);
Heap::ReserveSpace(new_size,
pointer_size,
......
......@@ -26,57 +26,57 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Object.extend = function (dest, source) {
for (property in source) dest[property] = source[property];
return dest;
for (property in source) dest[property] = source[property];
return dest;
};
Object.extend ( Function.prototype,
{
wrap : function (wrapper) {
var method = this;
var bmethod = (function(_method) {
return function () {
this.$$$parentMethodStore$$$ = this.$proceed;
this.$proceed = function() { return _method.apply(this, arguments); };
};
})(method);
var amethod = function () {
this.$proceed = this.$$$parentMethodStore$$$;
if (this.$proceed == undefined) delete this.$proceed;
delete this.$$$parentMethodStore$$$;
};
var value = function() { bmethod.call(this); retval = wrapper.apply(this, arguments); amethod.call(this); return retval; };
return value;
}
wrap : function (wrapper) {
var method = this;
var bmethod = (function(_method) {
return function () {
this.$$$parentMethodStore$$$ = this.$proceed;
this.$proceed = function() { return _method.apply(this, arguments); };
};
})(method);
var amethod = function () {
this.$proceed = this.$$$parentMethodStore$$$;
if (this.$proceed == undefined) delete this.$proceed;
delete this.$$$parentMethodStore$$$;
};
var value = function() { bmethod.call(this); retval = wrapper.apply(this, arguments); amethod.call(this); return retval; };
return value;
}
});
String.prototype.cap = function() {
return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
};
String.prototype.cap = String.prototype.cap.wrap(
function(each) {
if (each && this.indexOf(" ") != -1) {
return this.split(" ").map(
function (value) {
return value.cap();
}
).join(" ");
} else {
return this.$proceed();
}
function(each) {
if (each && this.indexOf(" ") != -1) {
return this.split(" ").map(
function (value) {
return value.cap();
}
).join(" ");
} else {
return this.$proceed();
}
});
Object.extend( Array.prototype,
{
map : function(fun) {
if (typeof fun != "function") throw new TypeError();
var len = this.length;
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++) { if (i in this) res[i] = fun.call(thisp, this[i], i, this); }
return res;
}
map : function(fun) {
if (typeof fun != "function") throw new TypeError();
var len = this.length;
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++) { if (i in this) res[i] = fun.call(thisp, this[i], i, this); }
return res;
}
});
assertEquals("Test1 test1", "test1 test1".cap());
assertEquals("Test2 Test2", "test2 test2".cap(true));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment