com.smartclient.debug.public.sc.client.language.Object.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smartgwt Show documentation
Show all versions of smartgwt Show documentation
SmartGWT - GWT API's for SmartClient
The newest version!
/*
* Isomorphic SmartClient
* Version SC_SNAPSHOT-2011-08-08 (2011-08-08)
* Copyright(c) 1998 and beyond Isomorphic Software, Inc. All rights reserved.
* "SmartClient" is a trademark of Isomorphic Software, Inc.
*
* [email protected]
*
* http://smartclient.com/license
*/
isc.noOp = function () {};
isc.emptyObject = {};
isc._emptyArray = [];
// normal and obfuscatable name
isc.emptyString = isc._emptyString = "";
isc.dot = ".";
isc.semi = ";";
isc.colon = ":";
isc.slash = "/";
isc.star = "*";
isc.auto = "auto";
isc.px = "px";
isc.nbsp = " ";
isc.xnbsp = " "; // XHTML
isc._false = "false";
isc._falseUC = "FALSE";
isc._underscore = "_";
isc._dollar = "$";
isc._obsPrefix = "_$observed_";
isc._superProtoPrefix = "_$SuperProto_";
isc.gwtRef = "__ref";
//> @classMethod isc.logWarn()
// Same as +link{classMethod:Log.logWarn}.
//
// @param message (String) message to log
// @param [category] (String) category to log in, defaults to "Log"
//
// @visibility external
//<
isc.logWarn = function (message, category) { isc.Log.logWarn(message, category) }
//> @classMethod isc.echo()
// Same as +link{classMethod:Log.echo}.
//
// @param value (any) object to echo
// @return (string) a short string representation of the object
//
// @visibility external
//<
isc.echo = function (value) { return isc.Log.echo(value) }
//> @classMethod isc.echoAll()
// Same as +link{classMethod:Log.echoAll}.
//
// @param value (any) object to echo
// @return (string) a short string representation of the object
//
// @visibility external
//<
isc.echoAll = function (value) { return isc.Log.echoAll(value) }
//> @classMethod isc.echoLeaf()
// Same as +link{classMethod:Log.echoLeaf}.
//
// @param value (any) object to echo
// @return (string) a short string representation of the object
//
// @visibility external
//<
isc.echoLeaf = function (value) { return isc.Log.echoLeaf(value) }
isc.echoFull = function (value) { return isc.Log.echoFull(value) }
//> @classMethod isc.logEcho()
// Logs the echoed object (using +link{classMethod:isc.echo}) as a warning, prefixed with an
// optional message.
//
// @param value (any) object to echo
// @param message (String) message to log
//
// @see Log.logWarn() for logging info
// @visibility external
//<
isc.logEcho = function (value, message) {
if (message) message += ": ";
isc.Log.logWarn((message || isc._emptyString) + isc.echo(value))
}
//> @classMethod isc.logEchoAll()
// Logs the echoed object (using +link{classMethod:isc.echoAll}) as a warning, prefixed with an
// optional message.
//
// @param value (any) object to echo
// @param message (String) message to log
//
// @see Log.logWarn() for logging info
// @visibility external
//<
isc.logEchoAll = function (value, message) {
if (message) message += ": ";
isc.Log.logWarn((message || isc._emptyString) + isc.echoAll(value))
}
// OutputAsString / StackWalking / Tracing
// ---------------------------------------------------------------------------------------
isc._makeFunction = function (args, script) {
var code = script || args;
return script == null ? new Function(code) : new Function(args, code);
};
isc.doEval = function (code) {
// transform code and eval inline
if (isc.Browser.isMoz) return isc._transformCode(code);
//return isc._transformCode(code);
if (!isc._evalSet) isc._evalSet = [];
isc._evalSet[isc._evalSet.length] = code;
return null;
}
// called at module end
isc.finalEval = function () {
//!OBFUSCATEOK
if (isc._evalSet) {
if (isc.Browser.isMoz) {
for (var i = 0; i < isc._evalSet.length; i++) {
isc.eval(isc._evalSet[i]);
}
}
var code = isc._evalSet.join("");
if (isc.Browser.isSafari) code = isc._transformCode(code);
// uncomment to use catch/rethrow stacks in IE as well
//else if (isc.Browser.isIE) code = isc._transformCode(code);
if (isc.Browser.isIE) window.execScript(code, "javascript");
// Safari
else isc.eval(code);
// Init pipelining: set a timeout to eval so that the module init time takes place
// while the next module is being downloaded (except for the last module)
// Can't be used for real until
/*
var evalFunc = function () {
if (isc.Browser.isIE) window.execScript(code, "javascript");
// Safari
else isc.eval(code);
}
if (isc.module_DataBinding != 1) {
//if (isc.Log) isc.Log.logWarn("delaying eval");
setTimeout(evalFunc, 0)
} else {
evalFunc();
}
*/
}
isc._evalSet = null;
}
//isc._eitherMarker = /\/\/\$[01]/;
isc._startMarker = "//$0";
isc._endMarker = "//$1";
isc._totalTransformTime = 0;
// code transform time, all modules
// - Moz: about 140ms
// - NOTE: overall init time rises by about 400ms, the balance is due to slower parsing
// because of the added try/catch constructs. This can be demonstrated by doing the
// split/join, but just restoring the markers
// - Safari: about 300ms
// - IE: 266ms
// - NOTE: some key advantages of this approach as compared to server-side generation *aside
// from* not hosing IE's ability to do full stack traces w/o try/catch:
// - allows arbitrary start/end code to be added with only client-side changes
// - can be conditional per load
// - much smaller code size impact: could ship w/o local vars for production use
isc._addCallouts = true;
isc._transformCode = function (code) {
// set flag indicating stack walking is enabled so that we will also add try..catch to
// generated functions
isc._stackWalkEnabled = true;
var start = isc.timeStamp ? isc.timeStamp() : new Date().getTime();
var startCode = isc._tryBlock, endCode = isc._evalFromCatchBlock;
if (isc._addCallouts) startCode = isc._methodEnter + startCode;
var chunks = code.split(isc._eitherMarker),
finalCode = [];
var chunks = code.split(isc._startMarker);
code = chunks.join(startCode);
chunks = code.split(isc._endMarker);
code = chunks.join(endCode);
if (isc._addCallouts) {
chunks = code.split("//$2");
code = chunks.join(isc._methodExit);
}
/*
// approach of single split and join to cut down on String churn.
// Problem is that because of nested functions, markers do not alternate. Would need to
// detect which kind of marker is needed for a given slot, by eg checking the next char
// over, which might be expensive enough to wipe out any advantage; untested.
var pos = 0;
for (var i = 0; i < chunks.length; i++) {
finalCode[pos++] = chunks[i];
if (i < chunks.length-1) {
finalCode[pos++] = i % 2 == 0 ? isc._tryBlock : isc._evalFromCatchBlock;
}
}
finalCode = finalCode.join("");
try {
window.isc.eval(finalCode);
} catch (e) {
//if (!this._alerted) alert(finalCode.substring(0,5000));
//this._alerted = true;
document.write("chunks